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

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

Getting Started with Cg. Release 1.2 February 2004

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

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

Introduction to Shaders.

Basics of GPU-Based Programming

Cg 2.0. Mark Kilgard

Shader Programming CgFX, OpenGL 2.0. Michael Haller 2003

Advanced Computer Graphics (CS & SE ) Lecture 7

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 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

Accelerating Realism with the (NVIDIA Scene Graph)

NVIDIA Developer Tools for Graphics and PhysX

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

NVIDIA FX Composer. Developer Presentation June 2004

Shaders. Slide credit to Prof. Zwicker

1 Hardware virtualization for shading languages Group Technical Proposal

Headline in Arial Bold 30pt. Visualisation using the Grid Jeff Adie Principal Systems Engineer, SAPK July 2008

Programmable Graphics Hardware

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

EE , GPU Programming

CUDA Conference. Walter Mundt-Blum March 6th, 2008

Pipeline Integration with FX Composer. Chris Maughan NVIDIA Corporation

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

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

Introduction to Programmable GPUs CPSC 314. Introduction to GPU Programming CS314 Gordon Wetzstein, 09/03/09

Pat Hanrahan. Modern Graphics Pipeline. How Powerful are GPUs? Application. Command. Geometry. Rasterization. Fragment. Display.

NVSG NVIDIA Scene Graph

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

Sébastien Dominé, NVIDIA. CgFX

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

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

CS 179: GPU Programming

Current Trends in Computer Graphics Hardware

developer.nvidia.com The Source for GPU Programming

Mobile Graphics Ecosystem. Tom Olson OpenGL ES working group chair

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

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

Per-Pixel Lighting and Bump Mapping with the NVIDIA Shading Rasterizer

GPU Ray Tracing at the Desktop and in the Cloud. Phillip Miller, NVIDIA Ludwig von Reiche, mental images

Graphics Hardware. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 2/26/07 1

The NVIDIA Quadro Advantage. NVIDIA Professional Solutions

COMP Preliminaries Jan. 6, 2015

printf Debugging Examples

NVIDIA workstation 2D and 3D graphics adapter upgrade options let you experience productivity improvements and superior image quality

Sung-Eui Yoon ( 윤성의 )

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

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono

Distributed Virtual Reality Computation

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

NVIDIA Tools for Artists

Cg Toolkit. Cg 2.0 January 2008 Release Notes

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

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

Direct3D Rendering Cookbook Epub Gratuit

Could you make the XNA functions yourself?

Cg Toolkit. Cg 2.1 October 2008 Release Notes

Lecture 2. Shaders, GLSL and GPGPU

A Real-Time Procedural Shading System for Programmable Graphics Hardware

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

Dynamic Code Generation for Realtime Shaders

Cg Toolkit. Cg 2.1 beta August 2008 Release Notes

CSE 591: GPU Programming. Introduction. Entertainment Graphics: Virtual Realism for the Masses. Computer games need to have: Klaus Mueller

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

CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS SPRING 2016 DR. MICHAEL J. REALE

Direct3D API Issues: Instancing and Floating-point Specials. Cem Cebenoyan NVIDIA Corporation

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

Introduction. Chapter What Is Cg?

Cg Toolkit. Cg 2.0 May 2008 Release Notes

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

Graphics Hardware. Instructor Stephen J. Guy

Introduction to OpenGL

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono

GPU Architecture. Michael Doggett Department of Computer Science Lund university

CS179 GPU Programming Introduction to CUDA. Lecture originally by Luke Durant and Tamas Szalay

Using Graphics Chips for General Purpose Computation

Shaders (some slides taken from David M. course)

CONSOLE ARCHITECTURE

