Sign in to follow this  
Topflappen

Self made shadow map

Recommended Posts

Hi im currently developing a project in WebGL and now got to the point where it would be nice to create shadows.

Therefor i want to use shadow maps. Unfortunately the basic functions to create a shadow map are missing in webgl so i have to do alot on my own.

I am already able to draw the depth values into my depth texture and project them correctly onto the scene.

My problem is the fragment comparison, when i render the scene normally.

In the fragment shader i can read the depth values out of the depth texture. But to what do i have to compare it to dertermine, wether at this fragement is shadow or not?

hope someone can help me out.

Share this post


Link to post
Share on other sites
You have to take the current fragment and put it in the same view space as the light. So take each of your final vertices (in world space) and put them through the lights view/projection matrix and scale that final coordinate from (-1,1) to (0,1) which is the texture matrix. Look up GLSL shadow mapping, there should be a tutorial somewhere to follow.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this