assignments
play

Assignments Please fill the dropboxes Volumetric Shaders Still - PDF document

Assignments Please fill the dropboxes Volumetric Shaders Still catching up on grading. Questions. Final exam effects Final exam effect Deliverables: Presentation: Research (Grads only) Final exam period Shader


  1. Assignments  Please fill the dropboxes… Volumetric Shaders  Still catching up on grading.  Questions. Final exam effects Final exam effect  Deliverables:  Presentation:  Research (Grads only)  Final exam period  Shader code  Monday, May 19th  Documentation  12:30 - 2:30pm  Describe shader params  ICL5  Explain chosen implementation.  15 minutes per presentation  List constraints.  Give results. Ever changing plans for the week Volume Rendering  This week is “wrap it up week”!  From Wikipedia:  Today: lecture(s)  Volume rendering is a technique used to  Volumetric Rendering display a 2D projection of a 3D discretely  Post-processing sampled data set.  Thursday: Labs (do one of 2)  Volumetric Rendering  Postprocessing  Next week (Week 10)  Lab catch up / group work time. 1

  2. Volume Rendering Volume Rendering 3D data Examples  Data sampled in a 3D space  Types of data:  Voxel -- 3D equivalent of a pixel  CT / MRI scans  Clouds  Subdivision of space holding a single data point  Atmospheric effects  “density function”  Fire, smoke Rendering Volume Data Marching Cubes  Isosurface Approach  Volexize your space  Convert densities to geometry  Choose threshold  Render corresponding geometry  For each voxel vertex, determine if point  Marching cubes algorithm is inside or outside isosurface based on  Direct Volume Rendering threshold.  Sample density in a volume along a ray  Create polygons for each voxel based  Splatting (Projection) on status of voxel vertices.  Ray marching 2

  3. Marching Cubes Marching cubes SIGGRAPH - HyperGraph Direct Volume Rendering Direct Volume Rendering  Splatting  Ray Marching SIGGRAPH - HyperGraph SIGGRAPH - HyperGraph Ray marching algorithm Ray Marching algorithm  Psedocode: Calculate segment of ray on which to march Set starting point while (current point is behind final point) call density function calculate light hitting point update current color total and opacity total Calculate and move to next sample point along ray end Set surface color / opacity. 3

  4. Volumetric rendering is Ray marching algorithm expensive  Said another way:  Sampling points in a volume along a ray Choose step size  Basic trade-off len = length (I); Pcur = P - I;  Too few samples -- aliasing while (len > 0) do  Too many samples -- takes too long. sample density and light at Pcur Cvol += (1-Ovol) * stepsize*scatteredLight  Choose your step size well Ovol += (1-Ovol) * stepsize*density Pcur += stepsize * normalize(I) len -= stepsize; end Determining density functions Challenges in procedural volumetric shading  Determining the “density function”  Empirical -- data is provided to you  Determining the “light scattering”  CR / MRI  Procedural  Efficient implementation of ray marching algorithm  You calculate the density…usually using some form of noise  Voxelized  General 3D data placed in voxel boxes. Light scattering Determining lighting  Scattered into the line of sight (in-  Must consider light illuminating the point scattering)  Must determine how much of that light  Scattered out of the line of sight (out- is scattered toward the viewer scattering)  Uniform scattering  Absorbed altogether (absorption)  Mie scattering  Raleigh scattering 4

  5. Light - Scattering Light -- Scattering r r � � Light is scattered by small particles in its path (e.g. haze,   r << λ total absorption (no scattering) smoke, etc.)  r < λ Rayleigh Scattering Given by fraction of light with respect to direction from particle  light impact.  r ≈ λ Mie scattering Size of particles are on the order of wavelengths of light.   r >> λ Geometric optics Light – Raleigh Scattering Light – Mie Scattering  Raleigh scattering (smoke / dust ), the  Mie Scattering (haze / fog) probability that the light will scatter in 8 1 cos � + � � direction α . Sparse / hazy P ( ) 1 9 � = + � � 2 � � 3 2 � P ( ) ( 1 cos ) � = + 32 1 cos � + � Dense / murky � 4 P ( ) 1 50 � = + � � 2 � � Questions so far? Uniform fog Uniform fog  Ray marching with assumptions:  Density is uniform and constant.  Light scattering is uniform and constant.  Can solve analytically 5

  6. Uniform fog Uniform fog C leave = C enter - C reduce + C increase  Other assumptions:  0 ≤ C reduce ≤ C enter Where  Can’t reduce more light than comes in C leave = light leaving along a ray  C reduce = h C enter C enter = light entering along a ray  h is uniform density. C reduce = light absorbed due to density  C increse = h C fog C increase = light scattered  C fog is the constant color of light scattered toward eye due to fog. Uniform fog Uniform fog  So…  Apply ray marching algorithm…Let’s assume 3 steps:  C leave = (1-h)C enter + hC fog  Rearranging things C leave = g 3 C enter + (1 � g 3 ) C fog  g = 1-h  C leave = gC enter + (1-g)C fog  More generally for z steps:  Light exiting fog is a fraction of the light C leave = g z C enter + (1 � g z ) C fog entering the fog plus 1 minus that fraction times the fog color C eye = g z C object + (1 � g z ) C fog Uniform fog Hypertexture [Perlin89]  Recall exponentials:  Extension of procedural textures  Exp and log base 2 are quick  Between surface + texture, i.e., spatial g z = exp 2 (log 2 ( g ) z ) filling/volumetric  Objects modeled as distribution of density  Final equation  hard region - objects completely solid C eye = fC object + (1 � f ) C fog  soft region - object shape is malleable using a toolkit of f = exp 2 ( � dz ) shaping functions and CSG style operators to combine shapes d = � log 2 (1 � h )  Where:  z is fog distance  h is fog density 6

  7. Hypertexture Hypertexture  Toolbox of base DMFs  D(x) - Object Density Function over R 3  Bias – up / down control  D ( x ) for all points x in 3D space [0,1]  Gain – controls gradiant  Density of 3D shape  Noise (controlled randomness)  D ( x ) = 0 for all points outside the surface  Won Ken an Academy Award!  D ( x ) = 1 for hard region of the object  Turbulence  0 < D ( x ) < 1 for soft region of the object  Sum of noise at variety of frequencies (fuzzy region)  Mathematical functions Bias Bias  Used to bend the density upwards or downwards over [0,1]  Properties:  bias b (0.00) = 0  bias b (0.5) = b Bias 0.25 Bias 0.5 Bias 0.75  bias b (1.00) = 1  Definition: ln( b ) ln(0.5) bias b ( t ) = t Gain Gain  Definition  used to help shape how fast the midrange of an objects soft region goes from 0 to 1. gain g (t) = if ( t > 0.5) then bias 1 � g (2 t ) else 2 � bias 1 � g (2 � 2 t )  Properties: 2 2  gain g (0.0) = 0.0;  gain g (0.25) = 0.5 - g/2;  gain g (0.5) = 0.5;  gain g (0.75) = 0.5 + g/2;  gain g (1.0) = 1.0; 7

  8. Gain Noise  Noise resembles a sin wave but with “random” bumps:  For hypertexture we use 3D noise gain 0.25 gain 0.5 gain 0.75 fBm / Turbulence fBm / Turbulence  fBm -- fractional Brownian motion.  Turbulence  1/f noise  Like fBm but absolute value of noise is summed  Sum of noise functions  Both are useful for “natural” effects  Contribution of each is proportional to the inverse of the frequency float value = 0; float value = 0; for (f = MINFREQ; f < MAXFREQ; f *=2) for (f = MINFREQ; f < MAXFREQ; f *=2) value += abs (snoise (P * f)) / f; value += snoise (P * f) / f; return value;. return value;. Hypertexture Noise Examples fBm / Turbulence Noisy 2* frequency, 1/2 amplitude fBm turbulence [Perlin89] High Amplitude, Noisy Sphere Fractal, noise - Σ many f’s 8

  9. Hypertexture Example - Fur/Hair Hypertexture Example - Fire Here noise displaces x before projecting; Red = low density uses variable to control Yellow = high curliness [Perlin89] D ( x ) = sphere(x ( 1 + turbulence ( x ))) [Perlin89] Tribble Rendering hypertextures Hypertexture clouds  Use a basic ray marching algorithm  Set inner radius = 0.0  A priori knowlegde of shape being  Entire interior region is “fuzzy” shaded  E.g. for sphere  See Perlin paper for more details/uses of hypertextures.  Define inner_raidus (where D = 1)  Define outer_radius (outside of which D = 0)  Ray march from inner to outer.  Questions? Volume Rendering in Volume Rendering in RenderMan RenderMan  volume shader  From the spec:  Defines how light, passing through a volume is  A volume shader is not associated with a surface, affected. but rather attenuates a ray color as it travels through space. As such, it does not have access  Global variables: to any geometric surface parameters, but only to  P - origin of ray the light ray I and its associated values. The  I - incident vector (direction of ray) shader computes the new ray color at the ray  E - eye point origin P-I. The length of I is the distance traveled through the volume from the origin of the ray to the  Ci / Oi -- surface color / opacity (output variables) point P. 9

Recommend


More recommend