diff --git a/examples/fragment.glsl b/examples/fragment.glsl index f036433..477c4e3 100644 --- a/examples/fragment.glsl +++ b/examples/fragment.glsl @@ -68,7 +68,7 @@ float limit(float val, float min, float max) { } void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 screen_uv = gl_FragCoord.xy / iResolution; + vec2 screen_uv = gl_FragCoord.xy / iResolution.xy; // We'll make origin in the top-left. screen_uv.y = 1.0 - screen_uv.y; screen_uv.x *= iResolution.x / iResolution.y; diff --git a/examples/texture.glsl b/examples/texture.glsl index 9df71b0..52e6823 100644 --- a/examples/texture.glsl +++ b/examples/texture.glsl @@ -1,5 +1,5 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord / iResolution; + vec2 uv = fragCoord / iResolution.xy; uv = vec2(uv.x, 1.0 - uv.y); // mixes two textures //fragColor = mix(texture(iChannel0, uv), texture(iChannel1, uv), 0.2); diff --git a/examples/wavy.glsl b/examples/wavy.glsl index af67ee9..1f4d811 100644 --- a/examples/wavy.glsl +++ b/examples/wavy.glsl @@ -1,7 +1,7 @@ #define PI 3.1415926538 void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord / iResolution; + vec2 uv = fragCoord / iResolution.xy; vec2 lines_uv = uv; diff --git a/glonkers.1 b/glonkers.1 index 061f9a6..4aaf23c 100644 --- a/glonkers.1 +++ b/glonkers.1 @@ -47,9 +47,9 @@ Time since program start. .RE .PP -\fBiResolution\fR : vec2 +\fBiResolution\fR : vec3 .RS 4 -Resolution in (number of pixels) x & y. +Resolution in number of pixels. x: width, y: height, z: aspect-ratio (hard coded to 1.0). .RE .PP @@ -59,11 +59,18 @@ The currently rendered frame. .RE .PP -\fBiChannel\fR{\fB0\fR..\fB3\fR} : int +\fBiChannel\fR{\fB0\fR..\fB3\fR} : sampler .RS 4 Samplers for provided textures. .RE +.PP +\fBiChannelResolution\fR : vec3[4] +.RS 4 +Array of resolutions for iChannel:s. x: width, y: height, z: aspect-ratio (hard coded +to 1.0). +.RE + .SH SEE ALSO \fBwlr-randr\fR(1) .PP diff --git a/renderer.c b/renderer.c index e2061ee..1a31aa4 100644 --- a/renderer.c +++ b/renderer.c @@ -45,7 +45,7 @@ const char *fragment_header_src = "precision lowp sampler2D;\n" "precision lowp samplerCube;\n" "layout(location = 0) out vec4 color;\n" -"uniform vec2 iResolution;\n" +"uniform vec3 iResolution;\n" "uniform float iTime;\n" "uniform int iFrame;\n" "uniform sampler2D iChannel0;\n" @@ -266,7 +266,7 @@ void render(Renderer *state, int w, int h, double time, char *shader_path, int r glUniform3fv(uniform_iChannelResolution, state->texture_count, iChannelResolutions); int uniform_iResolution = glGetUniformLocation(state->shader, "iResolution"); - glUniform2f(uniform_iResolution, w, h); + glUniform3f(uniform_iResolution, w, h, 1.0); int uniform_iTime = glGetUniformLocation(state->shader, "iTime"); glUniform1f(uniform_iTime, (float)time);