Hacker News new | ask | show | jobs
by manytexel 2407 days ago
With the first two points, it's not clear to me why you want to do that. If the reason is performance, I suggest you should first learn how to program GPUs, then think about it again. It'll be more obvious what you can and can't do efficiently.

> Renders from center of screen, in clockwise spiral outward, if any pixels remain after 15ms I want to drop them (should only be peripheral, I'm OK with that in exchange for constant performance time).

I suppose you could split up your CPU-side render calls into segments and drop the ones that occur beyond what you measure as 15ms.

However, this means that you need to wait for the GPU to finish work after each segment, which has some overhead. It's probably better to figure out how much you can fit into 15ms ahead of time and then submit all that in one go.

> Can add secondary orthogonal clipping triangles to each triangle, such that the clipping edge could be defined by a curve. Imagine a hexagon (made of 6 triangles), we could easily extend a low poly hexagon into a high resolution circle just by interpolating a curve here.

This kind of variable-length output problem is something that GPUs aren't very good at. You could do it with Geometry Shaders, but those tend to perform poorly and aren't available in WebGL (or Apple Metal).

It might be better to just submit a sufficient amount of vertices, which you can analytically displace, so for example you don't have to supply the coordinates of every vertex on the circle, but rather calculate them from the index on-the-fly. You can also use Tesselation Shaders to amplify geometry in an efficient and view-adaptive way, but again that's not in WebGL.

Having said that, all of this "smart rendering" might not be necessary at all. After all, your goal is to train a neural network. You can probably just use an off-the-shelf renderer with off-the-shelf hardware and it'll be fast enough to not be the bottleneck - especially nine years down the line.