Skip to content

Instantly share code, notes, and snippets.

@andsve
Created April 19, 2009 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andsve/98138 to your computer and use it in GitHub Desktop.
Save andsve/98138 to your computer and use it in GitHub Desktop.
void main (void)
{
float depth = texture2D(tex_depth, gl_TexCoord[0].st).r * 2.0 - 1.0;
vec3 norm = texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0;
//norm = normalize(norm); // no need?
vec4 ambient = texture2D(tex_motion, gl_TexCoord[0].st); // currently holds ambient colors
// will be used for velocity in future
// Viewport position at this pixel in the range -1 to 1.
vec4 projection_pos = vec4(gl_TexCoord[0].st * 2.0 - 1.0, depth, 1.0);
// Transform by the view-projection inverse.
vec4 viewport_pos = invprojmtx * projection_pos;
// Divide by w to get the world position.
vec4 frag_pos = viewport_pos / viewport_pos.w;
// ... blinn-phong calculations
gl_FragColor = final_color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment