Jump to content
  • Advertisement
Jan Haas

How to design a material system that can be dynamically updated?

This topic is 436 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

Hello guys ;)

My engine is currently only capable of rendering using materials that are shared among different meshes. (Change one parameter -> every mesh has it)
So my rendering loop looks like this:
for all materials m: upload common matrices (projection etc.). Use the shader. Then for all meshes associated with m: Render it after uploading model matrix.

But what if I want to instance a material (like in UE4)? This would mean that I either have to create a different shaderprogram for all different instances OR use one common shaderprogram. The last option implies that I have to update the uniforms of said shaderprogram each time I render an object with a material instance. 

So I don't know whats worse: A State change or high frequency updates of uniforms which decreases my bandwidth? 
My question: What is the best way to deal with the problem and how would a possible render loop look like?

Thank you.

Share this post

Link to post
Share on other sites

I would go with updating a constant buffer that contains the material parameters. It's very common to update a constant buffer before issuing a Draw, so drivers will try to optimize for that case. For DX11, you can see this article from Nvidia on how to optimize your constant buffer updates, and use D3D11.1 features in Windows 8.1 to make updating them even faster. On DX12/Vulkan/consoles updating a constant buffer is (almost) completely in your hands, and so you can potentially make it *really* fast.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!