- Home /
Get atten value in void surf
I'm making a shader for dynamic objects that are underground getting darker when going farther away from the opening. That works but the added darkness needs to be nullified when it's being hit by the mainlight. I believe the atten value gives a 0 or 1 if its lit or in shadow(?) But I just can't figure out how to get the value in the surf function. Thanks in advance.
void surf (Input IN, inout SurfaceOutputStandard o) {
float4 temp = UNITY_ACCESS_INSTANCED_PROP(_Light); // opening vector
float dist = (distance(temp.xyz, IN.worldPos));
dist = 1-(dist*0.05);
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) *( UNITY_ACCESS_INSTANCED_PROP(_Color)) * dist;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612112725im_/https://answers.unity.com/themes/thub/images/avi.jpg)