Facebook
From MT, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 240
  1. // Simple lighting model
  2. varying vec3 N;
  3. varying vec3 v;
  4.  
  5. // Fragment shader entry point
  6. void main()
  7. {
  8.         // Calculate lighting parameters
  9.         vec3 L = normalize(gl_LightSource[0].position.xyz - v);  
  10.         vec4 Idiff = gl_FrontLightProduct[0].diffuse * max(dot(N,L), 0.0);  
  11.         Idiff = clamp(Idiff, 0.0, 1.0);
  12.  
  13.         // Make it green
  14.         gl_FragColor = Idiff;
  15.         gl_FragColor.x = 0.0;
  16.         gl_FragColor.z = 0.0;
  17. }
  18.