matrices from hell

Post on 12-Feb-2016

60 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

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 Easy1 2 3

4 5 6

7 8 9

A B C

D E F

G H I+ =1+A 2+B 3+C

4+D 5+E 6+F

7+G 8+H 9+I

4 0 0

0 6 0

0 0 9

3 0 0

0 1 0

0 0 0+ =7 0 0

0 7 0

0 0 9

Matrix Multiplication Row,Colum1 2 3

4 5 6

7 8 9

A B C

D E F

G H Ix =1A + 2D + 3G

1B + 2E + 3H

1C + 2F + 3I

4A + 5D + 6G

4B + 5E + 6H

4C + 5F + 6I

7A + 8D + 9G

7B + 8E + 9H

7C + 8F + 9I

4 0 0

0 6 0

0 0 9

3 0 0

0 1 0

0 0 0x =12 0 0

0 6 0

0 0 0

That’s great, what do I need them for?

Translation Matrices• Coordinates from Object Coordinates to world

CoordinatesObject Translation World

Typically we use a Matrix Multiplication

100 0 0

0 20 0

0 0 -100+ =110 0 0

0 30 0

0 0 -100

10 0 0

0 10 0

0 0 0

Scaling

Scalar MatricesObject Scalar (1/10) World100 0 0

0 100 0

0 0 100

0.1 0.1 0.1

0.1 0.1 0.1

0.1 0.1 0.1x =10 0 0

0 10 0

0 0 10

Translation by Multiplication

• This is a computationally longer way to do a simple translation

1 0 0 x

0 1 0 y

0 0 1 z

0 0 0 1

x =1 0 0 x

0 1 0 y

0 0 1 z

0 0 0 1

1 0 0 10

0 1 0 5

0 0 1 10

0 0 0 1

Rotational Matrices

http://en.wikipedia.org/wiki/Rotation_matrix#Dimension_threeA Rotation around the unit vector u = (ux,uy,uz)

glRotatef(Theta,x,y,z);

Putting it all together

Typically you will want to:TranslateRotateScale

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= 0 4 8 C

1 5 9 D2 6 A E3 7 B F

0 1 2 3 4 5 6 7 8 9 A B C D E F

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

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-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)

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-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)

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-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)

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

RenderManhttps://renderman.pixar.com/

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_renderinghttp://en.wikipedia.org/wiki/Rendering_equationhttp://www.steckles.com/reyes1.html

top related