1 / 24

Geometric Objects and Transformations

Geometric Objects and Transformations. Coordinate systems. http://alt.pluralsight.com/wiki/default.aspx/Craig.DirectX/CoordinateSystemsTutorial.html. Clockwise = Front Face. http://msdn.microsoft.com/en-us/library/ee418867%28VS.85%29.aspx. The DirectX 10 Pipeline.

Download Presentation

Geometric Objects and Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Geometric Objects and Transformations

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

  3. Clockwise = Front Face

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

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

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

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

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

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

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

  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 NvidiaDx / 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#

More Related