#pragma kernel CSMain

Texture2D<float> Input;
RWTexture2D<float> Previous;
RWTexture2D<float> Result;
float Factor;

[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
    int xOffset = id.x * 64;
    int yOffset = id.y * 53;
    
    for(int localY = 0; localY < 53; ++localY)
    {
        for(int localX = 0; localX < 64; ++localX)
        {
            uint2 coordinate = uint2(xOffset + localX, yOffset + localY);
            float inputValue = (float)Input[coordinate];
            float previousValue = (float)Previous[coordinate];
            
            Result[coordinate] = abs(inputValue - previousValue) / Factor;
            Previous[coordinate] = Input[coordinate];
        }
    }    
}