PDA

View Full Version : difference in accessing texture



lobbel
07-20-2010, 07:32 AM
hello,
is there a difference between these two methods
accessing a texture ?




uniform sampler2D texImage;
uniform vec2 inv_screen; // inverse of screensize (1/x, 1/y)
in vec3 gs_TexCoord;
out vec4 gs_FragColor;

void main(void)
{
//method a
gs_FragColor = texture2D(texImage, gs_TexCoord);
// method b
gs_FragColor = texture2D(texImage, gl_FragCoord.xy * inv_screen);
}


for me there is no difference in method a and b. both texture
coordinates are in the range [0,1]. So I sometimes
read method b in some tutorials. Is there a reason for method b or does it just depends on the mood of the programmer ?

regards,
lobbel

ZbuffeR
07-20-2010, 01:31 PM
Method b does not need texturecoords, that can be useful sometimes.

lobbel
07-20-2010, 01:43 PM
thanks.

regards,
lobbel

nickels
08-26-2010, 07:34 AM
I just used the gl_FragCoord.xy approach with great success to access the depth buffer in a fog shader. In this case the polygon coords were meaningless.

My question: is there any way to find the viewport width/height without passing them in as uniforms?

Alfonse Reinheart
08-26-2010, 08:06 AM
My question: is there any way to find the viewport width/height without passing them in as uniforms?

No.

nickels
08-26-2010, 11:05 AM
My question: is there any way to find the viewport width/height without passing them in as uniforms?

No.

Shucks! Thanks, though :sorrow: