GLSL compile error '/' does not operate on 'vec4' and 'vec2'

Viewed 155

Part of my fragment shader not compiling

vec2 uv=gl_FragCoord/uTDOutputInfo.res.zw;

returns the following error

'/' does not operate on 'vec4' and 'vec2'

Also tried which gives same error.

vec2 uv=gl_FragCoord/iResolution.xy;
1 Answers

The type of gl_FragCoord is vec4. It is not possible to divide a vector with 4 components by a vector with 2 components.

Use Swizzling to get the x and y component of gl_FragCoord:

vec2 uv=gl_FragCoord.xy/iResolution.xy;
Related