Shader Programming CgFX, OpenGL 2.0. Michael Haller 2003

Similar documents
Sébastien Dominé, NVIDIA. CgFX

Shaders : the sky is the limit Sébastien Dominé NVIDIA Richard Stenson SCEA

Advanced Rendering & Shading

DirectX Programming #4. Kang, Seongtae Computer Graphics, 2009 Spring

Introduction to Shaders.

Basics of GPU-Based Programming

Shaders (some slides taken from David M. course)

Creating Real Shaders in FX Composer. Kevin Bjorke NVIDIA Corporation

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

Whitepaper. Using SAS with CgFX and FX file formats. Kevin Bjorke

Teaching Cg. This presentation introduces Cg ( C for graphics ) and explains why it would be useful when teaching a computer graphics course.

NVIDIA FX Composer. Developer Presentation June 2004

Shaders in Eve Online Páll Ragnar Pálsson

RenderMonkey 1.6. Natalya Tatarchuk ATI Research

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

High-Precision Shading and Geometry. Kevin Bjorke NVIDIA Corporation

Pipeline Integration with FX Composer. Chris Maughan NVIDIA Corporation

Whitepaper. Using SAS with CgFX and FX file formats. Kevin Bjorke

Shaders Part II. Traditional Rendering Pipeline

Accelerating Realism with the (NVIDIA Scene Graph)

Shaders. Slide credit to Prof. Zwicker

Shader Series Primer: Fundamentals of the Programmable Pipeline in XNA Game Studio Express

Lab 3 Shadow Mapping. Giuseppe Maggiore

The Ultimate Developers Toolkit. Jonathan Zarge Dan Ginsburg

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

User Guide. DU _v01f January 2004

Evolution of GPUs Chris Seitz

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Technical Report. Mesh Instancing

NVSG NVIDIA Scene Graph

SDK White Paper. Rainbows and Fogbows Adding Natural Phenomena

Getting Started with Cg. Release 1.2 February 2004

Data passed from a source application is recognized by the destination application, yielding identical results. Data (Converted) compatibility

NVIDIA Tools for Artists

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

Cg Toolkit. Cg 1.3 Release Notes. December 2004

NVIDIA Developer Tools for Graphics and PhysX

Introduction to OpenGL

OpenGL ES 2.0 : Start Developing Now. Dan Ginsburg Advanced Micro Devices, Inc.

The Effects Framework. October 31, Composed of the following components:

Teaching a Modern Graphics Pipeline Using a Shader-based Software Renderer

Cg 2.0. Mark Kilgard

Cg Toolkit. Cg 2.1 October 2008 Release Notes

The Application Stage. The Game Loop, Resource Management and Renderer Design

Cg Toolkit. Cg 2.1 beta August 2008 Release Notes

printf Debugging Examples

Cg Toolkit. Cg 2.0 May 2008 Release Notes

Cg Toolkit. Cg 2.0 January 2008 Release Notes

CS 4620 Program 3: Pipeline

Canonical Shaders for Optimal Performance. Sébastien Dominé Manager of Developer Technology Tools

Programming Graphics Hardware

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

Cg: A system for programming graphics hardware in a C-like language

Pump Up Your Pipeline

Optimal Shaders Using High-Level Languages

Cg Toolkit. Cg 2.2 February 2010 Release Notes

Computer Graphics Coursework 1

Dave Shreiner, ARM March 2009

last time put back pipeline figure today will be very codey OpenGL API library of routines to control graphics calls to compile and load shaders

Cg Toolkit. Cg 1.2 Release Notes

PVRShaman. User Manual

Designing a Modern GPU Interface

Computer graphics 2: Graduate seminar in computational aesthetics

Cg Toolkit. Cg 2.2 April 2009 Release Notes

Cg Toolkit. Cg 1.4 rc 1 Release Notes

Content. Building Geometry Appearance Lights Model Loaders

Technical Report. Anisotropic Lighting using HLSL

Programming Graphics Hardware

PyFX: A framework for programming real-time effects

Siggraph Agenda. Usability & Productivity. FX Composer 2.5. Usability & Productivity 9/12/2008 9:16 AM

GPU Programmable Graphics Pipeline

CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Game Graphics & Real-time Rendering

