#include "CoreRP/ShaderLibrary/Common.hlsl" #define DIRECTION_TOPRIGHT 0 #define DIRECTION_TOP 1 #define DIRECTION_RIGHT 2 #pragma kernel KMainTopRight KERNEL_NAME=KMainTopRight DIRECTION=DIRECTION_TOPRIGHT #pragma kernel KMainTop KERNEL_NAME=KMainTop DIRECTION=DIRECTION_TOP #pragma kernel KMainRight KERNEL_NAME=KMainRight DIRECTION=DIRECTION_RIGHT #pragma only_renderers d3d11 ps4 xboxone vulkan metal // ------------------------------------------------ // Texture buffers // ------------------------------------------------ RW_TEXTURE2D(float4, _Source); // ------------------------------------------------ // Constant buffers // ------------------------------------------------ CBUFFER_START(cb) int2 _RectOffset; CBUFFER_END // ------------------------------------------------ // Kernel // ------------------------------------------------ [numthreads(1, 1, 1)] void KERNEL_NAME(uint2 dispatchThreadId : SV_DispatchThreadID) { const int2 targetId = _RectOffset + dispatchThreadId; #if DIRECTION == DIRECTION_TOPRIGHT const int2 loadId = targetId - int2(1 + dispatchThreadId.x, 1 + dispatchThreadId.y); #elif DIRECTION == DIRECTION_TOP const int2 loadId = targetId - int2(0, 1 + dispatchThreadId.y); #elif DIRECTION == DIRECTION_RIGHT const int2 loadId = targetId - int2(1 + dispatchThreadId.x, 0); #endif _Source[targetId] = _Source[loadId]; }