the 2 nd half
play

The 2 nd half Cooks Shade Trees Procedural Shading Ken Perlin: - PDF document

The 2 nd half Cooks Shade Trees Procedural Shading Ken Perlin: PSE and Noise Shader Languages Shading Procedural Shading Shading (and/or texture) determined by a So far we have considered: function BRDFs Shading


  1. The 2 nd half • Cook’s Shade Trees Procedural Shading • Ken Perlin: PSE and Noise • Shader Languages Shading Procedural Shading Shading (and/or texture) determined by a • So far we have considered: function – BRDFs – Shading & Illumination Models Advantages Disadvantages – Texture Maps • Compact • Programming=> • Today we start to look at shaders that handle shading debugging • Resolution Independent (and texturing) procedurally • Unpredictable results • Unlimited Extent – Surface characteristics are defined by a function • Time vs. space tradeoff • Parameterizable -> class • Shading model – simulates behavior of surface material w.r.t. (can take a long time) diffuse and specular reflection of textures • Pattern generation - texture pattern and sets surface property values Shade Trees [Cook84] Shade Trees [Cook84] • Shading calculated by combining basic functional • First procedural shading system operations using appearance parameters • Allowed use of different shading model for each • Operations are organized in a tree (directed acyclic surface as well as light sources and atmospheric graph). considerations, i.e., light and atmosphere trees – Nodes – Operations • Traditional shading techniques could be combined • Uses zero or more appearance parameters as input • Handled complexity and simplicity in same image • Produces one or more appearance parameters as output – Color and transparency – Children – operands – basic geometric info: normals, location, etc. – Textures • Result of shade tree evaluation is a color – Reflection mapping – Displacement mapping • Evaluating equivalent to parsing tree (post order - – Solid texturing compiler design) 1

  2. Procedural Shading – Shade Trees Procedural Shading – Shade Trees • Basic operations include – Vector operations (normalize, dot product / cross product) – Arithmetic operations – Interpolation / “mix” – stochastic functions – Variables (points in eye or world) – Expandable dynamically • Basis for Renderman Shading Language [Cook84] Procedural Shading – Shade Trees Procedural Shading – Shade Trees • Shade trees - Phong model • Shade Trees - example…copper + ambient diffuse specular k a k d S N k s R V k e ∑ ∑ = + • + • k L ( V ) k L k L ( S N) k L ( R V) e a a d i i s i i i i ambient diffuse specular [Cook84] Procedural Shading – Shade Trees Procedural Shading – Shade Trees Shade trees - example code: for “metal” shade tree • Shade trees – “mix” uses one of inputs to interpolate between the other two Built into language Surface Command – designates shade tree for object (overrides default values) [Cook84] [Cook84] 2

  3. Procedural Shading – Shade Trees Procedural Shading – Shade Trees • Effectively using shade trees is more of an art • Are parameterizable than a science. • Have access to “important” attributes of the point in question – Normals, viewer vector, light vectors • Can be functionally combined – Output of one shade tree can be input to another by attaching as a branch – Nothing more that a parse tree for a function – Functional Programming (LISP) [Cook84] Perlin’s Pixel Stream Procedural Shading – Perlin’s PSE Editor (PSE) • Example Variable related to input image; others point, normal • Attempt to create a language around functional shade generation if surface == 1 – C like language color = [1 0 0] * max(0.1, dot(normal,[1 0 0]) color normal – Included control structures else color = [0 0 0.1] • Originally designed to work on pixels of an image as a postprocessor Produces diffusely shaded red object lit from positive x – Input image -> PSE (filter) -> output image direction on a dark blue background. – Input image has variable list: surface identifiers, point – location, normal, etc. Procedural Shading – Perlin’s PSE Procedural Shading – Perlin’s PSE • Any space function can be thought of as representing a • But the biggest contribution from the PSE was solid material – THE NOISE • If evaluated at visible surface points, get sculpture! – Shape and texture independent For, tomorrow, he knew, all the Who girls – Small code! and boys Would wake bright and early. They'd rush for • PSE programs are evaluated in 3D space to produce their toys! And then! Oh, the noise! Oh, the noise! such solid textures Oh, the Noise! Noise! Noise! Noise! That's one thing he hated! The NOISE! – Knowledge of x,y,z coordinates NOISE! NOISE! NOISE! – Knowledge of important “vectors” at surface How the Grinch Stole Christmas 3

  4. Procedural Shading – Perlin Noise Procedural Shading – Perlin Noise • What is noise • Observation: – Random signal with rich frequency distribution – Most things in the world have some sort of – Applet random or stochastic component to them http://graphics.lcs.mit.edu/~legakis/MarbleApplet/marbleapplet.html – A procedural shading system requires the use of – Types of noise: randomness (“noise”) for realism. • White – uniform frequency – Need more than simple random number • Pink – filtered generator. • Gaussian – based on Gaussian distribution – None appropriate for shader use Procedural Shading – Perlin Noise Procedural Shading-Noise Properties • Repeatable • Perlin on noise: – “Noise appears random but it is not. If it were really • Known range [-1, 1] random, then you’d get a different result each time you call • Band limited / scalable it. Instead it is “pseudo-random” – it gives the appearance of randomness” • Doesn’t exhibit obvious periodicities – “Noise is a mapping from R n → R – you input an n- • Statistically invariant under translation dimensional point with real coordinates and it gives you a • Statistically invariant under rotation real value. Currently, the most common uses is for n=1, 2, and 3. The first is used for animation, the second for cheap texture hacks, and the third for less-cheap texture hacks.” Procedural Shading-Perlin Noise Procedural Shading-Perlin Noise • “Controlled” Noise function • Controllable random number generator – White noise = noise at all frequencies • Emphasized importance of stochastic functions – Control the frequency of the noise used in texture design – e.g. noise (2x) will contain twice as much • Very efficient in time and space frequency (detail) as noise(x) • Implemented as a basic operation in the MMX chipset and other graphics hardware • Won Ken an Academy Award 4

  5. Procedural Shading-Perlin Noise Procedural Shading-Perlin Noise • Noise frequency and detail • Perlin Noise – Returns a scalar value between -1 and 1 – takes a 3d vector as an argument – float noise3 (float [3] vec) Procedural Shading-Perlin Noise Procedural Shading-Perlin Noise • 3D lattice (3D array) with 4 pseudorandom real • Perlin noise - Lattice numbers per point in the array • for each point (x 0 ,y 0 ,z 0 ) we assign a set of 4 pseudorandom numbers (a, b, c, d). • Compute d’ = d - (ax 0 +by 0 +cz 0 ) • noise (x,y,z) – if (x, y, z) is on the lattice, noise (x,y,z) = d – if (x,y,z) is NOT on the lattice, the values of (a,b,c,d) are interpolated from the (a,b,c,d) values of neighboring lattice points. Then noise(x,y,z) = ax + bx +cz +d’ using the interpolated (a,b,c,d) Procedural Shading – Perlin Noise Procedural Shading-Perlin Noise Increasing harmonics of 1-D Perlin noise • Perlin has further optimized using look up tables • Complete “C” code (approx 150 lines) on Web at: – http://mrl.nyu.edu/~perlin/doc/oscar.html#noise • Perlin has since revised the basic noise algorithm in order for efficiency, functionality, and ease of hardware implementation. • Perlin has since applied same paradigm to: • Solid Modeling Sum of 1 st 8 harmonics • Animation / Gesturing Paul Burke, 2000 5

  6. Procedural Shading – Perlin Noise Procedural Shading-Perlin Noise • Example 1 – Spotted Donut -No detail outside certain size range [Perlin85] Color = white * noise (point) Paul Burke, 2000 Sum Vector Procedural Shading-Perlin Noise Procedural Shading-Perlin Noise • Example 2 – Bozo’s Donut • Dnoise – Vector valued differential of noise signal, i.e., gradiant/derivative of noise function • Dnoise (x,y,z) = (dNoise/dx, dNoise/dy, dNoise/dz) • Good for modifying normal vector (bump [Perlin85] mapping) Color = Colorful(noise (k*point)) Constant multiplier Creating Wrinkles Procedural Shading-Perlin Noise • Adding successive noise at different but • Dnoise example – Bumpy Donut regular frequencies • 1/f, self-similar quality (Fractal-like…more on fractals later) i x = i N-1 ∑ Noise( b ) = NOISE( x ) i [Perlin85] a = i 0 Normal += Dnoise (point) 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend