posts about gpu generated visuals
November 14th, 2011

Post process voxels filter

This is a pixelshader that takes depth and outputs a new depth and normals that represent the scene made up of voxels. This can be useful for giving bone-animated objects a voxel style look. (animating with voxels is bothersome). It could also be applied to complete scenes. The “popping” that is visible at the silhouette of the object is hard to hide with a rotating perspective camera. It would be absent seen trough an orthographic non-rotating camera. I still have to fix the black separation lines that are sometimes visible.

It roughly works like this:
-Every screen pixel will belong to a cube (a cube can contain multiple pixels).
-Each cube needs to be completely drawn (the tricky part- because the silhouette of the object(s) will change).
-a pixel samples a number of pixels in an area that should be about as big as the biggest cube you would expect.
-since the screen-area of a cube can be very large (say 64 * 64 = 4096 pixels) it is impossible to sample all pixels in that area to search for a cube that could be occluding the current pixel. So for a single pixel there is a high error rate (it misses cubes that would be occluding itself), but this is solved later.
-It is sampling with a grid with a spacing of 16 pixels. (in one axis 1 out of 16 pixels is sampled)
-it does a ray-cast against every samples containing cube. The front-most hit is used as the new depth.
-at this moment a lot of cubes are only half drawn, or are represented by a few floating pixels.
-then a pass is run a number of times (the number depends on the spacing of the sampling grid in the first pass) which grows the cubes.
-1 pixel could become 3*3 pixels in 1 pass, if it is part of the front-most cube along that pixels ray.
-because this step is repeated, a cube which was only represented by a few pixels can grow to a complete cube.
-after this pass, all holes are filled, and the silhouette of the object has been changed.

1 Comment »

  1. You’re my new hero! Thanks for sharing all this amazing stuff!

    Comment by Tamas — November 15, 2011 @ 9:47 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under GPL - 2009 | Powered by Wordpress using the theme aav1