summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2ner.cginc35
-rw-r--r--2ner.shader15
-rw-r--r--Textures/white_4x4x4_rgb24.asset40
-rw-r--r--Textures/white_4x4x4_rgb24.asset.meta8
-rw-r--r--Textures/white_4x4x4_rgb48.asset40
-rw-r--r--Textures/white_4x4x4_rgb48.asset.meta8
-rw-r--r--features.cginc1
-rw-r--r--globals.cginc16
-rw-r--r--tessellation.cginc25
9 files changed, 153 insertions, 35 deletions
diff --git a/2ner.cginc b/2ner.cginc
index 7774084..0ef94b5 100644
--- a/2ner.cginc
+++ b/2ner.cginc
@@ -79,6 +79,18 @@ v2f vert(appdata v) {
shatterWaveVert(v.vertex.xyz, v.normal, v.tangent);
#endif
+#if defined(_VERTEX_DOMAIN_WARPING)
+ float3 basePos = v.vertex.xyz;
+ float t = _Time[0] * _Vertex_Domain_Warping_Speed;
+ for (uint i = 0; i < _Vertex_Domain_Warping_Octaves; i++) {
+ float3 uv = basePos * _Vertex_Domain_Warping_Scale +
+ _Time[0] * _Vertex_Domain_Warping_Speed;
+ float3 noise = _Vertex_Domain_Warping_Noise.SampleLevel(trilinear_repeat_s, uv, 0);
+ basePos += (noise * 2 - 1) * _Vertex_Domain_Warping_Strength;
+ }
+ v.vertex.xyz = basePos;
+#endif
+
#if defined(OUTLINE_PASS)
[branch]
if (!_Outlines_Enabled_Dynamic) {
@@ -99,24 +111,6 @@ v2f vert(appdata v) {
face_me(v);
#endif
-#if defined(_VERTEX_DOMAIN_WARPING)
- float3 basePos = v.vertex.xyz;
- float offset = sin(_Time[0] * _Vertex_Domain_Warping_Speed) *
- _Vertex_Domain_Warping_Temporal_Strength;
- v.vertex.xyz = domainWarp3(v.vertex,
- _Vertex_Domain_Warping_Spatial_Octaves,
- _Vertex_Domain_Warping_Spatial_Strength,
- _Vertex_Domain_Warping_Spatial_Scale,
- offset);
- float3 tangent_tmp = v.tangent.xyz;
- domainWarp3Normals(v.normal, tangent_tmp, basePos,
- _Vertex_Domain_Warping_Spatial_Octaves,
- _Vertex_Domain_Warping_Spatial_Strength,
- _Vertex_Domain_Warping_Spatial_Scale,
- offset);
- v.tangent.xyz = tangent_tmp;
-#endif
-
#if defined(_FOCAL_LENGTH_CONTROL)
[branch]
if (_Focal_Length_Enabled_Dynamic) {
@@ -170,7 +164,7 @@ v2f vert(appdata v) {
}
float4 frag(v2f i
-#if defined(_HARNACK_TRACING) || defined(_SHATTER_WAVE)
+#if defined(_HARNACK_TRACING) || defined(_SHATTER_WAVE) || defined(_VERTEX_DOMAIN_WARPING)
, out float depth : SV_DepthLessEqual
#endif
) : SV_Target {
@@ -187,6 +181,9 @@ float4 frag(v2f i
#if defined(_SHATTER_WAVE)
shatterWaveFrag(i.normal, i.objPos);
+#endif
+
+#if defined(_SHATTER_WAVE) || defined(_VERTEX_DOMAIN_WARPING)
{
float4 clip_pos = mul(UNITY_MATRIX_VP, float4(i.worldPos, 1.0));
depth = clip_pos.z / clip_pos.w;
diff --git a/2ner.shader b/2ner.shader
index 10d32d4..d195d54 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -535,6 +535,13 @@ Shader "yum_food/2ner"
_Tessellation_Heightmap_Scale("Scale", Float) = 1
_Tessellation_Heightmap_Offset("Offset", Range(-1, 1)) = 0
[HideInInspector] m_end_Tessellation_Heightmap("Heightmap", Float) = 0
+ [HideInInspector] m_start_Tessellation_Range_Factor("Range-based factor", Float) = 0
+ [ThryToggle(_TESSELLATION_RANGE_FACTOR)] _Tessellation_Range_Factor_Enabled("Enable", Float) = 0
+ _Tessellation_Range_Factor_Distance_Near("Distance (near)", Float) = 1
+ _Tessellation_Range_Factor_Factor_Near("Factor (near)", Float) = 1
+ _Tessellation_Range_Factor_Distance_Far("Distance (far)", Float) = 1
+ _Tessellation_Range_Factor_Factor_Far("Factor (far)", Float) = 1
+ [HideInInspector] m_end_Tessellation_Range_Factor("Range-based factor", Float) = 0
// Shit for thry
[HideInInspector] Tessellation_Enabled("Enabled", Float) = 1
[HideInInspector] Tessellation_EnabledForwardBase("Enabled (ForwardBase)", Float) = 1
@@ -554,11 +561,11 @@ Shader "yum_food/2ner"
//ifex _Vertex_Domain_Warping_Enabled==0
[HideInInspector] m_start_Vertex_Domain_Warping("Vertex domain warping", Float) = 0
[ThryToggle(_VERTEX_DOMAIN_WARPING)]_Vertex_Domain_Warping_Enabled("Enable", Float) = 0
- _Vertex_Domain_Warping_Spatial_Strength("Spatial warping strength", Float) = 0.10
- _Vertex_Domain_Warping_Spatial_Scale("Spatial warping scale", Float) = 1.0
- _Vertex_Domain_Warping_Spatial_Octaves("Spatial warping octaves", Float) = 1.0
+ _Vertex_Domain_Warping_Noise("Noise", 3D) = "black" {}
+ _Vertex_Domain_Warping_Strength("Strength", Float) = 0.10
+ _Vertex_Domain_Warping_Scale("Scale", Float) = 1.0
+ _Vertex_Domain_Warping_Octaves("Octaves", Float) = 1.0
_Vertex_Domain_Warping_Speed("Speed", Float) = 1.0
- _Vertex_Domain_Warping_Temporal_Strength("Temporal warping strength", Float) = 0.10
[HideInInspector] m_end_Vertex_Domain_Warping("Vertex domain warping", Float) = 0
//endex
diff --git a/Textures/white_4x4x4_rgb24.asset b/Textures/white_4x4x4_rgb24.asset
new file mode 100644
index 0000000..40c50eb
--- /dev/null
+++ b/Textures/white_4x4x4_rgb24.asset
@@ -0,0 +1,40 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!117 &11700000
+Texture3D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: white_4x4x4_rgb24
+ m_ImageContentsHash:
+ serializedVersion: 2
+ Hash: 00000000000000000000000000000000
+ m_ForcedFallbackFormat: 4
+ m_DownscaleFallback: 0
+ m_IsAlphaChannelOptional: 0
+ serializedVersion: 3
+ m_ColorSpace: 0
+ m_Format: 7
+ m_Width: 4
+ m_Height: 4
+ m_Depth: 4
+ m_MipCount: 1
+ m_DataSize: 192
+ m_TextureSettings:
+ serializedVersion: 2
+ m_FilterMode: 2
+ m_Aniso: 1
+ m_MipBias: 0
+ m_WrapU: 0
+ m_WrapV: 0
+ m_WrapW: 0
+ m_UsageMode: 0
+ m_IsReadable: 1
+ image data: 192
+ _typelessdata: 1eac804fb32d17c792b3affb729c8a2ef301edd44e92e29766bcd92926722a680afd43c0bddbdda73f1f355efb9e74dec072974b001a38b47d88b09a0a60cf1cb74382653fd8ddc2537f6b389fa057f2156c64b9162a13222437e1b9b31a9ee47e79ac31f3992403feccdd19aa1889e411171af39c63d4113597827ae97d029e3a65b6ff71cd7bf7aaa7c55884224fe4aef1c24f3ad7c26ac074687f7fb1032c6cf59ccfd415d95da57112d2717e6da8fa66a3a988fd042422cb3a94260ff991
+ m_StreamData:
+ serializedVersion: 2
+ offset: 0
+ size: 0
+ path:
diff --git a/Textures/white_4x4x4_rgb24.asset.meta b/Textures/white_4x4x4_rgb24.asset.meta
new file mode 100644
index 0000000..4f9ad3e
--- /dev/null
+++ b/Textures/white_4x4x4_rgb24.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: df208274ef5cd294ab5542629bd3b94a
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11700000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Textures/white_4x4x4_rgb48.asset b/Textures/white_4x4x4_rgb48.asset
new file mode 100644
index 0000000..49d3c03
--- /dev/null
+++ b/Textures/white_4x4x4_rgb48.asset
@@ -0,0 +1,40 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!117 &11700000
+Texture3D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: white_4x4x4_rgb48
+ m_ImageContentsHash:
+ serializedVersion: 2
+ Hash: 00000000000000000000000000000000
+ m_ForcedFallbackFormat: 4
+ m_DownscaleFallback: 0
+ m_IsAlphaChannelOptional: 0
+ serializedVersion: 3
+ m_ColorSpace: 0
+ m_Format: 23
+ m_Width: 4
+ m_Height: 4
+ m_Depth: 4
+ m_MipCount: 1
+ m_DataSize: 384
+ m_TextureSettings:
+ serializedVersion: 2
+ m_FilterMode: 1
+ m_Aniso: 1
+ m_MipBias: 0
+ m_WrapU: 0
+ m_WrapV: 0
+ m_WrapW: 0
+ m_UsageMode: 0
+ m_IsReadable: 1
+ image data: 384
+ _typelessdata: 303e9d04de94f36b5e2d713a27435e7fdb59a35d54400283e7814ad5e2acd7f0c617947ea7709cd5021e66901c41f755a3cfa2c77add620bad876ad1633f0056e9d001022be11c528176f9085529de45ec7a2071ee9054f978848e045d7ba22216e1c6e40c608a801b934a552674dc53c13ab83e2b52b33c578793aa0141f2986c847a51ef41f6aad86fbf987b173801d4d3ec61d6b740a926e45592034dc36f72666b4a7f2beaf2fc3406603ac2db7092bdf017c5961b214d6449301dd3add14d6cfac6447816b590933e265bbd516ae7b327ac5a233f700532c5270af90d7502cb1e4a51bd2d90ed2ff2694e5143f8bd712d944c64a07588a31a24680b17160063b74268880c24f08c1694e2689b79c051c07785dd7f76b7b1e59ef0b4bcb52f1b50537812adb04a899d444f7765d776e68c2bf84628a4d68c21b4a148bfddefaa94e8aacab65749cc3e26b16d6308c58483a88c26d8f3bded556898014671ad71eaa8346bbd90f832a9a351676777f53e41f02b1503bb744e719523c602eb
+ m_StreamData:
+ serializedVersion: 2
+ offset: 0
+ size: 0
+ path:
diff --git a/Textures/white_4x4x4_rgb48.asset.meta b/Textures/white_4x4x4_rgb48.asset.meta
new file mode 100644
index 0000000..f0222cc
--- /dev/null
+++ b/Textures/white_4x4x4_rgb48.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 56a1e130a67bafe40abef2ece1f616be
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11700000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/features.cginc b/features.cginc
index 9a96cd2..47c9ac2 100644
--- a/features.cginc
+++ b/features.cginc
@@ -207,6 +207,7 @@
//ifex _Tessellation_Enabled==0
#pragma shader_feature_local _TESSELLATION
#pragma shader_feature_local _TESSELLATION_HEIGHTMAP
+#pragma shader_feature_local _TESSELLATION_RANGE_FACTOR
//endex
//ifex _Spherize_Enabled==0
diff --git a/globals.cginc b/globals.cginc
index 3a54bb8..c1a9fb2 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -6,6 +6,7 @@
SamplerState point_repeat_s;
SamplerState linear_repeat_s;
SamplerState linear_clamp_s;
+SamplerState trilinear_repeat_s;
sampler2D _MainTex;
float4 _MainTex_ST;
@@ -286,11 +287,11 @@ DECLARE_DECAL_VARIABLES(3)
#endif
#if defined(_VERTEX_DOMAIN_WARPING)
-float _Vertex_Domain_Warping_Spatial_Strength;
-float _Vertex_Domain_Warping_Spatial_Scale;
-float _Vertex_Domain_Warping_Spatial_Octaves;
+texture3D _Vertex_Domain_Warping_Noise;
+float _Vertex_Domain_Warping_Strength;
+float _Vertex_Domain_Warping_Scale;
+float _Vertex_Domain_Warping_Octaves;
float _Vertex_Domain_Warping_Speed;
-float _Vertex_Domain_Warping_Temporal_Strength;
#endif // _VERTEX_DOMAIN_WARPING
#if defined(_UV_DOMAIN_WARPING)
@@ -439,6 +440,13 @@ float _Tessellation_Heightmap_Scale;
float _Tessellation_Heightmap_Offset;
#endif // _TESSELLATION_HEIGHTMAP
+#if defined(_TESSELLATION_RANGE_FACTOR)
+float _Tessellation_Range_Factor_Distance_Near;
+float _Tessellation_Range_Factor_Factor_Near;
+float _Tessellation_Range_Factor_Distance_Far;
+float _Tessellation_Range_Factor_Factor_Far;
+#endif // _TESSELLATION_RANGE_FACTOR
+
#if defined(_SPHERIZE)
float _Spherize_Radius;
float _Spherize_Strength;
diff --git a/tessellation.cginc b/tessellation.cginc
index faadd72..fa57861 100644
--- a/tessellation.cginc
+++ b/tessellation.cginc
@@ -15,16 +15,25 @@ struct tess_factors {
tess_factors patch_constant(InputPatch<v2f, 3> patch) {
tess_factors f;
#if defined(_TESSELLATION)
- f.edge[0] = _Tessellation_Factor;
- f.edge[1] = _Tessellation_Factor;
- f.edge[2] = _Tessellation_Factor;
- f.inside = _Tessellation_Factor;
+#if defined(_TESSELLATION_RANGE_FACTOR)
+ float d = length(getCenterCamPos() - patch[0].worldPos.xyz);
+ float factor = lerp(
+ _Tessellation_Range_Factor_Factor_Near,
+ _Tessellation_Range_Factor_Factor_Far,
+ smoothstep(
+ _Tessellation_Range_Factor_Distance_Near,
+ _Tessellation_Range_Factor_Distance_Far,
+ d));
#else
- f.edge[0] = 1;
- f.edge[1] = 1;
- f.edge[2] = 1;
- f.inside = 1;
+ float factor = _Tessellation_Factor;
#endif
+#else
+ float factor = 1;
+#endif
+ f.edge[0] = factor;
+ f.edge[1] = factor;
+ f.edge[2] = factor;
+ f.inside = factor;
return f;
}