summaryrefslogtreecommitdiffstats
path: root/tessellation.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-03-27 21:38:46 -0700
committeryum <yum.food.vr@gmail.com>2025-03-27 21:38:46 -0700
commit6d01be1827eea13d5f6cc66de763ea67e7fca631 (patch)
tree9a1d4595ea76714783bff0ae813b886f598e288f /tessellation.cginc
parent36dbdde9a08c66c5be2e8b8b6c822968a73041b6 (diff)
Use 3d textures for vertex domain warping
Diffstat (limited to 'tessellation.cginc')
-rw-r--r--tessellation.cginc25
1 files changed, 17 insertions, 8 deletions
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;
}