Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Lecture 8 Transparency, Mirroring
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Exploration of bump, parallax, relief and displacement mapping
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
3D Graphics Rendering and Terrain Modeling
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
Computer Graphics Inf4/MSc Computer Graphics Lecture 13 Illumination I – Local Models.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
HCI 530 : Seminar (HCI) Damian Schofield.
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
SET09115 Intro Graphics Programming
Maths and Technologies for Games Water Rendering CO3303 Week 22.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Computer Graphics Texture Mapping
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
Computer Graphics Module Review CO2409 Computer Graphics.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
Game Programming 06 The Rendering Engine
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Maths & Technologies for Games Advanced Graphics: Scene Post-Processing CO3303 Week
Local Illumination and Shading
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
- Introduction - Graphics Pipeline
Ying Zhu Georgia State University
Week 7 - Monday CS361.
Photorealistic Rendering vs. Interactive 3D Graphics
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Chapter 14 Shading Models.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
UMBC Graphics for Games
Computer Graphics Module Review
Computer Graphics Module Overview
CS-378: Game Technology Lecture #4: Texture and Other Maps
Computer Graphics Introduction to Shaders
Computer Graphics Material Colours and Lighting
Chapter 14 Shading Models.
Presentation transcript:

Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16

Lecture Contents 1.Introduction 2.Per-Pixel Lighting 3.Normal Mapping 4.Parallax Mapping 5.Cell Shading 6.Other Techniques 7.Further Reference

Introduction We have looked at the basics of the entire pipeline, using vertex and pixel shaders We have also created some interesting effects using shader techniques –But these effects were of limited use [wiggle!] We can use advanced shaders to implement more useful high-quality rendering techniques –Modern applications & games make much use of such shaders Here we briefly introduce some key techniques –Not in depth, intended to give a flavour only –Overview of techniques is examinable, exact knowledge of the finest detail is not expected

Per-Pixel Lighting We have considered lighting as a vertex processing task –Vertex lighting colours were interpolated (blended) across polygon pixels However, there are problems lighting large polygons only using the vertices –Specular highlights can be lost or vague –Attenuation (fall off of brightness) is poorly represented We can move the lighting calculations to the pixel shader –Very precise lighting effects are possible –More expensive – many more lighting calculations

An Aside: Rasterisation Vertex shaders work on vertices, pixel shaders on pixels –Many pixels per triangle, how are they generated? The rasterization stage, occuring between the shaders converts triangles into pixels –Take three vertices forming a triangle, calculate every pixel inside –Call pixel shader once for every pixel –Data from vertices is interpolated to give input to pixel shader Clearly pixel shader performance is important

An Aside: Interpolation The vertex shader outputs data into the pipeline –E.g. colours, texture coordinates, etc. –Geometry shader may update this data, but we’ll ignore that here This data is linearly interpolated by the rasterization stage to give inputs to the pixel shader –Each pixel is given a weighted average of the outputs from the three vertices in the triangle –In fact some perspective correction also occurs Some data doesn’t interpolate ideally –E.g. Vectors change length when interpolated

Per-Pixel Lighting Per-pixel lighting: Note the reflection on the front of the cube –Doesn’t affect any vertex –Vertex processing would lose this highlight entirely –Also attentuation & specular on the floor would be lost Method: The vertex shader passes the vertex position and normal on to the pixel shader Interpolated & used by the pixel shader to calculate lighting with the usual equations –I.e. Just pass data down the pipeline and calculate lighting later

Specular / Gloss Maps Multiple textures can be blended on a polygon –Trivial in a shader E.g. a specular map (or gloss map) is a texture used to adjust specular highlights It defines which areas are affected by specular light –i.e. the shiny areas

Diffuse & Specular Maps Equation used in pixel shader to use a specular map: Output pixel colour = diffuse light * diffuse map + specular light * specular map The main texture is called the diffuse map –The textures are named by the lighting they affect Convenient to store the diffuse and specular map within a single bitmap –Diffuse in the r, g, & b channels, specular in the alpha channel –Can’t use alpha transparency + =

Normal Mapping When calculating lighting per-pixel, the normals are interpolated: –All polygons will be flat or smoothly curved –Can only represent bumpiness with detailed models Use yet another texture containing normals – a normal map –Note the use of multiple textures in more advanced effects Look up the normal for each pixel in this texture –Ignore interpolated vertex normals Improves quality greatly –But some technical complexity

Normal Mapping Normal mapping example: –Diffuse texture is very simple Normal map shown later –Normal mapping suggests bumpiness when combined with pixel lighting

Normal Map Example Normal maps look unusual –Look at red, green and blue channels to visualise Red X direction of normal Green Y direction of normal Blue Z direction of normal + + = Actual Normal Map

Normal Map Transformation Normals in a normal map are defined relative to the polygon texture they are applied to –Assumes texture is facing down the Z-axis –This is tangent space – the world as seen from the texture But textures in the scene might face in any direction So transform normals from normal map onto mesh This is a matrix transform: –Tangent space (relative to texture) –To world space (because lights are in world space)

Tangent Space We need to calculate a matrix to represent the viewpoint of each polygon - the tangent space of the polygon –X & Y axes match U & V texture axes –The Z axis is simply the polygon normal Already have the polygon normal, –Store tangent vector (texture U axis) –But calculate the bi-tangent (see lab) Normal maps use RGB to define (X,Y,Z) vectors in tangent space –RGB range is 0-1, vector ranges -1 to 1 –So conversion: (RGB values * 2) – 1 –E.g. outward normal of (0,0,1) is stored as RGB(0.5,0.5,1), The distinctive purple-blue of normal maps

Parallax Mapping Normal maps give the impression of bumpiness with correct lighting, but it’s only a lighting effect The actual depth of bumpiness not shown Parallax mapping tries to shows depth as well as bumpy lighting Adjust the UVs used in the pixel shader –Distorts texture to give impression of depth –It’s an artificial effect Normal Mapping Parallax Mapping

Idea behind Parallax Mapping With parallax mapping we also need a height map: –A value for each texel indicating its height Stored in the alpha channel of the normal map Height map Black low, white high

Basics of Parallax Mapping We have a “bumpy” texture, but we are applying it to a flat surface This means that the texture coordinates we normally use are not the right ones: We attempt to correct this by offsetting the UVs Basic parallax mapping offsets them using the camera (eye) vector Uses an approximation shown in diagrams

Another Shader Example: Cell-Shading Cell-Shading describes cartoon like rendering: –Black outlines and only a few colours The outline can be created inside or outside of a shader –Here we draw a 2 nd inside-out slightly larger black model –Other methods too (e.g. could look at polygon normals / camera) Lighting is calculated in usual way But colours are clamped to a fixed set of values –A 1D texture is used for this (see labs) An example of non- photorealistic rendering

Other Techniques Many extensions to these techniques, e.g.: –Animated normal maps to create water effects –The parallax mapping methods can be taken further to create self shadowing surfaces with real depth –This is called steep parallax mapping –Newer approach: use tessellation to generate extra polygons to create the shape implied by the normal / height map Many other techniques too, e.g.: –Different lighting models (e.g. for skin, metal, etc.) –Image processing, HDR lighting –Post-processing for blur, feedback, scene distortion, high dynamic range lighting etc. –And many more. Consider for a 3 rd year project…