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

final exam effects
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

1

Textures II

Procedural Textures

Final Exam effects

 Ground rules

 Teams of 2  GRAD students: responsible for research  Team: responsible for implementation and

documentation

 Implement in Cg or RenderMan

Final exam effects

 Deliverables:

 Research (Grads only)  Shader code  Documentation

 Describe shader params  Explain chosen implementation.  List constraints.  Give results.

Final exam effect

 Presentation:

 Final exam period

 Thursday, May 24th  12:30 - 2:30pm  ICL6

 15 minutes per presentation

 …and now the effects

Final exam effect

Light Saber, you will render

(Yoda not included) Research: Nick Kochakian Russell Morrissey

Final exam effect

 “I pity the fool”  Stained Glass

(Mr T not included)

 Research: Mike Dumont  Dan Willemsen

slide-2
SLIDE 2

2

Final exam effect

 Have a Coke and a

Smile

 Ansitropy  Textures  “frost” 

Research: Dan D’Errico

Brian Sullivan

Final exam effect

 And on the first day the

Lord said... L X 1, GO! and there was light.”

 Research: John Santino  Andrew McCartney

 See the UberLight!

Final exam effect

 Lord of the Donut

Ring

 Doug Hawkinson  Scott Murphee

See “Advanced Donut Rendering” http://graphics.stanford.edu/courses/cs348b- competition/cs348b-05/donut/index.html

Final exam effect

 TOON!

 Andrew Bair  Jarrod Begnoche  See X-Toon (on PAPERS

page)

Final Exam Effect

Toon or Smoke? What about Toon Smoke? David Huyhn Hao Yan See: http://graphics.cs.brown.edu/games/CartoonSmoke/index.html

Final exam effect

 Questions?

slide-3
SLIDE 3

3

Plan

 Textures II

 Procedural Textures

 1st half: tools and functions  2nd half: Revisiting the brick.

It’s all about the mapping

x y z geometry u v image screen

Texture pipeline

Akenine-Moller / Haines

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 ]  How you set up textures will determine how

  • ut or range values are mapped

 Cg: set up in OpenGL / DX  RenderMan: argument to txmake

It’s all about the mapping

 In order to provide this inverse

mapping, texture coordinates must be defined.

 Cg: set up in OpenGL / DX

 Explicitly (e.g. glTexCoord())  Automatically (e.g. gluQuadricObjs)

 Renderman: set of rules

 Based on primitive

RenderMan rules

 Bicubic patches

 [ s t ] --> [ u v ]

 Quadrics

 [ s t ] --> 2D parameterization of quadric

slide-4
SLIDE 4

4

RenderMan rules

 Polygon

 [s t] --> [ x y ] in object space  Causes problems for polygons

perpendicular to x,y plane. (as we saw in lab)

Consider…

surface mytex () { Ci = color "rgb" (s, t, 0); Oi = 1; } In RIB file: AttributeBegin

Surface "mytext" TransformBegin Polygon "P" [-5 -5 5 5 -5 5 5 -5 -5 -5 -5 -5 ] AttributeEnd

What you get

S > 1 |S| <1 S <0 T=-5

How to fix

 Redefine polygon in object space then

transform

AttributeBegin

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

  • 5 < S <5
  • 5 < T <5

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

slide-5
SLIDE 5

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.

Proceduralism vs. Stored Textures

 Strored textures

 Need to be captured  Has limited resolution  One of a kind  Takes lots of space

 Procedural textures

 Need to write code  Need to debug code  Need to run code (may take time)  aliasing

Texture modulation

 Repeating patterns

 FP mod function -- returns floating point

remainder of x / y

 mod (x, y) -- RenderMan  fmod (x, y) -- Cg

Simple checkerboard

smod = mod (s * freq, 1); tmod = mod (t * freq, 1); if (smod < 0.5) if (tmod < 0.5) color = green else color = yellow; else if (tmod < 0.5) color = yellow else color = green

0 ≥ s ≥ 1 0 ≥ t ≥ 1

smod < 0.5 tmod < 0.5 smod > 0.5 tmod < 0.5 smod > 0.5 tmod < 0.5 smod > 0.5 tmod > 0.5

Layering

 Placing one texture on top of another.  Allows you to build textures up a bit at a

time

 Mixing layers:

 mix (C0, C1, f)

 F between 1 and 0  Returns (1-f)C0 + f*C1

slide-6
SLIDE 6

6 Steps, Clamps, and Conditionals

 step (a, x)

 Returns (x >= a)

 Quick and dirty if statement

 C = mix (c0, c1, step (0.5, u))

Steps, Clamps, and Conditionals

 clamp (x, mn, mx)

 Clamps a value between 2 extremes

Steps, Clamps, and Conditionals

 Smoothstep (a, b, x)

 Smooth stepping function

 0 if x < a  1 if x > b  Spline if between 0 and 1

Periodic functions

 To form repeating patterns

 sin, cos  Greater frequency -- more detail

Periodic functions

 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

Spectral Synthesis

slide-7
SLIDE 7

7

Noise

 What is noise

 Random signal with rich frequency

distribution

 Types of noise:

 White – uniform frequency  Pink – filtered  Gaussian – based on Gaussian distribution

 None appropriate for shader use

Noise

 Perlin on noise:

 “Noise appears random but it is not. If it were really random,

then you’d get a different result each time you call it. Instead it is “pseudo-random” – it gives the appearance of randomness”

 “Noise is a mapping from Rn→ R – you input an n-

dimensional point with real coordinates and it gives you a 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.”

Noise

 Repeatable  Known range [0, 1]

 Note original Perlin noise returns [-1 1]

 Band limited / scalable  Doesn’t exhibit obvious periodicities  Statistically invariant under translation  Statistically invariant under rotation

Noise

 Noise parameters

 noise (float) -- 1D noise  noise (float, float) -- 2D noise  noise (point) -- 3D noise  noise (point, float) -- 4D noise

 In Cg

 noise (x) -- depends upon type of x (float,

float2, float3, float4).

Noise in RenderMan

 Noise variants:

 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.

Noise as a sin substitute

 Noise resembles a sin wave but with

“random” bumps:

slide-8
SLIDE 8

8

Spectral Synthesis with noise

Paul Burke, 2000

Procedural Shading – Perlin Noise

Sum

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;.

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) value += abs (snoise (P * f)) / f; return value;.

fBm / Turbulence

fBm turbulence

Questions?

 Break

slide-9
SLIDE 9

9

Example: Building a Brick Shader

 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

Brick parameters -- 1st pass

 Brickcolor -- color of the brick  Mortarcolor -- color of the mortar  Brickwidth -- width of the brick (in s

coords)

 Brickheight -- height of the brick (in t

coords)

 Mortarthickness (in st space)

Brick coordinate system

BRICKWIDTH BRICKHEIGHT MORTARTHICKNESS

1 1

Step 1 -- Brick coloring

 Conversion from st to ss/tt

ss = s / (bWidth + mThickness); tt = t / (bHeight + mThickness);

 Shift every other row half a brick

if (mod (tt*0.5, 1) > 0.5) ss += 0.5;

Step 1 -- Brick coloring

 Find out which brick we are in and

subtract that off to get a point on that brick

sbrick = floor (ss); tbrick = floor(tt); ss -= sbrick; tt -= tbrick

Step 1 -- Brick coloring

 At this point we are in [0 1] of brick

space

 Are we in brick or mortar? if ((ss < mThickness) || (tt < mThickness)) Ci = mColor; else Ci = bColor;

slide-10
SLIDE 10

10

Step 2 -- Groove the mortar

 Use simple bump mapping to achieve a

“grooved” look.

 Bump mapping should be peformed in object

space

 Must use a illumination model that depends on N  Good use of smoothstep

float stbump = …calculate bump point Psh = transform (“shader”, P); normal Nsh = ntransform (“shader”, N); Nsh = calculatenormal (Psh + Nsh * stbump); Normal Nf = ntransform (“shader”, “current”, Nsh); Nf = normalize (Nf); // use in Phong

Step 3 - Add grain to bricks

 Bump map the brick surface using noise.

 Noise should be applied in object space if based

  • n point

 Bump mapping should be performed in object

space.

point Psh = transform (“shader”, P); float amp = 0.8; // amount of bump float freq = 20.0; // detail of grain float stbump = amp * noise (freq * Psh);

Step 4 - variable brick colors

 Vary the brick color…based on brick

 Use noise again.  Noise based on brick number

color Ct = bColor; color Cmod = color (1.0, 0.0, 0.0); Ct -= (Cmod * cellnoise(sbrick, tbrick));

Step 5 -- Variable color within individual bricks

 Keep the noise coming.  This time modify color based on noise.  Noise keyed off of s/t or point.

Ct += noise (freq * Psh);

Building an even better brick shader

Olano, 1998, http://www.cs.unc.edu/~olano/papers/dissertation/ plain Grooved mortar grain Different colored bricks Different colors within bricks

My attempt at RIT brick

slide-11
SLIDE 11

11

Questions For next time

 Thursday: Texture II Lab

 Procedural Textures

 Next week:

 Lighting