To Do. Advanced Computer Graphics. Real-Time Rendering. Motivation. Offline 3D Graphics Rendering. Evolution of 3D graphics rendering

Similar documents
Shadow and Environment Maps

Outline of Lecture. Real-Time High Quality Rendering. Geometry or Vertex Pipeline. Basic Hardware Pipeline. Pixel or Fragment Pipeline

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

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

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

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

03 RENDERING PART TWO

CS 283: Assignment 3 Real-Time / Image-Based Rendering

Texture. Detail Representation

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Shadows. Shadows. Spatial relationship between objects. Shadows as depth cue. Spatial relationship between objects

CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

To Do. Demo for mytest3. Methodology for Lecture. Importance of Lighting. Brief primer on Color. Computer Graphics

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Shadows. Shadows. Spatial relationship between objects. Shadows as depth cue. Spatial relationship between objects

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

To Do. Advanced Computer Graphics. Course Outline. Course Outline. Illumination Models. Diffuse Interreflection

Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.

Texture. Texture Maps

Discussion. Smoothness of Indirect Lighting. History and Outline. Irradiance Calculation. Irradiance Caching. Advanced Computer Graphics (Spring 2013)

Motivation. My General Philosophy. Assumptions. Advanced Computer Graphics (Spring 2013) Precomputation-Based Relighting

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

Rendering and Radiosity. Introduction to Design Media Lecture 4 John Lee

lecture 18 - ray tracing - environment mapping - refraction

Programmable GPUS. Last Time? Reading for Today. Homework 4. Planar Shadows Projective Texture Shadows Shadow Maps Shadow Volumes

Texture mapping. Computer Graphics CSE 167 Lecture 9

Chapter 7 - Light, Materials, Appearance

Computer Graphics Introduction. Taku Komura

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

The Rasterization Pipeline

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Shaders. Slide credit to Prof. Zwicker

Shadows. Shadows. Thanks to: Frédo Durand and Seth Teller MIT. Realism Depth cue

Computergrafik. Matthias Zwicker. Herbst 2010

CSE 163: Assignment 3 Final Project

frame buffer depth buffer stencil buffer

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Advanced Shading and Texturing

Motivation: Monte Carlo Rendering. Sampling and Reconstruction of Visual Appearance. Caustics. Illumination Models. Overview of lecture.

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

CS427 Multicore Architecture and Parallel Computing

The Traditional Graphics Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

The Traditional Graphics Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Lecture 17: Shadows. Projects. Why Shadows? Shadows. Using the Shadow Map. Shadow Maps. Proposals due today. I will mail out comments

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

x ~ Hemispheric Lighting

Pipeline Operations. CS 4620 Lecture 10

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

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

Hardware Shading: State-of-the-Art and Future Challenges

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

Recall: Indexing into Cube Map

To Do. Real-Time High Quality Rendering. Motivation for Lecture. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

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

CS 354R: Computer Game Technology

Instructor. Goals. Image Synthesis Examples. Applications. Foundations of Computer Graphics. Why Study 3D Computer Graphics?

Overview. Computer Graphics CS324. OpenGL. Books. Learning Resources. CS131 Notes. 30 Lectures 3hr Exam

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

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

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

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

Pipeline Operations. CS 4620 Lecture 14

Multiple Importance Sampling

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

BRDF Computer Graphics (Spring 2008)

3D Rasterization II COS 426

Introduction to Visualization and Computer Graphics

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Introduction. Chapter Computer Graphics

Graphics and Imaging Architectures

COMP371 COMPUTER GRAPHICS

Monte-Carlo Ray Tracing. Antialiasing & integration. Global illumination. Why integration? Domains of integration. What else can we integrate?

Computer Graphics Shadow Algorithms

Evolution of Imaging Technology in Computer Graphics. Related Areas

Shadow Rendering EDA101 Advanced Shading and Rendering

Supplement to Lecture 22

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

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

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

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

The Traditional Graphics Pipeline

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

Chapter 1 Introduction

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

To Do. Demo for mytest3. Methodology for Lecture. Importance of Lighting. Brief primer on Color. Foundations of Computer Graphics (Spring 2012)

Computer Graphics 10 - Shadows

The Rasterization Pipeline

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

Transcription:

Advanced Computer Graphics CSE 163 [Spring 2017], Lecture 12 Ravi Ramamoorthi http://www.cs.ucsd.edu/~ravir To Do Assignment 2 due May 19 Should already be well on way. Contact us for difficulties etc. Motivation Today, create photorealistic computer graphics Complex geometry, lighting, materials, shadows Computer-generated movies/special effects (difficult or impossible to tell real from rendered ) Real-Time Rendering Goal: interactive rendering. Critical in many apps Games, visualization, computer-aided design, Until 10-15 years ago, focus on complex geometry CSE 168 images from rendering competition (2011) But algorithms are very slow (hours to days) Chasm between interactivity, realism Evolution of 3D graphics rendering Interactive 3D graphics pipeline as in OpenGL Earliest SGI machines (Clark 82) to today Most of focus on more geometry, texture mapping Some tweaks for realism (shadow mapping, accum. buffer) Offline 3D Graphics Rendering Ray tracing, radiosity, photon mapping High realism (global illum, shadows, refraction, lighting,..) But historically very slow techniques So, while you and your children s children are waiting for ray tracing to take over the world, what do you do in the meantime? Real-Time Rendering SGI Reality Engine 93 (Kurt Akeley) Pictures courtesy Henrik Wann Jensen 1

New Trend: Acquired Data Image-Based Rendering: Real/precomputed images as input Also, acquire geometry, lighting, materials from real world Easy to obtain or precompute lots of high quality data. But how do we represent and reuse this for (real-time) rendering? 15 years ago High quality rendering: ray tracing, global illumination Little change in CSE 168 syllabus, from 2003 to today Real-Time rendering: Interactive 3D geometry with simple texture mapping, fake shadows (OpenGL, DirectX) Complex environment lighting, real materials (velvet, satin, paints), soft shadows, caustics often omitted in both Realism, interactivity at cross purposes Today: Real-Time Game Renderings Today Vast increase in CPU power, modern instrs (SSE, Multi-Core) Real-time raytracing techniques are possible (even on hardware: NVIDIA Optix) Unreal Engine 4 https://www.youtube.com/watch?v=gthamlnpxyk#t=33 4 th generation of graphics hardware is programmable (First 3 gens were wireframe, shaded, textured) Modern NVIDIA, ATI cards allow vertex, fragment shaders Digital Ira: NVIDIA, USC Great deal of current work on acquiring and rendering with realistic lighting, materials [Especially at UCSD] Focus on quality of rendering, not quantity of polygons, texture Goals Overview of basic techniques for high-quality real-time rendering Survey of important concepts and ideas, but do not go into details of writing code Outline Motivation and Demos Programmable Graphics Pipeline Shadow Maps Environment Mapping Some pointers to resources, others on web One possibility for assignment 3, will need to think about some ideas on your own 2

High quality real-time rendering Photorealism, not just more polygons Natural lighting, materials, shadows High quality real-time rendering Photorealism, not just more polygons Natural lighting, materials, shadows Interiors by architect Frank Gehry. Note rich lighting, ranging from localized sources to reflections off vast sheets of glass. Glass Vase Glass Star (courtesy Intel) Peacock feather Real materials diverse and not easy to represent by simple parameteric models. Want to support measured reflectance. High quality real-time rendering Photorealism, not just more polygons Today: Full Global Illumination Natural lighting, materials, shadows small area light, sharp shadows soft and hard shadows Agrawala et al. 00 Ng et al. 03 Natural lighting creates a mix of soft diffuse and hard shadows. Applications Programmable Graphics Hardware Entertainment: Lighting design Architectural visualization Material design: Automobile industry Realistic Video games Electronic commerce 3

Programmable Graphics Hardware Precomputation-Based Methods Static geometry Precomputation Real-Time Rendering (relight all-frequency effects) NVIDIA a new dawn demo http://www.geforce.com/games-applications/pcapplications/a-new-dawn/videos Involves sophisticated representations, algorithms Relit Images Video: Real-Time Relighting Ng, Ramamoorthi, Hanrahan 04 Spherical Harmonic Lighting Interactive RayTracing Advantages Very complex scenes relatively easy (hierarchical bbox) Complex materials and shading for free Easy to add global illumination, specularities etc. Disadvantages Hard to access data in memory-coherent way Many samples for complex lighting and materials Global illumination possible but expensive Modern developments: Leverage power of modern CPUs, develop cache-aware, parallel implementations https://www.youtube.com/watch?v=kcp1nzb49zu Avatar 2010, based on Ramamoorthi and Hanrahan 01, Sloan 02 4

Sparse Sampling, Reconstruction Sparse Sampling, Reconstruction Same algorithm as offline Monte Carlo rendering But with smart sampling and filtering (current work) Outline Motivation and Demos Programmable Graphics Pipeline Shadow Maps Environment Mapping Basic Hardware Pipeline Application Geometry Rasterizer CPU GPU Create geometry, lights, materials, textures, cubemaps, as inputs Transform and lighting calcs. Apply per-vertex operations Textures, Cubemaps Per-pixel (per-fragment) operations Geometry or Vertex Pipeline Pixel or Fragment Pipeline Model, View Transform Lighting Projection Clipping Screen Rasterization (scan conversion) Texture Mapping Z-buffering Framebuffer These fixed function stages can be replaced by a general per-vertex calculation using vertex shaders in modern programmable hardware These fixed function stages can be replaced by a general per-fragment calculation using fragment shaders in modern programmable hardware 5

