Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Adding Rim Light to Unity5 Standard Shader

Discussion in 'Shaders' started by MongoBongo, Apr 3, 2015.

  1. MongoBongo

    MongoBongo

    Joined:
    Dec 18, 2014
    Posts:
    5
    Ok, so I kinda understand the basics of surface shader writing, but getting lost when it comes to the vertex/frag stuff. I'm trying to figure out how to add the relatively simple rim light Emission effect to the Standard Shader to create the typical "glow on mouseover" effect. As well as apply it to the Albedo/Diffuse for a sort of outline effect (different from Image Effects Outline).

    So started digging thru the Standard Shader code, but can't for the life of me figure out how to get this to work. At first I thought it would go in the StandardInput include, but can't seem to pull the view direction vector - viewDir doesn't seem to work and no other references to it I can find in there. So ended up looking in the StandardCore include, but having problems finding references to the Normal Map there.

    Can anybody toss me a clue to point me in the right direction?
     
  2. MongoBongo

    MongoBongo

    Joined:
    Dec 18, 2014
    Posts:
    5
    Found a possible solution that appears to work.

    Most of the work seems to happen in the fragForwardBase function in the StandardCore include.
    -s.eyeVec (negative of the vector) seems to be the viewDir
    s.normalWorld is the reference to the Normal Map

    Hope that is right and helps anyone else poking around for an answer.