KSP-Conformal-Decals/Assets/ConformalDecals/Shaders/Decal/StandardDecal.cginc

37 lines
1.1 KiB
HLSL
Raw Normal View History

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) {
float4 color = tex2D(_Decal, IN.uv_decal);
o.Albedo = color.rgb;
o.Specular = 0.4;
2024-07-18 05:48:58 +00:00
o.Gloss = _Shininess;
#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
o.Normal = UnpackNormalDXT5nm(tex2D(_BumpMap, IN.uv_bumpmap));
#endif
#ifdef DECAL_SPECMAP
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
2024-06-27 05:28:41 +00:00
o.Specular = specular;
#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
}