Question

I have implemented depth texture and getting different outputs on 2 different drivers. I am reading all channels in texture() in fragment shader :

“vec4 color = texelFetch(tk_diffuseMap, ivec3(tmp), i);” 

In this case I get a red and grey image on A and B respectively. If I read red channel and replicate it to all the 4 channels I get a grey image on A like:

“vec4 color = vec4(texelFetch(tk_diffuseMap, ivec3(tmp), i).x)”. 

Which one is correct? enter image description here

enter image description here

Was it helpful?

Solution

It's irrelevant which one is right, because you shouldn't be looking at the other three channels at all. It's a depth texture; it only has one channel, the first one. That's the only one you should be touching. Even if OpenGL defined what the other values are, it would just be some default values which are irrelevant, since you don't care. You wanted the depth, so quit looking at the non-depth values.

However, if you want the spec answer, you should get the same thing you would from a GL_RED texture: 0 for green and blue, and 1 for alpha.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top