News for hackers. Stuff that matters.
Re:Render HTML via WebGL by aout on Thursday April 02, 2015 @09:52AM (#9310637)
Wait wait wait... Handling textures via CG Buffers is quite fast you are right and you can basically do whatever you want in terms of image manipulation using the shaders but you'll lose efficiency as soon as you introduce complex picking (text selection for example) and / or computations (aliasing etc...) between JS and your pseudo-DOM.

In the end the only difference you'll have compared to the real browser renderer is that you do less computations from CG(GL) to RAM (JS), hence the performance.

You can check this very old project of mine where we tried to link DOM and WebGL Nodes: https://github.com/aout/SAGE

edit: just saw the repo wasn't entirely up to date. Done now.

Re:Render HTML via WebGL by bsenftner on Thursday April 02, 2015 @09:56AM (#9310657)
Could you speak a bit more on the issues you encountered?
Re:Render HTML via WebGL by aout on Thursday April 02, 2015 @10:05AM (#9310722)
Well, your browser is already GPU-accelerated. What makes it slow is the process of making GPU-memory accessible to your JavaScript.

An example of that is drawing a DIV and applying a CSS 3D Transform to it. By doing so you'll modify it's display on the screen so you'll need to recompute it's actual bounding box. If you compute the BBox on the GPU and never access it anywhere else, everything is fine but as soon as you have to use it in JS you're screwed because you'll have to transfer data from your GPU to your RAM. Doing so at 60fps is very expensive, then you'll take a performance hit from JavaScript being usually slower than C/C++.

That's not the only problem you'll have, text rendering is probably the biggest one. As you might know, textures are rendered using memory friendly algorithms. To ensure maximum readability and quality you'll have to (1) use a lot of memory and / or (2) apply some advanced filtering so your texture doesn't lose quality. Those techniques are quite hard to implement if you're not a 3D programmer (just check what happens if you try to rotate text in CSS and select it) but more importantly you'll find yourself reinventing the wheel.

Re:Render HTML via WebGL by onion2k on Thursday April 02, 2015 @01:30PM (#9312078)
If you were happy to ignore hover, you'd only need to compute the bounding box when there's an event like a click.
Re:Render HTML via WebGL by aout on Friday April 03, 2015 @03:17AM (#9314717)
True, but picking is only one pass of rendering (and a pretty fast one as you can see here: https://github.com/aout/SAGE/tree/Multipass/Sage3D/Resources...).
Re:Render HTML via WebGL by PixelsCommander on Thursday April 02, 2015 @10:02AM (#9310700)
Nice, we may use it as a renderer for HTML GL. Shaders and fast rendering wirth it I believe. Try the demo in the bottom http://htmlgl.com/
Re:Render HTML via WebGL by aout on Thursday April 02, 2015 @10:09AM (#9310757)
I tried the demo of course and I thought you did a great job. I'm not saying you should abandon the project because of performance issues you'll encounter but rather focus on simplicity with clear boundaries. Again, go for it! (but don't go too far)
Re:Render HTML via WebGL by PixelsCommander on Thursday April 02, 2015 @10:14AM (#9310805)
Thank you. Agree, simplicity is what it is created for, will keep it that way.
Re:Render HTML via WebGL by aout on Thursday April 02, 2015 @10:52AM (#9311004)
Just updated the repo with multipass rendering including picking and lights. Might interest you.
Re:Render HTML via WebGL by danjayh on Thursday April 02, 2015 @10:10AM (#9310774)
I like the concept for graphics-heavy pages, but for any text-oriented page ... well, any website that didn't support highlighting (which I use to keep track of where I am on a page) and that didn't re-render when zooming (absolutely necessary for high-res displays, where a page might show up tiny and need to be re-scaled) would be a website that I didn't stay at for very long.