Sign in to follow this  

drawing a pixel accurate sphere

This topic is 1905 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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? Edited by lomateron

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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) [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[quote name='lomateron' timestamp='1348489701' post='4983195']
The only bad thing is when the camera gets inside the edges of the tetrahedron.
[/quote]
You could render only the backfaces of the tetrahedron to solve that problem. Edited by CryZe

Share this post


Link to post
Share on other sites
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 Edited by lomateron

Share this post


Link to post
Share on other sites

This topic is 1905 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this