General Purpose Computing on Graphical Processing Units (GPGPU(

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

CIS 581 Interactive Computer Graphics (slides based on Dr. Han-Wei Shen s slides) Requirements. Reference Books. Textbook

Cg Toolkit. Cg 1.3 Release Notes. December 2004

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL

NVIDIA nfinitefx Engine: Programmable Pixel Shaders

Evolution of GPUs Chris Seitz

GPGPU, 1st Meeting Mordechai Butrashvily, CEO GASS

GpuPy: Accelerating NumPy With a GPU

Rendering Subdivision Surfaces Efficiently on the GPU

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

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

Programming Graphics Hardware

CS380: Computer Graphics Introduction. Sung-Eui Yoon ( 윤성의 ) Course URL:

Mattan Erez. The University of Texas at Austin

Shading Languages for Graphics Hardware

CS535: Interactive Computer Graphics

CIS 665: GPU Programming and Architecture. Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider

Dave Shreiner, ARM March 2009

frame buffer depth buffer stencil buffer

CREATING AND USING NORMAL MAPS - A Tutorial

Cg Toolkit. Cg 1.2 Release Notes

Transcription:

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

Real-Time Graphics Has Come a Long Way Virtua Fighter (SEGA Corporation) NV1 50K triangles/sec 1M pixel ops/sec 1995 Dead or Alive 3 (Tecmo Corporation) Xbox (NV2A) 100M triangles/sec 1G pixel ops/sec 2001 Dawn (NVIDIA Corporation) GeForce FX (NV30) 200M triangles/sec 2G pixel ops/sec 2003 Real-time graphics has progressed dramatically over the past several years. Today s consumer-level graphics boards can deliver many times the performance of million-dollar graphics workstations of a decade ago. Modern graphics processing units (GPUs) are also massively programmable, allowing the creation of a truly infinite number of new effects and algorithms. 2

The Motivation for Cg Graphics hardware has become increasingly more powerful Programming powerful hardware with assembly code is hard GeForce FX supports programs more than 1,000 assembly instructions long Programmers need the benefits of a high-level language: Easier programming Easier code reuse Easier debugging Assembly DP3 R0, c[11].xyzx, c[11].xyzx; RSQ R0, R0.x; MUL R0, R0.x, c[11].xyzx; MOV R1, c[3]; MUL R1, R1.x, c[0].xyzx; DP3 R2, R1.xyzx, R1.xyzx; RSQ R2, R2.x; MUL R1, R2.x, R1.xyzx; ADD R2, R0.xyzx, R1.xyzx; DP3 R3, R2.xyzx, R2.xyzx; RSQ R3, R3.x; MUL R2, R3.x, R2.xyzx; DP3 R2, R1.xyzx, R2.xyzx; MAX R2, c[3].z, R2.x; MOV R2.z, c[3].y; MOV R2.w, c[3].y; LIT R2, R2;... float3 cspecular = pow(max(0, dot(nf, H)), phongexp).xxx; float3 cplastic = Cd * (cambient + cdiffuse) + Cs * cspecular; Before Cg, the only way to access the programmability of recent GPUs was to write assembly code and perform complex operations to correctly configure the graphics pipeline. With recent GPUs such as the GeForce FX, programs can be thousands of instructions long, making assembly programming undesirable. With Cg, these same algorithms can be written in a high-level language, with the Cg compiler and runtime handling the task of creating assembly code suitable for the GPU. Cg offers the same advantages over GPU assembly code that C offers over CPU assembly code. Algorithms written with high-level languages are easier to express, reuse, understand, and debug. 3

The High-Level Language for Graphics Cg is an open-source high-level shading language to make graphics programming faster and easier Cg replaces assembly code with a C-like language and a compiler Cg was developed in close collaboration with Microsoft and is syntactically equivalent to HLSL, the shading language in DirectX 9 Cg is cross-api (OpenGL & DirectX) and cross-platform (Windows, Linux, and Mac OS) Cg is a key enabler of cinematic computing The biggest revolution in graphics in 10 years, and the foundation for the next 10. Kurt Akeley (on Cg & CineFX) Graphics Architect, NVIDIA Co-founder of SGI Designer of OpenGL Cg was developed in conjunction with Microsoft, and uses the same syntax and constructs as DirectX 9 s High Level Shading Language (HLSL). Cg is also fully compatible with today s OpenGL 1.4 environment and supports ARB standards, like ARB_vertex_program and ARB_fragment_program. Cg works with both OpenGL and DirectX, with a variety of major platforms (Windows, Linux, and Mac OS), and with hardware from different graphics vendors, as long as the hardware supports OpenGL or DirectX. NVIDIA also has released an open-source Cg compiler, to rapidly enable other vendors to implement Cg for their platforms. Kurt Akeley, one of the founders of SGI and creator of OpenGL, said that the combination of the CineFX architecture and Cg is the biggest revolution in graphics in 10 years, and the foundation for the next 10. He even said that not since the Reality Engine and texture mapping has there been such an advancement in graphics technology. 4

How Cg Works Shaders are created (from scratch, from a common repository, or modified from other shaders) These shaders are used for modeling in Digital Content Creation (DCC) applications or rendering in other applications The Cg compiler compiles the shaders to a variety of target platforms, including APIs, OSes, and GPUs This slide shows the workflow when using Cg. The main advantage that Cg provides is that hardware-accelerated shaders can be applied during content creation, so that DCC applications can preview objects just as they will appear in the final application. The Cg compiler can then translate the same shaders to a variety of platforms and APIs. 5

Why Teach Cg? Cg targets the right level of programmability and performance It allows students to focus on what happens at the surface of an object OpenGL / DirectX forces students to focus on state management, not algorithms Software rendering is generally not interactive Students can also use Cg to explore topics outside of graphics, such as: GPU-accelerated physics Collision detection Chemical Simulation One major reason to teach Cg is that it allows students to focus exactly on the key graphics algorithms. In particular, Cg makes it easy to focus on what happens at the surface of an object. Using just OpenGL or DirectX to teach a graphics course means that students will spend all their time on state management, while restricted to the capabilities of the fixed-function pipeline. Using a software rendered to teach a graphics course means that students will not be able to interact with their applications at real-time rates. This stifles their creativity, because programming is really an iterative process of discovery and development. 6

Why Teach Cg? Let s look at a simple example: basic diffuse lighting The N dot L calculation is the key computer graphics concept being taught With OpenGL or DirectX, you set state for the material and light colors, but then the GPU calculates N dot L invisibly for you With Cg, you get to write the shader that performs the N dot L calculation Cg also allows you to escape the fixed-function function rendering pipeline s limitations As a simple example, take diffuse lighting. If you were to use OpenGL or DirectX to teach this concept, your students would make a series of function calls to get the material and light properties. The API would then transparently calculate N dot L for them, when in fact this is the key concept that you want to teach. With Cg, your students can now have complete control of what happens at the surface. After implementing the basic N dot L calculation, they can easily extend it to more advanced models. This ability to extend the model is not available with the fixed-function pipeline. 7

Why Teach Cg? Students who learn Cg can apply their skills in a variety of situations Graphics APIs OpenGL DirectX Operating Systems Windows Linux Mac OS Graphics Hardware NVIDIA GPUs ATI GPUs Actual Screenshots of Same Shader on Different Platforms (2 of 5 on ATI Hardware) OpenGL Other GPUs that support OpenGL and DirectX 9 Mac OS X Linux DirectX 9.0 compliant GPU DirectX 8.0 compliant GPU Cg is a highly transferable skill. Students who are proficient in Cg will be able to leverage their skills in a wide range of scenarios (different graphics APIs, operating systems, and graphics hardware). The figure in this slide shows a thin film shader running on several combinations of platform/api/gpu. 8

Why Teach Cg? Cg is integrated with the major DCC and CAD applications 3ds max 5 Maya 4.5 SOFTIMAGE XSI 3.0 SolidWorks Digital Immersion Mental Images Rendered with Cg (Courtesy of Alias Wavefront) Next Version of SolidWorks, Using Cg Cg is also integrated into a number of major DCC and CAD applications. Understanding Cg and hardware shading will make students more capable in industry. 9

Cg Integration in DCC Rendering Pipelines Direct Cg Code Editing and Compilation Images courtesy Alias Wavefront, discreet, and Softimage XSI This slide shows Cg s integration with the three major DCC applications. Top Left: CgFX integrated with Maya s hypershade a node-based shader editor. Sliders control key real-time parameters (for example, bump depth). Top Right: The CgFX Viewport manager enables the use of real-time shaders in 3ds max 5. Bottom: Cg integration in Softimage XSI s Render Tree allows direct Cg code editing and compilation. Net View also contains help, samples, and documentation. 10

Comprehensive Documentation NVIDIA Cg Compiler Cg Standard Library Cg Runtime Libraries for DirectX and OpenGL NVIDIA Cg Browser Cg Language Specification Cg User s Manual Cg Shaders (assorted pre-written programs) The Cg toolkit comes with comprehensive documentation, including a complete User s Manual that is available electronically and in hardcopy. It also comes with several sample shaders to learn from. 11

The Cg Tutorial Book The Cg Tutorial book is an ideal resource for teaching Cg. 12

The Cg Tutorial Book The first book about hardware shading to: Discuss graphics concepts thoroughly Provide complete examples Provide a complete hands-on framework to try and modify the examples, out-of-thebox Includes end-of of-chapter exercises and further reading The Cg Tutorial is the first book about real-time hardware shading to combine theoretical discussion with a clear hands-on approach. The book is geared towards courses, with end-of-chapter exercises to try out, and further reading for topics of interest. The book also comes with a complete hands-on framework (a standalone application) that allows students to try the various examples in the book, even if they don t already know OpenGL, DirectX, or even C/C++. 13

The Cg Tutorial Book Available now, online and in bookstores Book Web site: http://developer.nvidia.com/cgtutorial/ Includes: Links to excerpts Purchasing information Software updates Teaching Resources Supplementary Material Errata The Cg Tutorial is now available online and in bookstores around the United States. The book s Web site, http://developer.nvidia.com/cgtutorial, contains a wealth of information about the book, as well as related resources. You can order the book from Addison-Wesley at the link indicated, or you can find it at other sites, such as Amazon.com and BarnesandNoble.com. The URL indicated also contains sample material from the book. 14

Cg in Universities and Research Universities: Harvard MIT Caltech Stanford Purdue Brown University University of Illinois University of Texas, Austin University of North Carolina Utah Government Labs: NCSA Sandia Cg is a great tool for developing hardware accelerated graphics software for applications such as procedural modeling, simulating natural phenomena, exploring interactive advanced shading and rendering, and visualizing scientific and medical data. Dr. David S. Ebert Purdue University Several notable universities and government labs are currently involved with Cg. 15

Fitting Cg into a Course Curriculum Cg is appropriate for introductory or advanced graphics courses Introductory courses can use The Cg Tutorial as a primary textbook, or as a textbook for a segment of the course about Real-Time Graphics Advanced courses can use Cg as the language to experiment in, with The Cg Tutorial as a supplementary textbook (much like the OpenGL Programming Guide would often be) Real-time 3D graphics courses will probably focus on Cg, and The Cg Tutorial will be an ideal textbook for these The Cg Tutorial fits well as a core or supplementary textbook The complete software framework is a great base to build assignments on Because of Cg s cross-platform nature and industry support, it s appropriate to teach in a wide variety of situations. In some cases, it may be best suited as an optional textbook, while in other cases, it may be a primary resource. The standalone software framework that accompanies the book allows students to try and modify the examples that come with the book, without writing any C, C++, OpenGL, or DirectX code. This software is regularly updated and available on the book s Web site. 16