Custom Component Development Using RenderMonkey SDK. Natalya Tatarchuk 3D Application Research Group ATI Research, Inc

Dynamic Code Generation for Realtime Shaders

Programmable Graphics Hardware

B x. Interoperability Chart Version 2011 LEGEND. Perfect compatibility. Data (Converted) compatibility. Emulated (Bake) compatibility.

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

User s Guide. FX Composer 2.5. April 2008 DU _v01

Transforming Production Workflows with the GPU. Kevin Bjorke, NVIDIA SIGGRAPH 2004

Sung-Eui Yoon ( 윤성의 )

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

1 of 5 9/10/ :11 PM

Models and Architectures

12.2 Programmable Graphics Hardware

MXwendler Fragment Shader Development Reference Version 1.0

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

INFOGR Computer Graphics

Table of contents. Autodesk Entertainment Creation Suite 2016 Questions and answers. 1. General product information 3. 2.

CIS 536/636 Introduction to Computer Graphics. Kansas State University. CIS 536/636 Introduction to Computer Graphics

Programmable Graphics Hardware

Lecture 10: Shading Languages. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

Profiling and Debugging Games on Mobile Platforms

Shading Languages Tim Foley

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Transcription:

Shader Programming CgFX, OpenGL 2.0 Michael Haller 2003

Outline What is CgFX? CgFX runtime Production pipeline with CgFX CgFX Tools set OpenGL 2.0

What is CgFX? CgFX (C for Graphics Effekt File) Supports Microsoft.fx files Cg plus: Multi-pass Hardware fallbacks (techniques) Complete Hardware states Tweakables MS.fx (HLSL) plus: DirectX8 and OpenGL MAC and Linux

CgFX overview

Typical Production Pipeline Programmers write assembly for different hardware DCC tool (Maya, Max, SoftImage, ) Digital Content Creation Scene exporter plug-in Artists create models, textures, maps, in DCC tool of choice DCC Image ASM Shaders (HW1) ASM Shaders (HW2) Scene manager Models, Textures, Maps, Application (game, renderer, ) Not the same! Game Image App Scene Manager hard-coded to choose at run-time the appropriate ASM shaders + state for the hardware

CgFX Production Pipeline Programmers and/or artists write FX effects DCC tool (Maya, Max, SoftImage, ) FX material plug-in Scene exporter plug-in Artists assign FX files to scene objects and tweak parameters for each object in real-time FX files Models, Textures, Maps, FX effects + parameters Same Image Scene manager FX runtime Application (game, renderer, ) For any FX, App Scene Manager chooses at run-time the appropriate technique for the hardware

CgFX Example File - Structure Global declarations Tweakable declarations Vertex shaders Fragment shaders Techniques to encapsulate shaders

Techniques effect myeffectname { technique PixelShaderVersion { }; technique FixedFunctionVersion { }; technique LowDetailVersion { }; };

Passes Each technique contains one or more passes Each pass may contain a vertex program, a fragment program, or both. E.g. Pass 0: Fixed-function pixel processing to output the ambient color. Pass 1: ps_1_1 fragment program Pass 2: ps_2_0 fragment program Typically, all passes of a technique use Cg or assembly programs.

