roc_samples/data/shaders/shadow_pass1.vert
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

24 lines
No EOL
664 B
GLSL

uniform vec3 CameraPos;
uniform vec3 CameraDir;
uniform float DepthNear;
uniform float DepthFar;
varying float CameraDepth; // normalized camera depth
varying vec2 TexCoord;
void main()
{
// offset = vector to vertex from camera's position
vec3 offset = (gl_Vertex.xyz / gl_Vertex.w) - CameraPos;
// z = distance from vertex to camera plane
float z = -dot(offset, CameraDir);
// Depth from vertex to camera, mapped to [0,1]
CameraDepth = (z - DepthNear) / (DepthFar - DepthNear);
// typical interpolated coordinate for texture lookup
TexCoord = gl_MultiTexCoord0.xy;
gl_Position = ftransform();
}