• 13
• 18
• 19
• 27
• 10

# Coloring a Vertex why?

This topic is 4652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 on other sites
wow... i really don't understand. i should stick to 2D [sad]

##### Share on other sites
Quote:
 Original post by Alpha_ProgDesSince 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 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 on other sites
maybe i should notify everyone that i'm a complete n00b when it comes to these things, especially 3D in general

##### 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 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 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 on other sites
Yes, but only if you do two things: