Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shader Program in Gamebryo. Introduction Shader?  A complete Rendering Effect to apply to an object  Shader Program – Vertex/Pixel Shader Shader Programs.

Similar presentations


Presentation on theme: "Shader Program in Gamebryo. Introduction Shader?  A complete Rendering Effect to apply to an object  Shader Program – Vertex/Pixel Shader Shader Programs."— Presentation transcript:

1 Shader Program in Gamebryo

2 Introduction Shader?  A complete Rendering Effect to apply to an object  Shader Program – Vertex/Pixel Shader Shader Programs  Assembly code -.vsh/.psh  Compiled assembly code -.vso  Microsoft HLSL -.hlsl  nVidiaCG -.cg

3 Introduction (cont.) Shader Libraries  NSB/NSF  FX  CG Software Vertex Processing  DEVDESC_HAL_SWVERTEX / DEVDESC_HAL_MIXEDVERTEX  Switching Process Mode  NiD3DRenderState::SetSoftwareVertexProcessing

4 How to use shader program Write a Shader  NSB/NSF, FX, CG  Derivation from NiShader  Win32 – NiD3DShaderInterface, NiD3DShader, NiD3DDefaultShader  Derive NiShaderLibrary Create a Shader Library  a bunch of shaders put into the shader library Register Shader Library to a Shader Factory  NiShaderFactory::LoadAndRegisterShaderLibrary Use shaders through the shader factory

5 Shader Library A collection of shaders available to the application at run-time Provide Method  Retrieve shader  Retreive shader description To Use Shader Library Register to Shader Factory  NiShaderFactory::LoadAndRegisterShaderLibrary

6 Shader System Class Interaction Diagram

7 Class Detail NiShader  A Common interface for NiShader-NiRenderer interaction  NiShader-NiRenderer interaction  Obtaining a shader from the active material  PreProcessPipeline  Update Render-State : UsesNIRenderState Flag  UpdatePipeline  For all passes  SetupRenderingPass  SetupTransformations  PrepareGeometryForRendering – Packing streams  SetStreamSource, SetIndices  SetupShaderPrograms  PostProcessPipeline

8 Class Detail (cont.) NiShaderLibrary  A collection of shaders available to the application at run-time  Provide Method  Retrieve shader  Retreive shader description  To Use Shader Library Register to Shader Factory  NiShaderFactory::LoadAndRegisterShaderLibrary

9 Class Detail (cont.) NiShaderFactory  Handling shaders through shader-libraries  Provide Callback Method  NISHADERFACTORY_CLASSCREATIONCALLBACK  NISHADERFACTORY_RUNPARSERCALLBACK  NISHADERFACTORY_ERRORCALLBACK  Interface for Global Constants of shaders NiGPUProgram  Vertex, pixel shader program

10 Class Detail (cont.) NiShaderConstantMap  NiShaderConstantMapEntry  Constant  Defined  common transformations, material colors  Attribute  per-object settings of constant values  Global  Operator  result of some mathematical operation on other constant map entries  Object  represents an object in the scene – light, projected effects  Data Driven  NiExtraData

11 Class Detail (cont.) Decription classes  NiShaderDescBase NiShaderDescBase  NiShaderRequirementDesc NiShaderRequirementDesc  NiShaderAttributeDesc NiShaderAttributeDesc  NiShaderDesc NiShaderDesc  NiShaderLibraryDesc NiShaderLibraryDesc

12 NSF/NSB Shaders Provide a data-driven method for generating and using Gamebryo's shader system Write NSF  Text based file  Fast Prototyping Generate NSB from NSF  Binary type file  NiBinaryShaderLib Reference external shader file

13 NiMaterial System Determine proper shader in given circumstance  Generate vertex and pixel shader program code on the fly NiMaterial  NiSingleShaderMaterial NiSingleShaderMaterial  NiFragmentMaterial NiFragmentMaterial  NiStandardMaterial NiStandardMaterial

14 NiMaterial NiSingleShaderMaterial NiFragmentMaterial  Connected graph  Shade tree (http://portal.acm.org/citation.cfm?id=808602&dl=GUIDE&coll=GUIDE) Shade tree http://portal.acm.org/citation.cfm?id=808602&dl=GUIDE&coll=GUIDE  NiMaterialDescriptor  128-bit bitfield  GenerateDescriptor Is the object skinned? What per-vertex data exists on the object? Is the object lit? How many lights are affecting it? What types of lights are affecting it? What textures are applied to the object? What UV sets do they use? Are there tangent-space bases per-vertex? Is the object affected by specularity?

15 NiMaterial (cont.) NiFragmentMaterial (cont.)  Create shade tree  NiMaterialConfigurator – shade tree  NiGPUProgramDescriptor  NiMaterialNode – tree node  NiMaterialResource – uniform constants  NiMaterialResourceBinding – connections  Fallbacks  Breaking into several pass or eliminate certain lights or textures

16 NiMaterial (cont.) NiStandardMaterial  implements the default Gamebryo rendering pipeline

17 NiMaterial (cont.)

18 NiStandardMaterial (cont.)  Fallback method  SplitPerPixelLights  SplitPerVertexLights  SplitTextureMaps  DropParallaxMaps  DropParallaxMapThenSplitLights


Download ppt "Shader Program in Gamebryo. Introduction Shader?  A complete Rendering Effect to apply to an object  Shader Program – Vertex/Pixel Shader Shader Programs."

Similar presentations


Ads by Google