The practical cost of swapping effects
Posted
by
sebf
on Game Development
See other posts from Game Development
or by sebf
Published on 2011-02-13T16:55:38Z
Indexed on
2011/02/13
23:33 UTC
Read the original article
Hit count: 302
Hello,
I use XNA for my projects and on those forums I sometimes see references to the fact that swapping an effect for a mesh has a relatively high cost, which surprises me as I thought to swap an effect was simply a case of copying the replacement shader program to the GPU along with appropriate parameters.
I wondered if someone could explain exactly what is costly about this process? And put, if possible, 'relatively' into context?
For example say I wanted to use a short shader to help with picking, I would:
- Change the effect on every object, calculting a unique color to identify it and providing it to the shader.
- Draw all the objects to a render target in memory.
- Get the color from the target and use it to look up the selected object.
What portion of the total time taken to complete that process would be spent swapping the shaders? My instincts would say that rendering the scene again, no matter how simple the shader, would be an order of magnitude slower than any other part of the process so why all the concern over effects?
© Game Development or respective owner