Game Development Community

[Bug 1.0] Having Performance Issues with Basic Lighting

by Joshua Halls (Xerves) · in Torque 3D Professional · 10/01/2009 (5:11 pm) · 11 replies

We ported over from Beta4 to 1.0 and it seems at least on one of my test machines I am having a rather drastic reduction in framerate (70 -> 50). The machine is a single core AMD (3200) and I tested both an Nvidia 7600 and an ATI 4650 and both are losing just about the same % of framerates. AL seems to be on par if not slightly better and on another machine (Intel 8400/Nvidia GTX260) I am not seeing as much of a loss in BL (once I disable glow/shadows I tend to get about the same performance in BL in this machine).

Anyone else seen any metrics like this? I made sure I was comparing the same scene as much as possible and made sure the poly/draw count was similiar.

About the author

Part of the team that works on The Repopulation, a SciFi based MMO using a heavily modified version of the Torque MMO Kit - T3D. I also take care of the T3D version of the Torque MMO Kit.


#1
10/01/2009 (5:24 pm)
I would guess it's related to the addition of shadows in BL.
#2
10/01/2009 (5:31 pm)
Hum... so your seeing a drop in framerate in BL from the beta4 build to the 1.0 release correct?
#3
10/01/2009 (5:51 pm)
We did have a B5 build so I tested that and it wasn't as much as the 1.0 build in frameloss, but still a 75 -> 65 loss compared to around 75 -> 55. Same effect on the better machine though, hardly a change in framerate.
#4
10/01/2009 (8:33 pm)
After some tinkering I found these bits of code in the lighting.hlsl shader files.

#ifndef TORQUE_BL_NOSPOTLIGHT

If I remove this code (or put in that flag) I regain about 50% of what I lost. Spotlights seem to work as well. This shader file changes from B5->1.0.
#5
10/01/2009 (10:23 pm)
Sounds then like your fillrate bound on these systems and the new spotlight attenuation is hurting you.

Its totally valid to disable it if you want... spots will then act like point lights which may or may not be acceptable for your game.

The plan in 1.1 is to expose more performance tweaks to the developer like disabling spotlights... using vertex fog... disable normal mapping... etc. You'll then be able to define your games default low/medium/high target settings as well as what is visible to the end user from the custom settings.
#6
10/01/2009 (10:47 pm)
Sounds about right as I am sure the GTX260 I have will do a better better in the fillrate department. Any other changes off the top of you head from B4->1.0 that might effect Basic Light in regards to fillrate?
#7
10/01/2009 (11:44 pm)
Things get fuzzy and what was in beta1 or beta5 is hard to remember when your churning out code for a year. ;)

Its possible that the refactor of the lighting occured in beta5 which allowed for 4 lights per-mesh instead of one. That would be the biggest change to BL that occured that i can think of.

Really your best bet is to look at the procedural shaders folder for beta4 and 1.0 and compare a few random shaders. It should be clear pretty quick if something else changed that i'm forgetting.
#8
10/03/2009 (3:40 pm)
@Tom: Should this particular bit be causing performance issues if there are no spot lights in the scene (the mission itself has no spot lights just points).
#9
10/03/2009 (5:03 pm)
makes little sense as point lights commonly are the by far most expensive ones ...

question is if the define itself is the cause not what it activates.
also compare the shaders if the one for "with spot lights" potentially is better opted.
#10
10/04/2009 (4:42 pm)
@Joshua - Yes. The lighting is unified.... it can do 4 lights of any mix. So even if you don't have any spotlights it does cost a few more instructions per-pixel to have support for them. This allow us to move lights dynamically without the need for swapping shaders or extra draw calls as different lights effect geometry.

If i get some time i'll take another pass thru the lighting code and see if i can optimize it further while keeping it all per-pixel.

I'm thinking we could expose to the material system a 'no spotlights' option so you can tune individual materials if this is really a big win for you.

It would also be possible to add a 'vertex lighting' mode at the cost of having bad lighting on less tesselated geometry.

@Marc - Actually spotlights are the most expensive light type to have. A spotlight is a point light with extra work to attenuate the cone.
#11
10/04/2009 (5:40 pm)
For the most part we are looking at squeeking out as much performance out of Basic Lighting as humanly possible as that represents the low end market for those who would be playing our game (older mid-range cards to newer low-end cards). The testing I was doing was with an ATI 4650 ($50 new) and an older GForce 7600GT. Mainly, if they aren't willing to pay out for at least a mid-range card we want the game to run, it doesn't have to look great through for the low end stuff.

Again, anything that provides an option of turning down "looks" for "performance" of course is best for reaching as many customers as we can. We also put in changes to the Groundcover system so you can modify foliage count and distance from the client, might also look into that as well. Worked pretty well once we changed the code to billboard per cell instead of total billboards.