Nomad Sculpt side-by-side stereo rendering

One of the amazing things we love about Nomad Sculpt is the ability to make some truly inspired 3D renders. But compared to PC software like Blender it lacks a stereoscopic camera for rendering side-by-side, or even anaglyph, 3D images. However, not all is lost as, with a little bit of effort, and some simple Python 3 code, we can do something similar. So I thought I would write a post to explain how I do side-by-side stereoscopic rendering with Nomad Sculpt, to accompany the Parth3D Github repo for it. And to give you a sense of the excitement awaiting you, here’s the stereoscopic image we’ll be creating.

The Nomad Sculpt 3D model as a side-by-side stereoscopic render
The Nomad Sculpt 3D model as a side-by-side stereoscopic render.

It all begins, as you’ve most likely guessed, with a 3D model sculpted in Nomad, on an iPad, iPhone or Android device. I just took a cube and sculpted it to look spiky, then painted it in a metallic golden colour. A point light helped give a nice effect, together with some post-processing options that I like. You could use any 3D sculpt of course, but you can download mine if you want to – it’s in the Parth3D Github repository, along with the Python code, for a bit of testing. The important thing to note is that it’s positioned at the origin and the focus point is at zero depth (the reason will hopefully become clear soon).

The 3D model, front and right views, in Nomad Sculpt (red line shows zero depth)
The 3D model, front and right views, in Nomad Sculpt (red line shows zero depth).

With our model in place we next need to create a middle camera (with the tablet in portrait orientation so we can see what the render will look like) and, to keep things simple, we want it to be looking straight in from the front. As the screengrabs below show, we can do that by setting the locations and rotations to zero using the gizmo tool. We’ll set the camera depth to 10 – it can be whatever you need for your scene size but for now it’ll help you follow my calculations. Nomad Sculpt can be a bit finickity when adjusting cameras with the gizmo tool, so after changing the numeric values go to the camera dropdown menu, tap the name of the camera so the view changes, then tap the update icon.

Setting up our master camera view: 1 add a new view and name it, 2 edit matrix in gizmo tool, 3 tap name in camera list, 4 tap update icon
Setting up our master camera view: 1 add a new view and name it, 2 edit matrix in gizmo tool, 3 tap name in camera list, 4 tap update icon.

Do that last bit any other way and you risk the camera matrix resetting to it’s previous values, so I find it best to check in the gizmo tool to make sure they really updated OK. I renamed my middle camera to ‘Middle’ as the stereo cameras will be either side – and note that it’s useful later for making 2D renders of our scenes. Now, in the scene list, we can clone the middle camera and rename it, quite aptly, to ‘Left’. Now all we have to do is move it a little to the left (half our eye separation in fact, which I set to 2) and rotate it to look at the origin. Don’t worry, I’ve done the math so you don’t have to – it’s all in the diagram below.

The calculations needed to set up the cameras
The calculations needed to set up the cameras.

You’ll note that the math shows the camera has to be rotated 5.71 degrees clockwise from the default forward-looking camera orientation, plus translated -1 on the X-axis. As the right view is symmetrical we only have to repeat what we do for the left camera with a translation of 1 and a rotation of -5.71 degrees. After using those values in the gizmo tool for each camera (remember the fiddly way to make them ‘stick’ I mentioned above), we should have a left and right view as shown in the screenshots below.

The completed left and right camera views setups
The completed left and right camera views setups.

Now we can render the left and right views as normal, in portrait orientation and screen resolution, first selecting the appropriate camera view in the dropdown. But remember to set the perspective projection for the left and right cameras first – we need that for a natural view of the scene but it can be fiddly navigating during editing with it set. We’ll be needing the Photos3D Python3 library from our Github repo, which you need to get set up first. Then put the two renders into the Photos3D ‘imagestoprocess’ folder and save the code below to a file in the Photos3D main code folder – I called it ‘leftrighttosbs.py’ just cos it sounded nice.

import os
from matplotlib import pyplot as plt
from photos3d import sbs as sbsim
from photos3d import image as img

leftfname = os.path.join(".", "imagestoprocess", "left.png")
rightfname = os.path.join(".", "imagestoprocess", "right.png")
left = img.open(leftfname)
right = img.open(rightfname)
sbs = sbsim.create(left, right)
outfname = os.path.join(".", "imagestoprocess", "sbs.png")
sbs.save(outfname)
plt.imshow(sbs)
plt.show()

The Python3 code is quite simple, it just uses Photos3D to load the left and right images, creates a new side-by-side stereoscopic version of them, and saves that as a file called ‘sbs.png’ in the ‘imagestoprocess’ folder. Don’t worry if you made JPEG render files, just change the code to use ‘left.jpg’ and ‘right.jpg’ instead (note iOS may save the renders as .jpeg files, which can be confusing). The code will then display the stereoscopic image for you, so you can check all is good. And note this should also work for you without issue using Pythonista on iOS and PyDroid3 on Android, so you can do this on the same tablet or phone you used for Nomad Sculpt.

The stereoscopic image displayed in Pythonista on iOS
The stereoscopic image displayed in Pythonista on iOS.

Finally, if you’d like one more tip it’s this: try creating the cameras in a very simple Nomad Sculpt file. That way you can add that file to a scene, then scale and rotate objects so they fit nicely into the middle camera view. That way you can then create stereo renders without all the extra work of setting up new cameras and calculating their rotations. I’ve found that Nomad Sculpt doesn’t like saving files with just cameras in though, but that’s easily gotten over by including a tiny cube that’s easily ignored or deleted.

And really that’s all there is to it! I know making a stereoscopic side-by-side version of a Nomad Sculpt render should be a lot more complicated than that, so let’s just not tell anyone else and pretend we’re 3D geniuses 🙂