Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GL_FRAGMENT_SHADER
- #version 330 core
- uniform mat4 projectionMatrix;
- uniform mat4 viewMatrix;
- uniform mat4 modelMatrix;
- uniform mat4 mymat;
- uniform sampler2D texture_diffuse;
- uniform struct Light {
- vec3 position;
- vec3 intensity;
- int enabled;
- mat4 matrix;
- sampler2DShadow shadowTexture;
- };
- // TODO: Define this at shader compile time?
- const int LIGHT_COUNT = 20;
- uniform int enabledLightCount;
- uniform Light lights[LIGHT_COUNT];
- in vec4 pass_shadowCoord;
- in vec4 pass_Position;
- in vec4 pass_Colour;
- in vec4 pass_Normal;
- in vec2 pass_TextureCoord;
- out vec4 out_Colour;
- void main(void) {
- vec4 lightColour = vec4(1,1,1,1);
- vec4 diffuseColour = texture( texture_diffuse, pass_TextureCoord );
- //diffuseColour = pass_Color + vec4(0.5);
- vec4 newShadowCoord = lights[0].matrix * pass_Position;
- newShadowCoord = newShadowCoord / newShadowCoord.w;
- float vis = 1;
- float visibility = 1.0;
- visibility = texture( lights[0].shadowTexture, vec3( newShadowCoord.xy, newShadowCoord.z ) );
- if(visibility < 1)
- vis = 0.5;
- out_Colour = vis * ( diffuseColour * lightColour );
- //out_Colour = visibility * ( diffuseColour * lightColour );
- //out_Colour = vec4(visibility);
- //out_Colour = vec4(newShadowCoord.z);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement