I'm attempting to use micropolygon displacement to displace a cube into a larger cube, in an attempt to wrap my head around this feature. As near as I can tell, the following should work. Take a cube with each face having UVs in the range -1 to 1, so that 0 is in the center of the face. Calculate the length of the UV, which should be in the range 0 to sqrt(2), and map that to 1 to sqrt(3). Use that as the displacement height. The cube is of course set to smooth shading.
Asked
Active
Viewed 480 times
3 Answers
2
I would like to point out :
- I think your math is off
- You can get the length of a vector with a Vector Math node set to "Length"
- The UV map vector Z coordinate is 0 (I think)
The resulting node tree would be :
But since the "Displacement" node pushes geometry along the normals, you can get rid of your UV map setup like so :
Gorgious
- 30,723
- 2
- 44
- 101
-
Maybe should point out, unless I'm up the creek, (which I often am), that the displacement is along vertex normals, and the same for all, so these solutions rely on there being no vertex at the center of the faces. – Robin Betts Jun 19 '20 at 11:17
-
1You are right, my answer doesn't work if the cube is subdivided. But then if you manage to use the face normal, you get a cube that looks like it was beveled because there is a separation between where the vertex should go according to the different face normals it is attached to – Gorgious Jun 19 '20 at 11:23
-
1A solution would be to use a Vector Displacement node to add the corresponding delta but honestly it seems too complicated for the expected result and wouldn't even be usable on other meshes – Gorgious Jun 19 '20 at 11:32
-
Well, you were right about my math being off, but you solution is also incorrect which is why it only works for a cube with 4 vertices. The displacement value should have been sqrt(1+u^2+v^2) – Chris_F Jun 19 '20 at 19:32
2
Chris_F
- 142
- 5
-
And, if you use a Normal Edit modifier set to radial, (so the displacement is spherical from the center) it still works with an arbitrarily subdivided cube.. (it doesn't, otherwise) – Robin Betts Jun 19 '20 at 20:45
1
I'll add another method suggested by this video.
You need to plug the "Object" coordinates from the "Texture Coordinate" node into a "Vector Displacement" node set to "Object Space", not tangent with a midlevel of 0.
This will scale each point along its base coordinates, thus scaling the geometry uniformly.
Also, it works with a subdivided cube, and really any mesh geometry.
Gorgious
- 30,723
- 2
- 44
- 101
-
1
-
1Yup :) There seems to be a slight deformation along the Z axis though on Suzanne... Couldn't figure why, the cube deformation looks uniform though. – Gorgious Jun 22 '20 at 09:52
-
1Every shading point is displaced by [its own coordinate in the given space] with the origin set to (Midlevel,Midlevel,Midlevel). The displacement, here, actually takes place in Object space. Because the given Generated space is 0-1 along the sides of the object's bounding box, (with its origin at min XYZ,) and a monkey is not a cube, the given Generated space, from which the original coordinates are taken, is non-uniformly scaled with respect to the Object space in which the displacement takes place. Use Object texture coordinates, and a midlevel of 0. – Robin Betts Jun 22 '20 at 10:51
-





