Final Exam effects Ground rules Textures II Teams of 2/3 GRAD students: responsible for research Team: responsible for implementation and documentation Procedural Textures Implement in GLSL and RenderMan (for teams of 3) Implement in GLSL or RenderMan (for teams of 2) Final exam effects Final exam effect Deliverables: Presentation: Research (Grads only) Final exam period Shader code Monday, May 19th Documentation 12:30 - 2:30pm Describe shader params ICL5 Explain chosen implementation. 15 minutes per presentation List constraints. Give results. …and now the effects Final exam effect Final exam effect Strawberry Fields Forever Bright Lights, Big City (Neon) (Beatles not included) (Martini not included) Research: Abhishek Moothedath John Smith Research: Tim Peterson Steve Sarnelle Andrew Fabiny Dan Wisnewski 1
Final Exam Effect Final exam effect Made from the Best Stuff on Where’s the Ocean? Earth (JAWS not included) (Silly Factioids in the cap not included) Research: Abhijit Bhelande Research: Mike Allyger Jeff Herdman Adam Linderman Final Exam Effect Final exam effect CD / DVD Monet’s Pallette (music not included) (Giverny not included) Research: Jacob Hays Research: Rodrigo Urra Carl Loutin Andrew Ford Matt Penepent Final exam effect Final exam effect Having My Picture Questions? Taken (Job at Kodak not included) Research: Rohan Mehalwal Peter Kaszubinski Old Black and White or Glorious Technicolor 2
About Lab 3 Plan RenderMan only Textures II DevIL is on it’s way to getting installed. Procedural Textures 1st half: tools and functions Should understand texture space in 2nd half: Revisiting the brick. GLSL. It’s all about the mapping Texture pipeline y z x screen geometry Akenine-Moller / Haines v image u It’s all about the mapping It’s all about the mapping In order to provide this inverse In shaders mapping, texture coordinates must be [s, t] --> [ x y z ] defined. s, t range from 0 - 1 GLSL: set up in OpenGL Shaders provide [ x y z ] --> [ s t ] Explicitly (e.g. glTexCoord()) How you set up textures will determine how Automatically (e.g. gluQuadricObjs) out or range values are mapped Renderman: set of rules GLSL: set up in OpenGL Based on primitive RenderMan: argument to txmake 3
RenderMan rules RenderMan rules Bicubic patches Polygon [ s t ] --> [ u v ] [s t] --> [ x y ] in object space Quadrics Causes problems for polygons perpendicular to x,y plane. [ s t ] --> 2D parameterization of quadric Consider… What you get surface mytex () { Ci = color "rgb" (s, t, 0); Oi = 1; } S <0 |S| <1 S > 1 In RIB file: T=-5 AttributeBegin Surface "mytext" TransformBegin Polygon "P" [-5 -5 5 5 -5 5 5 -5 -5 -5 -5 -5 ] AttributeEnd Looking down at the floor How to fix Results Redefine polygon in object space then -5 < S <5 transform AttributeBegin Surface "mytext" -5 < T <5 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 4
To get texture between 0 - 1 To get texture between 0 - 1 Redefine polygon in object space then transform…you can scale too AttributeBegin Surface "mytext" 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 Procedural Textures Proceduralism vs. Stored Textures s and t will be calculated regardless if a Strored textures Need to be captured texture is read / used Has limited resolution Can use this to construct textures on One of a kind the fly. Takes lots of space Procedural textures Only calculate for sample points when Need to write code needed. Need to debug code Need to run code (may take time) aliasing Texture modulation Simple checkerboard 0 ≥ s ≥ 1 Repeating patterns smod = mod (s * freq, 1); FP mod function -- returns floating point smod < 0.5 smod > 0.5 tmod < 0.5 tmod < 0.5 remainder of x / y tmod = mod (t * freq, 1); smod > 0.5 smod > 0.5 mod (x, y) -- RenderMan if (smod < 0.5) tmod < 0.5 tmod > 0.5 0 ≥ t ≥ 1 mod (x, y) -- GLSL (float, vec234 versions) if (tmod < 0.5) color = green else color = yellow; else if (tmod < 0.5) color = yellow else color = green 5
Simple checkerboard -- freq Layering Placing one texture on top of another. Allows you to build textures up a bit at a time Mixing layers: Freq = 2 Freq = 1 mix (C0, C1, f) F between 1 and 0 Returns (1-f)C0 + f*C1 Freq = 3 Freq = 4 Steps, Clamps, and Conditionals Steps, Clamps, and Conditionals step (a, x) clamp (x, mn, mx) 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 6
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 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 Noise parameters Repeatable noise (float) -- 1D noise Known range [0, 1] 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[1234] (x) -- x can be (float, vec2, Statistically invariant under rotation vec3, vec4). 7
Noise in RenderMan Noise in GLSL Using noise in shaders Noise variants: noise -- variant of Perlin noise Use the built in noise function (if your card Tends to hover about [0.3, 0.7] supports it!) snoise - signed noise Write your own noise function in GLSL Range of [-1 1]….#defined. Calculate noise in OpenGL code and pass cellnoise -- for pseudorandom discrete values to shader as a 3D texture. Does NOT hover around 0.5 pnoise -- perioidic noise Repeats about some period. Noise in GLSL Noise in GLSL Why not just use the noise function? Then we should always use a texture, right? Well…. Your hardware may not support it! Consumes texture memory You may not like the noise your hardware gives you Uses a texture unit Accessing a texture map may be faster Sampling issues than calling noise. Obviously repeated You have to set it up in OpenGL Noise as a sin substitute Spectral Synthesis with noise Noise resembles a sin wave but with “random” bumps: 8
Procedural Shading – Perlin Noise fBm / Turbulence fBm -- fractional Brownian motion. 1/f noise Sum of noise functions Contribution of each is proportional to the inverse of the frequency float value = 0; for (f = MINFREQ; f < MAXFREQ; f *=2) value += snoise (P * f) / f; return value;. Paul Burke, 2000 Sum fBm / Turbulence fBm / Turbulence Turbulence Like fBm but absolute value of noise is summed Both are useful for “natural” effects float value = 0; for (f = MINFREQ; f < MAXFREQ; f *=2) fBm turbulence value += abs (snoise (P * f)) / f; return value;. Example: Building a Brick Questions? Shader Break Brick shader will be defined as a procedural texture that is mapped onto a surface Build texture in stages Coordinate system s, t texture coords from renderer ss, tt coordinate system of the brick 9
Recommend
More recommend