OpenGL PBR Shading

 

OpenGL PBR Shading

With the world of CG coming closer and closer to photo-real rendering across the board, I decided that it’d be worth my time to look into setting up my own physically based renderer to reproduce an object in real time. I’d previously attempted to recreate this same memory stick using OSL shaders for Renderman, however the results could have been improved with greater control over the process.

The memory stick consists of a worn, brushed metal housing, translucent plastic at the back, and plastic and metal internals. I also figured it’d add to the realism if the housing cast shadows on the internals as you’d expect it to in reality.

The plastic is relatively simple, as due to the size of the object refraction is not apparent, and by lowering the transparency I was able to achieve a close reproduction.

The metal housing was ‘scratched’ by applying various layers of noise for both the original brushed texture, and the scratches on top. The noise was generated in shader, however to save on framerate this could have been generated at program start and sent as a texture to each instance of the memory stick.

As for the shadows, as the shape of the opening is rather simple, I faked the shadows by applying a semi-transparent black coloured plane to the opening, with it fully transparent when fully lit and half transparent when fully dark.

The source code is available on GitHub, and it’s corresponding paper is available here.