3
$\begingroup$

I need a way to flip the UVs in a material depending on the angle of the viewer.

I'm creating an NPR character that looks like this: enter image description here

The eyes and mouth are textured billboards:

enter image description here

They look incorrect if viewed from the wrong side of the face:

enter image description here

I want the UVs to automatically flip when viewed from the left side. I had some limited success by cross-multiplying the normal and view vector, but that works per-fragment, not affecting the object as a whole all at once:

enter image description here

enter image description here

I think to make this approach work I need both the angle of the view/camera, and the angle (world coordinates) of the mouth object. But I haven't been able to find a way to input them into the material nodes.

Any clues at all would be appreciated!

$\endgroup$

1 Answer 1

1
$\begingroup$

Here is what I came up with:

  1. A bone, parented to the character's head bone, that points at the camera using the "Track to" bone constraint
  2. A value input in the material node setup with a driver applied, driven by the rotation of the camera tracking bone
  3. If the rotation of the camera tracking bone is negative, flip the UVs.

bone setup with positive rotation bone setup with negative rotation UV flipping node setup I use a "less than" node to threshold the value to 0 or 1 depending on if the rotation of the camera tracking bone is positive or negative (i.e. if the camera is viewing the left or right side of the face). Then the other math nodes change those thresholded values to either -1 or 1, which when multiplied with the x value of the UV input will either flip the UVs or do nothing.

I hope this crazy thing proves helpful to someone else!

$\endgroup$

You must log in to answer this question.

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