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

Similar documents
Programming shaders & GPUs Christian Miller CS Fall 2011

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

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

Introduction to Shaders.

OPENGL RENDERING PIPELINE

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

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Shaders. Slide credit to Prof. Zwicker

12.2 Programmable Graphics Hardware

Programmable Graphics Hardware

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

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

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

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

The Transition from RenderMan to the OpenGL Shading Language (GLSL)

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

CSE 167: Introduction to Computer Graphics Lecture #13: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Programmable Graphics Hardware

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

Supplement to Lecture 22

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

Levy: Constraint Texture Mapping, SIGGRAPH, CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon

Introduction to the OpenGL Shading Language

Introduction to Programmable GPUs CPSC 314. Real Time Graphics

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

Lecture 2. Shaders, GLSL and GPGPU

CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL

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

OpenGL Programmable Shaders

Introduction to Shaders for Visualization. The Basic Computer Graphics Pipeline

Introduction to the OpenGL Shading Language (GLSL)

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

Shaders. Introduction. OpenGL Grows via Extensions. OpenGL Extensions. OpenGL 2.0 Added Shaders. Shaders Enable Many New Effects

The Basic Computer Graphics Pipeline, OpenGL-style. Introduction to the OpenGL Shading Language (GLSL)

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

Programmable shader. Hanyang University

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

Graphics Hardware. Instructor Stephen J. Guy

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

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

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

COMP371 COMPUTER GRAPHICS

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

The Graphics Pipeline

CS427 Multicore Architecture and Parallel Computing

Spring 2009 Prof. Hyesoon Kim

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

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

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

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

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

The Graphics Pipeline

Rendering Objects. Need to transform all geometry then

Mobile Application Programing: Android. OpenGL Operation

Sign up for crits! Announcments

Spring 2011 Prof. Hyesoon Kim

The Graphics Pipeline

GLSL v1.20. Scott MacHaffie Schrödinger, Inc.

2.11 Particle Systems

Could you make the XNA functions yourself?

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

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

CS451Real-time Rendering Pipeline

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

GPU Programming EE Final Examination

LSU EE Homework 5 Solution Due: 27 November 2017

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

Evolution of GPUs Chris Seitz

Shader Programming 1. Examples. Vertex displacement mapping. Daniel Wesslén 1. Post-processing, animated procedural textures

Computer graphics 2: Graduate seminar in computational aesthetics

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

GPU Programming EE Final Examination

GLSL 1: Basics. J.Tumblin-Modified SLIDES from:

Rasterization Overview

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

BCA611 Video Oyunları için 3B Grafik

Best practices for effective OpenGL programming. Dan Omachi OpenGL Development Engineer

Zeyang Li Carnegie Mellon University

Mobile Application Programing: Android. OpenGL Operation

Lecture 09: Shaders (Part 1)

Lab 9 - Metal and Glass

CS 432 Interactive Computer Graphics

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

GPU Programming EE Midterm Examination

Some advantages come from the limited environment! No classes. Stranight ans simple code. Remarkably. Avoids most of the bad things with C/C++.

Sung-Eui Yoon ( 윤성의 )

GPU Memory Model. Adapted from:

Ciril Bohak. - INTRODUCTION TO WEBGL

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

1 of 5 9/10/ :11 PM

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

GpuPy: Accelerating NumPy With a GPU

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

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

The Rasterization Pipeline

Transcription:

Programmable GPUs Real Time Graphics Virtua Fighter 1995 (SEGA Corporation) NV1 Dead or Alive 3 2001 (Tecmo Corporation) Xbox (NV2A) Nalu 2004 (NVIDIA Corporation) GeForce 6 Human Head 2006 (NVIDIA Corporation) GeForce 7 Medusa 2008 (NVIDIA Corporation) GeForce GTX 200 Real-Time Dynamic Fracture 2013 (NVIDIA Corporation) GeForce GTX 700 1

[courtesy NVIDIA] [courtesy NVIDIA] 11/13/2013 GPUs vs CPUs 4500 GFLOPS vs ~500 GFLOPS GPUs vs CPUs 290 GB/s vs 60 GB/s 2

Programmable Pipeline so far: rendering pipeline = set of stages with fixed functionality Geometry Database Model/View Transform. Lighting Perspective Transform. Clipping Scan Conversion Texturing Depth Test Blending Framebuffer Programmable Pipeline now: programmable rendering pipeline! vertex shader Geometry Database Model/View Transform. Lighting Perspective Transform. Clipping Scan Conversion Texturing Depth Test Blending Framebuffer fragment shader 3

Vertex Shader Run once for every vertex in your scene: Common Functionality: Performs viewing transforms (MVP) Transforms texture coordinates Calculates per-vertex lighting A vertex is a malleable definition, you can pass in, and perform pretty much any operation you want Vertex Shader Common Inputs: vertex position Normal texture coordinate(s) Modelview and projection matrix Vertex Material or color Light sources color, position, direction etc. Common Outputs: Clip-space vertex position (mandatory) transformed texture coordinates vertex color 4

Vertex Shader - Applications deformable surfaces on the fly vertex position computation e.g. skinning [courtesy NVIDIA] Fragment Shader Runs for all initialized fragments: initialized rendered to after rasterization Common Tasks: texture mapping Shading Synonymous with Pixel Shader 5

