I built a PBR Renderer

I was completely immersed in rewriting my game engine when I stumbled upon these captivating images.

 
 

The author experimented with the properties of various metals and demonstrated how to create them in a Physically-Based Renderer through renderings.

They looked so cool that made me wonder if I could build a Physically-Based Renderer myself and render these metals.

I was a bit hesitant to take a detour from my engine and modify the renderer.

See, there were several things that I needed to change in my engine. For starters, I was using non-physically-based shaders. Thus, I was not using any material properties from a model. My engine would also require a user interface to manipulate material properties such as Roughness, Metallic, etc.

So, I listed the things that I had to do and after looking at the list, I decided to take a little detour and build a PBR Renderer.

My plan of action was super simple:

  1. Become more familiar with PBR and BRDF functions
  2. Modify the current code base to use material properties and PBR functions instead of non-physically based functions.
  3. Implement a User-Interface for the material properties

So, I began my new project by reading a bunch of amazing BRDF papers, articles, presentations, and everything I could get my hands on. I knew the role of BRDF in PBR but if I was going to build a PBR renderer, it made sense to do a deep dive and understand every aspect of it.

I used most of my existing code base in the renderer. The biggest changes I made were to the shaders. I kept my non-physically based shaders and added BRDF shader functions. I found a nice list of several functions here.

The UI implementation was super simple and it is not worth talking about it but here is an image of the UI.

 
 

It allows the user to manipulate several material properties, set tone maps, enable Image-based lighting, and set the direction of the light. One cool thing that I added was the ability to select different BRDFs. You can see in real-time the effect of choosing different BRDFs functions such as Cook-Torrance, Disney, etc.

So, everything seemed to be going well; however, I still had a major problem. The metals were not being rendered as metals; something was off. The rendering below shows my attempt to render Gold.

 
 

At this time, I decided to take a break from coding and focus on something that was bothering me, the "Fresnel Function." I didn't quite understand its role in BRDF, so I spent a weekend getting familiar with it. While reading about this topic, I realized that metals don't reflect any diffuse component. I ran to my computer, removed the diffused component, and BOOM!!!!

I had rendered GOLD.

 
 

In conclusion, I'm glad I got distracted to build a PBR Renderer. I learned much more than I imagined and had a lot of fun. Also, it wasn't that difficult at all. Here are renderings of other metals.

 
 

Thanks for reading

Harold Serrano

Computer Graphics Enthusiast. Currently developing a 3D Game Engine.