## Introduction: Computational 3D Lenticular Printing

Two exhibits opened my eyes to the joy and beauty of 3D imaging: Pictures from the Moon at the New Museum and 3D Lenticular Posters for the Hobbit at the Museum of the Moving Image. After seeing these, I became obsessed with holography, autostereoscopic imagery, and volumetric displays. With all of these imaging techniques, the results must be seen by the naked eye and images of it on computer just wont do. If you're reading this Instructable - I'll make the assumption that you have had the opportunity to see a 3D lenticular in person and it blew you away. I'll also assume that you know what a lenticular is, and you're looking to make a 3D lenticular print for yourself. There are many tutorials on the web for this, but this Instructable will focus on how to create 3D Lenticular Prints through computational means rather than photography and photoshop. This means we'll go over how to generate a series of images in code, how to interlace the images in code, and how to work to get the best results possible with your lens and printer.

## Step 1: Calibrating Your Lens

The first step is to buy a lenticular lens. I really like the ones MicroLens sells and their staff is super friendly. For my prints I purchased the 3D 20 LPI (lens per inch) at 22"x28". There are distinct trade-offs you have to make when selecting the LPI - like viewing distance, viewing angle, and image resolution. For my purposes, I thought 20 LPI would work for me since I expected my audience to stand 1-5 yards away from the work. The size of the lens also effects the amount of depth you can perceive (larger equating to more depth).

Now that you've chosen your lens you'll need to do a painstakingly tedious process of calibrating it with your printer. Expect this to take many hours if not days to get right.

Every printer produces slightly different results so it's important to have a single printer on hand that you can do calibration tests with. The printer I used is a Epson Stylus Pro 9800. Download the 'lenticular-calibration-rgb.jpg.zip' and print it out on your printer. This image is at 300dpi (assuming you want this as your final resolution - if not, change it) and goes from a 1px to 7px for each interlace width. Use this under your lenticular to find which pixel resolution is right for you. You know it's right when only one color is shown at a time. When looking for this make sure you close one eye (or view it at a 90 degree angle). The final specs I found to work for me on my printer with lens were:

Printer: SuperPhoto 2880 dpi

Media Type: Premium Semimatte Photo Photo Paper (250)

Print Quality: Finest Detail

Image: 300dpi

Images interlaced: 3

Pixels per interlace: 3px

This rgb test shows the correct width for each interlace with your lens & printer setup. However, it assumes that you have 3 images to interlace, but this may not always be the case. If you have less or more images that you want to interlace - use the 'lenticular-calibration-0-5.zip' to find the perfect pixel per interlace and images to interlace. This calibration print serves an identical functional although instead of rgb colors it interlaces images of numbers. Again look to try and be able to see each number distinctly when only one of your eyes is open.

## Step 2: Generating Content

For a computational 3D lenticular print I would recommend working with a code framework that supports openGL. In particular openFrameworks, Processing, and Three.js are great frameworks to work with. They all have TileSaver libraries that will make it easy for you to increase the resolution to 300dpi at 22"x28". These tileSaver libraries can be found here: OpenFrameworks, Processing, and Three.js.

Above you'll see several images from some test 3D scenes. It's best to start working with real imagery and once you get the full process down you can invest more time in the final content (using fancy shaders, geometry and textures).

Download 'ImageGenerator.zip' to check out a quick processing script you can use to generate a 3D scene. Use the left and right arrows to rotate the camera and space bar to save the frame. When exporting your final imagery - make sure you use a tileSaver library to get the correct resolution image.

Whether you're creating a lenticular from 3 images or 10 images - it's important to discuss the camera in the scene. In order to maximize the illusion of 3D depth - you'll want your first and last image in the sequence to equate to the pupillary distance of the average person (70mm). Programming a cameras horizontal movement always is in pixels/angles so there isn't an exact science for this translation. It's also highly dependent on your camera settings and the distance the camera is from the scene/object. When generating these images, you'll have to eyeball it to see if you think you got the right range in your cameras horizontal movement. When you make your final prints - test out how the depth is affected if you move your camera a little bit more or a little bit less.

Along with moving the camera horizontally it's critical to also have the camera focus on one point in the scene. If you're using three.js - there's a simple camera.lookAt(object) method which allows for this 'focus' very easily. Wherever your camera is focused will become the middle ground in your 3D scene. Things further than this focus point will seem to fall into the lenticular and things closer will pop out of the lenticular. If you are rendering an image of a human head - you may want the focus point to be the center of the head so that the nose and forehead stick out of image and the background recedes into the distance. If you want the head to appear inside the lenticular then use the tip of the nose as the focus point.

## Step 3: Interlacing the Images

The final step to get your programatic images to work behind the lens is to interlace them. Interlacing them essentially means we'll take vertical strips from several images and combine them in order to create a single image. This will allow the lens to bend the light so each eye will get a different image (offset via our camera in the 3d scene) - thus creating the illusion of depth.

We already did some interlacing tests in Step 1 - so it should be fairly easy to composite the final image. Based on your initial tests and how many images you decided work well with your lens - you'll want to use the attached Processing sketch to combine your images into the final output for printing.

Please note, you'll have to change the size(var1, var2) variables to match the size your print. You'll also need to put your generated images into the 'data/images' folder for them to be read by the program. Also adjust the numImages and pixelsPerLace variables based on the results you received from step one. If you read the 'interlace()' function you'll notice it does a fairly simple procedure to composite the images. If you're more comfortable coding in another language feel free to port this function.

After you run the program, open your final output in photoshop and go to Image > Image Size in the top menu. In here, uncheck resample and make the resolution to 300dpi (Processing outputs it at 72dpi naturally). Unchecking this will allow for the pixels to remain unchanged and keep everything crisp for the printer. From here - I usually print straight from Photoshop, but you are welcome to use Preview or any other program of your liking that has the printing function.

Voila! You have a 3D Lenticular print generated from computer imagery. Based on the steps we covered, you likely won't get it perfect the first time, but you'll want to make some tweaks to your scene, your camera, focus point, and potentially the number of images your interlacing and the pixels that each lace takes up.

Unlike photography - this method allows for quick iteration and infinite tweaking to get your content to look as good as possible. It also allows you to test what your scene would look like with 3 images or 10 images interlaced and better understand the art of 3D imaging.

I hope you found this Intractable interesting and fun!