My 2016 Christmas Card: Reimagining a CGI image by photographing 3D printed models

Every year since 1995 I’ve created my own computer rendered Christmas cards using the Persistence of Vision Ray Tracer also known as POV-Ray. Each year it’s been a challenge to come up with something new and different. Last year finding myself totally clueless as to what to do, I decided to recycle and update the previous year’s card. Last year’s card was a revised version of my 1997 Mary and Child card which was probably my favorite and the favorite of many friends and family. Note you can click on any of the images in this blog to see larger versions.

With the exception of 2013 in which I used a background photograph to complete the image, all of my cards have been 100% CGI rendered using POV-Ray. As it turned out the use of that photograph led to a lawsuit which is a whole other story. I’m pleased to report lawsuit was successfully settled out of court and I will chronicle that particular story elsewhere at a later time.

Step into the Real World

Because the figures and objects in my Christmas cards have all been rendered objects. They’ve never before existed in the real world. I’ve always wondered what some of these figures would look like if they could step from the virtual world of CGI into the material world. A year and a half ago as a 60th birthday present to myself I purchased a Printrbot Metal Plus 3D printer. One of the first things I tried to do with it was to print one of the figures from my Christmas cards. Specifically I wanted to create the Archangel Gabriel which is loosely modeled after the logo for my church St. Gabriel the Archangel Catholic Church in Indianapolis. Unfortunately POV-Ray will not export its files in a format capable of being used by 3D printer. The project went on the back shelf for quite some time until earlier this year I dove headlong into the issue of converting POV-Ray files into something 3D printable. I was able to come up with a technique that works and I’ve already described that in these articles.

Converting POV-Ray Shapes to Triangle Mesh for 3-D Printing

3-D Printing a POV-Ray Model

When it came time to do the 2016 card, obviously I was going to have to recycle one of my old designs like I did in 2015 but I decided to do something different. If we were going to reimagine an earlier card let’s go back to the beginning with that first 1995 card shown here.

This image has two of the St. Gabriel angels, the star of Bethlehem, and the little town of Bethlehem itself in the distance. I previously chronicled how I design and rendered the St. Gabriel angels as seen here.

It All Started with the St. Gabriel Logo

And how I did the 1995 card as seen here.

My First Ray Traced Computer Graphic Christmas Card 1995

What if I took a couple of my 3D printed angels which had finally come to life and photographed them in a real world re-creation of that very first CGI card? I wasn’t sure I would be able to pull it off and I held out the possibility that I might have to scrap the idea altogether and do something traditionally CGI. But I forged ahead and attempt to re-create a physical version of that 1995 card.

Printing the Parts

I had already successfully 3D printed an angel but while gluing together the face and head of the model we got them at slightly the wrong angle. I also wasn’t satisfied with the paint that we used for the skin tone of the face and for the gold color on the trumpet. I made the decision to 3D print 2 more complete Angel models. It took just over six hours each to print the two angels. The wings, body, hair, face, and trumpet are all printed as separate pieces and then glued together.

I should note that the halo on the angel in the CGI version is really just a glowing ball of gas. I did some experimentation with how to make physical representation of that halo but it just look like a big yellow Green Bay Packers football helmet no matter what I did. I made this sort of executive decision to just ignore the halo.

Apart from the angels there are three other objects in the original image. We have the little town of Bethlehem, the star, and the text message “Emmanuel — God with Us”. I also needed to somehow come up with a physical representation from the desert floor and the sky in the background.

After printing two brand-new copies of the angels, I next tackled the town because it was relatively straightforward. It consisted of nothing but boxes and spheres arranged to look like buildings inside a walled city. There is an arched doorway to one side through which you can see a courtyard. I simply re-created these objects using Blender 3D CAD software rather than try to export from POV-Ray. The rendered version uses a dark gray texture with a yellow indent inserted into the windows of the buildings to make them look like there were lights inside. I didn’t have any yellow plastic but I did have orange so I decided to print the town in orange and then paint it dark gray hoping to leave the windows unpainted with the orange plastic shining through. If I didn’t like the looks of that or was unable to keep the gray paint out of the indents for the windows, I had also purchased some yellow paint that I thought we could dab inside the windows with a toothpick. Below are some images of the unpainted and painted versions. I decided to stick with the orange windows.

