Snippets

Adam Walker ae9agM: Untitled snippet

Created by Adam Walker
#version 330 core

in vec4 ShadowCoord;

// Ouput data
layout(location = 0) out float fragmentdepth;
out vec3 color;

void main(){
    float visibility = 1.0;
    if ( texture( shadowMap, ShadowCoord.xy ).z  <  ShadowCoord.z){
        visibility = 0.5;
    }
    color = visibility*vec3(1,1,1);

    // Not really needed, OpenGL does it anyway
    fragmentdepth = gl_FragCoord.z;
}
#version 330 core

// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;
out vec4 ShadowCoord;

// Values that stay constant for the whole mesh.
uniform mat4 depthMVP;
uniform mat4 DepthBiasMVP;

void main(){
 // Output position of the vertex, in clip space : MVP * position
 gl_Position =  depthMVP * vec4(vertexPosition_modelspace,1);

 // Same, but with the light's view matrix
 ShadowCoord = DepthBiasMVP * vec4(vertexPosition_modelspace,1);
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.