Hey gang,
Here's my EyeShaderSimple. It includes what I find to be the necessary components for making real time eyes.
This shader is created for Maya, but I don't see any reason for it not to work with 3DSMax. I created it using Mental Mill and exported with Custom CGFX preset. There's an example Maya scene bundled.
You can download the shader here, at bottom of page.
*Updated this first post to match latest version*
Replies
Why not indent the cornea/pupil mesh?
JordanW> I actually played a bit of ME2 yesterday and tried to figure out their eyes, they do look good. Sounds like a cool idea using the parallax, would love to try it, but the parallax implementation from Mental Mill that exports to Maya is borked. I don't know how to fix it either
Do you know how modern games actually handle eyes? Do they use your suggested method?
ME2 Eyes
Shader for this didn't need any alpha. The diffuse part isn't normal map, so unfortunately the larger part of the eye couldn't benefit from a normal map to get a more smooth result. Don't think you notice that well either way. The specular and reflections use a normal map which simulates a spherical cornea.
So now the mesh is indented for counter lighting on the diffuse part. Normal map takes care of faking spherical cornea for specular and reflection.
Keep those suggestions coming, appreciate it.
[ame]http://www.youtube.com/watch?v=YK7spXJXecc[/ame]
Solved this with tweaking the diffuse and reflectivity textures.
Btw I was lazy and re used old UV layout from when I used a transparent cornea, so I'm not using the UV space efficiently here.
There's also the possibility to use a specular (colored) with gloss stored in it's alpha, I'm not using it in this example.
Here's the bundled example:
Once again, normal map is only affecting the specular and reflections not the diffuse texture.
But the specular is very tigh, does it behave well in motion even tough the geometry is not what the normal map is storing? I mean the normals are correct, but doesn't it appear to swing because it is still related to the mesh surface?
Btw the highlights of the cube are clamped, maybe you should look into putting those extra bright bits in a multiplier in the alpha or something, so that they don't have that 'gray ldr' look. Since you have a fresnel factor that problem will show up a lot
The specular seems to behave quite well imo, but I haven't studied eyes in detail to know for sure. There's a gloss factor and possibility to use a gloss texture if one would like to tweak this. There's a youtube clip above with a moving light which shows how the specular bends with the normal map.
The reflections have a gain value you can tweak that will multiply the reflections with itself to make the light areas pop. The gain on the example images above has already been tweaked compared to no gain at all, could push it further. Is this what you meant with tweaking them?
add realism. (or did I misunderstand you?)
Now that you show me I am tempted to add that. However I'm not sure how to get them that smooth in a good feasible way. Depth map shadows could work, but probably not that smooth and probably jagged, risk or artifacts as well. Painting them on the diffuse wouldn't work if these are to be animated eyes. Maybe some form of plane with a transparent solution?
Any ideas on this? Would be nice to get this kind of result right in your viewport/hardware render.
Here's just a random youtube clip to illusrate:
[ame]http://www.youtube.com/watch?v=ur7uvLwNb0U[/ame]
Here's a gif as well showing you a comparisson. Didn't show up with regular IMG tags.
eyeShadowComparisson.gif
Solved it with polygon planes with transparency. Please give me some opinions on this solution. Would this be a possible solution for a game? Why not? How else?
You can download the shader here, at bottom of page.
**Changes in v0.3 since v0.2**
Added drop shadow fake to simulate the shadow under the eyelid. This is done by creating a polygon plane, shaping
it along and placing it at the eyeball. Switch to the "Drop_Shadow_Transp_use_Diff_Alpha" technique and add an
alpha channel to your diffuse texture. Any surface area which isn't completely opaque will not recieve lighting,
specular highlights or reflections, this is so the shadow fake stays black. Look at the bundled project to see how
this works. There's also a Transparency Gain and Transparecy Subtract to fine tune the effect.
Here's a video of my shader showcase example, got all excited and did a bit of rigging as well
[ame]http://www.youtube.com/watch?v=EzH4q0lq8K8[/ame]
Contemplating on maybe trying to add eyelashes as well.
Not really happy with them, could be better. Ideas? Suggestions?
You might want to add geometry for the pupil so you can dilate the eyes growing/shrinking the iris by scaling the pupil geometry. I've done this with morph/blend shapes, animated UV's and even carefully placed bones set to scale.
Stuff like this is mostly used in cinematic work but a realtime solution would indeed rock.
Quick note about upper eye lashes, they are often thicker and longer than the lower lashes. Also lashes are at their longest in the enter of the eye and get shorter toward the corners of the eyes.