GLSL: How to get pixel x,y,z world position?

后端 未结 4 1723
情深已故
情深已故 2020-12-24 02:29

I want to adjust the colors depending on which xyz position they are in the world.

I tried this in my fragment shader:

varying vec4 verpos;

void mai         


        
4条回答
  •  没有蜡笔的小新
    2020-12-24 02:39

    The easiest way is to pass the world-position down from the vertex shader via a varying variable.

    However, if you really must reconstruct it from gl_FragCoord, the only way to do this is to invert all the steps that led to the gl_FragCoord coordinates. Consult the OpenGL specs, if you really have to do this, because a deep understanding of the transformations will be necessary.

提交回复
热议问题