I just can't figure out the most basic WebGL bits

So a while ago I made a little notebook demonstrating slit-scanning with a web-cam, using the CPU and regular RAM. It works, but it puts a ton of pressure on the GC, mainly because it has lots of pointless memory copying back and forth.

So to fix that I have been trying to use the new volume texture support of WebGL (you know, gl.TEXTURE_3D) to implement slit-scanning on the GPU instead. It’s about as basic a WebGL application as it gets and yet I can’t figure out how to do a simple vertex buffer to draw the texture to the size of the canvas :frowning:

I got it to work with gl.POINTS here, using gman’s answer from StackOverflow.

I think all I need to do now is to follow the instructions in WebGL2 fundamentals to use a simple vertex shader that makes it a proper rectangle the size of the canvas, but I just can’t figure it out!

It’s not the tutorial (that site is awesome), it’s me. Every time I have tried to learn WebGL I get lost in the verbosity of its many options. Could anyone help me out? I just want to play around with some more complicated fragment shaders…

Maybe this’ll help you get started? It’s WebGL 1, though.

3 Likes

Thanks, that might be enough to make it “click” in my head. I’ll give it another shot and let you know :wink:

It’s WebGL 1, though.

I think WebGL 1 and 2 are similar enough for that not to be a real issue (:crossed_fingers:)

Don’t feel bad about it though, OpenGL (and inherently WebGL) is notorious for being one of the most confusing and badly designed APIs every created. Even the most experienced developers struggle with it when doing basic stuff.

4 Likes

Even the most experienced developers struggle with it when doing basic stuff.

Thanks, “funny” thing: I just worked my way through 100+ pages of tax forms + explanations today and the similarity in how it feels is disturbing… and I do not feel this way about any other programming environment I work with (not to this degree at least)

Anyway, I got it to work… ish… now the bug is in the fragment shader, but I think it kind of works out nicely

1 Like

It’s working now, thanks :slight_smile:

2 Likes

Nicely done!

1 Like