صفحه 1:
0
Advanced D3D10
Shader Authoring
۱ ۳
صفحه 2:
Overview
® Review of Direct3D 10 and HLSL 4.0
© The power of the programmable
pipeline
® Guided) exercises: Visualizer
صفحه 3:
Some New D3D10
۶ 221۳1/257
® Completely re-architected from D3D9
fOr COnnmgurability and) performance
© Geometry Shader
© Fixed-function lighting and
thansformeation now programmable in
HLSL 4.0
© Configurable pipeline:
e Flexible shader sign
صفحه 4:
High Level Shader,
0 effective language
for Writing shaders
© Syntax is similar to °C’
e Preprocessor defines (#define, #ifdef,
tc)
oles ( «if , Matrix, etc)
0 ا ۱
۰ ۳ ۶ ea: 7011112 eta
صفحه 5:
Overview of the Pipeline
صفحه 6:
Vertex Shader 4.0 1
- 0 ی
e Vertices
® Shader Constants
e@ System Variables ( VertexID )
© Output
© ۱۳۶ ۱۱۵ ۱۵9 ۷۵۱ ۷
© Golor, Texture Coordi
nw
صفحه 7:
System-generated Values
® Values usable in shaders generated
by the D3D10 runtime
© Act exactly like semantics, just tag
your, Variable and off, you go
كزع ۷ ۶
© Provided to the VS ~
© SV _Instancelp
® Provided to the VS
© SV_PrimitivelD)
۰ 55-7 كر (or PS if there is ng
صفحه 8:
Geometry Shader 4.0
@ Input
© Per-primitive data (3 verts for a tri)
© System variables ( PrimitivelD )
© Output
© Points, lines, triangles
© Render target index, clip di
© Stream data to a buffer on t
© aka stream out
صفحه 9:
Geometry Shader
Restrictions
© Cannot output more than 4096 bytes
OF Information for each input
(9
© Performance is not guaranteed when
amplifying at this level
صفحه 10:
Pixel) Shader 4.0
© Input
© Interpolated data from vertex
shader
© Output
© Pixel color (with alpha)
© Optional; depth
صفحه 11:
Witata Was Means:
Gonngurability
© The real power of Direct3D 10 is that
there are many ways to accomplish
any one task
© More and more tasks can be pushed
Onto the GPU
© Performance/quality trad
made on yourterms
صفحه 12:
Guided) Exercises:
Visualizer
© DirectX 10 = exploitive effects in an
audio visualizer
© Roughly based| on the
GPUSpectrogram sample in available
in the’ DirectX SDK
e A framework to try out HL
£0 Show:
© |nstancelDs
صفحه 13:
Guided Exercises
Gesnisrell Dirsecloas
@ Each effect file guides you
through the exercises.
© Breakdancin’ Bob shows up in
the comments where there is
Something to learn or something
to do,
Use) Visual Studio to edit اع
صفحه 14:
The Basic Idea
© GPUSpectrogram uses the GPU to
analyze the raw audio data and
oa the levels of various
2 aan new integer
صفحه 15:
Using) Spectrogram Data
° Wel] be using shaders to take this
data and make a visualizer
© Dancing bars with extra effects
© These techniques directly زره ite)
game scenarios 5
© The configurability of the pi 6۵65
the possibilities endless
صفحه 16:
” ۱۹۱۷۷۱۵ ۲
6 006۱۱ ۱
1 ۵ و۵۲6 »رط
3
ردو
Bob's 2 [ ۱۱ ۵
ints
صفحه 17:
Exercise 1; Drawing the
Bays
9٩ 1107
input.Pos.y *=
abs(spectrogram.r)*fScale*g_ fScale;
ANA
صفحه 18:
Exercise 2: Performance
Well be using PIX to do performance
analysis
i Build ۵ ۱
Z, Open PIX (Start->PIX for Windows)
3) File -> New Experiment
4 Navigate to your built exerts:
5, Select “A replayable Dir
stream, saved to ۶ ~
صفحه 19:
Exercise 2: Performance
© When) you exit the application, you'll
have a\log of every D3D command
that Was executed
© We've created a perf event called
~Draw Bars” that will help you find the
actual draw calls for the bays
© Where is a small problem) into, it’s
rendering that’s causingyerless in
pemmornmance,.. a
© لاملا mse? t t 9 f
صفحه 20:
Exercise 2: Debugging —
صفحه 21:
۶,27۱ 2 2 00
© Solution;
pd3dDevice->DrawIndexedInstanced(
(UINT)pSubset->IndexCount, g iNumInstances, 0,
(UINT)pSubset->VertexStart, 0 );
ANA
صفحه 22:
صفحه 23:
Exercise 3; Geometry
زورره او زر زر
@ Solution:
TriStream.Append( output );
صفحه 24:
Exercise 4; More
Parrerileaes
® Well be’ using PIX to see how we can
tweak rendering parameters to
maximize performance
e We've made a custom set of
Variables you) can track in PIX so you
Gan see the values of the Sliders
6 ۱۷/۱ be seeing how cha eee
Values Changes framer
صفحه 25:
Exercise 4: More
2 iae tera
Z, Open PIX (Start->PIX for Windows)
3, File -> New Experiment
A Navigate to your built exercise
5, Click “More Options” =
7. Add all counters under thesPiuging
Coes
صفحه 26:
Exercise 4: More
De 5
صفحه 27:
Exercise 4: More
9۵ ارزو رازم
5 ۲۵ 6۵ 255101 6۵۱۵۳6۵ ۱۱۵5 ۲۵ 0
of the slider Values along the bottom
of the chat
® You can also set the framerate as a
Graphed line
© You can see the framerate
‘Gifect Correlation to man
sliders (Some more tha
صفحه 28:
صفحه 29:
22۲ ۱9 رد ۶,2۱2
© Solution;
tex.x += sin( input.Tex.y*40 )*0.001;
tex.y += sin( input.Tex.y*60 )*0.001;
صفحه 30:
و5۵ 2/22 ۳ ۶2622
© Please open Exercise06.sIn
© Hint; Bob’s hiding in Exercise06.fx
صفحه 31:
Exercise 62 Screen Effects
© Solution (One of many!):
float2 tex = input.Tex.xy*2 - 1;
float texMag = length( tex );
تس ت۱5
float shift = sin(texMag*50.0-g fTime*3)*g fElapsedTime*0.3;
float2 offset = float2(tex.y*shift, -tex.x*shift );
tex *= texMag;
7 i
غ056 حب برمع
۹96
float4 color = BoxFilter( g samLinearCl.
return color * 0.80;
ue
tex = tex/2 + 0.5;
fea pevelch
صفحه 32: