Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Eye Shader

Discussion in 'Works In Progress - Archive' started by jRocket, Dec 7, 2013.

  1. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
    I'm making a unity eye shader inspired by Valves eye shader and the CryEngine eye shader.

    Features
    • Separate shading passes that represent the inner iris and outer cornia bump
    • Parallax effect
    • Animated pupil dilation(looks really good)
    • "Lookat" script that prevents crosseyedness when the target gets too close

    It's kind of hard to see all the effects with a still image, so I will upload a video to Youtube soon. :D

    $eyes.png
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
  3. snowconesolid

    snowconesolid

    Joined:
    Dec 9, 2011
    Posts:
    868
    Thats a nice looking shader. Good work! Eyes Look great.
     
  4. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
    Thanks! Next thing to do- make a whole bunch of eye textures!
     
  5. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Very cool!
     
  6. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,789
    This is very cool :D It would be awesome to have a feature where the eye samples the current light amount hitting the shader, and automatically dilates the pupil accordingly. I look forward to seeing what types of eye variations can be done with this, great work.
     
  7. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
    I am indeed working on an auto dilation script, essentially by implementing the lighting model on a per model basis. I'm not sure how accurate that be, as it only takes into account direct light entering the eye, and ambient. it should be possible to detect if a light is obscured(eye in shadow) :)
     
  8. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    If I recall, the Crytek people did pupil dilation right in the shader. Whatever texture coordinate math they had for changing the dilation, they tied directly into N dot L. Something to think about :).
     
  9. Deleted User

    Deleted User

    Guest

    You recall correctly..

    This is very interesting, keep up the good work jRocket.
     
  10. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,789
    Yeah, crossing NdotL with the current pupil pixels should give an accurate enough approximation :)
     
  11. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Sorry to be boring on your thread but I'm looking for a mobile-friendly eye shader and was wondering if you have something along those lines in the asset store.
     
  12. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
    I haven't tested yet but this should work for mobile.(compiles for ogl es 2.0). There's also a lower quality version of the shader that doesn't have parallax ray tracing

    It is now on the asset store as well. LINK
     
  13. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,964
    WOW, nice!

    Eyes are very important on a character! I'll consider getting this in a near future!
     
  14. TheShane

    TheShane

    Joined:
    May 26, 2013
    Posts:
    136
    I knew I was going to like this from the title. It is both awesome and slightly creepy! It would be great to parametrize the shape of the pupil somehow to create squarish sheep eyes, vertical cat eyes, or demonic star-shaped eyes, etc. Differentially dilating based on the radial position input into some arbitrary function (even just sine and cosine would probably be neat).

    I don't have a need for anything like this now, but I'll have to remember about it for later. Keep up the good work!
     
  15. Cheburek

    Cheburek

    Joined:
    Jan 30, 2012
    Posts:
    384
    omg you extracted those eyes from your avatar!? No wonder he has such a frightened look.. :eek:
     
  16. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    This looks very nice! Cat and reptile eyes would be a great addition.
     
  17. Lemo76

    Lemo76

    Joined:
    Aug 7, 2012
    Posts:
    174
    Eye. Love. It!
     
  18. FernandoRibeiro

    FernandoRibeiro

    Joined:
    Sep 23, 2009
    Posts:
    1,362
    Wow! Those would look amazing on UMA!
     
  19. fly06bzh

    fly06bzh

    Joined:
    Jan 16, 2014
    Posts:
    12
    hello
    I wonder if this is compatible android platform, and if so, if it does not take too many resources
     
  20. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    699
    The main shader compiles to OGL ES 2.0, but I haven't tested on android yet. It should be noted that this is an expensive shader, but in most cases it will not take up a lot of pixels on screen at once

    The fallback shader(without eye depth/parallax effect) should work on all platforms. I plan to test on android soon.
     
  21. fly06bzh

    fly06bzh

    Joined:
    Jan 16, 2014
    Posts:
    12
    in fact what I need is dilated pupils