final exam effects
play

Final Exam effects Ground rules Textures II Teams of 2 GRAD - PDF document

Final Exam effects Ground rules Textures II Teams of 2 GRAD students: responsible for research Team: responsible for implementation and Procedural Textures documentation Implement in Cg or RenderMan Final exam effects Final


  1. Final Exam effects  Ground rules Textures II  Teams of 2  GRAD students: responsible for research  Team: responsible for implementation and Procedural Textures documentation  Implement in Cg or RenderMan Final exam effects Final exam effect  Deliverables:  Presentation:  Research (Grads only)  Final exam period  Shader code  Thursday, May 24th  Documentation  12:30 - 2:30pm  Describe shader params  ICL6  Explain chosen implementation.  15 minutes per presentation  List constraints.  Give results.  …and now the effects Final exam effect Final exam effect  “I pity the fool” Light Saber, you will render (Yoda not included)  Stained Glass (Mr T not included)  Research: Nick Kochakian Russell Morrissey  Research: Mike Dumont  Dan Willemsen 1

  2. Final exam effect Final exam effect  Have a Coke and a  And on the first day the Smile Lord said... L X 1, GO!  Ansitropy and there was light.”  Textures  “frost”  Research: John Santino  Andrew McCartney Research: Dan D’Errico  Brian Sullivan   See the UberLight! Final exam effect Final exam effect  Lord of the Donut  TOON! Ring  Andrew Bair  Doug Hawkinson  Jarrod Begnoche  Scott Murphee See “Advanced Donut Rendering”  See X-Toon (on PAPERS page) http://graphics.stanford.edu/courses/cs348b- competition/cs348b-05/donut/index.html Final Exam Effect Final exam effect  Questions? Toon or Smoke? What about Toon Smoke? David Huyhn Hao Yan See: http://graphics.cs.brown.edu/games/CartoonSmoke/index.html 2

  3. Plan It’s all about the mapping  Textures II y  Procedural Textures  1st half: tools and functions z x screen geometry  2nd half: Revisiting the brick. v image u Texture pipeline It’s all about the mapping  In shaders  [s, t] --> [ x y z ]  s, t range from 0 - 1  Shaders provide [ x y z ] --> [ s t ] Akenine-Moller / Haines  How you set up textures will determine how out or range values are mapped  Cg: set up in OpenGL / DX  RenderMan: argument to txmake It’s all about the mapping RenderMan rules  In order to provide this inverse  Bicubic patches mapping, texture coordinates must be  [ s t ] --> [ u v ] defined.  Quadrics  Cg: set up in OpenGL / DX  [ s t ] --> 2D parameterization of quadric  Explicitly (e.g. glTexCoord())  Automatically (e.g. gluQuadricObjs)  Renderman: set of rules  Based on primitive 3

  4. RenderMan rules Consider…  Polygon surface mytex () { Ci = color "rgb" (s, t, 0); Oi = 1; }  [s t] --> [ x y ] in object space  Causes problems for polygons In RIB file: perpendicular to x,y plane. (as we saw in AttributeBegin lab) Surface "mytext" TransformBegin Polygon "P" [-5 -5 5 5 -5 5 5 -5 -5 -5 -5 -5 ] AttributeEnd What you get How to fix  Redefine polygon in object space then transform S <0 |S| <1 S > 1 AttributeBegin T=-5 Surface "mytext" TransformBegin Rotate 90 1 0 0 Translate 0 2.5 0 Polygon "P" [-5 -5 0 5 -5 0 5 5 0 -5 5 0] TransformEnd AttributeEnd Results To get texture between 0 - 1  Redefine polygon in object space then -5 < S <5 transform…you can scale too AttributeBegin Surface "mytext" -5 < T <5 TransformBegin Rotate 90 1 0 0 Translate -5 0 1.25 Scale 10 10 10 Polygon "P" [ 0 0 0 1 0 0 1 1 0 0 1 0 ] TransformEnd AttributeEnd 4

  5. To get texture between 0 - 1 Procedural Textures  s and t will be calculated regardless if a texture is read / used  Can use this to construct textures on the fly.  Only calculate for sample points when needed. Texture modulation Proceduralism vs. Stored Textures  Strored textures  Repeating patterns  Need to be captured  FP mod function -- returns floating point  Has limited resolution remainder of x / y  One of a kind  mod (x, y) -- RenderMan  Takes lots of space  fmod (x, y) -- Cg  Procedural textures  Need to write code  Need to debug code  Need to run code (may take time)  aliasing Simple checkerboard Layering 0 ≥ s ≥ 1  Placing one texture on top of another. smod = mod (s * freq, 1); smod < 0.5 smod > 0.5  Allows you to build textures up a bit at a tmod < 0.5 tmod < 0.5 tmod = mod (t * freq, 1); time smod > 0.5 smod > 0.5 if (smod < 0.5)  Mixing layers: tmod < 0.5 tmod > 0.5 0 ≥ t ≥ 1 if (tmod < 0.5) color = green  mix (C0, C1, f) else color = yellow;  F between 1 and 0  Returns (1-f)C0 + f*C1 else if (tmod < 0.5) color = yellow else color = green 5

  6. Steps, Clamps, and Conditionals Steps, Clamps, and Conditionals  clamp (x, mn, mx)  step (a, x)  Returns (x >= a)  Clamps a value between 2 extremes  Quick and dirty if statement  C = mix (c0, c1, step (0.5, u)) Periodic functions Steps, Clamps, and Conditionals  Smoothstep (a, b, x)  To form repeating patterns  Smooth stepping function  sin, cos  0 if x < a  Greater frequency -- more detail  1 if x > b  Spline if between 0 and 1 Periodic functions Spectral Synthesis  mod can be used to construct periodic functions.  If f(x) is a function defined on [0, p] then  f (mod(x,p)) will give a periodic version of f 6

  7. Noise Noise  What is noise  Perlin on noise:  “Noise appears random but it is not. If it were really random,  Random signal with rich frequency then you’d get a different result each time you call it. Instead distribution it is “pseudo-random” – it gives the appearance of  Types of noise: randomness”  White – uniform frequency  “Noise is a mapping from R n → R – you input an n-  Pink – filtered dimensional point with real coordinates and it gives you a  Gaussian – based on Gaussian distribution real value. Currently, the most common uses is for n=1, 2, and 3. The first is used for animation, the second for cheap  None appropriate for shader use texture hacks, and the third for less-cheap texture hacks.” Noise Noise  Repeatable  Noise parameters  Known range [0, 1]  noise (float) -- 1D noise  noise (float, float) -- 2D noise  Note original Perlin noise returns [-1 1]  noise (point) -- 3D noise  Band limited / scalable  noise (point, float) -- 4D noise  Doesn’t exhibit obvious periodicities  In Cg  Statistically invariant under translation  noise (x) -- depends upon type of x (float,  Statistically invariant under rotation float2, float3, float4). Noise in RenderMan Noise as a sin substitute  Noise variants:  Noise resembles a sin wave but with “random” bumps:  noise -- variant of Perlin noise  Tends to hover about [0.3, 0.7]  snoise - signed noise  Range of [-1 1]….#defined.  cellnoise -- for pseudorandom discrete values  Does NOT hover around 0.5  pnoise -- perioidic noise  Repeats about some period. 7

  8. Procedural Shading – Perlin Noise Spectral Synthesis with noise Paul Burke, 2000 Sum fBm / Turbulence fBm / Turbulence  fBm -- fractional Brownian motion.  Turbulence  1/f noise  Like fBm but absolute value of noise is summed  Sum of noise functions  Both are useful for “natural” effects  Contribution of each is proportional to the inverse of the frequency float value = 0; float value = 0; for (f = MINFREQ; f < MAXFREQ; f *=2) for (f = MINFREQ; f < MAXFREQ; f *=2) value += abs (snoise (P * f)) / f; value += snoise (P * f) / f; return value;. return value;. fBm / Turbulence Questions?  Break fBm turbulence 8

  9. Example: Building a Brick Shader Brick parameters -- 1st pass  Brick shader will be defined as a  Brickcolor -- color of the brick procedural texture that is mapped onto  Mortarcolor -- color of the mortar a surface  Brickwidth -- width of the brick (in s coords)  Build texture in stages  Brickheight -- height of the brick (in t  Coordinate system coords)  s, t texture coords from renderer  Mortarthickness (in st space)  ss, tt coordinate system of the brick Brick coordinate system Step 1 -- Brick coloring  Conversion from st to ss/tt 1 MORTARTHICKNESS ss = s / (bWidth + mThickness); tt = t / (bHeight + mThickness); BRICKHEIGHT BRICKWIDTH  Shift every other row half a brick if (mod (tt*0.5, 1) > 0.5) 1 0 ss += 0.5; Step 1 -- Brick coloring Step 1 -- Brick coloring  Find out which brick we are in and  At this point we are in [0 1] of brick subtract that off to get a point on that space brick  Are we in brick or mortar? sbrick = floor (ss); if ((ss < mThickness) || (tt < mThickness)) tbrick = floor(tt); Ci = mColor; else ss -= sbrick; Ci = bColor; tt -= tbrick 9

Recommend


More recommend