differences between slab and shader?
Hello all,
Maybe I am missing some of the very basics.
Ok some opengl commands does not work as expected in jit.gl.slab like "discard" for example it actually do not discard pixels, but it works in jit.gl.shader. In my last project I tried to make a simple edge detection in slab and it does not works properly, but it works in shader.
I am attaching the output of the two objects and the picture is just a white rectangle on black background.
and the glsl piece is:
varying vec2 texcoord0;
uniform sampler2DRect tex0;
uniform float scale;
void main( void )
{
vec3 img = texture2DRect(tex0, texcoord0).rgb;
float lap = float( fwidth(img * 4.0) * scale );
vec3 ii = vec3( img );
vec3 ll = vec3( abs(lap) );
ll = clamp(ll, 0.0, 1.0);
gl_FragColor = vec4(ll, 1.0);
}
Can anyone advise me?
Thanks!
gl.slab is only for processing 2d textures. if you want to apply shading to geometry (eg. gl.gridshape) you can use gl.shader.
if you want help debugging your shader, please attach a complete jxs file and example patch.
Hello Rob, thanks for your replay,
I know that slab is only for processing textures. My point is that they both shows different behavior when I am processing just 2d textures.
I am attaching two examples from my previous experience in both I used slab and shader with the same piece of code and they understand it differently.
1. I tried to discard pixels with slab, it looks like that slab adds alpha channel instead of discarding. With shader it works perfect.
2. The example with the white rectangle, shader does exactly what I want fwidth() gives me the contour of it, but it seems that slab understands it a bit differently.
Am I missing something fundamental?
i don't think you're missing anything fundamental. gl.slab renders its textures to a fullscreen quad using the provided textures and an FBO, and then outputs the resultant texture, so there's going to be some differences in behavior vs applying the same effect to the geometry of a gl.videoplane, or gl.mesh.
your effects are best rendered by gl.shader applied to the desired geometry.
Thanks a lot, it is more clear now.