GLSL: How to get pixel x,y,z world position?
Posted
by
Rookie
on Stack Overflow
See other posts from Stack Overflow
or by Rookie
Published on 2011-02-04T15:13:50Z
Indexed on
2011/02/04
15:25 UTC
Read the original article
Hit count: 234
I want to adjust the colors depending on which xyz position they are in the world.
I tried this in my fragment shader:
vec4 pos = vec4(gl_FragCoord); // get pixel position
but it seems that the z-coord is always towards my camera... how do i make the coords independent from my camera position/angle?
Edit: if it matters, heres my vertex shader:
gl_Position = ftransform();
Edit2: changed title, so i want world coords, not screen coords!
© Stack Overflow or respective owner