#[WebGL] Buffer ping ponging behaving unexpectedly

92 messages · Page 1 of 1 (latest)

jolly hedge
#

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.

#

i wanna figure out why the 0.002 version is not working like the shadertoy version

quasi wraith
#

they both work on my phone

#

i suspect it's a precision thing but you are specifying highp

#

so idk

jolly hedge
#

thanks

#

weird thing is that it works on shadertoy for me

#

probably some weird flag thats being used

jolly hedge
#

bruh

#

it works when i disable hardware acceleration in chrome

stable musk
#

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

jolly hedge
#

is gl.RGBA the same as gl.RGBA8?

jolly hedge
stable musk
#

idk how webgl works but i think GL.RGBA, GL.UNSIGNED_BYTE means rgba8

stable musk
jolly hedge
#

ah ic

#

does that need to be manually enabled?

stable musk
#

i think its this

#
const ext = gl.getExtension("OES_texture_float");
jolly hedge
#

society

stable musk
#

are you using webgl2?

jolly hedge
#

yea

stable musk
#

so maybe just try changing GL.UNSIGNED_BYTE to GL.FLOAT

jolly hedge
#

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

jolly hedge
#
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

quasi wraith
#

that parameter isn't meant to affect storage at all????

#

ah, a webgl 1 deficiency

#

that's insane

jolly hedge
#

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

quasi wraith
#

that seems wild

jolly hedge
#

i think unsigned byte is incompatible with RGBA32F

#

lemme test rq

quasi wraith
#

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

jolly hedge
quasi wraith
#

the fact that webgl 1 uses these parameters for this is insanity

jolly hedge
#
GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA32F, GL.canvas.width, GL.canvas.height, 0, GL.RGBA, GL.UNSIGNED_BYTE, null);
quasi wraith
#

what the fuck

jolly hedge
#

this is wgl2

quasi wraith
#

??????

jolly hedge
#

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

quasi wraith
#

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

jolly hedge
#

lmao thats how i feel about webgl constantly

#

like, glad i solved it, this sucks tho

quasi wraith
#

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

jolly hedge
#

yeah es is fucked

#

i dont doubt that gl4 is leagues better

quasi wraith
#

had no idea they differed like this

quasi wraith
#

there is no excuse

jolly hedge
#

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

quasi wraith
#

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

jolly hedge
#

true