ignore ambient in a surface shader

Hello,

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

thanks

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

Could you provide an example?
thanks

You would have to use a custom lighting function, and thus your shader wouldn’t work with the deferred renderer.

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.

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.

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.

For future searchers like myself:

#pragma surface [I]surfaceFunction lightModel[/I] [B]noambient[/B]
6 Likes