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

Similar documents
CSE 167: Introduction to Computer Graphics Lecture #19: Wrapping Up. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Particle systems, collision detection, and ray tracing. Computer Graphics CSE 167 Lecture 17

CSE 167: Introduction to Computer Graphics Lecture #16: Procedural Modeling

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

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

Computergrafik. Matthias Zwicker. Herbst 2010

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

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

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

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

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

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

Overview. A real-time shadow approach for an Augmented Reality application using shadow volumes. Augmented Reality.

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

Computer Graphics. Shadows

The Traditional Graphics Pipeline

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

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

The Traditional Graphics Pipeline

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

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

The Traditional Graphics Pipeline

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

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

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

Texture mapping. Computer Graphics CSE 167 Lecture 9

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

CS 431/636 Advanced Rendering Techniques

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Graphics and Interaction Rendering pipeline & object modelling

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

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

Computer Graphics 10 - Shadows

Volume Shadows Tutorial Nuclear / the Lab

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

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

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

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

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

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

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

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

COMP 175: Computer Graphics April 11, 2018

Pipeline Operations. CS 4620 Lecture 10

What for? Shadows tell us about the relative locations. Vienna University of Technology 2

Hidden surface removal. Computer Graphics

CS 354R: Computer Game Technology

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

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

Shadows. Real-Time Hard Shadows. Collected by Ronen Gvili. Most slides were taken from : Fredu Durand Stefan Brabec

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

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

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

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Texture-Mapping Tricks. How Bad Does it Look? We've Seen this Sort of Thing Before. Sampling Texture Maps

CSE 167: Lecture #17: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

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

Introduction to Visualization and Computer Graphics

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Graphics Shadow Algorithms

Performance OpenGL Programming (for whatever reason)

CPSC GLOBAL ILLUMINATION

CSE 167: Introduction to Computer Graphics Lecture 11: Scene Graph 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

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

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

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

Deferred Rendering Due: Wednesday November 15 at 10pm

CS GAME PROGRAMMING Question bank

Announcements. Written Assignment 2 is out see the web page. Computer Graphics

Physically-Based Laser Simulation

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

Procedural modeling and shadow mapping. Computer Graphics CSE 167 Lecture 15

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

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

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Shading. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller/Fuhrmann

Shadow Rendering EDA101 Advanced Shading and Rendering

Collision and Proximity Queries

Topic 10: Scene Management, Particle Systems and Normal Mapping. CITS4242: Game Design and Multimedia

Spring 2009 Prof. Hyesoon Kim

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

DiFi: Distance Fields - Fast Computation Using Graphics Hardware

References. Additional lecture notes for 2/18/02.

Computer Graphics 7 - Texture mapping, bump mapping and antialiasing

Shadows in the graphics pipeline

Advanced Shading I: Shadow Rasterization Techniques

Shadows in Computer Graphics. by Björn Kühl im/ve University of Hamburg, Germany

Abstract. 2 Description of the Effects Used. 1 Introduction Phong Illumination Bump Mapping

Transcription:

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

Announcements TA evaluations CAPE Final project blog entries Monday, Nov 28th at 11:59pm Sunday, Dec 4th at 11:59pm Wednesday, Dec 7th at 11:59pm, includes video 2

Lecture Overview Particle Systems Collision Detection Bump Mapping Shadow Volumes 3

Particle Systems 4

Particle Systems Used for: Fire/sparks Rain/snow Water spray Explosions Galaxies 5

Internal Representation Particle system is collection of a number of individual elements (particles) Controls a set of particles which act autonomously but share some common attributes Particle Emitter: Source of all new particles 3D point Polygon mesh: particles initial velocity vector is normal to surface Particle attributes: position (3D) velocity (vector: speed and direction) color + opacity lifetime size shape weight 6

Dynamic Updates Particles change position and/or attributes with time Initial particle attributes often created with random numbers Frame update: Parameters: simulation of particles, can include collisions with geometry Forces (gravity, wind, etc) accelerate a particle Acceleration changes velocity Velocity changes position Rendering: display as OpenGL points (Textured) billboarded quads Point sprites 7 Source: http://www.particlesystems.org/

