Files
2026-06-04 00:55:54 +03:00

35 lines
666 B
Plaintext

#pragma kernel CSMain
RWStructuredBuffer<float4x4> matrices;
int _CountX;
int _CountZ;
float _SizeX;
float _SizeZ;
float _Height;
[numthreads(64, 1, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
uint idx = id.x;
uint total = _CountX * _CountZ;
if (idx >= total)
return;
uint ix = idx % _CountX;
uint iz = idx / _CountX;
float fx = ((float) ix / (_CountX - 1)) * _SizeX - (_SizeX * 0.5);
float fz = ((float) iz / (_CountZ - 1)) * _SizeZ - (_SizeZ * 0.5);
float fy = _Height;
float4x4 m = float4x4(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
fx, fy, fz, 1
);
matrices[idx] = m;
}