Gandi Posted January 10, 2010 Share Posted January 10, 2010 Is there a texture/buffer which stores the height-data of the scene, or is there any other way of getting the y-position of a pixel in the PostProcess shader? or is it possible to get all the coords (x/y/z) of a specific point? Quote Link to comment Share on other sites More sharing options...
klepto2 Posted January 14, 2010 Share Posted January 14, 2010 this is how to calculate the pixel position in world coords: //needed uniforms in eg postfilter.frag uniform vec3 cameraposition; uniform mat4 cameramatrix; vec3 screencoord; vec4 fogcoord; screencoord = vec3(((gl_FragCoord.x/buffersize.x)-0.5) * 2.0,((-gl_FragCoord.y/buffersize.y)+0.5) * 2.0 / (buffersize.x/buffersize.y),DepthToZPosition( depth )); screencoord.x *= screencoord.z; screencoord.y *= -screencoord.z; vec4 worldpos = vec4(screencoord,1.0) * cameramatrix; worldpos += vec4(cameraposition,0.0); Needed Shader variables to be set SetShaderVec3(postfilter,"cameraposition",camera.position); SetShaderMat4(postfilter , "cameramatrix" , GetEntityMatrix(Camera).Inverse() ) ; Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Gandi Posted January 16, 2010 Author Share Posted January 16, 2010 Thanks a lot! works fine! btw there are built in uniforms as "cameraposition" and "camerainversemat4" where i dont even have to parse the variables to the shader Quote Link to comment Share on other sites More sharing options...
klepto2 Posted January 16, 2010 Share Posted January 16, 2010 yeah, I wasn't sure in which version I have implemented it and so i have added these parameters as i haven't looked if they are provided by the engine. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.