drawing a pixel accurate sphere

Started by
2 comments, last by lomateron 11 years, 6 months ago
So to draw a pixel accurate circle I need only to have 3 vertices representing an Equilateral triangle and draw a circle inside it.
Now to draw a pixel accurate sphere I need to have tetrahedron and draw an sphere inside it.
I think its much better than having lost of vertices representing the sphere and doesn't matter how close you are you will always see perfect pixel sphere.
The only bad thing is when the camera gets inside the edges of the tetrahedron.
Has anyone done this?
Advertisement
Are you referring to using a pixel shader to produce the fill of the circle/sphere appropriately, and use an alpha blend/reject to exclude the excessly rasterized pixels?

If so, you can rasterize a sphere in the same way than a circle, if you just billboard the single triangle to always face the viewer. This guarantees that the triangle always encloses all the pixels required to draw the sphere. Also, since the vertices are billboarded, they'll never clip to the camera near plane.
Raytrace the sphere inside the pixel shader and use the resulting depth as SV_Depth (Conservative Depth if you were using DX11). Hustle Kings basically did the same thing. You get a completely perfect sphere (the normals can be calculated from the intersection position) and only need 3 vertices (or any other amount, depending on your implementation) smile.png


The only bad thing is when the camera gets inside the edges of the tetrahedron.

You could render only the backfaces of the tetrahedron to solve that problem.
I have a problem, i am drawing many spheres(using billboard triangle), their depth is aleatory. So if i draw a sphere in front and then draw another deeper, in a way that i can see the two intersected, (if the background is black)there will be a black pointy patch in the deeper sphere caused by the pointy triangle that is nearer, I cant think of a solution to this, the depht stencil is limited to the vertex depht not the pixel in the pixel shader.
Using directx 10

This topic is closed to new replies.

Advertisement