#pragma kernel appendId #pragma kernel copy Texture2D _Mask; float4 _MaskResolution; uint _ObjectID; Texture2D _ObjectIDs; float _ObjectIDsSize; float _MaskingSize; AppendStructuredBuffer _AppendBuffer; [numthreads(8, 8, 1)] void appendId (uint2 id : SV_DispatchThreadID) { float2 uv = id * _MaskingSize; int2 objIdx = (int2)round(uv * _ObjectIDsSize); uint objectId = (uint)_ObjectIDs[objIdx]; if (objectId == _ObjectID) _AppendBuffer.Append(uv); } StructuredBuffer _CompactUVBuffer; RWTexture2D _CompactUVTexture; int _CompactUVTextureSize; [numthreads(1, 1, 1)] void copy (uint2 id : SV_DispatchThreadID) { _CompactUVTexture[id] = _CompactUVBuffer[id.x + _CompactUVTextureSize * id.y]; }