Self made shadow map

Started by
0 comments, last by dpadam450 13 years, 2 months ago
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.
Advertisement
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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement