diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-14 22:08:29 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-14 22:08:29 -0800 |
| commit | f0d753b1cfa07079886abe0c3c5fc7ee75b426fd (patch) | |
| tree | 9b5f87aa5f9dc7477ca006cdbf699910df9550aa | |
| parent | 0b2eeefb9dd4b333f3065ba9842535d91524a536 (diff) | |
oops, add instancing cginc
| -rw-r--r-- | instancing.cginc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/instancing.cginc b/instancing.cginc new file mode 100644 index 0000000..eb8e25b --- /dev/null +++ b/instancing.cginc @@ -0,0 +1,22 @@ +#ifndef __INSTANCING_INC +#define __INSTANCING_INC + +#include "globals.cginc" +#include "interpolators.cginc" + +void instance_distance_culling(inout v2f i) { +#if defined(_INSTANCE_DISTANCE_CULLING) + // We want to measure the distance from the instance's transform to the camera. + float3 instance_pos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz; + float distance = length(_WorldSpaceCameraPos - instance_pos); + if (distance > _Instance_Distance_Culling_Distance) { + discard; + } +#endif // _INSTANCE_DISTANCE_CULLING +} + +void instancing_frag(v2f i) { + instance_distance_culling(i); +} + +#endif // __INSTANCING_INC |
