Game Development Community

T3D 1.1 Beta 3 - Huge Performance Drop with Shadowless Groundcover and Point Light Shadows - RESOLVED

by Oscar Velzi · in Torque 3D Professional · 03/11/2011 (5:33 am) · 22 replies

Thread Body:

Build: 1.1 Beta 3

Platform: Windows XP 32bit

Target: Editors

Issues: When a pointlight is set to cast shadows and interacts with the groundcover, there is a huge performance drop, even if all the groundcover shapes materials are set to not cast any shadows.

Steps to Repeat:
1. Create a terrain and a ground cover with 1 billboard and 3 meshes and a dense amount of it.
2. Create some point light shadows interacting with the groundcover and set them to cast shadows.


img861.imageshack.us/img861/1977/noshadows.jpg

img862.imageshack.us/img862/174/shadows.jpg

As you can see, FPS dropped from 125 to 57 even if no shadows are cast.
Page «Previous 1 2
#1
03/11/2011 (10:05 am)
How much the framerate drops if you remove the ground cover (just using the bare terrain?)
#2
03/11/2011 (10:13 am)
Around 25-30 FPS, I know that there is some overhead when adding lights and shadows, but a 65-70 fps hit seems quite high, and the only thing that these lights affect is the groundcover (not even the terrain). I'm going to try with the groundcover object materials with shadow casting enabled.

EDIT: Just tested with the materials set to cast shadows and the performance is exactly the same (55-60) when the lights are activated.

It almost seems that the pointlights shadows are taking into account the groundcover when rendering, no matter if the shadows are cast or not. But this is just an observation from someone who knows nothing of code or the actual rendering code.
#3
03/11/2011 (10:24 am)
Thanks for the report... we'll investigate it. THREED-1434
#4
03/11/2011 (12:56 pm)
Hey Oscar, I tried repoing this and couldn't get the same performance drop you've described. To make sure the issue hasn't already been fixed in our repo, would you mind sending me a .mis file with the case reproduced? You can just send it to rayatsickheadgamesdotcom (The address in my profile.) and we'll take a look at it. This will really help us.

I went into the FPSExample's blank level and created a terrain and ground cover, added three meshes and a billboard to the covers types. Then I increased the maxElements on the ground cover to 18,000, created three point lights and toggled their shadows. Anything I missed?

Thanks!
#5
03/11/2011 (1:25 pm)
The ground cover doesn't cast shadows... but does it receive them? If you place a shadow casting object over it, does it cast shadows on the ground cover?
#6
03/11/2011 (8:07 pm)
@Ray: Sent ;)

@Manoel: Yeah, the objects receive them. No object is casting shadows on them ATM, but they can. Maybe it's that?
#7
03/14/2011 (6:04 am)
@Oscar: most likely. If they can receive shadows this means they are executing the shadow receiving shader (sample shadow texture, perform depth comparison, etc) even if there are no shadow casters around. Do they show up if you go into the World Editor and toggle the "display normals" view mode?
#8
03/14/2011 (11:56 am)
I have 4 different layers in the groundcover:

- One uses the billboards, they always show up in the normals view mode, no matter the material settings.

- The second uses a grass mesh, that uses transparency, transparent z-write and alpha threshold. This one does not appear.

- The other two layers use meshes with only alpha threshold in their materials, and appears on the normals view.

They all have cast shadows disabled, BTW.
#9
03/16/2011 (2:44 pm)
Hey Oscar, we've looked into it all and think we've found the problem.

Would you mind trying the following fix and let me know if it solved the problem? This way we can mark this issue as resolved and move on to another : )

in ...Engine/source/lighting/shadowMap/lightShadowMap.h
/// All the shadow maps that have been reciently rendered to.
   static Vector<LightShadowMap*> smUsedShadowMaps;

   /// The object types to render into the shadows.
   static U32 smShadowObjectTypes; //<--- LINE ADDED

   virtual void _render(   SceneGraph *sceneManager, 
                           const SceneState *diffuseState ) = 0;

Now near the top of ...Engine/source/lighting/shadowMap/lightShadowMap.cpp
Vector<LightShadowMap*> LightShadowMap::smUsedShadowMaps;
Vector<LightShadowMap*> LightShadowMap::smShadowMaps;
U32 LightShadowMap::smShadowObjectTypes = TerrainObjectType | ShadowCasterObjectType | StaticRenderedObjectType | ShapeBaseObjectType; //<--- LINE ADDED

Now, you need to make the following replacement to the following files...
.../Engine/source/lighting/shadowMap/cubeLightShadowMap.cpp
.../Engine/source/lighting/shadowMap/dualParaboloidLightShadowMap.cpp
.../Engine/source/lighting/shadowMap/paraboloidLightShadowMap.cpp

sceneManager->renderScene(baseState, smShadowObjectTypes); //<-- ARGUMENT ADDED

And the following change in EnginesourcelightingshadowMapsingleLightShadowMap.cpp
U32 objectMask = smShadowObjectTypes; //<-- LINE CHANGED

Lastly, in Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp

U32 objectMask = smShadowObjectTypes; //<-- LINE CHANGED
      if ( i == mNumSplits-1 && params->lastSplitTerrainOnly )
         objectMask = TerrainObjectType;
      else // DELETE THIS LINE
         objectMask = ShadowCasterObjectType | StaticRenderedObjectType | ShapeBaseObjectType; //DELETE THIS LINE TOO

Hopefully, you should no longer see this performance drop!
#10
03/16/2011 (8:41 pm)
Thanks! I'll tell my programmer to add that and tell you how it goes =)
#11
03/18/2011 (11:35 am)
Hey Oscar, any news? I can't close or commit this fix until I get that confirmation :)
#12
03/18/2011 (11:39 am)
Well, yesterday my programmer went to Kiev to see a Irish metal band and to celebrate Saint Patrick's day, so I'm waiting for him to come back (and sober up) :P
#13
03/18/2011 (3:15 pm)
Ah, programmers :D
#14
03/18/2011 (3:44 pm)
What? Who's here?

*opens one eye*

Oh, that's you, guys... The build is uploaded and ready. May testing commence!
#15
03/18/2011 (8:51 pm)
Ray, you are awesome, that fixed it completely. Thank you!

And thanks Nick for implementing it :D


img143.imageshack.us/img143/1954/beforeck.jpg

img856.imageshack.us/img856/1605/afterh.jpg
#16
03/22/2011 (5:56 pm)
Cool, I'll mark this as resolved. Thanks for the test files, they helped!
#17
05/04/2011 (1:12 pm)
Sidenote: The original fix here solved the problem by not rendering GroundCover into the shadow passes at all. However, this also caused GroundCovers that are using shapes instead of billboards to not have shadows anymore. This is fixed for 1.1 final.
#18
05/04/2011 (1:16 pm)
Actually, I was using shapes in this particular case, they look much better for a top down game, and I don't want them to cast shadows. Will they cast them even if the "cast shadows" in the materials is set to false?
#19
05/04/2011 (1:28 pm)
Quote:Will they cast them even if the "cast shadows" in the materials is set to false?

Polys rendered with "Cast Shadows" turned off won't cast shadows. However, if you want all the shapes to not cast shadows, this will be in-efficient as the materials come into play pretty late in the game. IMO there should be a switch like "shapesCastShadows" on GroundCover to summarily turn the shadow rendering for replicated shapes on or off.
#20
05/04/2011 (1:30 pm)
Yeah, such a switch will really be handy.
Page «Previous 1 2