Advanced D3D10 Shader Authoring
اسلاید 1: Advanced D3D10 Shader AuthoringPresentation/Presenter Title Slide
اسلاید 2: OverviewReview of Direct3D 10 and HLSL 4.0The power of the programmable pipelineGuided exercises: Visualizer
اسلاید 3: Some New D3D10 FeaturesCompletely re-architected from D3D9 for configurability and performanceGeometry ShaderFixed-function lighting and transformation now programmable in HLSL 4.0Configurable pipelineFlexible shader signaturesSystem-generated values
اسلاید 4: High Level Shader LanguageHLSL is a highly effective language for writing shadersSyntax is similar to ‘C’Preprocessor defines (#define, #ifdef, etc)Basic types (float, int, uint, bool, etc)Operators, variables, functionsHas some important differencesBuiltin variables (float4, matrix, etc)Intrinsic functions (mul, normalize, etc)
اسلاید 5: Overview of the PipelineTrianglesVertexShaderShader ConstantsTextures / BuffersEffectGeometryShaderPixelShader
اسلاید 6: Vertex Shader 4.0InputVerticesShader ConstantsSystem Variables ( VertexID )OutputIt’s up to you nowColor, Texture Coordinates, etc
اسلاید 7: System-generated ValuesValues usable in shaders generated by the D3D10 runtimeAct exactly like semantics, just tag your variable and off you goSV_VertexID Provided to the VSSV_InstanceIDProvided to the VSSV_PrimitiveIDProvided to the GS (or PS if there is no GS)
اسلاید 8: Geometry Shader 4.0InputPer-primitive data (3 verts for a tri)System variables ( PrimitiveID )OutputPoints, lines, trianglesRender target index, clip distancesStream data to a buffer on the GPUaka stream out
اسلاید 9: Geometry Shader RestrictionsCannot output more than 4096 bytes of information for each input primitivePerformance is not guaranteed when amplifying at this level
اسلاید 10: Pixel Shader 4.0InputInterpolated data from vertex shaderOutputPixel color (with alpha)Optional: depth
اسلاید 11: What This Means: ConfigurabilityThe real power of Direct3D 10 is that there are many ways to accomplish any one taskMore and more tasks can be pushed onto the GPUPerformance/quality tradeoff can be made on your terms
اسلاید 12: Guided Exercises: VisualizerDirectX 10 - exploitive effects in an audio visualizer Roughly based on the GPUSpectrogram sample in available in the DirectX SDKA framework to try out HLSL 4.0 plus to show:InstanceIDsInteger offset samplersGeometry amplificationDebugging using PIX
اسلاید 13: Guided Exercises General DirectionsEach 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.
اسلاید 14: The Basic IdeaGPUSpectrogram uses the GPU to analyze the raw audio data and evaluate the levels of various frequency rangesTo 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
اسلاید 15: Using Spectrogram DataWe’ll be using shaders to take this data and make a visualizerDancing bars with extra effectsThese techniques directly apply to game scenariosThe configurability of the pipeline makes the possibilities endless
اسلاید 16: Exercise 1: Drawing the BarsPlease open Exercise01.slnHint: Bob’s hiding in Exercise01.fx
اسلاید 17: Exercise 1: Drawing the BarsSolution: input.Pos.y *= abs(spectrogram.r)*fScale*g_fScale;
اسلاید 18: Exercise 2: PerformanceWe’ll be using PIX to do performance analysisBuild Exercise02.slnOpen PIX (Start->PIX for Windows)File -> New ExperimentNavigate to your built exerciseSelect “A replayable Direct3D call stream, saved to file:”Enter a file name ending in “.PIXrun”Click “Start Experiment”
اسلاید 19: Exercise 2: PerformanceWhen you exit the application, you’ll have a log of every D3D command that was executedWe’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
اسلاید 20: Exercise 2: Debugging
اسلاید 21: Exercise 2: PerformanceSolution:pd3dDevice->DrawIndexedInstanced( (UINT)pSubset->IndexCount, g_iNumInstances, 0, (UINT)pSubset->VertexStart, 0 );
اسلاید 22: Please open Exercise3.slnHint: Bob’s hiding in Exercise3.fxExercise 3: Geometry Amplification
اسلاید 23: Exercise 3: Geometry AmplificationSolution:TriStream.Append( output );
اسلاید 24: Exercise 4: More PerformanceWe’ll be using PIX to see how we can tweak rendering parameters to maximize performanceWe’ve made a custom set of variables you can track in PIX so you can see the values of the slidersWe’ll be seeing how changing these values changes framerate
اسلاید 25: Exercise 4: More PerformanceBuild Exercise04.slnOpen PIX (Start->PIX for Windows)File -> New ExperimentNavigate to your built exerciseClick “More Options”For CounterSet, select “(Custom)”Add all counters under the “Pluging Counters”Click “OK”Click “Start Experiment”
اسلاید 26: Exercise 4: More Debugging
اسلاید 27: Exercise 4: More DebuggingYou can assign colored lines to each of the slider values along the bottom of the chatYou can also set the framerate as a graphed lineYou can see the framerate has a direct correlation to many of these sliders (some more than others)
اسلاید 28: Exercise 5: Floor EffectPlease open Exercise05.slnHint: Bob’s hiding in Exercise05.fx
اسلاید 29: Exercise 5: Floor EffectSolution: tex.x += sin( input.Tex.y*40 )*0.001;tex.y += sin( input.Tex.y*60 )*0.001;
اسلاید 30: Exercise 6: Screen EffectsPlease open Exercise06.slnHint: Bob’s hiding in Exercise06.fx
اسلاید 31: Exercise 6: Screen EffectsSolution (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;
اسلاید 32: © 2007 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. www.xna.com End Slide
نقد و بررسی ها
هیچ نظری برای این پاورپوینت نوشته نشده است.