Title of the Presentation

Download Report

Transcript Title of the Presentation

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
DirectX SDK
Tutorials
Samples
HLSL
Effects
PRT
HDR
UVAtlas
Tools / Utilities
Effects Editor
PIX for Windows
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
[email protected]
4
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)
The Programmable Pipeline
Microsoft® Standard Annotations and Semantics (SAS)
Effect
Shader Constants
Textures
VS 3.0
Triangles
Vertex Shader
Pixel Shader
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
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
High Level Shader Language
Example
//-------------------------------------------------------------------------------------// 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;
}
Shader Demo
1.
2.
3.
4.
5.
6.
7.
8.
Diffuse Lighting
Texturing
Texture Blending
Vertex Animation
Environment Mapping
Specular Lighting
Normal Mapping
Atmosphere Glow
Direct3D Part 2
Sam Z. Glassenberg
PRS416
Deep Dive into Building Real Time Graphics
Applications Using Direct 3D
Microsoft Corporation
Local Illumination
Global Illumination:
Soft Shadows
Global Illumination:
Interreflections
Global Illumination:
Subsurface Scattering
Static Global Illumination:
Light Maps
The D3DX PRT Engine
Computes multiple bounces of light
through the scene from all directions
D3DXCreatePRTEngine(...)
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
ID3DXPRTEngine::ComputeDirectLightingSH (
ID3DXPRTEngine::ComputeSS(.
ID3DXPRTEngine::ComputeBounce(.
Radiance Transfer Vector
Precomputed Radiance Transfer
=
Y
Representing Vectors
X
0.8
0.2
Representing Signals
…
Any 1D signal can be
represented as a sum
of sine waves
Spherical Harmonics
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 *
…
Lighting Environment
“Source Radiance”
D3DXSHEvalSphericalLight(...)
D3DXSHEvalHemisphereLight(...)
D3DXSHEvalDirectionalLight(...)
D3DXSHEvalDirection(...)
D3DXSHEvalConeLight(...)
Lighting Environment
n=2
n=3
n=5
D3DXSHProjectCubeMap(...)
n=26
original
Direct3D10
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
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
…
Overview: The New Hardware Pipeline
Command
Input
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!
Input
Assembler
Virtualized Memory
(GPU/System Memory)
Vertex Buffer
Index Buffer
Vertex
Shader
Texture
Geometry
Shader
Texture
Stream Output
Rasterizer/
Interpolator
Pixel
Shader
Output
Merger
Texture
Depth/Stencil
Render Target
Direct3D10 GPU Particle System
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
Data Representation
Particle Data:
Type
LAUNCHER
SHELL
EMBER1/2/3
Position
Velocity
Lifetime
LAUNCHER
Position
Velocity
Timer
SHELL
Position
Velocity
Timer
EM BER1
Position
Velocity
Timer
EM BER1
Position
Velocity
Time
EM BER1
Position
Velocity
Time
SHELL
Position
Velocity
Time
Geometry Shader
Geometry Amplification/De-Amplification
GS Inputs:
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!
GS Outputs:
0
1
2
3
n-2
n-1
0
1
2
3
n-2
n-1
1
0
3
2
5
4
n-2
n-3
n-1
Stream Output
Geometry
Shader
Stream Output
Rasterizer/
Interpolator
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
…
Texture
Pass 1
Technique 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 );
}
}
Pass 2
Technique RenderParticles
SHELL
Position
Velocity
Timer
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,
}
}
…
Constant Buffers
Usage Model
Constant Buffers
A
A
B
Shader A
B
C
D
B
A
D
C
Shader B
Simply organize constants by frequency of
update/use  no redundant sets
Direct3D10 Particle System
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
[email protected]
47
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.