Game Development Community

Small Atlas perf fix

by Tom Spilman · in Torque Game Engine Advanced · 03/03/2007 (4:22 pm) · 8 replies

This shows up as a minor win on my box here, but it is wasted effort. Currently the Atlas terrain takes as much as 4 passes to render. Well currently zbuffer writing is enabled on all 4 passes when it is only really needed in the first pass.

The fix is simple. In the function AtlasClipMapBatcher::render() in atlas\runtime\atlasClipMapBatcher.cpp:

GFX->setVertexShaderConstF( 6, (const F32*)waterZ, 1 );
  
   renderClipMap();
   GFX->setZWriteEnable( false );  // NO MORE ZWRITES NEEDED
   renderDetail();
   renderLight();
   renderFog();

I saw a 1 fps win here, but if you were extremely fill-rate bound that may be different.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
03/03/2007 (5:50 pm)
Wouldnt that prevent the detail texture from being rendered?

Or is renderDetail referring to something else?

addikt
#2
03/03/2007 (6:18 pm)
No... the renderClipMap() draws the basic terrain and puts down zbuffer values. The other calls just need to do ztests and don't need to write the same zvalues into the buffer 3 more times.
#3
03/04/2007 (5:06 am)
Where are you getting the shader call from? Is that from your own codebase, or did I perhaps miss an update? (Q not related to zbuffer, I added that fix fine, thanks)
#4
03/04/2007 (5:14 am)
@Erik - Oh... that's a new hack i'm testing. It fixes the z flicker where the terrain meets the water. As soon as i clean it up i'll post it for everyone. ;)
#5
03/04/2007 (7:36 am)
Nice :-)
Would be interesting to see if it would be hard to combine it with my detail hack that allows setting the detail texture information (start fade, end fade and detail repeat) through the editor, for each atlas2 instance on its own.
(the resource for that is currently waiting to be approved)
#6
03/04/2007 (12:58 pm)
Oh oh, the z flicker fix sounds just like what I need, that bugs me that thing.. no pun intended...hehe

addikt
#7
03/04/2007 (6:53 pm)
@Marc - You mean like this hack? Great minds think alike. ;) Feel free to merge anything useful from my post into your resource.
#8
03/04/2007 (10:17 pm)
Yes like this one.
Search didn't show that thread up at all (looking for "atlas2 detail") so I added it myself and made it a resource so future people searching for something like this are able to find it due to keywords at least until it is added to TGEA itself *no idea why it isn't in but hardcoded*. The board search still seems to be very useless unless it works massively different than even altavista search a decade ago.