Skip to main content
GameDev.net gamedev.net
🔒 Locked

Improved Shadowmapping

Started by mrbig Mar 29, 2006 at 12:25 AM 7 replies 1.2k views
Original Post
mrbig
mrbig
Shadowmapping is fast and simple, it can cast shadows on everything (including self shadowing), it can be used to create soft shadows (by using multiple point lights) and still remain fast. But it has one big flaw: aliasing. But I came up with a way to solve it while using as low shadowmap resolutions as 64x64. All you need to do with the shadowmap is: 1. Anti-alias it 2. Blur it using gaussian blur with a very small radius 3. Use texture filtering All that can be done using fragment shaders, and since the resolution and the amount of blur is very small, there's a very little number of fragments to process so it should be fast. Here's an example of the results of such filtering. A 32x32 square scaled to 512x512. The square was 32x32 before it was scaled. No aliasing appears. Altough it wasn't supposed to have smooth edges, we can use that to our adventage too when using multiple point lights to create soft shadows! The smooth edges will make the transition between one shadow to another smooth!
Demus79
Demus79

Why not write a little tutorial about it ?
mrbig
mrbig
I'm not a very skilled OpenGL programmer.
And GLSL is driving me nuts, working and not working randomly...
If you think this might work, try to implement it and show me the results. :)
Should work, theoretically... Shadowmaps can be filtered, right?
mrbig
mrbig
Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...
MButchers
MButchers
I dont know much about shadow mapping as I have yet to implement it in my engine but I dont think

Quote:


Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...



Will work as all your geometry will be the shadow color, as you dont determine if its behind the blocker with the depth test! ( You would effectively
project a black texture :) )

I think though in AOM what they might have done is simply project a pre-rendered texture onto the terrain to give the impression of shadow mapping. But you wouldnt get self shadowing this way.

Mark
Kalidor
Kalidor
As zedzeek said, this won't work because you can't directly filter depth values. It's good to see that some people can still think for themselves though [smile]. What you can do is store the shadow map in a different way, one which does let you filter it anyway you like. See Variance Shadow Maps for example. I haven't implemented it, but from reading the paper and that thread it seems like it could be a very good solution.

EDIT: And just for more clarity, PCF (Percentage Closer Filtering) is a technique of filtering the depth comparisons. What you basically do is run the depth comparison for several samples in the shadow map and then filter the results of all those comparisons to get some percentage that the current fragment is shadowed. Depending on the number of samples you use it can offer decent results, but the more samples you take the slower it goes.
mrbig
mrbig
Here's a description of a demo I found at http://pages.pomona.edu/~nrr02004/opengl.html

"This demo demonstrates shadow mapping. Radeons don't support rendering directly to depth textures, so the 512x512 shadow map is rendered to a pbuffer and then copied to a texture. The light is omnidirectional but only one shadow map is used; this can be done since the table is the only shadow caster in the scene. Light space projection, clipping, and 4-sample PCF (percentage-closer filtering) is done by the fragment shader. In a real application of shadow mapping, one would use a cubemap for omnidirectional lights."

I think that solves the problem! :D
Sounds a bit messy, though...

By the way, check this page out: http://dee.cz/fcss/
It has a demo demonstrating soft shadows using shadowmaps. (Not filtered, but it's pretty cool.)
zedzeek
zedzeek
Quote:
Original post by mrbig
Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...

i think u mean, render an object/s from the lights position and projection this black texture onto the scenery behind it.
yes this used to be used quite often (i forget the graphics term its called) the problem with it is it doesnt handle selfshadowing

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.