roc_samples/data/shaders/shadow_pass2.frag
cecilkorik 12cb7128f7 split everything in roc_samples out of the main roc project
refactored as needed to make roc work as a shared library, without any stupid import hacks
2017-05-08 23:49:09 -07:00

25 lines
No EOL
706 B
GLSL

uniform sampler2D DepthTexture;
uniform sampler2D ShadowTexture;
varying vec2 DepthTexCoord;
varying vec3 ShadowNear;
varying vec3 ShadowDir;
const vec3 shadowColor = vec3(0.0);
void main()
{
// read from DepthTexture
// (depth is stored in texture's alpha component)
float cameraDepth = texture2D(DepthTexture, DepthTexCoord).a;
vec3 shadowPos = (cameraDepth * ShadowDir) + ShadowNear;
float l = dot(shadowPos.yz, shadowPos.yz);
float d = shadowPos.x;
// k = shadow density: 0=opaque, 1=transparent
// (use texture's red component as the density)
float k = texture2D(ShadowTexture, vec2(l, d)).r;
gl_FragColor = vec4(shadowColor, k);
}