Production Shader Writing Fundamentals & Physically Plausible Shading

Taught by Christos Obretenov

Course Number:
Software Version:
Original Run Date:
July 2012 
7 hours 2 minutes 
Following the RND202 course “Renderman Techniques in Production”, this course dives deeper into the fundamentals of Shader Writing in the Renderman Shading Language (RSL), as well as the newer Physically Plausible shading in Renderman.

Technical Directors will find this course useful for expanding their shading knowledge in Renderman, by diving into the shaders and building them up step-by-step. Coming out of the course the student will be able to put into practice, in a production environment, building and using Renderman Shaders, as well as a deep understanding of Physically Plausible shading including Importance Sampling and Image Based Lighting. In addition, we cover the Phsyically Plausible shading library inside Renderman Studio 4 (for Maya), raytraced re-rendering technology, and a crash course on Renderman setup in Houdini.

Obretenov has worked in a variety of roles, designing and developing shading software for Walt Disney's The Wild feature film, followed by shading and lighting for Superman Returns, Spider-Man 3, Beowulf, Christmas Carol, and Mars Needs Moms feature films.

The curriculum is broken up into three sections:

Part 1 - Production Shader Writing Fundamentals

We build up the shaders from scratch and explore the source code. Common Types of shaders used in production are Surface, Displacement & Volume. Building blocks are Loops, Functions, defines, Message-passing, AOVs & Custom primvars. We look at co-shaders: Differences between co-shaders and monolithic/traditional and Co-shader examples. We also look at noise functions in depth: Perlin, Worley, Voronoi and FBM

Part 2 - PRMan & Houdini “Crash Course”

We go through all the settings in getting your custom shaders into Houdini and the steup required to render in PRMan. We build a scene from scratch, go through the render man output driver. Work with shaders, bringing in Surface and Displacement, setting up “Materials”. Work with AVOs and Primvars: custom variables added to geo, read into shader. Looks at attributes: how to setup Renderman attributes on models and general output driver. Then look at examples: specular/diffuse/transmission visibilities, displacement bounds, trace depth, etc.

Part 3 - Physically Plausible Shading & Importance Sampling - In Depth

We dive in BRDFs, looking at the Definition, different types of BRDFs and Shader Source code samples and use. Then look at Importance Sampling and it's Definition, Light vs BRDF, Examples and Source code in shaders.

Next we work with Physically Plausible, looking at the Definition, Energy Conservation, Fully raytracing paradigm, Biased-vs-unbiased, Path Tracing (uni and bidirectional), Shaders and source code exploration, Examples, Comparison to non physically-plausible and Plausible Shader constructed from scratch; explaining inclusion of each piece in plausible framework

We also work with Physically Plausible Library in Renderman Studio 4: Light and surface shaders: RMSGPSurface, RMSGILight, RMSEnvlight, RMSAreaLight, and others.

Educated at Simon Fraser University in Computing Science and Computer Graphics, Christos started contributing to the Animation and Film industry during "co-op" work terms at Mainframe Entertainment in conjunction with Simon Fraser University. He continued his career by designing and developing shading software for Walt Disney's The Wild feature film, followed by shading and lighting for Superman Returns, Spider-Man 3, Beowulf, Christmas Carol, and Mars Needs Moms feature films. Recently co-founding, Christos develops procedural solutions to shading and lighting, currently experimenting with Physically Plausible Shading and Image Based Lighting. He currently resides in Vancouver, BC, Canada.
Production Shader Writing Fundamentals & Physically Plausible Shading
Watch our overview of the course

Class Listing

Class 1

In the first lesson of this course, we outline the shader building blocks we will be covering in the next few lessons, as well as the different types of shaders used in production. We explore an overview graph of where a shader fits into our rendering pipeline, then proceed to implement each stage from scratch: we build a simple shader, and insert it into a basic RIB file in a text editor, then render in PRMan from the command-line. We then take the same shader and run it through Houdini where we build a scene from scratch and go over every step to get the Renderman shader and Output Driver running. We also look at the RIB file that Houdini generates and compare it with our basic one that was created manually. Next we want to run the same shader through Renderman Studio 4 (RMS) in Maya to see the same render, and the steps required to get it there. We also explore the realtime re-rendering technology in RMS with our scene, and look at the RIB file generated by RMS.

Class 2

We follow up on the surface shader workflow with a displacement shader workflow. We describe the concept of the vector math behind displacement shaders, create a very simple displacement shader, and go through the source code line by line discussing the process. We compile our shader and load it into a simple Houdini scene where we attach it to our geometry and render to see the displaced geometry. We also examine the RIB file generated by Houdini and render that manually through a shell terminal.

Class 3

