Advertisement
piepieonline

texturedFragment.glsl

Oct 17th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. //GL_FRAGMENT_SHADER
  2. #version 330 core
  3.  
  4. uniform mat4 projectionMatrix;
  5. uniform mat4 viewMatrix;
  6. uniform mat4 modelMatrix;
  7.  
  8. uniform mat4 mymat;
  9.  
  10. uniform sampler2D texture_diffuse;
  11.  
  12. uniform struct Light {
  13. vec3 position;
  14. vec3 intensity;
  15. int enabled;
  16. mat4 matrix;
  17. sampler2DShadow shadowTexture;
  18. };
  19.  
  20. // TODO: Define this at shader compile time?
  21. const int LIGHT_COUNT = 20;
  22. uniform int enabledLightCount;
  23. uniform Light lights[LIGHT_COUNT];
  24.  
  25. in vec4 pass_shadowCoord;
  26.  
  27. in vec4 pass_Position;
  28. in vec4 pass_Colour;
  29. in vec4 pass_Normal;
  30. in vec2 pass_TextureCoord;
  31.  
  32. out vec4 out_Colour;
  33.  
  34. void main(void) {
  35. vec4 lightColour = vec4(1,1,1,1);
  36.  
  37. vec4 diffuseColour = texture( texture_diffuse, pass_TextureCoord );
  38. //diffuseColour = pass_Color + vec4(0.5);
  39.  
  40.  
  41. vec4 newShadowCoord = lights[0].matrix * pass_Position;
  42. newShadowCoord = newShadowCoord / newShadowCoord.w;
  43.  
  44. float vis = 1;
  45.  
  46. float visibility = 1.0;
  47. visibility = texture( lights[0].shadowTexture, vec3( newShadowCoord.xy, newShadowCoord.z ) );
  48.  
  49. if(visibility < 1)
  50. vis = 0.5;
  51.  
  52. out_Colour = vis * ( diffuseColour * lightColour );
  53. //out_Colour = visibility * ( diffuseColour * lightColour );
  54. //out_Colour = vec4(visibility);
  55. //out_Colour = vec4(newShadowCoord.z);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement