diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-30 16:16:24 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-30 16:16:27 -0800 |
| commit | 46a7aa991625e90428325e9f0be790a50e1b902d (patch) | |
| tree | 353510a963b6e86bf73fbcdb2a3d99be0645c7d1 /decals.cginc | |
| parent | 80ea42aa92d98b5efbb5bf7aebc6a57f1f3f23c1 (diff) | |
add static toggle to switch decal alpha blend order
Diffstat (limited to 'decals.cginc')
| -rw-r--r-- | decals.cginc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/decals.cginc b/decals.cginc index 1e9427b..38dbf6d 100644 --- a/decals.cginc +++ b/decals.cginc @@ -202,6 +202,10 @@ float4 getCmykWarpingPlanesColor(DecalParams params, float2 uv) { #define APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
decal_albedo.a = lerp(0, decal_albedo.a, params.opacity); \
+ albedo = alphaBlend(albedo, decal_albedo);
+
+#define APPLY_DECAL_BLEND_MODE_ALPHA_BLEND_INVERTED(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
+ decal_albedo.a = lerp(0, decal_albedo.a, params.opacity); \
albedo = alphaBlend(decal_albedo, albedo);
#define APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
@@ -267,8 +271,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -329,8 +337,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -391,8 +403,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #elif defined(_DECAL2_MULTIPLY)
APPLY_DECAL_BLEND_MODE_MULTIPLY(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
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -453,8 +469,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -515,8 +535,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #elif defined(_DECAL4_MULTIPLY)
APPLY_DECAL_BLEND_MODE_MULTIPLY(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
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -577,8 +601,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -639,8 +667,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
@@ -701,8 +733,12 @@ void applyDecals(in v2f i, inout float4 albedo, inout float3 normal_tangent, ino #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);
+ #else
APPLY_DECAL_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
+ #endif
#if defined(FORWARD_BASE_PASS)
float3 tmp_emission = 0;
|
