Assignments Please fill the dropboxes Lights Still catching up on - - PDF document

assignments
SMART_READER_LITE
LIVE PREVIEW

Assignments Please fill the dropboxes Lights Still catching up on - - PDF document

Assignments Please fill the dropboxes Lights Still catching up on grading. Questions. Final exam effects Final exam effect Deliverables: Presentation: Research (Grads only) Final exam period Shader code


slide-1
SLIDE 1

1

Lights Assignments

 Please fill the dropboxes…  Still catching up on grading.  Questions.

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

 Monday, May 19th  12:30 - 2:30pm  ICL5

 15 minutes per presentation

All the world’s a stage

 Looking for stage crew  Critters

 Premiere of Virtual Theatre  May 3rd at noon-2pm  Rehearsals this and next week

 Interested? Please see me.

Plan for this week

 Tonight: Light

 Lighting controls  Lights in RenderMan  Lights in GLSL  A bit about shadows

 Thursday:

 Lighting Lab

slide-2
SLIDE 2

2

Light – Parameters

 Controllable parameters for light sources:

 Position / Direction

 Where is the light coming from and in what direction

 Intensity

 How intense is the light

 Distribution

 What is the area of effect the beam  How does intensity vary within that area.

 And of course…color

 Same triplet used for color and intensity (0 - 1)

Lights in Computer Graphics

 Types of light

 Ambient  Background light  Directional Light  Light arriving from a given direction regardless of the shading

point

 Point Light source  Light positioned at a given point. Light distributed equally in all

directions

 Spotlight  Point light source with a limited beam of effect  Area light source  Light emitted from a finite geometric area

Light - Simple Point Light Source

 Light distributed equally in all directions

Light - Directional Light

 Light distributed equally from a given

direction

 Point light source at infinity is an

estimation for sunlight

Light - Spotlight

 Basic CG Spotlight

 Point light source with a limited beam

A

Light -- Spotlight

 Spotlight controls

 Beam shape  Beam Falloff

 How intensity is effected as one moves across

the beam

 Intensity Falloff

 How intensity is effected by the distance from

light source to shading point.

slide-3
SLIDE 3

3

Light - Spotlight

 Basic Shape -- cone

[Advanced Renderman]

Light - Spotlight

 Shape

 Barn doors (beam shape)

Light - Spotlight

 Shape – Gobos (use go between to shape

beam)

Light - Spotlight

 Beam Falloff

Light - Spotlight

 Beam Falloff (at edge)

Light - Spotlight

 Intensity falloff

 Intensity of light will decrease proportional

to the inverse of the distance squared.

slide-4
SLIDE 4

4

Light -- Spotlight

 Intensity Falloff

Light -- area light source

 Light emitted from a finite geometric

source.

 Note: RenderMan spec has support for

area light sources however prman does not implement these features

 Area light sources are often modeled as a

set of point light sources.

Light - Distribution

 Area Light Sources

 sampled point sources within area

Questions?

RenderMan

 A note about illuminance  Recall the rendering equation:

[ ]

  • +
  • =
  • S

