diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-11 22:30:03 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-11 22:30:03 -0800 |
| commit | cbc299f489d6bdc38cce30d74040c54197efe125 (patch) | |
| tree | c5968e39e99ab521e6922316729a5120ff230734 | |
| parent | d2d4b8897ded5f399378ca447474f51eaefbf1a5 (diff) | |
Implement distance-based culling for instances
| -rw-r--r-- | 3ner.shader | 13 | ||||
| -rw-r--r-- | features.cginc | 4 | ||||
| -rw-r--r-- | globals.cginc | 4 | ||||
| -rw-r--r-- | pbr.cginc | 3 |
4 files changed, 23 insertions, 1 deletions
diff --git a/3ner.shader b/3ner.shader index e7865e2..70a5174 100644 --- a/3ner.shader +++ b/3ner.shader @@ -399,6 +399,18 @@ Shader "yum_food/3ner" [ThryToggle(_UNLIT)] _Unlit("Unlit", Float) = 0 //endex + [DoNotAnimate][HideInInspector] Instancing ("Instancing", Float) = 0 + //ifex Instancing==0 + [HideInInspector] m_start_Instancing("Instancing", Float) = 0 + //ifex _Instance_Distance_Culling_Enabled + [HideInInspector] m_start_Instance_Distance_Culling("Distance Culling", Float) = 0 + [ThryToggle(_INSTANCE_DISTANCE_CULLING)] _Instance_Distance_Culling_Enabled("Enable", Float) = 0 + _Instance_Distance_Culling_Distance("Distance (m)", Float) = 10 + [HideInInspector] m_end_Instance_Distance_Culling("Instance Distance Culling", Float) = 0 + //endex + [HideInInspector] m_end_Instancing("Instancing", Float) = 0 + //endex + //ifex _Parallax_Heightmap_Enabled==0 [HideInInspector] m_start_Parallax_Heightmap("Parallax Heightmap", Float) = 0 [ThryToggle(_PARALLAX_HEIGHTMAP)] _Parallax_Heightmap_Enabled("Enable", Float) = 0 @@ -476,7 +488,6 @@ Shader "yum_food/3ner" [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Source Blend", Float) = 1 [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Destination Blend", Float) = 0 [Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Int) = 1 - [DoNotAnimate][HideInInspector] Instancing ("Instancing", Float) = 0 [HideInInspector] m_end_Rendering_Options("Rendering Options", Float) = 0 } diff --git a/features.cginc b/features.cginc index 814d80d..9d1c17b 100644 --- a/features.cginc +++ b/features.cginc @@ -41,6 +41,10 @@ #pragma shader_feature_local _UNLIT //endex +//ifex _Instance_Distance_Culling_Enabled==0 +#pragma shader_feature_local _INSTANCE_DISTANCE_CULLING +//endex + //ifex _Parallax_Heightmap_Enabled==0 #pragma shader_feature_local _PARALLAX_HEIGHTMAP //endex diff --git a/globals.cginc b/globals.cginc index ad7f6d4..10f0556 100644 --- a/globals.cginc +++ b/globals.cginc @@ -166,6 +166,10 @@ float _Ray_Marching_Hexagon_Radius; float _Ray_Marching_Hexagon_Height; #endif // _RAY_MARCHING_HEXAGON +#if defined(_INSTANCE_DISTANCE_CULLING) +float _Instance_Distance_Culling_Distance; +#endif // _INSTANCE_DISTANCE_CULLING + #if defined(_PARALLAX_HEIGHTMAP) texture2D _Parallax_Heightmap; float4 _Parallax_Heightmap_ST; @@ -3,6 +3,7 @@ #include "filamented.cginc" #include "globals.cginc" +#include "instancing.cginc" #include "interpolators.cginc" #include "texture_utils.cginc" @@ -140,6 +141,8 @@ void apply_marble(float3 world_pos, inout float3 albedo) { Pbr getPbr(v2f i) { Pbr pbr = (Pbr) 0; + instancing_frag(i); + float3 n = normalize(i.normal); float3 t = normalize(i.tangent.xyz); t = normalize(t - n * dot(n, t)); // Gram-Schmidt to avoid skew |
