TorqueShaderEngine/LightingSystem/Performance Considerations
From TDN
|
[edit] IntroductionTGEA performance considerations.
[edit] Generic PerformanceSee Generic Performance Considerations.
[edit] Dynamic Lighting PerformanceDynamic lighting is rendered using additional passes on top of the base light map layer, which creates rendering overhead. It's always best to use static lighting whenever possible (for information on the differences between static and dynamic lighting see Static vs Dynamic Lights).
Avoid large radius dynamic lights and keep lights spread out to reduce overdraw and help improve performance.
Feature Optimizations
There are several dynamic lighting optimizations controlled through the light datablock's Features property. The property determines which of the base material features (diffuse, bump, specular, cube mapping, ...) the lighting reproduces. Removing lighting features increases rendering performance by reducing shader complexity, and, because some features are often difficult to see in normal lighting conditions, it rarely affects the scene's visual quality.
The lighting features are:
Full - reproduces the entire base material features (highest rendering overhead) Non Torque Lighting System lights (weapon fire, explosion, fxLight) all use the NoSpecCube feature for maximum performance.
Dual Light Optimizations
Under certain conditions two lights can render simultaneously as a "Dual" light - avoiding an additional rendering pass and reducing overall shader complexity.
In most cases rendering a "Dual" light eliminates 80% of the second light's overhead, rendering it nearly for free.
The "Dual" light optimization is dependent on the light's features:
Full - un-optimized, always renders in its own pass (avoid this at all costs!) Zoning
Breaking interiors into zones is critical to getting to highest performance out of Torque. A full list of performance gains is beyond the scope of this article, however zoning is critical to dynamic lighting performance in the following ways:
Limiting Dynamically Lit Geometry - like the base rendering pass, dynamic lighting renders the entire zone in one large and efficient geometry chunk. Interior dynamic lighting is always treated as zoned lighting (limited to the containing zone), so creating smaller zones reduces the amount of geometry rendered by dynamic lights.
Limiting Overdraw - because dynamic lighting renders the entire zone, creating smaller zones also reduces the number of overlapping lights and the overdraw they create.
Limiting Visible Lights - because dynamic lighting is limited to the light's zone, the lighting is culled when the zone isn't visible. Creating smaller zones increases the likelihood of culling.
[edit] Dynamic Shadow PerformanceDynamic shadows use a lot of system resources and reduce performance, so it's important to balance the overhead with the visual impact in the scene, making sure to get the most out of the used resources.
The most important performance improvement is to only enable dynamic shadows on objects that absolutely need them and to use objects that cast static shadows elsewhere.
Likewise self-shadowing and DTS-shadowing have a high rendering overhead (especially on high poly objects) and should only be used on objects that absolutely need it.
Disabling Cast Shadows on all but the key scene lights reduces the total number of dynamic shadows.
Disabling multi-shadows limits the shadows-per-object to one, reducing the total number of shadows considerably.
Dynamic shadows require render targets for generating the shadow image. Due to advanced caching and shared z-buffers the memory usage for these targets is heavily reduced, however having a large number of on-screen shadows will consume considerable video memory. So again limit dynamic shadow usage to the objects that absolutely need them. Also try to keep shadow sizes small.
Keep visible distances of shadows to a minimum to reduce the number of on-screen shadows even when a large number of shadow casting objects are visible (assuming they are all varying distances from the viewer).
Use short shadow projection distances to reduce the number of surfaces the shadow is clipped against, the number of rendered shadow pieces, and to improve the likelihood of sections being culled.
Disable move and animate to stop the shadow image (animate) and shadow pieces (move) from being recalculated. This only works well on static objects, which really should use static shadows, however another similar technique that works well on dynamic objects is to increase the animation frame skip (the number of frames rendered between image recalculations).
|



