Advertisement
Boltzmann

fragment shader GLSL

Aug 9th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. uniform vec4 fvAmbient;
  2. uniform vec4 fvSpecular;
  3. uniform vec4 fvDiffuse;
  4. uniform float fSpecularPower;
  5.  
  6. //uniform sampler2D baseMap;
  7.  
  8. //varying vec2 Texcoord;
  9. varying vec3 ViewDirection;
  10. varying vec3 LightDirection;
  11. varying vec3 Normal;
  12.  
  13. void main( void )
  14. {
  15. vec3 fvLightDirection = normalize( LightDirection );
  16. vec3 fvNormal = normalize( Normal );
  17. float fNDotL = dot( fvNormal, fvLightDirection );
  18.  
  19. vec3 fvReflection = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection );
  20. vec3 fvViewDirection = normalize( ViewDirection );
  21. float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
  22.  
  23. //vec4 fvBaseColor = texture2D( baseMap, Texcoord );
  24. vec4 fvBaseColor = vec4(1,1,1,1);
  25.  
  26. vec4 fvTotalAmbient = fvAmbient * fvBaseColor;
  27. vec4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor;
  28. vec4 fvTotalSpecular = fvSpecular * ( pow( fRDotV, fSpecularPower ) );
  29.  
  30. gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement