Closed marioecg closed 1 year ago
Hi @marioecg! So good that you brought this up! u_scene
/POSTPROCESSING
passes were originally designed for 3D workflows. Where you have a 3D scene (with some geometry) in the main pass and you want to apply some 2D post processing effect after that.
For what you want to make using simple buffers is the canonical way. The main pass becomes the "postprocessing" . For example:
uniform sampler2D u_buffer0;
varying vec2 v_texcoord;
void main(void) {
vec4 color = vec4(0., 0., 0., 1.);
vec2 uv = v_texcoord;
#if defined(BUFFER_0)
color.r = 1.0;
#else
color.rgb = texture2D(u_buffer0, uv).rgb;
#endif
gl_FragColor = color;
}
But now that you brought this up, it makes a lot of conceptual sense to still be able to have another 2D post processing pass. I will take a look to the code and see if I can make that work. In the mean time, for 2D pipelines I recommend using buffers, they are powerful and a hell lot of fun. If you are into doing ping-pong or feedback loops remember you have u_doubleBuffer<N>
/DOUBLE_BUFFER_<N>
Ah right! I knew I was missing something, it looked more straightforward to use defined(POSTPROCESSING)
. Your example works like a charm, thank you!! I will be exploring more with buffers soon 💯
Hi and first of all thanks Patricio and the community for your efforts on glslViewer. I'm trying to setup a simple post-processing pass using defines, but instead of rendering a color an error shows:
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
.The command I'm running is
glslViewer main.frag -l
, and this is the shader:I would expect a red color output on the screen, perhaps I'm missing something? I'm running glslViewer on a 14-in MBP 2021 with Monterey 12.6.