An Approximation of Volumetric Lighting

Slides:



Advertisements
Similar presentations
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Advertisements

Light Issues in Computer Graphics Presented by Saleema Amershi.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Alla Sheffer Advanced Rendering Week.
CSCE 641: Photon Mapping Jinxiang Chai. Outline Rendering equation Photon mapping.
Representing Geometry in Computer Graphics Rick Skarbez, Instructor COMP 575 September 18, 2007.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
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.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
CSS 522 Topics in Rendering March 01,2011 Scott and Lew.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
02/25/05© 2005 University of Wisconsin Last Time Meshing Volume Scattering Radiometry (Adsorption and Emission)
-Global Illumination Techniques
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Week 10 - Wednesday.  What did we talk about last time?  Shadow volumes and shadow mapping  Ambient occlusion.
CSE 381 – Advanced Game Programming GLSL Lighting.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Ray Tracer Spring 2008 Help Session. Outline Project Web Resources What do you have to do for this project? Ray Class Isect Class Requirements Tricks.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
RENDERING : Global Illumination
CSE 681 Introduction to Ray Tracing. CSE 681 Ray Tracing Shoot a ray through each pixel; Find first object intersected by ray. Image plane Eye Compute.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Volumetric Lighting Effects By Thomas Brown and Albert Ng.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
CIS 681 Distributed Ray Tracing. CIS 681 Anti-Aliasing Graphics as signal processing –Scene description: continuous signal –Sample –digital representation.
Computer Graphics Lecture 26 Mathematics of Lighting and Shading Part II Taqdees A. Siddiqi

Basic Ray Tracing CMSC 435/634.
Reflection & Mirrors.
Shading Revisited Some applications are intended to produce pictures that look photorealistic, or close to it The image should look like a photograph A.
Ray Tracer Spring 2007 Help Session.
Distributed Ray Tracing
Deferred Lighting.
Ray Tracing Dr. Scott Schaefer.
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Tracing Geometry CSE 681.
Mike Merchant Nicholas Hilbert
Ray Tracing Geometry CSE 681.
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
An Approximation of Volumetric Lighting
Real-Time Volume Graphics [06] Local Volume Illumination
Lighting.
Caustics Ray Tracing CSS522
Distributed Ray Tracing
CS5500 Computer Graphics May 29, 2006
CSCE 441: Computer Graphics Ray Tracing
Ray Tracer Spring 2004 Help Session.
GR2 Advanced Computer Graphics AGR
Ray Tracer Spring 2008 Help Session.
Chapter 14 Shading Models.
CS 480/680 Computer Graphics Shading.
Introduction to Ray Tracing
Distributed Ray Tracing
GPAT – Chapter 7 Physics.
Real-time Global Illumination with precomputed probe
Ray Tracer Autumn 2005 Help Session.
Ray Tracer Spring 2006 Help Session.
Presentation transcript:

An Approximation of Volumetric Lighting By Thomas Brown and Albert Ng

What We’ll Discuss... What is Volumetric Lighting? What’s the problem? What’s our solution? What are some issues we might encounter?

What is Volumetric Lighting? Volumetric lighting gives lighting a 3D volume that can interact with other aspects of a scene It can interact with items like fog or solid objects to create interesting lighting effects Volumetric lighting can produce effects like: Headlights in a foggy night Sunlight coming through a window Smoke blocking one’s view

Pictures of Volumetric Lighting Light Through A Window

Headlights in Fog

Obscured Vision

A Graphics Render of Volumetric Lighting

Another Graphics Render of Volumetric Lighting

The Problem Must model interaction of light with billions of tiny particles representing fog or dust clouds Refraction and reflection can add to the complexity Must be feasible in terms of memory, computation time, and resources Has to interact with the scene Needs to look good General volumes Light attenuation Light refraction/reflection Fog should look like fog, not random noise

Analyzing Our Options We can either: Create a large number of tiny geometries that represent the particles suspended in the scene Accurate! SLOW Create fog textures Very fast! Can get stretched Won’t interact with the scene well Create a geometry that can correctly represent and produce volumetric lighting effects Slower than texture mapping Looks decent Can interact with the scene More complicated to implement

Our Solution Create geometries that will realistically represent lights or fog Add a 3D cone as it a common geometry in volumetric lighting Alter IntersectionRecord calculations to calculate both entry and exit points Find a pseudo-random number generator that will give us somewhat similar results as we traverse a 3D environment Normal RNG is terrible! Numbers aren’t related at all, will just give noise Perlin’s Noise is perfect! Approximate the density of particles inside the volume Calculate light exposure/attenuation Calculate shading along a ray

Aspects of Our Solution Make 3D Geometries Start with a cone Intersect a ray with a cone Update IntersectionRecord to work with 3D Geometries Ray-marching Density Perlin’s Noise Beer-Lambert’s Law

Cones

Cones Cones are very common Cylinder with one face having an area of 0 Streetlamps Spotlights Headlights Cylinder with one face having an area of 0 Requires: Apex (Tip) Direction of the Cone (from the apex to the base) Length of the Cone (along the direction vector) Angle between the direction vector and a side of the cone Need to implement ray-cone intersections

Cones Several types of intersections: Ray could completely miss the cone Ray could technically intersect the cone, but the cone is behind the ray’s origin The ray could touch the cone at a single tangential point The ray could enter AND exit the cone The ray could originate inside of the cone and exit at a single point Must consider intersections with: The sides The cone base

Cones: The Math D = direction of the cone V = apex of the cone X = point within the bounds of the cone’s sides Theta = cone’s half-angle

Cones: The Math

Cones: The Math

Cones: The Math

Cones: The Math

Cones: The Math

Cones: The Math

Cones: The Math

Cones: The Math

The Normal Quadratic Equation Derivation

The Normal Quadratic Equation Derivation

Special Quadratic Equation Derivation

Special Quadratic Equation Derivation

Matrix Multiplication

Cones: Base Intersection Have to check for ray intersection with cone’s base Check to see if ray intersects with cone base’s plane If it does, check to see if the ray is less than the base’s radius away from the base’s center Can’t tell where a ray will intersect with the cone, or which points will be closer Have to store all found intersection distances Compare distances and choose two closest ones If ray started inside the cone, set the hitDistance to 0

Updating IntersectionRecord Need to update to work with 3D Geometries Needs to keep track of entry point AND exit point Should track entry and exit normals for easy refraction ray calculations Should track length of ray between entry and exit point Only existing 3D Geometry is the RTSphere Just need to add exit point and exit normal Exit point already calculated, just not stored in IntersectionRecord Exit normal is just the normalized vector from the center of the sphere to the exit point Need to consider 2D Geometries Exit point will be the entry point Exit normal will be the reversed entry normal

Ray-Marching Sample along a ray’s length at set intervals Sum and weigh values as you go along the ray Pros: Allows checking of information at points that is not necessarily continuous along the direction of the ray Light exposure Density Color (for multi-colored 3D objects) Results in better looking images Cons: Takes extra time Similar to super-sampling

Density of Particles Uniform density Ramp or gradient of density Opaque coloring Ramp or gradient of density Can simulate gravity Can simulate increasing thickness Statistical approach Randomness as to whether a ray “hits a particle” Unique algorithms Whatever you want to program in

How to Get the “Fog” Look Use a pseudorandom number generator? No similarity between two values close together in 3D space Instead of fog, RNGs will give us pure noise Bad choice Texture map? Same fog time and time again Pseudorandom number generator that takes into account closeness between two points in 3D space? Could work well for fog

Perlin’s Noise Random number generator that utilizes multi-dimensional space As you cross small spaces, values are somewhat similar to each other Great for fog randomness Uses a stored 3D grid of vectors Each “box” has a vector and the bounds of the box How It Works: Input x, y, z coordinates to get a box and a point in that box Make vectors to the point to all 8 corners of the box Dot product the stored vector with all 8 point-to-corner vectors The interpolated dot product gives a float that acts as a semi-random number!

