Coloring a Vertex why?

Started by
15 comments, last by deadimp 18 years, 10 months ago
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?

Beginner in Game Development?  Read here. And read here.

 

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

Beginner in Game Development?  Read here. And read here.

 

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,
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.
maybe i should notify everyone that i'm a complete n00b when it comes to these things, especially 3D in general

Beginner in Game Development?  Read here. And read here.

 

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
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?

Beginner in Game Development?  Read here. And read here.

 

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
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.
Bulma

This topic is closed to new replies.

Advertisement