// 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 TerrainMinMax { float minHeight; float maxHeight; }; Texture2D Input; globallycoherent RWStructuredBufferoutputBuffer; int passes; [numthreads(8,8,1)] void CSMain (uint3 id : SV_DispatchThreadID) { for(int i=0;ioutputBuffer[0].maxHeight) { outputBuffer[0].maxHeight = Input[id.xy].r; } else if(Input[id.xy].r