Problem with DTS Shadow
by Mahmud Hasan · in Torque Game Engine Advanced · 02/23/2007 (6:02 am) · 18 replies
Hi,
I was working with TGEA lighting and went through the TDN resources about the lighting.
So far I understand that the ShapeBase Object can receive shadows of other shapeBase objects (Player).
The ShapeBase Object also can cast selfshadow in it.
I wanted to cast the shadow of my player to a wooden bridge. So what I did is add a staticShapeData datablock for the bridge dts. which is like the following:
datablock StaticShapeData(WoodenBridge)
{
Category = "Structure";
ShapeFile = "~/data/DTS/bridge_wood.dts";
shadowEnable = true;
shadowSelfShadow = true;
shadowDTSShadow = true;
shadowSize = 512;
shadowSphereAdjust = 1.5;
shadowBias = 0.001;
};
It worked and I got the player shadow cast on the bridge. But I didn't get any self shadow effect on the bridge. But most interestingly next day I got that the shadow is not casting at all! Probably I made changes unintentionally that switched off the dynamic shadow on the bridge but I could not found the problem.
In my Default.cs lighting configuration was as follows:
$pref::LightManager::sgAtlasMaxDynamicLights = "16";
$pref::LightManager::sgDynamicShadowDetailSize = "0";
$pref::LightManager::sgDynamicShadowQuality = "0";
$pref::LightManager::sgLightingProfileAllowShadows = "1";
$pref::LightManager::sgLightingProfileQuality = "0";
$pref::LightManager::sgMaxBestLights = "10";
$pref::LightManager::sgMultipleDynamicShadows = "1";
$pref::LightManager::sgShowCacheStats = "0";
$pref::LightManager::sgUseBloom = "";
$pref::LightManager::sgUseDRLHighDynamicRange = "0";
$pref::LightManager::sgUseDynamicRangeLighting = "0";
$pref::LightManager::sgUseDynamicShadows = "1";
$pref::LightManager::sgUseToneMapping = "";
Can anybosy help me to figure out what could be the problem or if I missed something?
Why the self shadowing is not working?
Thanks a lot.
I was working with TGEA lighting and went through the TDN resources about the lighting.
So far I understand that the ShapeBase Object can receive shadows of other shapeBase objects (Player).
The ShapeBase Object also can cast selfshadow in it.
I wanted to cast the shadow of my player to a wooden bridge. So what I did is add a staticShapeData datablock for the bridge dts. which is like the following:
datablock StaticShapeData(WoodenBridge)
{
Category = "Structure";
ShapeFile = "~/data/DTS/bridge_wood.dts";
shadowEnable = true;
shadowSelfShadow = true;
shadowDTSShadow = true;
shadowSize = 512;
shadowSphereAdjust = 1.5;
shadowBias = 0.001;
};
It worked and I got the player shadow cast on the bridge. But I didn't get any self shadow effect on the bridge. But most interestingly next day I got that the shadow is not casting at all! Probably I made changes unintentionally that switched off the dynamic shadow on the bridge but I could not found the problem.
In my Default.cs lighting configuration was as follows:
$pref::LightManager::sgAtlasMaxDynamicLights = "16";
$pref::LightManager::sgDynamicShadowDetailSize = "0";
$pref::LightManager::sgDynamicShadowQuality = "0";
$pref::LightManager::sgLightingProfileAllowShadows = "1";
$pref::LightManager::sgLightingProfileQuality = "0";
$pref::LightManager::sgMaxBestLights = "10";
$pref::LightManager::sgMultipleDynamicShadows = "1";
$pref::LightManager::sgShowCacheStats = "0";
$pref::LightManager::sgUseBloom = "";
$pref::LightManager::sgUseDRLHighDynamicRange = "0";
$pref::LightManager::sgUseDynamicRangeLighting = "0";
$pref::LightManager::sgUseDynamicShadows = "1";
$pref::LightManager::sgUseToneMapping = "";
Can anybosy help me to figure out what could be the problem or if I missed something?
Why the self shadowing is not working?
Thanks a lot.
#2
I too am having trouble getting my head around this. How can I 100% be sure I've got everything I need to cast dynamic shadows? In our TGE version of the game, about 9 months ago we turned off the player shadow, as we didn't need it, but want it back in again now. I can't for the life of me remember how to get it back, also none of our dts's cast dynamic shadows either, they used to, in fact we had to make every model in the level set to not have fynamic shadows etc. I think our default.cs and preferences etc are okay, I just can't seem to get any shadows at all. This will be a really stupid thing that I'm missing I know. Does anyone have an example of a working datablock of something with a shadow working? Any help would be great, I'm going to kick myself when I find it I know I will, it'll be something really easy.....It's the player shadow we want, we can do without the rest.
02/23/2007 (10:13 am)
Hi Guys,I too am having trouble getting my head around this. How can I 100% be sure I've got everything I need to cast dynamic shadows? In our TGE version of the game, about 9 months ago we turned off the player shadow, as we didn't need it, but want it back in again now. I can't for the life of me remember how to get it back, also none of our dts's cast dynamic shadows either, they used to, in fact we had to make every model in the level set to not have fynamic shadows etc. I think our default.cs and preferences etc are okay, I just can't seem to get any shadows at all. This will be a really stupid thing that I'm missing I know. Does anyone have an example of a working datablock of something with a shadow working? Any help would be great, I'm going to kick myself when I find it I know I will, it'll be something really easy.....It's the player shadow we want, we can do without the rest.
#3
You are right. Only ShapeBase Derived object can get Dynamic Shadows. I used StaticShapeData block which is ShapeBase Derived.
I used:
datablock StaticShapeData(WoodenBridge)
{
Category = "Structure";
ShapeFile = "~/data/DTS/bridge_wood.dts";
shadowEnable = true;
shadowSelfShadow = true;
shadowDTSShadow = true;
shadowSize = 512;
shadowSphereAdjust = 1.5;
shadowBias = 0.001;
};
When I use this object in the mission, this object will not be TSStatic it will be StaticShape which is dervied from ShapeBase. You can have a look in the StaticShape.h file:
class StaticShape: public ShapeBase
{
}
So i think my wooden bridge should receive the shadow from player and should cast own shadow to terrain as well as to itself (selfshadow).
I might have some wrong understanding, please correct me if my concept os wrong.
Thank you.
02/25/2007 (11:00 pm)
Hi Marc,You are right. Only ShapeBase Derived object can get Dynamic Shadows. I used StaticShapeData block which is ShapeBase Derived.
I used:
datablock StaticShapeData(WoodenBridge)
{
Category = "Structure";
ShapeFile = "~/data/DTS/bridge_wood.dts";
shadowEnable = true;
shadowSelfShadow = true;
shadowDTSShadow = true;
shadowSize = 512;
shadowSphereAdjust = 1.5;
shadowBias = 0.001;
};
When I use this object in the mission, this object will not be TSStatic it will be StaticShape which is dervied from ShapeBase. You can have a look in the StaticShape.h file:
class StaticShape: public ShapeBase
{
}
So i think my wooden bridge should receive the shadow from player and should cast own shadow to terrain as well as to itself (selfshadow).
I might have some wrong understanding, please correct me if my concept os wrong.
Thank you.
#4
Might be that simply the shadow casting range isn't far enough for itself (not sure on that)
I'm not that good at explaining that so you might want to check out this thread:
www.garagegames.com/mg/forums/result.thread.php?qt=58417
02/25/2007 (11:13 pm)
How large is the bridge?Might be that simply the shadow casting range isn't far enough for itself (not sure on that)
I'm not that good at explaining that so you might want to check out this thread:
www.garagegames.com/mg/forums/result.thread.php?qt=58417
#5
Thanks for quick reply. I am looking into your suggested link.
On a side note, I just wanted to mention that when in the previous configuration, I added a Dynamic light near the bridge and it produces 2 shadow of the player in the bridge (one from the sun light and other from the dynamic light) but no shadow of the bridge itseld nor any dynamci shadow.
But now the dynamic light don't even cast any shadow of the player on the bridge.
Thank you.
02/25/2007 (11:46 pm)
Hi Marc,Thanks for quick reply. I am looking into your suggested link.
On a side note, I just wanted to mention that when in the previous configuration, I added a Dynamic light near the bridge and it produces 2 shadow of the player in the bridge (one from the sun light and other from the dynamic light) but no shadow of the bridge itseld nor any dynamci shadow.
But now the dynamic light don't even cast any shadow of the player on the bridge.
Thank you.
#6
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
Now the bridge cast shadows in the terrain. A sample screen shot is given below:

