Fragment level programmability in OpenGL Evan Hart

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS SOFTWARE.
Advertisements

Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems.
DirectX 8 and GeForce3 Christian Schär & Sacha Saxer.
Mali Instruction Set Architecture
Normal Map Compression with ATI 3Dc™ Jonathan Zarge ATI Research Inc.
Frame Buffer Postprocessing Effects in DOUBLE-S.T.E.A.L (Wreckless)
SPIM and MIPS programming
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
Shading Languages GeForce3, DirectX 8 Michael Oswald.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Chapter.
Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
Status – Week 277 Victor Moya.
GPU Simulator Victor Moya. Summary Rendering pipeline for 3D graphics. Rendering pipeline for 3D graphics. Graphic Processors. Graphic Processors. GPU.
Status – Week 276 Victor Moya. Hardware Pipeline Command Processor. Command Processor. Vertex Shader. Vertex Shader. Rasterization. Rasterization. Pixel.
ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL.
Status – Week 279 Victor Moya. Rasterization Setup triangles (calculate slope values). Setup triangles (calculate slope values). Fill triangle: Interpolate.
Status – Week 283 Victor Moya. 3D Graphics Pipeline Akeley & Hanrahan course. Akeley & Hanrahan course. Fixed vs Programmable. Fixed vs Programmable.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
Status – Week 281 Victor Moya. Objectives Research in future GPUs for 3D graphics. Research in future GPUs for 3D graphics. Simulate current and future.
Introduction to OpenGL. What is OpenGL OpenGL is a low-level software interface to graphics hardware No commands for performing windowing tasks or obtaining.
Compilation, Architectural Support, and Evaluation of SIMD Graphics Pipeline Programs on a General-Purpose CPU Mauricio Breternitz Jr, Herbert Hum, Sanjeev.
Status – Week 260 Victor Moya. Summary shSim. shSim. GPU design. GPU design. Future Work. Future Work. Rumors and News. Rumors and News. Imagine. Imagine.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Using Vertex Shader in DirectX 8.1 강 신 진
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Blending, Modern Hardware.
General-Purpose Computation on Graphics Hardware Adapted from: David Luebke (University of Virginia) and NVIDIA.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
A User-Programmable Vertex Engine Erik Lindholm Mark Kilgard Henry Moreton NVIDIA Corporation Presented by Han-Wei Shen.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
David Luebke 1 1/25/2016 Programmable Graphics Hardware.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
Pixel Shader  Based on nVIDIA’s GF3/4 architecture  Texture shader + register combiner texture unit 0texture program texture unit 1texture program texture.
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
Reflective Shadow Mapping By: Mitchell Allen.
Programmable Pipelines
The Graphic PipeLine
Graphics Processing Unit
Important stuff that doesn’t fit elsewhere Evan Hart
Chapter 6 GPU, Shaders, and Shading Languages
Introduction to Programmable Hardware
Graphics Processing Unit
Where does the Vertex Engine fit?
Last Time Presentation of your game and idea Environment mapping
Programming with OpenGL Part 3: Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
CS 480/680 Computer Graphics GLSL Overview.
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

Fragment level programmability in OpenGL Evan Hart ehart@ati.com ARB Fragment Program Fragment level programmability in OpenGL Evan Hart ehart@ati.com

Plan of Action What is it How does it work What is it good for

Introduction to ARB FP New standardized programming model What it replaces What it does not replace

Standardized Fragment Programmability ARB standard for fragment-level programmability Derived from ARB_vertex_program Point out standardization and and level of HW supported

Replaces Multitexture Pipe Texture blending Color Sum Fog Subsumes texture enables texture target priorities Discuss standard GL texture ops

Fragment Processing Pipe setup rasterizer User-defined Fragment Processing Texture Fetch and Application Color Sum Fog frame-buffer ops

Preserves Backend Operations Coverage application Alpha Test Stencil and depth test Blending

