I've implemented a really basic buffer pingponging setup in webgl, and for some reason, it just doesnt work.
Here's a github repo https://github.com/Naitronbot/webgltest
For me, it just shows a static rainbow gradient, but based on how i have the draw loop set up, it should continuously get whiter
What's odd, is when I change 0.002 to 0.005 in src > shader.ts > line 26 it works perfectly.
#[WebGL] Buffer ping ponging behaving unexpectedly
92 messages · Page 1 of 1 (latest)
Here's a page showcasing the 0.002 version: https://htmlpreview.github.io/?https://github.com/Naitronbot/webgltest/blob/main/build/index.html
Here's a page showcasing the 0.005 version: https://htmlpreview.github.io/?https://github.com/Naitronbot/webgltest/blob/working/build/index.html
And here's the 0.002 version recreated in shadertoy: https://www.shadertoy.com/view/DlVBDm
i wanna figure out why the 0.002 version is not working like the shadertoy version
they both work on my phone
i suspect it's a precision thing but you are specifying highp
so idk
dam
thanks
weird thing is that it works on shadertoy for me
probably some weird flag thats being used
they both work on my mac
@jolly hedge maybe its because youre creating an rgba8 texture, so each channel can go from 0 to 255, and 0.002 is less than 1/255
shadertoy uses rgba32f textures for the buffers
is gl.RGBA the same as gl.RGBA8?
how does it do that, i thought you couldnt render to rgba32f
idk how webgl works but i think GL.RGBA, GL.UNSIGNED_BYTE means rgba8
it requires a (pretty widely supported) extension
i think its this
const ext = gl.getExtension("OES_texture_float");
are you using webgl2?
yea
There is no RGBA32F in WebGL. It's inferred by gl.RGBA, gl.FLOAT
https://stackoverflow.com/a/26559396/19524419
so maybe just try changing GL.UNSIGNED_BYTE to GL.FLOAT
did that
canvas is just black now
GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, GL.canvas.width, GL.canvas.height, 0, GL.RGBA, GL.FLOAT, null);
why the hell is webgl throwing errors in the honey extension log wtf???
oh i think it was just a chrome console bug
changing it to this
GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA32F, GL.canvas.width, GL.canvas.height, 0, GL.RGBA, GL.FLOAT, null);
gives me
GL.getExtension('EXT_color_buffer_float');
doing this makes the errors go away, but it still doesnt work
I GOT IT
WOOOOO
GL.getExtension( 'OES_texture_float_linear');
GL.getExtension( 'EXT_color_buffer_float');
needed both of these
thank you @stable musk
?????
that parameter isn't meant to affect storage at all????
ah, a webgl 1 deficiency
that's insane
no, its the case for webgl2 as well
GL.RGBA with GL.UNSIGNED_BYTE makes the texture store each channel as a byte
RGBA 0-255
if you want proper floating point textures, you need to do GL.RGBA32F with GL.FLOAT
the thing that was tripping me up, was that in order to render to a GL.RGBA32F you need a few extensions
even if you specify GL.RGBA32F?
that seems wild
I mean it shouldn't matter because in every other version of opengl it is unrelated
when passing null data, the last two format/type arguments are redundant
the fact that webgl 1 uses these parameters for this is insanity
GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA32F, GL.canvas.width, GL.canvas.height, 0, GL.RGBA, GL.UNSIGNED_BYTE, null);
what the fuck
this is wgl2
??????
only certain combinations of internal formats, formats, and types are valid
doesnt appear to be just a webgl thing, seems to be a thing for the whole of es 3
ah wtf you're right
well about the errors at least
they still should have no affect on storage when using sized internal formats
man no wonder people tried so hard to get rid of glTexImage2D
es 3 also has glTexStorage2D which completely does away with this weirdness
why did that not make it into webgl :(
anyway I'm glad you solved it I suppose
man I'm sure I've used the equivalent in desktop gl to upload rgba8 data to floating point textures
okay yeah it looks like this might be a difference between desktop and es
had no idea they differed like this
it has been the same api since 2.0
there is no excuse
gpu as a whole is screwed, we should just start over and make it again but good
hold gpu manufacturers to a reasonable standard
dont let them get away with corner cutting bullshit
don't think I have the imagination for that
all I want is for vendors to agree on just one api to use
apple coming up with their own instead of just adopting vulkan or smth was just hostile
true