i'm currently following a tutorial on youtube to get started with computer graphics (shaders) and it contains the following GLSL code:
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy * 2. - 1.; // Normalize & center
uv.x *= iResolution.x / iResolution.y; // Account for aspect ratio
float d = length(uv);
fragColor = vec4(d, d, d, 1.0);
}
However, in the tutorial the two first lines are simplified into:
vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
I can't understand how this simplification is made. I think I found the first part by merging both expressions in one:
vec2 uv = (fragCoord * 2.0 / iResolution.xy - 1.0) * vec2(iResolution.x / iResolution.y, 1.0);
If possible, could anyone provide me with the detailed steps of this simplification please ?
This is a picture of the expected result:
Thank you