I had to decide what to do about the text. I could just take the photograph of the angels and the city and then use photo editing to superimpose the text over it. But that seems like cheating if I was trying to re-create the image in the physical world. I tried 3D printing the text directly onto the build plate with some thin strands of plastic connecting the letters. But when you are printing very small parts such as those individual letters, it’s hard to get good adhesion to the build plate and you end up with globs of gooey plastic balling up around the nozzle. I decided I had to print a background plate with the letters on top of it.

Because I do not have a dual extrusion printer I had to set it up so that it printed the plate in a dark brown plastic, then paused while I changed the filament, and then continued to print the letters in a different color in this case white. Unfortunately the Printrbot Metal Plus does not have an LCD control panel or any kind of physical controls. Therefore the typical methods of pausing and resuming a print in the middle don’t work. I will do a completely separate blog post from a technical standpoint on how I managed to get the pause and resume to work. Here’s a photo of the text plate that we printed.

The most difficult part of this project was trying to print the star of Bethlehem. Again I could have copped out and superimposed the star using photo editing software but I really wanted to make a physical 3D printed representation of the star with the rays of light radiating from it as it did in the original image. Again the problem is it’s very difficult to get very thin pieces of plastic to adhere to the build plate. Although I’ve had my printer a year and a half I still wasn’t satisfied with my techniques for getting parts to stick. My method of choice was to put Elmer’s glue stick on top of the Kapton tape that is on the build plate. I used 70° C heat on the plate.

We must’ve tried 10 different times to print the star and it just wasn’t going to work. Finally I came up with the idea of printing the star without the rays and then printing some strips of plastic that we would use as rays that we would glue down in a radiating pattern around the original star. In order to get the strips to print, I anchored them at each end. Here’s what that looked like.

After I had this contingency available, I decided to go back to my original plan to print the rays and the star in one unit. However this time I decided to put a small disc at the end of each ray to anchor it to the build plate in the same way that that bar across the printed rays helped them print. It still took two or three attempts because we didn’t get the glue spread all the way into the corners at the exact proper place but eventually we did get the entire star with the rays printed as a single unit filling almost the entire 10 x 10″ build plate. Shown in this image on the right we had to put it on a diagonal because that longest ray is more than the 10 inch width of the plate. We later cut the discs off the tips of the rays. Here’s the results.

Building a Background

Finally I had to figure out what to do for the sky background and the desert floor. The original images depicted the sky using a gradient color of dark blue to black with a sprinkling of small stars randomly scattered throughout. I considered the possibility of printing out a star pattern and taping it to a piece of cardboard for a backdrop. However my dad found an old piece of dark blue poster board that looked pretty good so I decided to use it and forgo any other stars other than the Bethlehem star. We used glue stick to stick the star to the poster board. We had to reposition it several times and sometimes the rays tended to droop a little but I didn’t care. It looked pretty good. We taped the poster board to the lid of a cardboard box and fastened it to the table using a C clamp.

Speaking of the table, I was going to set it up on my dining room table and use the oak wood grain as a dark brown surface to represent the ground. I also tried some brown placemats that normally sit on my dining room table but none of these surfaces appealed to me in test photographs. Because I wanted to be able to visualize the camera angles and adjust the lighting, I decided to set up the scene on a hospital bed table that I have. I used to use it in my bedroom when I needed my laptop in front of me on my bed. These days my laptop is connected into my bedroom TV and I’ve not used the tray table in a long time. It was a good choice because it was big enough, it had a brown surface, and the height was adjustable which let me eyeball the camera angles. We could also roll it around the dining room so that the ceiling lights and other room lights as well as light coming in the windows would hit the scene at various angles.

In the end, the fake wood texture on the table didn’t look right for the floor either. I needed some brown cloth and it turns out I have an ordinary brown cotton T-shirt that was just right. We slipped it over the end of the table and set all of the pieces on top of it. Here is a photo that shows my set up with my digital camera sitting on a tiny tabletop tripod.

