Sign in to follow this  

Is this right for a deferrence shader?

This topic is 3297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Just woundering if this is how you do the deference shading.. Anything wrong with this, and anything that should be added? [vertex] varying vec3 Normal; varying vec4 Position; void main(){ Normal = gl_NormalMatrix * gl_Normal; Position = gl_ModelViewMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); } [fragment] //holding the texture for the image uniform sampler2D TextureMap; varying vec3 Normal; varying vec4 Position; void main(){ //normal is not normalized, so we make the normal normal :P vec3 n = normalize( Normal ); //thanks to gamedev.net n = ( n * 0.5 ) + 0.5; //move it from [-1,1] to [0,1] gl_FragData[0] = texture2D( TextureMap, gl_TexCoord[0] ); gl_FragData[1] = vec4( Position.xyz, 1.0); gl_FragData[2] = vec4( n, 1.0 ); }

Share this post


Link to post
Share on other sites

This topic is 3297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this