Skip to content

Instantly share code, notes, and snippets.

@PamisuMyon
PamisuMyon / FrustumCulling.compute
Last active July 10, 2024 10:21
Unity URP DrawMeshInstancedIndirect Frustum Culling Demo
#pragma kernel CSMain
float4 _FrustumPlanes[6]; // 视锥体的六个面
float3 _BoundMin; // 物体包围盒最小点
float3 _BoundMax; // 物体包围盒最大点
StructuredBuffer<float4x4> _AllMatricesBuffer; // 所有物体的复合变换矩阵
AppendStructuredBuffer<uint> _VisibleIDsBuffer; // 可见物体实例ID
bool IsOutsideThePlane(float4 plane, float3 position)
{