fix(of): postfx GLSL 150 + bloom GUI default 0.15
Deep analyse du bug "écran blanc avec FX" :
1. postfx.vert utilisait gl_Vertex / gl_MultiTexCoord0 (GLSL 120
built-ins compat profile) — non disponibles en GL 3.2 core sur
macOS. Le shader ne compilait probablement pas, le fallback de
PostFx::draw dessinait fboScene_ brut (sans tone-map ni clamp),
d'où le blanc en mode Hybrid (additif sature en RGBA8).
2. fxBloom_.setup("bloom", 0.4f, ...) dans ofApp.cpp ligne 119
hardcodait la valeur GUI à 0.4 — les fix précédents touchaient
PostFx.h::Params::bloom qui est ignoré (la GUI pilote le shader).
Approach:
- postfx.vert : #version 150, in/out, attributs nommés (position,
texcoord) injectés par oF.
- postfx.frag : #version 150, varying → in, gl_FragColor → out
fragColor, texture2DRect → texture (sampler2DRect reste, mais
texture() le résout en GLSL 150).
- ofApp.cpp : fxBloom_ default 0.4 → 0.15.
- PostFx::reloadShader log error si le compile échoue, pour
pouvoir confirmer le diag dans la console oF.
- WaveformVis::draw : slow trace dessiné AVANT les traces audio
(en arrière-plan, pas par-dessus).
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#version 120
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
#version 150
|
||||
|
||||
// Composite post-processing pass. Each effect is gated by an intensity
|
||||
// uniform — set to 0 to skip its branch. Order matters: spatial /
|
||||
// kaleido first (work in UV), then color / chromatic / glitch.
|
||||
// macOS GL 3.2 core : sampler2DRect + texture() (sans 2DRect).
|
||||
|
||||
uniform sampler2DRect uScene;
|
||||
uniform sampler2DRect uPrev;
|
||||
@@ -25,7 +25,8 @@ uniform float uFbRot;
|
||||
uniform float uGlitch;
|
||||
uniform float uGlitchProb;
|
||||
|
||||
varying vec2 vTex;
|
||||
in vec2 vTex;
|
||||
out vec4 fragColor;
|
||||
|
||||
const float TAU = 6.2831853;
|
||||
|
||||
@@ -89,9 +90,9 @@ void main() {
|
||||
// 4. Chromatic aberration : RGB channels sampled at radial offsets
|
||||
vec2 dir = c * uChroma * 14.0;
|
||||
vec3 col;
|
||||
col.r = texture2DRect(uScene, clamp(glUv + dir, vec2(0.0), uRes - 1.0)).r;
|
||||
col.g = texture2DRect(uScene, glUv).g;
|
||||
col.b = texture2DRect(uScene, clamp(glUv - dir, vec2(0.0), uRes - 1.0)).b;
|
||||
col.r = texture(uScene, clamp(glUv + dir, vec2(0.0), uRes - 1.0)).r;
|
||||
col.g = texture(uScene, glUv).g;
|
||||
col.b = texture(uScene, clamp(glUv - dir, vec2(0.0), uRes - 1.0)).b;
|
||||
|
||||
// 5. Glitch channel swap
|
||||
if (uGlitch > 0.55) {
|
||||
@@ -105,7 +106,7 @@ void main() {
|
||||
float w = 4.0 + uBloom * 12.0;
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
for (int j = -2; j <= 2; j++) {
|
||||
vec3 s = texture2DRect(uScene,
|
||||
vec3 s = texture(uScene,
|
||||
clamp(uv + vec2(i, j) * w, vec2(0.0), uRes - 1.0)).rgb;
|
||||
float lum = max(max(s.r, s.g), s.b);
|
||||
bl += s * smoothstep(0.45, 1.0, lum);
|
||||
@@ -133,7 +134,7 @@ void main() {
|
||||
fc = rot2(fc, uFbRot);
|
||||
fc += uRes * 0.5;
|
||||
fc = clamp(fc, vec2(0.0), uRes - 1.0);
|
||||
vec3 prev = texture2DRect(uPrev, fc).rgb * 0.96;
|
||||
vec3 prev = texture(uPrev, fc).rgb * 0.96;
|
||||
col = max(col, prev * uFeedback * 1.5);
|
||||
}
|
||||
|
||||
@@ -161,5 +162,5 @@ void main() {
|
||||
// valeur d'entrée 1.0 mappe à ~0.375, 5.0 à ~0.75, jamais à 1.0.
|
||||
col = (col * 0.6) / (1.0 + col * 0.6);
|
||||
col = clamp(col, 0.0, 1.0);
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
fragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 120
|
||||
// openFrameworks injects modelViewProjectionMatrix and the standard
|
||||
// gl_Vertex / gl_MultiTexCoord0 inputs in compatibility mode.
|
||||
#version 150
|
||||
|
||||
// macOS oF 0.12 tourne en GL 3.2 core profile : pas de gl_Vertex /
|
||||
// gl_MultiTexCoord0 (built-ins legacy). On utilise les attributs nommés
|
||||
// que oF injecte automatiquement (cf. glow.vert / bloom.vert).
|
||||
uniform mat4 modelViewProjectionMatrix;
|
||||
varying vec2 vTex;
|
||||
in vec4 position;
|
||||
in vec2 texcoord;
|
||||
out vec2 vTex;
|
||||
|
||||
void main() {
|
||||
vTex = gl_MultiTexCoord0.xy;
|
||||
gl_Position = modelViewProjectionMatrix * gl_Vertex;
|
||||
vTex = texcoord;
|
||||
gl_Position = modelViewProjectionMatrix * position;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,14 @@ void PostFx::resize(int w, int h) {
|
||||
}
|
||||
|
||||
void PostFx::reloadShader() {
|
||||
shader_.load("shaders/postfx");
|
||||
const bool ok = shader_.load("shaders/postfx");
|
||||
if (!ok || !shader_.isLoaded()) {
|
||||
ofLogError("PostFx") << "shader postfx FAILED to load/compile — "
|
||||
"le tone-map ne s'appliquera pas, fallback "
|
||||
"= scène brute (peut paraître blanche).";
|
||||
} else {
|
||||
ofLogNotice("PostFx") << "shader postfx loaded OK";
|
||||
}
|
||||
}
|
||||
|
||||
void PostFx::beginScene() {
|
||||
|
||||
@@ -116,7 +116,7 @@ void ofApp::setup() {
|
||||
fxGui_.setup("post-fx", "fx-settings.xml", 230, 10);
|
||||
fxGui_.add(fxEnableToggle_.setup("enabled", true));
|
||||
fxGui_.add(fxChroma_.setup("chroma", 0.0f, 0.0f, 1.0f));
|
||||
fxGui_.add(fxBloom_.setup("bloom", 0.4f, 0.0f, 1.0f));
|
||||
fxGui_.add(fxBloom_.setup("bloom", 0.15f, 0.0f, 1.0f));
|
||||
fxGui_.add(fxRgbShift_.setup("hue rot", 0.0f, 0.0f, 1.0f));
|
||||
fxGui_.add(fxSat_.setup("saturation", 1.0f, 0.0f, 2.0f));
|
||||
fxGui_.add(fxScan_.setup("scanlines", 0.3f, 0.0f, 1.0f));
|
||||
|
||||
@@ -163,29 +163,28 @@ void WaveformVis::draw(int x, int y, int w, int h) {
|
||||
ofEndShape(false);
|
||||
};
|
||||
|
||||
// Glow phosphor : 3 passes décalées en alpha
|
||||
for (int pass = 3; pass >= 1; --pass) {
|
||||
const float a = 30.0f * pass;
|
||||
plot(trace1_, ofColor(0, 255, 140, static_cast<int>(a)), h * 0.30f);
|
||||
plot(trace2_, ofColor(255, 200, 60, static_cast<int>(a)), h * 0.70f);
|
||||
}
|
||||
|
||||
// Overlay trace lent — vue enveloppe / drift, traversant tout l'écran.
|
||||
// Cyan épais semi-transparent, dessiné par-dessus les traces audio.
|
||||
// Trace lent en arrière-plan (sous les traces audio) — vue enveloppe /
|
||||
// drift, traversant tout l'écran. Cyan épais semi-transparent.
|
||||
if (showSlowOverlay_ && !slowTrace_.empty()) {
|
||||
ofSetColor(120, 220, 255, 180);
|
||||
ofSetLineWidth(3);
|
||||
ofSetColor(80, 160, 200, 110);
|
||||
ofSetLineWidth(4);
|
||||
ofBeginShape();
|
||||
const int n = static_cast<int>(slowTrace_.size());
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const float px = x + (static_cast<float>(i) / (n - 1)) * w;
|
||||
// l'overlay occupe 80% de la hauteur, centré
|
||||
const float py = y + h * 0.5f - slowTrace_[i] * (h * 0.40f);
|
||||
ofVertex(px, py);
|
||||
}
|
||||
ofEndShape(false);
|
||||
}
|
||||
|
||||
// Glow phosphor : 3 passes décalées en alpha (au-dessus du slow trace)
|
||||
for (int pass = 3; pass >= 1; --pass) {
|
||||
const float a = 30.0f * pass;
|
||||
plot(trace1_, ofColor(0, 255, 140, static_cast<int>(a)), h * 0.30f);
|
||||
plot(trace2_, ofColor(255, 200, 60, static_cast<int>(a)), h * 0.70f);
|
||||
}
|
||||
|
||||
// HUD
|
||||
ofSetColor(160, 220, 180);
|
||||
const float vdiv1 = 0.5f;
|
||||
|
||||
Reference in New Issue
Block a user