2

im trying to make something on shader toy: https://www.shadertoy.com/view/wsffDN
(original ref: https://www.shadertoy.com/view/3dtSD7) bufferA line 18

i want to know why uv was declared as uv

vec2 uv = (fragCoord.xy - iResolution.xy*.5) / iResolution.y;

, but this line

sceneColor = vec3((uv[0] + stagger) / initpack + 0.05*0., -0, 0.05);

uv[0] is used as a float

how does this work, and what uv's value become?

1 Answer 1

3

It is perfectly legal to access the components of any vec type (or mat type for that matter) with array syntax. You can even use a non-constant array index (well, depending on the GLSL version, but 1.30+ versions allow it). uv[0] does exactly what it looks like: access the first element of the vector.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.