From 6d01be1827eea13d5f6cc66de763ea67e7fca631 Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 27 Mar 2025 21:38:46 -0700 Subject: Use 3d textures for vertex domain warping --- tessellation.cginc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'tessellation.cginc') 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 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; } -- cgit v1.2.3