Getting Started with Cg. Release 1.2 February 2004

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

Basics of GPU-Based Programming

Cg 2.0. Mark Kilgard

The Problem: Difficult To Use. Motivation: The Potential of GPGPU CGC & FXC. GPGPU Languages

Introduction to Shaders.

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

Cg Toolkit. Cg 1.2 Release Notes

Cg Toolkit. Cg 2.0 January 2008 Release Notes

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

3D buzzwords. Adding programmability to the pipeline 6/7/16. Bandwidth Gravity of modern computer systems

Cg Toolkit. Cg 2.0 May 2008 Release Notes

Shaders. Slide credit to Prof. Zwicker

Cg Toolkit. Cg 1.3 Release Notes. December 2004

Cg Toolkit. Cg 2.1 October 2008 Release Notes

Cg Toolkit. Cg 2.1 beta August 2008 Release Notes

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Programming Graphics Hardware

Shader Programming CgFX, OpenGL 2.0. Michael Haller 2003

Cg Toolkit. Cg 1.4 rc 1 Release Notes

NVIDIA Developer Tools for Graphics and PhysX

Tutorial on GPU Programming. Joong-Youn Lee Supercomputing Center, KISTI

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

Sébastien Dominé, NVIDIA. CgFX

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

Accelerating Realism with the (NVIDIA Scene Graph)

CG Surfaces: Materials, Shading, and Texturing

Cg Toolkit. Cg 2.2 April 2009 Release Notes

CS427 Multicore Architecture and Parallel Computing

Intro to GPU Programming (OpenGL Shading Language) Cliff Lindsay Ph.D. Student CS WPI

Graphics Hardware. Instructor Stephen J. Guy

Cg Toolkit. Cg 2.2 February 2010 Release Notes

CS195V Week 9. GPU Architecture and Other Shading Languages

CS 179: GPU Programming

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

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Programmable Graphics Hardware

NVSG NVIDIA Scene Graph

COMP371 COMPUTER GRAPHICS

Lecture 2. Shaders, GLSL and GPGPU

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

The Ultimate Developers Toolkit. Jonathan Zarge Dan Ginsburg

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

Programmable GPUS. Last Time? Reading for Today. Homework 4. Planar Shadows Projective Texture Shadows Shadow Maps Shadow Volumes

Shaders (some slides taken from David M. course)

Computer Graphics Coursework 1

Copyright Khronos Group Page 1

CS GPU and GPGPU Programming Lecture 1: Introduction. Markus Hadwiger, KAUST

OpenGL Programmable Shaders

3D Computer Games Technology and History. Markus Hadwiger VRVis Research Center

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

MXwendler Fragment Shader Development Reference Version 1.0

DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/

Whiz-Bang Graphics and Media Performance for Java Platform, Micro Edition (JavaME)

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

NVIDIA FX Composer. Developer Presentation June 2004

Developer Tools. Robert Strzodka. caesar research center Bonn, Germany

Could you make the XNA functions yourself?

printf Debugging Examples

From Brook to CUDA. GPU Technology Conference

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

Adding Advanced Shader Features and Handling Fragmentation

GPGPU, 4th Meeting Mordechai Butrashvily, CEO GASS Company for Advanced Supercomputing Solutions

A Real-Time Procedural Shading System for Programmable Graphics Hardware

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

Using the PowerVR SDK to Optimize your Renderer

GPGPU. Peter Laurens 1st-year PhD Student, NSC

Advanced Computer Graphics (CS & SE ) Lecture 7

GpuPy: Accelerating NumPy With a GPU

NVIDIA Authoring Tools for

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

frame buffer depth buffer stencil buffer

Motivation Hardware Overview Programming model. GPU computing. Part 1: General introduction. Ch. Hoelbling. Wuppertal University

The PowerVR Insider SDK. PowerVR Developer Technology

12.2 Programmable Graphics Hardware

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

Programming shaders & GPUs Christian Miller CS Fall 2011

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

CS 543: Computer Graphics. Introduction

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

Complex Multipass Shading On Programmable Graphics Hardware

Hardware Accelerated Volume Visualization. Leonid I. Dimitrov & Milos Sramek GMI Austrian Academy of Sciences

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Dynamic Code Generation for Realtime Shaders

BCA611 Video Oyunları için 3B Grafik

CS GPU and GPGPU Programming Lecture 8+9: GPU Architecture 7+8. Markus Hadwiger, KAUST

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

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

Lecture 13: OpenGL Shading Language (GLSL)

Rendering Objects. Need to transform all geometry then

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

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

Cornell University CS 569: Interactive Computer Graphics. Introduction. Lecture 1. [John C. Stone, UIUC] NASA. University of Calgary

Homework 3: Programmable Shaders

SIGGRAPH Briefing August 2014

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

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Pipeline Integration with FX Composer. Chris Maughan NVIDIA Corporation

Transcription:

Getting Started with Cg Release 1.2 February 2004

What This Presentation Contains What s Included in the Cg Distribution How to Learn Cg Quickly A Brief Introduction to Cg Using Cg in Your Applications Using the Cg Runtime Frequently Asked Questions about Cg

What s Included in the Cg Distribution Cg Compiler Cg Runtime Cg User s Manual Cg Browser Sample Cg Shaders Runtime Transition Document and Utility

