

uniform vec2 fsrScreenSize;
uniform vec2 fsrRenderScale;


void FsrScaleVS(inout vec4 position, vec2 jitter){
    position.xy /= position.w;
    position.xy = position.xy * fsrRenderScale + fsrRenderScale - 1.0;
    #ifdef CUSTOM_RENDER_RESOLUTION
        position.xy += jitter * fsrRenderScale;
    #else
        position.xy += jitter;
    #endif
    position.xy *= position.w;
}

bool FsrDiscardFS(vec2 fragCoord){
    return any(greaterThan(fragCoord, fsrScreenSize));
}

#ifdef CUSTOM_RENDER_RESOLUTION
    uniform vec3 gbufferProjection0;
    uniform mat4 gbufferProjection;
    uniform mat4 gbufferProjectionInverse;

    void RedoProject(inout vec4 position){
		position = gbufferProjectionInverse * position;
        mat4 projectMat = gbufferProjection;
        projectMat[0][0] = gbufferProjection0.x;
        projectMat[1][1] = gbufferProjection0.y;
        position = projectMat * position;
    }

    #ifdef LOD_RENDERING
        uniform vec3 lodProjection0;
        uniform mat4 dhProjection;
        uniform mat4 dhProjectionInverse;

        void RedoProjectDH(inout vec4 position){
            position = dhProjectionInverse * position;
            mat4 projectMat = dhProjection;
            projectMat[0][0] = gbufferProjection0.x;
            projectMat[1][1] = gbufferProjection0.y;
            position = projectMat * position;
        }
    #endif

#endif