2020-07-25 07:54:21 +00:00
|
|
|
float4 _DecalColor;
|
|
|
|
|
|
|
|
float4 _OutlineColor;
|
|
|
|
float _OutlineWidth;
|
|
|
|
|
|
|
|
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
|
|
|
float4 color = _DecalColor;
|
2020-08-22 06:44:58 +00:00
|
|
|
float dist = _Cutoff - tex2D(_Decal, IN.uv_decal).r; // text distance
|
2020-08-16 06:24:39 +00:00
|
|
|
float ddist = SDFdDist(dist); // distance gradient magnitude
|
2020-07-25 07:54:21 +00:00
|
|
|
|
|
|
|
#ifdef DECAL_OUTLINE
|
2020-08-16 06:24:39 +00:00
|
|
|
// Outline
|
|
|
|
float outlineOffset = _OutlineWidth * 0.25;
|
|
|
|
float outlineRadius = _OutlineWidth * 0.5;
|
|
|
|
|
|
|
|
#ifdef DECAL_FILL
|
|
|
|
// Outline and Fill
|
|
|
|
float outlineDist = -dist - outlineOffset;
|
|
|
|
float outlineFactor = SDFAA(outlineDist, ddist);
|
|
|
|
dist -= outlineOffset;
|
|
|
|
color = lerp(_DecalColor, _OutlineColor, outlineFactor);
|
|
|
|
#else
|
|
|
|
// Outline Only
|
|
|
|
float outlineDist = abs(dist) - outlineOffset;
|
|
|
|
dist = outlineDist;
|
|
|
|
color = _OutlineColor;
|
|
|
|
#endif
|
2020-07-25 07:54:21 +00:00
|
|
|
#endif
|
2020-08-16 06:24:39 +00:00
|
|
|
|
|
|
|
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
|
|
|
|
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
|
2020-07-25 07:54:21 +00:00
|
|
|
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
|
|
|
|
|
|
|
#ifdef DECAL_BASE_NORMAL
|
|
|
|
float3 normal = IN.normal;
|
|
|
|
float wearFactor = 1 - normal.z;
|
|
|
|
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
|
|
|
o.Alpha *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DECAL_SPECMAP
|
|
|
|
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
|
|
|
o.Gloss = specular.r;
|
|
|
|
o.Specular = _Shininess;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
|
|
|
|
o.Emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
|
|
|
}
|