shading n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Shading PowerPoint Presentation
Download Presentation
Shading

Loading in 2 Seconds...

play fullscreen
1 / 32

Shading - PowerPoint PPT Presentation


  • 133 Views
  • Uploaded on

Shading. CMSC 435/634. RenderMan. Displacement. Surface. Light. Volume. Imager. Displacement. Given Position Normal Compute Position Normal. Displacement. Surface. Light. Volume. Imager. Surface color. Given Position Compute Color Opacity. Displacement. Surface. Light.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Shading' - karik


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
shading

Shading

CMSC 435/634

renderman
RenderMan

Displacement

Surface

Light

Volume

Imager

displacement
Displacement
  • Given
    • Position
    • Normal
  • Compute
    • Position
    • Normal

Displacement

Surface

Light

Volume

Imager

surface color
Surface color
  • Given
    • Position
  • Compute
    • Color
    • Opacity

Displacement

Surface

Light

Volume

Imager

lighting
Lighting
  • Given
    • Surface Position
  • Compute
    • Light Direction
    • Light Color

Displacement

Light

Surface

Volume

Imager

volume effects
Volume Effects
  • Given
    • Position
    • Color
  • Compute
    • New Color

Displacement

Surface

Light

Volume

Imager

image effects
Image Effects
  • Given
    • Pixel Color
  • Compute
    • Pixel Color

Displacement

Surface

Light

Volume

Imager

non real time vs real time
Non-real time vs. Real-time
  • RenderMan
  • GPU

Application

Application

Texture/

Buffer

Displacement

Vertex

Surface

Light

Geometry

Volume

Imager

Fragment

Displayed

Pixels

Displayed

Pixels

renderman vs gpu
RenderMan vs. GPU
  • RenderMan
    • Developed from General CPU code
    • Seconds to hours per frame
    • 1000s of lines
    • “Unlimited” computation, texture, memory, …
  • GPU
    • Developed from fixed-function hardware
    • Tens of frames per second
    • 1000s of instructions
    • Limited computation, texture, memory, …
history not real time
History (not real-time)
  • Testbed[Whitted and Weimer 1981]
  • Shade Trees [Cook 1984]
  • Image Synthesizer [Perlin 1985]
  • RenderMan[Hanrahan and Lawson 1990]
  • Multi-pass RenderMan[Peercy et al. 2000]
  • GPU acceleration[Wexler et al. 2005]
history real time
History (real-time)
  • Custom HW [Olano and Lastra 1998]
  • Multi-pass standard HW [Peercy, Olano, Airey and Ungar 2000]
  • Register combiners [NVIDIA 2000]
  • Vertex programs [Lindholm et al. 2001]
  • Compiling to mixed HW [Proudfoot et al. 2001]
  • Fragment programs
  • Standardized languages
  • Geometry shaders[Blythe 2006]
renderman brick
RenderManBrick

mortar

brick

gap

height

width

gap

brick shader
Brick Shader

surface brick(

uniform float width = .2,

uniform float height = .1,

uniform float gap = .05,

color brick = color(1,0,0),

color mortar = color(.5,.5,.5) )

{

varying color bc;

/* compute brick color */

normal Nf = faceforward(normalize(N),I)

Oi = Os;

Ci = Oi*bc*(ambient()+diffuse(Nf));

}

brick color
Where am I in my brick?

“brick coordinates”

Brick Color

bs

bt

varying float bs, bt;

/* compute brick coordinates */

if (bs < width && bt < height)

bc = brick;

else

bc = mortar;

brick coordinates
Brick Coordinates

bt = mod(t, height+gap);

bs = s;

if (mod((t-bt)/(height+gap), 2) == 1)

bs += (width+gap)/2;

bs = mod(bs, width+gap);

renderman shader variables
RenderManShader Variables

Cs, Os

u, v, du, dv, s, t

time, dtime

P, dPdu, dPdv, dPdtime, N, Ng

E, I

L, Cl, Ol (In illuminance)

Ci, Oi

renderman outputs
RenderMan Outputs
  • Displacement
    • P, N
    • Set DisplacementBounds!
  • Surface, Volume, Imager
    • Ci, Oi
  • Light
    • Cl, Ol
shading methods
Shading Methods
  • Repeating Patterns
    • mod, sin
    • Divide and floor
  • Shapes
    • Implicit form: is this pixel inside
  • Color tables
  • Noise or computed patterns
noise subtleties
Noise Subtleties
  • Many noise functions based on a lattice
    • Piecewise function between integer coordinates
    • Hash of integer coordinates  control points
  • Interpolating values easy but poor
    • Even with higher-order interpolation
  • Perlin’snoise
    • Passes through 0 at each integer
    • Hash gives gradient
noise characteristics
Noise Characteristics
  • Repeatable
  • Locally continuous but distant points uncorrolated
  • values
    • RenderMan [0,1], average 0.5
    • Perlin’s [-1,1], average 0
  • 1/2 – 1 cycle per unit
  • Versions for 1D-4D input
perlin noise in renderman
Perlin Noise in RenderMan

surface noisetest(float sc=1) {

Ci = float noise(floor(1/t)*sc*P);

}

fractional brownian motion fbm
Fractional Brownian Motion (fBm)

// Combine octaves, scaled by 1/f

for(f=1; f<=floor(1/t); f*=2)

Ci += (float noise(f*sc*P)-.5)/f;

Ci += .5;

turbulence
Turbulence

// fBm using abs(noise)

for(f=1; f<=floor(1/t); f*=2)

Ci += abs(float noise(f*sc*P)-.5)/f;

Ci += .5;

advanced shading methods
Advanced Shading Methods
  • Perturbed patterns
    • Adjust position, radius, etc. with noise
  • Bombing
    • Divide space into cells
    • Compute random position in each cell
    • Check if pixel is inside shape
  • Blending
    • Fade effects in and out with smoothstep
renderman shader debugging
RenderManShader Debugging
  • printf
    • Format codes for colors and points
    • Use conditionals to just print a few pixels!
  • Render as color
    • Map intermediate values to 0-1
    • Interpret results
gpu shading
GPU Shading

Application

Texture/

Buffer

Vertex

Geometry

Fragment

Displayed

Pixels

gpu shading choices
GPU Shading Choices
  • OS: Windows, Mac, Linux
  • API: DirectX, OpenGL
  • Language: HLSL, GLSL, Cg, …
  • Compiler: DirectX, OpenGL, Cg, ASHLI
  • Runtime: CgFX, ASHLI, OSG (& others), sample code
glsl hlsl
GLSL / HLSL
  • Vertex, Geometry & Fragment/Pixel
  • C-like, if/while/for
  • Structs & arrays
  • Float + small vector and matrix
    • Swizzle & mask (a.xyz = b.xxw)
  • Common math & shading functions
noise
Noise
  • Controlled, repeatable randomness
    • Still spotty implementation
    • Can use texture or compute
modified noise olano 2005
Modified Noise [Olano 2005]
  • Three relatively independent modifications
    • New computable hash
    • Change gradient computation
    • Reorder computation
  • Variety of computation/texture options
    • Can just store in a texture
    • Can compute with some texture accesses
    • Can compute with no texture accesses