Point Sprite Screen-aligned element of variable size Defined by single point Sample code: gltexenvf(gl_point_sprite, GL_COORD_REPLACE, GL_TRUE); glenable(gl_point_sprite); glbegin(gl_points); glvertex3f(position.x, position.y, position.z); glend(); gldisable(gl_point_sprite); 8

Demo Demo software by Prof. David McAllister: http://www.calit2.net/~jschulze/tmp/particle221demos.zip 9

References Tutorial with source code by Bartlomiej Filipek, 2014: http://www.codeproject.com/articles/795065/flexible-particle-system-opengl- Renderer Articles with source code: Jeff Lander: The Ocean Spray in Your Face, Game Developer, July 1998 http://www.darwin3d.com/gamedev/articles/col0798.pdf John Van Der Burg: Building an Advanced Particle System, Gamasutra, June 2000 http://www.gamasutra.com/view/feature/3157/building_an_advanced_particle_.php Founding scientific paper: Reeves: Particle Systems - A Technique for Modeling a Class of Fuzzy Objects, ACM Transactions on Graphics (TOG) Volume 2 Issue 2, April 1983 http://zach.in.tu-clausthal.de/teaching/vr_literatur/reeves%20-%20particle%20systems.pdf 10

Collison Detection 11

Collision Detection Goals: Physically correct simulation of collision of objects Not covered here Determine if two objects intersect Slow calculation because of exponential growth O(n 2 ): # collision tests = n*(n-1)/2 12

Intersection Testing Purpose: Keep moving objects on the ground Keep moving objects from going through walls, each other, etc. Goal: Believable system, does not have to be physically correct Priority: Computationally inexpensive Typical approach: Spatial partitioning Object simplified for collision detection by one or a few Points Spheres Axis aligned bounding box (AABB) Pairwise checks between points/spheres/aabbs and static geometry 13

Sweep and Prune Algorithm Sorts bounding boxes Not intuitively obvious how to sort bounding boxes in 3-space Dimension reduction approach: Project each 3-dimensional bounding box onto the x,y and z axes Find overlaps in 1D: a pair of bounding boxes can overlap if and only if their intervals overlap in all three dimensions Construct 3 lists, one for each dimension Each list contains start/end point of intervals corresponding to that dimension By sorting these lists, we can determine which intervals overlap Reduce sorting time by keeping sorted lists from previous frame, changing only the interval endpoints Alternative: project bounding boxes onto coordinate axis planes and look for overlaps in 2D 14

Collision Map (CM) 2D map with information about where objects can go and what happens when they go there Colors indicate different types of locations Map can be computed from 3D model, or hand drawn with paint program Granularity: defines how much area (in object space) one CM pixel represents 15

Bump Mapping 16

Bump Mapping Many textures are the result of small perturbations in the surface geometry Modeling these changes would result in an explosion in the number of geometric primitives. Bump mapping attempts to alter the lighting across a polygon to provide the illusion of texture. [This chapter includes slides by Roger Crawfis]

Bump Mapping Example Crawfis 1991

Bump Mapping Consider the lighting for a modeled surface.

Bump Mapping We can model this as deviations from some base surface. The question is then how these deviations change the lighting. N

Bump Mapping Store in a texture and use textures to alter the surface normal Does not change the shape of the surface Just shaded as if it were a different shape Sphere w/diffuse Texture Swirly Bump Map Sphere w/diffuse Texture & Bump Map

Simple textures work great Bump Map Cylinder w/diffuse Texture Map Cylinder w/texture Map & Bump Map

Normal Mapping

Normal Mapping Just texture mapped Texture and normal maps Notice: The geometry is unchanged. There s the same number of vertices and triangles. This effect is entirely from the normal map.

Normal Maps Store the normal directly in the texture.

Normal Maps Diffuse Color Texture Map Normal Map Each pixel RGB values is really a normal vector relative to the surface at that point. -1 to 1 range is mapped to 0 to 1 for the texture so normals become colors.

Normal Map Operation Vertex Normal Normals from Normal Map Vertex Normal For each pixel, determine the normal from a texture image. Use that to compute the color.

