Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

ignore ambient in a surface shader

Discussion in 'Shaders' started by the_gnoblin, Oct 22, 2010.

  1. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    Hello,

    Is it possible to stop a surface shader from reacting to ambient light in a scene?

    thanks
     
  2. snakeylake

    snakeylake

    Joined:
    Aug 20, 2010
    Posts:
    19
    Hi,
    I think you can use a custom parameter instead of albedo ( also make sure albedo is 0 ). Your shader with custom lighting will use the parameter that you've set. The ambient light shading code which you have no control of ( not that I've figured out yet ) will use albedo of 0 and have no effect.

    hope this makes sense
     
  3. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    Could you provide an example?
    thanks
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    You would have to use a custom lighting function, and thus your shader wouldn't work with the deferred renderer.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Are you sure that the specification of the own lighting function does not work with deferred rendering?
    I was under the impression that they work independent of the rendering path but have not tested with that yet.
     
  6. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    As you know, Unity uses deferred lighting (as opposed to deferred shading) which means that rendering is split into three phases: geometry buffer rendering, the irradiance buffer generation, and the shading pass. If you want to change how the irradiance values are used, you can do that in the shading pass, which is customizable. However, you have no control over the formula used in generating the irradiance buffer, so (for instance) ambient light will always be included there.

    Check out Lighting.cginc to see exactly how the two types of lighting functions (forward and prepass) relate to one another.
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Guess will have to do that.
    Didn't require own lighting so far, thats why I could happily avoid going down that path (and on the iOS I don't give a *** about it ;)).

    Thanks for the hint.
     
  8. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Last edited: Sep 21, 2011