1 / 48

Direct3D Part 2

Direct3D Part 2. Rudolph Balaz & Sam Glassenberg PRS416 Deep Dive into Building Real Time Graphics Applications Using Direct 3D Microsoft Corporation. Agenda. Really quick Direct3D overview Direct3D Demo Cool things you can do with Direct3D Windows Vista and Direct3D. Where To Start.

faolan
Download Presentation

Direct3D Part 2

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. Direct3D Part 2 Rudolph Balaz & Sam Glassenberg PRS416 Deep Dive into Building Real Time Graphics Applications Using Direct 3D Microsoft Corporation

  2. Agenda • Really quick Direct3D overview • Direct3D Demo • Cool things you can do with Direct3D • Windows Vista and Direct3D

  3. Where To Start • DirectX SDK • Tutorials • Samples • HLSL • Effects • PRT • HDR • UVAtlas • Tools / Utilities • Effects Editor • PIX for Windows

  4. Direct3D 9.0c • Just works on Windows Vista • Use DirectX SDK • http://msdn.microsoft.com/directx/directxSDK • Resources • http://forums.microsoft.com/msdn/default.aspx • directx@microsoft.com

  5. How To Start • Vista contains Direct3D 9.0 runtime • Platform SDK contains Headers & Libs • DirectX SDK • Contains Direct3DX • Other tools • Steps • Install Vista • Install Platform SDK • Install DirectX SDK (October)

  6. The Programmable Pipeline Microsoft® Standard Annotations and Semantics (SAS) Effect Shader Constants Textures VS 3.0 Vertex Shader Pixel Shader Triangles

  7. Vertex Shader • Input: • Vertex stream • Shader constants • Texture data (VS 3.0) • Output: • Required: Transformed clip-space position • Optional: Colors, texture coordinates, normals (data you want passed on to the pixel shader) • Restrictions: • Can’t create new vertices • Can’t store result in memory

  8. Pixel Shader • Input: • Interpolated data from vertex shader • Shader constants • Texture data • Output: • Required: Pixel color (with alpha) • Optional: Can write additional colors to multiple render targets • Restrictions: • Can’t read and write the same texture simultaneously

  9. High Level Shader LanguageExample //-------------------------------------------------------------------------------------- // This vertex shader computes standard transform and lighting //-------------------------------------------------------------------------------------- VSOutput VS( VSInput input ) { VSOutput output; // Transform to clip space by multiplying by the basic transform matrices output.TransformedPosition = mul(input.Position, mul(World, mul(View, Projection))); // Calculate per-vertex lighting float3 worldNormal = mul(input.Normal, World); output.Light = DirectionalLight.Color * dot( worldNormal, DirectionalLight.Direction ); // Pass texture coordinates on to the pixel shader output.TexCoords = input.TexCoords; return output; }

  10. Shader Demo • Diffuse Lighting • Texturing • Texture Blending • Vertex Animation • Environment Mapping • Specular Lighting • Normal Mapping • Atmosphere Glow

  11. Direct3D Part 2 Sam Z. Glassenberg PRS416 Deep Dive into Building Real Time Graphics Applications Using Direct 3D Microsoft Corporation

  12. Local Illumination

  13. Global Illumination:Soft Shadows

  14. Global Illumination:Interreflections

  15. Global Illumination:Subsurface Scattering

  16. Static Global Illumination:Light Maps

  17. The D3DX PRT Engine • Computes multiple bounces of light through the scene from all directions D3DXCreatePRTEngine(...)

  18. The D3DX PRT Engine • Radiance • Light traveling along a line (i.e. the light hitting your eye) • Source Radiance • Represents the lighting environment as a whole • Assumed to be distant relative to the object • Exit Radiance • Represents the light leaving from a point on the surface

  19. ID3DXPRTEngine::ComputeDirectLightingSH (...)

  20. ID3DXPRTEngine::ComputeSS(...)

  21. ID3DXPRTEngine::ComputeBounce(...)

  22. Radiance Transfer Vector

  23. Precomputed Radiance Transfer

  24. Representing Vectors

  25. Representing Signals • Any 1D signal can be represented as a sum of sine waves …

  26. Spherical Harmonics

  27. Spherical Harmonics converts complex 2D functions on a unit sphere into a set of coefficients of SH basis functions 0.1 * 0.5 * 0.5 * 0.2 * …

  28. Lighting Environment • “Source Radiance” D3DXSHEvalSphericalLight(...) D3DXSHEvalHemisphereLight(...) D3DXSHEvalDirectionalLight(...) D3DXSHEvalDirection(...) D3DXSHEvalConeLight(...)

  29. Lighting Environment n=2 n=3 n=5 D3DXSHProjectCubeMap(...) n=26 original

  30. Direct3D10

  31. Windows Vista: Evolving The GPU • GPU as a shared resource • GPU as a more robust rendering unit • GPU as a reliable coprocessor for graphics and beyond

  32. Unprecedented Visual Effects Entirely on the Direct3D10 GPU • Improved Small Batch Performance: More materials and objects for richer scenes • More impressive shaders & unlimited resources • Improved shadows • Realistic reflections • Better fur and vegetation rendering • Procedural geometry & detailing • Multi-pass geometry processing • More believable characters • New physics techniques enabled • All-GPU particle systems & volumetric effects • …

  33. Guaranteed Feature Set Strictly-defined, consistent behavior across hardware Common Shader Cores Full integer/bitwise instruction set New Pipeline Stages & Primitive types Input Assembler Geometry Shader Stream Output Ubiquity of resource access Access memory everywhere Render-to-volume, Render-to-cube, … And more! Overview: The New Hardware Pipeline

  34. Direct3D10 GPU Particle System

  35. Features Leveraged • Geometry Shader • Data Amplification • Stream Output/DrawAuto() • Multi-pass data & geometry processing • State Objects, Constant Buffers • Reduced batch overhead • Effects10 System and HLSL

  36. Data Representation • Particle Data: • Type • LAUNCHER • SHELL • EMBER1/2/3 • Position • Velocity • Lifetime

  37. Emits new primitives of a specified output type Limited data amplification/de-amplification:Output 0-1024 values per invocation No more 1 vertex in, 1 vertex out limit! Geometry ShaderGeometry Amplification/De-Amplification GS Inputs: GS Outputs:

  38. Stream Output • Writes GS Output to one or more buffers • DrawAuto() to draw streamed-out data of variable size without CPU intervention • Uses: • Intra-frame re-use • Skin/morph once, render many • Inter-frame re-use • Iterative/procedural geometry processing • …

  39. Pass 1Technique AdvanceParticles • Geometry Shader • Updates Position, Velocity • Keeps existing particle, creates new particles, or destroys current particle geometryshader gsStreamOut = ConstructGSWithSO(compile gs_4_0 GSAdvanceParticlesMain(),"POSITION.xyz; VEL.xyz; TIMERNTYPE.xy"); technique AdvanceParticles { pass p0 { SetVertexShader( compile vs_4_0 VSPassThroughmain() ); SetGeometryShader( gsStreamOut ); SetPixelShader( NULL ); } }

  40. Pass 2 Technique RenderParticles • Rendered with DrawAuto() • Geometry Shader Generates a “Point Sprite” • Pixel Shader renders color • Blended with Additive Blending technique RenderParticles { pass p0 { SetVertexShader( compile vs_4_0 VSScenemain() ); SetGeometryShader( compile gs_4_0 GSScenemain() ); SetPixelShader( compile ps_4_0 PSScenemain() ); SetBlendState( AdditiveBlending, float4(0.0f,0.0f, … } }

  41. Constant BuffersUsage Model • Simply organize constants by frequency of update/use  no redundant sets Constant Buffers A B C D A B B A D C Shader A Shader B

  42. Direct3D10 Particle System

  43. Community Resources • “Windows Development” MSDN Forums • http://forums.microsoft.com/msdn/default.aspx • General, Graphics, Tools, Performance, and Audio • Notification Alerts, Messages and RSS Feeds • Integrated with Visual Studio 2005 • Advanced Search • FAQs, Answered/Unanswered Questions • directx@microsoft.com

  44. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

More Related