Jump to content
  • Advertisement
Sign in to follow this  

Is this right for a deferrence shader?

This topic is 3608 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!