Date post: | 22-Dec-2015 |
Category: |
Documents |
Upload: | warren-johns |
View: | 217 times |
Download: | 1 times |
computer graphics & visualization
Lighting & Shading
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Illumination
Without Local Global
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Global Illumination- Interaction with matter - Consider multiple reflections, transmission, shadows
Rendering Equation:
iiiinrirrer dxIxfxIxI cos,,,,,
BRDF
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local Illumination - Phong LightingGeneral Idea:
- Consider only (non-area) light sources that are directly visible from the point on the objects surface without reflections.
- Each point is illuminated independent of its “global” surroundings (except “self”-occlusion of light sources)
- Idea: Approximate illumination by three additive components, representing ambient, diffuse and specular lighting.
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationAmbient Lighting- Hack for replacing true global illumination
(i.e. light bouncing off from other objects)- No direction- Incoming light component that is identical everywhere in the
whole scene
where- ka is the ambient material coefficient of reflection with
0.0 <= ka <= 1.0 and- Ia is the intensity of the ambient light
aaamb IkI
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationDiffuse Lighting- Rough material - Brightness ~ incoming Energy (Lambertian reflection)- Object scatters light into all directions equally- Heuristic reflection model but plausible for certain materials
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationDiffuse LightingPower per unit area arriving at point x depends on the angle of
the surface to the light direction (Johann Friedrich Lambert)
dA
dA‘
Iin
N
J
J cosI
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationDiffuse Lighting- Rough material - Brightness ~ incoming Energy (Lambertian reflection)- Object scatters light into all directions equally- Heuristic reflection model but physically plausible for certain kd
N
L
Intersection Point
)()()),(cos()()( LNxIkLNxIkxI indinddiff
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationSpecular Lighting- Glossy/smooth material - Light is mostly reflected into the directions around the mirror
direction RL of L
Diffuse SpecularGlossy
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local IlluminationSpecular Lighting: The Phong model- Use cosine power as heuristic - Light is mostly reflected into the directions
around the mirror direction RL of L (Rapid decay)- Perfect mirroring only in direction RL (perfect mirror: n )
nLinspec
ninspecspec RVxIkxIkxI )()()(cos)()(
a
cosn
aJ J
N
LRL
V
eye
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Local Illumination
Careful! If a light is situated behind the object (α > 90°) then cos(α) < 0. Discard negative intensity values by clamping the dot products dot to the range [0,1] ! dot = max(0,dot)
ka = 0.1
kd = 0.5
ks = 0.4Ambient Diffuse Specular Phong
nLinsspecinddiffaaamb RVxIkxILNxIkxIIkI )()()(,)()()(,
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Incorporating color• So far we have only dealt with Intensity:
One possible approach to incorporate color: – diffusely reflected light results from the reflection via multiple scattering
events in the micro-scale geometry reflected light is coloured by selective absorption by the surface i.e. a green surface absorbs all wavelengths except green
– specularly reflected light interacts once with the surface and is thus not “coloured” by the surface i.e. the reflection of a light source remains the colour of the source
))()(((0
numLights
x specdiffamblocal xIxIII
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Color of Material and LightUsually we define Colors as 3 component vector C(r,g,b) Therefore the Phong model becomes:
Camb global ambient lighting color defined once in the whole scene
Cdiff defined per material
Cspec specified per light source
(To increase flexibility the specular color can additionally be scaled by a color defined per material)
))()(((0 spec
numLights
x specdiffdiffambamblocal CxICxICIC
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Graphics Pipeline (DirectX 10)Input Data
Input AssemblerStage (IA)
Vertex ShaderStage (VS)
Geometry ShaderStage (GS)
Stream OutputStage (SO)
Rasterizer Stage(RS)
Pixel ShaderStage (PS)
Output MergerStage (OM)
Output Data
Memory Resources:
Buffers, Textures,
Constant Buffers
Buffer
Texture, Constant Buffer
Texture, Constant Buffer
Texture, Constant Buffer
Buffer
States
Buffer, Texture, Constant Buffer
VB
IB
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Shading: Flat vs. Gouraud vs. Phong
Phong Lighting
Gouraud Shading
Phong Lighting
Phong Shading
Phong Lighting
Flat Shading
computer graphics & visualization
Seminar SS 2010 – Game Engine DesignLighting & Shading
Shading: Gouraud vs. PhongGouraud Shading Phong Shading
evaluates lighting per vertex evaluates lighting per fragment