status – week 277
DESCRIPTION
Status – Week 277. Victor Moya. Lightning. Diffuse Lightning. Light Sources. Specular Lightning. Emission. Gouraud Shading. Phong Shading. Bump Mapping. OpenGL Lightning. Light Sources. Ambient Light. Directional Light Sources Infinite light source (parallel rays). No attenuation. - PowerPoint PPT PresentationTRANSCRIPT
Status – Week Status – Week 277277
Victor MoyaVictor Moya
LightningLightning
Diffuse Lightning.Diffuse Lightning. Light Sources.Light Sources. Specular Lightning.Specular Lightning. Emission.Emission. Gouraud Shading.Gouraud Shading. Phong Shading.Phong Shading. Bump Mapping.Bump Mapping. OpenGL Lightning.OpenGL Lightning.
Light SourcesLight Sources Ambient Light.Ambient Light. Directional Light SourcesDirectional Light Sources
Infinite light source (parallel rays).Infinite light source (parallel rays). No attenuation.No attenuation.
Point Light Sources.Point Light Sources. All directions.All directions. Attenuation.Attenuation.
Spot Light Sources.Spot Light Sources. Cone of light.Cone of light. Attenuation.Attenuation.
Kc, Kl and Kq are constant, linear and quadratic attenuation values.Kc, Kl and Kq are constant, linear and quadratic attenuation values.U: Direction of the spot light.U: Direction of the spot light.L: Unit direction vector from surface point to light spot.L: Unit direction vector from surface point to light spot.
dKKKC
qlc2
1
dKKK
ULC
qlc2
}0,max{
Diffuse LightingDiffuse Lighting
A: Ambient lightA: Ambient lightT: Texture sample.T: Texture sample.D: Surface diffuse reflection color.D: Surface diffuse reflection color.Ci: Intensity of the i light at the surface point.Ci: Intensity of the i light at the surface point.N: Normal vector of the surface.N: Normal vector of the surface.Li: Unit direction vector to the light source I.Li: Unit direction vector to the light source I.
n
i
NLiCiDTDTAdiffuseK1
}0,max{
Specular LightingSpecular Lighting
S: Surface specular color.S: Surface specular color.Ci: Intensity of the incident light.Ci: Intensity of the incident light.m: specular exponent (larger, sharper hightlight).m: specular exponent (larger, sharper hightlight).G: Gloss map sample.G: Gloss map sample.N: Normal vector at the surface.N: Normal vector at the surface.L: Unit direction to light vector.L: Unit direction to light vector.Hi: Halfway vector (V + L).Hi: Halfway vector (V + L).V: Unit direction to viewer vector.V: Unit direction to viewer vector.
)0(}0,max{1
NLCiSGspecular NHiKmn
i
EmissionEmission
KKemissionemission = EM = EM
E: Surface emission color.E: Surface emission color.
M: Emission map sample.M: Emission map sample.
Gouraud ShadingGouraud Shading
Lighting is calculated at each vertex Lighting is calculated at each vertex and interpolated across the triangle.and interpolated across the triangle.
K = KK = Kprimaryprimary * T * T11 * T * T22 * ... * T * ... * Tkk + K + Ksecondarysecondary
Ti : Color samples for one of k texture maps.Ti : Color samples for one of k texture maps.* : One of several available texture combination operations* : One of several available texture combination operations
n
i
NLiCiDDAEprimaryK1
}0,max{
)0(secondary }0,max{1
NLCiS NHiKmn
i
Phong ShadingPhong Shading
Interpolate vertex normals and evaluates the Interpolate vertex normals and evaluates the lighting formula at each pixel.lighting formula at each pixel.
K = Kemission + Kdiffuse + KspecularK = Kemission + Kdiffuse + Kspecular
Problem: interpolation of normals produce non Problem: interpolation of normals produce non unit vectors. Use normalization cube maps.unit vectors. Use normalization cube maps.
Flat, Gouraud and Phong Flat, Gouraud and Phong ShadingShading
Bump MappingBump Mapping A hardware implementation of Phong A hardware implementation of Phong
Shading.Shading. Uses a texture map to perturb the normal Uses a texture map to perturb the normal
vector at each pixel (not interpolated).vector at each pixel (not interpolated). Bump Map: 2D arrays of 3D vectors. Bump Map: 2D arrays of 3D vectors.
Direction of the normal vector relative to Direction of the normal vector relative to the interpolated normal vector at the pixel.the interpolated normal vector at the pixel.
Uses tangent space for storing the Uses tangent space for storing the perturbations. Object to tanget space perturbations. Object to tanget space transformation (3x3 matrix multiplication).transformation (3x3 matrix multiplication).
Bump MappingBump Mapping
OpenGL LightingOpenGL Lighting
Calculated at vertex, interpolated Calculated at vertex, interpolated inside the triangle (Gouraud).inside the triangle (Gouraud).
Bump mapping supported by Bump mapping supported by propietary extensions.propietary extensions.
Pixel Shaders for programmable Pixel Shaders for programmable per pixel lighting.per pixel lighting.
OpenGL LightingOpenGL Lighting
OpenGL LightingOpenGL Lighting
OpenGL LightingOpenGL Lighting
Hardware PipelineHardware Pipeline
Command Processor.Command Processor. Vertex Shader.Vertex Shader. Rasterization.Rasterization. Pixel Shader.Pixel Shader. Fragment Operations and Tests.Fragment Operations and Tests.
Com
man
dPr
oces
sor
Ver
tex
Sha
der
Rast
eriza
tion
Pix
elS
hade
r
Frag
men
tO
pera
tions
and
Test
s
vertex data (16x4D):1 pos1 weight1 normal2 colors1 fog coord8 texture coords
Vertex Output (15x4D):1 Homogeneous pos4 colors1 fog coord1 point size8 texture coord
Fragment 10x4D)2 colors8 texture coords
Fragment Coords
Fragment Output (10x4D)1 color1 depth coordinate
Fragment Coords
FramebufferCPU
Memory
Vertex Programand Constants
OGLStateFragment
Program andConstants
TextureMemory
OGLState
OGLState
Color BufferZBufferStencil Buffer
Command ProcessorCommand Processor
Recieves commands from the CPU Recieves commands from the CPU (driver, OpenGL/Direct3D).(driver, OpenGL/Direct3D).
Fetches data from memory: vertex Fetches data from memory: vertex data (DMA).data (DMA).
Updates and stores Updates and stores OpenGL/Direct3D render state.OpenGL/Direct3D render state.
Vertex ShaderVertex Shader
Transforms and lits vertex streams.Transforms and lits vertex streams. Vertex shader program (from GPU Vertex shader program (from GPU
memory?).memory?). Vertex shader constans (from GPU Vertex shader constans (from GPU
memory?).memory?). Inputs: vertex data 16x4D Inputs: vertex data 16x4D Outputs: vertex data 14x4DOutputs: vertex data 14x4D
RasterizationRasterization Includes:Includes:
ClippingClipping Divide by wDivide by w Affine transformAffine transform Primitive assemblyPrimitive assembly CullingCulling SetupSetup Fragment generation.Fragment generation.
Recieves vertexs and produces fragments.Recieves vertexs and produces fragments. Uses OpenGL/Direct3D render state.Uses OpenGL/Direct3D render state. Input: vertex (15x4D).Input: vertex (15x4D). Output: fragments (10x4D).Output: fragments (10x4D).
Pixel ShaderPixel Shader Shades fragments: calculate texture address, Shades fragments: calculate texture address,
read texture, color operations.read texture, color operations. Pixel Shader program and constants (from Pixel Shader program and constants (from
GPU memory?).GPU memory?). Texture read: TMU (texture sample, filter Texture read: TMU (texture sample, filter
unit, texture cache, GPU memory).unit, texture cache, GPU memory). Optional:Optional:
Modify depth coordinate (1 Z output).Modify depth coordinate (1 Z output). Render to texture (up to 4 colors outputs).Render to texture (up to 4 colors outputs).
Input: fragment (12x4D).Input: fragment (12x4D). Output: color (2x4D).Output: color (2x4D).
Fragment Operations and Fragment Operations and TestsTests
Includes (OpenGL):Includes (OpenGL): Fog.Fog. Color Sum.Color Sum. Ownership Test.Ownership Test. Scissor Test.Scissor Test. Alpha Test.Alpha Test. Stencil Test.Stencil Test. Depth Test.Depth Test. Blend.Blend. Logic Operation.Logic Operation.
Accesses framebuffer (GPU memory). Updates framebuffer.Accesses framebuffer (GPU memory). Updates framebuffer. Framebuffer: color, Z and stencil.Framebuffer: color, Z and stencil. OpenGL/Direct3D render state defines operations.OpenGL/Direct3D render state defines operations. Input: color.Input: color. Output: FB updated.Output: FB updated.
OthersOthers AntialiasingAntialiasing
Anisotropic Filtering (textures).Anisotropic Filtering (textures). Line Antialiasing.Line Antialiasing. Edge AntialiasingEdge Antialiasing Full Screen Antialiasing (FSAA):Full Screen Antialiasing (FSAA):
Supersampling.Supersampling. MultiSampling.MultiSampling.
TBDR: Tile Based Deferred Rendering (STMicro TBDR: Tile Based Deferred Rendering (STMicro PowerVR).PowerVR).
HOS (High Order Surfaces): N-Patches, Bezier, HOS (High Order Surfaces): N-Patches, Bezier, Displacement Mapping, TruForm, Tesselation.Displacement Mapping, TruForm, Tesselation.