Guest User

Untitled

a guest
Nov 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #version 330
  2.  
  3. uniform mat4 transformationMatrix;
  4. uniform mat4 projectionMatrix;
  5. uniform mat4 viewMatrix;
  6.  
  7. layout(location = 0) in vec3 position;
  8. layout(location = 1) in vec2 textureCoordinates;
  9.  
  10. out vec3 colour;
  11. out vec2 pass_textureCoordinates;
  12.  
  13. void main() {
  14.  
  15. gl_Position = projectionMatrix * viewMatrix * transformationMatrix * vec4(position,1.0);
  16. pass_textureCoordinates = textureCoordinates;
  17.  
  18. }
  19.  
  20. #version 330
  21. uniform sampler2D modelTexture;
  22.  
  23. in vec3 colour;
  24. in vec2 pass_textureCoordinates;
  25.  
  26. //use your own output instead of gl_FragColor
  27. out vec4 out_Color;
  28.  
  29. void main() {
  30. out_Color = texture(modelTexture,pass_textureCoordinates);
  31. }
  32.  
  33. #version 330 compatibility
  34.  
  35. attribute vec3 aVertexTangent;
  36.  
  37. varying vec3 vvLocalSurfaceNormal ;
  38. varying vec3 vvLocalSurfaceToLightDirection;
  39.  
  40. void main()
  41. {
  42. vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz;
  43. vvLocalSurfaceToLightDirection = normalize(vLightModelPosition – gl_Vertex.xyz);
  44.  
  45. vvLocalSurfaceNormal = normalize(gl_Normal);
  46.  
  47. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  48. }
  49.  
  50. #version 330 compatibility
  51.  
  52. varying vec3 vvLocalSurfaceNormal;
  53. varying vec3 vvLocalSurfaceToLightDirection;
  54.  
  55. void main()
  56. {
  57. vec3 vNormalisedLocalSurfaceNormal = normalize(vvLocalSurfaceNormal);
  58. vec3 vNormalisedLocalSurfaceToLightDirection = normalize(vvLocalSurfaceToLightDirection);
  59.  
  60. float fLightIntensity = max(dot(vNormalisedLocalSurfaceToLightDirection, vNormalisedLocalSurfaceNormal), 0.0);
  61.  
  62. vec3 rgbFragment = vec3(1.0);
  63.  
  64. rgbFragment *= fLightIntensity;
  65.  
  66. gl_FragColor.rgb = rgbFragment;
  67. gl_FragColor.a = 1.0 ; // TODO : Worry about materials which allow transparency!
  68. }
  69.  
  70. gl_ModelViewMatrixInverse
Add Comment
Please, Sign In to add comment