4 ms·
Cool article. I'm wondering, instead of using 4 vertices to represent the sphere could points have been used instead to do the same thing? Would it be simpler?
by nkassis 15y ago
Cool article. I'm wondering, instead of using 4 vertices to represent the sphere could points have been used instead to do the same thing? Would it be simpler?
- jacobolus 15y agoIt might be, though it sounds like at some point he needs to have four points for the sake of drawing each square. Either way, my guess is that that wouldn’t make much difference to performance, since the expensive part is actually computing and drawing all the little textures.
- kmm 15y agoI don't see how that would work. With the 4 vertices, he defines a square quad that gets "textured" in the fragment shader. If one were to use a point, only one pixel would be sent to the fragment shader.
- palish 15y agoIn OpenGL 3+ you can use something called a 'geometry shader'. Execution flow looks like: 1. application renders a list of points 2. those points are transformed by the Vertex Shader 3. the output of [2] is fed into the Geometry Shader. (and the output of [3] is additional geometry, created "on the fly", which is then rasterized.) As a simple example, a geometry shader could turn each point into a square. For each input point, it outputs the four corners of the square: [[ptX-1,ptY-1] [ptX+1,ptY-1] [ptX+1,ptY+1] [ptX-1,ptY+1]] But yeah that's not coming to GLES anytime soon.
- nkassis 15y agobut with gl_PointSize in the vertex shader he could make it as large as he needs (within limit of his hardware's max point size) and still be able to shade it in the fragment shader as a sphere looking thing by using gl_PointCoord, a texture of a sphere and discarding some fragments where the texture is a certain threshold. I don't think opengl es has quads so he's using two polygons per square running the vertex shaders 4 times per square. But the difference is probably real small that I might be useless optimization. Was just an idea as I was reading the first part of the post.