Note that in the original image the angels are hovering over the city. I needed to make some little 3D printed stands to hold them up in the air. I would later Photoshop them to remove them from the scene. Also the T-shirt and poster board were not quite wide enough in certain areas to fill the scene so I used a little retouching to paint out some background. I tried to keep the digital manipulations to a minimum but there’s no way I could get around this without building a really complicated suspension system to hold the angels up in the air. It just wasn’t worth it.

Lighting Issues

I tried a variety of lighting scenarios. I like the way the figures look under flash photography. The highlights look really good and it makes the figures stand out against the background. The problem is that the figures then cast a shadow on the dark blue poster board which of course is unrealistic. This image is a flash photograph that shows the shadow problem and points out other areas digitally retouched.

Below is another image that attempts to eliminate the shadow problems by using an overhead light from the dining room chandelier. I also increased the distance from the angels to the poster board. However that created a scale issue for the size of the Bethlehem star. Also because the poster board has a slick surface I get a little bit of specular highlight from any kind of lighting depending on the angle.

I tried a variety of other room lighting including from my kitchen bar and natural light coming through the dining room windows. I tried using Photoshop to get rid of the shadows on the poster board. I tried evening out the background to get rid of the specular highlight by picking a color and doing a flood fill. None of the retouching looked right.

In the end I just decided that what I was creating was not really a photorealistic image depicting angels over the city of Bethlehem. What I was depicting was a photograph of a diorama of little plastic statues sitting in front of a cardboard background. I moved the angels very close to the poster board which minimized the shadows but does not eliminate them. I did minimal retouching to extend the floor as needed. I retouched to eliminate the angels supports. The final image is a flash photo. I adjusted the contrast to brighten the objects and darken the background.

The Final Image

Here is the final image as I sent it VistaPrint.com to be printed. The printed cards arrived the last week of November and I began working on the interior message which I would customize using my laser printer. Unfortunately life got in the way. On December 3 I had to be rushed to the hospital in respiratory distress. As of this writing on Christmas day I’m still the hospital and will not return home until sometime the middle of next week. At that point I plan to pick up the task of customizing the interior of the Christmas cards and mailing them to friends and family even though they won’t arrive until early January.

Here’s a comparison of that image side-by-side with the original 1995 rendering. Note that the aspect ratio is different because of the way they were ultimately printed. The original 1995 image was printed on one fourth of 8.5 x 11″ sheet of paper. The new image was created according to Vista Print landscape format folding holiday card specifications that comes out about 5 x 7″.

Overall it was a fun experiment in trying to drag the virtual world into the material world. I doubt that I will do it again for the Christmas card but I would like to see 3D printed versions of some of my other figures especially the 1997 Mary and Child. Who knows… Maybe someday I will 3D print an entire nativity scene.

3-D Printing a POV-Ray Model

gabriel

The above image is a rendering of St. Gabriel the Archangel that I created sometime in 1995 using the Persistence of Vision Ray Tracer or POV-Ray. It is loosely based on the logo for St. Gabriel Church in Indianapolis where I attend. Click here to see a YouTube video that explains how I designed it. The angel has appeared in many Christmas cards that I’ve designed including the first card I designed in 1995 which you can read about here. The style of the angel became the basis for a number of other figures in other Christmas cards that I’ve created over the years.

I’ve always wondered what this angel would look like in real life. With its shiny somewhat iridescent surface I’ve always envisioned it as if it was made out of glass or fired ceramic. Not having any skill in that field my desire to see it realized it had to be put on hold for decades. However a little over a year ago I purchased a 3-D printer and I finally found a way to create a printed version of the angel. The halo is rendered as a sort of gaseous blob floating around the head so there’s no way I can re-create that but the rest of the figure can be 3-D printing.

The biggest technical problem is that POV-Ray does not export its designs in a format that can be used by 3-D printers. I eventually found a way to get POV-Ray to scan the shapes and create a set of points in 3-D space referred to as a “point cloud”. I then use that exported data in the program called Mesh Lab that will turn this set of points into a mesh of triangles that can be imported into other CAD design software and eventually be 3-D printed.

Here are some photos of a small version that printed in a single color plastic. The trumpet was 3-D printed separately but the rest of the figure was printed in one piece. Is about 2 inches tall.

small_angel

