Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Similar documents
CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Lab 9 - Metal and Glass

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Real-time Graphics 6. Reflections, Refractions

Today. Texture mapping in OpenGL. Texture mapping. Basic shaders for texturing. Today. Computergrafik

Computer Graphics (CS 543) Lecture 8c: Environment Mapping (Reflections and Refractions)

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Computergrafik. Matthias Zwicker. Herbst 2010

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Complex Shading Algorithms

Lighting and Shading

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

COMP environment mapping Mar. 12, r = 2n(n v) v

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

CS 325 Computer Graphics

Computer Graphics. Illumination and Shading

The Rasterization Pipeline

The Rendering Equation. Computer Graphics CMU /15-662

Ambien Occlusion. Lighting: Ambient Light Sources. Lighting: Ambient Light Sources. Summary

Lighting and Materials

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

x ~ Hemispheric Lighting

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Photorealism: Ray Tracing

Illumination & Shading: Part 1

Lecture 10: Ray tracing

Global Illumination CS334. Daniel G. Aliaga Department of Computer Science Purdue University

Raytracing. COSC 4328/5327 Scott A. King

Interactive Methods in Scientific Visualization

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Ray Tracing. Kjetil Babington

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Ray Tracing: Special Topics CSCI 4239/5239 Advanced Computer Graphics Spring 2018

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Simple Lighting/Illumination Models

Lighting affects appearance

CPSC 314 LIGHTING AND SHADING

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

Radiance. Radiance properties. Radiance properties. Computer Graphics (Fall 2008)

Introduction to Visualization and Computer Graphics

Recall: Basic Ray Tracer

Shading 1: basics Christian Miller CS Fall 2011

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

CS5620 Intro to Computer Graphics

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Shading and Illumination

Ambient Occlusion. Ambient Occlusion (AO) "shadowing of ambient light "darkening of the ambient shading contribution

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

COMP371 COMPUTER GRAPHICS

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Reflection and Shading

Illumination and Shading

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

03 RENDERING PART TWO

Game Technology. Lecture Physically Based Rendering. Dipl-Inform. Robert Konrad Polona Caserman, M.Sc.

Introduction to the OpenGL Shading Language

The Rendering Equation & Monte Carlo Ray Tracing

BRDF Computer Graphics (Spring 2008)

Global Illumination The Game of Light Transport. Jian Huang

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 14: Grand Recap. Welcome!

Module 5: Video Modeling Lecture 28: Illumination model. The Lecture Contains: Diffuse and Specular Reflection. Objectives_template

CPSC GLOBAL ILLUMINATION

LIGHTING AND SHADING

CHAPTER 1 Graphics Systems and Models 3

LIGHT. Speed of light Law of Reflection Refraction Snell s Law Mirrors Lenses

Supplement to Lecture 16

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Pipeline Operations. CS 4620 Lecture 14

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

CS : Assignment 2 Real-Time / Image-Based Rendering

Reflection models and radiometry Advanced Graphics

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Image-based Lighting

COMPUTER GRAPHICS AND INTERACTION

Computer Graphics Lecture 11

rendering rasterization based rendering pipelined architecture, parallel mostly triangles (lines and points possible too)

Illumination and Shading

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Lighting. Figure 10.1

Deferred Rendering Due: Wednesday November 15 at 10pm

CS 4600 Fall Utah School of Computing

Shaders. Slide credit to Prof. Zwicker

Illumination. Illumination CMSC 435/634

Transcription:

Computergrafik Matthias Zwicker Universität Bern Herbst 2016

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 2

More realistic illumination In real world, at each point in scene light arrives from all directions Not just from point light sources Environment maps Store omni-directional illumination as images Each pixel corresponds to light from a certain direction 3