Fragment Shader input (interpolated over primitives by rasterizer): Fragment coordinates (mandatory) texture coordinates color output: fragment color (mandatory) fragment depth Fragment Shader - Applications Not really shaders, but very similar to NPR! A Scanner Darkly, Warner Independent Pictures GPU raytracing, NVIDIA 6

Vertex & Fragment Shader massively parallel computing by parallelization same shader is applied to all data (vertices or fragments) SIMD (single instruction multiple data) parallel programming issues: main advantage: high performance main disadvantage: no access to neighboring vertices/fragments Shader Languages Many languages exist to write shaders: GLSL GL Shading Language (Opengl) HLSL High Level Shading Language (Direct3D) CG (Nvidia mid-level language for both) 7

GLSL We are using GLSL: C-like programming language for GPUs Highly Parallel (SIMD) Differs greatly between versions GLSL Integration into Opengl http://zach.in.tu-clausthal.de/teaching/cg_literatur/glsl_tutorial/ http://www.arcsynthesis.org/gltut/positioning/ubocontextbinding.svg 8

GLSL - Types Has all the basic C types Has vector types: vec2, vec3, vec4 Has matrix types: mat2, mat3, mat4 Has sampler types Used for reading data from textures and framebuffers (might be worthwhile looking into for Assignment 4) Look at these links for more info: http://www.opengl.org/wiki/data_type_%28glsl%29 http://www.opengl.org/wiki/sampler_%28glsl%29#sampler_types GLSL Built in Variables GLSL has some variables built in These variables are always there and accessible in the corresponding shader Vertex Shader In: gl_vertex (position), gl_normal, gl_color Out: gl_position Fragment Shader In: glfragcoord (fragment location), gl_color Out: gl_fragcolor, gl_fragdepth 9

http://web.media.mit.edu/~gordonw/opengl/images/teapot_vertexshader.jpg 11/13/2013 GLSL Built in Variables Accessible in all shaders: gl_modelviewmatrix gl_modelviewprojectionmatrix gl_projectionmatrix Here is a quick reference guide: http://mew.cx/glsl_quickref.pdf GLSL Example Vertex Shader Vertex Shader: scale vertices #version 200 void main( ) { // scale passed in vertex vec4 a = gl_vertex; a.x = a.x * 1.5; a.y = a.y * 1.5; // transform vertex gl_position = gl_modelviewprojectionmatrix * a; } 10

http://www.opengl.org/sdk/docs/tutorials/clockworkcoders/loading.php 11/13/2013 GLSL Example Fragment Shader Fragment Shader: color green #version 200 void main( ) { // color rendered fragments green gl_fragcolor = vec4(0.0, 1.0, 0.0, 1.0); } GLSL Uniform Variables Used to access data from the CPU on the GPU Need to be given a value from the opengl side 11

GLSL Example Uniform Variables http://www.lighthouse3d.com/tutorials/glsl-tutorial/uniform-variables/ GLSL Example Uniform Variables Within shader: #version 200 uniform float specintensity; uniform vec4 speccolor; uniform float t; uniform vec4 colors; void main( ) { // do something } 12

GLSL Samplers A type of uniform used to read from a texture within shaders There are different samplers for the different types of textures 2D textures store square textures Rectangle textures store non-square textures, such as the image being processed in A4 OpenGL Error Checking When Things go Wrong: Opengl wont tell you To ask, call glgeterror() Tells you the gl state (ok, error, etc) For A4, this is all done for you, but you will need to break before the end of the program to read the output (in the black terminal) 13

OpenGL the old and the new GL 1.2 2.1 GL 3.0 4.4 Vertex Shader Vertex Shader Pixel Shader Tessellation (Control) Shader Tessellation Evaluation/Hull Shader Geometry Shader Fragment Shader... Compute Shader OpenGL updated graphics pipeline 14

OpenGL 3.0+ changes Removed many of the GLSL built in variables Removed GLSL/Opengl built in matrices Removed glvertex(), glcolor, gltexcoord, glmaterial(), OpenGL 3.0+ changes Why? Efficiency in most cases you don't need everything lots of computation wasted checking what applies Control with less dictated, shaders can be used to do more 15

OpenGL 3.0+ Advanced Pipeline Tesselaton Control shader Synonymous with Tesselation shader (d3d Subdivide geometry based on vertices Tesselation Evaluation Synonymous with Hull shader (d3d) Rearrange new vertices from tesselation control OpenGL 3.0+ Advanced Pipeline Geometry Shaders Perform operations on groups of vertices Compute Shaders Use the GPU to do math for you (no rendering) This executes after the geometry shader, replacing the rest of the pipeline 16

GPGPU Applications [courtesy NVIDIA] References and Resources http://www.opengl.org/wiki/uniform_%28glsl%29 http://www.lighthouse3d.com/tutorials/glsl-tutorial/uniform-variables/ http://www.opengl.org/wiki/rendering_pipeline_overview http://www.davidcornette.com/glsl/glsl.html http://nehe.gamedev.net/article/glsl%20an%20introduction/25007/ http://www.opengl.org/wiki/data_type_%28glsl%29 http://www.opengl.org/wiki/sampler_%28glsl%29#sampler_types http://zach.in.tu-clausthal.de/teaching/cg_literatur/glsl_tutorial/ 17