What does iResolution mean in a shader?

I am new to GLSL. I believe that in every demo there is a variable iResolution https://www.shadertoy.com/new . What does it mean?

If I want to pass this variable to a shader, what do I need to do?

+7
source share
1 answer

You can see the definition if you expand the Shader Inputs section above the code:

enter image description here

The description pretty much says it all. This is the size of the window / viewport in pixels. In the example gl_FragCoord, which is the position in pixels of the fragment, it is divided by this size to obtain the relative position of the fragment in the viewport.

:

GLint loc = glGetUniformLocation(program, "iResolution");
glUniform2f(loc, width, height);

width height - / . , vec3, x y.

+9

Source: https://habr.com/ru/post/1570768/


All Articles