init commit
This commit is contained in:
34
Assets/Lesson_1 Assets/Shaders/GrassShader.compute
Normal file
34
Assets/Lesson_1 Assets/Shaders/GrassShader.compute
Normal file
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user