Files
com.misaki.ao-volume/Runtime/Shader/Includes/Common.hlsl
2025-03-01 16:58:26 +09:00

31 lines
702 B
HLSL

#ifndef VOLUME_COMMON
#define VOLUME_COMMON
#define _MAX_CLUSTER_COUNT 16
#define _DEPTH_STEP (1.0 / _MAX_CLUSTER_COUNT)
float4 ComputePositionNDC(float4 positionCS, float projectionSign)
{
float4 positionNDC = positionCS * 0.5f;
positionNDC.xy = float2(positionNDC.x, positionNDC.y * projectionSign) + positionNDC.w;
positionNDC.zw = positionCS.zw;
return positionNDC;
}
uint GetClusterIndex(float linearDepth)
{
return (uint)clamp(floor(linearDepth / _DEPTH_STEP), 0.0, (float)_MAX_CLUSTER_COUNT - 1.0);
}
void GetClusterVolumeCount(uint clusterIndex, out uint count)
{
// TODO
}
uint FetchVolumeIndex(uint clusterIndex, uint offset)
{
// TODO
return 0;
}
#endif