Archived

This topic is now archived and is closed to further replies.

robert_s

Shadow technique for a Car

Recommended Posts

Hi. I am working on a rally car simulator. I need to add shadow to my car as it is hard to tell if its standing on ground or not. See HERE I''ve read about shadows a bit and it looks as there are several methods to implement shadows. What shadow technique do you think is most appropriate to use for a rally car and not too expensiove in terms of processing? What techniques are used in real rally games?

Share this post


Link to post
Share on other sites
BTW, that screen shot looks really nice! Congrats.

As far as what kind of shadows to use, it really depends on how accurate you want your shadows to be.

If you just want something that looks ok, you can use projection shadows. These types of shadows basically take your car geometry and project it onto a plane. Older style games used this technique because it wans''t very expensive and for most games, it was enough

If you want very accurate shadows, there are basically two types to techniques to choos from: Shadow Volumes and Shadow Mapping. I''m not sure of which technique rally games use but I think that Splinter Cell used Shadow Mapping. There are also some equally impresive games that have used Shadow Volumes. Each of these have good and bad points. For example, shadow volumes are expensive when it comes to geometry processing, and shadow mapping is expensive when it comes to pixel processing.

Do a search in the Graphics Programming forum for any of these: "projection shadows", "shadow volume", "shadow map" and you''ll see a lot of info. Shadows is a very common topic and I''m sure you''ll find plenty of info.

Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites
Cars don''t have much self-shadowing, so shadow maps or volumes are overkill really. Projected shadow textures are a good way for this. Basically just render your car to a texture from the point of view of the light, then project this generated shadow onto your track.

Share this post


Link to post
Share on other sites
Thx. guys!
Yes, after reading about the two above techniques neneboricua19 mentioned ie. shadow volumes & shadow mapping, I think they''re a bit expensive for my app to handle at the moment as I have already quite low FPS (avg 70). Mainly caused by my unoptimized physics engine

neneboricua19 you''re right, there is alot of stuff on the above mentioned shadow techniques but I''m still having problems fining something on projected shadow textures. Do you guys happen to know some good tutorials or papers on projected shadow textures GrangyTang mentioned? Thanks

Share this post


Link to post
Share on other sites
I don''t get one thing with projected shadow textures (because I couldn''t find much on this stuff).
1. Do I render my car to a texture every frame?
2. Once I have this texture should I apply this texture to my terrain mesh (multitextures) or I create a plane on which I apply this texture with alpha blending?

Sorry I am a bit confused how you guys do this stuff.

Share this post


Link to post
Share on other sites
1. Usually every frame. You could render it every other frame if you wanted to save on speed (or cache it like imposters and only update it after the object or light have rotated/moved over a certain threashold.

2. Typically projected onto your terrain mesh. If you''ve got a texture unit to spare you can multitexture. Failing that re-render the appropriate section of the terrain with the shadow darkening the appropriate area.

Share this post


Link to post
Share on other sites
I don''t really know much on the subject, but I may have a few ideas to consider when it comes to projection shadows.

The shadows themselves I think pretty much just depend on the position of the camera, and the position of the light source. That said, if your camera position is static, or at least is always at the same angle relative to the car, I see no reason why you couldn''t just render the shadow to a texture once at the beginning, and reuse it later. Furthermore, you could generated it once, write it to a file, and use that file instead.

If your camera is continuously bouncing around and revolving around your car (this is probably more realistic), you would probably have to generate it every frame, or even better, generate it only when your car, camera, or light source changes position.

A third possibility would be to render the shadow from a select few angles. However, this limits you to having some-what predictable camera, car, and light movements.

I hope I helped somewhat.. looking back it seems as though OrangyTang summed it up pretty well.

    ___       ___       ___       ___       ___       ___       ___       ___   
/\ \ /\__\ /\ \ /\ \ /\ \ /\ \ /\ \ /\__\
/::\ \ /:/ _/_ _\:\ \ _\:\ \ \:\ \ /::\ \ /::\ \ /:/ _/_
/::\:\__\ /:/_/\__\ /::::\__\ /::::\__\ /::\__\ /::\:\__\ /::\:\__\ /::-"\__\
\/\:\/__/ \:\/:/ / \::;;/__/ \::;;/__/ /:/\/__/ \;:::/ / \:\:\/ / \;:;-",-"
\/__/ \::/ / \:\__\ \:\__\ \/__/ |:\/__/ \:\/ / |:| |
\/__/ \/__/ \/__/ \|__| \/__/ \|__|

Share this post


Link to post
Share on other sites
Thx . Fuzztrek. I roughly know as much as you as the name "Projected shadow Texture" is self explanatory.
There are some details you have to get from somewhere in order to develop it from scratch. Unfortuantely I could not find it in my books or on the net. Thus these questions.

ok. I have one more thing to ask, its about putting the shadow texture on my terrain mesh. I initially though that I should create a 2D plane onto which I should apply the shadow texture which would quite easy to transform. I know its wrong coze it would always be flat even on bumpy terrain.
So. you''re saying that the texture should be directly mapped on the terrain mesh right?
ok. now, each triangle in my terrain is 2 meters long. my car is 4.5 meters long. now how can you know while driving when to jump from one set of coordinate texture to another with my shadow texture. I guess I would have to update tex coords dynamically right?

Even if I could work out the new set of tex coords dynamically then I wil probably see my texture jumping from one set of polygon stripes to another set (on regular grid terrain). How about rotating the texture when the car turns? it sounds a bit weird.

Do you guys know what I mean?
How do you solve this? thanks in advance.

Share this post


Link to post
Share on other sites
Thanks a bunch OrangyTang for the link.

If you guys know more links about this stuff then please post it here too. I am sure others wil benefit from it too.

Iam just wonderring. When I specify the number of coordinates to generate the shadow texture then should it be as many coords as my car consists of?

Share this post


Link to post
Share on other sites