What is the best way to create shadows in an environment?

I’ve read through many of the posts, tried a couple things, but have been unsuccessful. Can someone direct me to a python script or explain a simple way to do shadows in an environment?

Thanks,
Garry

Look to direct/src/showbase/ShadowDemo.py for an example.

David

I’ve looked at ShadowPlacer.py and ShadowDemo.py - neither seems to really do what I need. It is very simple :slight_smile:

I have two objects, one is an environment, the other is a “chair” that is placed in the environment. What is the easiest way to programattically get a simple dark shadow under the chair? I could of course build it into the .egg, but this could become a problem with a large environment.

I’m really trying to get something more photorealistic up and running, and shadows are critical to getting a proper look.

Any help would be greatly appreciated.

Thanks,
Garry

Ah, yes. ShadowDemo.py shows how to create an interactive, rendered shadow, for instance of an animated character.

If you want a static shadow, you’re really best off painting it into the model. Many modeling packages have features that allow you to set up lights in the modeling package and “bake” the shadows into the textures, which helps solve the management issue for large environments.

The problem is that current 3-D graphics hardware is not really good at generating shadows in real time. There are lots of different hacks to compute shadows, and all of them suffer from some limitations and they all tend to be fairly expensive. It’s something you’d only do when you had no other way to generate shadows, for instance for an animated character.

Non real-time renderers, like raytracers, can do shadows easily. But shadows at real time are hard by their nature. Some real-time graphics engines do have a single API call to enable shadows, but a single API call doesn’t mean the feature is cheap–enabling shadows will always require the graphics engine to go through serious hoops, such as what is done by ShadowDemo.py. It’s still something you don’t really want to do on static geometry.

David

How is it better for dynamic geometry than static geometry?

My idea is if the item is static, just render the shadows once and hold that texture on the floor, wall, whatever.

It’s not that it’s better for dynamic geometry, but the point is that with dynamic geometry there’s only one way to do it, which is the expensive way, so you don’t have any choice about it.

With static geometry, you do have a choice. You can do it the expensive way, which is to render them on the fly, or you can do it the cheap way, which is to paint the shadows in ahead of time.

Rendering the texture once and then keeping the texture around is a reasonable halfway choice, but it’s still complicated to do that and you still end up with a multitexture effect, which might or might not be expensive depending on your graphics card.

David