Jump to content
  • Advertisement
Sign in to follow this  
Alpha_ProgDes

Coloring a Vertex why?

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

Since this isn't a complicated problem, I figured I'll put it here. I'm just wondering why you would color a vertex. It's not like anyone is going to notice the color of one. Are they?

Share this post


Link to post
Share on other sites
Advertisement
From what I understand, the coloring acts as a color mask [espeically if you set diffuse on]. I used this sort of trick to make a bunch of different colored "balls". The actual texture was only a whitescale dot with varying alpha levels. By setting the vertexes to diffuse and changing their color, I had different colored dots while only needing one texture.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
Since this isn't a complicated problem, I figured I'll put it here. I'm just wondering why you would color a vertex. It's not like anyone is going to notice the color of one. Are they?


You can also use the vertex diffuse color to modulate the triangle texture color - you've just did a (very) fake volumetric fog.

There are plenty of use for the vertex colors :)

Regards,

Share this post


Link to post
Share on other sites
There are many reasons, one would be having texts of different colors, or various differently colored bars (health, etc.) without having to use textures.
You cna also use ti for per vertex lighting, and so on.

Share this post


Link to post
Share on other sites
As you mentioned the color of "one", I think you dont quite understand the concept.
Its not just the vertex that is colored but he color of all vertices in the primitive are interpolated. Meaning that if you have a riangle for instace, then haveing one vertex colored will make that are of the triangle of that color. Also the color is added to the texture, so for instance you could have a landscape with a white texture and then have valleys with green vertices and hills with grey or the like.

-CProgrammer

Share this post


Link to post
Share on other sites
ahhh. i think i understand. so lemme try [smile]
so i have a triangle at:

v1 = {0, 1, 1}
v2 = {-1, -1, 1}
v3 = {1, -1, 1}
// where vX = {x, y, z}
// also z positive goes away from the screen


so i have a function: color_vert(&v1, green)
now v1, v2, and v3 will be set to that color and the triangle on the screen will show up green. right?

Share this post


Link to post
Share on other sites
Well it depends on the colors of v2 and v3.
say they are standard white.
then your triangle will be green in the corner v1, about 1/3 of the triangle will be green. In the middle white and green will mix a bit.

Honestly the best hing you can do is just grab an opengl or directx tutorial and play around a bit. Or get some kind of modelling software.
This is in fact something you just know becuase youve seen it and once youve seen it the theory will be relatively clear to you.

-CProgrammer

Share this post


Link to post
Share on other sites
Yes, but only if you do two things:
- set rendering mode to flat shading (D3DRS_SHADEMODE = D3DSHADE_FLAT)
- disable lighting (D3DRS_LIGHTING = FALSE)

What you are doing here is in fact bypassing lighing part of rendering pipeline and providing lighing result by yourself (which is vertex color). With flat shading mode (instead of default, gouraud) you need to specify color for first vertex only in every triangle.

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!