Jump to content
  • Advertisement
Sign in to follow this  
diegoarj

Material Animation and Render Queues

This topic is 1430 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 everyone!

 

In my system, I have MaterialDefinition which points to a ShaderProgram and a list of ShaderParameters that the Shader needs. This type of resource is shared, meaning that there is only instance of MaterialDefinition and the ShaderParameters don't contain any value. These are fetched from Material instances. Each Renderable has its own Material Instance, and this way, I can animate Materials in different renderables without affecting other renderables.

 

How would you go about implementing a RenderQueue with key (i.e.: 64-bit integer) based sorting where some of the bits are based on the Material ID and have Material Animation on some of its parameters (animating the colours). The big issue here is that the RenderQueue assumes that Materials with the same ID have exactly the same parameter values so that the number of render commands is reduced but with animation it becomes harder.

 

Creating a key based on the Material Definition would allow me to reduce the number of times I change shaders. Creating a key based on the Material would allow me to reduce shader, textures and parameters changes. However, if I have animations, then each renderable could potentially have different material IDs and would defeat the whole purpose.

 

How would you solve a situation like this?

Share this post


Link to post
Share on other sites
Advertisement

The big issue here is that the RenderQueue assumes that Materials with the same ID have exactly the same parameter values so that the number of render commands is reduced but with animation it becomes harder.

Why would shaders have fixed parameters? It costs more to swap shaders than to change parameters, so you’re only making things slower by doing this.


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites
Sort by definitions first, then instances second?
I.e. Material definition ID in more significant bra of the key than the material instance ID.

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!