diff options
| -rw-r--r-- | 2ner.shader | 16 | ||||
| -rw-r--r-- | features.cginc | 4 | ||||
| -rw-r--r-- | globals.cginc | 13 | ||||
| -rw-r--r-- | yum_pbr.cginc | 37 |
4 files changed, 67 insertions, 3 deletions
diff --git a/2ner.shader b/2ner.shader index 0b8c951..cfb9bf3 100644 --- a/2ner.shader +++ b/2ner.shader @@ -460,6 +460,20 @@ Shader "yum_food/2ner" //endex [HideInInspector] m_end_Decals("Decals", Float) = 0 + //ifex _3D_SDF_Enabled==0 + [HideInInspector] m_start_3D_SDF("3D SDF", Float) = 0 + [ThryToggle(_3D_SDF)] _3D_SDF_Enabled("Enable", Float) = 0 + _3D_SDF_Texture("Texture", 3D) = "white" {} + _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) + _3D_SDF_Color_2("Color 2", Color) = (0, 0, 1, 1) + _3D_SDF_Color_3("Color 3", Color) = (1, 1, 0, 1) + _3D_SDF_Z("Z", Range(0, 1)) = 0 + _3D_SDF_Z_Speed("Z speed", Float) = 0 + [HideInInspector] m_end_3D_SDF("3D SDF", Float) = 0 + //endex + //ifex _Face_Me_Enabled==0 [HideInInspector] m_start_Face_Me("Face me", Float) = 0 [ThryToggle(_FACE_ME)] _Face_Me_Enabled("Enable", Float) = 0 @@ -595,10 +609,12 @@ Shader "yum_food/2ner" //ifex _UV_Domain_Warping_Enabled==0 [HideInInspector] m_start_UV_Domain_Warping("UV domain warping", Float) = 0 [ThryToggle(_UV_DOMAIN_WARPING)]_UV_Domain_Warping_Enabled("Enable", Float) = 0 + _UV_Domain_Warping_Noise("Noise", 2D) = "black" {} _UV_Domain_Warping_Spatial_Strength("Spatial warping strength", Float) = 0.10 _UV_Domain_Warping_Spatial_Scale("Spatial warping scale", Float) = 0.10 _UV_Domain_Warping_Spatial_Octaves("Spatial warping octaves", Float) = 1.0 _UV_Domain_Warping_Spatial_Speed("Spatial warping speed", Float) = 1.0 + _UV_Domain_Warping_Spatial_Direction("Spatial warping direction", Vector) = (1.0, 1.0, 0.0, 0.0) [HideInInspector] m_end_UV_Domain_Warping("UV domain warping", Float) = 0 //endex diff --git a/features.cginc b/features.cginc index faffddd..716c032 100644 --- a/features.cginc +++ b/features.cginc @@ -148,6 +148,10 @@ #pragma shader_feature_local _DECAL3_REPLACE_ALPHA //endex +//ifex _3D_SDF_Enabled==0 +#pragma shader_feature_local _3D_SDF +//endex + //ifex _False_Color_Visualization_Enabled==0 #pragma shader_feature_local _FALSE_COLOR_VISUALIZATION //endex diff --git a/globals.cginc b/globals.cginc index 5530d41..955cc2a 100644 --- a/globals.cginc +++ b/globals.cginc @@ -300,10 +300,12 @@ float _Vertex_Domain_Warping_Audiolink_VU_Scale_Factor; #endif // _VERTEX_DOMAIN_WARPING_AUDIOLINK
#if defined(_UV_DOMAIN_WARPING)
+texture2D _UV_Domain_Warping_Noise;
float _UV_Domain_Warping_Spatial_Strength;
float _UV_Domain_Warping_Spatial_Scale;
float _UV_Domain_Warping_Spatial_Octaves;
float _UV_Domain_Warping_Spatial_Speed;
+float2 _UV_Domain_Warping_Spatial_Direction;
#endif
#if defined(_EYE_EFFECT_00)
@@ -473,4 +475,15 @@ float _Spherize_Radius; float _Spherize_Strength;
#endif // _SPHERIZE
+#if defined(_3D_SDF)
+texture3D _3D_SDF_Texture;
+float4 _3D_SDF_Thresholds;
+float4 _3D_SDF_Color_0;
+float4 _3D_SDF_Color_1;
+float4 _3D_SDF_Color_2;
+float4 _3D_SDF_Color_3;
+float _3D_SDF_Z;
+float _3D_SDF_Z_Speed;
+#endif // _3D_SDF
+
#endif // __GLOBALS_INC
diff --git a/yum_pbr.cginc b/yum_pbr.cginc index 71d7f2e..662ee1c 100644 --- a/yum_pbr.cginc +++ b/yum_pbr.cginc @@ -32,9 +32,28 @@ YumPbr GetYumPbr(v2f i) { float2 raw_uv = i.uv01.xy; #if defined(_UV_DOMAIN_WARPING) - i.uv01.xy = domainWarp2(i.uv01.xy, _UV_Domain_Warping_Spatial_Octaves, - _UV_Domain_Warping_Spatial_Strength, _UV_Domain_Warping_Spatial_Scale, - _UV_Domain_Warping_Spatial_Speed); + { + float2 warped_uv = raw_uv; + float amplitude = _UV_Domain_Warping_Spatial_Strength; + float frequency = _UV_Domain_Warping_Spatial_Scale; + + float2 speed_direction = _UV_Domain_Warping_Spatial_Direction; + float2 time_offset = speed_direction * _Time.y * _UV_Domain_Warping_Spatial_Speed; + + const float lacunarity = 2.0; + const float persistence = 0.5; + + [loop] + for (uint ii = 0; ii < _UV_Domain_Warping_Spatial_Octaves; ii++) { + float2 noise_uv = warped_uv * frequency + time_offset; + float2 offset_sample = _UV_Domain_Warping_Noise.SampleLevel(trilinear_repeat_s, noise_uv, 0).rg; + offset_sample = (offset_sample * 2.0 - 1.0); + warped_uv += offset_sample * amplitude; + frequency *= lacunarity; + amplitude *= persistence; + } + i.uv01.xy = warped_uv; + } #endif #if defined(OUTLINE_PASS) @@ -46,6 +65,18 @@ YumPbr GetYumPbr(v2f i) { UV_SCOFF(i, _MainTex_ST, /*which_channel=*/0)) * _Color; #endif +#if defined(_3D_SDF) + { + float3 sdf_uv = float3(i.uv01.xy, _3D_SDF_Z + _Time.y * _3D_SDF_Z_Speed); + float sdf_value = _3D_SDF_Texture.SampleLevel(trilinear_repeat_s, sdf_uv, 0).r; + float4 is_lit = sdf_value < _3D_SDF_Thresholds; + result.albedo.rgb = lerp(result.albedo.rgb, _3D_SDF_Color_3, is_lit.w); + result.albedo.rgb = lerp(result.albedo.rgb, _3D_SDF_Color_2, is_lit.z); + result.albedo.rgb = lerp(result.albedo.rgb, _3D_SDF_Color_1, is_lit.y); + result.albedo.rgb = lerp(result.albedo.rgb, _3D_SDF_Color_0, is_lit.x); + } +#endif + float3 normal_tangent = UnpackScaleNormal( tex2D(_BumpMap, UV_SCOFF(i, _BumpMap_ST, /*which_channel=*/0)), _BumpScale); |
