Experimenting with Physically based rendering in Blender Cycles
by Martin Thomas
Cycles should be OK? …
I’ve been thinking about experimenting with physically based rendering for a long time, but at first I didn’t want to write any code. So I turned to the Blender Cycles path tracer. Cycles is great because it should give the “ground truth” path traced solution, so later I can see how close I got to that. However, simply importing a model doesn’t give you nice results outright, you have to set up the materials. I also read a lot about PBR from mainly here: http://interplayoflight.wordpress.com/2013/12/30/readings-on-physically-based-rendering/
But where do I get PBR assets from?
Physically based rendering is great because it simpifies the asset creation process, and it makes it difficult for the artists to create unrealistic results. It is usually paired with a streamlined asset creation pipeline, with all the reference materials and the like.
But I don’t have these, so I set out to search for PBR assets that one can use without paying artists to create them.
I found this great gun asset here: http://artisaverb.info/PBT.html
I also used it as reference for rendering results.
There’s not much more assets around the web.
How to achieve fast, clean render output on AMD
Render settings tab:
Resolution: set to desired (1080p)
Sampling: branched path tracing, 4 AA, 8 diffuse, 6 glossy, 4 AO samples, rest is 1 sample (add more if needed)
Light paths: set max samples to 128 for each of them, min to 0
NO motion blur
Performance: dynamic BVH, cache, persistent spatial splits, 256×256 tiles, no progressive
Set up an equirectangular background texture for the environment map at the world settings.
Use importance sampling here.
Disable importance sampling for ALL your lights, as they cause “black lines” artifacts.
Use NO depth of field for the camera.
OpenCL allows up to 576MB of allocatable Buffer Size (clCreateBuffer) on my 1GB video card, so make sure you don’t go over that!
Reduce texture sizes if needed (I used 2k)
This made sure that on my HD 7770 I got around 40 second render time for a frame. However the image wasn’t at all noise-free. If I set the render settings to the “final” preset with “full global illumination” I got around 5-8 minutes of render time per frame.
With all these optimizations a 1.5 minute movie still took 2 days to render.
Steps to set up PBR in Blender Cycles
1) add a diffuse shader as seen on the graph image
2) add the normal map as non-color texture (tangent space) and set it up like in the graph image. Note that for Cycles you don’t need to do normal map filtering, as path tracing should do that automatically for you (by taking more samples)
3) add diffuse texture
4) add ambient occlusion and mix it with the diffuse output. Note that it is possible to go without the AO, as the path tracer should do this anyways, but I included it to get the same look as in the original video/images.
5) mix diffuse with metalness to get proper diffuse colors. Perfectly specular materials should have their diffuse color set to zero. So high metalness should result in dark diffuse colors.
6) add specular shader
7) set up the normals for the specular shader
8) set up roughness for the specular shader with remapping. Note that you can remap the roughness to any range as needed, I used this range, as it looked mostly right.
9) set up specular color using the mask textures provided, I used this for reference: http://seblagarde.wordpress.com/2014/04/14/dontnod-physically-based-rendering-chart-for-unreal-engine-4/
10) mix with metalness to achieve dark specular in places specular shouldn’t be. I also hacked it a bit, so that the image is closer to the reference image.
The End result
In conclusion, I think I got really close to the reference images. Of course different lighting will resulted in a different image, but this is one of the best things about PBR, no matter what lighting you use, it will always look good.
Note that with PBR I think there’s no “incorrect” material, it’s just different. So with different values you may get a plastic look instead of aluminium, but it will at least look like a nice plastic material.
Here are the final files (200MB):
Here’s a video that showcases the end result in motion.