Capturing environment maps 360 degrees panoramic image Instead of 360 degrees panoramic image, take picture of mirror ball (light probe) Light probes [Paul Debevec, http://www.debevec.org/probes/] 4

Environment maps as light sources Simplifying assumption Assume light captured by environment map is emitted infinitely far away Environment map consists of directional light sources Value of environment map is defined for each direction, independent of position in scene Use single environment map as light source at all locations in the scene Approximation! 5

Environment maps as light sources How do you compute shading of a diffuse surface using an environment map? What is more expensive to compute, shading a diffuse or a specular surface? 6

Environment maps applications Use environment map as light source Global illumination [Sloan et al.] Reflection mapping 7

Sphere & cube maps Store incident light on sphere or on six faces of a cube Elevation q const. North pole q=90 South pole q=-90 Elevation, azimuthal angle Spherical map Cube map 8

Cube maps in OpenGL Application setup Load, bind a cube environment map glbindtexture(gl_texture_cube_map, ); // the six cube faces glteximage2d(gl_texture_cube_map_positive_x, ); glteximage2d(gl_texture_cube_map_negative_x, ); glteximage2d(gl_texture_cube_map_positive_y, ); glenable(gl_texture_cube_map); More details OpenGL Shading Language, Randi Rost OpenGL Superbible, Sellers et al. Online tutorials 9

Cube maps in OpenGL Look-up Given direction (x,y,z) Largest coordinate component determines cube map face Dividing by magnitude of largest component yields coordinates within face Look-up function built into GLSL Use (x,y,z) direction as texture coordinates to samplercube 10

Environment map data Also called light probes http://www.debevec.org/probes/ Tool for high dynamic range data (HDR) http://projects.ict.usc.edu/graphics/hdrshop/ Pre-rendered light probes for games http://docs.unity3d.com/manual/lightprobes.html Light probes (http://www.debevec.org/probes/) 11

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 12

Reflection mapping Simulate mirror reflection Compute reflection vector at each pixel using view direction and surface normal Use reflection vector to look up cube map Rendering cube map itself is optional Reflection mapping 13

Reflection mapping in GLSL Vertex shader Compute viewing direction for each vertex Reflection direction Use GLSL built-in reflect function Pass reflection direction to fragment shader Fragment shader Look-up cube map using interpolated reflection direction in float3 refl; uniform samplercube envmap; texture(envmap, refl); 14

Reflection mapping examples Approximation, reflections are not accurate [NVidia] 15

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 16

Shading using environment map Assumption: distant lighting Incident light is a function of direction, but not position Realistic shading requires Take into account light from all directions Include occlusion Illumination from environment Same environment map for both points Illumination is a function of direction, but not position 17

Mathematical model Assume Lambertian (diffuse) material, BRDF k d Ignore occlusion for now Illumination from point light sources Illumination from environment map using hemispherical integral Directions w Hemisphere of directions W Environment map, radiance from each direction c(w) 18

Irradiance environment maps Precompute irradiance as a function of normal Store as irradiance environment map Shading computation at render time Depends only on normal, not position Environment map Irradiance map 19

Irradiance environment maps Directional light Environment illumination Images from http://www.cs.berkeley.edu/~ravir/papers/envmap/ 20

Implementation Precompute irradiance map from environment HDRShop tool, diffuse convolution http://projects.ict.usc.edu/graphics/hdrshop/ At render time, look up irradiance map using surface normal When object rotates, rotate normal accordingly Can also approximate glossy reflection Blur environment map less heavily Look up blurred environment map using reflection vector 21

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 22

Including occlusion At each point, environment is partially occluded by geometry Add light only from un-occluded directions Visualization of un-occluded directions 23

Including occlusion Visibility function V x (w) Binary function of direction w Indicates if environment is occluded Depends on position x V x0 =1 V x1 =0 x0 x1 Environment map V x0 =0 Visibility functions V x1 =1 24

Mathematical model V x =1 Diffuse illumination with visibility Ambient occlusion V x =0 Fraction of environment that is not occluded from a point x Scalar value Approximation: diffuse shading given by irradiance weighted by ambient occlusion 25

Ambient occlusion Ambient occlusion Diffuse shading Ambient occlusion combined (using multiplication) with diffuse shading http://en.wikipedia.org/wiki/ambient_occlusion 26

Implementation Precomputation (off-line, before rendering) Compute ambient occlusion on a per-vertex basis Using ray tracing Free tool that saves meshes with per-vertex ambient occlusion http://www.xnormal.net/ Caution Basic pre-computed ambient occlusion does not work for animated objects 27

Shading integral Ambient occlusion with irradiance environment maps is crude approximation to general shading integral BRDF for (non-diffuse) material Incident directions w i Reflected radiance c(w o ) Hemisphere W Outgoing direction w o 28

Shading integral Accurate evaluation is expensive to compute Requires numerical integration Many tricks for more accurate and general approximation than ambient occlusion and irradiance environment maps exist Spherical harmonics shading http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf 29

Note Visually interesting results using combination (sum) of diffuse shading with ambient occlusion and reflection mapping Diffuse shading with ambient occlusion Reflection mapping Combination (sum) http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf 30

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 31

Reflection & refraction 32

Refraction http://en.wikipedia.org/wiki/refraction Light rays that travel from one medium to an other are bent To the viewer, object at location x appears to be at location y air water 33

Index of refraction http://en.wikipedia.org/wiki/refractive_index Speed of light depends on medium Speed of light in vacuum c Speed of light in medium v Index of refraction n=c/v Air 1.00029 Water 1.33 Acrylic glass 1.49 Change in phase velocity leads to bending of light rays air water 34

Snell s law http://en.wikipedia.org/wiki/snell's_law Ratio of sines of angle of incidence q 1 and refraction q 2 is equal to opposite ratio of indices of refraction n 1, n 2 Vector form in 3D Viewing, refracted direction v, r Normal vector n 35

Total internal reflection http://en.wikipedia.org/wiki/total_internal_reflection Angle of refracted ray Critical angle If we get, refracted ray is parallel to interface If we have total internal reflection (light ray does not cross interface between media) 36

Fresnel equations http://en.wikipedia.org/wiki/fresnel_equations When light travels from one medium to an other, both reflection and refraction may occur Fresnel equations describe fraction of intensity of light that is reflected and refracted Depend on polarization of light (R s, R p in plots) 37

Fresnel equations Fresnel equations are relatively complex to evaluate In graphics, often use Schlick s approximation https://en.wikipedia.org/wiki/schlick%27s_approximation Ratio F between reflected and refracted light Indices of refraction n 1, n 2 38

Implementation Accurate implementation requires ray tracing For interactive graphics, approximation using environment maps Use reflected and refracted rays to look up environment map Use Fresnel equations to determine fraction of reflected and refracted light Does not take into account geometry after first bounce (i.e., surface intersection) Assumes illumination is infinitely far away 39

Vertex shader const float Eta = 0.67; // Ratio of indices of refraction (air -> glass) const float FresnelPower = 10.0; // Controls degree of reflectivity at grazing angles const float F = ((1.0 - Eta) * (1.0 - Eta)) / ((1.0 + Eta) * (1.0 + Eta)); varying vec3 Reflect; varying vec3 Refract; varying float Ratio; void main(void) { vec4 ecposition = gl_modelviewmatrix * gl_vertex; vec3 ecposition3 = ecposition.xyz / ecposition.w; CAUTION: need to update this for OpenGL 3 compliance vec3 i = normalize(ecposition3); vec3 n = normalize(gl_normalmatrix * gl_normal); Ratio = F + (1.0 - F) * pow((1.0 - dot(-i, n)), FresnelPower); Refract = refract(i, n, Eta); Refract = vec3(gl_texturematrix[0] * vec4(refract, 1.0)); Reflect = reflect(i, n); Reflect = vec3(gl_texturematrix[0] * vec4(reflect, 1.0)); } gl_position = ftransform(); 40

Fragment shader Application needs to set up cube map varying vec3 Reflect; varying vec3 Refract; varying float Ratio; uniform samplercube cubemap; CAUTION: need to update this for OpenGL 3 compliance void main(void) { vec3 refractcolor = vec3 (texturecube(cubemap, Refract)); vec3 reflectcolor = vec3 (texturecube(cubemap, Reflect)); vec3 color = mix(refractcolor, reflectcolor, Ratio); } gl_fragcolor = vec4(color, 1.0); 41

Chromatic dispersion http://en.wikipedia.org/wiki/dispersion_(optics) Phase velocity (i.e., index of refraction) in many media depends on wavelength/frequency Dispersive media Different colors refract at different angles 42

Chromatic dispersion In the context of camera lenses, chromatic aberration Try to use achromatic lenses 43

Implementation Approximate dispersion by using three different ratios of indices of refraction for R,G,B channels Glass: 0.65, 0.67, 0.69 Perform separate look-ups for R,G,B channels in environment map 44

Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading 45

Toon shading Simple cartoon style shader Emphasize silhouettes Discrete steps for diffuse shading, highlights Sometimes called CEL shading http://en.wikipedia.org/wiki/cel-shaded_animation Off-line toon shader GLSL toon shader 46

Toon shading Silhouette edge detection Compute dot product of viewing direction v and normal n Use 1D texture to define edge ramp uniform sample1d edgeramp; e=texture1d(edgeramp,edge); edgeramp 1 0 edge 47

Toon shading Compute diffuse and specular shading Use 1D textures diffuseramp, specularramp to map diffuse and specular shading to colors Final color uniform sampler1d diffuseramp; uniform sampler1d specularramp; c = e * (texture(diffuse,diffuseramp)+ texture(specular,specularramp)); 48

Tools Nvidia developer page http://developer.nvidia.com/page/home.html 49

Next time Bump mapping, shadows 50