We take off from the previous lesson's simple surface and displacement shader examples into some fundamental building blocks of production shaders. We introduce the topics of loops, functions, define's, message passing between surface and displacement shaders, ST co-ordinates and their relationship to the texture() call, and texture reading. We do this on the backdrop of building up a procedural and texture based snow shader, where we use all these building blocks, as well as our imgFile shader.

Class 4

We continue on with our production shader writing fundamentals, and explore Arbitrary Output Variables (AOVs), as well as Surface Normals and the Viewing Vector. We build on our snow shader scene and define what exactly needs to go in our snow surface shader to define our custom AOVs, and the corresponding declaration in the RIB file. We then load our scene in Houdini and declare the AOVs there, and render them out to see all the different passes. To explore surface normals and the viewing vector, we use an Oren Nayar Diffuse illumination in our snow shader and show the creation of the V vector, and how its used within the diffuse illumination by dot products and cross products of the vectors.

Class 5

PRMan & Houdini "Crash Course"

Class 6

By popular demand on the forums for this topic (thanks for all that expressed interest), we've added a new topic for just this lesson, where we explore and implement "Procedural Wear" with dust/scratches/rust/dirt/etc placement onto our models. I developed a complex shader on the feature film "Mars Needs Moms" for Disney using these techniques, and we build up our shader and scene with this workflow using an edge detection shader and ambient occlusion to drive our masks for dirt/scratches/rust/etc textures.

Class 7

In this lesson we move onto Physically Plausible Shading and Co-Shaders. We define a Physical Plausible Shading System and the important fundamentals within it, including energy conservation, physical material properties, and physically based lights. For implementation of that system, we explore importance sampling and raytracing concepts. In our Physically Plausible scene, we explore the plausible surface shaders and lights, render our RIB file, and examine the source code of the plausibleDielectric shader. Exploring the Physically Plausible system leads us to writing co-shaders (or class-based shaders, shader objects): we define co-shaders and Object Oriented Programming, why they are used, and compare the source code to traditional shaders that ultimately do the same functionality in our example, but the co-shaders are more modular and have more efficient message/variable passing, as we will see in future lessons.

Class 8

In this lesson we continue on with Class-based shaders and Co-shaders, and Physically Plausible Shading. Taking off from our class based shader created in the previous lesson, we create two small co-shaders to really illustrate the modularity of a co-shader paradigm and how those co-shaders plug into our main Shader Object, and how they all work together in the RIB file with "handles". We distinguish between "Shader Objects", "methods" inside Shader Objects, and "co-shaders". Having those fundamentals allows us to re-examine the Physically Plausible Shaders in PRMan and see the Shader Objects and method calls, and we specifically look at what the new pipeline methods lighting(), diffuselighting(), and specularlighting(). But using PRMan's new Physically Plausible Shading is not the only way to implement a co-shader Physically Based paradigm, many studios have created their own using co-shaders even before PRMan16 where Physically Plausible Shading was introduced as part of the renderer: we outline a custom co-shader Physically Based System and see what the RIB file looks like including the BRDF's and Integrator - this is a high level concept of the entire system with RIB implementation. Finally, how does the artist or technical director work with these kinds of co-shaders in production? We show a typical node-based UI mockup of connecting different BRDF's into a final integrator (or sometimes called Collector) and how the modularity really shines when we can write our own co-shader BRDF's and plug them in.

Class 9

With Shader Objects, Co-shaders, and the Physically Plausible Shading system in PRMan in our toolbelts, we look at ways we can extend and customize our Physically Based system. One of the things we can modify in our existing system of shaders and lights is the BRDF - we can customize existing BRDF's, or add our own. Where do we begin if we want to extend or add our own BRDF's? We distill the plausibleDielectric shader and look at the Lambertian Diffuse and Ashikhmin-Shirley Specular BRDF's, how they are used in plausibleDielectric, and their corresponding header files. From there we create our own myDiffBRDF header file with our own struct, and modify the BRDF computation slightly, show how this plugs into the main shader, and do a render to compare the results on our scene. Moving onto a more complex BRDF that we want to implement, we look at the Oren-Nayer Diffuse model that we've used with our snow shader earlier in this course, and convert that from a traditional RSL1 shader into our RSL2 Physically Based Shader Object system: this requires a number of conversions of vectors, normals, and light looping to work with our system, which we successfully do and plug into our Physically Plausible scene and do a few renders with different diffuse roughness settings of our new BRDF. With knowledge of this workflow, we have what we need to add any kind of BRDF we want into our system.

Class 10

After a number of lessons focused on shader writing with Shader Objects and Co-Shaders, modifying and writing our own BRDF's, this lesson focuses on using those shaders in RendermanStudio's raytraced re-renderer. As mentioned in the intro to this course, we wanted to spend one lesson rendering in the raytraced renderer since the technology is such a great tool and provides instantaneous visual feedback as we modify our lights, shaders, and camera - this is a great way to wrap up our physically based section of the course where we get to really see the shaders and lights in action.