76 lines
1.8 KiB
Plaintext
76 lines
1.8 KiB
Plaintext
|
|
|||
|
#include "Include/PlatformDefines.hlsl"
|
|||
|
|
|||
|
#pragma kernel CSInstancedTransformOffsetKernel
|
|||
|
#pragma kernel CSRemoveInsideBounds
|
|||
|
#pragma kernel CSRemoveInsideBox
|
|||
|
#pragma kernel CSRemoveInsideSphere
|
|||
|
#pragma kernel CSRemoveInsideCapsule
|
|||
|
#pragma kernel CSInstancedMatrixOffsetKernel
|
|||
|
|
|||
|
RWStructuredBuffer<float4x4> gpuiInstanceData;
|
|||
|
uniform uint bufferSize;
|
|||
|
|
|||
|
uniform float3 positionOffset;
|
|||
|
uniform float4x4 matrixOffset;
|
|||
|
|
|||
|
#include "Include/DataModel.hlsl"
|
|||
|
#include "Include/Collider.hlsl"
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSInstancedTransformOffsetKernel(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
gpuiInstanceData[id.x]._14_24_34 += positionOffset;
|
|||
|
}
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSRemoveInsideBounds(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
if (IsInsideBounds(gpuiInstanceData[id.x]._14_24_34))
|
|||
|
gpuiInstanceData[id.x] = zeroMatrix;
|
|||
|
}
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSRemoveInsideBox(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
if (IsInsideBox(gpuiInstanceData[id.x]._14_24_34))
|
|||
|
gpuiInstanceData[id.x] = zeroMatrix;
|
|||
|
}
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSRemoveInsideSphere(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
if (IsInsideSphere(gpuiInstanceData[id.x]._14_24_34))
|
|||
|
gpuiInstanceData[id.x] = zeroMatrix;
|
|||
|
}
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSRemoveInsideCapsule(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
if (IsInsideCapsule(gpuiInstanceData[id.x]._14_24_34))
|
|||
|
gpuiInstanceData[id.x] = zeroMatrix;
|
|||
|
}
|
|||
|
|
|||
|
[numthreads(GPUI_THREADS, 1, 1)]
|
|||
|
void CSInstancedMatrixOffsetKernel(uint3 id : SV_DispatchThreadID)
|
|||
|
{
|
|||
|
if (id.x >= bufferSize)
|
|||
|
return;
|
|||
|
|
|||
|
gpuiInstanceData[id.x] = mul(matrixOffset, gpuiInstanceData[id.x]);
|
|||
|
}
|