Engineering

Linux Radiance on Windows with WSL and X11

Use Radiance at its best.


The LBNL Radiance software suite is a set of individual command-line executables, developed for UNIX systems, like Linux.

Although there is a Windows version of it, it’s not complete of all the executables, it doesn’t exploit multiple-core CPUs, the executables that exist are limited in some functionality (tensor-tree BSDFs for example), most of the graphical output that originally exploits X11 has no Windows counterpart.

On the other hand, Windows is the OS that supports CAD applications that create the input files for the Radiance engine.

We would like to use both at the same time, and turn out we can.

Now, I’m not talking about using a full Linux GUI in a virtual machine like Hyper-V. That works, but it’s not good to pass data back and forth from Windows, and it’s fairly hardware intensive, especially on laptops.

Luckily there is a lightweight solution that comes in the form of WSL (Windows Subsystem for Linux), a virtualization environment that puts the Linux terminal in the Windows command prompt, without carrying all the unnecessary UI which we wouldn’t use anyway.

Windows Subsystem for Linux (WSL)

To use WSL you need a Windows 10 device, updated to at least Update 1709 for version 1, and Update 2004 for version 2. Both of them will do the job for us, I’m using version 2 because it performs better.

The steps to install it are:

  • Enable the “Virtual Machine Platform” optional component, by checking the corresponding box in the “Turn Windows features on or off” options panel;
  • In the same panel enable “Windows Subsystem for Linux”;
  • Hit “OK” at the bottom of the panel and let Windows do its things;

  • Reboot the computer;
  • Go to the Windows Store and download a Linux distribution. I’ll use Ubuntu 20.04 LTS, the latest Ubuntu version at the time of writing.

  • Launch Ubuntu by clicking “Launch” in the Store, or by searching for it in the Start menu. This will open a Windows command prompt which will install WSL.
  • You may get an error stating “WSL 2 requires an update to its kernel component…”. To fix it follow the link https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel, download the update .msi file and execute it; Repeat previous step.
  • When the install is finished you’ll be prompted to create a default UNIX account (a username and a password). Note that the password won’t be displayed while you type it, but will be registered on “Enter”.
  • You’re done. To run WSL in the future simply search for Ubuntu in the Start menu, or open the command prompt and write “bash” and then hit “Enter”.

To check if everything is working you can open the Power Shell and write the command wsl -l -v. This will list the existing WSL virtual machines, along with their state (running or not running) and the WSL version (1 or 2). If the machine you’re running is version 1, but you what version 2 type the command wsl --set-version NameOfTheMachine 2. You can also set version 2 as a default for new machines with the command wsl --set-default-version 2.

Radiance for Linux

It’s time to get the Linux version of Radiance. Doing so is very easy since NREL keeps a GitHub repo where you can download precompiled binaries (here is the link of the official version at the time of writing).

EDIT: if some executables of the precompiled binaries end up not working at the end of the process, build Radiance from source as explained here.

After downloading extract the folder somewhere you want. Here is the directory tree you’ll see:

--- radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance

------ bin

# the radiance suite of software

------ lib

# library files

------ man

# manual files

What we want to do is to move these three child folders (bin, lib, and man) into the WSL environment; I suggest putting them in usr/local/radiance.

To do that:

  • Move the “radiance” folder (the one containing “bin”, “lib”, and “man”) to the Desktop (it’s optional, you just need to know where it is saved).
  • Locate the “radiance” folder in the Windows environment. In my case, I put it on the Desktop (C:\Users\<your_username>\Desktop).
  • Open the terminal in WSL as explained before (open cmd, write “bash” and hit “Enter”).
  • You can move to the Windows location in which you have the radiance files to be copied with cd mnt/c/Users/<your_username>/Desktop
  • Check if the “radiance” folder is there: write ls and you’ll see a list of the directories on your Desktop.
  • Go back to the root with cd /

 

  • (these two are the only strictly necessary steps)
  • To copy the files write sudo cp -r /mnt/c/Users/<your_username>/Desktop/radiance /usr/local (sudo means as admin, cp means copy, -r means recursively [all files and folders within the parent])
  • Enter your Linux password.

 

  • Check if the “radiance” folder has been successfully copied with cd /usr/local and then ls
  • You’re done.

To let Ubuntu understand the name of the Radiance commands, we need to add the newly installed folders to the environment variables (similar to the path in Windows if you are familiar with it).

To do that open the wls terminal and use the commands:

export PATH=$PATH:.:/usr/local/radiance/bin

export RAYPATH=.:/usr/local/radiance/lib

To test if the installation is working type the command genbox. If you are prompted with the suggestion Usage: genbox material name xsize ysize zsize [-i] [-b bevel | -r rounde], Radiance is installed correctly.

 

X Window System (X11)

You’ll notice that there are a set of commands that are named xSomething. If you try to call them, they won’t work. The reason is that they are based on a windowing system called X Window, which neither Windows nor WSL Ubuntu comes with. But there’s a solution!

The xSomething software are the ones that need a GUI to output results. To make them work we simply install VcXsrv (that can be downloaded here). After running the installer launch the XLaunch software, leaving all options to default, except in the “Extra settings” tab check “Disable access control”.

To quickly check if the install is working open the bash terminal and write the xclock command, if an old looking clock comes up, it is.

Note that you’ll need to run XLaunch every time you want to use x11 software from the Radiance package.

Conclusions

You’re set to go! Now you can exploit the full power of Radiance like in its native environment.

Useful references

  1. WSL Documentation | https://docs.microsoft.com/en-us/windows/wsl/
  2. Windows 10 releases | https://docs.microsoft.com/en-us/windows/release-information/
  3. LBNL Radiance website | https://www.radiance-online.org/
  4. X Window System (X11) | https://en.wikipedia.org/wiki/X_Window_System

06 Sep 2020
Mattia Bressanelli

Comments

Leave a Reply to Mathias Sønderskov Cancel reply

Your email address will not be published. Required fields are marked *