I know that I can perform a transformation(rotation,scale) in the vertex shader. However I wonder if I can do the similar thing in the fragment
shader.
shadertoy.com - transformation_in_fragment_shade
I tried to apply transformation in fragment shader by multiply the uv
but being confused by the result.
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
uv = fract(uv * 2.);
vec4 img = texture(iChannel0, uv);
// Output to screen
fragColor = img;
}
I expected the image will be scaled by 2x instead of zoom out, and I'm also confused by the meaning of fract
here, why apply this function can split image into 4 chunks.
So the question is, can I apply rotation or scaling in the fragment shader here? Should I use different approach to do the rotation, scaling here?