Writing Shaders

Class 401: Writing mental ray Shaders

Class Description: Writing mental ray Shaders

Intended for programmers, this three-day class introduces fundamental mental ray concepts, covering a broad collection of shaders, and providing source code and methods for custom shader development. Exercises rendering with standalone mental ray, while editing scene files and shader source code, reveal the basic conventions and API resources available for writing shaders. The exercises reinforce a methodology for efficient realization of custom shader kits.


Class Prerequisites: Writing mental ray Shaders

The minimum requirements for taking the class include:

  1. Experience using mental ray in one of the 3D applications (Maya, XSI, 3ds max, etc.).
  2. Reasonable proficiency with a text editor and command-line tools
  3. Basic knowledge of C programming, including:
    |  Variable declaration and type definition
    |  Control structures: "if/else", "for", "while", "switch"
    |  Function definition
    |  Pointers: declaration, dereferencing, casting of "void*" pointers, use as function
    |  arguments for return values
    |  Structs: pointer syntax, field access
    |  Compilation, linking and definition of shared libraries

Class Outline: Writing mental ray shaders

Monday-Wednesday, 10AM-6PM


Day 1


Introduction

Introduction to mental ray Rendering
|  Exercise 1 - Render with ray, display with imf_disp


Break


Part 1 - Structure

.mi Scene File Structure
|  Exercise 2 - Editing and rendering a scene file
Shader Structure
Shaders in the Scene
|  Exercise 3 - Using a shader in a scene file
Shader Programming Overview


Lunch Break


Part 2 - Color

Single Color
Color from Orientation
Color from Position
|  Exercise 4 - Compile and use color shaders
Transparency
|  Exercise 5 - Compile and use transparency shader
Color from Image Files (Texture Maps)
|  Exercise 6 - Compile and use texture shaders
Color of Edges


Break


Part 3 - Light

Point Lights, Spot Lights and Shadows
Light on Surface - Direct Illumination with Lambert, Phong, etc.
|  Exercise 7 - Compile and use Lambert and other shader
Reflection
|  Exercise 8 - Using reflection
Refraction
|  Exercise 9 - Using refraction


Day 2


Light Paths, Traced Rays and Ray Types Review
Light from Other Surfaces - Indirect Illumination
Ambient Occlusion
|  Exercise 10 - Using ambient occlusion


Break


Part 4 - Shape

Modifying Surface Geometry
|  Exercise 11 - Displacement mapping
Modifying Surface Orientation
|  Exercise 12 - Bump mapping
Creating Shapes


Lunch Break


Part 5 - Space

Global and Object Environment
|  Exercise 13 - Environment shader
Global and Object Volume
|  Exercise 14 - Volume shader in hull object


Break


Part 6 - Image

Samples, Pixels and Tiles
|  Exercise 15 - Sample diagnostics, fixed and adaptive
|  Exercise 16 - Sample diagnostics, object samples
Lens Shaders
|  Exercise 17 - Fisheye lens


Break


Motion and Temporal Samples
Rendering Image Components
|  Exercise 18 - User Framebuffers
Output Shaders


Day 3


Part 7 - Implementation

Render Process
|  Jobs and execution order
|  Parallelism
|  The render report
Memory - Scene Cache
Placeholders - Object Files and Callbacks
|  Exercise 19 - Placeholder example
Sharing Data
|  Exercise 20 - User data example
State Shaders


Break


Using the Rasterizer
Alternate Pipeline Options
|  Exercise 21 - Alternate pipeline example


Lunch Break


Labels - Identifying Object Sets
|  Exercise 22 - Shader using labels
Leaf instances
Geometry shader object in scene DAG


Break


Part 8 - Illumination Models

Color and Energy Representation
Matching Shader Implementations
|  Traditional vs. physically correct
|  When to use shadow shaders


Break


Part 9 - Debugging Techniques and Resources

Summary of Techniques Used Throughout Exercises
-debug Option
Online Manual
|  State information
LAmrUG Forum - Advanced Shaders Section

Legal and Privacy Information
© mental images GmbH | Fasanenstr. 81 10623 Berlin Germany | phone +49.30.315.99.70 | fax +49.30.315.99.733 | office@mental.com