Reputation: 167
As a computer graphics task we were assigned to translate some ShaderToy filters into our teacher's personal language, but I can't find any documentation or tutorial that can help me with many of the new stuff that I keep encountering, I managed to get to a good point by myself with some research but now I'm stuck!
My questions are:
FragCoord.xy
what exact value returns? (With vec2 FragCoord = {i, j}
if I guessed correctly).
If I divided FragCoord.xy
by 720, what vec2
value would be returned?
Thanks
Upvotes: 1
Views: 581
Reputation: 211057
.xy
is called Swizzling:
You can use x, y, z, or w, referring to the first, second, third, and fourth components, respectively.
That means FragCoord.xy
takes the x
and y
component of FragCoord
and creates a vector of type vec2
. It is even possible to use components multiple times (e.g. FragCoord.xx
, FragCoord.yy
) or to change it's order (e.g. FragCoord.yx
).
GLSL binary Operators work component-wise. Therefore FragCoord.xy / 720
can be replaced by vec2(FragCoord.x / 720, FragCoord.y / 720)
.
Upvotes: 1