7
$\begingroup$

I created a character that has anormal eyes eyelids, and i had to create this kind of mesh for the eyes to fit on him. I Added a uv warp modifier to control the uv texture, but due to the mesh geometry that are a bit curved in the top, the eye texture gets distorted as I move it. Is there a way to make the texture not be affected by the mesh geometry?

Blender 2.79

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ Hey :). As an alternative to Rich Sedman's brilliant answer, you can also use UV > Project from view, to get rid of the distortion, if you want to use UV coordinates. $\endgroup$ Commented Feb 10, 2021 at 22:43
  • $\begingroup$ It doesn't work, the distortions still are there, you can try it with the the blend file. $\endgroup$
    – Paul
    Commented Feb 11, 2021 at 1:19

3 Answers 3

8
$\begingroup$

Instead of using UV coordinates you can use the Object coordinates of an Empty. In this way, the position of the pupil is controlled by the empty (you should Parent the empty to the eye so that it stays in place as the character moves) and the shape remains undistorted despite the geometry. This can be achieved as follows :

eye based on empty object coordinates

Here the Texture Coordinate's Object socket is used with the Object set to the Empty. This means that each point on the surface is handles in coordinates in relation to the specified object (the Empty) instead of your mesh coordinates.

The Vector Math node set to Multiply is set to mask out the Z coordinate and the following Vector Math set to Distance returns the distance from the centre. The distance is passed into the Color Ramp to produce the eye pattern based on the distance from the centre. If need be you can scale the eye texture by changing the X and Y multipliers in the Multiply node or by scaling the Empty itself.

Moving and rotating the Empty will move the texture, with it always aligned with the empty's Z-axis (although you can pick a different axis by changing which channel is multiplied by zero in the Multiply node).


To use an image texture instead of generating the eye from the distance from the centre, you can use something like the following :

moveable eye as an image

Here the UV coordinates are manipulated using a Vector node to map the centre by 0.5 in each of the X and Y directions. This is to centre the image onto the empty (otherwise it will correspond to the top-left coordinate since that is the 'origin' of the image texture space). The Mix node uses the image Alpha to fill in the surrounding space around the texture. Note also that the Image Texture node is set to Clip so as to have only a single image.


As an aside, the first example (using the distance from the centre) uses nodes that were introduced relatively recently and aren't available at some earlier versions of Blender - in particular the Multiply and Distance modes of the Vector Math node. While the new nodes are very convenient, there are other ways to achieve the same thing - but you have to perform the underlying maths manually rather than relying on the convenient new node functions.

For example, you can achieve the same effect at Blender 2.79 using the following nodes :

distance using maths

Here the Separate XYZ uses only the X and Y coordinates - effectively the same as multiplying Z by zero - while the Power Maths node (raising to the power of 2), the Add, the Power (to the power of 0.5) calculates the distance using Pythagoras (sqrt(x^2 + y^2)). The newer nodes offer a more convenient way by hiding the underlying maths.


Using your example Blend file I imported the material, images and meshes, re-located Empty.001 to near the surface and rotated it 90 degrees so its Z-axis pointed to the surface and scaled to size and produced the following result :

from provided blend file

$\endgroup$
9
  • $\begingroup$ Blender 2.79 doesn't have the distance option in the math node, and I need to use an image texture for the pupil, not a color ramp $\endgroup$
    – Paul
    Commented Feb 11, 2021 at 1:33
  • 1
    $\begingroup$ I've edited the answer to include working with an image as well as how to implement the same at Blender 2.79 where those nodes aren't available. @JachymMichal's suggestion of using Project From View should work too though - I do think that might be worth further exploration if that's an easier solution in your case... although using either method will still show distortion when the eye is viewed from different directions due to being projected onto the geometry. Another option would be to project based on Camera Space but that would be more complicated and might not be the effect you're after. $\endgroup$ Commented Feb 11, 2021 at 7:52
  • $\begingroup$ None of this worked, and i just don't know why, i added all the necessary nodes with the empty, but it simply doesn't move the texture when I move the empty, and de distortion still appears. Image: i.ibb.co/tmdKLcr/Nodes.png Blender file: <img src="https://blend-exchange.giantcowfilms.com/embedImage.png?bid=np2dd4Zs" /> $\endgroup$
    – Paul
    Commented Feb 11, 2021 at 18:36
  • $\begingroup$ @Silly3D Using your example file if I append your Images, Meshes and Materials into my own Blend file and then move Empty.001 to the surface of your 'eye' mesh and rotate it by 90 degrees around X, it seems to work fine. I think the distortion you are seeing is due to the way that the empty is projecting along its Z axis - the rotation by 90 degrees around X puts it in the correct orientation to work with the horizontally pointing eye mesh. You are very close to getting this working. I'll post an image in the answer. $\endgroup$ Commented Feb 11, 2021 at 22:49
  • $\begingroup$ I tried that, and as i expected, it didn't worked, and in the image you posted, the eye still have distortion as it had with the uv warp. i.ibb.co/FwGjCyF/ssss.png <img src="https://blend-exchange.giantcowfilms.com/embedImage.png?bid=GGSLjErX" /> $\endgroup$
    – Paul
    Commented Feb 12, 2021 at 1:58
2
$\begingroup$

To add to Rich Sedman's answer, the reason your texture appears distorted when projecting from the empty is simply that that's how the texture is "supposed" to look, it's already distorted:

Most likely because your UV map wasn't a 1:1 aspect ratio before, you can either scale the empty or change the Scale in your mapping node to squish it back down as needed.

$\endgroup$
4
  • $\begingroup$ I used this texture i.ibb.co/jHppdTH/EEEEEEEEEEEEEEEEEE.png and the result was that: i.ibb.co/cJhVLhB/AAAAZZZZCD.png and as i said to Rich Sedman, the empty doesn't work, and the distortions still are there. $\endgroup$
    – Paul
    Commented Feb 12, 2021 at 16:58
  • $\begingroup$ and i need the eyeball to be big $\endgroup$
    – Paul
    Commented Feb 12, 2021 at 17:04
  • $\begingroup$ @Silly3D In that screenshot you’re connecting the UV socket of the Texture Coordinate node instead of the Object one. That could be why moving the empty doesn’t work. $\endgroup$ Commented Feb 12, 2021 at 20:04
  • $\begingroup$ The empty doesn't work no matter what I do $\endgroup$
    – Paul
    Commented Feb 12, 2021 at 20:17
0
$\begingroup$

A potential workaround is to create a separate mesh for the iris and pupil that you can shape to your desire and then have it just in front of the eye mesh. This can give you a lot of control as a side benefit. Eg look direction, eye expressions, etc.

$\endgroup$
3
  • $\begingroup$ Have it in front of the mesh? and how am I going to move the pupil without leaving the eye mesh? $\endgroup$
    – Paul
    Commented Feb 12, 2021 at 19:51
  • $\begingroup$ Either shape keys, eye bones placed in the right spot, or a combination thereof. I'm basing my answer on how vroid studio makes their anime avatar eyes. You could also use drivers to help keep the pupil on the eye. $\endgroup$ Commented Feb 13, 2021 at 4:54
  • $\begingroup$ Before so much answers I think I just get it, there is no way around with the kind of shape that my eye has, This method won't work because, the pupil will leave the eye mesh due to the distortion even if i put corrective shape keys on it, the distortion will remain on the pupil, becuase the pupil has to follow eye mesh that are distorted, and if the mesh has this kind of geometry, there is no way that something may work, $\endgroup$
    – Paul
    Commented Feb 13, 2021 at 6:13

You must log in to answer this question.

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