BarcodeRead.compute 432 B

123456789101112131415161718192021
  1. #pragma kernel Read
  2. Texture2D<float4> Source;
  3. int Row;
  4. int Column;
  5. RWStructuredBuffer<float4> Result;
  6. [numthreads(8,1,1)]
  7. void Read(uint id : SV_DispatchThreadID)
  8. {
  9. float width, height;
  10. Source.GetDimensions(width, height);
  11. uint x = id.x % Row;
  12. uint y = id.x / Row;
  13. uint pixelx = (x + 0.5) * width / Row;
  14. uint pixely = (y + 0.5) * height / Column;
  15. Result[id.x] = Source[uint2(pixelx, pixely)];
  16. }