0

I am trying to find an algorithm for 3D line segment rasterization. Bresenham's algorithm seems like it's almost what I want but it doesn't compute any Z values.

Does anyone know if there is a way to extend Bresenham's algorithm or maybe a different algorithm?

  • 1
    Bresenham's algorithm can be extended to 3D. But simple DDA (iterate the longest axis and calculate the other two) is easier to implement and probably faster on modern hardware. Or do you need integer arithmetic? – Nico Schertler Dec 07 '15 at 16:20
  • 1
    I don't get your question. Why don't you project your line onto the view plane and then rasterize the projected line? The screen is 2D after all. Maybe I'm missing something. – xxbbcc Dec 07 '15 at 16:20
  • you can handle 3D Bresenham as 2x2D Bresenham just iterate the `biggest` axis and have separate variables for the 2 other axises ... The same goes for DDA. @xxbbcc if you have Z-Buffer or per fragment lighting you need also the Z-coordinate ... – Spektre Dec 08 '15 at 07:49

0 Answers0