Jump to content
  • Advertisement
Sign in to follow this  
Noggs

Rendering organization

This topic is 3071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!