What's Missing? There are no bumps on the silhouette of a bump or normal-mapped object Displacement Mapping

Shadow Volumes 29

Shadow Volumes 30 NVIDIA md2shader demo

Shadow Volumes A single point light source splits the world in two Shadowed regions Unshadowed regions Volumetric shadow technique A shadow volume is the boundary between these shadowed and unshadowed regions Determine if an object is inside the boundary of the shadowed region and know the object is shadowed 31

Shadow Volumes Many variations of the algorithm exist Most popular ones use the stencil buffer Depth Pass Depth Fail (a.k.a. Carmack s Reverse, developed for Doom 3) Exclusive-Or (limited to non-overlapping shadows) Most algorithms designed for hard shadows Algorithms for soft shadows exist 32

Shadow Volumes Light source Shadowing object Surface outside shadow volume (illuminated) Shadow volume (infinite extent) Eye position (note that shadows are independent of the eye position) Partially shadowed object Surface inside shadow volume (shadowed) 33

Shadow Volume Algorithm High-level view of the algorithm Given the scene and a light source position, determine the geometry of the shadow volume Render the scene in two passes Draw scene with the light enabled, updating only fragments in unshadowed region Draw scene with the light disabled, updated only fragments in shadowed region 34

Shadow Volume Construction Need to generate shadow polygons to bound shadow volume Extrude silhouette edges from light source 35 Extruded shadow volumes

Shadow Volume Construction Done on the CPU Silhouette edge detection An edge is a silhouette if one adjacent triangle is front facing, the other back facing with respect to the light Extrude polygons from silhouette edges 36

Stenciled Shadow Volumes Advantages Support omnidirectional lights Exact shadow boundaries Disadvantages Fill-rate intensive Expensive to compute shadow volume geometry Hard shadow boundaries, not soft shadows Difficult to implement robustly Source: Zach Lynn 37

The Stencil Buffer Per-pixel 2D buffer on the GPU Similarities to depth buffer in way it is stored and accessed Stores an integer value per pixel, typically 8 bits Like a stencil, allows to block pixels from being drawn Typical uses: shadow mapping planar reflections portal rendering Source: Adrian-Florin Visan 38

Video Using the stencil buffer, rendering a stencil mirror tutorial http://www.youtube.com/watch?v=3xzq-yeoisk 39

Tagging Pixels as Shadowed or Unshadowed The stenciling approach Clear stencil buffer to zero and depth buffer to 1.0 Render scene to leave depth buffer with closest Z values Render shadow volume into frame buffer with depth testing but without updating color and depth, but inverting a stencil bit (Exclusive-Or method) This leaves stencil bit set within shadow 40

Stencil Inverting of Shadow Volume Light source Shadowing object Two inverts, left zero One invert, left one Eye position Zero inverts, left zero 41

Visualizing Stenciled Shadow Volume Tagging Shadowed scene Stencil buffer contents red = stencil value of 1 green = stencil value of 0 GLUT shadowvol example credit: Tom McReynolds 42

For Shadow Volumes With Intersecting Polygons Use a stencil enter/leave counting approach Draw shadow volume twice using face culling 1st pass: render front faces and increment when depth test passes 2nd pass: render back faces and decrement when depth test passes This two-pass way is more expensive than invert Inverting is better if all shadow volumes have no polygon intersections 43

Increment/Decrement Stencil Volumes Light source Shadowing object zero +1 zero Eye position +1 +2 +2 +3 44

Shadow Volume Demo URL: http://www.paulsprojects.net/opengl/shadvol/shadvol.html 45

Resources for Shadow Rendering Overview, lots of links http://www.realtimerendering.com/ Basic shadow maps http://en.wikipedia.org/wiki/shadow_mapping Avoiding sampling problems in shadow maps http://www.comp.nus.edu.sg/~tants/tsm/tsm.pdf http://www.cg.tuwien.ac.at/research/vr/lispsm/ Faking soft shadows with shadow maps http://people.csail.mit.edu/ericchan/papers/smoothie/ Alternative: shadow volumes http://en.wikipedia.org/wiki/shadow_volume http://www.gamedev.net/reference/articles/article1873.asp 46