Paper Summaries • Any takers? The Renderman Shading Language Assignments Projects • Project feedback • Checkpoint 2 • Approx 22 projects – Graded – getting points back • Listing of projects now on Web • Checkpoint 3 • Presentation schedule – Due today – Presentations (15 min max) • Checkpoint 4 / RenderMan – Last 3 classes (week 10 + finals week) – To be given today – Sign up • Email me with 1 st , 2 nd , 3 rd choices • First come first served. Projects Motivational Films • Projects Mid-term report – due on web on Wed • Since we are talking about Renderman… April 15 th (next Wednesday) • Pixar Films – Final chance to change specification of what will be presented and turned in – Luxo, Jr. – The spec upon which project will be judged – Tin Toy – If no change from original proposal, simply say so. – Geri’s Game – Include explicit plans for presentation • ICL6 is available, we can project from there. • Need to know if other tools need to be installed. • Can also use other ICLs Pat Hanrahan 1
Computer Graphics as Virtual Photography Computer Graphics as Virtual Photography real camera photo Photographic real camera photo Photographic Photography: Photography: scene (captures processing print scene (captures processing print light) light) processing processing camera camera Computer 3D synthetic Computer 3D synthetic tone tone model model Graphics: models image Graphics: models image reproduction reproduction (focuses (focuses simulated simulated lighting) lighting) Renderman Shading Language Renderman Shading Language • Renderman consists of three parts: • Renderman Shading Language – Functional scene description mechanism (API for C) – Inspired by Cook’s shade trees Renderman is an Interface! – Goals • State Model Description – Maintains a current graphics state that can be placed onto a stack. • Abstract shading language based on ray optics, • Geometry is drawn by utilizing the current graphics state. independent of any specific algorithm or – File format - Renderman Interface Bytestream (RIB) implementation – Shading Language and Compiler. • Interface between rendering program and shading model • High level language that is easy to use. Renderman Shading Language Renderman Shading Language • Types of shaders • Unlike other shading languages, Rendeman allows for procedural definition of all types of light – Light source shaders - calculates the color of a transport, not just reflection light being emitted in given direction. – Light emission – Surface reflectance shaders - computes the light – Atmospheric effects reflected from a surface in a given direction – Reflection – Volume shaders - implements the effect of light – Transmission passing through a volume of space, i.e., exterior, – Transformations interior and atmospheric scattering effects. – Bump Mapping 2
Runtime architecture Renderman Shading Language • Types of Shaders – Displacement Shaders - perturb the surface of an Shader 1 Shader Shader / render link object “object” RenderMan file Shader 2 slc – Transformation Shaders - apply geometric Shader transformations to coordinates Shader 3 “object” Graphics file state – Imager Shader - post processing on image pixels. Shader “object” file • Note: Not all shaders need be available in an Rendering implementation! application Renderman Shading Language Solids Renderman Shading Language 3D Coordinate Systems Use CSG and hierarchical modeling to build models [ Renderman Companion , 60] [ Renderman Companion , 52] Renderman Shading Language Renderman Shading Language • Dataflow Model • Built in data types – float – string – color - 3 element vector. Several color spaces are supported. – point - 3D vector representing a point or vector in space. – Cannot add types [ Renderman Companion , 277] 3
Renderman Shading Language Renderman Shading Language • Features • Built in operations – C-like – Arithmetic, trigonometric, derivative – Declaration – not a function but a shader – Control (if-then-else, for, while, etc) – Instance variables (shader arguments) – Vector (dot product, cross product) – Local variables – Geometric (length, distance, etc.) – Global variables (e.g., for color and opacity for – Lighting (secular, diffuse, ambient, surfaces) illuminance) – No return type – Texture mapping functions • Shader modifies global graphic state variables Renderman Shading Language A note about SL functions Attaching shaders to object • Only one return statement allowed RiLightHandle RiLightSource (“name”, parameterlist); � • All arguments are pass by reference or LightHandle LightSource “name” parameterlist – However, not all are writeable - sets shader “name” to be the current light source shader • No separate compilation � RiSurface (“name”, parameterlist); or Surface “name” parameterlist – However can use #include - sets shader “name” to be the current surface shader. • Variable qualifiers � RiAtmosphere (“name”, parameterlist); or – output Atmosphere “name” parameterlist – extern - sets shader “name” to be the current atmosphere shader. – uniform – varying Light Shaders Light Shaders • Describes the directions, amounts, and colors of illumination distributed by a light source in a scene. • Will get called by surface shaders that “query” the scene for light sources. • May contain solar and illuminate calls. • Global variables – Ps – position of point on the surface being shaded – L – vector giving direction from the light source to the point being shaded (this vector will be used by surface shaders) – Cl – color of the energy emitted. Setting this variable is the purpose of a light shader. [ Renderman Companion , 277] 4
Light Shaders light ambientlight (float intensity = 1; color lightcolor = 1) Light Source { Shader Cl = intensity * lightcolor; globals L = 0; State } L is vector from light source to point being shaded Note: Up to programmer to accumulate results of reflectance computation [Hanrahan, 1990] Light Shaders Light Shaders light distantlight • L is not usually set explicitly, instead, L is ( float intensity = 1; usually set by auxiliary lighting functions: color lightcolor = 1; point from = point "camera" (0,0,0); – solar – directional distribution point to = point "camera" (0,0,1)) solar (vector axis, float spreadangle) { } { solar (to - from, 0.0) -- will set L to axis Cl = intensity * lightcolor; Coordinate system – Illuminate – point light distribution to convert to } • illuminate (point from) { } • Sets L to Ps - from Note: solar restricts illumination to a range of directions without specifying a position for the source. Light Shaders Light Shaders light pointlight ( float intensity = 1; • Another form of illuminate color lightcolor = 1; point from = point "camera" (0,0,0) – illuminate (point from, vector axis, float angle) ) • Will set L to Ps – from { Position of light source • Light only emitted within a cone (of a given illuminate (from) angle) around a given axis Cl = intensity * lightcolor / (L . L); } • Spotlights Distance 2 (dot product) Note: illuminate does expect a position for the light source. With no axis, angle, means it illuminates in all directions. 5
Light Shaders Light Shaders light spotlight ( float intensity = 1; Spotlight geometry color lightcolor = 1; point from = point "camera" (0,0,0); Instance point to = point "camera" (0,0,1); Variables float coneangle = radians(30); float conedeltaangle = radians(5); float beamdistribution = 2 ) { uniform point A = (to - from) / length (to - from); uniform float cosoutside = cos (coneangle); Local uniform float cosinside = cos (coneangle - conedeltaangle); Variables float atten, cosangle; illuminate (from, A, coneangle) { cosangle = (L . A) / length(L); atten = pow (cosangle, beamdistribution) / (L . L); atten *= smoothstep (cosoutside, cosinside, cosangle); Cl = atten * intensity * lightcolor ; } } NOTE: smoothstep( min, max, val) – 0, if val < min; otherwise a smooth Hermite [ Renderman Companion , 223] interpolation between 0 and 1 Light Shaders Light Shaders Barn door to control shape of beam Gobos to control shape of beam Surface Shaders Light Shaders Intensity Intensity distribution across distribution based beam on distance [Renderman Companion , 277] 6
Recommend
More recommend