But I have still problem. The bridge doesn't receive any shadows from player. and selfshadow is not working at all. a sample screensjot is given again:

If anyone can point out the problem, it will be greatly appreciated.
Thank you.
02/26/2007 (3:00 am)
Some portion of the shadow is now working. I changes the following field of the datablock:shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
Now the bridge cast shadows in the terrain. A sample screen shot is given below:

But I have still problem. The bridge doesn't receive any shadows from player. and selfshadow is not working at all. a sample screensjot is given again:

If anyone can point out the problem, it will be greatly appreciated.
Thank you.
#7
I think you'll find that as you decrease the sizes of
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
the shadow will darken to a point and you may be able to see it, and then eventually vanish again as it goes past the point where you needed it in the first place.
The shadowProjectionDistance = 150; value means that your bridge will cast a shadow anything up to 150 meters away onto the terrain if it neded to, so you should be able to reduce this.
The shadowMaxVisibleDistance = 250; means you can have the camera anything up to 250 meters away and still see the shadow before it lods out.
I'm also just trying to get my head around all this, but it seems to me that if you've got a dts the size of the orc, it's no problem to get it to self shadow etc, but as things increase in size, you have to increase the two values above, and the self shadowing/dts shadowing either doesn't display, or has lodded out or something. I'm sure it'll be something quite simple once we find out what it is,......It's just finding out what it is. It's easy when you know how eh?
I've spent a good deal of the weekend on it though, I'm a bit stumped I have to say....
02/26/2007 (3:31 am)
Hi Mahmud, you've probably read the thread I've been working on about this from the link above...I have the exact same problem as you.I think you'll find that as you decrease the sizes of
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
the shadow will darken to a point and you may be able to see it, and then eventually vanish again as it goes past the point where you needed it in the first place.
The shadowProjectionDistance = 150; value means that your bridge will cast a shadow anything up to 150 meters away onto the terrain if it neded to, so you should be able to reduce this.
The shadowMaxVisibleDistance = 250; means you can have the camera anything up to 250 meters away and still see the shadow before it lods out.
I'm also just trying to get my head around all this, but it seems to me that if you've got a dts the size of the orc, it's no problem to get it to self shadow etc, but as things increase in size, you have to increase the two values above, and the self shadowing/dts shadowing either doesn't display, or has lodded out or something. I'm sure it'll be something quite simple once we find out what it is,......It's just finding out what it is. It's easy when you know how eh?
I've spent a good deal of the weekend on it though, I'm a bit stumped I have to say....
#8
Thanks for your detailed analysis. As you can see, in my case the the bridge is casting shadow in the ground.
I'll try your suggestion to see if I can tweak the shadow for better view.
I got another problem as you'll see in the second image, the orc is not casting shadow in the bridge. I got it done before, but somehow i changes some values and could not remember what it was and teh shadow is gone. The orc still cast shadow in the terrain but not in the bridge. Thats strange i think.
Keep in touch :-)
Thank you.
02/26/2007 (4:21 am)
Hi Harvey,Thanks for your detailed analysis. As you can see, in my case the the bridge is casting shadow in the ground.
I'll try your suggestion to see if I can tweak the shadow for better view.
I got another problem as you'll see in the second image, the orc is not casting shadow in the bridge. I got it done before, but somehow i changes some values and could not remember what it was and teh shadow is gone. The orc still cast shadow in the terrain but not in the bridge. Thats strange i think.
Keep in touch :-)
Thank you.
#9
You showed the datablock that sets it for the bridge but you did not clarify if the ork has it set as well. From the screenshot it is hard to say if it has.
DTS - DTS shadow needs self shadow to be enabled.
This is just to make sure in case it is not a 1:1 copy of the demo ork with datablock etc.
If you are sure that it is, just skip this post :)
02/26/2007 (5:50 am)
Self shadowing is enabled on the ork and the bridge, right?You showed the datablock that sets it for the bridge but you did not clarify if the ork has it set as well. From the screenshot it is hard to say if it has.
DTS - DTS shadow needs self shadow to be enabled.
This is just to make sure in case it is not a 1:1 copy of the demo ork with datablock etc.
If you are sure that it is, just skip this post :)
#10
In my case the selfShadow for player is enabled. I think my problem is more of a engine configuration related rather then datablock, because at first it was working but for some reason it stopped working.
But from the postings of Harvey's thread I successfully tewaked the shadow for the bridge to Terrain. So my situation is something like following:
Bridge casts shadow to terrain = TRUE
Player casts shadow to terrain = TRUE
Player casts shadow to itself (self shadow) = TRUE
Player casts shadow to bridge = FALSE
Bridge casts shadow to itdelf (self shadow) = FALSE
02/26/2007 (7:00 am)
Hi Marc,In my case the selfShadow for player is enabled. I think my problem is more of a engine configuration related rather then datablock, because at first it was working but for some reason it stopped working.
But from the postings of Harvey's thread I successfully tewaked the shadow for the bridge to Terrain. So my situation is something like following:
Bridge casts shadow to terrain = TRUE
Player casts shadow to terrain = TRUE
Player casts shadow to itself (self shadow) = TRUE
Player casts shadow to bridge = FALSE
Bridge casts shadow to itdelf (self shadow) = FALSE
#11
That's what I kind of think's happening...
02/26/2007 (7:27 am)
So is this because your bridge is over a certain size, and so it's the only thing that's not behaving itself? ie. If the bridge were say a barrel or crate instead, and not quite as big, would it be sitting there behaving itself and shadowing correctly do you think? Because the player is of a certain size it's fine??That's what I kind of think's happening...
#12
Thank you.
02/26/2007 (8:43 am)
I don't know if the problem is due to it's size. I have a bridge and a jetty in my level. The Jetty is almost one fourth of the bridge. Both of them are behaving same way.Thank you.
#13
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
If you reduce them significantly they may work. Sounds like you'rehaving the EXACT same problem as I am...
02/26/2007 (8:49 am)
Hmmm...do they all use these figures?shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
If you reduce them significantly they may work. Sounds like you'rehaving the EXACT same problem as I am...
#14
02/26/2007 (10:27 am)
Can you send over a test mod that shows the one or two objects that are not shadowing correctly and I'll take a look at it.
#15
I used
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
for Bridge and
shadowProjectionDistance = 100;
shadowMaxVisibleDistance = 250;
for the Jetty. Reducing the projection distance didn't help. The shadow got dim and then it disappeared.
@ John, How can I send you the mod? do you need the script file as well?
Thank you.
02/26/2007 (11:44 pm)
@ HarveyI used
shadowProjectionDistance = 150;
shadowMaxVisibleDistance = 250;
for Bridge and
shadowProjectionDistance = 100;
shadowMaxVisibleDistance = 250;
for the Jetty. Reducing the projection distance didn't help. The shadow got dim and then it disappeared.
@ John, How can I send you the mod? do you need the script file as well?
Thank you.
#16
I am preparing a test mod with the objects having problem with shadows.
Let me know how can I send it to you.
Thanks.
02/27/2007 (12:02 am)
@ JohnI am preparing a test mod with the objects having problem with shadows.
Let me know how can I send it to you.
Thanks.
#17
03/02/2007 (1:12 pm)
If the file is around 1M you can send it directly to me (email in profile), otherwise upload the file to You Send It and assign me as the recipient.
#18
Sorry for late reply. I was busy with other stuff. I am preparing a small mod for you and will upload soon.
Thank you,
Mahmud
03/12/2007 (5:11 am)
Hi John,Sorry for late reply. I was busy with other stuff. I am preparing a small mod for you and will upload soon.
Thank you,
Mahmud
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
http://tdn.garagegames.com/wiki/Torque/LightingSystem/DTS_Lighting_and_Shadows#DTS_Shadows lists the supported shadow types
And http://tdn.garagegames.com/wiki/TorqueShaderEngine/LightingSystem/Dynamic_Shadows says, that only ShapeBase derived can get DTS shadow.