Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CH06-brick.vert.txt 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Vertex shader for procedural bricks
  3. //
  4. // Authors: Dave Baldwin, Steve Koren, Randi Rost
  5. // based on a shader by Darwyn Peachey
  6. //
  7. // Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
  8. //
  9. // See 3Dlabs-License.txt for license information
  10. //
  11. uniform vec3 LightPosition;
  12. const float SpecularContribution = 0.3;
  13. const float DiffuseContribution = 1.0 - SpecularContribution;
  14. varying float LightIntensity;
  15. varying vec2 MCposition;
  16. void main()
  17. {
  18. vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
  19. vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
  20. vec3 lightVec = normalize(LightPosition - ecPosition);
  21. vec3 reflectVec = reflect(-lightVec, tnorm);
  22. vec3 viewVec = normalize(-ecPosition);
  23. float diffuse = max(dot(lightVec, tnorm), 0.0);
  24. float spec = 0.0;
  25. if (diffuse > 0.0)
  26. {
  27. spec = max(dot(reflectVec, viewVec), 0.0);
  28. spec = pow(spec, 16.0);
  29. }
  30. LightIntensity = DiffuseContribution * diffuse +
  31. SpecularContribution * spec;
  32. MCposition = gl_Vertex.xy;
  33. gl_Position = ftransform();
  34. }