Programming Model ASM based similar to ARB_vertex_program Rich SIMD instruction set Requires resource management Texture accesses Interpolators Temporaries Constants

Similar to ARB_vertex_program Assembly syntax Same basic grammar rules Ops are upper case Statements terminated by semicolons Comments begin with #

Fragment Program Machine Program Environment Parameters Program Local Parameters Attributes Fragment Program Address Variables Temporary Variables Result Registers

Large Instruction Set Three basic categories Component swizzling Scalar (single value) operations Vector operations Texture operations Component swizzling Component masking

Scalar Instructions COS – cosine EX2 – base 2 exponential LG2 – base 2 logarithm RCP – reciprocal RSQ – reciprocal square root SIN – sine SCS – sine and cosine POW – power

New Scalar Instructions COS – cosine SIN – sine SCS – sine and cosine

Removed Scalar Instructions EXP – Partial Precision EX2 LOG – Partial Precision LG2

Vector Instructions Standard Arithmetic Special purpose vector

Standard Arithmetic Ops ABS – absolute value FLR – floor FRC – fraction component SUB – subtract XPD – cross product CMP – compare LRP – linearly interpolate MAD – multiply accumulate MOV – move ADD – add DP3 – three component dot product DP4 – four component dot product

Special Vector Ops LIT – compute lighting DPH – homogeneous dot product DST – compute distance vector

New Instructions LRP – Linearly Interpolate CMP - Compare

Texture Instructions TEX TXP TXB KIL

Standard Texture Fetch TEX <dest>, <src>, texture[n], <type>; Does not divide by q

Extended Texture Fetches TXP Same syntax as TEX Divides first three components by the fourth TXB Adds the fourth component to the computed LOD

Killing pixels KIL instruction Terminates shader program if any component is less than 0

Resource Categories in ARB FP Temporaries Textures Attributes Parameters Instructions Texture Instructions Arithmetic Instructions

Identifying Limits Standard Resource limits Texture Indirections Number of temps etc Texture Indirections

Using Fragment Program API Simple shaders Complex shaders

Simple API Loading programs Setting Parameters Making active

Shared API glGenProgramsARB( num, id ); glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, id ); glProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, length, string );

Simple shaders Pre-programmable functionality Texture * color

Simple Shader Example !!ARBfp1.0 TEMP temp; #temporary ATTRIB tex0 = fragment.texcoord[0]; ATTRIB col0 = fragment.color; PARAM pink = { 1.0, 0.4, 0.4, 1.0}; OUTPUT out = result.color; TEX temp, tex0, texture[0], 2D; #Fetch texture MOV out, temp; #replace #MUL out, col0, temp; #modulate #MUL out, temp, pink; #modulate with constant color

Complex Shaders Lighting Procedural

Phong Lighting #compute half angle vector ADD spec.rgb, view, lVec; DP3 spec.a, spec, spec; RSQ spec.a, spec.a; MUL spec.rgb, spec, spec.a; #compute specular intensisty DP3_SAT spec.a, spec, tmp; LG2 spec.a, spec.a; MUL spec.a, spec.a, const.w; EX2 spec.a, spec.a; #compute diffuse illum DP3_SAT dif, tmp, lVec; ADD_SAT dif.rgb, dif, const;

Procedural Bricks #Apply the stagger MUL r2.w, r0.y, half; FRC r2.w, r2.w; SGE r2.w, half, r2.w; MAD r0.x, r2.w, half, r0.x; #determine whether it is brick or mortar FRC r0.xy, r0; SGE r2.xy, freq, r0; SUB r3.xy, 1.0, freq; SGE r0.xy, r3, r0; SUB r0.xy, r2, r0; MUL r0.w, r0.x, r0.y;

Caveats Remember the difference between {3.0} 3.0 Ensure Continuity at Boundaries Needed to compute LOD Programs under limits may not load

Wrap up Fragment Program is the Standard for Fragment Programmability Assembly Language Shaders Enhances Pixel Level Effects

Questions? ehart@ati.com