blob: eb8e25ba92f7de455526fef697717f5fdf553c42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|