Presentation is loading. Please wait.

Presentation is loading. Please wait.

Strategies and Techniques for Real-Time Shaders Neil Hazzard Software Engineer Autodesk, Media and Entertainment.

Similar presentations


Presentation on theme: "Strategies and Techniques for Real-Time Shaders Neil Hazzard Software Engineer Autodesk, Media and Entertainment."— Presentation transcript:

1

2 Strategies and Techniques for Real-Time Shaders Neil Hazzard Software Engineer Autodesk, Media and Entertainment

3 Overview  Recap from GDC 2005  What’s new in 3ds max 8  Scene Effects  Extending effects with MAXscript  Tips  Lots of Demos…

4 Quick Recap from GDC 2005  3ds max supports HLSL Effect files  Dynamic UI creation based on Semantic and Annotations in the file  Automatic update of changed file and bitmaps  Based on Parser Technology  Two Formats supported. 3ds max and DxSAS 0.8  MAXScript extendible  GDC 2005 session available 

5 What’s new in 3ds max 8  New Annotation “ColorChannel” specifies whether a Map Channel contains color information.  int texcoord1 : Texcoord  <  int Texcoord = 1;  int MapChannel = 10;  bool ColorChannel = true;  >;  #define support - _3DSMAX_, 3DSMAX, MAX & _MAX_ Easier support for max specific code, by using #ifdef _MAX_  Use of DiffuseMap semantic to provide better Material Editor sample slot rendering  Scene Effects

6 Scene Effects  Effects that work at the scene level  Pre Effects – runs before any geometry is drawn  Useful for background images  Post Effects – runs after all geometry is drawn  Any “post production” work – blur, glow etc..  Environment Effects – special type that process the scene for use in per object rendering  Ideal for Shadow Maps or CubeMaps generation  Only work with the DirectX 9 Shader Material

7 Using Scene Effects - 1/4  Scene effects use a ParamID of 0x003  Tells the system to use the correct parser  Uses bool PreShader = true; to help the parser with usage.  Post effects receive the render target containing the scene in a texture parameter called SceneMap.  Pre Effects simply render into the current active render target.  Load the scene effects using the Scene Effect Loader Utility

8 Using Scene Effects - 2/4  Example of the post_output.fx file #include "quad.fxh“//helper file for drawing quads string ParamID = "0x003";//tells the system what parser //Macro to define the Scene texture and sampler DECLARE_QUAD_TEX(SceneMap,SceneSampler,"X8R8G8B8") //Simple pixel shader that simply outputs the input scene data float4 OutputPS(VertexOutput IN) : COLOR { float4 texCol = float4(tex2D(SceneSampler, IN.UV).xyz,1); // Do anything else here return texCol; }

9 Using Scene Effects - 3/4  Environment Effects  Run before the main scene output starts  Should run in conjunction with object based shaders  Object shaders can then use specific transforms setup by the environment stage  An Example is light transforms for Shadow maps  Use multiple techniques, one for environment pass and another for final pass. Have a naming convention so the parser can set them dynamically  Can create maps that would be used by objects based effects

10 Using Scene Effects – 4/4  Developers can write their own scene parsers  Node sorting and filtering can be implemented  The utility simply sorts based on the GBuffer ID and filters non DirectX 9 Shader materials  New interfaces – see RTMax.h  IDxSceneManager, IValidateNodeCallback and IDxSceneTransformManager

11 Extending with MAXScript Scripted Material Auto Generated UI

12 Extending with MAXScript  Scripted Material  plugin material StandardFX name:"StandardFX" classID:#(692421,413582) extends:DirectX_9_Shader replaceUI:true version:1 (…)  Parameters use the name defined in the effect file  You could still use “showproperties meditmaterials[1]” to list the names  Simply use the delegate keyword to set the value  The texture used by effects is actually a bitmap type

13 Extending with MAXScript  On Create Handler (Scripted_StandardFX.ms) on create do ( -- setup initial material effectfile = GetDir #maxroot effectfile = effectfile + "\\maps\\fx\\StandardFX.fx" delegate.effectfile = effectfile ambientlock = true )

14 Extending with MAXScript  Button Handler (Scripted_StandardFX.ms) on b_topDiffuseClr pressed do ( b = selectbitmap caption: "Top Diffuse Map" if b != undefined then ( delegate.g_TopTexture = b b_topDiffuseClr.text = b.filename topdiffuseMap = b --defined as type:#bitmap )

16 Things to remember  Annotations are case sensitive  The three built in parsers are very different, don’t mix up your annotations  Type verses ResourceType  name verses ResourceName  3ds max is Z-up  You soon find this out with cubemaps!!  Swap YZ around to make it work  Currently only camera based matrixes are support at the object level.  Use Scripted materials  Good to work around “Auto UI” look and feel  Data management/validation

17 Resources   Sample parsers available and documentation    msdn.microsoft.com/directx  Ben Cloward  


Download ppt "Strategies and Techniques for Real-Time Shaders Neil Hazzard Software Engineer Autodesk, Media and Entertainment."

Similar presentations


Ads by Google