Shadow Speed Problem?
by Ken Searle · in Torque Game Engine · 10/25/2004 (10:26 pm) · 23 replies
I am having an odd speed problem with Shadows, but can't quite figure out why. If anyone can explain or has ideas that would be appreciated.
Here is what happens.
When I add 1 Roman style Column (15.24 meters high) on a new mission terrain, it takes about 15-17 seconds to do a one time render of the shadow onto the terrain. When I add 6 more Columns the total render time is only about 30 seconds. I can deal with that since it is only once.
Now starting over with no Columns, I add a single large platform as its own object instance 50x50x10 meters which uses the default gray castle wall texture. Adding 1 Column on it, the render time of the shadow onto the platform is also about 15-17 seconds, but when I add the other 6 Columns on top of the platform, it takes over 5 minutes to render the shadows on the platform.
When all the renders are done the shadows look very nice, but I can't afford 5 minutes for 6 Columns when my completed area would have about 400+ Columns on the platform. I have to find another way.
If I can't figure it out, I am thinking of turning off Shadows while I am working and then let them render over night.
Anyone have an idea of why this happens what I could do? Thanks.
Here is what happens.
When I add 1 Roman style Column (15.24 meters high) on a new mission terrain, it takes about 15-17 seconds to do a one time render of the shadow onto the terrain. When I add 6 more Columns the total render time is only about 30 seconds. I can deal with that since it is only once.
Now starting over with no Columns, I add a single large platform as its own object instance 50x50x10 meters which uses the default gray castle wall texture. Adding 1 Column on it, the render time of the shadow onto the platform is also about 15-17 seconds, but when I add the other 6 Columns on top of the platform, it takes over 5 minutes to render the shadows on the platform.
When all the renders are done the shadows look very nice, but I can't afford 5 minutes for 6 Columns when my completed area would have about 400+ Columns on the platform. I have to find another way.
If I can't figure it out, I am thinking of turning off Shadows while I am working and then let them render over night.
Anyone have an idea of why this happens what I could do? Thanks.
About the author
#2
Have you tried to set the detail on the shadowmaps down a bit to see if it lightens the load?
10/25/2004 (11:53 pm)
Somewhere around 1 second, right.. depending on complexity.Have you tried to set the detail on the shadowmaps down a bit to see if it lightens the load?
#3
I had been doing tests to see how big I could scale the aiplayer model and found that once I scaled upto 70-120 times the size of the normal model the game would drop to around 20-30 fps.
Someone on the IRC channel pointed me towards the fact that the shadows could be the cuase and when I turned them off my fps jumped back up again.
Are you scaling your columns or bringing them in at the size they are modelled at?
I dont know whether the scaling cuases the shadows to have this problem or whether it is just the huge shadows themselves that it does not like rendering...
10/26/2004 (12:56 am)
I dont know if this is related but I was getting huge FPS drops due to shadows.I had been doing tests to see how big I could scale the aiplayer model and found that once I scaled upto 70-120 times the size of the normal model the game would drop to around 20-30 fps.
Someone on the IRC channel pointed me towards the fact that the shadows could be the cuase and when I turned them off my fps jumped back up again.
Are you scaling your columns or bringing them in at the size they are modelled at?
I dont know whether the scaling cuases the shadows to have this problem or whether it is just the huge shadows themselves that it does not like rendering...
#4
To Stephan : I have not tried changing the detail on the shadowmaps so I will look for that.
To David : I am still using the default FPS player model in its original, the new mission terrain in its original scale and I am bringing in the models at the scale they were created. I definitely suspect it to be a shadow problem.
To All : Thanks for the feedback.
10/26/2004 (2:37 am)
To Billy Sce : My card is a slower ATI 128 Rage Pro so I expect it will run slower than most people on this site. I doubt I will get near a 1 sec render no matter what I do but the jump from 15-20 seconds up to 5 minutes is my concern. My Columns are .dif and have 280 vertices.To Stephan : I have not tried changing the detail on the shadowmaps so I will look for that.
To David : I am still using the default FPS player model in its original, the new mission terrain in its original scale and I am bringing in the models at the scale they were created. I definitely suspect it to be a shadow problem.
To All : Thanks for the feedback.
#5
10/26/2004 (3:02 am)
Sorry, but I didn't see any properties in the sun or sky or elsewhere to set the detail on shadowmaps lower. Anyone know where that setting is? In the code somewhere?
#6
I use a Gforce2 32 mb :)
280 vertices is nothing , i have buildings with over 3000 and it takes max 2 sec to relight the scene !
client/prefs.cs
$pref::Shadows = "0";
10/26/2004 (3:54 am)
@Ken I use a Gforce2 32 mb :)
280 vertices is nothing , i have buildings with over 3000 and it takes max 2 sec to relight the scene !
client/prefs.cs
$pref::Shadows = "0";
#7
10/26/2004 (4:29 am)
You might find that graphics cards have very little to do with scene relighting, all processing power. Displaying it will depend on your graphics card.
#8
I am modifying the example starter.fps code so I saw two files named prefs.cs
torque/example/starter.fps/client/prefs.cs
torque/example/common/client/prefs.cs
I changed $pref::shadows = "2"; to $pref::shadows = "0";
but the Shadow from the Column is still being drawn.
I reloaded the program and rebuilt the scene from a New Mission and the Column Shadow still shows up. Even after rebuilding/compiling the entire solution.
I also commented out all of the code for
ShapeBase::renderShadow(F32 dist, F32 fogAmount) in shapeBase.cc
but still the Column Shadow Shows.
I commented the function calls in Shadow::Shadow() in Shadow.cc
but still the Column Shadow Shows.
Does anyone know where the code is that controls these shadows so I can at least completely turn them until I can find out the problem. Thanks
10/26/2004 (10:18 pm)
OK, I tried to reduce or completely remove the shadow as a temporary workaround, but nothing I have changed seems to have any affect on the shadow. In all cases I have tried, I still get a highly detailed nice looking shadow which has the same shape as my column onto the platform.I am modifying the example starter.fps code so I saw two files named prefs.cs
torque/example/starter.fps/client/prefs.cs
torque/example/common/client/prefs.cs
I changed $pref::shadows = "2"; to $pref::shadows = "0";
but the Shadow from the Column is still being drawn.
I reloaded the program and rebuilt the scene from a New Mission and the Column Shadow still shows up. Even after rebuilding/compiling the entire solution.
I also commented out all of the code for
ShapeBase::renderShadow(F32 dist, F32 fogAmount) in shapeBase.cc
but still the Column Shadow Shows.
I commented the function calls in Shadow::Shadow() in Shadow.cc
but still the Column Shadow Shows.
Does anyone know where the code is that controls these shadows so I can at least completely turn them until I can find out the problem. Thanks
#10
The directions say to place the files in the fps/client/scripts and fps/client/ui directorys. I do not have an fps directory but have a starter.fps directory so I placed the files in starter.fps/client/scripts and start.fps/client/ui.
I tried re-starting and recompiling the entire project and solution but do not see any changes when I open the main menu options button. I see the deafult options and not the ones shown in the screenshot.
CVS has them marked these files in red so I do not know if I need to do something to have the solution recognize them.
I have been able to install other code like having non-repeating terrain so this gives me further questions.
10/28/2004 (9:27 pm)
Now I really feel like an idiot. I downloaded these files and am trying to install them but can't see any new options yet. The directions say to place the files in the fps/client/scripts and fps/client/ui directorys. I do not have an fps directory but have a starter.fps directory so I placed the files in starter.fps/client/scripts and start.fps/client/ui.
I tried re-starting and recompiling the entire project and solution but do not see any changes when I open the main menu options button. I see the deafult options and not the ones shown in the screenshot.
CVS has them marked these files in red so I do not know if I need to do something to have the solution recognize them.
I have been able to install other code like having non-repeating terrain so this gives me further questions.
#11
10/28/2004 (9:30 pm)
I can't beleive it is this hard just to turn shadows off. Isn't there a line of code that does it?
#12
The former have basically no overhead to render - they take the same amount of time no matter how complex the object. There is a lightmap rendering step that happens when a mission is loaded - this happens once, then the results are cached until the mission file is changed. These lightmaps are how static shadows on terrain and interiors are done. All of the lightmap calculations are done on the CPU. GPU has no bearing on them.
The latter do have an overhead, as they have to be dynamically added to the scene every frame. As you might imagine this can be costly, especially if you have a big, complex shadow spanning a lot of scene geometry. This sort of shadow does depend on a fast GPU, although it will work just fine even on very low end cards.
If you're seeing a lightmap render time in the minutes for just a few objects, there's something deeply wrong. Have you tried looking at your scene in wireframe mode (f9 toggles, I think)? How many faces are actually in your pillar? Even for complex level geometry like in Tim Aste's content packs, it doesn't take more than a few minutes to light a level. It sounds like maybe something is broken with your shapes...
10/29/2004 (1:26 pm)
Realize that there are two types of shadows in the engine, baked-in shadows from lightmaps and dynamic shadows from moving objects.The former have basically no overhead to render - they take the same amount of time no matter how complex the object. There is a lightmap rendering step that happens when a mission is loaded - this happens once, then the results are cached until the mission file is changed. These lightmaps are how static shadows on terrain and interiors are done. All of the lightmap calculations are done on the CPU. GPU has no bearing on them.
The latter do have an overhead, as they have to be dynamically added to the scene every frame. As you might imagine this can be costly, especially if you have a big, complex shadow spanning a lot of scene geometry. This sort of shadow does depend on a fast GPU, although it will work just fine even on very low end cards.
If you're seeing a lightmap render time in the minutes for just a few objects, there's something deeply wrong. Have you tried looking at your scene in wireframe mode (f9 toggles, I think)? How many faces are actually in your pillar? Even for complex level geometry like in Tim Aste's content packs, it doesn't take more than a few minutes to light a level. It sounds like maybe something is broken with your shapes...
#13
This problem I have right now is the one time render that it takes to draw the baked in shadows (Over 5 minutes with just 6 Columns). One Column is a .dif with 280 vertices.
I also get long delays if I use multiple towers from the default starter.fps. Again, beautiful shadows but after several minutes to load.
If I render objects over terrain it is much faster than rendering on a simple box platform that is 50x50x10 meters (with the default castle wall texture.
I will look into your suggestions.
10/29/2004 (2:07 pm)
Thanks Ben.This problem I have right now is the one time render that it takes to draw the baked in shadows (Over 5 minutes with just 6 Columns). One Column is a .dif with 280 vertices.
I also get long delays if I use multiple towers from the default starter.fps. Again, beautiful shadows but after several minutes to load.
If I render objects over terrain it is much faster than rendering on a simple box platform that is 50x50x10 meters (with the default castle wall texture.
I will look into your suggestions.
#14
I have decided to wipe everything out and start over with the latest download code as of Yesterday (1.3).
I will see if I can get the Advanced Options to work with the new version.
I will recheck my Columns to try and optimize having all pieces in integer units and will retest staring with a simple 1 piece column and work my way up.
I have a 733Mhz Pentium with ATI Rage Pro 32MB video so I hope to be upgrading to a better development system soon.
I will continue to work at it since I believe it is better to learn how to optimize correctly before going crazy with larger scenes.
Thanks for helping.
10/29/2004 (2:13 pm)
Thanks everyone. Here is what I will do.I have decided to wipe everything out and start over with the latest download code as of Yesterday (1.3).
I will see if I can get the Advanced Options to work with the new version.
I will recheck my Columns to try and optimize having all pieces in integer units and will retest staring with a simple 1 piece column and work my way up.
I have a 733Mhz Pentium with ATI Rage Pro 32MB video so I hope to be upgrading to a better development system soon.
I will continue to work at it since I believe it is better to learn how to optimize correctly before going crazy with larger scenes.
Thanks for helping.
#15
10/29/2004 (3:37 pm)
I thought I was missing something!! Are shadows supposed to be on by default? If not, how do I turn em on, because I have no shadows whatsoever in my mission, but several trees and dif. objects. Using version 1.3. Thanks.
#16
I just downloaded 1.3 and went into the default mission. The existing buildings have baked shadows. If I add towers and press (Alt-L) the shadows are made in that mission.
In a New Mission I placed some Columns over the terrain and got mixed results, Some with Shadows and some without.
Thinking it might be due to the angle of the sun, being behind a hill, or my Column, I went to the tallest hill and placed a lot of simple cubes all around (on the sunny side).
I detected about 16-17 shadows out of 20 cubes. I looked carefully for the others, where shadows should have been, but they were not there.
It seems that at certain angles or thresholds, shadows do not draw according to what my eyes would expect.
I thought I would mention it because when I placed my first couple of columns I could not detect any shadows on a new mission terrain.
10/29/2004 (7:59 pm)
@RobertI just downloaded 1.3 and went into the default mission. The existing buildings have baked shadows. If I add towers and press (Alt-L) the shadows are made in that mission.
In a New Mission I placed some Columns over the terrain and got mixed results, Some with Shadows and some without.
Thinking it might be due to the angle of the sun, being behind a hill, or my Column, I went to the tallest hill and placed a lot of simple cubes all around (on the sunny side).
I detected about 16-17 shadows out of 20 cubes. I looked carefully for the others, where shadows should have been, but they were not there.
It seems that at certain angles or thresholds, shadows do not draw according to what my eyes would expect.
I thought I would mention it because when I placed my first couple of columns I could not detect any shadows on a new mission terrain.
#17
10/29/2004 (8:01 pm)
One thing ruled out. I downloaded the 1.3 code and still have the same slowness issues in the same places. Still have to try the other ideas.
#18
10/29/2004 (9:18 pm)
Thanks for the reply Ken. My player character has a dynamic shadow, but that seems to be the only one in the mission. I'll try placing the sun in a higher position, and see if that changes anything. Cheers.
#19
As a dynamic dts, I am pretty sure the default character's shadow is calculated differently. It is definitely more visible to me while the terrrain shadows are wider and very subtle in some cases.
10/29/2004 (9:45 pm)
@RobertAs a dynamic dts, I am pretty sure the default character's shadow is calculated differently. It is definitely more visible to me while the terrrain shadows are wider and very subtle in some cases.
#20
Now to my original problem. If I turn all of the options down to the lowest setttings, it does not seem to have any impact on my problem with baked shadows.
It does definitity speed up dynamic draw time so my framerate and mouse response are faster. Thus it is a nice addition and will help.
Next I will experiment with simpler Columns.
10/29/2004 (11:52 pm)
I got the Advanced Options Dialog working from the above link from Bill ScE. It turns out that there were a couple of .dso files that would not reset and thus I kept seeing the default Options Dialog. Finally I deleted the dso files manually and got that working.Now to my original problem. If I turn all of the options down to the lowest setttings, it does not seem to have any impact on my problem with baked shadows.
It does definitity speed up dynamic draw time so my framerate and mouse response are faster. Thus it is a nice addition and will help.
Next I will experiment with simpler Columns.
Torque 3D Owner Billy L
Are these columns complex shapes ,are they dif or dts shapes.
Because this should take less then 1 sec to render.