1st Edition

Shader Writing in Open Shading Language With RenderMan® Examples

By Mitch J. Prater Copyright 2025
    238 Pages 116 Color & 40 B/W Illustrations
    by CRC Press

    238 Pages 116 Color & 40 B/W Illustrations
    by CRC Press

    Incorporating both historical techniques and the most recent developments in computer graphics, Shader Writing in Open Shading Language is a treatise on OSL shader writing and shader development that intends to remedy the current lack of material on this important area of technical and artistic expertise. It is for artists who wish to know more about shaders and shader writing, for programmers who want the ultimate in creative control, or for anyone in‑between.

    It begins by covering the entire range of independent variables upon which all shaded pattern generation is based. From that foundation, every fundamental procedural, textural, conversion, and pattern modification shader category is described with clear and practical examples.

    Each topic is presented in a progression of chapters that begin with the fundamentals and expand to more complex shaders illustrating more advanced techniques that build on the previously covered material.

    In addition, these important topics are also covered:

    • Shader user interface design and parameter widgets
    • Color, color models, color spaces, and color transformations
    • 2d and 3d spaces and their transformations
    • Texture patterns
    • Ray tracing for pattern generation
    • Displacement and bumped shading normal generation
    • Shader organization, building, and deployment
    • Shader execution and debugging


    1. Introduction

    2. Variables

                    2.1 Data Types

                    2.2 Compound Types

                                    2.2.1 Arrays

                                    2.2.2 Structs

                    2.3 Global

                    2.4 Built In

                    2.5 Primitive

                                    2.5.1 Parameter Access

                                    2.5.2 getattribute() Access

                    2.6 Options and Attributes

                                    2.6.1 OSL Attributes

                                    2.6.2 RenderMan Options and Attributes

                                    2.6.3 User Attributes

                    2.7 Example Shaders

                                    2.7.1 Global Variables

                                    2.7.2 Built-In Variables

                                    2.7.3 Primitive Variables

    3. Coordinate Systems

    4. Conversion Shaders

                    4.1 Simple Types

                                    4.1.1 Float to Color

                                    4.1.2 Color to Float

                                    4.1.3 Type Connections

                    4.2 Artistic to Physical

                                    4.2.1 Base Color and Metallic to Specular Face and Edge Colors

                                    4.2.2 Specular Face and Edge Colors to Complex Refractive Index

    5. Color

                    5.1 Color Models

                                    5.1.1 RGB

                                    5.1.2 HSV & HSL

                                    5.1.3 CMYK

                                    5.1.4 Spectral

                    5.2 Color Spaces

                                    5.2.1 CIE 1931 XYZ

                                    5.2.2 xyY

                                    5.2.3 Television Standards

                                    5.2.4 Web Standard

                                    5.2.5 Academy Standards

                    5.3 Color Space Conversions

                                    5.3.1 sRGB to Rec. 709

                                    5.3.2 Rec. 709 to ACEScg

                                    5.3.2 sRGB to ACEScg

    6. Spaces and Transformations

                    5.1 2D Space

                    5.2 3D Space

                    5.3 2D Transform

                    5.2 3D Transform

    7. Texture Patterns

                    7.1 File Names

                                    7.1.1 String Functions

                                    7.1.2 Tokens

                    7.2 t Inversion

                    7.3 Metadata

                    7.4 Data Access

                    7.5 Projections

                                    7.5.1 Orthographic

                                    7.5.2 Shear

                                    7.5.3 Spherical

                                    7.5.4 NDC

                                    7.5.5 Rounded Cube

    8. Procedural Patterns

                    8.1 Spatial Conversion

                                    8.1.1 Sawtooth

                                    8.1.2 Triangle

                                    8.1.3 Sine and Cosine

                                    8.1.4 Square

                                    8.1.5 Smoothstep

                                    8.1.6 Float and Gray Outputs

                    8.2 Noise

                    8.3 Cellular

                                    8.3.1 Tessellation

                                    8.3.2 Worley

                    8.4 Spatial Warping

                    8.5 Fractals

                                    8.5.1 Distortion

                    8.6 Ray Tracing

    9. Signal Modification

                    9.1 Contrast

                                    9.1.1 Average Value Interpolation

                                    9.1.2 Range Remapping

                                    9.1.3 Redistribution

                    9.2 Creasing

                    9.3 Skew

                    9.4 Range Clamping

                    9.5 Combining

                                    9.5.1 Binary Operators

                                    9.5.2 Weighted Mixing

                                    9.5.3 Layering

                                    9.5.4 Patterned Transitions

    10. Displacement and Bumping

                    10.1 Common Space

                    10.2 Displacement

                                    10.2.1 Height Patterns

                                    10.2.2 Vector Patterns

                                    10.2.3 Cascading Height Displacements

                                    10.2.4 Geometry Inversion

                    10.3 Bumping

                                    10.3.1 Vertex Shading Normals

                                    10.3.2 BxDF Normal Orientation

                                    10.3.3 Bump Conversion Shader

    11. Shader Execution

                    11.1 JIT Optimization

                    11.2 Strings and Filenames

                    11.3 Displacement and BxDF Shading Phases

                                    11.3.1 Micropolygon Dicing

                                    11.3.2 Common Space

                                    11.3.3 Surface Variables

                                    11.3.4 "Original" Surface Variables

                                    11.3.5 Ray Tracing

                    11.4 Differentiation

    12. Interface Design

                    12.1 Naming

                    12.2 Metadata

                    12.3 Widgets

                                    12.3.1 checkbox

                                    12.3.2 mapper

                                    12.3.3 popup

                                    12.3.4 slider

                                    12.3.5 string

                                    12.3.6 color

                    12.4 Types and Connections

                    12.5 Help Content

    13. Development, Deployment, and Debugging

                    13.1 Source File Organization

                    13.2 Build System

                    13.3 Debugging

                                    13.3.1 IT

                                    13.3.2 printf()

                                    13.3.3 The .rib File




    Mitch Prater's interest in graphics began at age 12 when he set out to build his own "Pong" game based on an article in Popular Electronics magazine. Mitch graduated from hardware to software implementations with Fortran IV programmed on punch cards and a line-printer for output. Through the 1980's and 1990's he progressed through CRT terminals, dedicated graphics hardware, integrated GPU chips, graphics libraries, and finally into rendering systems with dedicated shading languages when in 1988 he began working at Pixar using the Pixar Image Computer and was introduced to the 1.0 alpha version of RenderMan. From there Mitch wrote shaders and created new shading and lighting techniques for use in Pixar's commercials, short films, and all the features from Toy Story to Cars; and then again from ParaNorman to Missing Link at Laika. Throughout a career that now spans nearly 40 years, Mitch Prater continuously developed new shading and lighting techniques, shader code libraries, and production shaders for feature films, animated shorts, and real-time games.