340 likes | 560 Views
Matrices from HELL . Paul Taylor 2010. Basic Required Matrices. PROJECTION WORLD VIEW. Matrix Math (Joy!). Matrix Addition Matrix Multiplication Translation and Rotation Matrices. Matrix Addition is Easy. =. +. =. +. Matrix Multiplication Row,Colum. =. x. =. x.
E N D
Matrices from HELL Paul Taylor 2010
Basic Required Matrices • PROJECTION • WORLD • VIEW
Matrix Math (Joy!) • Matrix Addition • Matrix Multiplication • Translation and Rotation Matrices
Matrix Addition is Easy = + = +
Matrix Multiplication Row,Colum = x = x
That’s great, what do I need them for? Translation Matrices • Coordinates from Object Coordinates to world Coordinates Object Translation World Typically we use a Matrix Multiplication = +
Scaling Scalar Matrices Object Scalar (1/10) World = x
Translation by Multiplication • This is a computationally longer way to do a simple translation = x
Rotational Matrices glRotatef(Theta,x,y,z); http://en.wikipedia.org/wiki/Rotation_matrix#Dimension_three A Rotation around the unit vector u = (ux,uy,uz)
Putting it all together Typically you will want to: Translate Rotate Scale Matrix Multiplication is the inverse to the logical order! So: Scale then Rotate, then Translate
Retrieving Matrices • This is slow! • The Video Matrices are 4x4 hence: D3DMATRIX world; world=
DirectX 10 Has your back! Static float rotation; D3DMATRIX world; D3DMatrixIdentity(&world); rotation = 0.001f; D3DMatrixRotationY(*world, rotation); This creates a matrix on the PC, not on the Video Card, that’s the next step
Update your Shader (Effect) Matrix World; float4 VS( float4 Pos : POSITION ) : SV_POSITION { Pos = mul( Pos, World); return Pos; } float4 PS( float4 Pos : SV_POSITION ) : SV_Target { return float4( 1.0f, 1.0f, 0.0f, 1.0f ); // Yellow, with Alpha = 1 } technique10 Render { pass P0 { SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetGeometryShader( NULL ); SetPixelShader( CompileShader( ps_4_0, PS() ) ); } }
Putting you matrix on the GPU Create a Pointer to the GPU Matrix: ID3D10EffectMatrixVariable worldMatrixPointer; Fill the Pointer to the GPU Matrix: Effect->GetvariableByName(“World”)->AsMatrix(); Set the Matrix on the GPU: worldMatrixPointer->SetMatrix(world);
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
Sort-Middle Application Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Sort Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Display Display Display Display
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
Sort-Last Application Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Composite Display
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
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
Sort-First Application Sort Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Geometry (Vertex Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Fragments (Pixel Shading) Display Display Display Display
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
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??
Image Based Rendering • Geometric Upscaling! • The process of getting 3D information out of 2D image(s) • Far outside our scope, but interesting in Research
https://renderman.pixar.com/ RenderMan
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
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
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
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
The Reyes Pipeline • http://en.wikipedia.org/wiki/File:Reyes-pipeline.gif
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!!
Licensing • $3500 us per Server • $2000us – 3500us per Client Machine • Far cheaper than expected, until you build your cluster....
References http://en.wikipedia.org/wiki/Reyes_rendering http://en.wikipedia.org/wiki/Rendering_equation http://www.steckles.com/reyes1.html