# Rasterize sphere or disk in software

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

## Recommended Posts

I'm currently rasterizing points into a cubemap, which is relatively straightforward because every points maps to one pixel.
Now I would like to give the points a radius (and maybe a direction). One idea is to generate points on the surface of the sphere and raster them, but I guess it is hard to avoid problems if the sphere is very large or close by.
Do you know of any good method for rasterizing a sphere?

##### Share on other sites

I'm currently rasterizing points into a cubemap, which is relatively straightforward because every points maps to one pixel.
Now I would like to give the points a radius (and maybe a direction). One idea is to generate points on the surface of the sphere and raster them, but I guess it is hard to avoid problems if the sphere is very large or close by.
Do you know of any good method for rasterizing a sphere?

bresenham has not just a line, but also a (2d) sphere/circle/disk algorithm http://en.wikipedia.org/wiki/Midpoint_circle_algorithm , you can use it to generate the left/right border and then fill inbetween.

if you want to have a vectorized version, you can still use it to make a coarse-raster.

##### Share on other sites
Thank you, I'll look into that.
Do you happen to know how to estimate how many pixels a sphere will cover when projected onto the render target? Specifically I'm interested in the case where the sphere covers more than one pixel.

##### Share on other sites
For spheres use the Midpoint Circle Algorithm and for Disks you should use the Midpoint Ellipse Algorithm.

Midpoint Circle can draw 8 Pixels along the circle line at the same time and therefore very fast. Midpoint Ellipse draws 4 Pixels at the same time. Filling out the circle/ellipse can be done via scan line, but all you need is to calculate r_min and r_max for the disc.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634113
• Total Posts
3015570
×