Sign in to follow this  
Noggs

Rendering organization

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this