// Each #kernel tells which function to compile; you can have many kernels #pragma kernel CSMain // Create a RenderTexture with enableRandomWrite flag and set it // with cs.SetTexture struct TerrainPosition { int terrainID; uint2 min; uint2 max; int affected; }; Texture2D Input; RWStructuredBufferoutputBuffer; float fitnessThreshold; int testInt; int numberOfTerrains = 0; [numthreads(8,8,1)] void CSMain (uint3 id : SV_DispatchThreadID) { if(Input[id.xy].r>fitnessThreshold) { for(int i=0;i= currentPos.min.x && id.y >= currentPos.min.y && id.x <= currentPos.max.x && id.y <= currentPos.max.y ) { outputBuffer[i].affected = 1; } } } }