Upload
pier
View
31
Download
2
Embed Size (px)
DESCRIPTION
Ray Tracing 2. Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination Path Tracing Radiosity Exercise 2. Sampling. Ray Casting is a form of discrete sampling. Rendered Image: Sampling of the ground Truth at regular intervals. Ground Truth: - PowerPoint PPT Presentation
Citation preview
Ray Tracing Advanced Topics
Ray Tracing 2The uncanny vally1TodayAnti-aliasingSurface ParametrizationSoft ShadowsGlobal IlluminationPath TracingRadiosityExercise 2
-
2SamplingRay Casting is a form of discrete sampling.Ground Truth:An Exact MathematicRepresentation
Rendered Image:Sampling of the groundTruth at regular intervalsSignal Frequency?Sampling Frequency? 3Anti-AliasingAliasing: A distortion or artifact as a result of sampling.
Higher frequency removal
To reproduce the signal fully - Nyquist rate
Signal Sampled
Related problem Moir
4Anti-AliasingStaircasing
Pixels on the boundary
5Anti-AliasingAnti-aliasing - The attempt to reduce or eliminate aliasing artifacts
6Uniform SupersamplingInstead of sampling one point in every pixel. Sample k2 times (for some n) in uniform intervals
Set the pixel color to the average of the k2 colorssampledSingle Pixel - Single SampleSingle Pixel - Multiple Sample7Cast ray through pixelConstructing a ray through a pixelParameters: Eye point PView direction - towardsUp directionField of view (xfov, yfov)Distance to screen d
right = towards x upright and up define theorientation of the screen.P0 and d define where its at.P0uptowardsrightdcenter of screenPcxfovyfov8Cast ray through pixelPc = P0 + towards*dP is the pixel at (xpixel, ypixel) = (2, 2)
Calculate (xscreen, yscreen) P = Pc + xscreen*right + yscreen*up
V = (P - P0) / ||P - P0||ray direction to P.
P0uptowardsxfovyfovdPcrightPVray = P0 + t*V9Cast ray through pixelxfov = 2.0yfov = 2.0Transforming (xpixel, ypixel) to (xscreen, yscreen)
+ypixel-width = 320 pxpixel-height = 240 px+upScreen In Object SpaceApplication Window+x+rightPcObject space .10Uniform SupersamplingP0uptowardsxfovyfovdPcrightPVray = P0 + t*VPc = P0 + towards*dP is the pixel at (xpixel, ypixel) = (2.5, 2.5)
Calculate (xscreen, yscreen) P = Pc + xscreen*right + yscreen*up
V = (P - P0) / ||P - P0||ray direction to P.
do this k2 times, average results.
Pixel coordinates can now have fractions11Uniform SupersamplingWhere should you sample the pixel?
1 sample per pixel4 sample per pixel9 sample per pixel01011001 12Uniform Supersampling Global uniformity:Distance betweenSamples is always the same
What NOT to do:
Two samples in the same point13Uniform Supersampling
14Adaptive SupersamplingIf the difference between adjacent samples is too great, divide the pixel to 4 and cast more rays
Smooth pixels need only 4 samples Edges can still be reproduced smoothly
Reuse common rays
15Stochastic SamplingUniform sampling often still cant account for frequency issuesSub-divide the pixel to a gridChoose a random point in every cell
Makes the interval of sampling non-uniformReduce aliasing by introducing noise
16
Questions?Surface ParameterizationHow to add a 2D texture to a surface embedded in 3D?
(x,y,z)
18Surface ParameterizationSimple case rectanglular plane
uvu [0,1], v [0,1] P = -v * (P3-P1) + u * (P2-P1)Baricentric coordinatesEquation P1P2P3P4P1. Extract (u,v) from P2. Get the pixel color at (u,v)19Surface ParameterizationSimple case - rectanglular plane
uvu [0,1], v [0,1] P = -v * (P3-P1) + u * (P2-P1)Baricentric coordinatesEquation P1P2P3P4P
1. Extract (u,v) from P2. Get the pixel color at (u,v)20Surface ParameterizationA Little more complex - Sphere
uvu [0,1], v [0,1]
1. Extract (u,v) from P2. Get the pixel color at (u,v)PP = (x,y,z) (,,r)u = , v =
Sphertical Coordinates- phi - theta21Surface ParameterizationGeneral Case A Triangle Mesh
22
Surface ParameterizationA Little more complex - Sphere
uvu [0,1], v [0,1] 1. Extract (u,v) from P2. Get the pixel color at (u,v)PP = (x,y,z) (,,r)u = , v =
Sphertical Coordinates- phi - theta23Questions?
Area LightSo far weve see only ideal light sourcesLight from infinityPoint LightSpot Light
These produceHard Shadows
To Create a realisticShadow one option isto use a morerealistic light source
Directed LightPoint LightArea Light25Area LightPoint light - Hard ShadowsFull ShadowUmbraLighs Source
26Area LightSimple area light - simulated using a uniform grid of point lights.Full Shadow UmbraSoft Shadow PenumbraLighs Source
. , 27Area LightDisadvantages of the simple uniform method:Very time consumingIf the grid resolution is low, artifacts appear in the shadows.
28Area LightMonte-Carlo Area lightLight is modeled as a sphereHighest intensity in the middle. Gradually fade out.Shoot n rays to random points in the sphereAverage their value.
Caustics29Monte Carlo vs Las VegasTwo types of randomized, probabilistic methods for constructing an algorithmResults are statistic Has an expectancy E(X) to be correct.Monte Carlo: Has a predictable time complexity.Result may not be correct.Better results the more you run itLas Vegas:Time complexity not guaranteedAlways returns the correct answer
Convert Monte-Carlo to Las-Vegas?LasVegasMonteCarloE(X)proofTimeproofE(X)Result
Quicksort, 30Global Illumination
In the real world light is everywhere.Reflects in every direction from every surface onto every surface.Anywhere in the world, light comes from infinite directions around.
In the lighting equation weve used the Ambient intensity to approximate this.31Monte-Carlo Path TracingConventional Ray Tracing: Cast rays from eye through each pixelTrace secondary rays to light sources and reflections
32Monte-Carlo Path TracingA generalization of the concept of Monte-Carlo area lightCast rays from eye through each pixelCast random rays from the visible point, average contributions
33Monte-Carlo Path TracingCast rays from eye through each pixelCast random rays from the visible point, average contributionsRecurse
34Monte-Carlo Path Tracing
Cast rays from eye through each pixelCast random rays from the visible pointRecurse, accumulate contributions35Monte-Carlo Ray TracingCast random rays from the visible pointRecurse, accumulate contributionsSample light from all points we visited
36Monte-Carlo Path Tracing
1 random ray per pixel, 1 level recursion - 37Monte-Carlo Path Tracing16 random rays per pixel, 3 level recursion
38Monte-Carlo Path Tracing64 random rays per pixel, 3 level recursion
39Monte-Carlo Path Tracing64 random rays per pixel, 3 level recursionNoticeColor BleedTo White ball
40Monte-Carlo Path Tracing16 random rays per pixel100 level recursion
16 random rays per pixel1 level recursion41GlossaryRay Casting:Cast rays from eye through each pixel, find first hitRay Tracing:Cast rays from eye through each pixel, find first hitRecourse- Ray changes course/divides into few raysAccumulate all results.Path TracingCast rays from eye through each pixel, find first hitRecourse- Shoot random rays in the reflect hemisphereAccumulate All results
1-3 rays per recursion step1-100 rays per recursion stepGlossaryDirect IlluminationFind a interaction between objects and emitters of lightHow much light from light source X hits this pointRay TracingGlobal IlluminationFind interaction between objects and complete environmentHow much light hits this point, Indirect lightingPath TracingFaked with The Ambient constant in the light equation.
RadiosityPhoton mapping
43Radiosity (simplified)A different approach to Global Illumination
Divide the scene into a set of small areas
The radiosicy of a patchis the total amount of lightemitted from it
Calculate all the amountof light a patch receives fromall other patches.Calculate the radiosityIterate.
44RadiosityCalculating the amount of light a patch receivesConstruct a Hemicube on the patchRender the scene on the hemicubeAverage the color.
45RadiosityRendering on a hemicube
Radiosity
Initial StateFirst IterationLight emitted = Color * Light received47Radiosity32nd iteration320th Iteration
Compute light emissions once,View from any angle!48Radiosity
Direct IlluminationRadiosity49Radiosity Surface SubdivisionUsing a uniform mesh?Wasteful. Smooth areas dont need a great level of detailHierarchical subdivisionAreas with large changes get subdivided.
50Ray Tracing exercise
51a52