Game Development Community

How to stop collision mesh shadowing?

by Jason Gossiaux · in Torque Game Engine · 07/06/2008 (2:05 am) · 3 replies

I'm at my wits end regarding object shadowing at the moment. All I'd like is to have a few object types that exhibit shadowing behavior similar to the player while also having a collision mesh.

So here is what I've added to both ShapeBase and Staticshape in the source code.

shadowEnable = true;
shadowCanMove = true;
shadowCanAnimate = true;

genericShadowLevel = Player_GenericShadowLevel;
noShadowLevel = Player_NoShadowLevel;


Now this works, and I get very realistic looking shadows that animate on my shapes. The problem is that if I give my shapes collision meshes they inter-shadow and create many visual artifacts. Does anyone know how I might tweak the engine to ignore collision meshes for the purpose of shadowing? I've tried making the collision meshes smaller than the model and that does not help at all.

The only reason player shadows work is because they get their collision box from script and not from the model :P
Thanks!

#1
07/06/2008 (5:25 pm)
Someone in the milkshape forum suggested this is a bug where TGE renders shadows only on the lowest detail level of mesh - which is by default the collision mesh and its -1, -2, etc. Would anyone know how I might be able to work this out in the engine code? It seems like a pretty big bug.
#2
07/07/2008 (1:27 am)
Alright, I was right and the shadow code only selects the highest detail level for obstruction calculations. This means only one collision mesh is used, and only the most negative one. By changing this one line :

S32 TSShapeInstance::getCurrentDetail()
{
   return 0; //mCurrentDetailLevel; //JDG shadow LOD fix
}

I was able to get the whole visible mesh used for shadow generation. I did a find in files and on the surface this function appears to only be used for shadow generation... so I'm hoping no bugs pop up later :P

My other problem where shadows were being corrupted on objects is a result of an earlier change I'd forgotten about involving Self Shadowing DTS shapes.

I'd made a change to this mask :

U32 Shadow::smShadowMask = TerrainObjectType | InteriorObjectType | StaticShapeObjectType | StaticObjectType;

This change lets the player shadow on top of DTS shapes. Unfortunately the shapes themselves start exhibiting massive shadow problems that I am still tracking down. I'll post back here if I can unravel it.

Edit : I think what is happening is the shape geometry mesh tries to project its shadow onto its collision mesh, which results in some really odd looking shadows. I need to either fix the code so shadows are placed on geometry and not collision meshes, or to fix the findobjects() function to ignore itself.
#3
09/23/2010 (2:27 pm)
Jason: Did you ever manage to stop objects projecting their own shadow onto their collision mesh? If so can you help me out? Please!