Jump to content

  • Log In with Google      Sign In   
  • Create Account


Triangle color from code


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Littorio   Members   -  Reputation: 254

Like
0Likes
Like

Posted 31 May 2013 - 05:34 PM

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.

Sponsor:

#2 frob   Moderators   -  Reputation: 20363

Like
0Likes
Like

Posted 31 May 2013 - 07:37 PM

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.
Check out my personal indie blog at bryanwagstaff.com.

#3 Adam_42   Crossbones+   -  Reputation: 2462

Like
2Likes
Like

Posted 31 May 2013 - 07:38 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS