2024-07-30 05:32:11 +00:00
|
|
|
#include "DecalsCommon.cginc"
|
2024-07-25 07:31:16 +00:00
|
|
|
#include "../SDF.cginc"
|
2024-07-18 05:48:58 +00:00
|
|
|
|
|
|
|
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
2020-07-01 08:28:45 +00:00
|
|
|
float4 color = tex2D(_Decal, IN.uv_decal);
|
2024-07-26 06:29:42 +00:00
|
|
|
o.Albedo = color.rgb;
|
2024-06-26 08:04:00 +00:00
|
|
|
o.Specular = 0.4;
|
2024-07-18 05:48:58 +00:00
|
|
|
o.Gloss = _Shininess;
|
2020-07-01 08:28:45 +00:00
|
|
|
|
|
|
|
#ifdef DECAL_BASE_NORMAL
|
|
|
|
float3 normal = IN.normal;
|
|
|
|
float wearFactor = 1 - normal.z;
|
|
|
|
o.Alpha *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DECAL_BUMPMAP
|
2024-06-26 08:04:00 +00:00
|
|
|
o.Normal = UnpackNormalDXT5nm(tex2D(_BumpMap, IN.uv_bumpmap));
|
2020-07-01 08:28:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DECAL_SPECMAP
|
|
|
|
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
2024-06-27 05:28:41 +00:00
|
|
|
o.Specular = specular;
|
2020-07-01 08:28:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DECAL_EMISSIVE
|
|
|
|
o.Emission += tex2D(_Emissive, IN.uv_emissive).rgb * _Emissive_Color.rgb * _Emissive_Color.a;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
float dist = BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal);
|
|
|
|
#ifdef DECAL_SDF_ALPHA
|
|
|
|
float decalDist = _Cutoff - color.a;
|
|
|
|
o.Alpha *= SDFAA(max(decalDist, dist));
|
|
|
|
#else
|
|
|
|
o.Alpha *= SDFAA(dist);
|
|
|
|
o.Alpha *= color.a;
|
2024-07-18 05:48:58 +00:00
|
|
|
#endif
|
2020-07-01 08:28:45 +00:00
|
|
|
}
|