38
Illumination and Shading

Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination and Shading

Page 2: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Rendering

• Simulation of physical interaction of light and matter.

• Physically correct shading is too complex– Material layers– Inter-object relations

• Good approximations are possible– Physical models when CPU available– Heuristics that look good

Page 3: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Sources

• Point source (A)– Light originates from a point– The point may be at infinity– Approximation for light sources whose

dimensions are small relative to objects

AB

C

Page 4: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Sources

• Parallel source– Light rays are parallel – Can be modeled as a light source in infinity– Approximation for far sources

AB

C

Page 5: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Sources

• Light originates at a finite area– Windows– Fluorescent

• Sometimes called distributed source

AB

C

Page 6: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Sources Example

Parallel light source

Point light source

Page 7: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination models

• Material has following properties– Ambient– Diffuse– Specular

Page 8: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination models

• Material has following properties– Ambient

• Compensates for global interactions• Assumes non directional light in the environment• The shading equation:

I = IAKA, IA – ambient light, KA – surface parameter

– Diffuse– Specular

Page 9: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination models

• Material has following properties– Ambient– Diffuse

• Represents matt (non shining) surfaces • Known as Lambert model• Reflects lights in all directions• Reflected light is proportional to <N,L>

• I = IDKD<N,L>

– Specular L

N

Page 10: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination models

• Material has following properties– Ambient– Diffuse– Specular

• Shiny (metallic) surfaces reflect light in preferred direction

• Ideal shiny surface reflects only in one direction R• Phong specularity exponent (no physical basis)

nL R

V

cos cos8 cos128

Page 11: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination models

• Material has following properties– Ambient– Diffuse– Specular

• Computing R

N

L

R

N L N L

LNLNLLNLNR

,2),(2

Page 12: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination Equation• Definitions

– N – point normal

– V – viewing direction

– L – lighting direction

– R – reflection direction

– D – diffuse, A – ambient, S – specular

– I – intensity

– K – surface coefficient,

– θ – angle between V and L

– α – angle between V and R

nL R

V

1

1

( ( ) ( ) )

( cos( ) cos( ) )

i

i

mn

a a d d i s ii

mn

a a d d i s ii

I I k I k N L k R V

I k I k k

Page 13: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Illumination comparison

Ambient

Diffuse

Specular, n = 100

Specular, n = 8

Page 14: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Shading

• Constant

• Gouraud

• Phong

Page 15: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Shading

• Constant– Color each polygon according to its normal

• Gouraud

• Phong

Page 16: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Shading

• Constant

• Gouraud– Compute exact colors for vertexes– Interpolate colors for interior pixels of polygon– We can miss specular highlights

• Phong

Page 17: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Shading

• Constant

• Gouraud

• Phong (default Inventor model)– Compute normals for vertexes– Interpolate normals for interior pixels– Compute color according to pixel normal

Page 18: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Shading Example

Page 19: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Interpolation

c1

c2 c3

scanline

c c c4 1 1 1 21 ( ) c c c5 2 1 2 31 ( )

c( , ) ( )x y c c 3 4 3 51

( , )x y

Page 20: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Lights in Inventor

• Light node in Inventor determines– What the light illuminates (following nodes)– Where it is located (affected by current

transformation)

• Light sources are cumulative

• SoTransformSeparator– Light should not be under standard separator– You can separate only light transformation– Only the light position can be changed

Page 21: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes

• SoLight fields– On (SoSFBool)

• If the source is turned on / off

– Intensity (SOSFFloat)• 0 – minimum• 1 – maximum

– color (SOSFColor)• Color of the light

Page 22: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes

• SoPointLight (Point Source)– location (SoSFVec3f)

• 3D location of a point light source • affected by current geometric transformation

Page 23: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes

• SoDirectionalLight (Parallel source)– direction (SOSFVec3f)

• Direction of rays• Affected by current transformation

Page 24: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes• SoSpotLight

– A point light restricted to a cone– location (SoSFVec3f)

• 3D location of a point light source • affected by current geometric transformation

– direction (SoSFVec3f)• primary direction of illumination

– dropOffRate (SoSFFloat)• rate at which the light intensity drops off from the primary

direction.• 0.0 = constant intensity• 1.0 = sharpest drop-off

Page 25: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes• cutOffAngle (SoSFFloat)

– angle, in radians, where the intensity is 0.0– measured from one cone edge to the other

Page 26: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Light Nodes

• Directional lights are the fastest

• Spotlights are the slowest

• To increase speed use fewer lights

Page 27: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Multiple Lights Example

• The example contains:– A red stationary directional light– A green light moved back and forth by SoShuttle

Page 28: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Example// Add a directional light SoDirectionalLight *myDirLight = new SoDirectionalLight; myDirLight->direction.setValue(0, -1, -1); myDirLight->color.setValue(1, 0, 0); // red root->addChild(myDirLight);

// Add shuttle and point light SoShuttle *myShuttle = new SoShuttle; myTransformSeparator->addChild(myShuttle); myShuttle->translation0.setValue(-2, -1, 3); myShuttle->translation1.setValue( 1, 2, -3); SoPointLight *myPointLight = new SoPointLight; myTransformSeparator->addChild(myPointLight); myPointLight->color.setValue(0, 1, 0); // green

Page 29: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Surface Material

• Opaque surface– Light is reflected and absorbed

• Transparent surface– Light is reflected and transmitted

• SoMaterial contains– transparrency (SoMFFloat)

• 0.0 for opaque• 1.0 for transparent

Page 30: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Surface material• The amount reflected depends on material

– Shiny reflect more• Intensive brightness in one direction

– Rough reflect less• Equally bright from all directions

• SoMaterial contains– shininess (SoMFFloat)

• 0.0 for diffuse• 1.0 for metallic

– diffuseColor (SoMFColor) KD

– specularColor (SoMFColor) KS

Page 31: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Ambient light• Models inter-object relations• The object is illuminated with the same light

everywhere• One equation for each channel R,G,B.• SoEnvironment contains

– ambientIntensity ( SoSFFloat) IA

– ambientColor (SoSFColor) KAE (environment)

• SoMaterial contains– ambientColor (SoSFColor) KAM (material)

KA = KAE*KAM

Page 32: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Ray Tracing

Page 33: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Ray Tracing

Page 34: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Radiosity

Direct Illumination Global Illumination

Page 35: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Radiosity

Page 36: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Radiosity

Page 37: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Radiosity

Page 38: Illumination and Shading. Rendering Simulation of physical interaction of light and matter. Physically correct shading is too complex –Material layers

Radiosity