0
$\begingroup$

I'm trying to color a cube with its own position in 3D space, which works well with the shader node setup I have, but only sets the colors for the vertices. However, I would like this to interpolate across the faces, so that the position is not only correct at the vertices but between as well. Is there some shader magic to get this working?

Img. of my cube and the colored vertices (note how the upper right corner correctly is set to (1,1,1 = white) but that it's not interpolating across the face middle): enter image description here

$\endgroup$
2
  • $\begingroup$ It's not that it's interpolating incorectly (and it's not really interpolating anyways, not like you think, it's looking at the position of each sample). It's that the 0,0,0 world position is in the middle of your cube, and the negative positions are getting clamped to 0,0,0. You have to decide what you want it to do if position is less than zero or greater than 1. Because your monitor will never be able to display color outside the 0,1 range. $\endgroup$ – Nathan Mar 1 at 15:45
  • $\begingroup$ You're right, ofc I would have to do some kind of normalization. $\endgroup$ – i2n Mar 1 at 15:56
2
$\begingroup$

you can get the result you want by plugging the generated texture coordinates from the vertex positions of your cube in the Texture Coordinate node instead of the Geometry node.

Here's the result :

$\endgroup$
4
  • $\begingroup$ Perfect! Thanks a lot! Bonus question: do you know how I can unwrap this shading effect, and bake it into an image? Or could you give me some pointers as to what keywords to look up ? $\endgroup$ – i2n Mar 1 at 15:57
  • $\begingroup$ I tried baking using the Cycles render engine and trying to use the Emit Bake Type but I have an error that says that there's no active image found in my material even if I have the position plugged in. Tell me if you find. This other post helped a little : blender.stackexchange.com/questions/100731/… $\endgroup$ – sgariepy.3d Mar 1 at 16:13
  • $\begingroup$ I just found out that this is called "render baking" and "texture baking". Thanks guys! $\endgroup$ – i2n Mar 1 at 16:13
  • $\begingroup$ I'm not that familiar with Cycles to be honest. If I had to do it, I would probably import the mesh inside of Substance Painter and bake the position in it. $\endgroup$ – sgariepy.3d Mar 1 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.