صفحه 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:

Advanced D3D10 Shader Authoring Overview Review of Direct3D 10 and HLSL 4.0 The power of the programmable pipeline Guided exercises: Visualizer Some New D3D10 Features Completely re-architected from D3D9 for configurability and performance Geometry Shader Fixed-function lighting and transformation now programmable in HLSL 4.0 Configurable pipeline Flexible shader signatures System-generated values High Level Shader Language HLSL is a highly effective language for writing shaders Syntax is similar to ‘C’ Preprocessor defines (#define, #ifdef, etc) Basic types (float, int, uint, bool, etc) Operators, variables, functions Has some important differences Builtin variables (float4, matrix, etc) Intrinsic functions (mul, normalize, etc) Overview of the Pipeline Effect Triangles Shader Constants Vertex Shader Geometry Shader Pixel Shader Textures / Buffers Vertex Shader 4.0 Input Vertices Shader Constants System Variables ( VertexID ) Output It’s up to you now Color, Texture Coordinates, etc System-generated Values Values usable in shaders generated by the D3D10 runtime Act exactly like semantics, just tag your variable and off you go SV_VertexID Provided to the VS SV_InstanceID Provided to the VS SV_PrimitiveID Provided to the GS (or PS if there is no GS) Geometry Shader 4.0 Input Per-primitive data (3 verts for a tri) System variables ( PrimitiveID ) Output Points, lines, triangles Render target index, clip distances Stream data to a buffer on the GPU aka stream out Geometry Shader Restrictions Cannot output more than 4096 bytes of information for each input primitive Performance is not guaranteed when amplifying at this level Pixel Shader 4.0 Input Interpolated data from vertex shader Output Pixel color (with alpha) Optional: depth What This Means: Configurability 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 tradeoff can be made on your terms Guided Exercises: Visualizer DirectX 10 - exploitive effects in an audio visualizer Roughly based on the GPUSpectrogram sample in available in the DirectX SDK A framework to try out HLSL 4.0 plus to show: InstanceIDs Integer offset samplers Geometry amplification Debugging using PIX Guided Exercises General Directions 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 the effect and cpp files and to build. If you get stuck or need help, raise your hand. A proctor will assist you. The Basic Idea GPUSpectrogram uses the GPU to analyze the raw audio data and evaluate the levels of various frequency ranges To check this code out and see the new integer instruction set in action, check out the GPUSpectrogram sample or GPUSpectrogram.fx included in the workshop Using Spectrogram Data We’ll be using shaders to take this data and make a visualizer Dancing bars with extra effects These techniques directly apply to game scenarios The configurability of the pipeline makes the possibilities endless Exercise 1: Drawing the Bars Please open Exercise01.sln Hint: Bob’s hiding in Exercise01.fx Exercise 1: Drawing the Bars Solution: input.Pos.y *= abs(spectrogram.r)*fScale*g_fScale; Exercise 2: Performance We’ll be using PIX to do performance analysis 1. Build Exercise02.sln 2. Open PIX (Start->PIX for Windows) 3. File -> New Experiment 4. Navigate to your built exercise 5. Select “A replayable Direct3D call stream, saved to file:” 6. Enter a file name ending in “.PIXrun” 7. Click “Start Experiment” 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 bars. There is a small problem in how it’s rendering that’s causing a loss in performance… You might want to look in Exercise02.cpp Exercise 2: Debugging Exercise 2: Performance Solution: pd3dDevice->DrawIndexedInstanced( (UINT)pSubset->IndexCount, g_iNumInstances, 0, (UINT)pSubset->VertexStart, 0 ); Exercise 3: Geometry Amplification Please open Exercise3.sln Hint: Bob’s hiding in Exercise3.fx Exercise 3: Geometry Amplification Solution: TriStream.Append( output ); Exercise 4: More Performance We’ll be using PIX to see how we can tweak rendering parameters to maximize performance We’ve made a custom set of variables you can track in PIX so you can see the values of the sliders We’ll be seeing how changing these values changes framerate Exercise 4: More 1. Build Exercise04.sln Performance 2. Open PIX (Start->PIX for Windows) 3. File -> New Experiment 4. Navigate to your built exercise 5. Click “More Options” 6. For CounterSet, select “(Custom)” 7. Add all counters under the “Pluging Counters” 8. Click “OK” 9. Click “Start Experiment” Exercise 4: More Debugging Exercise 4: More Debugging You can assign colored lines to each 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 has a direct correlation to many of these sliders (some more than others) Exercise 5: Floor Effect Please open Exercise05.sln Hint: Bob’s hiding in Exercise05.fx Exercise 5: Floor Effect Solution: tex.x += sin( input.Tex.y*40 )*0.001; tex.y += sin( input.Tex.y*60 )*0.001; Exercise 6: Screen Effects Please open Exercise06.sln Hint: Bob’s hiding in Exercise06.fx Exercise 6: Screen Effects Solution (One of many!): float2 tex = input.Tex.xy*2 - 1; float texMag = length( tex ); tex /= texMag; float shift = sin(texMag*50.0-g_fTime*3)*g_fElapsedTime*0.3; float2 offset = float2(tex.y*shift, -tex.x*shift ); tex *= texMag; tex += offset; tex = tex/2 + 0.5; float4 color = BoxFilter( g_samLinearClamp, tex, 3 ); return color * 0.80; www.xna.com © 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

51,000 تومان