Shader Program in Gamebryo Introduction Shader A complete
Shader Program in Gamebryo
Introduction Shader? A complete Rendering Effect to apply to an object Shader Program – Vertex/Pixel Shader Programs Assembly code -. vsh/. psh Compiled assembly code -. vso Microsoft HLSL -. hlsl n. Vidia. CG -. cg
Introduction (cont. ) Shader Libraries NSB/NSF FX CG Software Vertex Processing DEVDESC_HAL_SWVERTEX / DEVDESC_HAL_MIXEDVERTEX Switching Process Mode Ni. D 3 DRender. State: : Set. Software. Vertex. Processing
How to use shader program Write a Shader NSB/NSF, FX, CG Derivation from Ni. Shader Win 32 – Ni. D 3 DShader. Interface, Ni. D 3 DShader, Ni. D 3 DDefault. Shader Derive Ni. Shader. Library Create a Shader Library a bunch of shaders put into the shader library Register Shader Library to a Shader Factory Ni. Shader. Factory: : Load. And. Register. Shader. Library Use shaders through the shader factory
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 Ni. Shader. Factory: : Load. And. Register. Shader. Library
Shader System Class Interaction Diagram
Class Detail Ni. Shader A Common interface for Ni. Shader-Ni. Renderer interaction Obtaining a shader from the active material Pre. Process. Pipeline Update Render-State : Uses. NIRender. State Flag Update. Pipeline For all passes Setup. Rendering. Pass Setup. Transformations Prepare. Geometry. For. Rendering – Packing streams Set. Stream. Source, Set. Indices Setup. Shader. Programs Post. Process. Pipeline
Class Detail (cont. ) Ni. 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 Ni. Shader. Factory: : Load. And. Register. Shader. Library
Class Detail (cont. ) Ni. Shader. Factory Handling shaders through shader-libraries Provide Callback Method NISHADERFACTORY_CLASSCREATIONCALLBACK NISHADERFACTORY_RUNPARSERCALLBACK NISHADERFACTORY_ERRORCALLBACK Interface for Global Constants of shaders Ni. GPUProgram Vertex, pixel shader program
Class Detail (cont. ) Ni. Shader. Constant. Map. Entry Constant Defined Attribute result of some mathematical operation on other constant map entries Object per-object settings of constant values Global Operator common transformations, material colors represents an object in the scene – light, projected effects Data Driven Ni. Extra. Data
Class Detail (cont. ) Decription classes Ni. Shader. Desc. Base Ni. Shader. Requirement. Desc Ni. Shader. Attribute. Desc Ni. Shader. Library. Desc
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 Ni. Binary. Shader. Lib Reference external shader file
Ni. Material System Determine proper shader in given circumstance Generate vertex and pixel shader program code on the fly Ni. Material Ni. Single. Shader. Material Ni. Fragment. Material Ni. Standard. Material
Ni. Material Ni. Single. Shader. Material Ni. Fragment. Material Connected graph Shade tree (http: //portal. acm. org/citation. cfm? id=808602&dl=GUIDE&coll=GUIDE) Ni. Material. Descriptor 128 -bit bitfield Generate. Descriptor 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?
Ni. Material (cont. ) Ni. Fragment. Material (cont. ) Create shade tree Ni. Material. Configurator – shade tree Ni. GPUProgram. Descriptor Ni. Material. Node – tree node Ni. Material. Resource – uniform constants Ni. Material. Resource. Binding – connections Fallbacks Breaking into several pass or eliminate certain lights or textures
Ni. Material (cont. ) Ni. Standard. Material implements the default Gamebryo rendering pipeline
Ni. Material (cont. )
Ni. Material (cont. ) Ni. Standard. Material (cont. ) Fallback method Split. Per. Pixel. Lights Split. Per. Vertex. Lights Split. Texture. Maps Drop. Parallax. Map. Then. Split. Lights
- Slides: 18