
e07e81c7bfc34736e0eb48d04b4570f5.ppt
- Количество слайдов: 16
Teaching Cg
Real-Time Graphics Has Come a Long Way Virtua Fighter Dead or Alive 3 Dawn (SEGA Corporation) (Tecmo Corporation) (NVIDIA Corporation) NV 1 50 K triangles/sec 1 M pixel ops/sec Xbox (NV 2 A) 100 M triangles/sec 1 G pixel ops/sec Ge. Force FX (NV 30) 200 M triangles/sec 2 G pixel ops/sec 1995 2001 2003
The Motivation for Cg Graphics hardware has become increasingly more powerful Programming powerful hardware with assembly code is hard Ge. Force FX supports programs more than 1, 000 assembly instructions long Programmers need the benefits of a high-level language: language Easier programming Easier code reuse Easier debugging Assembly … DP 3 RSQ MUL MOV MUL DP 3 RSQ MUL ADD DP 3 RSQ MUL DP 3 MAX MOV LIT. . . R 0, c[11]. xyzx; R 0, R 0. x, c[11]. xyzx; R 1, c[3]; R 1, R 1. x, c[0]. xyzx; R 2, R 1. xyzx; R 2, R 2. x; R 1, R 2. x, R 1. xyzx; R 2, R 0. xyzx, R 1. xyzx; R 3, R 2. xyzx; R 3, R 3. x; R 2, R 3. x, R 2. xyzx; R 2, R 1. xyzx, R 2. xyzx; R 2, c[3]. z, R 2. x; R 2. z, c[3]. y; R 2. w, c[3]. y; R 2, R 2; float 3 c. Specular = pow(max(0, dot(Nf, H)), phong. Exp). xxx; float 3 c. Plastic = Cd * (c. Ambient + c. Diffuse) + Cs * c. Specular;
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 Direct. X 9 Cg is cross-API (Open. GL & Direct. X) and cross-platform (Windows, Direct. X Linux, and Mac OS) 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 & Cine. FX) Graphics Architect, NVIDIA Co-founder of SGI Designer of Open. GL
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
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 Open. GL / Direct. X forces students to focus on state management, not algorithms management 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 …
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 Open. GL or Direct. X, you set state for the material Direct. X 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 rendering pipeline’s limitations
Why Teach Cg? Students who learn Cg can apply their skills in a variety of situations Graphics APIs Open. GL Direct. X Operating Systems Windows Linux Mac OS Actual Screenshots of Same Shader on Different Platforms (2 of 5 on ATI Hardware) Linux Mac OS X Open. GL Direct. X 9. 0 compliant GPU Direct. X 8. 0 compliant GPU Graphics Hardware NVIDIA GPUs ATI GPUs Other GPUs that support Open. GL and Direct. X 9
Why Teach Cg? Cg is integrated with the major DCC and CAD applications 3 ds max 5 Maya 4. 5 SOFTIMAGE|XSI 3. 0 Solid. Works Digital Immersion Mental Images Rendered with Cg (Courtesy of Alias|Wavefront) Next Version of Solid. Works, Using Cg
Cg Integration in DCC Rendering Pipelines Direct Cg Code Editing and Compilation Images courtesy Alias|Wavefront, discreet, and Softimage|XSI
Comprehensive Documentation NVIDIA Cg Compiler Cg Standard Library Cg Runtime Libraries for Direct. X and Open. GL NVIDIA Cg Browser Cg Language Specification Cg User’s Manual Cg Shaders (assorted pre-written programs)
The Cg Tutorial Book
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-chapter exercises and further reading
The Cg Tutorial Book Available now, online and in bookstores Book Web site: http: //developer. nvidia. com/Cg. Tutorial/ Includes: Links to excerpts Purchasing information Software updates Teaching Resources Supplementary Material Errata
Cg in Universities and Research Universities: Harvard MIT Caltech Stanford Purdue Brown 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
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 Open. GL Programming Guide would often be) Real-time 3 D 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