Last active
December 13, 2015 20:38
-
-
Save Cloudef/4971329 to your computer and use it in GitHub Desktop.
vsm glhck shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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