Home Website Youtube GitHub

Eye rig orientation

Hey guys,

I’'m currently using the eye rigger for the first time and everything works really well, however I do have a question. How do you control the orientation of the I rig. I know it’s based on the pivot of the eye, that makes sense however I find it quite hard to orient correctly. In my case you’d expect the orientation would be the line between the two eye corners and then the axis would be related to that. Is there any way to control the orientation either with the default tools or with custom steps. My pivot is in the center of the eye.

Thanks a lot!

Cheers Ralph

First, just to check the simple stuff first: Did you remember to check “Set Manual Vertex Corners”? I always forget to do that.

But in the code, I believe it gets the upvector from a function in facial_rigger.eye_rigger.py march_vertex()

And march_vertex() simply looks for the middle vertex between your two corners.
upperVert = pathOne[int(round(len(pathOne) * 0.5) - 1)]

So if you count the middle vertex, you’ll likely find that is where the controls are pointing.

Maybe eye_rigger should have an optional field to specify a top vertex for orientation. Or march_vertex() could have an option to search for the closest to a point that is perpendicular to the corners, like in your drawing, instead of simply the middle one.

The skew might also happen around this line, where it calculates the upvector in worldspace relative to the average of the 4 corner vertices and the bboxCenter, which I think is the center of your eye geometry:

# Tracking
    # Eye aim control
    t_arrow = transform.getTransformLookingAt(bboxCenter,
                                              averagePosition,
                                              upPos.getPosition(space='world'),
                                              axis="zy", negate=False)

If that’s the case, and you aren’t comfortable with Python, and you want a hack right now, you might be able to use a fake temporary sphere as eye geometry, and line it up so it perfectly matches the middle of your eye socket, even if it doesn’t fit inside the eye socket. And that might straighten out the skew.

(But I’m not sure. I’ve never tested that. I’m just reading the code.)

2 Likes

Hey Chris,

Thanks for your reply. I think you are right and it’s probably a combination of both the things you mentioned. I did checked the manual vertex corners :slight_smile: I made that mistake the first time but unfortunately that didn’t fix it. Before I posted I tried the thing with the dummy eye ball but I never really got expected results. It adjusts the x and y orientation but not the z axis if you know what I mean. It’s almost as if the orientation should be mirrored. I think if you use the vector between the vertex corners and cross product that with the z axis you get a nice orientation. I’m quite comfortable with python so I’ll dive into the code as well to see if I can fix it.

Thanks for your help! Love your blog btw!

Ralph

1 Like

If you dig into the code and find a more robust way of orienting the eye, or find something that you suspect is wrong or flipped/mirrored, definitely consider making a PR on Github, or flagging it here.

Love your blog btw!

thanks! :slight_smile:

1 Like

So I’ve been browsing through the code and made a small adjustment that works for me personally . I’m basically using the two corner vertices to calculate the normal that is used to orient the main “eyeLid_L_center_lookatRoot” group. Like I said it works for me but not sure if it works in all the cases since I don’t know the full code implementation. I’m sure this can be optimized but maybe it’s of some help.

if extCorner:
        try:
            normalPos = pm.PyNode(extCorner)
            npw = normalPos.getPosition(space='world')
            if side == "R":
                outPos = pm.PyNode(intCorner)
                normalVec = inPos.getPosition(space='world') - outPos.getPosition(space='world')
                # normalVec = npw - bboxCenter ----old
            else:
                outPos = pm.PyNode(extCorner)
                normalVec = inPos.getPosition(space='world') - outPos.getPosition(space='world')
                # normalVec = bboxCenter - npw -----old

Again thanks!

Ralph

1 Like