x d x x I x x x x x x x g x x I ) , ( ) , , ( ) , ( ) , ( ) , (

  • Illuminance is meant to

estimate this integration

RenderMan

 Light shaders

 Used to define the color, intensity, and direction of

the light.

 Works in concert with illuminance

 Illuminance will loop over all light sources in a given solid

angle

 It will query each light source to see if the light source

has effect.

 Querying == running the light source shader for the light

source.

RenderMan

 Light source shader “global variables”

 Input:

 Ps -- point on the surface that requested data from the

light

 (others for area light source -- not supported in prman)

 Output:

 L -- vector giving the direction from the light to the point

being shaded

 Cl -- Color of the energy being emitted by the source in

the direction of Ps.

slide-5
SLIDE 5

5

Renderman

 Implementing ambient light light ambient (float intensity = 1; color lightcolor = 1;) { Cl = intensity * lightcolor; L = 0; }

Renderman

 Reason d’etre of the light source shader is to

set L and Cl.

 Handy lighting constructs that’ll do that for

you.

 For directional light:

solar (vector axis, float spread) { } L will always be set to axis solar will compare illuminance angle to axis if not in range, solar block will not be executed,

RenderMan

light distantlight (float intensity = 1; color lightcolor = 1; point from = point “shader” (0,0,0); point to = point “shader” (0, 0, 1);) { solar (to-from, 0) { Cl = intensity * lightcolor; } }

RenderMan

 For point light sources

illuminate ( point from) { } illuminate (point from; vector axis; float angle) { } Sets L to the vector from the from point to Ps. Also will check if illuminance spread is within range

RenderMan

light pointlight (float intensity = 1; color lightcolor = 1; point from = point “shader” (0,0,0);) { illuminate (from) { Cl = intensity * lightcolor / (L . L); } }

1/d2 intensity falloff

RenderMan

light simplespot (float intensity = 1; color lightcolor = 1; point to = point “shader” (0, 0, 1); point from = point “shader” (0,0,0); float coneangle = radians (30);) { uniform vector A = normalize (to-from); illuminate (from, A, coneangle) { Cl = intensity * lightcolor / (L . L); } }

slide-6
SLIDE 6

6

RenderMan

 Light categories:

light simplespot (float intensity = 1; color lightcolor = 1; point to = point “shader” (0, 0, 1); point from = point “shader” (0,0,0); float coneangle = radians (30); string __category =- “mylight”)

RenderMan

 Then…in a surface shader:

illuminance (“mylight”, P, Nf, PI/2) { … }

RenderMan

 Surface shaders can also access light shader

parameters from within an illuminance loop:

float lightsource (string param, output type

result)

 If light source has a parameter named param with

the given type, result is filled with the parameter value and the function returns 1.0…Otherwise the function returns 0.0.

GLSL

 OpenGL lighting model:

 Emissive, ambient, diffuse, specular

 No solar or illuminate construct  Will need to code these construct as

GLSL functions.

GLSL - spotlight GLSL - spotlight

 Simulating illuminate float illuminate (float3 P, float3 from, float3 axis, float angle) { float3 V = normalize (P - from); float cosCone = cos (angle); float cosDir = dot (V, axis); if (cosCone <= cosDir) return 1; else return 0; }

slide-7
SLIDE 7

7 GLSL - built in uniform variables

GLSL - multiple lights

 Array of light structures.  Use plain old for loop to simulate the

illuminance loop

 Questions?  Break?

Projective Texture Maps

 Projective texture mapping is a method

  • f texture mapping that allows a

textured image to be projected onto a scene as if by a slide projector.

 What is it good for?

 Shadow generation  Light masks -- gobos.

Textures

 Projective texture mapping

Projective texture mapping

 How it’s done.

 Basic projection  Create coordinate system about light

 As you would set up your camera  Convert point from world to light space  Do perspective by dividing by z.

Camera Coordinates

 Camera Orientation

 The camera has it’s own 3D coordinate

system based on it’s orientation

 u,v,n  u corresponds to x (as seen by the camera)  v corresponds to y (as seen by the camera)  n corresponds to z (as seen by the camera)  Negative n is into the scene

slide-8
SLIDE 8

8

Camera coordinates

 Defining camera orientation

 Provide the camera location (eyepoint)  Indicate what direction the camera is looking

(lookat)

 Give the “up” direction of the camera  Then

 n = eyepoint – lookat  u = up x n  v = n x u

 Note: right handed coordinate system

Camera Coordinates

 View coordinate system may not coincide with world

coordinate system.

 Must transform point in world (x,y,z) to a point in

coordinate system of view (u,v,n)

  • =
  • 1

1 z y x M n v u

Camera Coordinates

 (ux,uy,uz) are coordinates of unit u vector w.r.t. world space

 Similar for v, n,

 (eye) is the origin of view space w.r.t world space

 If ups are aligned, simply

use negative eye location values in the fourth column

            = 1

z y x z y x z y x

n n n v v v u u u M

  • eye• u
  • eye• v
  • eye• n

Perspective projection

 Replace camera with light!

Perspective Projection Perspective Projection

 In object space:

M = Model matrix Vp = View Matrix (of projector) Pp = Projection Matrix (of projector)

slide-9
SLIDE 9

9

Perspective Projection

 Problems with doing this in object

space:

 We really don’t have Model Matrix  Must be updated every time we transform

  • bject.

Perspective Projection

 In eye space:

Ve = View Matrix (camera) Vp = View Matrix (of projector) Pp = Projection Matrix (of projector)

Support

 GLSL

 texure2DProj will perform perspective

divide.

 Still must set up transformation matrix

 Can do so by using “standard OpenGL”

functions.

 RenderMan

 Roll your own

 Either in shader or in RIB file

Light and Shadows

 Unlike with ray tracing, the inclusion of

shadows does not come for free

 Shadows must be explicitly added.  Many algorithms to do this.  Shadow / Depth Maps

 Most common and most supported  Basic support in both RenderMan and Cg.

Shadow z-buffer (Shadow Map)

 [Williams 1978]

 Image space  (Same year Blinn introduced Bump Mapping)

 Use a Z buffer (depth buffer) from light source

point of view and use as a texture onto scene rendered from viewpoint

Shadow Map

 Step 1 (Construct shadow map)

 The view of the scene is constructed from

the light source’s point of view.

 The depth values (Z) for the objects closest

to the light source are stored to the depth map for each point.

slide-10
SLIDE 10

10

Shadow Map

 Step 2 – Use Shadow Map

 Render scene from viewpoint  use the saved depth buffer as a texture

which is projected from the light's position

 compare the value from the texture

projected onto the point to the distance from the point to the light

Shadow Map

http://www-sop.inria.fr/reves/personnel/Marc.Stamminger/psm/

Shadow Map

 Basic Z buffer algorithm

Initialize frame buffer (to background) Initialize Z-buffer (to 0) For each polygon P { For each pixel p in polygon’s projection { z = P’s z at pixel p if (z > Zbuffer at that pixel) { zBuffer at pixel = z Frame buffer at pixel = calcColor() } }

Shadow Map

 Modified Z buffer algorithm

Initialize frame buffer (to background) Initialize Z-buffer (to 0) For each polygon P { For each pixel p in polygon’s projection { z = P’s z at pixel p if (z > Zbuffer at that pixel) { zBuffer at pixel = z Frame buffer at pixel = calcColor() if ( z > shadow depth) place in shadow } }

Shadow Map Support

 RenderMan

 float shadow ( string mapname, point Ptest)

 Returns 0 if Ptest is not in shadow, 1.0 otherwise

 GLSL

 Supported in hardware by using shadow2D

functions

 Returns 1 or 0 depending if point is in shadow

Shadow Maps

 For both Cg and RenderMan, the

shadow map must be precreated.

 How to set this up in OpenGL:  http://www.paulsprojects.net/tutorials/smt/s

mt.html

 Questions?

slide-11
SLIDE 11

11

For lab on Tuesday

 Implement a stage lighting instrument.