Perlin’s Noise How to average values: Simple averaging won’t work Need to linearly interpolate values between pairs of points along an axis Choose an axis of change (x, y, z, etc.) Calculate how close the chosen point’s x (or y or z) value is to the left point’s x (or y or z) value to get a normalized weight (between 0 and 1) Multiply the weight by the left dot product and (1 - weight) by the right dot product to get the linearly interpolated dot product Complete for all axes Will go from 8 points to interpolate to 4 points to 2

Pseudorandom Number Generator vs. Perlin Noise

Perlin Noise Already implemented in MP5! Problems: Opportunities: Code from New York University in RTTextureType_Noise gives an efficient construction of the Perlin’s Noise algorithm Just need to pass in x, y, z coordinates for a point in 3D space Problems: Values aren’t guaranteed to be between 0 and 1 Could be negative Need to cap values Not accessible, so it needs to be taken out from RTTextureType_Noise Opportunities: Can alter values or homogenize them to make fog look blurrier and thicker Can bump up value to reduce “empty” space and produce more fog, or vice versa

Summary Calculate entry and exit points of a 3D object Update IntersectionRecord If the geometry intersected is not 100% opaque (i.e. transparency of the material stored is > 0.0f)... Calculate a refraction ray Calculate the attenuation of light throughout the fog if the geometry has one Collide with the next object Use Perlin’s Noise and Beer-Lambert’s Law to calculate light dropoff and add some randomness to our fog

Remaining Problems Account for interaction between objects inside the volume and the volume itself Reflection Shadows i.e last example picture Should account for the attenuation of light as it travels along the volume, as the particles in the volume are absorbing the incoming light as it travels along the volume Could utilize ray-marching, but it’ll be slower

Beer-Lambert Law Calculates intensity of light as it passes through a medium Uses e (base of natural logarithm) (~2.7183) The equation we will use is I = Io * e^(Cx) I = end intensity Io = initial intensity C = Concentration coefficient x = Distance through the medium or the number of particles passed Provides natural light attenuation dropoff equation for our fog!

Thanks!

References "GPU Gems 2." GPU Gems. Web. 28 Feb. 2016. <http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter08.html> "GPU Gems 3." - Chapter 13. Volumetric Light Scattering as a Post-Process. Web. 09 Mar. 2016. <http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html> Zoren, Denis. Ray Tracing II. New York: N.p., 2016. Web. 1 Mar. 2016 <http://mrl.nyu.edu/~dzorin/rend05/lecture2.pdf> Marschner, Steve. Volumetric Path Tracing. N.p., 2016. Web. 28 Feb. 2016 <http://www.cs.cornell.edu/courses/cs6630/2012sp/notes/09volpath.pdf> Eberly, David. Intersection of a Line and a Cone. N.p., 2016. Web. 28 Feb. 2016 <http://www.geometrictools.com/Documentation/IntersectionLineCone.pdf > Ilya Baran, Jiawen Chen, et al. 2010. A Hierarchical Volumetric Shadow Algorithm for Single Scattering. acm Transactions on Graphics. Article no. 178. <http://groups.csail.mit.edu/graphics/volumeshadows/vs.pdf> Perlin, Ken. "Ken's Academy Award." Ken's Academy Award. Web. 3 Mar. 2016. <http://mrl.nyu.edu/~perlin/doc/oscar.html#noise> "Beer-Lambert Law." Beer-Lambert Law. Web. 3 Mar. 2016. <http://life.nthu.edu.tw/~labcjw/BioPhyChem/Spectroscopy/beerslaw.htm> Wikipedia: "Lambert Law." Wikipedia. Wikimedia Foundation. Web. 2 Mar. 2016. <https://en.wikipedia.org/wiki/Beer–Lambert_law> "Volume Ray Casting." Wikipedia. Wikimedia Foundation. Web. 28 Feb. 2016. <https://en.wikipedia.org/wiki/Volume_ray_casting> "Perlin Noise." Wikipedia. Wikimedia Foundation. Web. 28 Feb. 2016. <https://en.wikipedia.org/wiki/Perlin_noise>