You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
|
|
#include "./../../../GPUInstancer/Resources/Compute/Include/PlatformDefines.compute"
|
|
|
|
#pragma kernel CSAnimationBufferToTextureKernel
|
|
|
|
uniform StructuredBuffer<float4x4> gpuiAnimationBuffer;
|
|
RWTexture2D<float4> gpuiAnimationBufferTexture;
|
|
uniform uint totalNumberOfBones;
|
|
uniform uint instanceCount;
|
|
uniform uint maxTextureSize;
|
|
|
|
[numthreads(GPUI_THREADS_2D, GPUI_THREADS_2D, 1)]
|
|
void CSAnimationBufferToTextureKernel(uint3 id : SV_DispatchThreadID)
|
|
{
|
|
if (id.x >= instanceCount || id.y >= totalNumberOfBones)
|
|
return;
|
|
|
|
uint index = id.y + totalNumberOfBones * id.x;
|
|
|
|
uint indexX = index % maxTextureSize;
|
|
uint indexY = floor(index / float(maxTextureSize));
|
|
|
|
float4x4 boneMarix = gpuiAnimationBuffer[index];
|
|
|
|
gpuiAnimationBufferTexture[uint2(indexX, 0 + indexY * 4)] = boneMarix._11_12_13_14; // row0
|
|
gpuiAnimationBufferTexture[uint2(indexX, 1 + indexY * 4)] = boneMarix._21_22_23_24; // row1
|
|
gpuiAnimationBufferTexture[uint2(indexX, 2 + indexY * 4)] = boneMarix._31_32_33_34; // row2
|
|
gpuiAnimationBufferTexture[uint2(indexX, 3 + indexY * 4)] = boneMarix._41_42_43_44; // row3
|
|
} |