Search Unity

Surface shader problems

Discussion in 'Shaders' started by Ippokratis, Nov 2, 2011.

  1. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi,
    I try to learn coding surface shaders. I have written a couple of simple Cg and openGL shaders so far and I wish to use surface shaders because they behave well on different platforms. I went through the examples, made some modifications, liked the results. Problem is that I have many gaps in my knowledge. In this documentation page says :
    Great.
    The meaning of the Alpha is clear.
    Now, what is the meaning / definition of Albedo, Normal, Emission, Specular, Gloss in this context ?
    I understand more or less that


    • Albedo = comes from this texture mixed with that texture
    • Normal = comes from the normal map
    • Specular = makes things shine
    • Gloss = makes thing shine too (!)
    • Emission = totally lost
    I wish to know more, so I can use surface shaders in their full potential.
    Now, it is clear to me that it is my problem, not Unity's that I have no idea about those things. But I have to ask somewhwere !
    I would appreciate any explanations and references regarding these parameters, so I can start using them efficiently.
    Thanks for your time,
    -Ippokratis
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Albedo is the diffuse reflectance of a surface. It is like _MainTex in most shaders.
    Normal is of course the normal of the surface at that point.
    Gloss and Specular control specular exponent (from the Blinn-Phong equation) and brightness, which is just a multiplier on the specular result. I can never remember which is which, though, because their names are completely opaque, to the point where I believe they are mixed up even internally.
    Emission is light emitted from the surface itself. The colour in emission will be shown at the same brightness regardless of whether the surface is in light or shadow.
     
  3. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    Specular controls the specular exponent and Gloss is a multiplier on the specular result.
     
  4. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi,
    Thanks a lot for the feedback :D
    I now understand that

    • Albedo : shades the texture input.
    • Emission : does not shade the texture input.
    • Specular is a measure of roughness for the specular highlights ( fading between the specular highlights center and edges ).
    • Gloss determines how bright the specular highlights will be.
     
  5. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Other way around, I think.

    Gloss controls the breadth of the specular highlight (high gloss = pin-point highlight, low gloss = broad highlight).
    Specular controls the strength of the specular highlight (high spec = bright, low spec = dull highlight).

    Or at least, it should be that way around. Unity seems to swap them then swap them back in side the surface shaders.
     
  6. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi,
    Thanks for the answers, I ll try to make an example based on this info.
     
  7. cowlinator

    cowlinator

    Joined:
    Mar 15, 2012
    Posts:
    69
    (Bookmarked)

    Thank you! I'm surprised at how hard this was to find. (Maybe I just don't know what to search for)