3. CS 354 3
My Office Hours
Tuesday, before class
Painter (PAI) 5.35
8:45 a.m. to 9:15
Thursday, after class
ACE 6.302
11:00 a.m. to 12
Randy’s office hours
Monday & Wednesday
11 a.m. to 12:00
Painter (PAI) 5.33
4. CS 354 4
Last time, this time
Last lecture, we discussed
Project 2 on Programmable Shaders
Interaction
Event models
Buffering frames
This lecture
Project 2 discussion
Procedural methods for texturing and modeling
Intermediate milestone for Project 2 due
Had to first 2 shader tasks done
Deadline was yesterday
All shaders due Friday, April 6th
5. CS 354 5
On a sheet of paper
Daily Quiz • Write your EID, name, and date
• Write #1, #2, #3, #4 followed by its answer
Multiple choice: Which one of True or False: Tearing is a
these is not an interactive event display artifact that results
processing model? from unsynchronized buffer
swap or blit operations.
a) Batching
b) Polling
Multiple choice: Triple
buffering can improve display
c) Event-driven update latency but suffers
from:
True or False: GLUT a) Requiring additional buffer
programs receive events memory
through callback functions.
b) May render frames that
are never actually displayed
c) Both a) and b)
d) Neither a) nor b)
6. CS 354 6
Project 2
Project is NOW available
PDF + code to use
Requirements
Mostly writing GLSL shaders
Small amount of C/C++ code
Convert height map to normal map
Implement NormalMap::computeNormal method
Intermediate milestone
Yesterday: Monday, April 2nd
Submit snapshots and GLSL code for first two shaders
Complete project
Due Friday, April 6th
All 10 shaders
Embellish for additional credit
7. CS 354 7
Your Mission So Far
You should now have these first two
shaders tasks implemented
Task 1: apply decal
Task 0: roll torus
8. CS 354 8
Procedurally Generating a
Torus from a 2D Grid
2D grid over (s,t)∈[0,1]
Tessellated torus
9. CS 354 9
GLSL Standard Library Routines
You’ll Need for Project 2
texture2D—accesses a 2D texture through a sampler2D and a 2-component
texture coordinate set (s,t)
textureCube—access a cube map with a samplerCube and a 3-component
texture coordinate set (s,t,r)
normalize—normalizes a vector
cross—computes a cross product of 2 vectors
dot—computes a dot (inner) product of 2 vectors
max—compute the maximum of two values
reflect—compute a reflection vector given an incident vector and a normal
vector
vec3—constructor for 3-component vector from scalars
mat3—constructor for 3x3 matrix from column vectors
*—matrix-by-vector or vector-by-matrix multiplication
sin—sine trigonometric function
cos—cosine trigonometric function
pow—raise a number to a power, exponentiation (hint: specular)
10. CS 354 10
Coordinate Spaces for Project 2
Parametric space
2D space [0..1]x[0..1] for 2D patch
Object space
Transform the patch’s parametric space into a 3D space
containing a torus
Has modeling transformation from object- to world-space
World space
Environment map is oriented in this space
gluLookAt’s coordinates are in this space
Surface space
(0,0,1) is always surface normal direction
Mapping from object space to surface space varies along torus
Perturbed normal from normal map overrides (0,0,1) geometric
normal
Eye space
gluLookAt transforms world space to eye space
11. CS 354 11
Artist-driven
Content Generation
Advantages
Human artistic expression!
Human-to-human user interface
Polish
Disadvantages
Human-intensive
Takes time to make lots of it
Involved to change
Data intensive
12. CS 354 12
Image-driven
Content Generation
Advantages
As easy as taking pictures
Disadvantages
Very data-intensive
Calibrating cameras & correlating images
Quite involved
image panorama
Involved to edit
13. CS 354 13
Procedural
Texturing and Modeling
Let programs generate content!
Advantages
Small programs → lots of content
Compact storage requirements
Easy to generate more content
Disadvantages
Hard to control exactly
15. CS 354 15
Generating Lots of Content
Procedurally
16. CS 354 16
L-Systems
Developed by Aristid Lindenmayer
Theoretical biologist
Hence the L in L-System
Concept
Use a rewriting system to model growth and
morphology of biological organisms
Components
Axiom – initial state
Generator – applied recursively
Useful in non-biology contexts too
Geology, man-made objects, etc.
17. CS 354 17
Sierpinski Gasket
Rule based:
Repeat n times. As n →∞
Area→0
Perimeter →∞
Not a normal geometric object
30. CS 354 30
Procedural Generation of
Buildings
Buildings have rules too
Doors, windows, facades
Consistency of style
Instant Architecture
façade derivation…
31. CS 354 31
Procedural Generation of Cities!
Cities are very detailed and complex
CityGen
But follow regular rules – roads, blocks, respecting
topography, etc.
33. CS 354 33
Particle Systems and
Their Equations
pi = (xi, yi zi)
vi = dpi /dt = pi‘ = (dxi /dt, dyi /dt , zi /dt)
m vi‘= fi
Hard part is defining force vector
33
38. CS 354 38
Noise Textures
Invented by Ken Perlin
Academy Award winning idea
A texturing primitive
Basis for “natural” looking textures and
phenomenon
No memory/bandwidth requirements
Computed on the fly; no “source image”
No mapping problem
Naturally 3D so not prone to “gift wrapping” issues
Useful for range of applications and
effects
39. CS 354 39
What is Noise?
Band-limited repeatable
pseudo-random function
Domain: Rn
Approximate to Gaussian filtered
random noise
Implemented as a pseudo-
random spline
On regular grid
Marble vase
generated with
Perlin noise
40. CS 354 40
Variations on Noise
Use noise within other functions
turbulence
41. CS 354 41
Combining Noise Patterns
Sum noise patterns
As frequency doubles, amplitude halves
42. CS 354 42
Turbulence
Simulate turbulence by generating noise at
different octaves (scales)
Average those octaves:
43. CS 354 43
Generating Marble Pattern
Start with sine pattern in solid texture
Then add turbulence
Looks like veins in marble
44. CS 354 44
Variations on Marble
Scale the magnitude of the turbulence
displacing the sine pattern
45. CS 354 45
Wood Pattern
Start with cylindrical pattern
Compute sine of distance from center of cylinder
Interpolate between dark and light brown color
46. CS 354 46
Irregular Wood Rings
Now use small amount of turbulence to displace
the tree rings in the wood
Much less turbulence than marble case
To preserve the rings
47. CS 354 47
Irregular Wood Grain
Also want turbulence in Z direction but scale it
back to preserve the grain
less turbulence in z
49. CS 354 49
Other Procedurally Modeled
Phenomenon
Smoke
Difficult for an artist to model
Needs to billow and flow around objects
50. CS 354 50
Entire Book on
Procedural Techniques
David Ebert,
Ken Musgrave,
Darwyn Peachey,
Ken Perlin,
Steve Worley
51. CS 354 51
Next Class
Next lecture
Bezier curves
How do we move smoothly and simply with control?
Project 2
Shading and lighting with GLSL
Due Friday, April 6th