Drawing lines in WebGL is pretty hard. Here's my Schrödinger wavefunction visualizer (http://ridiculousfish.com/wavefiz/) where I learned too much about it.
Note these lines are in actual 3d space: you can rotate the scene using the circle control towards the bottom.
The approach I used is per Matt Deslauriers (https://mattdesl.svbtle.com/drawing-lines-is-hard) . The essential idea is to construct a zero-width line, then use a vertex shader to push each vertex along the line's normal in screen space (not model space). Now represent each vertex twice, and push each one in opposite directions, and you get a nice width.
Like in particular real time data. This idea of “uploading data” is classified as slow. I’m not interested in preloading. I want a mouse to churn 1k pixels. This “upload to gpu” seems a major bottleneck. Where’s 1000000 particles cannot be interactively controlled
I find this post intriguing not just for the actual effect, but as yet another little signal of the slow and steady mixing of serious-ish mathematics (though mostly applied maths) into engineering culture; which there was almost no trace of only a few years ago.
I'm not sure if this a typical case, but the reason I use serious-ish math is my major in physics. When I see a simulation problem calculus comes to mind first.
In my experience there was not a single time calculus was applied in everyday engineering on my projects.
I disagree- maths has always been an essential tool of all engineering disciplines. Software engineering is not an exception (algorithms, control systems, graphics, simulations).
Of course, a lot of people can and do write useful software knowing little to no maths, but then again, I suppose one can build a working bridge based on gut feeling as well.
Works really well even on my old-ish smartphone (2014). WebGL is really interesting, too bad I still have yet to find the time to get a grasp of it. But blog posts like this are very inspiring!
I don't understand why'd you do it this way. I would draw a full screen quad and evaluate if a pixel should be lit or not in screen space in a frag/pixel shader.
The cost of doing this would be enormous - program shader for each pixel would have to calculate this function for every line segment. Instead, only triangles that cover the segment are evaluated.
[+] [-] ridiculous_fish|8 years ago|reply
Note these lines are in actual 3d space: you can rotate the scene using the circle control towards the bottom.
WebGL supports lines natively, but Windows Chrome ignores the thickness (https://bugs.chromium.org/p/chromium/issues/detail?id=60124) so I had to find a different approach on Chrome.
The approach I used is per Matt Deslauriers (https://mattdesl.svbtle.com/drawing-lines-is-hard) . The essential idea is to construct a zero-width line, then use a vertex shader to push each vertex along the line's normal in screen space (not model space). Now represent each vertex twice, and push each one in opposite directions, and you get a nice width.
A fragment shader is used to soften the edges.
Here's my vertex shader, which is the meat of the drawing: https://github.com/ridiculousfish/wavefiz/blob/master/ts/pol...
[+] [-] absrnd|8 years ago|reply
Couldn't you use a geometry shader to convert points into triangles (or quads)?
[+] [-] DSMan195276|8 years ago|reply
[0] https://stackoverflow.com/questions/8641119/webgl-geometry-s...
[+] [-] Fifer82|8 years ago|reply
Webgl and “shadertoy” is why I am in computing, I am not here for Angular but this is how I make money.
My fascination is pointless processing of pixels and without it I feel bored.
I need to learn webgl but there seems no definite guide.
[+] [-] Fifer82|8 years ago|reply
[+] [-] tw1010|8 years ago|reply
[+] [-] m1el|8 years ago|reply
I'm not sure if this a typical case, but the reason I use serious-ish math is my major in physics. When I see a simulation problem calculus comes to mind first.
In my experience there was not a single time calculus was applied in everyday engineering on my projects.
[+] [-] fest|8 years ago|reply
Of course, a lot of people can and do write useful software knowing little to no maths, but then again, I suppose one can build a working bridge based on gut feeling as well.
[+] [-] flannelhead|8 years ago|reply
[+] [-] Exuma|8 years ago|reply
[+] [-] Pica_soO|8 years ago|reply
[+] [-] banachtarski|8 years ago|reply
[+] [-] m1el|8 years ago|reply
[+] [-] thethirdone|8 years ago|reply
[+] [-] reificator|8 years ago|reply
[+] [-] grzm|8 years ago|reply