Given a cube defined as:

struct Cube
    float min[3];
    float size;

What would be the fastest rasterization method? On the internet I only found methods that used polygons, but I think for only drawing a cube thats extremely ineffective. I don't need any depth information, I want the result to be a shadeless silhouette.

  • 1
    $\begingroup$ Is this rasterization happening on CPU or GPU? Also I'm curious if there's a reason you need it to be faster than polygons as it might help shape an answer. Thanks! $\endgroup$
    – Alan Wolfe
    Nov 13, 2016 at 15:56
  • $\begingroup$ GPU, OpenCL. Also why shouldn't it be faster than polygons? Why should I be looking for an algorithm, that's slower than polygons? :) $\endgroup$
    – l'arbre
    Nov 13, 2016 at 17:13
  • 2
    $\begingroup$ Faster vs just using polygons hehe. As in... Do you have an actual usage case where you need an algorithm faster than triangles? If so, what are the details of that usage case. If it's just curiosity though, that's fine too. $\endgroup$
    – Alan Wolfe
    Nov 13, 2016 at 17:22
  • $\begingroup$ Im trying to rewrite my voxel octree raycaster to a work without raycasting..if you know, what i mean. I dont want to use polygons since it seems stupid, rendering 12 individual triangles for the sake of rendering a cube, that by itself is only defined by 4 numbers and has itself some limitation of course, like rotation being impossible to be applied directly to the cube, which on the other hand is something i dont need for my renderer. $\endgroup$
    – l'arbre
    Nov 13, 2016 at 17:44
  • $\begingroup$ it feels like maybe you could translate the 3d points and project them into 2d (think: x/z, y/z types of transforms), and then you could use some "convex hull" finding algorithm on the points to come up with a 2d poly, instead of starting with triangles. The fact that it's symmetric (since it's a cube) likely means you can do less work than transforming all of it's 8 points, or even rasterizing the whole thing. You can likely rasterize half or a quarter, and mirror it or something. $\endgroup$
    – Alan Wolfe
    Nov 16, 2016 at 1:07

1 Answer 1


Since the cube is a convex object, you could first find the silhouette edges of the cube, by using dot product between cube face normals & view vectors. Then you can sort the edges by the smallest screen y-coordinate for each edge and rasterize the cube a scanline at the time by filling the span between two active edges for each scanline. For each scanline you progress the two edges by adding the edge slopes (x1-x0)/(y1-y0) to the current x-coordinate of the edges.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.