An Approximation of Volumetric Lighting

Slides:



Advertisements
Similar presentations
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 6, 2014 TEXTURE MAPPING TEXTURES BUMP MAPPING ENVIRONMENT MAPPING PROCEDURAL TEXTURING.
Representing Geometry in Computer Graphics Rick Skarbez, Instructor COMP 575 September 18, 2007.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Texture Mapping from Watt, Ch. 8 Jonathan Han. Topics Discussed Texture Map to Models Bump Maps, Light Maps Environment (Reflection) Mapping 3D Textures.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Texture Mapping April 9, The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CIS 681 Distributed Ray Tracing. CIS 681 Anti-Aliasing Graphics as signal processing –Scene description: continuous signal –Sample –digital representation.
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.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
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)
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
-Global Illumination Techniques
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
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.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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.
An Approximation of Volumetric Lighting
University of New Mexico
Reflection & Mirrors.
Computer Graphics Texture Mapping
Distributed Ray Tracing
Deferred Lighting.
Ray Tracing Dr. Scott Schaefer.
3D Graphics Rendering PPT By Ricardo Veguilla.
Mike Merchant Nicholas Hilbert
© University of Wisconsin, CS559 Fall 2004
Real-Time Volume Graphics [06] Local Volume Illumination
Lighting.
Lecture 13 Clipping & Scan Conversion
Distributed Ray Tracing
CS5500 Computer Graphics May 29, 2006
Texture Mapping Ed Angel Professor Emeritus of Computer Science
Illumination and Shading
CSCE 441: Computer Graphics Ray Tracing
Ray Tracer Spring 2004 Help Session.
GR2 Advanced Computer Graphics AGR
Chapter 14 Shading Models.
CS 480/680 Computer Graphics Shading.
Introduction to Ray Tracing
Distributed Ray Tracing
GPAT – Chapter 7 Physics.
Ray Tracer Autumn 2005 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

Transpose Matrices

Cones: The Math

Cones: Derived Ray Intersection Equation

Cones: Verified Ray Intersection Equation

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 http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html http://mrl.nyu.edu/~dzorin/rend05/lecture2.pdf http://groups.csail.mit.edu/graphics/volumeshadows/vs.pdf https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law http://www.cs.cornell.edu/courses/cs6630/2012sp/notes/09volpath.pdf https://en.wikipedia.org/wiki/Volume_ray_casting http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter08.html