WebGL 2: Attributes (Part 1)

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025

Комментарии • 18

  • @georgeytg
    @georgeytg 2 года назад +15

    I watched 3 different tutorials about uniforms and attributes before this, and I still couldn't figure out what the point was. Thankfully I managed to push myself to try another, and oh boy, was that a good idea. Immediately understood the whole thing. It's almost criminal how few views this tutorial has, the man really explains everything perfectly. Thank you.

  • @leftleg4024
    @leftleg4024 Год назад +3

    This is just amazing

  • @pauzhou8639
    @pauzhou8639 3 месяца назад +1

    just wasted a whole afternoon watching school videos on WebGL. I hope I'd found your videos earlier. Thank you!

  • @wtch28
    @wtch28 5 месяцев назад

    Great Playlist!
    I've tried to learn Graphics Programming for a while now (Books, Videos, Websites ..) but your Series and the use of JavaScript/WebGL makes it soooo much easier to focus on the actual thing instead of abstracting and worrying about type-safety! :D
    Thank you!

  • @ccjx_space
    @ccjx_space 6 месяцев назад +1

    I can't stop watching this :)

  • @dominicprior9844
    @dominicprior9844 2 года назад +1

    I love this video series! I especially like your direct approach, the one without all those confusing abstractions and dependencies!

  • @md.maskawathossainmasuk1814
    @md.maskawathossainmasuk1814 Год назад +1

    Truly appriciatuates your video

  • @monfera
    @monfera 2 года назад +2

    Great series, thanks for sharing! Minor addition: it's rare but technically possible to draw even a triangle mesh of arbitrary size without programmer created array attributes, and therefore without array buffers, using the built-in gl_VertexID and gl_InstanceID, which I think of as implicit attrib arrays (iirc they even consume from the MAX_VERTEX_ATTRIBS limit, if you happen to use them). Their full use is mostly practical with generative art, aesthetic pieces and particles. These built-in GLSL variables are useful in other settings too to help derive data that is the function of which instance and/or which vertex the shader code is currently processing. They can also be used with instancing in a way that all programmer specified attribs will have a divisor of one (or higher)

    • @osakaandrew
      @osakaandrew  2 года назад +2

      Thanks! That's really fun stuff you're talking about. Some of the things people do on Shadertoy are a bit mind-boggling. I was thinking of doing a video on fragment shaders, built-in variables, and shader functions. But it might be possible to include vertex shaders as well and go over some of this as well. Definitely an interesting suggestion!

  • @MichaelJIriarte
    @MichaelJIriarte 3 года назад +1

    What a great course! Thank you for sharing!

  • @sidekick3rida
    @sidekick3rida 4 месяца назад +1

    The book Real-time 3D Graphics with WebGL 2 mentions the use of the varying qualifier.

    • @osakaandrew
      @osakaandrew  4 месяца назад

      Interesting. It does say that (and that `attribute` is also a storage qualifier). For sure, these keywords were removed from the language for GLSL ES 3.0 and will both throw errors if you try to use them in any shader declared as `#version 300 es`. My guess is that this page was about GLSL ES 1.0 but stayed in the book even through a second edition. The rest of the book does go to great pains to show how `in` and `out` replaced these storage qualifiers. Just unfortunate editing. It is a very good book.

    • @sidekick3rida
      @sidekick3rida 4 месяца назад

      @@osakaandrew oh ok, makes sense. Thanks!

  • @malachas
    @malachas 2 года назад +2

    Hey. Amazing series! I'm really glad I found it. I want to verify 1 thing about `enableVertexAttribArray` . I have a single gl context with 2 programs (one with 2 attributes, second with 3). With `getAttribLocation` in the program with 2 attributes, I get locations 0 1, in the second 0 1 2. It seems that I can omit `enableVertexAttribArray` from the first one (pretty sure bad thing to do and dont want to do that), since the second one with 3 attributes enables these locations. Can this overlap of locations cause some issues? Should I manually bind different locations?

    • @osakaandrew
      @osakaandrew  2 года назад +1

      In your case, it sounds like there's no reason to call `enableVertexAttribArray()` more than once per attribute location, even for multiple programs.
      If you're:
      1. not using Vertex Array Objects (VAOs), and
      2. not using "generic vertex attributes" (that's when you use functions like `gl.vertexAttrib4f(0, 1,2,3,4)` to set an attribute value that remains constant throughout a draw call, a lot like a uniform) on one program and not the other, and
      3. not calling `disableVertexAttribArray()` anywhere,
      ...then calling `enableVertexAttribArray()` more than once per location value is unnecessary. Once enabled, it stayed enabled until you disable it. And there's no problem with enabling a vertex attribute array that doesn't exist in any program. You could enable every location from 0 to `gl.getParameter(gl.MAX_VERTEX_ATTRIBS)` without causing problems. There's no reason to, but you could. So in your case, it's fine to enable 0, 1 and 2, even though only one program uses 2.
      Once you start using VAOs, though, you'll have to enable vertex array attributes individually for every VAO, which I remember was a bit surprising to me.

  • @pickle1987
    @pickle1987 2 года назад +1

    Thank you very much for you videos, would appreciate if you put the source code in github