Gamebryo Shaders.

Slides:



Advertisements
Similar presentations
© Copyright Khronos Group, Page 1 COLLADA FX Update and FX Composer 2.0 Daniel Horowitz & Ignacio Castaño.
Advertisements

Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
What's new in Microsoft Visual C Preview
Programming Languages and Paradigms The C Programming Language.
Test 2 Jason Jenkins Lauren Sears Aaron Stricklin Brandon Wolfe Julie Alexander.
Strategies and Techniques for Real-Time Shaders Neil Hazzard Software Engineer Autodesk, Media and Entertainment.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Introduction to Shader Programming
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
Beyond Uber-Shaders EXPERIMENTATIONS ON IMPROVING SHADER & EFFECT WORKFLOW.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Cg Kevin Bjorke GDC NVIDIA CONFIDENTIAL A Whole New World with Cg Graphics Program Written in Cg “C” for Graphics Compiled & Optimized Low Level,
1 High Level Shader Language (HLSL) Chapter What is HLSL? The previous vertex and pixel shader programming is to use assembly language to write.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
Week 3 - Wednesday.  What did we talk about last time?  Project 1  Graphics processing unit  Programmable shading.
Week 3 - Friday.  What did we talk about last time?  Vertex shaders  Geometry shaders  Pixel shaders.
Real-time Graphical Shader Programming with Cg (HLSL)
차세대 그래픽 개발 환경.NET & DirectX 강성재 Community Specialist Microsoft Corporation.
Geometric Objects and Transformations. Coordinate systems rial.html.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Overview [See Video file] Architecture Overview.
Week 3 - Monday.  What did we talk about last time?  Graphics rendering pipeline  Rasterizer Stage.
Computer graphics & visualization The programmable (D3D 10) Pipeline.
Real-Time High Quality Rendering CSE 291 [Winter 2015], Lecture 4 Brief Intro to Programmable Shaders
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
GTK Binding for Alice Robert Grabowski Eine GTK-Schnittstelle für Alice.
NVIDIA CONFIDENTIAL Hardware Shading for Artists.
The Cg Runtime Cyril Zeller. Cg Pipeline Graphics programs are written in Cg and compiled to low-level assembly code... Cg Runtime API...
Shader Program in Gamebryo. Introduction Shader?  A complete Rendering Effect to apply to an object  Shader Program – Vertex/Pixel Shader Shader Programs.
Object Oriented Programming (OOP) Lecture No. 10.
Introduction to Programming
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
NVIDIA FX Composer 2 Shader Authoring for Everyone Philippe Rollin Aravind Kalaiah.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Do-it-yourself dictionaries in Haskell1 Ingmar Brouns & Lukas Spee.
Adam Pletcher Volition, Inc. / THQ Shader Pipeline – Volition, Inc.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
.NET Mobile Application Development XML Web Services.
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
Advanced D3D10 Shader Authoring Presentation/Presenter Title Slide.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
OpenGl Shaders Lighthouse3d.com.
CgFX Sébastien Dominé, NVIDIA. Overview What is CgFX? CgFX runtime Production pipeline with CgFX CgFX Tools set Demo.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
AliRoot Classes for access to Calibration and Alignment objects Magali Gruwé CERN PH/AIP ALICE Offline Meeting February 17 th 2005 To be presented to detector.
Computer Science – Game DesignUC Santa Cruz Tile Engine.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Advanced Materials Using Shaders. Show demo advanced_ogre.
C++ Lesson 1.
Introduction to OpenGL
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Computer Graphics Practical Lesson 10
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
03 | Creating, Texturing and Moving Objects
Introduction to OpenGL
CS 480/680 Computer Graphics GLSL Overview.
Language Definitions Chap. 3 of Orange Book.
C Language B. DHIVYA 17PCA140 II MCA.
OpenGL-Rendering Pipeline
Presentation transcript:

Gamebryo Shaders

Shader and Shader program Entire Rendering Pipeline Shader program Vertex or Pixel shader available in Gamebryo

Gamebryo Shader System Data Driven APP TOOL Shader Library Shaders

Shader Programs NSF/NSB FX CG FX Lite – xbox360 CGFX – ps3

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

NSF Layout NSFShader < Name > { “Description” UserDefinedData Objects Global_Attributes Attributes PackingDef Implementation }

NSF – Objects Access NiDynamicEffects From NiDynamicEffectState Objects { ObjectType ObjectIndex LocalName } Example Objects { Effect_GeneralLight 1 Light1 Effect_DirectionalLight 0 Light2 Effect_PointLight 0 Light3 Effect_GeneralLight 2 Light4 Effect_GeneralLight 3 Light5 }

NSF – Attributes(1) Global_Attributes / Attributes [Global_]Attributes { AttributeType AttributeName Artist/Hidden InitialValue <OptionalRange> or AttributeType AttributeName[ArraySize] Artist/Hidden InitialValue }

NSF – Attributes(2) Example Attributes { Attrib_Bool TestBool Artist true Attrib_UInt TestUInt Hidden 1024 [0 2048] Attrib_Float TestFloat Artist 0.65 [0.0 1.0] Attrib_Point2 TestPoint2 Artist 0.0,0.5 [(0.0,0.0) (1.0,1.0)] Attrib_Point3 TestPoint3 Artist 0.1,0.2,0.3 [(0.0,0.0,0.0) (1.0,1.0,1.0)] Attrib_Point4 TestPoint4 Artist 0.1,0.2,0.3,0.4 [(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 0 "DefaultTextures\Image000.bmp“ } Global_Attributes Attrib_Point4 TestArrayPoint4[5] Hidden 0.0,0.0,0.0,0.0

NSF – PackingDef(1) PackingDef < Name > { PD_Stream # Parameter Register Type } Parameter Register Type Tesselator Usage UsageIndex

NSF – PackingDef(2) Example PackingDef MultiStream { PD_Stream 0 // First set of vertex/normal/texture data PDP_Position 0 PDT_Float3 PDP_Normal 3 PDT_Float3 PDP_TexCoord0 6 PDT_Float2 PD_Stream 1 // Second set of vertex/normal data PDP_ExtraData 0 1 PDT_Float3 PDTESS_Default PDU_Position 1 PDP_ExtraData 1 4 PDT_Float3 PDTESS_Default PDU_Normal 1 PD_Stream 2 // Third set of vertex/normal data PDP_ExtraData 2 2 PDT_Float3 PDTESS_Default PDU_Position 2 PDP_ExtraData 3 5 PDT_Float3 PDTESS_Default PDU_Normal 2 }

NSF-Implementation Need Packing Definition Declare Fixed Pipeline을 사용할 때는 필요없음 Implementation < Name > { “Description” Requirements ClassName = NameOfDerivedClass UserDefinedData PackingDef RenderStates (VS,GS,PS)_ConstantMap Pass }

Questions

NSF – Impl – RenderStates RenderState = value Save Save기능은 D10에서는 사용되지 않음 Example RenderStates { Lighting = false AlphaBlendEnable = false Save ZEnable = ZB_True ZWriteEnable = true }

NSF – Impl – Constantmap(1) Platform마다 다르게 설정할 수 있음 Entries Object Entry Defined Entry Attribute Entry Constant Entry Global Entry Operator Entry

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 BoneMatrix3 10 0 20

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

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

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 }

Questions

NSF – Impl – Pass Pass < Name > { UserDefinedData RenderState (VS,GS,PS)Program (VS,GS,PS)_ConstantMap Stage Sampler Texture }

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     } }

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" }

NSF – Impl – Pass – Stage(1) Configure Fixed Function Pxel Pipeline Sampler and Texture Used with Pixel Shader instead Stage N OPTIONAL_StageN { Entries }

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 }

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

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

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" }

Questions

Sample Colorize vsh psh

Sample TwoPass

Sample BaseBumpWithSpatialGlow

Extension of NSB Shader ClassName = MyDerivedClass NiBinaryShader CreateNiBinaryShaderCallback typedef NiBinaryShader* (*CREATENIBINARYSHADER) ( const char* pacClassName )

Questions

FX Shaders 수많은 FX Shader 예제들을 손쉽게 붙여볼 수 있음 NSB/NSF 과 유사함 다른 FX Tool과 완벽히 호환되지 않음

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

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”

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;>

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

Sample PerPixelLightingEffect

Questions

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)

Shader Library Architecture

NiShaderFactory Handle Shader Libraries NISHADERFACTORY_CLASSCREATIONCALLBACK Requested with LoadAndRegisterShaderLibrary via RegisterClassCreationCallback NISHADERFACTORY_RUNPARSERCALLBACK Requested with LoadAndRunParserLibrary NISHADERFACTORY_ERRORCALLBACK

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

Sample Demo/ShaderSample/ShaderLibrary Aniso,Halo

Questions

Shaders in Gamebryo

Shaders in Gamebryo

Shaders in Gamebryo Eturnum MetalWars