Pipelines are for Whimps
description
Transcript of Pipelines are for Whimps
![Page 1: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/1.jpg)
Pipelines are for Whimps
Raycasting, Raytracing, and Hardcore Rendering
![Page 2: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/2.jpg)
Ray Casting
• Definition Time• There are two definitions of Ray Casting• The Old and the New• The old was related to 3D games back in the
Wolfenstein / Doom 1 Era. Where gameplay was on a 2D platform
• The New definition is:– Non Recursive Ray Tracing
![Page 3: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/3.jpg)
Ray Tracing
• http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_1_Introduction.shtml
Glass Ball
![Page 4: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/4.jpg)
Rays from the Sun or from the Screen
• Rays could be programmed to work in either direction
• We choose from the screen to the Light– Only X x Y Pixels to trace
• From the Light we would need to emulate Millions of Rays to find the few thousand that reach the screen
![Page 5: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/5.jpg)
Our Rays
![Page 6: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/6.jpg)
Center of Projection
(0,0)
![Page 7: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/7.jpg)
Viewport
(0,0)
Screen
Clipping Planes
![Page 8: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/8.jpg)
Into World Coordinates
(0,0)
Screen
Clipping Planes
![Page 9: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/9.jpg)
Getting Each Initial Ray
• Origin = (0,0,0)• Direction = ScreenX,screenY, zMin– ScreenX, ScreenY are the float locations of each
pixel in projected world coordinates– zMin is the plane on which the screen exists
![Page 10: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/10.jpg)
Materials
• Surfaces must have their Material Properties set– Diffuse, Reflective, Emissive, and Colour need to
be considered
![Page 11: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/11.jpg)
For Each Pixel (the main Raytrace loop)
For each pixel {
Construct ray from camera through pixel Find first primitive hit by ray Determine colour at intersection point Draw colour to pixel Buffer
}
![Page 12: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/12.jpg)
Intersections
• The simplest way is to loop through all your primitives (All Polygons)– If the Polygon Normal DOT RayDirection(Cos
Theta) < 0 // Face is opposite to Ray Ignore– Now we can Intersect the Ray with the Polygon– Or Intersect the Ray with the Polygons Plane
![Page 13: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/13.jpg)
Ray / Polygon Intersection
p0, p1 and p2 are verts of the trianglepoint(u,v) = (1-u-v)*p0 + u*p1 + v*p2U > 0V > 0U + V <= 1.0
![Page 14: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/14.jpg)
Line Representation
point(t) = p + t * dt is any point on the line p is a known point on the lineD is the direction vectorCombined:p + t * d = (1-u-v) * p0 + u * p1 + v * p2A Point on the line (p + t * d) which Is part of the triangle[(1-u-v) * p0 + u * p1 + v * p2]
![Page 15: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/15.jpg)
• http://www.lighthouse3d.com/opengl/maths/index.php?raytriint
![Page 16: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/16.jpg)
Intersections Suck!
• http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/
• http://www.netcomuk.co.uk/~jenolive/vect18c.html
• http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm#Line-Plane%20Intersection
• http://members.tripod.com/~Paul_Kirby/vector/Vplanelineint.html
![Page 17: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/17.jpg)
Intersecting a Plane
• A point on the Plane = p1• Plane Normal = n.• Ray = p(t) = e + td
P(t) = Point on RayE = OriginD = Direction Vectort = [(P1 – e) . n]/ d.n
![Page 18: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/18.jpg)
World / Object Coordiantes
• We need to translate the Ray into Object Coordinates / Vice Versa to get this to work
• Ray = p(t) = e + td• Ray = Inv (Object->World)e + t Inv (Object-
>World)d
![Page 19: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/19.jpg)
After Finding the Intersecting Plane
• You need a simple way to check for a hit or miss
• If your Object has a bounding box this can be achieved through a line check
![Page 20: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/20.jpg)
Miss Conditions
![Page 21: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/21.jpg)
![Page 22: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/22.jpg)
Hit Conditions
![Page 23: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/23.jpg)
For Other Shaped Flat Polygons
• An Even Number of Intersections with the Outside of the Polygon means a Miss
• An Odd Number of Intersections means a Hit
![Page 24: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/24.jpg)
Task List for Ray Casting
1) Create a vector for each Pixel on the screena) From the Origin of the Camera Matrix (0,0,0)b) That intersects with a Pixel in the screen
2) Use this Vector to create a trace through the World
a) From the Zmin to the Zmax Clipping Volumeb) UnProjected into World Coordinates
3) Intersect the trace with every object in the world
![Page 25: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/25.jpg)
4) When the ray hits an Object we need to check how the pixel should be lita) Check if the Ray has a direct view to each of the lights in the sceneb) calculate the input from each light.c) Color the pixel based on the lighting and surface properties
![Page 26: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/26.jpg)
One extra task for Ray Casting
• After Intersection Calculate the reflective Vector– Dot Product of Ray and Surface Normal
• Then cast a new Ray– This continues in a recursive fashion untill:• A ray heads off into the universe• A ray hits a light• We reach our maximum recursion level
![Page 27: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/27.jpg)
How we would like to be able to calculate light
![Page 28: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/28.jpg)
Conservation of Energy
• A Physics-Based Approach to Lighting– Surfaces will absorb some light, and reflect some
light– Any surfaces may also be light emitting– Creating a large simultaneous equation can solve
the light distribution (I mean LARGE)– The light leaving a point is the sum of the light
emitted + the sum of all reflected light
![Page 29: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/29.jpg)
Don’t Scream (loudly)
![Page 30: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/30.jpg)
The Rendering Equation
http://en.wikipedia.org/wiki/Rendering_equation
Light Leaving Point X in direction
Light Emitted by Point X in direction
Integral over the Input Hemisphere
Bidirectional reflective function (BDRF) in the direction from direction ’
Light toward Point X from direction ’
Attenuation of inward light related to incidence angle
![Page 31: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/31.jpg)
The Monte Carlo Method
• Repeated Random Sampling• Deterministic Algorithms may be unfeasibly
complex (light)
![Page 32: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/32.jpg)
Metropolis Light Transport
• A directed approach to simplifying the BDRF• Still considered a Monte Carlo Method• It directs the randomness considering more
samples from directions with a higher impact on the point being assessed
![Page 33: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/33.jpg)
BDRF Tracing
http://graphics.stanford.edu/papers/metro/
![Page 34: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/34.jpg)
Metropolis Light Transport
http://graphics.stanford.edu/papers/metro/
![Page 35: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/35.jpg)
Radiosity
• Simplifying the Rendering Equation by making all surfaces perfectly diffuse reflectors
• This simplifies the BDRF function
![Page 36: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/36.jpg)
Parallel Rendering (Rendering Farms)
• There are Three major Type Definitions– Sort-First– Sort-Middle– Sort-Last
• These are just the outlines, in reality things need to be customised based on technical limitations / requirements
![Page 37: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/37.jpg)
Sort-MiddleApplication
Sort
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Display
DisplayDisplay
Display
Fragments(Pixel Shading)
Geometry(Vertex Shading)
![Page 38: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/38.jpg)
Sort-Middle
• Pros– The number of Vertex Processors is independent of the
Number of Pixel Processors• Cons– Normal Maps may mess with Polygons on overlap areas– Correcting Aliasing between Display Tiles
(RenderMan??)– Requires specific hardware– Rendering may not be balanced between Display Tiles
![Page 39: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/39.jpg)
Sort-LastApplication
Composite
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Display
Fragments(Pixel Shading)
Geometry(Vertex Shading)
![Page 40: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/40.jpg)
Sort-Last
• Pros– Can be easily created from networked PCs
• Cons– Each Vertex Processor requires a Pixel Processor– Unsorted Geometry means each Pixel Processor must
carry a full-size frame buffer• Limited scalability
– Composing the image requires integrating X frame buffers considering X Z-Buffers
![Page 41: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/41.jpg)
Sort-Last
• Compositing can be done more efficiently (memory requirements) utilising a binary tree approach– May lead to idle processors
• Another approach is a Binary Swap architecture– Large Data Bus usage
![Page 42: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/42.jpg)
Sort-FirstApplication
Sort
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Geometry(Vertex Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Fragments(Pixel Shading)
Display
DisplayDisplay
Display
Fragments(Pixel Shading)
Geometry(Vertex Shading)
![Page 43: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/43.jpg)
Sort-First• Pros
– Pixel Processors only need a tile of the display buffer– Can be created utilising PC hardware– Infinitely Scalable
• Cons– We are sorting Primitives BEFORE they are translated into projected
space!!!• This requires some overhead
– Polygons crossing tiles will be sent to both pipelines– An error backup could consider a bus to move incorrectly sorted polygons to the
correct render queue (Transparency causes issues here!)
– Correcting Aliasing between Display Tiles– Rendering may not be balanced between Display Tiles
![Page 44: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/44.jpg)
Parallel Processing Techniques
• Conclusively– Sort-Middle is for expensive hardware– Sort-Last is limited by scalability– Sort-First requires careful consideration on
implementation• Sort First / Sort Last COULD be run on a Cloud– Bandwidth??– Security??– What happens when you max the cloud??
![Page 45: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/45.jpg)
Image Based Rendering
• Geometric Upscaling!• The process of getting 3D information out of
2D image(s)– Far outside our scope, but interesting in Research
![Page 46: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/46.jpg)
RenderManhttps://renderman.pixar.com/
![Page 47: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/47.jpg)
RenderMan / Reyes
• Reyes (Renders Everything You Ever Saw)• RenderMan is an implementation of Reyes– Reyes was developed by two staff at the
‘Lucasfilm's Computer Graphics Research Group’ now known as Pixar!
– RenderMan is Pixar’s current implementation of the Reyes Architecture
![Page 48: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/48.jpg)
The Goals of Reyes
• Model Complexity / Diversity• Shading Complexity• Minimal Ray Tracing• Speed• Image Quality (Artefacts are Unacceptable)• Flexibility– Reyes was designed so that new technology could be
incorporated without an entire re-implementation
![Page 49: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/49.jpg)
The Functionality of Reyes / RenderMan
• Objects (Polygons and Curves) are divided into Micro Polygons as needed– A Micro Polygon is a typically smaller than a pixel– In Reyes Micro Polygons are quadrilaterals– Flat shading all the Quads gives an excellent
representation of shading• These quads allow Reyes to use a Vector Based
Rendering Approach– This allows simple Parallelism
![Page 50: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/50.jpg)
• Bound– Bounding Boxes
• Split– Geometry Culling & Partials
• Dice– Polygons into grids of Micro Polygons
• Shade– Shading Functions are applied to the Micro Polygons
• Functions used are Independent of Reyes
• Bust– Do Bounding and Visibility checking on each Micro Polygon
• Sample (Hide)– Generate the Render based on the remaining Micro Polygons
![Page 51: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/51.jpg)
The Reyes
Pipeline
• http://en.wikipedia.org/wiki/File:Reyes-pipeline.gif
![Page 52: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/52.jpg)
Interesting Facts
• Some Frames take 90 hours!!! (1/24th of a second of footage)
• On average Frames take 6 hours to render!!!!• 6 * 24 = 1 second = 144 Hours– About 2 years for a 2 hour Movie!!
![Page 53: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/53.jpg)
Licensing
• $3500 us per Server• $2000us – 3500us per Client Machine• Far cheaper than I expected!
![Page 54: Pipelines are for Whimps](https://reader035.fdocuments.in/reader035/viewer/2022070503/56816380550346895dd462d7/html5/thumbnails/54.jpg)
References
http://en.wikipedia.org/wiki/Reyes_renderinghttp://
en.wikipedia.org/wiki/Rendering_equationhttp://www.steckles.com/reyes1.htmlhttp://
www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_1_Introduction.shtml
http://www.lighthouse3d.com/opengl/maths/index.php?raytriint