RenderCompute.compute 535 B

1234567891011121314151617181920212223242526
  1. #pragma kernel CS_CopyDepth COPY_DEPTH
  2. #define DEPTH_COPY_WORKGROUP 16
  3. #ifdef COPY_DEPTH
  4. float2 Resolution;
  5. Texture2D<float> _CameraDepthTexture;
  6. RWTexture2D<float> _DepthOUT;
  7. [numthreads(DEPTH_COPY_WORKGROUP, DEPTH_COPY_WORKGROUP, 1)]
  8. void CS_CopyDepth(uint3 id : SV_DispatchThreadID)
  9. {
  10. if (any(float2(id.xy) > Resolution))
  11. {
  12. return;
  13. }
  14. float sceneDepth = _CameraDepthTexture.Load(int3(id.xy, 0));
  15. #if !UNITY_REVERSED_Z
  16. sceneDepth = 1.0 - sceneDepth;
  17. #endif
  18. _DepthOUT[id.xy] = sceneDepth;
  19. }
  20. #endif