You are previewing The RenderMan® Shading Language Guide.
O'Reilly logo
The RenderMan® Shading Language Guide

Book Description

Discover how to achieve the stunning imagery and dazzling effects that wow audiences in animated and live action motion pictures. "The RenderMan® Shading Language Guide" shows you how to master this powerful rendering program, used by filmmakers in conjunction with 2D and 3D painting, modeling, and animation software to transport audiences to faraway lands and awe them with fantastic creatures. A comprehensive guide to the RenderMan Shading Language (RSL), the book teaches experienced 3D animators and artists fundamentals through advanced RSL and image synthesis concepts. Beginning with an introduction to RSL, you'll learn about the shader writing process and how to set up a proper shader developing environment. After that you'll try your hand at some simple shading methods such as light and volume shaders. Once you have the basics down, you'll move on to more advanced shading skills including raytracing, global illumination, pattern anti-aliasing, and DSO shadeops. The book presents over 80 complete shaders and teaches good coding style and techniques. "The RenderMan Shading Language Guide" presents the skills you need to become proficient with RSL so that you can use them to create amazing special effects for use in movies, video games, and more.

Table of Contents

  1. Copyright
  2. Dedication
  3. Acknowledgments
    1. Rudy
    2. Saty
  4. About the Authors
  5. Introduction
    1. Welcome to RenderMan
    2. The Road Ahead
    3. Who This Book Is For
  6. I. RSL Fundamentals
    1. 1. Introduction to RSL and RenderMan
      1. Background and Industry Insight
      2. RenderMan Overview
      3. The REYES Rendering Algorithm
      4. Bounding
      5. Onscreen Test
      6. Size Test
      7. Dice
      8. Shade
      9. Bust and Bound
      10. Micropolygon Onscreen Test
      11. Sample
      12. Composite and Filter
        1. Anatomy of a RIB File
      13. Options and Attributes
      14. Transformations
      15. End of Line and Comments
      16. Image Control Options
        1. Format
        2. Projection
        3. Clipping
        4. Display
        5. PixelSamples and ShadingRate
        6. PixelFilter
      17. More About RIBs and the RiSpec
    2. 2. RSL Details
      1. Language Overview
      2. Shader Types
        1. Displacement
        2. Surface
        3. Lights
        4. Volume (Atmosphere, Interior, and Exterior)
        5. Imager
        6. Variables
      3. Data Classes
        1. Data Types
          1. Float
          2. String
          3. Points, Vectors, and Normals
          4. Color
          5. Matrix
        2. Arrays
        3. Syntax Rules
          1. White Space
          2. End of Line
          3. Comments
        4. Shader Structure
        5. Operators
        6. Flow Control
        7. Functions
        8. The C Preprocessor
          1. Constants
          2. Commands
            1. include
            2. If Defined and If Not Defined
            3. if, else, elseif
          3. Macros
    3. 3. Shader Writing Process
      1. Design
      2. Research and Development
      3. Implementation
      4. Testing and Optimization
      5. Release
      6. Update and Maintenance
      7. Shader Development Files
      8. The Basic Tools
        1. Text Editors
        2. IDE Programs
        3. Shader Authoring Tools
        4. The Shader Compiler
      9. Your First Shader: “Hello World Shader”
        1. Adding Color and Opacity Control
        2. Ambient Illumination
        3. Lambert Illumination
        4. Specular Reflections
  7. II. Shader Development
    1. 4. Setting Up a Developing Environment
      1. CYGWIN
        1. Most Used Commands
        2. UNIX Folder Structure
        3. It’s All About Speed
          1. Shortcuts and Environment Variables
          2. Aliases
          3. Tab Completion
      2. Text Editors
        1. Emacs and XEmacs
        2. Common Customizations
          1. Syntax Highlighting
          2. Face Colors
          3. Line and Column Numbers
          4. Tab Space
        3. rsl-Mode Installation
      3. Folder Structure
      4. Versioning Systems
        1. RCS
        2. Subversion
        3. Setting Up a Repository
          1. Importing a Folder and Initial Checkout
          2. Common Operations
      5. GNU Make
        1. Variables
        2. Writing Rules and Commands
    2. 5. Math for Shader Writers
      1. Useful Operations
        1. Inverting a Value
        2. Signing a Value
        3. Divide Value by 1
        4. Parametrizing a Value
        5. bias() and gain()
        6. gamma()
        7. compress() and expand()
        8. remap()
      2. Trigonometry
      3. Vector Math
        1. Vector Addition, Subtraction, and Scaling
        2. Vector Length and Normalize
        3. Dot and Cross Product
        4. Reflections and Refractions
      4. Color Math
        1. Color Theory and Spaces
        2. Add, Subtract, Divide, and Multiply
        3. Color to Float
        4. Advanced Color Mixing Operations
        5. colorOver()
        6. colorAdd(), colorSubtract(), and colorMultiply()
        7. colorDissolve()
        8. colorScreen()
        9. colorOverlay()
        10. colorDarken() and colorLighten()
        11. colorDifference()
        12. colorHardlight() and colorSoftlight()
        13. colorDodge() and colorBurn()
    3. 6. Shader Design Methodology
      1. Why Follow a Methodology?
      2. Reference
      3. Make Your Efforts Count
      4. Divide and Conquer
        1. Layered Approach
        2. Shader Outline
        3. Layer 1—Base Color
        4. Layer 2—Green Stripes
        5. Layer 3—Veins (Detail Within the Stripes)
        6. Illumination
      5. Additional Reading
  8. III. Basic Shading
    1. 7. Displacement and Surface Shaders
      1. Displacements
      2. Displacement or Bump
        1. A Simple Displacement Shader
        2. Bump Shader
        3. Built-in Variables for Displacement Shaders
        4. Large Displacements and Patch Cracks
        5. Displacing Polygons
        6. Layering and Manipulating Displacements
          1. Add, Subtract, Multiply
          2. Max and Clamp
          3. Offset
          4. Tips on Displacement Shading
        7. Surface Shaders
    2. 8. Light Shaders
      1. Introduction
      2. Ambient Lights
        1. Enhanced Ambient Light
        2. Super Ambient Light
      3. Point Lights
        1. Shadow Maps
        2. Raytraced Shadows
        3. Adding Shadow Maps
        4. Distant Directional Lights
        5. Spotlights
        6. Uberlight
      4. From Here and Beyond
    3. 9. Volume Shaders
      1. Atmosphere, Interior, and Exterior Volume Shaders
        1. Simple Fog
        2. Raymarching
    4. 10. Imager Shaders
      1. Imager Global Variables
      2. Working Examples
        1. Background Shader
        2. Old Picture Filter Shader
        3. Paper Texture Shader
  9. IV. Intermediate Shading
    1. 11. Illumination Loops—BRDFs
      1. BRDFs
      2. Illumination Models Using RSL
        1. Examples of Using illuminance()
          1. diffuse()
          2. Wrap diffuse()
          3. Biased diffuse()
          4. Translucent Surfaces
          5. Seeliger
          6. Oren-Nayar
          7. Fresnel—Simple Approximation
          8. Fresnel—Schlick’s Approximation
          9. Fresnel—RSL Function
          10. Gooch Warm/Cool Shading
          11. Specular: Phong
          12. Modifying Specular Reflection Vector
          13. Specular: Blinn
          14. Blinn: Anisotropic Shading
          15. Specular: Schlick’s Approximation
          16. Scattered Highlights
          17. Sparkle
          18. Hair
          19. Glossy Illumination
          20. Westin: Brushed Metal
          21. Spirotropic Illumination
          22. Ward: Anisotropic Reflection
          23. Ashikhmin-Shirley Model
          24. Lafortune—Simplified Model
          25. Schlick’s Model
          26. Banks
          27. Cook-Torrance Model
          28. Minnaert Illumination
          29. Phosphor Under Blacklight
          30. Scaling Lights
    2. 12. Procedural Patterns
      1. Why Procedural?
      2. Design Philosophy
      3. Pattern Generation Toolbox
      4. Types of Patterns
        1. Regular Patterns
        2. Stochastic Patterns
        3. Mixed Patterns
      5. Examples of Procedural Shaders
        1. Surface Shaders
        2. (s,t) Grid
        3. An Optical Illusion
        4. Anisotropic Hues
        5. Note Paper
          1. Spirograph Curves
          2. Mandelbrot Fractal
          3. noise() Function
          4. cellnoise() Function
        6. Displacement Shaders
          1. Wireframe Cage
          2. Ridged Multifractal
        7. Light Shaders
          1. Rainbow
        8. Imager Shaders
          1. Sunburst
      6. Further Reading
    3. 13. Texture Mapping
      1. Basics
      2. Image Processing
      3. Image Warping
      4. Texture Projection
      5. Environment Mapping
      6. Displacement Mapping
      7. Multiple Maps
      8. Additional Details
    4. 14. Raytracing
      1. Reflection, Refraction, Shadowing
      2. Distributed Tracing
      3. Ray Continuation
      4. Collaborative Shading
      5. Miscellany
  10. V. Advanced Shading
    1. 15. Global Illumination
      1. Occlusion
      2. Image-Based Lighting (IBL)
      3. Transmission
      4. Indirect Diffuse
      5. Photon Map GI
      6. Subsurface Scattering—Irradiance
      7. Baking Rendered Data
        1. Baking Point Cloud Files
        2. The ptfilter Utility
        3. The brickmake Utility
        4. ptviewer and brickviewer
    2. 16. Beyond RSL: DSO Shadeops
      1. Need for RSL Plug-Ins
      2. Old-Style versus New-Style Plug-Ins
      3. Creating and Using DSO Shadeops
      4. Example Shadeops
      5. API Support
      6. Multithreading
    3. 17. Anti-aliasing
      1. The Problem of Aliasing
      2. Anti-aliasing via Increased Sampling
      3. Anti-aliasing Using Texture Lookup
      4. Anti-aliasing by Clamping High Frequencies
      5. Analytical Anti-aliasing