Sign in to follow this  
colt527

Real Time Lighting / Shadows

Recommended Posts

I have lost all hope in lightmaps, I successfully created a parser for a .dmf file (DeleD 3D Editor) that used the lightmaps that the program generated. The quality was not what I expected, the resolution on the lightmaps is so small that you can see the pixel edges of the lightmap on the texture. I figure dynamic lighting using pixel/vertex shaders is the next step in my experiment of lighting. I have already implemented the good old standard diffuse vertex shader and that works great for single objects w/o shadows on them. I could always just use normal shadows but that would kill the performance, so I'm looking for a way of incorperating the lighting and the shadows in either a vertex shader or pixel shader. I am thinking about casting a ray from the light source to the vertex I am calculating the diffuse color for and seeing if it hits and object, but I think I would need a high vertex count for that too look at all convincing. If you have any links to tutorials where I can find information on this topic, please share. :)

Share this post


Link to post
Share on other sites
In general, there are two main techniques used to calculate realtime dynamic shadows. One is shadow mapping, the other is called shadow volumes. Both are very good. Depending on what kind of shadows your application needs, they may be overkill. For example, if you're making a racing game and know that your shadows will always be on a flat surface, then there are simpler methods you could use.

Do a search for shadow mapping and shadow volumes and you'll get a lot of info on them. They both have different pros/cons so its up to you to decide which is best for your specific applicaiton.

Both of these techniques can be implemented with shaders and used along with code that calculates lighting for your scene. In fact, it wasn't until the introduction of shaders in general that graphics cards got powerfull enough to be able to use these techniques in realtime. Lightmaps were good back in the day when graphics hardware wasn't that powerfull and where realtime lighting was prohibitvely expensive. But today, lightmaps aren't needed as much. They still have their uses but most games calculate the majority of their lighting in realtime.

neneboricua

Share this post


Link to post
Share on other sites
It seems like Shadow Mapping is the way to go for my project, I am dealing with a large number of objects and it seems like calculating the projection of every object affected by every light would be too great of a task for current computers. So, if I do go with Shadow Mapping, this is the general idea i'm getting from searching on it.

1.) See how far all the pixels the light can see are from the light
2.) See how far all of the pixels the camera can see are from the camera
3.) Translate what the camera sees to light view space
4.) Compare the 2 and dont give light to pixels where something the light sees is in front of what the camera sees.

Am I completly off on this? or am I sort of on the right track?

Share this post


Link to post
Share on other sites
You've got the basic idea down right. There are a number of tutorials and white papers on shadow mapping available on the web. A search should give you all the info you need. If you have specific questions about how to do something, post a message in the forum and I'm sure lots of people will offer to help.

neneboricua

Share this post


Link to post
Share on other sites
shadow maps are a good choice for large number of objects, but you can mix lightmaps with shadow maps, static geometry like buildings and other stuff can be rendered with lightmaps very fast, and dymanic objects like moving models may be rendered with shadow mapping.
you won't need shaders if you don't want self shadowing on objects.
I recommend you use lightmaps too, because they are very fast specially on the current hardware
I don't calculate lightmaps, I just wrote an exporter that exports level geometry with their lightmaps in 3dsmax, texture sizes can be anything, and max builds perfect lightmaps.

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