diff options
| -rwxr-xr-x | 3ner.shader | 108 | ||||
| -rw-r--r-- | decal.cginc | 150 | ||||
| -rwxr-xr-x | features.cginc | 27 | ||||
| -rwxr-xr-x | globals.cginc | 66 |
4 files changed, 351 insertions, 0 deletions
diff --git a/3ner.shader b/3ner.shader index 83872c6..32f51d7 100755 --- a/3ner.shader +++ b/3ner.shader @@ -101,6 +101,114 @@ Shader "yum_food/3ner" //endex [HideInInspector] m_end_Decal0("Decal 0", Float) = 0 //endex + + //ifex _Decal1_Enabled==0 + [HideInInspector] m_start_Decal1("Decal 1", Float) = 0 + [ThryToggle(_DECAL1)] _Decal1_Enabled("Enable", Float) = 0 + _Decal1_MainTex("Base color", 2D) = "white" {} + [HDR] _Decal1_Color("Tint", Color) = (1, 1, 1, 1) + _Decal1_Opacity("Opacity", Range(0, 1)) = 1 + [ThryWideEnum(Repeat, 0, Mirror, 1, Clamp, 2)] _Decal1_UV_Mode("UV Mode", Int) = 0 + [ThryWideEnum(AlphaBlend, 0, Multiply, 1, AddProduct, 2)] _Decal1_Mix_Mode("Mix Mode", Int) = 0 + [IntRange] _Decal1_UV_Channel("UV Channel", Range(0, 3)) = 0 + [ThryToggle(_DECAL1_ALBEDO_CLAMP)] _Decal1_Albedo_Clamp("Clamp albedo", Float) = 0 + + //ifex _Decal1_Mask_Enabled==0 + [HideInInspector] m_start_Decal1_Mask("Mask", Float) = 0 + [ThryToggle(_DECAL1_MASK)] _Decal1_Mask_Enabled("Enable", Float) = 0 + _Decal1_Mask("Mask", 2D) = "white" {} + [ThryToggle(_DECAL1_MASK_INVERT)] _Decal1_Mask_Invert("Invert", Float) = 0 + [IntRange] _Decal1_Mask_UV_Channel("UV Channel", Range(0, 3)) = 0 + [HideInInspector] m_end_Decal1_Mask("Mask", Float) = 0 + //endex + + //ifex _Decal1_Metallic_Gloss_Enabled==0 + [HideInInspector] m_start_Decal1_Metallic_Gloss("Metallic Gloss", Float) = 0 + [ThryToggle(_DECAL1_METALLIC_GLOSS)] _Decal1_Metallic_Gloss_Enabled("Enable", Float) = 0 + _Decal1_Metallic_Gloss("Metallic Gloss", 2D) = "white" {} + [HideInInspector] m_end_Decal1_Metallic_Gloss("Metallic Gloss", Float) = 0 + //endex + + //ifex _Decal1_Rotation_Enabled==0 + [HideInInspector] m_start_Decal1_Rotation("Rotation", Float) = 0 + [ThryToggle(_DECAL1_ROTATION)] _Decal1_Rotation_Enabled("Enable", Float) = 0 + _Decal1_Rotation("Rotation", Range(-0.5, 0.5)) = 0 + [HideInInspector] m_end_Decal1_Rotation("Rotation", Float) = 0 + //endex + [HideInInspector] m_end_Decal1("Decal 1", Float) = 0 + //endex + + //ifex _Decal2_Enabled==0 + [HideInInspector] m_start_Decal2("Decal 2", Float) = 0 + [ThryToggle(_DECAL2)] _Decal2_Enabled("Enable", Float) = 0 + _Decal2_MainTex("Base color", 2D) = "white" {} + [HDR] _Decal2_Color("Tint", Color) = (1, 1, 1, 1) + _Decal2_Opacity("Opacity", Range(0, 1)) = 1 + [ThryWideEnum(Repeat, 0, Mirror, 1, Clamp, 2)] _Decal2_UV_Mode("UV Mode", Int) = 0 + [ThryWideEnum(AlphaBlend, 0, Multiply, 1, AddProduct, 2)] _Decal2_Mix_Mode("Mix Mode", Int) = 0 + [IntRange] _Decal2_UV_Channel("UV Channel", Range(0, 3)) = 0 + [ThryToggle(_DECAL2_ALBEDO_CLAMP)] _Decal2_Albedo_Clamp("Clamp albedo", Float) = 0 + + //ifex _Decal2_Mask_Enabled==0 + [HideInInspector] m_start_Decal2_Mask("Mask", Float) = 0 + [ThryToggle(_DECAL2_MASK)] _Decal2_Mask_Enabled("Enable", Float) = 0 + _Decal2_Mask("Mask", 2D) = "white" {} + [ThryToggle(_DECAL2_MASK_INVERT)] _Decal2_Mask_Invert("Invert", Float) = 0 + [IntRange] _Decal2_Mask_UV_Channel("UV Channel", Range(0, 3)) = 0 + [HideInInspector] m_end_Decal2_Mask("Mask", Float) = 0 + //endex + + //ifex _Decal2_Metallic_Gloss_Enabled==0 + [HideInInspector] m_start_Decal2_Metallic_Gloss("Metallic Gloss", Float) = 0 + [ThryToggle(_DECAL2_METALLIC_GLOSS)] _Decal2_Metallic_Gloss_Enabled("Enable", Float) = 0 + _Decal2_Metallic_Gloss("Metallic Gloss", 2D) = "white" {} + [HideInInspector] m_end_Decal2_Metallic_Gloss("Metallic Gloss", Float) = 0 + //endex + + //ifex _Decal2_Rotation_Enabled==0 + [HideInInspector] m_start_Decal2_Rotation("Rotation", Float) = 0 + [ThryToggle(_DECAL2_ROTATION)] _Decal2_Rotation_Enabled("Enable", Float) = 0 + _Decal2_Rotation("Rotation", Range(-0.5, 0.5)) = 0 + [HideInInspector] m_end_Decal2_Rotation("Rotation", Float) = 0 + //endex + [HideInInspector] m_end_Decal2("Decal 2", Float) = 0 + //endex + + //ifex _Decal3_Enabled==0 + [HideInInspector] m_start_Decal3("Decal 3", Float) = 0 + [ThryToggle(_DECAL3)] _Decal3_Enabled("Enable", Float) = 0 + _Decal3_MainTex("Base color", 2D) = "white" {} + [HDR] _Decal3_Color("Tint", Color) = (1, 1, 1, 1) + _Decal3_Opacity("Opacity", Range(0, 1)) = 1 + [ThryWideEnum(Repeat, 0, Mirror, 1, Clamp, 2)] _Decal3_UV_Mode("UV Mode", Int) = 0 + [ThryWideEnum(AlphaBlend, 0, Multiply, 1, AddProduct, 2)] _Decal3_Mix_Mode("Mix Mode", Int) = 0 + [IntRange] _Decal3_UV_Channel("UV Channel", Range(0, 3)) = 0 + [ThryToggle(_DECAL3_ALBEDO_CLAMP)] _Decal3_Albedo_Clamp("Clamp albedo", Float) = 0 + + //ifex _Decal3_Mask_Enabled==0 + [HideInInspector] m_start_Decal3_Mask("Mask", Float) = 0 + [ThryToggle(_DECAL3_MASK)] _Decal3_Mask_Enabled("Enable", Float) = 0 + _Decal3_Mask("Mask", 2D) = "white" {} + [ThryToggle(_DECAL3_MASK_INVERT)] _Decal3_Mask_Invert("Invert", Float) = 0 + [IntRange] _Decal3_Mask_UV_Channel("UV Channel", Range(0, 3)) = 0 + [HideInInspector] m_end_Decal3_Mask("Mask", Float) = 0 + //endex + + //ifex _Decal3_Metallic_Gloss_Enabled==0 + [HideInInspector] m_start_Decal3_Metallic_Gloss("Metallic Gloss", Float) = 0 + [ThryToggle(_DECAL3_METALLIC_GLOSS)] _Decal3_Metallic_Gloss_Enabled("Enable", Float) = 0 + _Decal3_Metallic_Gloss("Metallic Gloss", 2D) = "white" {} + [HideInInspector] m_end_Decal3_Metallic_Gloss("Metallic Gloss", Float) = 0 + //endex + + //ifex _Decal3_Rotation_Enabled==0 + [HideInInspector] m_start_Decal3_Rotation("Rotation", Float) = 0 + [ThryToggle(_DECAL3_ROTATION)] _Decal3_Rotation_Enabled("Enable", Float) = 0 + _Decal3_Rotation("Rotation", Range(-0.5, 0.5)) = 0 + [HideInInspector] m_end_Decal3_Rotation("Rotation", Float) = 0 + //endex + [HideInInspector] m_end_Decal3("Decal 3", Float) = 0 + //endex [HideInInspector] m_end_Decals("Decals", Float) = 0 [HideInInspector] m_start_Matcaps("Matcaps", Float) = 0 diff --git a/decal.cginc b/decal.cginc index 8492c74..5f60fe7 100644 --- a/decal.cginc +++ b/decal.cginc @@ -78,6 +78,156 @@ void applyDecals(v2f i, inout Pbr pbr) { #endif // _DECAL0_METALLIC_GLOSS } #endif + +#if defined(_DECAL1) + { + float2 uv = get_uv_by_channel(i, _Decal1_UV_Channel); + uv -= _Decal1_MainTex_ST.zw; + uv *= _Decal1_MainTex_ST.xy; +#if defined(_DECAL1_ROTATION) + uv = decal_rotate(uv, _Decal1_Rotation); +#endif + float4 albedo = decal_sample(_Decal1_MainTex, uv, _Decal1_UV_Mode); + albedo *= _Decal1_Color; + albedo.a *= _Decal1_Opacity; + +#if defined(_DECAL1_MASK) + float2 mask_uv = get_uv_by_channel(i, _Decal1_Mask_UV_Channel); + mask_uv -= _Decal1_Mask_ST.zw; + mask_uv *= _Decal1_Mask_ST.xy; + float mask = decal_sample(_Decal1_Mask, mask_uv, _Decal1_UV_Mode); +#if defined(_DECAL1_MASK_INVERT) + mask = 1 - mask; +#endif // _DECAL1_MASK_INVERT + albedo.a *= mask; +#endif // _DECAL1_MASK + +#if defined(_DECAL1_ALBEDO_CLAMP) + albedo.rgb = saturate(albedo.rgb); +#endif // _DECAL1_ALBEDO_CLAMP + + [forcecase] + switch (_Decal1_Mix_Mode) { + case DECAL_MIX_MODE_ALPHA_BLEND: + pbr.albedo = alpha_blend(albedo, pbr.albedo); + break; + case DECAL_MIX_MODE_MULTIPLY: + pbr.albedo.rgb *= lerp(1, albedo.rgb, albedo.a); + break; + case DECAL_MIX_MODE_ADD_PRODUCT: + pbr.albedo.rgb += lerp(0, albedo.rgb * pbr.albedo.rgb, albedo.a); + break; + } + +#if defined(_DECAL1_METALLIC_GLOSS) + float4 mg = decal_sample(_Decal1_Metallic_Gloss, uv, _Decal1_UV_Mode); + pbr.metallic = lerp(pbr.metallic, mg.r, albedo.a); + pbr.smoothness = lerp(pbr.smoothness, mg.a, albedo.a); + pbr.roughness_perceptual = clamp(1 - pbr.smoothness, MIN_PERCEPTUAL_ROUGHNESS, 1); + pbr.roughness = clamp(pbr.roughness_perceptual * pbr.roughness_perceptual, MIN_ROUGHNESS, 1); +#endif // _DECAL1_METALLIC_GLOSS + } +#endif + +#if defined(_DECAL2) + { + float2 uv = get_uv_by_channel(i, _Decal2_UV_Channel); + uv -= _Decal2_MainTex_ST.zw; + uv *= _Decal2_MainTex_ST.xy; +#if defined(_DECAL2_ROTATION) + uv = decal_rotate(uv, _Decal2_Rotation); +#endif + float4 albedo = decal_sample(_Decal2_MainTex, uv, _Decal2_UV_Mode); + albedo *= _Decal2_Color; + albedo.a *= _Decal2_Opacity; + +#if defined(_DECAL2_MASK) + float2 mask_uv = get_uv_by_channel(i, _Decal2_Mask_UV_Channel); + mask_uv -= _Decal2_Mask_ST.zw; + mask_uv *= _Decal2_Mask_ST.xy; + float mask = decal_sample(_Decal2_Mask, mask_uv, _Decal2_UV_Mode); +#if defined(_DECAL2_MASK_INVERT) + mask = 1 - mask; +#endif // _DECAL2_MASK_INVERT + albedo.a *= mask; +#endif // _DECAL2_MASK + +#if defined(_DECAL2_ALBEDO_CLAMP) + albedo.rgb = saturate(albedo.rgb); +#endif // _DECAL2_ALBEDO_CLAMP + + [forcecase] + switch (_Decal2_Mix_Mode) { + case DECAL_MIX_MODE_ALPHA_BLEND: + pbr.albedo = alpha_blend(albedo, pbr.albedo); + break; + case DECAL_MIX_MODE_MULTIPLY: + pbr.albedo.rgb *= lerp(1, albedo.rgb, albedo.a); + break; + case DECAL_MIX_MODE_ADD_PRODUCT: + pbr.albedo.rgb += lerp(0, albedo.rgb * pbr.albedo.rgb, albedo.a); + break; + } + +#if defined(_DECAL2_METALLIC_GLOSS) + float4 mg = decal_sample(_Decal2_Metallic_Gloss, uv, _Decal2_UV_Mode); + pbr.metallic = lerp(pbr.metallic, mg.r, albedo.a); + pbr.smoothness = lerp(pbr.smoothness, mg.a, albedo.a); + pbr.roughness_perceptual = clamp(1 - pbr.smoothness, MIN_PERCEPTUAL_ROUGHNESS, 1); + pbr.roughness = clamp(pbr.roughness_perceptual * pbr.roughness_perceptual, MIN_ROUGHNESS, 1); +#endif // _DECAL2_METALLIC_GLOSS + } +#endif + +#if defined(_DECAL3) + { + float2 uv = get_uv_by_channel(i, _Decal3_UV_Channel); + uv -= _Decal3_MainTex_ST.zw; + uv *= _Decal3_MainTex_ST.xy; +#if defined(_DECAL3_ROTATION) + uv = decal_rotate(uv, _Decal3_Rotation); +#endif + float4 albedo = decal_sample(_Decal3_MainTex, uv, _Decal3_UV_Mode); + albedo *= _Decal3_Color; + albedo.a *= _Decal3_Opacity; + +#if defined(_DECAL3_MASK) + float2 mask_uv = get_uv_by_channel(i, _Decal3_Mask_UV_Channel); + mask_uv -= _Decal3_Mask_ST.zw; + mask_uv *= _Decal3_Mask_ST.xy; + float mask = decal_sample(_Decal3_Mask, mask_uv, _Decal3_UV_Mode); +#if defined(_DECAL3_MASK_INVERT) + mask = 1 - mask; +#endif // _DECAL3_MASK_INVERT + albedo.a *= mask; +#endif // _DECAL3_MASK + +#if defined(_DECAL3_ALBEDO_CLAMP) + albedo.rgb = saturate(albedo.rgb); +#endif // _DECAL3_ALBEDO_CLAMP + + [forcecase] + switch (_Decal3_Mix_Mode) { + case DECAL_MIX_MODE_ALPHA_BLEND: + pbr.albedo = alpha_blend(albedo, pbr.albedo); + break; + case DECAL_MIX_MODE_MULTIPLY: + pbr.albedo.rgb *= lerp(1, albedo.rgb, albedo.a); + break; + case DECAL_MIX_MODE_ADD_PRODUCT: + pbr.albedo.rgb += lerp(0, albedo.rgb * pbr.albedo.rgb, albedo.a); + break; + } + +#if defined(_DECAL3_METALLIC_GLOSS) + float4 mg = decal_sample(_Decal3_Metallic_Gloss, uv, _Decal3_UV_Mode); + pbr.metallic = lerp(pbr.metallic, mg.r, albedo.a); + pbr.smoothness = lerp(pbr.smoothness, mg.a, albedo.a); + pbr.roughness_perceptual = clamp(1 - pbr.smoothness, MIN_PERCEPTUAL_ROUGHNESS, 1); + pbr.roughness = clamp(pbr.roughness_perceptual * pbr.roughness_perceptual, MIN_ROUGHNESS, 1); +#endif // _DECAL3_METALLIC_GLOSS + } +#endif } #endif // __DECAL_INC diff --git a/features.cginc b/features.cginc index 265c35f..621c7f0 100755 --- a/features.cginc +++ b/features.cginc @@ -167,6 +167,33 @@ #pragma shader_feature_local _DECAL0_MASK_INVERT //endex +//ifex _Decal1_Enabled==0 +#pragma shader_feature_local _DECAL1 +#pragma shader_feature_local _DECAL1_ALBEDO_CLAMP +#pragma shader_feature_local _DECAL1_METALLIC_GLOSS +#pragma shader_feature_local _DECAL1_ROTATION +#pragma shader_feature_local _DECAL1_MASK +#pragma shader_feature_local _DECAL1_MASK_INVERT +//endex + +//ifex _Decal2_Enabled==0 +#pragma shader_feature_local _DECAL2 +#pragma shader_feature_local _DECAL2_ALBEDO_CLAMP +#pragma shader_feature_local _DECAL2_METALLIC_GLOSS +#pragma shader_feature_local _DECAL2_ROTATION +#pragma shader_feature_local _DECAL2_MASK +#pragma shader_feature_local _DECAL2_MASK_INVERT +//endex + +//ifex _Decal3_Enabled==0 +#pragma shader_feature_local _DECAL3 +#pragma shader_feature_local _DECAL3_ALBEDO_CLAMP +#pragma shader_feature_local _DECAL3_METALLIC_GLOSS +#pragma shader_feature_local _DECAL3_ROTATION +#pragma shader_feature_local _DECAL3_MASK +#pragma shader_feature_local _DECAL3_MASK_INVERT +//endex + //ifex _Matcap0_Enabled==0 #pragma shader_feature_local _MATCAP0 #pragma shader_feature_local _MATCAP0_QUANTIZATION diff --git a/globals.cginc b/globals.cginc index 263c07e..44417ac 100755 --- a/globals.cginc +++ b/globals.cginc @@ -271,6 +271,72 @@ float4 _Decal0_Metallic_Gloss_ST; #endif // _DECAL0_METALLIC_GLOSS #endif // _DECAL0 +#if defined(_DECAL1) +float4 _Decal1_Color; +texture2D _Decal1_MainTex; +float4 _Decal1_MainTex_ST; +float _Decal1_Opacity; +int _Decal1_UV_Mode; +int _Decal1_UV_Channel; +int _Decal1_Mix_Mode; +#if defined(_DECAL1_ROTATION) +float _Decal1_Rotation; +#endif // _DECAL1_ROTATION +#if defined(_DECAL1_MASK) +texture2D _Decal1_Mask; +float4 _Decal1_Mask_ST; +int _Decal1_Mask_UV_Channel; +#endif // _DECAL1_MASK +#if defined(_DECAL1_METALLIC_GLOSS) +texture2D _Decal1_Metallic_Gloss; +float4 _Decal1_Metallic_Gloss_ST; +#endif // _DECAL1_METALLIC_GLOSS +#endif // _DECAL1 + +#if defined(_DECAL2) +float4 _Decal2_Color; +texture2D _Decal2_MainTex; +float4 _Decal2_MainTex_ST; +float _Decal2_Opacity; +int _Decal2_UV_Mode; +int _Decal2_UV_Channel; +int _Decal2_Mix_Mode; +#if defined(_DECAL2_ROTATION) +float _Decal2_Rotation; +#endif // _DECAL2_ROTATION +#if defined(_DECAL2_MASK) +texture2D _Decal2_Mask; +float4 _Decal2_Mask_ST; +int _Decal2_Mask_UV_Channel; +#endif // _DECAL2_MASK +#if defined(_DECAL2_METALLIC_GLOSS) +texture2D _Decal2_Metallic_Gloss; +float4 _Decal2_Metallic_Gloss_ST; +#endif // _DECAL2_METALLIC_GLOSS +#endif // _DECAL2 + +#if defined(_DECAL3) +float4 _Decal3_Color; +texture2D _Decal3_MainTex; +float4 _Decal3_MainTex_ST; +float _Decal3_Opacity; +int _Decal3_UV_Mode; +int _Decal3_UV_Channel; +int _Decal3_Mix_Mode; +#if defined(_DECAL3_ROTATION) +float _Decal3_Rotation; +#endif // _DECAL3_ROTATION +#if defined(_DECAL3_MASK) +texture2D _Decal3_Mask; +float4 _Decal3_Mask_ST; +int _Decal3_Mask_UV_Channel; +#endif // _DECAL3_MASK +#if defined(_DECAL3_METALLIC_GLOSS) +texture2D _Decal3_Metallic_Gloss; +float4 _Decal3_Metallic_Gloss_ST; +#endif // _DECAL3_METALLIC_GLOSS +#endif // _DECAL3 + #define MATCAP_MODE_REPLACE 0 #define MATCAP_MODE_ADD 1 #define MATCAP_MODE_MULTIPLY 2 |