Vertices Images OpenGL Rendering Pipeline Programmable in Modern GPUs (Vertex Shader) Geometry Primitive Operations Pixel Operations Scan Conversion (Rasterize) Texture Memory Programmable in Modern GPUs (Fragment Shader) Fragment Operations Traditional Approach: Fixed function pipeline (state machine) New Development (2003-): Programmable pipeline Framebuffer Simplified OpenGL Pipeline User specifies vertices (vertex buffer object) For each vertex in parallel OpenGL calls user-specified vertex shader: Transform vertex (ModelView, Projection), other ops For each primitive, OpenGL rasterizes Generates a fragment for each pixel the fragment covers For each fragment in parallel OpenGL calls user-specified fragment shader: Shading and lighting calculations OpenGL handles z-buffer depth test unless overwritten Modern OpenGL is lite basically just a rasterizer Real action in user-defined vertex, fragment shaders Shading Languages Vertex / Fragment shading described by small program Written in language similar to C but with restrictions Long history. Cook s paper on Shade Trees, Renderman for offline rendering Stanford Real-Time Shading Language, work at SGI Cg from NVIDIA, HLSL GLSL directly compatible with OpenGL 2.0 (So, you can just read the OpenGL Red Book to get started) Shader Setup Initializing (shader itself discussed later) 1. Create shader (Vertex and Fragment) 2. Compile shader 3. Attach shader to program 4. Link program 5. Use program Shader source is just sequence of strings Similar steps to compile a normal program Shader Initialization Code Linking Shader Program GLuint initshaders (GLenum type, const char *filename) { // Using GLSL shaders, OpenGL book, page 679 GLuint shader = glcreateshader(type) ; GLint compiled ; string str = textfileread (filename) ; GLchar * cstr = new GLchar[str.size()+1] ; const GLchar * cstr2 = cstr ; // Weirdness to get a const char strcpy(cstr,str.c_str()) ; glshadersource (shader, 1, &cstr2, NULL) ; glcompileshader (shader) ; glgetshaderiv (shader, GL_COMPILE_STATUS, &compiled) ; if (!compiled) { shadererrors (shader) ; throw 3 ; } return shader ; } GLuint initprogram (GLuint vertexshader, GLuint fragmentshader) { GLuint program = glcreateprogram() ; GLint linked ; glattachshader(program, vertexshader) ; glattachshader(program, fragmentshader) ; gllinkprogram(program) ; glgetprogramiv(program, GL_LINK_STATUS, &linked) ; if (linked) gluseprogram(program) ; else { programerrors(program) ; throw 4 ; } return program ; } 6

Cliff Lindsay web.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/gpu.pdf Cliff Lindsay web.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/gpu.pdf Fragment Shader Compute Lighting vec4 ComputeLight (const in vec3 direction, const in vec4 lightcolor, const in vec3 normal, const in vec3 halfvec, const in vec4 mydiffuse, const in vec4 myspecular, const in float myshininess) { float ndotl = dot(normal, direction) ; vec4 lambert = mydiffuse * lightcolor * max (ndotl, 0.0) ; float ndoth = dot(normal, halfvec) ; vec4 phong = myspecular * lightcolor * pow (max(ndoth, 0.0), myshininess) ; Outline Motivation and Demos Programmable Graphics Pipeline Shadow Maps Environment Mapping } vec4 retval = lambert + phong ; return retval ; Discuss Assignment 2, due date Shadow and Environment Maps Basic methods to add realism to interactive rendering Shadow maps: image-based way hard shadows Very old technique. Originally Williams 78 Many recent (and older) extensions Widely used even in software rendering (RenderMan) Simple alternative to raytracing for shadows Environment maps: image-based complex lighting Again, very old technique. Blinn and Newell 76 Huge amount of recent work (some covered in course) Together, give most of realistic effects we want But cannot be easily combined!! See Annen 08 [real-time all-frequency shadows dynamic scenes] for one approach: convolution soft shadows Common Real-time Shadow Techniques Light maps Projected planar shadows Hybrid approaches Shadow volumes This slide, others courtesy Mark Kilgard 7

Problems Mostly tricks with lots of limitations Projected planar shadows works well only on flat surfaces Stenciled shadow volumes determining the shadow volume is hard work Light maps totally unsuited for dynamic shadows In general, hard to get everything shadowing everything Shadow Mapping Lance Williams: Brute Force in image space (shadow maps in 1978, but other similar ideas like Z buffer, bump mapping using textures and so on) Completely image-space algorithm no knowledge of scene s geometry is required must deal with aliasing artifacts Well known software rendering technique Basic shadowing technique for Toy Story, etc. Phase 1: Render from Light Depth image from light source Phase 1: Render from Light Depth image from light source Phase 2: Render from Eye Standard image (with depth) from eye Phase 2+: Project to light for shadows Project visible points in eye view back to light source Eye Eye (Reprojected) depths match for light and eye. VISIBLE 8

Phase 2+: Project to light for shadows Project visible points in eye view back to light source Visualizing Shadow Mapping A fairly complex scene with shadows Eye the point light source (Reprojected) depths from light, eye not the same. BLOCKED!! Visualizing Shadow Mapping Compare with and without shadows Visualizing Shadow Mapping The scene from the light s point-of-view FYI: from the eye s point-of-view again with shadows without shadows Visualizing Shadow Mapping The depth buffer from the light s point-of-view Visualizing Shadow Mapping Projecting the depth map onto the eye s view FYI: from the light s point-of-view again FYI: depth map for light s point-of-view again 9

Visualizing Shadow Mapping Comparing light distance to light depth map Visualizing Shadow Mapping Scene with shadows Green is where the light planar distance and the light depth map are approximatel y equal Non-green is where shadows should be Notice how specular highlights never appear in shadows Notice how curved surfaces cast shadows on each other Hardware Shadow Map Filtering Hardware Shadow Map Filtering Percentage Closer filtering Normal texture filtering just averages color components Averaging depth values does NOT work Solution [Reeves, SIGGARPH 87] Hardware performs comparison for each sample Then, averages results of comparisons Provides anti-aliasing at shadow map edges Not soft shadows in the umbra/penumbra sense GL_NEAREST: blocky GL_LINEAR: antialiased edges Low shadow map resolution used to heighten filtering artifacts Problems with shadow maps Reflection Maps Hard shadows (point lights only) Quality depends on shadow map resolution (general problem with image-based techniques) Involves equality comparison of floating point depth values means issues of scale, bias, tolerance Blinn and Newell, 1976 10

Environment Maps Environment Maps Miller and Hoffman, 1984 Interface, Chou and Williams (ca. 1985) Environment Maps Cylindrical Panoramas Reflectance Maps Reflectance Maps (Index by N) Horn, 1977 Irradiance (N) and Phong (R) Reflection Maps Miller and Hoffman, 1984 Cubical Environment Map 180 degree fisheye Photo by R. Packo Mirror Sphere Chrome Sphere Matte Sphere Irradiance Environment Maps R N Assumptions Diffuse surfaces Distant illumination No shadowing, interreflection Hence, Irradiance a function of surface normal Incident Radiance (Illumination Environment Map) Irradiance Environment Map 11

Radiosity (image intensity) Diffuse Reflection B = = ρe Reflectance (albedo/texture) Irradiance (incoming light) Analytic Irradiance Formula Lambertian surface acts like low-pass filter E lm = A l L lm Al 0 π 2 π /3 0 1 2 π /4 l quake light map Ramamoorthi and Hanrahan 01 Basri and Jacobs 01 ( 1) l 2 1 l! A l = 2π (l + 2)(l 1) 2 l ( l! 2 )2 l even 9 Parameter Approximation 9 Parameter Approximation Exact image Order 0 1 term Exact image Order 1 4 terms RMS error = 25 % 0 l m Y lm (θ,ϕ) RMS Error = 8% 0 l m Y lm (θ,ϕ) 1 y z x 1 y z x 2 xy yz 3z 2 1 zx x 2 y 2 2 xy yz 3z 2 1 zx x 2 y 2-2 -1 0 1 2-2 -1 0 1 2 Exact image 9 Parameter Approximation RMS Error = 1% For any illumination, average error < 3% [Basri Jacobs 01] 0 1 2 l m y z Order 2 9 terms Y lm (θ,ϕ) xy yz 3z 2 1 zx x 2 y 2-2 -1 0 1 2 x Real-Time Rendering E(n) = n t Mn Simple procedural rendering method (no textures) Requires only matrix-vector multiply and dot-product In software or NVIDIA vertex programming hardware Widely used in Games (AMPED for Microsoft Xbox), Movies (Pixar, Framestore CFC, ) surface float1 irradmat (matrix4 M, float3 v) { float4 n = {v, 1} ; return dot(n, M*n) ; } 12

Environment Map Summary Very popular for interactive rendering Extensions handle complex materials Shadows with precomputed transfer But cannot directly combine with shadow maps Limited to distant lighting assumption Resources OpenGL red book (latest includes GLSL) Web tutorials: http://www.lighthouse3d.com/opengl/glsl/ Older books: OpenGL Shading Language book (Rost), The Cg Tutorial, http://www.realtimerendering.com Real-Time Rendering by Moller and Haines Debevec http://www.debevec.org/reflectionmapping/ Links to Miller and Hoffman original, Haeberli/Segal http://www.cs.berkeley.edu/~ravir/papers/envmap Also papers by Heidrich, Cabral, Lots of information available on web Look at resources from CSE 274 website 13