Notifications
Clear all

[Closed] color(diffuse) value at vertex location?

Hi there.

I’m trying to get the diffuse color value from a material for a specific vertex on the surface.
Does anyone know how to do that?

Thanks for any help.

14 Replies
 JHN

There was a thread about that recently, try a search,

-Johan

“barycentric coordinates” is the magic word(s) you are looking for. Search for that and you should get all the information you need.

-Eric

barycentric coordinates?
I’m trying to read the RGB value at a certain location on the surface from a material’s diffuse component, not to locate a point on that surface (this I’ve figured already).
Say I know the UV corrdinates, I’d like to get the color value, whether the material is using a plain color, a bitmap or a procedural texture.
So far I couldn’t find a method to read that value.

JHN: I searched first but couldn’t find anything relevant (probably using the wrong keywords).

edit: found it! Quite a lot of code to go through but that should solve my problem. Thanks!

If you want to evaluate the whole material, you will have to go through the renderer.
Maybe you can bake out a diffuse texture and then sample that texture at all the requested locations.

Thanks for the tip, harefort. I’m getting there

Barycentric Coordinates will give you the uvw position of the face at the specified position on the face. You can’t look up the correlation of world surface to UVW without it, AFAIK. If you are using Bobo’s example from last month you will be using barycentric coordinates to convert/retrieve the color data.

-Eric

Yep, using barycentric coordinates.

-Eric

@PiXeL_MoNKeY: I don’t need barycentric coordinates because I want the color at the vertices’ positions, not in the middle of a face. My question was about reading the color value. Still, I’ll still have to convert from mesh vert to texture vert, but that’s easy.
Thanks anyway.

Thanks, palstic. That’s the exact thread I’ve bookmarked earlier.

Page 1 / 2