Can any pro guide me on these 2 functions in the shader? what is the NEAR_Z and FAR_Z stand for, is the camera far and near value? how to get that in monogame?
float LinearDepth(float depth)
{
return (depth * NEAR_Z) / (FAR_Z - depth * (FAR_Z - NEAR_Z));
}
float ViewDepth(float depth)
{
return (FAR_Z * NEAR_Z) / (FAR_Z - depth * (FAR_Z - NEAR_Z));
}
float2 ProjectionConstants(float gNearZ, float gFarZ)
{
float2 projectionConstants;
projectionConstants.x = gFarZ / (gFarZ - gNearZ);
projectionConstants.y = (-gFarZ * gNearZ) / (gFarZ - gNearZ);
return projectionConstants;
}
float LinearZ(float4 outPosition)
{
float2 projectionConstants = ProjectionConstants(gNearZ, gFarZ);
float depth = outPosition.z / outPosition.w;
float linearZ = projectionConstants.y / (depth - projectionConstants.x);
return linearZ;
}