summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-06-24 01:53:15 -0700
committeryum <yum.food.vr@gmail.com>2025-06-24 01:53:15 -0700
commit31bba649de265dd83ea1af638c03d224696d07b3 (patch)
tree5db7f48188231b2d9be274d687e10ba1f5826ae8
parent9bfb0bf53419330ff27565e65a80873e3e5defbb (diff)
Add decal emissions & proximity emissions feature
-rw-r--r--2ner.shader120
-rw-r--r--decals.cginc462
-rw-r--r--features.cginc24
-rw-r--r--globals.cginc9
-rw-r--r--yum_pbr.cginc19
5 files changed, 464 insertions, 170 deletions
diff --git a/2ner.shader b/2ner.shader
index b9c724d..c37fecc 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -361,6 +361,21 @@ Shader "yum_food/2ner"
_Decal0_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal0_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal0_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal0_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL0_EMISSIONS)] _Decal0_Emissions_Enabled("Enable", Float) = 0
+ _Decal0_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal0_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL0_EMISSION_MODE_ADD_PRODUCT)] _Decal0_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal0_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal0_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL0_EMISSIONS_PROXIMITY)] _Decal0_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal0_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal0_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal0_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal0_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal0_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal0_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL0_DOMAIN_WARPING)] _Decal0_Domain_Warping_Enabled("Enable", Float) = 0
@@ -423,6 +438,21 @@ Shader "yum_food/2ner"
_Decal1_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal1_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal1_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal1_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL1_EMISSIONS)] _Decal1_Emissions_Enabled("Enable", Float) = 0
+ _Decal1_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal1_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL1_EMISSION_MODE_ADD_PRODUCT)] _Decal1_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal1_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal1_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL1_EMISSIONS_PROXIMITY)] _Decal1_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal1_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal1_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal1_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal1_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal1_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal1_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL1_DOMAIN_WARPING)] _Decal1_Domain_Warping_Enabled("Enable", Float) = 0
@@ -485,6 +515,21 @@ Shader "yum_food/2ner"
_Decal2_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal2_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal2_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal2_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL2_EMISSIONS)] _Decal2_Emissions_Enabled("Enable", Float) = 0
+ _Decal2_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal2_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL2_EMISSION_MODE_ADD_PRODUCT)] _Decal2_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal2_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal2_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL2_EMISSIONS_PROXIMITY)] _Decal2_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal2_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal2_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal2_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal2_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal2_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal2_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL2_DOMAIN_WARPING)] _Decal2_Domain_Warping_Enabled("Enable", Float) = 0
@@ -547,6 +592,21 @@ Shader "yum_food/2ner"
_Decal3_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal3_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal3_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal3_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL3_EMISSIONS)] _Decal3_Emissions_Enabled("Enable", Float) = 0
+ _Decal3_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal3_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL3_EMISSION_MODE_ADD_PRODUCT)] _Decal3_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal3_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal3_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL3_EMISSIONS_PROXIMITY)] _Decal3_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal3_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal3_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal3_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal3_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal3_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal3_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL3_DOMAIN_WARPING)] _Decal3_Domain_Warping_Enabled("Enable", Float) = 0
@@ -609,6 +669,21 @@ Shader "yum_food/2ner"
_Decal4_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal4_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal4_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal4_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL4_EMISSIONS)] _Decal4_Emissions_Enabled("Enable", Float) = 0
+ _Decal4_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal4_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL4_EMISSION_MODE_ADD_PRODUCT)] _Decal4_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal4_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal4_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL4_EMISSIONS_PROXIMITY)] _Decal4_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal4_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal4_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal4_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal4_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal4_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal4_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL4_DOMAIN_WARPING)] _Decal4_Domain_Warping_Enabled("Enable", Float) = 0
@@ -671,6 +746,21 @@ Shader "yum_food/2ner"
_Decal5_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal5_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal5_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal5_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL5_EMISSIONS)] _Decal5_Emissions_Enabled("Enable", Float) = 0
+ _Decal5_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal5_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL5_EMISSION_MODE_ADD_PRODUCT)] _Decal5_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal5_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal5_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL5_EMISSIONS_PROXIMITY)] _Decal5_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal5_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal5_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal5_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal5_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal5_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal5_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL5_DOMAIN_WARPING)] _Decal5_Domain_Warping_Enabled("Enable", Float) = 0
@@ -733,6 +823,21 @@ Shader "yum_food/2ner"
_Decal6_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal6_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal6_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal6_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL6_EMISSIONS)] _Decal6_Emissions_Enabled("Enable", Float) = 0
+ _Decal6_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal6_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL6_EMISSION_MODE_ADD_PRODUCT)] _Decal6_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal6_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal6_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL6_EMISSIONS_PROXIMITY)] _Decal6_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal6_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal6_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal6_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal6_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal6_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal6_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL6_DOMAIN_WARPING)] _Decal6_Domain_Warping_Enabled("Enable", Float) = 0
@@ -795,6 +900,21 @@ Shader "yum_food/2ner"
_Decal7_Metallic("Metallic", Range(0, 1)) = 0.0
[HideInInspector] m_end_Decal7_Reflections("Reflections", Float) = 0
//endex
+ //ifex _Decal7_Emissions_Enabled==0
+ [HideInInspector] m_start_Decal7_Emissions("Emissions", Float) = 0
+ [ThryToggle(_DECAL7_EMISSIONS)] _Decal7_Emissions_Enabled("Enable", Float) = 0
+ _Decal7_Emission_Color("Emission color", Color) = (1, 1, 1, 1)
+ _Decal7_Emission_Strength("Emission strength", Float) = 1
+ [ThryToggle(_DECAL7_EMISSION_MODE_ADD_PRODUCT)] _Decal7_Emission_Mode_Add_Product("Add product", Float) = 0
+ //ifex _Decal7_Emissions_Proximity_Enabled==0
+ [HideInInspector] m_start_Decal7_Emissions_Proximity("Proximity", Float) = 0
+ [ThryToggle(_DECAL7_EMISSIONS_PROXIMITY)] _Decal7_Emissions_Proximity_Enabled("Enable", Float) = 0
+ _Decal7_Emissions_Proximity_Min_Distance("Min distance", Float) = 0
+ _Decal7_Emissions_Proximity_Max_Distance("Max distance", Float) = 1
+ [HideInInspector] m_end_Decal7_Emissions_Proximity("Proximity", Float) = 0
+ //endex
+ [HideInInspector] m_end_Decal7_Emissions("Emissions", Float) = 0
+ //endex
//ifex _Decal7_Domain_Warping_Enabled==0
[HideInInspector] m_start_Decal7_Domain_Warping("Domain warping", Float) = 0
[ThryToggle(_DECAL7_DOMAIN_WARPING)] _Decal7_Domain_Warping_Enabled("Enable", Float) = 0
diff --git a/decals.cginc b/decals.cginc
index 2f0edb2..ee4e1cd 100644
--- a/decals.cginc
+++ b/decals.cginc
@@ -33,6 +33,10 @@ struct DecalParams {
float cmyk_warping_planes_strength;
float cmyk_warping_planes_scale;
float cmyk_warping_planes_speed;
+ float3 emission_color;
+ float emission_strength;
+ float emissions_proximity_min_distance;
+ float emissions_proximity_max_distance;
};
// Macro to initialize decal parameters
@@ -61,7 +65,11 @@ struct DecalParams {
params.cmyk_warping_planes_noise = prefix##CMYK_Warping_Planes_Noise; \
params.cmyk_warping_planes_strength = prefix##CMYK_Warping_Planes_Strength; \
params.cmyk_warping_planes_scale = prefix##CMYK_Warping_Planes_Scale; \
- params.cmyk_warping_planes_speed = prefix##CMYK_Warping_Planes_Speed;
+ params.cmyk_warping_planes_speed = prefix##CMYK_Warping_Planes_Speed; \
+ params.emission_color = prefix##Emission_Color; \
+ params.emission_strength = prefix##Emission_Strength; \
+ params.emissions_proximity_min_distance = prefix##Emissions_Proximity_Min_Distance; \
+ params.emissions_proximity_max_distance = prefix##Emissions_Proximity_Max_Distance;
float2 applyDomainWarping(DecalParams params, float2 uv) {
float2 warped_uv = uv;
@@ -148,7 +156,7 @@ float4 getCmykWarpingPlanesColor(DecalParams params, float2 uv) {
return float4(final_rgb, saturate(decal_color0.a + decal_color1.a + decal_color2.a + decal_color3.a));
}
-#define APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_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) \
@@ -160,425 +168,569 @@ float4 getCmykWarpingPlanesColor(DecalParams params, float2 uv) {
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_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
decal_uv = applyDomainWarping(params, decal_uv);
-#define APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, params) {}
+#define APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {}
-#define APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float4 decal_albedo = getCmykWarpingPlanesColor(params, decal_uv);
-#define APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float4 decal_albedo = getDecalColor(params, decal_uv);
-#define APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float4 decal_albedo; \
{ \
decal_albedo = params.mainTex.Sample(trilinear_repeat_s, decal_uv); \
decal_albedo *= params.color; \
}
-#define APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_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_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, params) {}
+#define APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {}
-#define APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float decal_mask = params.mask.SampleLevel(linear_repeat_s, raw_decal_uv, 0); \
decal_albedo.a *= decal_mask;
-#define APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float decal_mask = 1;
-#define APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, params) \
+#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_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
albedo = lerp(albedo, decal_albedo, decal_mask * params.opacity);
-#define APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
albedo = lerp(albedo, decal_albedo * albedo, decal_mask * params.opacity);
-#define APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_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) \
+ emission += albedo.rgb * params.emission_color * params.emission_strength;
+
+#define APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {}
+
+#define APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float3 decal_normal = UnpackScaleNormal( \
params.normalTex.Sample(trilinear_repeat_s, decal_uv), \
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_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, params) {}
+#define APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) {}
-#define APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
+#define APPLY_DECAL_REFLECTIONS_ON(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_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, params) {}
+#define APPLY_DECAL_REFLECTIONS_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) {
+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_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL0_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL0_SDF) && defined(_DECAL0_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL0_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL0_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL0_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL0_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL0_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_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);
+ #elif defined(_DECAL0_EMISSIONS)
+ APPLY_DECAL_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);
+ #endif
+ #if defined(_DECAL0_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
#endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL0_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL0_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL0
#if defined(_DECAL1)
{
INIT_DECAL_PARAMS(decal, _Decal1_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL1_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL1_SDF) && defined(_DECAL1_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL1_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL1_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL1_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL1_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL1_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
+ #else
+ APPLY_DECAL_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);
+ #elif defined(_DECAL1_EMISSIONS)
+ APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
+ #endif
+ #if defined(_DECAL1_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
#endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL1_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL1_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL1
#if defined(_DECAL2)
{
INIT_DECAL_PARAMS(decal, _Decal2_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL2_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL2_SDF) && defined(_DECAL2_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL2_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL2_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL2_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL2_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL2_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_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);
+ #elif defined(_DECAL2_EMISSIONS)
+ APPLY_DECAL_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);
+ #endif
+ #if defined(_DECAL2_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
#endif
+
#if defined(_DECAL2_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL2_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL2
#if defined(_DECAL3)
{
INIT_DECAL_PARAMS(decal, _Decal3_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL3_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL3_SDF) && defined(_DECAL3_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL3_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL3_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL3_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL3_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL3_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
+ #else
+ APPLY_DECAL_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);
+ #elif defined(_DECAL3_EMISSIONS)
+ APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
+ #endif
+ #if defined(_DECAL3_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
#endif
+
#if defined(_DECAL3_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL3_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL3
#if defined(_DECAL4)
{
INIT_DECAL_PARAMS(decal, _Decal4_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL4_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL4_SDF) && defined(_DECAL4_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL4_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL4_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL4_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL4_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL4_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
+ #else
+ APPLY_DECAL_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);
+ #elif defined(_DECAL4_EMISSIONS)
+ APPLY_DECAL_EMISSION_ON_MODE_ADD(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_EMISSION_OFF(i, albedo, normal_tangent, metallic, smoothness, tmp_emission, decal);
#endif
+ #if defined(_DECAL4_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL4_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL4_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL4
#if defined(_DECAL5)
{
INIT_DECAL_PARAMS(decal, _Decal5_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL5_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL5_SDF) && defined(_DECAL5_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL5_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL5_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL5_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL5_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL5_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_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);
+ #elif defined(_DECAL5_EMISSIONS)
+ APPLY_DECAL_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);
+ #endif
+ #if defined(_DECAL5_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL5_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL5_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL5
#if defined(_DECAL6)
{
INIT_DECAL_PARAMS(decal, _Decal6_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL6_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL6_SDF) && defined(_DECAL6_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL6_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL6_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL6_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL6_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL6_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_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);
+ #elif defined(_DECAL6_EMISSIONS)
+ APPLY_DECAL_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);
+ #endif
+ #if defined(_DECAL6_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL6_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL6_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL6
#if defined(_DECAL7)
{
INIT_DECAL_PARAMS(decal, _Decal7_);
- APPLY_DECAL_SEC00_GENERIC(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_GENERIC(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#if defined(_DECAL7_DOMAIN_WARPING)
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC00B_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_DOMAIN_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL7_SDF) && defined(_DECAL7_CMYK_WARPING_PLANES)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL7_SDF)
- APPLY_DECAL_SEC01_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_ON_WARPING_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC01_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL7_TILING_MODE)
- APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC02_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_CLAMP_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL7_MASK)
- APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL7_REPLACE_ALPHA)
- APPLY_DECAL_SEC04_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_REPLACE(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#elif defined(_DECAL7_MULTIPLY)
- APPLY_DECAL_SEC04_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_BLEND_MODE_MULTIPLY(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC04_BLEND_MODE_ALPHA_BLEND(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_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);
+ #elif defined(_DECAL7_EMISSIONS)
+ APPLY_DECAL_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);
+ #endif
+ #if defined(_DECAL7_EMISSIONS_PROXIMITY)
+ float tmp_d = distance(i.worldPos, _WorldSpaceCameraPos);
+ tmp_emission = lerp(tmp_emission, 0, saturate((tmp_d - decal.emissions_proximity_min_distance) / (decal.emissions_proximity_max_distance - decal.emissions_proximity_min_distance)));
+ #endif
+ emission += tmp_emission;
+ #endif
+
#if defined(_DECAL7_NORMAL)
- APPLY_DECAL_SEC05_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC05_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_NORMAL_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
#if defined(_DECAL7_REFLECTIONS)
- APPLY_DECAL_SEC06_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_ON(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#else
- APPLY_DECAL_SEC06_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, decal);
+ APPLY_DECAL_REFLECTIONS_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, decal);
#endif
}
#endif // _DECAL7
diff --git a/features.cginc b/features.cginc
index d0c3fd1..c43e0bf 100644
--- a/features.cginc
+++ b/features.cginc
@@ -130,6 +130,9 @@
#pragma shader_feature_local _DECAL0_MULTIPLY
#pragma shader_feature_local _DECAL0_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL0_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL0_EMISSIONS
+#pragma shader_feature_local _DECAL0_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL0_EMISSIONS_PROXIMITY
//endex
//ifex _Decal1_Enabled==0
#pragma shader_feature_local _DECAL1
@@ -142,6 +145,9 @@
#pragma shader_feature_local _DECAL1_MULTIPLY
#pragma shader_feature_local _DECAL1_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL1_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL1_EMISSIONS
+#pragma shader_feature_local _DECAL1_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL1_EMISSIONS_PROXIMITY
//endex
//ifex _Decal2_Enabled==0
#pragma shader_feature_local _DECAL2
@@ -154,6 +160,9 @@
#pragma shader_feature_local _DECAL2_MULTIPLY
#pragma shader_feature_local _DECAL2_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL2_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL2_EMISSIONS
+#pragma shader_feature_local _DECAL2_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL2_EMISSIONS_PROXIMITY
//endex
//ifex _Decal3_Enabled==0
#pragma shader_feature_local _DECAL3
@@ -166,6 +175,9 @@
#pragma shader_feature_local _DECAL3_MULTIPLY
#pragma shader_feature_local _DECAL3_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL3_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL3_EMISSIONS
+#pragma shader_feature_local _DECAL3_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL3_EMISSIONS_PROXIMITY
//endex
//ifex _Decal4_Enabled==0
#pragma shader_feature_local _DECAL4
@@ -178,6 +190,9 @@
#pragma shader_feature_local _DECAL4_MULTIPLY
#pragma shader_feature_local _DECAL4_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL4_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL4_EMISSIONS
+#pragma shader_feature_local _DECAL4_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL4_EMISSIONS_PROXIMITY
//endex
//ifex _Decal5_Enabled==0
#pragma shader_feature_local _DECAL5
@@ -190,6 +205,9 @@
#pragma shader_feature_local _DECAL5_MULTIPLY
#pragma shader_feature_local _DECAL5_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL5_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL5_EMISSIONS
+#pragma shader_feature_local _DECAL5_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL5_EMISSIONS_PROXIMITY
//endex
//ifex _Decal6_Enabled==0
#pragma shader_feature_local _DECAL6
@@ -202,6 +220,9 @@
#pragma shader_feature_local _DECAL6_MULTIPLY
#pragma shader_feature_local _DECAL6_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL6_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL6_EMISSIONS
+#pragma shader_feature_local _DECAL6_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL6_EMISSIONS_PROXIMITY
//endex
//ifex _Decal7_Enabled==0
#pragma shader_feature_local _DECAL7
@@ -214,6 +235,9 @@
#pragma shader_feature_local _DECAL7_MULTIPLY
#pragma shader_feature_local _DECAL7_CMYK_WARPING_PLANES
#pragma shader_feature_local _DECAL7_DOMAIN_WARPING
+#pragma shader_feature_local _DECAL7_EMISSIONS
+#pragma shader_feature_local _DECAL7_EMISSION_MODE_ADD_PRODUCT
+#pragma shader_feature_local _DECAL7_EMISSIONS_PROXIMITY
//endex
//ifex _3D_SDF_Enabled==0
diff --git a/globals.cginc b/globals.cginc
index 246366f..bffc566 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -300,7 +300,14 @@ texture2D _Decal##n##_Domain_Warping_Noise; \
float _Decal##n##_Domain_Warping_Octaves; \
float _Decal##n##_Domain_Warping_Strength; \
float _Decal##n##_Domain_Warping_Scale; \
-float _Decal##n##_Domain_Warping_Speed;
+float _Decal##n##_Domain_Warping_Speed; \
+\
+float3 _Decal##n##_Emission_Color; \
+float _Decal##n##_Emission_Strength; \
+\
+float _Decal##n##_Emissions_Proximity_Min_Distance; \
+float _Decal##n##_Emissions_Proximity_Max_Distance;
+
#if defined(_DECAL0)
DECLARE_DECAL_VARIABLES(0)
#endif
diff --git a/yum_pbr.cginc b/yum_pbr.cginc
index 342b020..76383c0 100644
--- a/yum_pbr.cginc
+++ b/yum_pbr.cginc
@@ -14,9 +14,7 @@
struct YumPbr {
float4 albedo;
float3 normal;
-#if defined(_EMISSION) || (defined(_GLITTER) && (defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS))) || defined(OUTLINE_PASS)
float3 emission;
-#endif
float smoothness;
float roughness;
float roughness_perceptual;
@@ -30,7 +28,7 @@ void propagateRoughness(in float smoothness, out float roughness_perceptual, out
}
YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) {
- YumPbr result;
+ YumPbr result = (YumPbr)0;
float2 raw_uv = i.uv01.xy;
#if defined(_UV_DOMAIN_WARPING)
@@ -103,16 +101,14 @@ YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) {
result.albedo.a = saturate(result.albedo.a * _Alpha_Multiplier);
#endif
+#if defined(FORWARD_BASE_PASS)
#if defined(_EMISSION)
result.emission = tex2D(_EmissionMap, UV_SCOFF(i, _EmissionMap_ST, /*which_channel=*/0)) * _EmissionColor;
#endif
#if defined(OUTLINE_PASS)
-#if defined(_EMISSION)
result.emission += _Outline_Color * _Outline_Emission;
-#else
- result.emission = _Outline_Color * _Outline_Emission;
-#endif
#endif
+#endif // FORWARD_BASE_PASS
#if defined(_METALLICS)
float4 metallic_gloss = tex2D(_MetallicGlossMap, UV_SCOFF(i, _MetallicGlossMap_ST, /*which_channel=*/0));
@@ -132,7 +128,7 @@ YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) {
result.ao = 1;
#endif
- applyDecals(i, result.albedo, normal_tangent, result.metallic, result.smoothness);
+ applyDecals(i, result.albedo, normal_tangent, result.metallic, result.smoothness, result.emission);
result.smoothness = min(0.99, result.smoothness);
propagateRoughness(result.smoothness, result.roughness_perceptual, result.roughness);
@@ -167,12 +163,7 @@ YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) {
float4 glitter_albedo = getGlitter(i, glitter_p, result.normal);
result.albedo = alphaBlend(result.albedo, glitter_albedo);
- float3 gitter_emission = glitter_albedo.rgb * glitter_albedo.a * _Glitter_Emission;
-#if defined(_EMISSION)
- result.emission += gitter_emission;
-#else
- result.emission = gitter_emission;
-#endif
+ result.emission += glitter_albedo.rgb * glitter_albedo.a * _Glitter_Emission;
#endif
return result;