- Home /
Surface Shader: Achieve pure black
I am trying to create a lit shader, that behaves just like always, but - under some conditions - is pure black. I created a surface shader and adapted the surf function:
if (condition < 0.5) {
o.Albedo = 0;
o.Metallic = 0;
o.Smoothness = 0;
o.Alpha = 1;
} else {
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
The result looks like this:
As you can see, it kind of works, but the black area is still influenced by lighting. What is the simplest way to achieve a pure black that is not influenced by lighting? Do I have to use vertex+fragment shaders or can surface shaders do this?
I'm using the deferred rendering path.
(does the answer differ for forward rendering?)
Answer by Pangamini · Jan 23, 2018 at 06:51 PM
Would the Final Color Modifier be what you need?
Answer by aurelioprovedo · Jan 24, 2018 at 12:19 PM
You also have to implement a custom lighting function for your surface shader. Add the same condition and return a black color.
Your answer
Follow this Question
Related Questions
Unity Surface Shader - Deferred lighting viewDir and lightDir 0 Answers
How to define custom deferred ambient lighting? 0 Answers
Spherical Hamonics - ShadeSH9 and Surface Shader issue 0 Answers
Switching shader Lighting On/Off from script 1 Answer
Surface shader: modify the emission with lighting? 3 Answers