9
$\begingroup$

I'm struggle with vector displacement shader. I'm trying to do something like reverse cone but I can't figure out how to add radial direction. I would like to use RGB curves like screw (lathe) modifier but in shader. My actual setup: enter image description here

$\endgroup$
1
  • $\begingroup$ Hi, I've got it into Tangent space, but with a limitation. See edit $\endgroup$
    – Robin Betts
    Mar 27, 2020 at 8:30

1 Answer 1

12
+500
$\begingroup$

The strategy in this example is to generate the displaced position Q of the shading point P (in an originally planar Object space), and subtract P from Q to give the displacement vector.

The displacement is masked. If P is outside the input Radius (r2 in the tree) from object 0 , it is not displaced. A soft border has been put on the mask to prevent unsightly tearing of the surface.

Q's Z is a mapping of the mask-circle. The circumference of the circle is mapped to Z = 0, the center to Z = (Input) h. The circle is 'drawn upwards' from its center.

Q's X and Y are more easily calculated in polar coordinates. There are 2 groups in the tree, for converting between polar and Cartesian coordinates, so the mapping need only be of r, the radius of P. (Pr -> Qr)

First, Pr, the radius of the shading point, is remapped from 0->r2 to -1->1, so it uses the full range of the Vector Curves node. The result of the curve in the node is then mapped to 0-1. The result, Qr, is recombined with the original theta to get Q's X and Y, and plugged into the 3D vector Q, the displaced position of the shading point. That is then subtracted from the original shading point. The Y and Z components in the Curve node have been set to map to 0.

enter image description here

A shader-generated pawn

I'll try to get this into Blender-compatible tangent space (unfortunately, that's not standard), so it can be, say, tiled onto deformable surfaces.

EDIT:

OK, some progress, this has been shuffled into Tangent Space:

enter image description here

.. which involves working in corner-to center displaced UV coordinates, and subtracting radii, rather than entire displacement, and adding the Y -> Normal coordinate in as an absolute component.

This answer is getting long, so I won't illustrate the tree again, it's in the Blend. But there's still a problem: this does not scale elegantly. The Normal displacement (which is absolute) is not proportional to the face size (which is relative, from the UV mapping). Again, I'll try to fix this, unless you or someone else gets there first. I hope eventually we can get to a single switchable tree, which would be more generally useful, and strip this answer back.

$\endgroup$
5
  • 1
    $\begingroup$ Great! Thank you.. It is possible to convert this solution to object space (IDK if object space is right term - just in direction of surface normal) $\endgroup$
    – Destrosvet
    Mar 26, 2020 at 10:09
  • 1
    $\begingroup$ OMG (this site needs emo) $\endgroup$
    – vklidu
    Oct 20, 2020 at 20:13
  • $\begingroup$ @Jachym Wow! what can I say? I was kind of hiding from the bounty section, licking my wounds, not being able to give SHikha Mittal a nice answer.. (At least, giving that problem a break.) I know there will be really nice questions and answers out there I can give this rep away to, before long. $\endgroup$
    – Robin Betts
    Oct 23, 2020 at 18:16
  • $\begingroup$ @Robin Sorry I missed your comment before, SE didn't ping me :). No need to take the bounties personally :D, I just use them to highlight underrated answers. Besides, it's just internet points, what else am I going to do with them? $\endgroup$ Feb 24, 2021 at 8:42
  • 1
    $\begingroup$ ... @Jachym ..(We) going to do with them? Zackerly. Actually, this answer could be improved. I could already improve it some. I'll wait until I can improve it lots. Erindale a master in this area $\endgroup$
    – Robin Betts
    Feb 24, 2021 at 8:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .