I know how to make it simple with textures. I wonder how to implement blinking or eye movement. I've been looking for a YouTube course and there's a few textures that say eye rigging, but I'm not satisfied.
From what I understand he uses drivers to control the Mapping X and Y location values with an empty. To do that you need to create your object, an empty (parent it to the object) and this kind of setup:
Then right click on the Mapping X location value of the eye texture and choose Add Driver, then in the driver's window you need the following settings: Object > Empty, Type > X Location, Space > Local Space, also find the good Expression variable which seems to be "*-0.2" for me (?):
Same thing to make the eyes move on the Z axis, right click on the Y location value, but this time you need to choose Type > Z Location.
You could also control the eyes with the Texture Coordinate's Object option and choose an empty as Object on the bottom.
For the eye blinking you could draw the eyelid on the same image as the pupil, you'll just need to move the empty until it's visible.
You can also use a bone instead of an empty.
Looking at the node setup it seems the idea is you have multiple textures:
- eye white (sclera)
- eye black (iris + pupil)
- eye mask, using red channel as alpha channel.
And the idea is that you draw the body, then the eye white, masked by eye mask, then you move the eye black some distance away from center in the direction of an empty or a bone or anything else controlling the eye movement, also masked by the eye mask.
Now, actually in your setup the eye white and eye black are combined together. Makes sense especially if the eye white is not a solid color and you want it to move together with the eye black.
Of course in actual shading the idea is implemented slightly differently:
- if you're outside of a mask, draw body texture
- otherwise draw eye black+white, with the coordinates translated by an empty (or bone etc.)
- you probably want to clamp the values to some maximum value, so the black doesn't go outside the mask (so it becomes invisible or travels into the other eye)
In the node setup below I'm using the vector difference (separate distances on axes) of the empty to the center of the cube, and vector-add that to the UV:
Unmuting the nodes will enable clamping:
It works only because I rotated the cube so it looks upwards and the X/Y axes of UV and object coordinates are aligned. You need to parent the empty to the cube in this configuration before rotating the cube, so that the setup works in any orientation of the cube.