Jump to content

Get Pixel Height (PostProcess)


Gandi
 Share

Recommended Posts

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() ) ;

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...