Render States pass firstpass { DepthWriteEnable = true; AlphaBlendEnable = false; MinFilter[ 0 ] = Linear; MagFilter[ 0 ] = Linear; MipFilter[ 0 ] = Linear; // Pixel shader written in assembly PixelShader = asm { ps.1.1 tex t0; mov r0, t0; }; };

Variables and Semantics Global and per-technique Cg-style variables (passed as uniform parameters): bool AlphaBlending = false; float bumpheight = 0.5f; These variables can contain a user-defined semantic, which helps applications provide the correct data to the shader: float4x4 myviewmatrix : ViewMatrix; texture2d sometexture : DiffuseMap;

Annotations Additionally, each variable can have an optional annotation. An annotation describes a user interface element for manipulating uniform variables: float bumpheight < string gui = slider ; float uimin = 0.0f; float uimax = 1.0f; float uistep = 0.1f; > = 0.5f;

My first fx example (Blinn) struct appdata { float4 vposition : POSITION; float4 vnormal : NORMAL; float4 vtexcoords : TEXCOORD0; }; struct vpconn { float4 vtexcoord0 : TEXCOORD0; float4 vdiffuse : COLOR0; float4 vposition : POSITION; float4 vspecular : COLOR1; };

My first fx example (Blinn) II // un-tweakables float4x4 worldview : WorldView; float4x4 worldviewit: WorldViewIT; float4x4 worldviewprojection : WorldViewProjection; [...] // tweakables float4 diffuse : DIFFUSE = { 0.1f, 0.1f, 0.5f, 1.0f }; [...] float4 lightpos : Position < string Object = "PointLight"; string Space = "World"; > = {100.0f, 100.0f, 100.0f, 0.0f};

My first fx example (Blinn) III vpconn vs_blinnshading(appdata IN, uniform float4x4 ModelViewProj, uniform float4x4 ModelView, uniform float4x4 ModelViewIT, uniform float4x4 ViewIT, uniform float4x4 View, uniform float4 lightpos, uniform float4 diffuse, uniform float4 specular, uniform float4 ambient) { vpconn OUT; [ ] } OUT.vDiffuse = diff_term; OUT.vPosition = mul(modelviewproj,in.vposition); return OUT;

My first fx example (Blinn) IV technique Blinn { pass p0 { Zenable = true; ZWriteEnable = true; CullMode = None; VertexShader = compile vs_1_1 vs_blinnshading( worldviewprojection, worldview, worldviewit, viewit, view, lightpos, diffuse, specular, ambient); } }

Results (Blinn) I

Results (Blinn) II

Production Pipeline with CgFX

CgFX Tools Set Integrated authoring in DCC apps: 3ds MAX 5.1 MAYA 4.5 XSI (CgFX Coming soon...) NVB Exporter CgFX Viewer OpenGL ARB, DirectX8, DirectX9

3D Studio Max 5.1 stdmaterial <-> CgFX Ability to select MAX scene lights and connect them to.fx parameters On the fly editing of shaders and auto-update of.fx GUI MAXSCRIPT support Source Code

Integration in 3D Studio Max

CgFX Viewport Manager Intuitive artist controls (sliders, color pickers, etc.) Dynamic, shaderspecific GUI Multiple Techniques for fallbacks Supports.fx file format

Shader changed by selecting a new fx file Color and numeric values can be changed Customizable Parameters are specific to each effect Bitmaps can be swapped

NVB Exporter for 3ds max Based on Pierre Terdiman s 3ds max exporter http://www.codercorner.com/flexporter.htm Exports Scene data Mesh, materials, lights, camera, skinning, etc... Exports CgFX materials ICgFXDataBridge interface Source code

CgFX Viewer Scene graph GUI.fx parameters edition Error reporting for easy.fx file problem identification Runs OpenGL, DirectX8, DirectX9 Switch between devices at any point

CgFX Viewer II Main Application Window Connection Editor Window The CgFX Viewer can be used as a production resource and a code example for implementing CgFX

How Does CgFX relate to Cg? CgFX describes an entire effect Cg implements a particular function required by an effect CgFX describes all the parameters (and their meaning or semantics) that the app has to provide automatic parameter discovery CgFX can describe complex multi-pass effects CgFX can handle multiple techniques

Hardware Shader Workflow Designing Shaders and Using Existing Shaders Artist-Configurable Parameters Editing Shader Parameters Exporting Shader Parameters to Game Engine

Multiple, narrowly-targeted shaders are more efficient/faster than large all-purpose shaders Several shaders may share similar features and lighting models Small Efficient Shaders

OpenGL: Where do you want to go today?

OpenGL 2.0 Goals Reduce the need for existing and future extensions to OpenGL by replacing complexity with programmability. Backward compatibility to OpenGL 1.x Address the needs of dynamic media authoring and playback applications needed by OpenML.

Status of Shading Language Extensions to support the OpenGL Shading Language Language approved as ARB extensions in June 2003 Language and extensions expected to be rolled into OpenGL in 6 rolled into OpenGL in 6-12 months 12 months That version of OpenGL will be called OpenGL 2.0 It will still be backwards compatible with 1.0-1.5 3Dlabs is shipping a preliminary implementation

Overview

Thanks!