From 5ffb79e9f39c1e027155200e72b7678ea111273d Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 2 Dec 2025 18:16:31 -0800 Subject: add sdf ssn only mode, useful when u dont wanna write color --- 2ner.shader | 30 ++-- decals.cginc | 530 +++++++++++++++++++++++++++++---------------------------- features.cginc | 8 + 3 files changed, 295 insertions(+), 273 deletions(-) diff --git a/2ner.shader b/2ner.shader index 1f186b3..dede8d4 100644 --- a/2ner.shader +++ b/2ner.shader @@ -63,7 +63,7 @@ Shader "yum_food/2ner" //ifex _Detail_Maps_Enabled==0 [HideInInspector] m_start_Detail_Maps("Detail maps", Float) = 0 [ThryToggle(_DETAIL_MAPS)]_Detail_Maps_Enabled("Enable", Float) = 0 - _Detail_Maps_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Detail_Maps_UV_Channel("UV channel", Range(0, 3)) = 0 _DetailMask("Mask", 2D) = "white" {} _DetailAlbedoMap("Base color", 2D) = "white" {} [Normal]_DetailNormalMap("Normals", 2D) = "bump" {} @@ -369,7 +369,7 @@ Shader "yum_food/2ner" _Decal0_MainTex("Base color", 2D) = "white" {} _Decal0_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal0_Angle("Angle", Range(0, 1)) = 0.0 - _Decal0_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal0_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal0_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL0_INVERT_BLEND_ORDER)] _Decal0_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL0_TILING_MODE)] _Decal0_Tiling_Mode("Tiling mode", Float) = 0 @@ -427,6 +427,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal0_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL0_SDF_SSN)] _Decal0_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL0_SDF_SSN_REPLACE)] _Decal0_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL0_SDF_SSN_ONLY)] _Decal0_SDF_SSN_Only("Only normals", Float) = 0 _Decal0_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal0_SSN("Screen space normals", Float) = 0 //endex @@ -456,7 +457,7 @@ Shader "yum_food/2ner" _Decal1_MainTex("Base color", 2D) = "white" {} _Decal1_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal1_Angle("Angle", Range(0, 1)) = 0.0 - _Decal1_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal1_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal1_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL1_INVERT_BLEND_ORDER)] _Decal1_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL1_TILING_MODE)] _Decal1_Tiling_Mode("Tiling mode", Float) = 0 @@ -514,6 +515,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal1_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL1_SDF_SSN)] _Decal1_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL1_SDF_SSN_REPLACE)] _Decal1_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL1_SDF_SSN_ONLY)] _Decal1_SDF_SSN_Only("Only normals", Float) = 0 _Decal1_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal1_SSN("Screen space normals", Float) = 0 //endex @@ -543,7 +545,7 @@ Shader "yum_food/2ner" _Decal2_MainTex("Base color", 2D) = "white" {} _Decal2_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal2_Angle("Angle", Range(0, 1)) = 0.0 - _Decal2_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal2_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal2_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL2_INVERT_BLEND_ORDER)] _Decal2_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL2_TILING_MODE)] _Decal2_Tiling_Mode("Tiling mode", Float) = 0 @@ -601,6 +603,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal2_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL2_SDF_SSN)] _Decal2_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL2_SDF_SSN_REPLACE)] _Decal2_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL2_SDF_SSN_ONLY)] _Decal2_SDF_SSN_Only("Only normals", Float) = 0 _Decal2_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal2_SSN("Screen space normals", Float) = 0 //endex @@ -630,7 +633,7 @@ Shader "yum_food/2ner" _Decal3_MainTex("Base color", 2D) = "white" {} _Decal3_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal3_Angle("Angle", Range(0, 1)) = 0.0 - _Decal3_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal3_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal3_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL3_INVERT_BLEND_ORDER)] _Decal3_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL3_TILING_MODE)] _Decal3_Tiling_Mode("Tiling mode", Float) = 0 @@ -688,6 +691,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal3_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL3_SDF_SSN)] _Decal3_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL3_SDF_SSN_REPLACE)] _Decal3_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL3_SDF_SSN_ONLY)] _Decal3_SDF_SSN_Only("Only normals", Float) = 0 _Decal3_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal3_SSN("Screen space normals", Float) = 0 //endex @@ -717,7 +721,7 @@ Shader "yum_food/2ner" _Decal4_MainTex("Base color", 2D) = "white" {} _Decal4_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal4_Angle("Angle", Range(0, 1)) = 0.0 - _Decal4_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal4_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal4_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL4_INVERT_BLEND_ORDER)] _Decal4_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL4_TILING_MODE)] _Decal4_Tiling_Mode("Tiling mode", Float) = 0 @@ -775,6 +779,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal4_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL4_SDF_SSN)] _Decal4_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL4_SDF_SSN_REPLACE)] _Decal4_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL4_SDF_SSN_ONLY)] _Decal4_SDF_SSN_Only("Only normals", Float) = 0 _Decal4_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal4_SSN("Screen space normals", Float) = 0 //endex @@ -804,7 +809,7 @@ Shader "yum_food/2ner" _Decal5_MainTex("Base color", 2D) = "white" {} _Decal5_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal5_Angle("Angle", Range(0, 1)) = 0.0 - _Decal5_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal5_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal5_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL5_INVERT_BLEND_ORDER)] _Decal5_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL5_TILING_MODE)] _Decal5_Tiling_Mode("Tiling mode", Float) = 0 @@ -862,6 +867,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal5_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL5_SDF_SSN)] _Decal5_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL5_SDF_SSN_REPLACE)] _Decal5_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL5_SDF_SSN_ONLY)] _Decal5_SDF_SSN_Only("Only normals", Float) = 0 _Decal5_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal5_SSN("Screen space normals", Float) = 0 //endex @@ -891,7 +897,7 @@ Shader "yum_food/2ner" _Decal6_MainTex("Base color", 2D) = "white" {} _Decal6_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal6_Angle("Angle", Range(0, 1)) = 0.0 - _Decal6_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal6_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal6_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL6_INVERT_BLEND_ORDER)] _Decal6_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL6_TILING_MODE)] _Decal6_Tiling_Mode("Tiling mode", Float) = 0 @@ -949,6 +955,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal6_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL6_SDF_SSN)] _Decal6_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL6_SDF_SSN_REPLACE)] _Decal6_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL6_SDF_SSN_ONLY)] _Decal6_SDF_SSN_Only("Only normals", Float) = 0 _Decal6_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal6_SSN("Screen space normals", Float) = 0 //endex @@ -978,7 +985,7 @@ Shader "yum_food/2ner" _Decal7_MainTex("Base color", 2D) = "white" {} _Decal7_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal7_Angle("Angle", Range(0, 1)) = 0.0 - _Decal7_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _Decal7_UV_Channel("UV channel", Range(0, 3)) = 0 _Decal7_Bias("Mip bias", Range(-4, 4)) = 0 [ThryToggle(_DECAL7_INVERT_BLEND_ORDER)] _Decal7_Invert_Blend_Order("Invert blend order", Float) = 0 [ThryToggle(_DECAL7_TILING_MODE)] _Decal7_Tiling_Mode("Tiling mode", Float) = 0 @@ -1036,6 +1043,7 @@ Shader "yum_food/2ner" [HideInInspector] m_start_Decal7_SSN("Screen space normals", Float) = 0 [ThryToggle(_DECAL7_SDF_SSN)] _Decal7_SDF_SSN_Enabled("Enable", Float) = 0 [ThryToggle(_DECAL7_SDF_SSN_REPLACE)] _Decal7_SDF_SSN_Replace("Replace normals", Float) = 0 + [ThryToggle(_DECAL7_SDF_SSN_ONLY)] _Decal7_SDF_SSN_Only("Only normals", Float) = 0 _Decal7_SDF_SSN_Strength("Strength", Range(0, 10)) = 1 [HideInInspector] m_end_Decal7_SSN("Screen space normals", Float) = 0 //endex @@ -1239,7 +1247,7 @@ Shader "yum_food/2ner" [ThryToggle(_3D_SDF)] _3D_SDF_Enabled("Enable", Float) = 0 _3D_SDF_Texture("Texture", 3D) = "white" {} _3D_SDF_ST("Scale and offset", Vector) = (1, 1, 0, 0) - _3D_SDF_UV_Channel("UV channel", Range(0, 3.1)) = 0 + [IntRange] _3D_SDF_UV_Channel("UV channel", Range(0, 3)) = 0 _3D_SDF_Thresholds("Thresholds", Vector) = (0.2, 0.4, 0.6, 0.8) _3D_SDF_Color_0("Color 0", Color) = (1, 0, 0, 1) _3D_SDF_Color_1("Color 1", Color) = (0, 1, 0, 1) @@ -2278,7 +2286,7 @@ Shader "yum_food/2ner" //ifex _Quasi_Shadows_Enabled==0 [HideInInspector] m_start_Quasi_Shadows("Quasi Shadows", Float) = 0 [ThryToggle(_QUASI_SHADOWS)] _Quasi_Shadows_Enabled("Enable", Float) = 0 - _Quasi_Shadows_0_Color("Color 0", Color) = (1, 1, 1, 1) + [HDR] _Quasi_Shadows_0_Color("Color 0", Color) = (1, 1, 1, 1) _Quasi_Shadows_0_Threshold("Threshold 0", Range(0, 1)) = 0.5 _Quasi_Shadows_0_Width("Width 0", Range(0, 1)) = 0.1 [HideInInspector] m_end_Quasi_Shadows("Quasi Shadows", Float) = 0 diff --git a/decals.cginc b/decals.cginc index f75e63f..a26e045 100644 --- a/decals.cginc +++ b/decals.cginc @@ -173,11 +173,15 @@ float3 calculateSdfSsn(DecalParams params, float2 decal_uv, float4 decal_albedo) sdf_grad_uv.y = (sdf_dy * uv_dx.x - sdf_dx * uv_dy.x) / det; float2 scaled_grad = sdf_grad_uv * params.sdf_ssn_strength * decal_albedo.a * params.opacity; + if (det == 0) { + scaled_grad.xy = 0; + } return normalize(float3(-scaled_grad.xy, 1.0)); } -#define APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +// DS = decal stage +#define DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float2x2 decal_rot = float2x2( \ cos(params.angle * TAU), -sin(params.angle * TAU), \ sin(params.angle * TAU), cos(params.angle * TAU) \ @@ -189,25 +193,25 @@ float3 calculateSdfSsn(DecalParams params, float2 decal_uv, float4 decal_albedo) decal_uv = mul(decal_rot, decal_uv - 0.5) + 0.5; \ decal_uv = (params.tiling_mode == DECAL_TILING_MODE_CLAMP ? saturate(decal_uv) : decal_uv); -#define APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ decal_uv = applyDomainWarping(params, decal_uv); -#define APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} -#define APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float4 decal_albedo = getCmykWarpingPlanesColor(params, decal_uv); -#define APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float4 decal_albedo = getDecalColor(params, decal_uv); -#define APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float4 decal_albedo; \ { \ decal_albedo = params.mainTex.SampleBias(trilinear_aniso4_repeat_s, decal_uv, params.mip_bias); \ decal_albedo *= params.color; \ } -#define APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ { \ float3 sdf_normal_ts = calculateSdfSsn(params, decal_uv, decal_albedo); \ sdf_normal_ts.xy *= 1.0f - albedo.a; \ @@ -215,103 +219,107 @@ float3 calculateSdfSsn(DecalParams params, float2 decal_uv, float4 decal_albedo) normal_tangent = blendNormalsHill12(normal_tangent, sdf_normal_ts); \ } -#define APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ { \ float3 sdf_normal_ts = calculateSdfSsn(params, decal_uv, decal_albedo); \ normal_tangent = normalize(lerp(normal_tangent, normalize(sdf_normal_ts), decal_albedo.a)); \ } -#define APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ { \ float eps = 1e-4; \ float2 uv_clamped = step(eps, decal_uv) * step(decal_uv, 1 - eps); \ decal_albedo.a *= uv_clamped.x * uv_clamped.y; \ } -#define APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} -#define APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float decal_mask = params.mask.SampleLevel(trilinear_aniso4_repeat_s, raw_decal_uv, params.mip_bias); \ decal_albedo.a *= decal_mask; -#define APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float decal_mask = 1; -#define APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ + float alpha_blend_amount = (1.0f - albedo.a) * decal_albedo.a; + +#define DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ decal_albedo.a = lerp(0, decal_albedo.a, params.opacity); \ float alpha_blend_amount = (1.0f - albedo.a) * decal_albedo.a; \ albedo = alphaBlend(albedo, decal_albedo); -#define APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ decal_albedo.a = lerp(0, decal_albedo.a, params.opacity); \ float alpha_blend_amount = (1.0f - albedo.a) * decal_albedo.a; \ - albedo = alphaBlend(decal_albedo, albedo); + albedo = alphaBlend(decal_albedo, albedo); \ + decal_albedo.a = alpha_blend_amount; -#define APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ albedo = lerp(albedo, decal_albedo, decal_mask * params.opacity); -#define APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ albedo = lerp(albedo, decal_albedo * albedo, decal_mask * params.opacity); -#define APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ emission += params.emission_color * params.emission_strength; -#define APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ emission += albedo.rgb * params.emission_color * params.emission_strength; -#define APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} -#define APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float3 decal_normal = UnpackScaleNormal( \ params.normalTex.SampleBias(trilinear_aniso4_repeat_s, decal_uv, params.mip_bias), \ params.normal_scale * decal_albedo.a * params.opacity); \ normal_tangent = blendNormalsHill12(normal_tangent, decal_normal); //normal_tangent = lerp(normal_tangent, decal_normal, decal_albedo.a * params.opacity); -#define APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} -#define APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float4 metallic_gloss = params.metallicGlossMap.Sample(trilinear_repeat_s, decal_uv); \ metallic = lerp(metallic, metallic_gloss.r * params.metallic_value, decal_albedo.a); \ smoothness = lerp(smoothness, metallic_gloss.a * params.smoothness_value, decal_albedo.a); -#define APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ +#define DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, params) \ float4 metallic_gloss = params.metallicGlossMap.Sample(trilinear_repeat_s, decal_uv); \ - metallic = lerp(metallic, metallic_gloss.r * params.metallic_value, decal_albedo.a * alpha_blend_amount); \ - smoothness = lerp(smoothness, metallic_gloss.a * params.smoothness_value, decal_albedo.a * alpha_blend_amount); + metallic = lerp(metallic, metallic_gloss.r * params.metallic_value, alpha_blend_amount); \ + smoothness = lerp(smoothness, metallic_gloss.a * params.smoothness_value, alpha_blend_amount); -#define APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} -#define APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} +#define DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {} void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, inout float metallic, inout float smoothness, inout float3 emission) { DecalParams decal; #if defined(_DECAL0) { INIT_DECAL_PARAMS(decal, _Decal0_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL0_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL0_SDF) && defined(_DECAL0_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL0_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL0_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL0_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL0_REPLACE_ALPHA) @@ -319,38 +327,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL0_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL0_SDF_SSN) && !defined(_DECAL0_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL0_SDF_SSN) && defined(_DECAL0_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL0_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL0_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL0_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL0_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL0_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL0_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL0_EMISSIONS) && defined(_DECAL0_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL0_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL0_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -360,39 +368,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL0_REFLECTIONS) && !defined(_DECAL0_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL0_REFLECTIONS) && defined(_DECAL0_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL0 #if defined(_DECAL1) { INIT_DECAL_PARAMS(decal, _Decal1_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL1_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL1_SDF) && defined(_DECAL1_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL1_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL1_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL1_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL1_REPLACE_ALPHA) @@ -400,38 +408,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL1_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL1_SDF_SSN) && !defined(_DECAL1_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL1_SDF_SSN) && defined(_DECAL1_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL1_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL1_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL1_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL1_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL1_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL1_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL1_EMISSIONS) && defined(_DECAL1_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL1_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL1_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -441,39 +449,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL1_REFLECTIONS) && !defined(_DECAL1_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL1_REFLECTIONS) && defined(_DECAL1_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL1 #if defined(_DECAL2) { INIT_DECAL_PARAMS(decal, _Decal2_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL2_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL2_SDF) && defined(_DECAL2_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL2_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL2_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL2_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL2_REPLACE_ALPHA) @@ -481,38 +489,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL2_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL2_SDF_SSN) && !defined(_DECAL2_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL2_SDF_SSN) && defined(_DECAL2_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL2_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL2_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL2_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL2_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL2_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - #if defined(_DECAL2_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL2_EMISSIONS) && defined(_DECAL2_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL2_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL2_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -522,41 +530,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL2_REFLECTIONS) && !defined(_DECAL2_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL2_REFLECTIONS) && defined(_DECAL2_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL2 #if defined(_DECAL3) { INIT_DECAL_PARAMS(decal, _Decal3_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL3_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL3_SDF) && defined(_DECAL3_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL3_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL3_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL3_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL3_REPLACE_ALPHA) @@ -564,38 +570,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL3_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL3_SDF_SSN) && !defined(_DECAL3_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL3_SDF_SSN) && defined(_DECAL3_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL3_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL3_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL3_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL3_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL3_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL3_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL3_EMISSIONS) && defined(_DECAL3_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL3_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL3_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -605,39 +611,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL3_REFLECTIONS) && !defined(_DECAL3_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL3_REFLECTIONS) && defined(_DECAL3_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL3 #if defined(_DECAL4) { INIT_DECAL_PARAMS(decal, _Decal4_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL4_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL4_SDF) && defined(_DECAL4_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL4_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL4_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL4_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL4_REPLACE_ALPHA) @@ -645,38 +651,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL4_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL4_SDF_SSN) && !defined(_DECAL4_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL4_SDF_SSN) && defined(_DECAL4_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL4_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL4_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL4_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL4_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL4_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - #if defined(_DECAL4_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL4_EMISSIONS) && defined(_DECAL4_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL4_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL4_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -686,39 +692,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL4_REFLECTIONS) && !defined(_DECAL4_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL4_REFLECTIONS) && defined(_DECAL4_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL4 #if defined(_DECAL5) { INIT_DECAL_PARAMS(decal, _Decal5_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL5_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL5_SDF) && defined(_DECAL5_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL5_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL5_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL5_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL5_REPLACE_ALPHA) @@ -726,38 +732,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL5_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL5_SDF_SSN) && !defined(_DECAL5_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL5_SDF_SSN) && defined(_DECAL5_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL5_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL5_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL5_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL5_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL5_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL5_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL5_EMISSIONS) && defined(_DECAL5_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL5_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL5_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -767,39 +773,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL5_REFLECTIONS) && !defined(_DECAL5_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL5_REFLECTIONS) && defined(_DECAL5_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL5 #if defined(_DECAL6) { INIT_DECAL_PARAMS(decal, _Decal6_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL6_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL6_SDF) && defined(_DECAL6_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL6_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL6_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL6_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL6_REPLACE_ALPHA) @@ -807,38 +813,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL6_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL6_SDF_SSN) && !defined(_DECAL6_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL6_SDF_SSN) && defined(_DECAL6_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL6_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL6_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL6_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL6_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL6_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL6_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL6_EMISSIONS) && defined(_DECAL6_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL6_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL6_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -848,39 +854,39 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL6_REFLECTIONS) && !defined(_DECAL6_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL6_REFLECTIONS) && defined(_DECAL6_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL6 #if defined(_DECAL7) { INIT_DECAL_PARAMS(decal, _Decal7_); - APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #if defined(_DECAL7_DOMAIN_WARPING) - APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL7_SDF) && defined(_DECAL7_CMYK_WARPING_PLANES) - APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL7_SDF) - APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL7_TILING_MODE) - APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL7_MASK) - APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL7_REPLACE_ALPHA) @@ -888,38 +894,38 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL7_NORMAL) - APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(_DECAL7_SDF_SSN) && !defined(_DECAL7_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL7_SDF_SSN) && defined(_DECAL7_SDF_SSN_REPLACE) - APPLY_DECAL_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_ON_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_SDF_SSN_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif - #if defined(_DECAL7_REPLACE_ALPHA) - APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #if defined(_DECAL7_SDF_SSN_ONLY) + DS_BLEND_MODE_SSN_ONLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL7_REPLACE_ALPHA) + DS_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL7_MULTIPLY) - APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #else - #if defined(_DECAL7_INVERT_BLEND_ORDER) - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + #elif defined(_DECAL7_INVERT_BLEND_ORDER) + DS_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); - #endif + DS_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif #if defined(FORWARD_BASE_PASS) float3 tmp_emission = 0; #if defined(_DECAL7_EMISSIONS) && defined(_DECAL7_EMISSION_MODE_ADD_PRODUCT) - APPLY_DECAL_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD_PRODUCT(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #elif defined(_DECAL7_EMISSIONS) - APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #else - APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); + DS_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal); #endif #if defined(_DECAL7_EMISSIONS_PROXIMITY) float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos); @@ -929,11 +935,11 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #endif #if defined(_DECAL7_REFLECTIONS) && !defined(_DECAL7_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_REGULAR(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #elif defined(_DECAL7_REFLECTIONS) && defined(_DECAL7_REFLECTIONS_ALPHA_BLEND) - APPLY_DECAL_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_ON_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #else - APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); + DS_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal); #endif } #endif // _DECAL7 diff --git a/features.cginc b/features.cginc index 169b28f..442506e 100644 --- a/features.cginc +++ b/features.cginc @@ -134,6 +134,7 @@ #pragma shader_feature_local _DECAL0_SDF #pragma shader_feature_local _DECAL0_SDF_SSN #pragma shader_feature_local _DECAL0_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL0_SDF_SSN_ONLY #pragma shader_feature_local _DECAL0_MASK #pragma shader_feature_local _DECAL0_TILING_MODE #pragma shader_feature_local _DECAL0_INVERT_BLEND_ORDER @@ -153,6 +154,7 @@ #pragma shader_feature_local _DECAL1_SDF #pragma shader_feature_local _DECAL1_SDF_SSN #pragma shader_feature_local _DECAL1_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL1_SDF_SSN_ONLY #pragma shader_feature_local _DECAL1_MASK #pragma shader_feature_local _DECAL1_TILING_MODE #pragma shader_feature_local _DECAL1_INVERT_BLEND_ORDER @@ -172,6 +174,7 @@ #pragma shader_feature_local _DECAL2_SDF #pragma shader_feature_local _DECAL2_SDF_SSN #pragma shader_feature_local _DECAL2_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL2_SDF_SSN_ONLY #pragma shader_feature_local _DECAL2_MASK #pragma shader_feature_local _DECAL2_TILING_MODE #pragma shader_feature_local _DECAL2_INVERT_BLEND_ORDER @@ -191,6 +194,7 @@ #pragma shader_feature_local _DECAL3_SDF #pragma shader_feature_local _DECAL3_SDF_SSN #pragma shader_feature_local _DECAL3_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL3_SDF_SSN_ONLY #pragma shader_feature_local _DECAL3_MASK #pragma shader_feature_local _DECAL3_TILING_MODE #pragma shader_feature_local _DECAL3_INVERT_BLEND_ORDER @@ -210,6 +214,7 @@ #pragma shader_feature_local _DECAL4_SDF #pragma shader_feature_local _DECAL4_SDF_SSN #pragma shader_feature_local _DECAL4_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL4_SDF_SSN_ONLY #pragma shader_feature_local _DECAL4_MASK #pragma shader_feature_local _DECAL4_TILING_MODE #pragma shader_feature_local _DECAL4_INVERT_BLEND_ORDER @@ -229,6 +234,7 @@ #pragma shader_feature_local _DECAL5_SDF #pragma shader_feature_local _DECAL5_SDF_SSN #pragma shader_feature_local _DECAL5_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL5_SDF_SSN_ONLY #pragma shader_feature_local _DECAL5_MASK #pragma shader_feature_local _DECAL5_TILING_MODE #pragma shader_feature_local _DECAL5_INVERT_BLEND_ORDER @@ -248,6 +254,7 @@ #pragma shader_feature_local _DECAL6_SDF #pragma shader_feature_local _DECAL6_SDF_SSN #pragma shader_feature_local _DECAL6_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL6_SDF_SSN_ONLY #pragma shader_feature_local _DECAL6_MASK #pragma shader_feature_local _DECAL6_TILING_MODE #pragma shader_feature_local _DECAL6_INVERT_BLEND_ORDER @@ -267,6 +274,7 @@ #pragma shader_feature_local _DECAL7_SDF #pragma shader_feature_local _DECAL7_SDF_SSN #pragma shader_feature_local _DECAL7_SDF_SSN_REPLACE +#pragma shader_feature_local _DECAL7_SDF_SSN_ONLY #pragma shader_feature_local _DECAL7_MASK #pragma shader_feature_local _DECAL7_TILING_MODE #pragma shader_feature_local _DECAL7_INVERT_BLEND_ORDER -- cgit v1.2.3