Next I printed a somewhat larger version about 3 1/2 or 4 inches tall in different kinds of plastic. The main body and arms are printed using sky-blue PLA plastic. The wings are printed in a transparent plastic called “t-glaze”. The end result is sort of a frosty translucent look. The hair was printed in dark brown PLA. It was difficult to find flesh colored plastic from the face so I printed it using the light blue and then we painted it with acrylic paint. The trumpet was printed in orange PLA and then coated with gold glitter paint. We use glue to put the pieces together. The angle of the hair is off by a little bit and does not line up with face perfectly. I may end up creating another version that we will assemble more carefully.

angel1
angel2

When I initially printed the wings I printed them both the same time but as the printhead went back and forth between the two objects it left an artifact in the middle of the wings as seen on the left. I then reprinted it printing them one time and got a clean set.

bad_wings good_wings

Before printing the body I printed a small test piece to see what tolerance I needed for the holes where the wings would be inserted as seen in the image on the left. On the right is shows the hair and the face before I painted it. Below that shows the body with the cutouts for the rings and the head.

test_fit hair_face

big_body

When completed the entire model was sprayed with a clear coat which can be seen in this flash photo.

angel3

Here as a YouTube video describing the process that I used to convert the POV-Ray shapes into something that could be 3-D printed.

Here is a technical article giving more details about the software that I used.

Converting POV-Ray Shapes to Triangle Mesh for 3-D Printing

The Persistence of Vision Ray Tracer or POV-Ray is an open source free ray tracing rendering engine that uses a special text based scene description language for modeling and rendering objects. Unlike many CAD programs that use triangle meshes to define it shapes, POV-Ray uses mathematical formulas to define its primitive shapes. In addition to traditional primitive objects such as sphere, box, and torus it includes blobs, fractals and polynomial based objects. It does also support creating objects out of triangle meshes but there’s no way to convert other POV-Ray objects into triangle meshes. If you want to 3-D print an object you’ve designed in POV-Ray or transfer it to some other CAD program that only supports meshes there’s no surefire way to do that.

POV-Ray does give you the ability within its scene description language to fire a ray at any object and determine its intersection point and surface normal at that point. We can use this feature to fire rays at an object in a grid and create a set of points called a “point cloud”. These points can be output to a text file and then imported into other software that will create a triangle mesh based on this collection of points. This method is not useful for exporting an entire scene with many objects and lots of details. But if you have one of those organic blob, fractal, or polynomial primitive shapes that you want to convert to a mesh it does give you a reasonably accurate representation of the original shape.

We have created a set of macros called “pov2mesh” that automates this process for you. In this tutorial we will describe how to use this software along with other free programs to scan a POV-Ray object, create a set of points, and convert it to STL files suitable for import into other modeling software and eventual 3-D printing.

The part of the process is the POV-Ray vector function “trace” which is used as follows:

   #declare Norm=<0,0,0>;  
   #declare Hit=trace(Object,Location,Direction,Norm);
   #if(vlength(Norm))
      #debug concat(vstr(3, Hit, " ",0,6), "\n")
   #end

The function returns a three element vector containing the XYZ coordinates of where the ray hits. You pass it the object you want to trace, the initial location, the direction of the ray, and a vector variable that it will use to return the surface normal. You have to pre-initialize a vector for the surface normal. The function modifies that parameter to return the value. If the length of that normal vector is zero then the ray did not hit. If the length is nonzero we then output the values to a text file using the #debug statement. Each point is output to a single line separated by spaces.

The macros we are supplying use this code to fire rays at your object in a grid pattern of parallel rays. We also have a cylindrical pattern which we will describe later. The grid macro is as follows:

Grid_Trace(Object,StartR,EndR,DeltaR,DirR,
           StartC,EndC,DeltaC,DirC,CamL,CamD,DotR) 

The first parameter is the object you want to scan. The scan is done in rows and columns. You specify the start coordinate of the row, the end coordinate, the increment or delta value that is the distance between the rows, and the direction of the row. This is followed by the start, end, delta, and direction of the columns. If you want to visualize where the hit occurs the final parameter is the radius of a tiny sphere which will be rendered at the intersection point. If you pass zero then the spheres are not created. Here is an example of how you would invoke this macro:

Grid_Trace(My_Object,-3,3,0.25,y, -4,4,0.25,x, -10*z,z, 0.1) 

This uses rows in the Y direction from -3 to +3 in 0.25 increments. It goes from -4 to +4 and 0.25 increments in the x direction. The ray starts at -10*z and is emitted in the +z direction. The radius of the dots is 0.1.

The trace function only gives you the first hit where the ray intersects the object. Therefore it is generally necessary to fire the rays from multiple directions. We also provide a cylindrical pattern that you would invoke as follows:

Cyln_Trace(Object,StartR,EndR,DeltaR,DirR,
           StartH,EndH,DeltaH,DirH,CamL,CamD,DotR) 

The second through fifth parameters are the starting angle of rotation, ending angle, the increment in degrees, and the direction of rotation. The next four parameters the start, end, increment, and direction of the height of the cylindrical scan. The other parameters are as with the grid trace version of the macro. Here is a typical way to invoke it.

Cyln_Trace (My_Object,0,360,2,y, -4,4,0.25,y, 10*x,-x, 0.1) 

This does a cylindrical scan going from 0 to 360 degrees rotating about the y-axis in 2 degree increments. It goes from -4 to +4 along the y-axis in 0.25 increments. The ray starts out at location 10*x and points inwards in the -x direction. That location is what’s rotated. If you wanted to scan from the inside out those parameters would be <0,0,0>,x which would put the camera on the origin and point outward in the +x direction.

We also give you a combination macro which will fire rays from the top, bottom, left, right, front, and back as well as cylindrical scans outside in and inside out. It is defined as follows:

All_Trace (Object,GridMin,GridMax,Deltas,DeltaAng,Dot) 

The parameters GridMin and GridMax are vectors defining the bounds of the area to be scanned. Deltas is the increment for grid scan and DeltaAng is the increment in degrees for the cylindrical scans. You would invoke it as follows:

All_Trace (Object,<-3,-4,-3>,<3,4,3>, 0.25,2, 0.1) 

You can download the sample code from GitHub at the following link. https://github.com/cyborg5/pov2mesh It contains three files. The first file “test_platform.pov” is a standard camera and lighting system that I use when testing objects. The file “pov2mesh.pov” contains the macros. Finally there is a sample scene “blob.pov” using blob shapes that we will use to illustrate the process of converting the data into a mesh. Here is that scene:

#declare test_cam_loc=<20,20,-50>;
#include "test_platform.pov"
#include "pov2mesh.pov"
#declare Strength = 1.0;
#declare Radius1  = 1.0;

#declare My_Object=
   blob{
     threshold 0.6
     sphere{< 0.75,  0,   0>, Radius1, Strength scale <1,1,0.5>}
     sphere{<-0.375, 0.65,0>, Radius1, Strength}
     sphere{<-0.375,-0.65,0>, Radius1, Strength}
     scale 5
     pigment{rgb<1,0,0>}
   }

object {My_Object}
All_Trace(My_Object,<-6,-6,-6>,<6,6,6>,0.2,2,0.05)
background {rgb 1}

You should render this scene and redirect the debug output to a text file using the following command line switch “+GDblob.asc”. The “.asc” extension is simply an ASCII text file which we will import to a free program called Mesh Lab. Here is where you put the switch to redirect the output.

pov_gd_switch

Here is the image created which shows you the dots on your object. The box around the object illustrates the minimum and maximum areas for the grid scan. We don’t really need the image that was rendered. We are only interested in the text file containing the points.

blob

This is an example of a few lines of the file we created.

-4.200000 -3.600000 -0.327045
-4.200000 -3.400000 -0.454927
-4.200000 -3.200000 -0.476401
-4.200000 -3.000000 -0.408605
-4.200000 -2.800000 -0.164190

We will now import this file into Mesh Lab. It is a free program available on multiple platforms which you can download here. http://meshlab.sourceforge.net/ You can click on the images
throughout this blog to see larger versions. Open Mesh Lab and click on the File -> Import Mesh menu. A small dialog box will open and you should use the default settings. You will then see the point cloud you have imported.

meshlab_points

Because our scanning method could have produced identical points or points that were extremely close to one another we need to filter them out using a “Clustering Decimation” filter. You should click on the menu Filter-> Remeshing, Simplification and Reconstruction-> Clustering Decimation item. A dialog box will pop up and you should enter a number in the first field “Cell Size”. I recommend entering a world unit of 0.1 which means that any points which are closer together than 0.1 units will be combined into an average location of a single point. This value should be equal to or perhaps less than the increments you used when creating the scan of points in POV Ray. You also have an alternative percentage value that you can set if you would rather do it that way. You then click on the “apply” and “close” buttons.

meshlab_cluster_menu meshlab_cluster_dialog

Next we need to compute the normal for each of the vertices. Although the POV Ray “trace” function gave us the normal, we have not yet figured out how to import that information into Mesh Lab. Click on the menu Filter-> Normals, Curvatures and Orientation-> Compute normals for point sets. You can use the default settings in this dialog box. Click on the “apply and “close” buttons.

meshlab_normal_menu meshlab_normal_dialog

We are now ready to actually construct the faces of the mesh using the points. On the menu select Filter->Remeshing, Simplification and Reconstruction-> Surface Reconstruction Poisson. Note that there are two other methods of surface reconstruction available. The others are “Ball Pivoting” and “VCG”. To be honest I don’t understand what any of these three options mean. The Poisson method was recommended by a website I found and it works for me so I use it. You can probably use the default settings in the dialog box that pops up. Again I’m not really sure what these values do. At times I’ve tried experimenting by increasing the first two values from the 6 to 8 and the samples from 1 to 2 and at times it gave me slightly better results. Or you can just click on “apply” and “close”.

meshlab_poisson_menu meshlab_poisson_dialog

You should now see your object shaded gray like the image below.

meshlab_completed

However if it comes out very dark or black like the image below, it means that the service normals of the faces somehow got inverted and we need to force them to flip over.

meshlab_needs_flip

To invert the face normals use the menu Filters-> Normals, Curvatures and Orientation-> Invert Faces Orientation. Use the default values on the dialog box and make sure that “Force Flip” is checked. Click on “apply” and “close”.

meshlab_flip_menu meshlab_flip_dialogue

Finally we already to export our newly created mesh as an STL file. On the menu select File-> Export Mesh. Give it a filename and under the Files of type: choose STL File Format.

meshlab_export_menu meshlab_export_dialogue

Many CAD programs and 3-D printing slicing software can import and manipulate and print STL files. We like to use Blender 3D for editing files and designing models. You can obtain it at https://www.blender.org/ We’re not going to go into any detail on how to use Blender because there are plenty of online tutorials available especially on YouTube. Also you may be using other software. In Blender balance to you can click on the menu File-> Import-> STL format. You’ll probably notice that your object is not in the orientation that you expected.

blender_imported

That is because the POV Ray coordinate system has the y-axis pointing upwards and the z-axis pointed into the screen. Most CAD programs have the y-axis pointing away from you and the z-axis pointing upwards. So you may have to rotate and/or mirror flip to get your object oriented properly.

blender_oriented

Here is what the object looks like in edit mode so that you can see the individual triangles. You may want to use a decimation modifier to reduce the number of triangles in relatively smooth areas while retaining detail in areas with tight radius.

blender_mish

Unless you use extremely small increments, you may lose detail in converting your object. Sharp edges are never going to be completely sharp using any scanning method. You may have to do some retouching in another program. This method is really only intended for those bizarre shapes that POV Ray can render that are not available in other CAD programs.

Here is a link to another article describing how I used this software to 3-D print a POV-Ray object that I created many years ago. It includes a YouTube video that shows an animated depiction of how the scanning process works.

angel1

Rendering and Animating the 2016 Rio Olympic Cauldron using POV-Ray

After watching the opening ceremonies of the 2016 Rio Summer Olympics, I became fascinated by the kinetics sculpture behind the Olympic flame cauldron. I thought about trying to make a 3-D printed version of it. However the shapes do not lend themselves to being 3-D printed on a flat bed. There would’ve been as many as 120 individual pieces to be printed and assembled. Instead I decided to just create a CGI rendering and animation. Click here to see the original cauldron from this video from NBC Sports that is used as reference material. My animated version of the object is illustrated explained is that YouTube video embedded below.