- Home /
Non traditional Shader, for adding saturation
I am trying to make a shader, that uses lights to saturate an image. I start with an already colored image and when it is in the "shadow" it looses its color. I am still learning Unity's shader system, but the issue lies in the return value of LightingBasicDiffuse() is added to the color, not set to. and the function surf() does not appear to have a way to look at lights in the scene.
CGPROGRAM
#pragma surface surf BasicDiffuse
#pragma target 3.0
sampler2D _MainTex;
float _Desat;
float _Darken;
inline float4 LightingBasicDiffuse (SurfaceOutput s, fixed3 lightDir, fixed atten)
{
float4 col;
float difLight = dot (s.Normal, lightDir);
if(atten<0.1){
float avrg = (col.r+col.g+col.b)/3;
col.rgb=float4(avrg,avrg,avrg,1);
return col;
}else{
col.rgb = s.Albedo*0.5;
//col.rgb=float4(0.5,0.5,0.5,1);
col.a = s.Alpha;
return col;
}
}
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
float4 c;
c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
One of two ways I see that I can fix this, either I need to find what to include in the pragma that does the addition from LightingBasicDiffuse() or I need to expose the atten variable in the surf() function, and I really don't know how to do either.
Your answer

Follow this Question
Related Questions
How to make a conditional #pragma surface noforwardadd 1 Answer
How to force the compilation of a shader in Unity? 5 Answers
Shader.SetKeyword per material? 0 Answers
conditional pragma target 0 Answers