230 likes | 368 Views
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.
E N D
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. • Point Light Sources. • All directions. • Attenuation. • Spot Light Sources. • Cone of light. • Attenuation. Kc, Kl and Kq are constant, linear and quadratic attenuation values. U: Direction of the spot light. L: Unit direction vector from surface point to light spot.
Diffuse Lighting A: Ambient light T: Texture sample. D: Surface diffuse reflection color. Ci: Intensity of the i light at the surface point. N: Normal vector of the surface. Li: Unit direction vector to the light source I.
Specular Lighting S: Surface specular color. Ci: Intensity of the incident light. m: specular exponent (larger, sharper hightlight). G: Gloss map sample. N: Normal vector at the surface. L: Unit direction to light vector. Hi: Halfway vector (V + L). V: Unit direction to viewer vector.
Emission Kemission = EM E: Surface emission color. M: Emission map sample.
Gouraud Shading • Lighting is calculated at each vertex and interpolated across the triangle. K = Kprimary * T1 * T2 * ... * Tk + Ksecondary Ti : Color samples for one of k texture maps. * : One of several available texture combination operations
Phong Shading • Interpolate vertex normals and evaluates the lighting formula at each pixel. K = Kemission + Kdiffuse + Kspecular • Problem: interpolation of normals produce non unit vectors. Use normalization cube maps.
Bump Mapping • A hardware implementation of Phong Shading. • Uses a texture map to perturb the normal vector at each pixel (not interpolated). • Bump Map: 2D arrays of 3D vectors. Direction of the normal vector relative to the interpolated normal vector at the pixel. • Uses tangent space for storing the perturbations. Object to tanget space transformation (3x3 matrix multiplication).
OpenGL Lighting • Calculated at vertex, interpolated inside the triangle (Gouraud). • Bump mapping supported by propietary extensions. • Pixel Shaders for programmable per pixel lighting.
Hardware Pipeline • Command Processor. • Vertex Shader. • Rasterization. • Pixel Shader. • Fragment Operations and Tests.
Command Processor • Recieves commands from the CPU (driver, OpenGL/Direct3D). • Fetches data from memory: vertex data (DMA). • Updates and stores OpenGL/Direct3D render state.
Vertex Shader • Transforms and lits vertex streams. • Vertex shader program (from GPU memory?). • Vertex shader constans (from GPU memory?). • Inputs: vertex data 16x4D • Outputs: vertex data 14x4D
Rasterization • Includes: • Clipping • Divide by w • Affine transform • Primitive assembly • Culling • Setup • Fragment generation. • Recieves vertexs and produces fragments. • Uses OpenGL/Direct3D render state. • Input: vertex (15x4D). • Output: fragments (10x4D).
Pixel Shader • Shades fragments: calculate texture address, read texture, color operations. • Pixel Shader program and constants (from GPU memory?). • Texture read: TMU (texture sample, filter unit, texture cache, GPU memory). • Optional: • Modify depth coordinate (1 Z output). • Render to texture (up to 4 colors outputs). • Input: fragment (12x4D). • Output: color (2x4D).
Fragment Operations and Tests • Includes (OpenGL): • Fog. • Color Sum. • Ownership Test. • Scissor Test. • Alpha Test. • Stencil Test. • Depth Test. • Blend. • Logic Operation. • Accesses framebuffer (GPU memory). Updates framebuffer. • Framebuffer: color, Z and stencil. • OpenGL/Direct3D render state defines operations. • Input: color. • Output: FB updated.
Others • Antialiasing • Anisotropic Filtering (textures). • Line Antialiasing. • Edge Antialiasing • Full Screen Antialiasing (FSAA): • Supersampling. • MultiSampling. • TBDR: Tile Based Deferred Rendering (STMicro PowerVR). • HOS (High Order Surfaces): N-Patches, Bezier, Displacement Mapping, TruForm, Tesselation.