Shadows

Blitz3D Forums/Blitz3D Programming/Shadows

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Norc:
The code is really simple if you look at it.

All you have to do is call one function to define an object as casting a shadow, and another object as reciving the shadow from that object, and the texture to use for the shadow, and then each time you render the world call the function which regenerates all the shadows.

That's it!

The code casts shadows straight down only currently. But in theory it should be possible to modify it to cast shadows in any directon.

Also, the shadow textures right now are intended to be circular shadows. So you just make a circular black texture. Then that will wrap around the obejct the shadow is being cast down upon.

However, you should be able to generate a new shadow texture each frame from the actual object's geometry, and then you could have shaped shadows which cast downward.

In theory you could do this by rendering the world from a camera view to a small viewport offscreen. Just point the camera down towards the object making sure the object is black and the background is white. Then you just grab that for your texture.

I don't have a small sample program for it, but like I said, it's only 2 function calls. One to create the shadow generator shadow caster link, and one each renderworld to create the actual shadows. Doesn't get any simpler than that.

Oh nad with my system it doesn't matter how your world is textured. The system creates new geometry specifically for the shadows.