Use of "ScreenTC" and "TC_Window" in fragment shaders

52 Views Asked by At

I am quite new to GLSL and graphics programming in general. I have looked around for what these terms could mean and how they would be calculated in GLSL shaders but I have not been able to find anything that goes into much detail

I wanted to know what screenTC is or tc_window in these shaders and how it could be calculated. I assume they mean "Screen Texture Coordinates" and "Texture Coordinate Window" respectively although, I am not sure. I am seeing the use of these terms in SSAO related shaders

Example 1

uniform vec2 tc_window;
float ec_depth(in vec2 tc)
{
    float buffer_z = texture(depthMap, tc).x;
    return camera.proj[3][2] / (-2.0 * buffer_z + 1.0 - camera.proj[2][2]);
}

vec2 tc_depths = gl_FragCoord.xy / tc_window;
float ndc_linear_depth = -ec_depth(tc_depths) / z_far;

Example 2 - shaderX7 SSAO Crytek shader

float ComputeSSAO(sampler2D sRotSampler4x4, sampler2D sSceneDepthSampler, vec2 screenTC, vec2 screenSize, float farClipDist) 

{
   vec2 rotationTC = screenTC * screenSize / 4;
   vec3 vRotation = 2 * tex2D(sRotSampler4x4,rotationTC).rgb-1;

//...


   float fSceneDepthP = texture(sSceneDepthSampler, screenTC).r * farClipDist;

}

My guess as to how it might be achieved

const vec2 window = vec2(1920, 1080);
vec2 screenTC = gl_FragCoord.xy / window;
0

There are 0 best solutions below