Download presentation
Presentation is loading. Please wait.
1
Gamebryo Shaders
2
Shader and Shader program
Entire Rendering Pipeline Shader program Vertex or Pixel shader available in Gamebryo
3
Gamebryo Shader System
Data Driven APP TOOL Shader Library Shaders
4
Shader Programs NSF/NSB FX CG FX Lite – xbox360 CGFX – ps3
5
NSF/NSB Shader NSF NSB vs ps NSF NSB Data Driven NDL Shader File
Text-based NSB Shader Description NSF’s Binary Version Compiled NSB’s Filename <Shader Name in NSF FILE>.nsb Data Driven NSF compile NSB vs ps
6
NSF Layout NSFShader < Name > { “Description” UserDefinedData Objects Global_Attributes Attributes PackingDef Implementation }
7
NSF – Objects Access NiDynamicEffects From NiDynamicEffectState
Objects { ObjectType ObjectIndex LocalName } Example Objects { Effect_GeneralLight Light1 Effect_DirectionalLight Light2 Effect_PointLight Light3 Effect_GeneralLight Light4 Effect_GeneralLight Light5 }
8
NSF – Attributes(1) Global_Attributes / Attributes
[Global_]Attributes { AttributeType AttributeName Artist/Hidden InitialValue <OptionalRange> or AttributeType AttributeName[ArraySize] Artist/Hidden InitialValue }
9
NSF – Attributes(2) Example Attributes {
Attrib_Bool TestBool Artist true Attrib_UInt TestUInt Hidden [ ] Attrib_Float TestFloat Artist [ ] Attrib_Point TestPoint2 Artist 0.0, [(0.0,0.0) (1.0,1.0)] Attrib_Point TestPoint3 Artist 0.1,0.2, [(0.0,0.0,0.0) (1.0,1.0,1.0)] Attrib_Point TestPoint4 Artist 0.1,0.2,0.3, [(0.0,0.0,0.0,1.0) (1.0,1.0,1.0,1.0)] Attrib_Matrix3 TestMatrix3 Artist 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9 Attrib_Transform TestTransform Artist 0.1,0.2,0.3,0.4, 0.5,0.6,0.7,0.8, 0.9,1.0,1.1,1.2, 1.3,1.4,1.5,1.6 Attrib_Color TestColor Artist 1.0,0.2,0.4 [(0.0,0.0,0.0) (1.0,1.0,1.0)] Attrib_Color TestColor2 Artist 0.0,0.2,0.4,0.8 [(0.0,0.0,0.0,0.0) (1.0,1.0,1.0,1.0)] Attrib_Texture TestTexture Artist "DefaultTextures\Image000.bmp“ } Global_Attributes Attrib_Point4 TestArrayPoint4[5] Hidden 0.0,0.0,0.0,0.0
10
NSF – PackingDef(1) PackingDef < Name > { PD_Stream # Parameter Register Type } Parameter Register Type Tesselator Usage UsageIndex
11
NSF – PackingDef(2) Example PackingDef MultiStream {
PD_Stream 0 // First set of vertex/normal/texture data PDP_Position PDT_Float3 PDP_Normal PDT_Float3 PDP_TexCoord PDT_Float2 PD_Stream 1 // Second set of vertex/normal data PDP_ExtraData PDT_Float3 PDTESS_Default PDU_Position 1 PDP_ExtraData PDT_Float3 PDTESS_Default PDU_Normal 1 PD_Stream 2 // Third set of vertex/normal data PDP_ExtraData PDT_Float3 PDTESS_Default PDU_Position 2 PDP_ExtraData PDT_Float3 PDTESS_Default PDU_Normal 2 }
12
NSF-Implementation Need Packing Definition Declare
Fixed Pipeline을 사용할 때는 필요없음 Implementation < Name > { “Description” Requirements ClassName = NameOfDerivedClass UserDefinedData PackingDef RenderStates (VS,GS,PS)_ConstantMap Pass }
13
Questions
14
NSF – Impl – RenderStates
RenderState = value Save Save기능은 D10에서는 사용되지 않음 Example RenderStates { Lighting = false AlphaBlendEnable = false Save ZEnable = ZB_True ZWriteEnable = true }
15
NSF – Impl – Constantmap(1)
Platform마다 다르게 설정할 수 있음 Entries Object Entry Defined Entry Attribute Entry Constant Entry Global Entry Operator Entry
16
NSF – Impl – Constantmap(2)
Object Entry CM_Object Name Parameter Register CM_Object Name Parameter VarName Parameters Dimmer, Ambient, Diffuse, WorldPostion… Defined Entry CM_Defined Name Register ExtraData CM_Defined Name VarName ExtraData Example CM_Defined BoneMatrix
17
NSF – Impl – Constantmap(3)
Attribute Entry CM_Attribute Name Register RegisterCount ExtraData Name NiExtraData at Runtime is not provide Hand Attach / Exposure to Tool ExtraData isn’t valid right now(unsigned int) Constant Entry CM_Constant Name Register RegisterCount Values
18
NSF – Impl – Constantmap(4)
Operator Entry Vertex Shader Constant Map Only CM_Operator OpEntryName Register RegisterCount Entry1Name operator Entry2Name OPTIONAL_Inverse OPTIONAL_Tanspose Operators ( * / + - ) Entries Point4, Color, Transform, Uint, float
19
NSF – Impl – Constantmap(5)
VS_Constantmap { CM_Attribute SelectedColor 4 1 0 CM_Constant RandomConstant 5 1 0.2,0.4,0.5,0.1 CM_Defined World -1 0 CM_Defined ViewProj -1 0 CM_Operator TransformTranspose 0 4 World * ViewProj Transpose CM_Object Light1 ModelPosition 6 }
20
Questions
21
NSF – Impl – Pass Pass < Name > { UserDefinedData RenderState (VS,GS,PS)Program (VS,GS,PS)_ConstantMap Stage Sampler Texture }
22
RenderStates,ConstantMap in a Pass
Pass N 에서 설정한 값이 Pass N+1에서 수정하지 않는한 영향을 미치게 된다. Save 옵션을 설정하였을 경우 Pass N에서 설정한 값은 Pass N+1에서는 Pass N 이전의 값으로 셋팅되어 진다. Example Pass1 { RenderStates { AlphaBlendEnable = true Zenable = ZB_true } } Pass2 { RenderStates { Zenable = ZB_false } }
23
NSF – Impl – Pass – Shader Programs
Simple Declaration (VS,GS,PS)Program ProgramName EntryPoint ShaderTarget EntryPoint for HLSL Complete Declaration VSProgram { Platform = DX9 Program = "VertexShaderDX9.hlsl" EntryPoint = VertexShader ShaderTarget = vs_2_0 } PSProgram { Platform = DX9 Program = "PixelShaderDX.psh" }
24
NSF – Impl – Pass – Stage(1)
Configure Fixed Function Pxel Pipeline Sampler and Texture Used with Pixel Shader instead Stage N OPTIONAL_StageN { Entries }
25
NSF – Impl – Pass – Stage(2)
Example Stage 0 { TSS_TexCoordIndex = TCI_PassThru 0 TSS_ColorOp = TOP_Modulate TSS_ColorArg1 = TA_Texture TSS_ColorArg2 = TA_Diffuse TSS_AlphaOp = TOP_SelectArg1 TSS_AlphaArg1 = TA_Texture TSS_Texture = <TestMap> } Stage 1 { TSS_Texture = NTM_Base TSS_TexCoordIndex = UseMapIndex TSS_ColorOp = TOP_Modulate TSS_ColorArg1 = TA_Texture TSS_ColorArg2 = TA_Diffuse TSS_AlphaOp = TOP_Disable }
26
NSF – Impl – Pass – Sampler/Texture
Sampler_state = sampler_state_value Save Texture N OPTIONALTextureN { source = TextureSource } TextureSource Texture mapping ID NTM_Base, NTM_Dark, NTM_Detail… Attribute Name ObjectMap
27
User Defined Data(1) Support NSF, Implementation, Pass Level
UserDefinedData NameOfUDDBlock { NameOfEntry0 = < data 0 > “Quated Name” = < data * > } Data Type Int/ unsigned int, boolean, float, string/quoted string
28
User Defined Data(2) UserDefinedData ExampleBlock {
Test_Integer = 1234 Test_Boolean = true Test_1Float = 0.0 Test_2Floats = 0.0, 1.0 Test_3Floats = 0.0, 1.0, 2.0 Test_4Floats = 0.0, 1.0, 2.0, 3.0 Test_8Floats = 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 Test_9Floats = 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 Test_12Floats = 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,10.0,11.0 Test_16Floats = 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,10.0,11.0, 12.0,13.0,14.0,15.0 Test_String = StringTest Test_QuotedString = "Quote Test" "Quoted Name" = "This is a test string" }
29
Questions
30
Sample Colorize vsh psh
31
Sample TwoPass
32
Sample BaseBumpWithSpatialGlow
33
Extension of NSB Shader
ClassName = MyDerivedClass NiBinaryShader CreateNiBinaryShaderCallback typedef NiBinaryShader* (*CREATENIBINARYSHADER) ( const char* pacClassName )
34
Questions
35
FX Shaders 수많은 FX Shader 예제들을 손쉽게 붙여볼 수 있음 NSB/NSF 과 유사함
다른 FX Tool과 완벽히 호환되지 않음
36
FX Shader – Attributes Global Attributes / Attributes
float3 LightDirection : GLOBAL = {0,0,1.0} float3 LightDirection < string VarType = “Global”; > = {0,0,1.0} string description, bool hidden, bool color, <type> min, <type> max VarType GLOBAL / ATTRIBUTE
37
FX Shader – Predifined Constants
float4x4 WorldView : WORLDVIEW; PROJECTION, VIEW, WORLD … BONEMATRIX3,4, SKINBONEMATRIX3,4 Declare as array Number of array is must same of bone defined by “BonesPerPartition”
38
FX Shader – Techniques int Implementation int BonePerPartition
Auto select or Explicit Select int BonePerPartition string NBTMethod bool UsesNIRenderState bool UsesNILightState technique ComplexEffect <string shadername = "NeatEffect"; int implementation = 0;> technique SimplerEffect <string shadername = "NeatEffect"; int implementation = 1;>
39
FX Shader – etc Preprocessor Definitions Limitations #define _DX9 1
No Procedural Texture Generation Texture file Path Full path, Relative path from app’s working dir Mesh cannot be specified in the file BG color or texture cannot ne specified D3D Effects cannot share parameters
40
Sample PerPixelLightingEffect
41
Questions
42
Shader Library A collection of shaders available to the application at run-time Provide Interface for application and Tools DLL Compile for Tools(max, maya)
43
Shader Library Architecture
44
NiShaderFactory Handle Shader Libraries
NISHADERFACTORY_CLASSCREATIONCALLBACK Requested with LoadAndRegisterShaderLibrary via RegisterClassCreationCallback NISHADERFACTORY_RUNPARSERCALLBACK Requested with LoadAndRunParserLibrary NISHADERFACTORY_ERRORCALLBACK
45
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 DLL for Tools
46
Sample Demo/ShaderSample/ShaderLibrary Aniso,Halo
47
Questions
48
Shaders in Gamebryo
49
Shaders in Gamebryo
50
Shaders in Gamebryo Eturnum MetalWars
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.