Sign in to follow this  

Coloring a Vertex why?

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

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
Specifying an individual colour per vertex is probably most obvious when using gouraud shading. Instead of having the whole polygon the same colour (flat shading), you can specify an individual colour for each vertex.

This may or may not help:



Basically, you don't specify a colour for each pixel, just for each vertex. In order to get the colour at any given pixel, it has to be calculated- this is done by interpolating between the colours at the vertices.

If sombody wants to expand on that... (I'm not much good at explaining stuff)

Share this post


Link to post
Share on other sites
Another use for coloring, but on top of textures being used. Did you play any 16-bit RPGs, or I think even final fantasy 7 did this. You see an enemy at the beginning of the game, then you see the same thing later, more powerful, and with a red tint. Sometimes they use the same texture and color it like that, other times it actually is a different texture, but that is another use of color vertices. But if you have smooth shading on(not sure what is called in DX), then you have to color all vertices.

Share this post


Link to post
Share on other sites
Quote:
Original post by CyberFox
Hey, it just accrued to me how DXSprites go about doing color modulation! Learn something new every day. [smile]


Accrued? Someone has been taking too many economics courses! [grin]

Share this post


Link to post
Share on other sites
Quote:
Or to few spelling ones...

> "Or too few spelling ones..."
Sorry, I couldn't pass this up [smile]

Also, if I tell DirectX not to modulate (or is it diffuse?) texture colors, then will it simply mask the color over the texture (ex. Make it solid white)?

Share this post


Link to post
Share on other sites

This topic is 4558 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this