GeFroce2 MX: texture stages unexprected behaviour

Started by
9 comments, last by S1CA 18 years, 5 months ago
Quote:Original post by tokaplan
Thanks a lot, S1CA, that was great!!
I just have one question left: how bad is the performance penalty for multipass rendering? Is it the same as rendering twice?
Thank you a lot!


In terms of the API calls to D3D and depending on the cost of your scene manager, it can be as bad as rendering twice. If your app is CPU bound, you might not want to incur that cost, or at least not for everything (scalable shader-LOD is a good idea - drop some part of your lighting for far away objects when running on older hardware.

If you have a lot of static stuff which shares the same state/shaders you can pre-transform it into world space at load/author time to significantly reduce API and driver call overhead.

In terms of the actual rendering, the price of the second pass can be pretty cheap since the first pass filled in the Z buffer for you so the second pass only renders pixels that are truly visible (i.e. the 2nd pass has 0 overdraw for all opaque geometry). In some situations, particularly with complex pixel shaders/texture blending it can even make sense to "lay down Z" first and do 3 passes where the first pass only writes to the Z buffer (the COLORWRITE render state set accordingly). That way complex (slow) pixel processing is only performed for pixels that actually need to be visible.


Quote:Actually, this is not specular, this is the whole lighting - diffuse + ambient. I do it in a shader.


Even so, Sim (who knows more than I do about the inner workings of nVidia chips than I do [wink]) has a point which I touched on briefly (but no so well): you can add the per-vertex Gouraud interpolated specular on for free... that's *something* extra at the end of your pipeline that you may be able to squash your lighting equation into - doesn't have to be specular either - just remember you have extra operations that occur after the traditional texture blend cascade.


BTW: if you're looking for stuff to drop when reorganising/simplifying lighting, per-vertex diffuse looks pretty good unless you have really low-polygon models - per-vertex specular on the other hand looks pretty bad unless you have really high tesselation. So if you're stuck and want to do per-pixel lighting, do the specular per pixel and the diffuse per vertex (it looks better than the other way around).

Also bear in mind that per-pixel diffuse lighting without moving objects or moving light sources is effectively just an expensive form of detail texturing - use detail texturing if things don't move (same doesn't work for specular, though some forms of emboss will give ok-ish results)...

BTW2: Sim's journal here is well worth a read if you want to aim for high end effects on lower end cards.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement