Skip to content

Instantly share code, notes, and snippets.

@Cloudef
Last active December 13, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cloudef/4971329 to your computer and use it in GitHub Desktop.
Save Cloudef/4971329 to your computer and use it in GitHub Desktop.
vsm glhck shader
Basic VSM shadow mapping shader
-- GLhck.DepthRender.Unpacking.Fragment
void main() {
float Depth = glhckUnpackHalf(texture2D(GlhckTexture0, GlhckFUV0).st);
GlhckFragColor = vec4(Depth, Depth, Depth, 1.0);
}
-- GLhck.Depth.Packing.Fragment
void main() {
const float Near = 5.0;
const float Far = 250.0;
const float LinearDepthConstant = 1.0/(Far - Near);
float LinearDepth = length(GlhckFVertexLightView) * LinearDepthConstant;
float Moment1 = LinearDepth;
float Moment2 = Moment1 * Moment1;
GlhckFragColor = vec4(glhckPackHalf(Moment1), glhckPackHalf(Moment2));
}
-- GLhck.Lighting.ShadowMapping.Unpacking.Fragment
uniform sampler2D ShadowMap;
void main() {
vec4 Diffuse = texture2D(GlhckTexture0, GlhckFUV0.st) * GlhckMaterial.Diffuse/255.0;
GlhckFragColor = clamp(vec4(glhckLighting(Diffuse.rgb) * glhckShadow(ShadowMap), Diffuse.a), 0.0, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment