browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

Initials shadow block, using POV-Ray

Posted by on August 28, 2013

Gödel, Escher, Bach: cover

Many of us (geeks?) who grew up in the right era were inspired by Douglas Hofstadter’s book Gödel, Escher, Bach: An Eternal Golden Braid (“GEB”). My dad introduced me to it via his copy. (If you haven’t read it … it’s fascinating stuff.) On the cover was a photo of some cleverly-carved blocks of wood, shaped just right so that spotlights shining through them along each of the three axes cast the shadows of the initials in the book’s title: E, G, B.

Like probably many other GEB fans, I tried my hand at designing shadow blocks like these, for different sets of letters. About 20 years ago (!), while working for a software company, I used POV-Ray to mock up a shadow-block logo for the product we were working on. That was done by designing the letters manually, using virtual cylinder and sphere primitives. The result was satisfactory, but I didn’t really go beyond those three letters.

Then yesterday I ran across a neat Instructable about making this kind of shadow block out of wood. The author astutely notes that designing how the letter shapes intersect each other is “actually the most important, but also probably the most difficult [step]. All you need to do is draw your initials on each side of the cube, and imagine what shape will result when you cut them out.”

As much fun as it is to imagine 3D shapes, I got to wondering how well the “imagining” step could be automated. If you get letter shapes of the right size, and could use CSG to intersect them, you could often produce something that fulfilled the requirements, even if the resulting shapes were not the most aesthetically pleasing. (Not always… because, depending on the choice of letters, the ordering, and the characteristics of the typeface, it’s sometimes not possible to design a block that casts the right shadows.)

As I looked into doing this automated version in POV-Ray, I was pleased to find that letters made from True-Type fonts were primitives that could be manipulated by CSG commands like Intersect. That made it pretty easy to plug in the desired three letters, and attempt to construct a shadow block. Here’s the code:

// 3D monogram, by Lars Huttar
// Inspired by the cover of Godel, Escher, Bach
//   by Douglas Hofstadter

// Declare your initials here:
#declare L1 = "G";
#declare L2 = "E";
#declare L3 = "B";
// You may need to reorder the letters for best results.     
// Try thicker (blacker) fonts such as "IMPACT.TTF" or "CARBONBL.TTF",
// or "cyrvetic.ttf" as a fallback.
#declare FontFile = "IMPACT.TTF";

#version  3.6;
global_settings { 
  assumed_gamma 2.2

#include ""
#include ""
#include ""

camera {
   location  <3, 2,-3>*0.7
   direction <0, 0,  1>
   up        <0,  1,  0>
   right     <4/3, 0,  0>
   look_at   <0, -0.35, 0>

background { color rgb <0.5, 0.5, 0.5> }  

#macro Make_Letter(letter, rotation)
    #local Letter = 
        text { ttf FontFile,
            letter, 1, 0
    #local Max = max_extent(Letter);
    object {
        scale <1.0 / Max.x, 1.0 / Max.y, 1.0>
        translate -0.5 // put center at origin
        rotate rotation

// Define each of the three letters, with the lower left corner at origin.
// Scale so that the opposite corner is at <1,1,1>.

intersection {
   Make_Letter(L1, y*-90)
   Make_Letter(L2, 0)
   Make_Letter(L3, x*90) 
   texture { T_Wood19
     finish { specular 0.50 roughness 0.1 ambient 0.25 }

#declare Brightness = 0.8;
light_source {<100, 0, 0>  colour White*Brightness spotlight radius 0.2 falloff 0.5 point_at <-1,0,0>}
light_source {<100, 0, 0>  colour Orange*Brightness spotlight radius 0.3 falloff 0.6 point_at <-1,0,0>}
light_source {<0, 100, 0>  colour White*Brightness spotlight radius 0.2 falloff 0.5 point_at <0,-1,0>}
light_source {<0, 100, 0>  colour Orange*Brightness spotlight radius 0.3 falloff 0.6 point_at <0,-1,0>}
light_source {<0, 0, -100> colour White*Brightness spotlight radius 0.2 falloff 0.5 point_at <0,0,1>}
light_source {<0, 0, -100> colour Orange*Brightness spotlight radius 0.3 falloff 0.6 point_at <0,0,1>}

union {                          
   plane { <1, 0, 0>, -2 }
   plane { <0, 1, 0>, -1.75 }
   plane { <0, 0, -1>, -2 }
   pigment { color rgb <1, 1, 1> }
   finish { ambient 0.2 diffuse 0.6 }

And here’s the result, for the letters GEB, using the Impact font that comes with Windows:

It’s interesting to me how similar this automatically-constructed wood shape looks to the manually (I assume) designed upper block on the cover of GEB. Maybe there are not that many options. Here’s how it works with a less “black” font, cyrvetic.ttf that comes with POV-Ray:


Note that this POV-Ray code scales each letter to the size of a unit cube. If you use a skinny letter like I, it will get stretched wide and will look pretty strange. Also, serif typefaces don’t work very well:


I plugged in the initials of each person in our family…



etc. Lots of fun!

Comments are closed.