I’m working on transforming a set of point sprites to sphere using a geometry shader (i found that it could be a good idea).
RIght now, the vertex and fragment shader are working, they make the point sprites look like sphere but in 2D (the texture of the sphere is always facing you). When i’m trying to use the geometry shader below, nothing is rendered. HELP!!! lol!
Here the code :
I haven’t checked what is the problem with the geometry shader but I would not suggest to replace your point sprite based sphere renderer with a geometry shader based one because performance will suffer badly. Here are some facts why:
You’ll have a huge amount of primitives to rasterize, compared to the point sprite version. This, and considering that you want to draw millions of these spheres, means that your card can easily get to its rasterization throughput limit.
Even if rasterization throughput is not clamping your performance, rasterizing the additional triangles will degrade performance anyway as more data has to be processed.
Geometry shaders do not perform well when emitting loads of vertices. This is because those vertices has to be stored first in a temporary buffer which limits the number of parallel cores that execute your geometry shader. This will cause severe performance drop, especially on early geometry shader capable NVIDIA cards. But any card will suffer heavily from this
You need some cycles in your geometry shaders to construct a sphere geometry, which is not really parallel. Instanced geometry shaders introduced by GL4.0 solve this problem somewhat, but the main principle applies: geometry shaders are not for geometry amplification.
My main question is why you want to go with a geometry shader based solution if you have your point sprite based solution up and running? The later one should be orders of magnitude faster.
(Btw, looking at your geometry shader it barely looks like something that creates a sphere geometry, rather it looks like a geometry shader that is meant to emit point sprites or billboards, whatever you call them, just there is some strange for cycle at the beginning which emits the received vertices. It all looks weird.)
Pulling off a textured sphere impostor requires selecting texture coordinates based on the view direction for that fragment. This is really just a direction/sphere intersection test, which is simple math.
Here two texture i found. Someone told me i could use them to transform the point sprite in real spheres using shaders. I’m able to use the texture in the shader and to see the point sprite as sphere. I’m just unable to transform the point sprite in real sphere using the sphere1.png and depth.png file. Anyone can help me with this? Thanks.