SanAndreasUnity/Assets/Resources/Shaders/Shared.cginc

60 lines
1 KiB
HLSL
Raw Normal View History

2020-05-31 19:07:22 +02:00
sampler2D _MainTex;
sampler2D _MaskTex;
fixed4 _Color;
#ifdef VEHICLE
int _CarColorIndex;
2021-02-13 22:18:27 +01:00
fixed3 _CarColor;
fixed _CarEmission;
2020-05-31 19:07:22 +02:00
float _Metallic;
float _Smoothness;
#endif
#ifdef FADE
sampler2D _NoiseTex;
fixed _Fade;
#endif
struct Input
{
float2 uv_MainTex;
float4 screenPos;
float4 color : COLOR;
};
void surf(Input IN, inout SurfaceOutputStandard o)
{
#ifdef FADE
fixed noise = tex2D(_NoiseTex, IN.screenPos.xy / (IN.screenPos.w == 0 ? 1 : IN.screenPos.w)).a * .99;
fixed fade = fixed(_Fade < 0 ? noise > 1 + _Fade : noise < _Fade);
#else
fixed fade = 1;
#endif
fixed3 clr = tex2D(_MainTex, IN.uv_MainTex).rgb;
fixed mask = tex2D(_MaskTex, IN.uv_MainTex).a;
o.Albedo = clr
#ifdef VEHICLE
2021-02-13 22:18:27 +01:00
* _CarColor
2020-05-31 19:07:22 +02:00
#endif
* IN.color.rgb * _Color.rgb;
o.Alpha = fade * mask * IN.color.a * _Color.a;
#ifdef VEHICLE
o.Metallic = _Metallic * o.Alpha;
o.Smoothness = _Smoothness;
2021-02-13 22:18:27 +01:00
o.Emission = _CarEmission * o.Albedo;
2020-05-31 19:07:22 +02:00
#else
o.Metallic = 0;
o.Smoothness = 0;
#endif
}