Jump to content
  • Advertisement
Sign in to follow this  
Littorio

Triangle color from code

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

I have to display some meshes where each triangle color depend from a value in an array that can change each frame.
The meshes are loaded when the game run and are not know in advance. The meshes uses shared vertices.

Which would be the best way to implement this? Use a geometry shader?

I will use this to display the hitpoints on each armor segment of the hull on a vehicle.

Share this post


Link to post
Share on other sites
Advertisement
Lots of ways to do it.

Shaders are certainly one perfectly acceptable method. If that makes sense in your case, go ahead.

Swapping textures, dynamically recoloring textures, or setting vertex colors directly may also make sense, depending on your setup.

Share this post


Link to post
Share on other sites

The obvious option is to read SV_PrimitiveID in the pixel shader, and use that to look up the colour from a texture or constant buffer.

 

Alternatively avoid the shared vertices, and do the work in the vertex shader. You could then put the colour data in a separate vertex stream. This should be more efficient than doing it in the pixel shader.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!