Game Development Community

Dynamic shadowing

by Matthias Georgi · in Torque Game Engine · 01/17/2008 (2:38 pm) · 1 replies

I need a solution to cast shadows from any object to a tsStatic shape in TGEA. Dynamic shadowing should work for all ShapeBase objects if the relevant fields are enabled in the datablock.

There are two solutions for this problem:
- using static shape objects
- using tsStatic objects and implementing/modifying the shadow projection code

Static shapes are not a real solution for me in this case, as they are not covered by the polysoup resource. So I tried to implement the shadow projection for tsStatic objects.

I added following code to the sgObjectBasedProjector class:

// find all tsStatic objects:
		gClientContainer.findObjects(StaticTSObjectType,
			sgShadowProjector::dtsCallback, this);


	for(U32 o=0; o<sgShadowReceivers.size(); o++)
	{

		TSStatic *tsStatic = dynamic_cast<TSStatic *>(sgShadowReceivers[o]);

		if (tsStatic)
		{
			shape = tsStatic->getShapeInstance();
			if(!shape)
				continue;
			shapeworld = tsStatic->getRenderTransform();
			shapeworld.scale(tsStatic->getScale());
		}

I'm searching for all tsStatic objects and getting their TSShapeInstance. This is exactly the same code as for the ShapeBase objects. It actually works somehow, but for some reason the shadow is rendered repeatedly all over the shadow receiving tsStatic object. It looks like the shadow is rendered for each polygon of the tsStatic object.

My understanding of the shadow projection code is quite limited. I have no clue why this thing is happening.

I'm not sure if the original code for casting on ShapeBase objects is correct. Maybe the projection was developed only for small objects.

I would appreciate any help on this topic or some pointer for a better understanding of the shadow casting code. Thanks!

#1
01/17/2008 (3:07 pm)
Correct ... shadow casting with objects larger than 70 units or the like is known to be problematic (there is a thread on that with a large scale space ship where self shadowing ticks totally out)