Home Creators Posts Import Register Favorites Logout

Content

It’s surprisingly easy to build and run the MoonRay renderer in Windows Subsystem for Linux (WSL). WSL is an amazing tool that lets us run an entire Linux distro without leaving Windows. Let’s look at how to get MoonRay up and running, step by step!

WSL Setup

If you don’t already have WSL enabled, it’s simple to set up. Open PowerShell and type:

wsl --install

Well, that’s all there is to it! Type:

wsl --list

This will show what distros are currently installed. The default is Ubuntu.

Linux Setup

To make life easy we’ll use a specific Linux distro for building MoonRay: Rocky 9. The MoonRay code base is specifically configured for Rocky, including a number of convenience scripts to automate the process.

To start, download a Rocky 9 image here: https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-Container-Base.latest.x86_64.tar.xz

Next, open up PowerShell and type:

wsl --import rocky9 <destination_folder> <path/to/Rocky-9-Container-Base.latest.x86_64.tar.xz> --version 2

Replace destination_folder with the folder on your machine where you’d like to store the Rocky 9 WSL installation.

After a minute, WSL will have everything set up. Type:

wsl -d rocky9

This will immediately start up a Rocky 9 root session. All the standard Linux tools are available. For example, you can type dnf update to sync with the Rocky online repositories or ls to view the contents of the current directory.

Building MoonRay

The MoonRay build process is largely automated, so our job is just to trigger a number of scripts and processes. I had to make a few changes to get things working. I’ll explain those as we encounter them.

First things first. We need to clean out the PATH environment variable. WSL automatically picks up on all the stuff we have in Windows PATH, which can lead to a lot of conflicts during the build process. I use a very basic PATH that seems to work fine:

export PATH=/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib

Next, we’ll create the MoonRay folders and download the GitHub MoonRay repo.

mkdir -p /opt/MoonRay/{installs,build,build-deps,source}mkdir -p /opt/MoonRay/installs/{bin,lib,include}

cd /opt/MoonRay/sourcednf install -y gitgit clone --recurse-submodules https://github.com/dreamworksanimation/openmoonray.git

Now we’ll run a script that downloads all the precompiled libraries MoonRay needs. I turned off the CUDA and libcgroup options. CUDA won’t work on this particular WSL installation and the libcgroup stuff is broken and not necessary anyway. Type:

/opt/MoonRay/source/openmoonray/building/Rocky9/install_packages.sh -nocuda -nocgroup

You’ll see lots of messages about packages being installed, but there shouldn’t be any errors.

Next we’ll compile more dependencies from source. Type the following, replacing num_cores with the number of cores on your CPU you’d like to use. It’s good to leave some extra so your system doesn’t grind to a halt. For example, on a 16 core machine you could set -j 12 to leave 4 unused.

cd /opt/MoonRay/build-depscmake ../source/openmoonray/building/Rocky9cmake --build . -- -j <num_cores>

This step will take quite a while and you’ll be treated to thousands of lines of compiler messages. If there are any errors they’ll display in red and the process will stop. With a bit of luck, everything should complete without issue.

Once the dependencies are built, we’ll build MoonRay itself. I turned off Optix here since we don’t have it installed and leaving it enabled will cause the build to fail. Type:

cd /opt/MoonRay/source/openmoonraycmake -DMOONRAY_USE_OPTIX=0 --preset rocky9-releasecmake --build --preset rocky9-release -- -j <num_cores>

After a few minutes the build will finish. To finalize everything and run a test render, type:

source /opt/MoonRay/installs/openmoonray/scripts/setup.shcd /opt/MoonRay/source/openmoonray/testdatamoonray_gui -exec_mode vector -info -in curves.rdla

This will launch a MoonRay window and render a simple test scene. When I first did this build I was honestly shocked to find out that WSL allows a Qt window to display like this. But, it does and it works great!

We can download some more complex test scenes by typing:

wget https://docs.openmoonray.org/assets/test-scenes/example_scenes.zip

Rocky 9 doesn’t have unzip enabled by default, so to install it type:

dnf install -y unzip

Then type:

unzip example_scenes.zip

To render the Coffee Maker scene, for example, type:

cd example_scenes/pbrt_scenes/coffee_makermoonray_gui -exec_mode vector -info -in scene.rdla scene.rdlb

Closing Thoughts

This whole build process is unusually straightforward and MoonRay works great from within WSL.

There's one major caveat: we can’t use MoonRay in XPU mode and take advantage of our Nvidia GPUs. WSL actually does support CUDA, but unfortunately at this point it’s Ubuntu-only. The problem is that you need to install the CUDA Toolkit but NOT the Nvidia drivers.

If we try to install CUDA in our Rocky 9 it will force inclusion of the driver. There’s a repo with a WSL-specific CUDA setup that doesn’t do this, but it only works in Ubuntu. I’m sure it’s possible to configure the same for Rocky, but that’s no doubt a complex process and best left to the professionals. People have also successfully built MoonRay in Ubuntu, but, again, this is complicated and fraught with pitfalls.

All that being said, the MoonRay experience is just fine on CPU only. We’re not missing out on a whole lot by not having CUDA or Optix. The intention here is to experiment with MoonRay and possibly modify the source code, not create a full production-ready environment.

Files

Comments

citruprince

very useful thank you exactly what I need to get started with wsl. Do you now if it's possible to run moonray with houdini throught wsl or it's not something worth researching ?