Jump to content
  • Advertisement
Sign in to follow this  
B_old

Rasterize sphere or disk in software

This topic is 2572 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

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!