Rendering organization

Started by
1 comment, last by Jason Z 14 years, 2 months ago
Hi guys, I have a couple of questions, the answer to which is probably very straightforward. Whenever I want to render a model with a shader, do I need to set the parameters each time or are they stored? Obviously if they've changed then I'd set them, but would it be worth caching the values on the CPU side and only setting the differing ones? Secondly, if most of my shaders need a viewProjection matrix, what is the best way to implement this? Do I need to know the parameter name for each shader (or use a standard name), store a handle to that parameter, and each time I want to render using the shader set the matrix via the handle? Repeat for all the effects and surfaces I'm rendering? Do you have a set of standard parameters which are always set on an effect?
Advertisement
For the second part of your question, you can specify that a uniform variable corresponds to a particular register. It's common to have "standard" variables, like matrices etc on the same registers in every shader, this way it's simple to set that data.
I'm not so sure about OpenGL, but in D3D11 (I assume D3D9 & D3D10 & OpenGL all are the same) the bindings remain in between draw calls. So it can make sense in some situations to cache the changes only and then set them. I have implemented a system like this in Hieroglyph 3 (see my signature for a link to the project page) if you want to see an implementation.

This topic is closed to new replies.

Advertisement