Download
1 / 17

Strategies and Techniques for Real-Time Shaders - PowerPoint PPT Presentation


  • 64 Views
  • Uploaded on

Strategies and Techniques for Real-Time Shaders. Neil Hazzard Software Engineer Autodesk, Media and Entertainment. Overview. Recap from GDC 2005 What’s new in 3ds max 8 Scene Effects Extending effects with MAXscript Tips Lots of Demos…. Quick Recap from GDC 2005.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Strategies and Techniques for Real-Time Shaders' - mary-mullins


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Strategies and Techniques for Real-Time Shaders

Neil Hazzard

Software Engineer

Autodesk, Media and Entertainment


Overview
Overview

  • Recap from GDC 2005

  • What’s new in 3ds max 8

  • Scene Effects

  • Extending effects with MAXscript

  • Tips

  • Lots of Demos…


Quick recap from gdc 2005
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

    • http://sparks.autodesk.com/downloads


What s new in 3ds max 8
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


Scene effects
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


Using scene effects 1 4
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


Using scene effects 2 4
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;

    }


Using scene effects 3 4
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


Using scene effects 4 4
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


Extending with maxscript
Extending with MAXScript

Scripted Material

Auto Generated UI


Extending with maxscript1
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


Extending with maxscript2
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

    )


Extending with maxscript3
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

    )

    )


Extending with maxscript4
Extending with MAXScript

  • Generates custom and sophisticated UIs

  • Allows data validation and Access control

    • E.g. power of two textures, or textures no greater than a certain size.

  • Can provide workarounds for the UI widgets generated by the parsers

  • Scriptable values instead of UI generated can drive delegate values

    • E.g. UV clamping etc..


Things to remember
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


Resources
Resources

  • http://sparks.autodesk.com

    • Sample parsers available and documentation

  • http://developer.nvidia.com

  • http://www.ati.com/developer

  • msdn.microsoft.com/directx

  • Ben Cloward

    • http://www.monitorstudios.com/bcloward/resources.html

  • [email protected]


ad