Triangle color from code

Started by
1 comment, last by Adam_42 10 years, 10 months ago
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.
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.

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.

This topic is closed to new replies.

Advertisement