Where to Find Information About Cg http://developer.nvidia.com/cg Whitepapers Presentations Cg User s Manual Cg Language Specification Cg Toolkit Downloads Bug Reporting www.cgshaders.org Forums Shader Repository (Freeware)

How to Learn Cg Quickly Read this presentation Understand the high-level picture Download the Cg Toolkit Cg_Toolkit.zip contains the complete toolkit If bandwidth is an issue, just get Cg_Compiler.exe Check out the Cg User s Manual Read the Introduction to the Cg Language chapter This explains the language syntax and constructs Try A Brief Tutorial Gives you a chance to try Cg first-hand Everything is already set up for you

How to Learn Cg Quickly (Cont d) Try the Cg Tutorials Available at http://developer.nvidia.com/view.asp?io=cg_tutorials Learn about the Cg Runtime Read Using the Cg Runtime (in the Cg User s Manual) Don t Hesitate to Ask Questions Try the forums on www.cgshaders.org to talk to others who are learning or have learned Cg Send mail to cgsupport@nvidia.com

A Brief Introduction to Cg Cg is C C for Graphics, a high-level level, cross-platform language for graphics programming Cg replaces tedious assembly coding with a C-like language and a compiler that generates assembly for you Cg is a cross-api and cross-platform language: It works with both OpenGL and DirectX It runs on Windows and Linux and OS X (more in the works) It supports hardware from NVIDIA, ATI, Matrox, and any other programmable hardware that supports OpenGL or DirectX The Cg Runtime simplifies parameter passing from your application to the vertex and fragment programs

A Brief Introduction to Cg (Cont d) Ensures increasing optimization through forward compatibility Works with ALL programmable GPUs supporting DirectX 8/9 or OpenGL 1.4 Works with future versions of DirectX and OpenGL

What Does Cg Look Like? Assembly RSQR R0.x, R0.x; MULR R0.xyz, R0.xxxx, R4.xyzz; MOVR R5.xyz, -R0.xyzz; MOVR R3.xyz, -R3.xyzz; DP3R R3.x, R0.xyzz, R3.xyzz; SLTR R4.x, R3.x, {0.000000}.x; ADDR R3.x, {1.000000}.x, -R4.x; MULR R3.xyz, R3.xxxx, R5.xyzz; MULR R0.xyz, R0.xyzz, R4.xxxx; ADDR R0.xyz, R0.xyzz, R3.xyzz; DP3R R1.x, R0.xyzz, R1.xyzz; MAXR R1.x, {0.000000}.x, R1.x; LG2R R1.x, R1.x; MULR R1.x, {10.000000}.x, R1.x; EX2R R1.x, R1.x; MOVR R1.xyz, R1.xxxx; MULR R1.xyz, {0.900000, 0.800000, 1.000000}.xyzz, R1.xyzz; DP3R R0.x, R0.xyzz, R2.xyzz; MAXR R0.x, {0.000000}.x, R0.x; MOVR R0.xyz, R0.xxxx; ADDR R0.xyz, {0.100000, 0.100000, 0.100000}.xyzz, R0.xyzz; MULR R0.xyz, {1.000000, 0.800000, 0.800000}.xyzz, R0.xyzz; ADDR R1.xyz, R0.xyzz, R1.xyzz;... Cg float3 cspec = pow(max(0, dot(nf, H)), phongexp).xxx; float3 cplastic = Cd * (cambi + cdiff) + Cs * cspec; Shading Language (RenderMan ) color cspec = phong(nf,v,phongexp); Ci = Oi * (FinalColor = DiffuseColor * (AmbientLight + DiffuseLight)) + SpecularColor * cspec; Phong Shader

Advantages of Cg Cg greatly simplifies developing OpenGL and DirectX applications with programmable shading Cg is easier than assembly Managing parameters is simplified with Cg Adds abstraction from hardware and graphics API Cg is flexible you can use as little or as much of it as you want Cg language only API-independent libraries API-dependent libraries

Choose from Many Levels of Support Cg The shading language itself (cross-platform, multi-api) Compile to assembly and use it directly Cg Runtime Parameter management Optional specialized runtimes for OpenGL and Direct3D CgFX Shading code + render state encapsulation OpenGL and DirectX CgFX Runtime API to access CgFX files Cg Plugins Use Cg in 3ds max, Maya and Softimage XSI

Using Cg in Your Applications Simply replace your vertex and fragment shaders with equivalent Cg shaders Two options: Use Cg for development, and compile to assembly code for final product Cg compiler output is assembly code Use your preferred graphics API to load and run it Use the Cg Runtime Compiles Cg code and passes it to the GPU for you

Using the Cg Runtime The Cg Runtime helps you by: Loading programs Compiling programs Managing program parameters Managing texture units Making your programs future-proof (you can now compile them at run-time instead of compile-time) Read Using the Cg Runtime (in the Cg User s Manual)

Frequently Asked Questions About Cg To see some of the most frequent questions and answers about Cg, please visit: http://www.cgshaders.org/articles/interview_davidkir k02.php http://www.cgshaders.org/articles/interview_nvidia- jul2002.php http://www.nvidia.com/view.asp?io=cg_faq