Replies: 1 comment
-
Thanks for the feedback. It was the vertexAttribDivisor that did it.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
continued from https://webgl2fundamentals.org/webgl/lessons/webgl-instanced-drawing.html#comment-6302445421
I'm not seeing a repo. https://jsfiddle.net/9chaxo40/ The background is drawing.
I suspect though the issue is on your machine the attribute location used in drawing the background quad matches one of the ones for the matrixes for the particles. It seems you ignored everything I wrote in my previous reply about using a vertex array and/or setting the divisor to 0 😢
I do see a ton of other issues though
are you really trying to target IE in 2023?
Using overflow: hidden here is just hiding the real bug. The real bug is your canvas is display
inline
which means it's got padding. The correct CSS istype="text/javascript" hasn't been needed in ~15+ years
You shoudn't use
window.innerWidth
andwindow.innerHeight
. You should rather just ask the browser what size the canvas is. See https://webgl2fundamentals.org/webgl/lessons/webgl-anti-patterns.htmlwidth and height on the canvas are integers, not CSS units
Note: devicePixelRatio is NOT an integer. See https://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html
Similarly, this code is arguably wrong
canvas.width
andcanvas.height
are already integersAs I mentioned before, you don't need to disable vertex arrays
This is also not "unbinding". The buffer is still bound, it's just you've turned off the attribute's use of the bound buffer. In either case though there's no reason to unbind it
As I mentioned in the previous reply. The most likely issue is that you're not setting the divisor back to 0.
This code, at the end of the particle drawing
should be this
But really, you should be using vertex arrays (which I also mentioned), then you wouldn't need this code
Here's a version setting the divisor to 0: https://jsfiddle.net/greggman/4oy539j0/
Here's a version using vertex arrays: https://jsfiddle.net/greggman/Lt7xyohm/
You don't set the viewport based on devicePixelRatio.
Not a bug but a much easier way to implement
colorFromHex
isNow you can also pass it any CSS color
etc...
Beta Was this translation helpful? Give feedback.
All reactions