Presentation is loading. Please wait.

Presentation is loading. Please wait.

Geometric Objects and Transformations. Coordinate systems rial.html.

Similar presentations


Presentation on theme: "Geometric Objects and Transformations. Coordinate systems rial.html."— Presentation transcript:

1 Geometric Objects and Transformations

2 Coordinate systems http://alt.pluralsight.com/wiki/default.aspx/Craig.DirectX/CoordinateSystemsTuto rial.html

3 Clockwise = Front Face

4 The DirectX 10 Pipeline Stage 1: Model Space -> World Space http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

5 The DirectX 10 Pipeline Stage 2: World Space -> Camera Space (Not done in OpenGL 2.x) http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

6 The DirectX 10 Pipeline Stage 3: Camera Space -> Projection Space http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

7 The DirectX 10 Pipeline Stage 4: Change the Clipping Matrix (If you are not using the std Projection Matrix) http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

8 The DirectX 10 Pipeline Stage 5: Clipping (Not a Matrix!) http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

9 The DirectX 10 Pipeline Stage 6: Projected Space -> Clipping Space (Flips the Y-Axis) http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

10 The DirectX 10 Pipeline Stage 7: Projected Space -> Screen Space (Coordinates passed to the rasterizer) http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx

11 Up till Dx9 this was all done for us... With the new approach to Rendering, NOTHING is default Need to write our own: – Geometry Shader (Optional) – Vertex Shader – Pixel Shader – Code to run the Combined Vertex Shader + Pixel Shader on the GPU (Effect)

12 HLSL High Level Shader Language, the Dx only solution. Cg, the Nvidia Dx / GL solution GLSL, the GL only solution

13 What about a real Vertex Shader? matrix World; matrix View; matrix Projection; VS_OUTPUT VS( float4 Pos : POSITION, float4 Color : COLOR ) { VS_OUTPUT output = (VS_OUTPUT)0; output.Pos = mul( Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); output.Color = Color; return output; }

14 Our Super Cheap Vertex Shader float4 VS( float4 Pos : POSITION ) : SV_POSITION { return Pos; } The Colon: sets the semantics of the data (metadata)

15 Geometry Shaders WTF? Grass Water Fur +ve Less Bus Data Less CPU + Memory usage -ve More GPU Load No Dx9 or below compatibility (Who cares!)

16 Vertex Shader Base Functions: – World – View – Projection Transformation Extensions: – Water Movement – Plant movements – Object Morphing

17 Pixel (Fragment) Shader Colouring Simple texturing Cell shading Normal mapping Particle effects Alpha blending Etc!

18 Semantics (metadata) There are so few data types in GPU programming (Typically just a load of floats) Using Semantics we can specify the intended purpose of the variables What does this do: float3 pos : POSITION; Creates 3x floats to store the xyz + tells HLSL the floats are used as a position

19 Semantics What about: float4x4 wvp : WORLDVIEWPROJ...

20 float4 PS( float4 Pos : SV_POSITION ) : SV_Target { return float4( 1.0f, 1.0f, 0.0f, 1.0f ); // BGRA }

21 In both OpenGL and Direct3D Z is the depth of the viewport!!!! hence the Z-buffer (Depth Buffer)

22 Z Buffer Depth – Due to the scalar nature of the Pyramid Viewport – Depth precision drops as the distance between the Near and Far planes are moved apart – This will result in more artefacts and visual errors

23 Viewport types Orthogonal – No depth perception (scaling) Projected – This is the typical 3D viewport Objects \ Vertices are scaled and rotated based on the ‘virtual’ distance from the screen

24 References http://knol.google.com/k/hlsl-shaders#


Download ppt "Geometric Objects and Transformations. Coordinate systems rial.html."

Similar presentations


Ads by Google