SGI OpenGL Shader. Marc Olano SGI

Similar documents
Chapter 1 Introduction. Marc Olano

Hardware Shading: State-of-the-Art and Future Challenges

Complex Shading Algorithms

Advanced Shading and Texturing

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

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

Optimizing DirectX Graphics. Richard Huddy European Developer Relations Manager

Evolution of GPUs Chris Seitz

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Shaders. Slide credit to Prof. Zwicker

Introduction to the OpenGL Shading Language

Deferred Rendering Due: Wednesday November 15 at 10pm

CS 130 Final. Fall 2015

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

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

Textures. Texture coordinates. Introduce one more component to geometry

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Lecture 2. Shaders, GLSL and GPGPU

RSX Best Practices. Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog

Computergrafik. Matthias Zwicker. Herbst 2010

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


A Real-Time Procedural Shading System for Programmable Graphics Hardware

Lab 9 - Metal and Glass

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

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

Interactive Shading Language (ISL) Language Description April 6, 2000

Computer Graphics Coursework 1

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

GPU Memory Model. Adapted from:

Rendering Objects. Need to transform all geometry then

CHAPTER 1 Graphics Systems and Models 3

The Rasterization Pipeline

NVIDIA nfinitefx Engine: Programmable Pixel Shaders

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

Announcements. Written Assignment 2 is out see the web page. Computer Graphics

1.2.3 The Graphics Hardware Pipeline

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

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

Efficient GPU Rendering of Subdivision Surfaces. Tim Foley,

Graphics Processing Unit Architecture (GPU Arch)

Render all data necessary into textures Process textures to calculate final image

Advanced Rendering & Shading

Anselmo Lastra, Steve Molnar, Marc Olano, Yulan Wang. Marc Olano, Yulan Wang University of North Carolina at Chapel Hill

Interactive Methods in Scientific Visualization

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Computer Graphics (CS 543) Lecture 10: Normal Maps, Parametrization, Tone Mapping

Optimal Shaders Using High-Level Languages

Lecture 10: Part 1: Discussion of SIMT Abstraction Part 2: Introduction to Shading

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Canonical Shaders for Optimal Performance. Sébastien Dominé Manager of Developer Technology Tools

Technical Report. Anisotropic Lighting using HLSL

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Render-To-Texture Caching. D. Sim Dietrich Jr.

Towards Interactive Bump Mapping with Anisotropic Shift-Variant BRDFs

Wednesday, July 24, 13

Programming Graphics Hardware

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

Game Technology. Lecture Physically Based Rendering. Dipl-Inform. Robert Konrad Polona Caserman, M.Sc.

Module 13C: Using The 3D Graphics APIs OpenGL ES

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Pipeline Operations. CS 4620 Lecture 14

Windowing System on a 3D Pipeline. February 2005

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

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

The Rasterization Pipeline

CS 4620 Program 3: Pipeline

Computer Graphics. Shadows

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

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

Local Illumination physics. Law of reflection and Snell s law of refraction

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

CS GAME PROGRAMMING Question bank

Shading and Texturing Due: Friday, Feb 17 at 6:00pm

Drawing a Crowd. David Gosselin Pedro V. Sander Jason L. Mitchell. 3D Application Research Group ATI Research

AGDC Per-Pixel Shading. Sim Dietrich

Filtering Cubemaps Angular Extent Filtering and Edge Seam Fixup Methods

Appearance-Preserving Simplification

Primitive processing and advanced shading architecture for embedded space. Digital Media Professionals, Inc

Shading Languages for Graphics Hardware

The Pixel-Planes Family of Graphics Architectures

OpenGL Status - November 2013 G-Truc Creation

Physically Based Shading in Unity. Aras Pranckevičius Rendering Dude

OPENGL RENDERING PIPELINE

Chapter 1. Introduction Marc Olano

The Making of Seemore WebGL. Will Eastcott, CEO, PlayCanvas

Virtual Reality for Human Computer Interaction

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

The Graphics Pipeline

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

Computer Graphics with OpenGL ES (J. Han) Chapter XI Normal Mapping

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

Introduction to Shaders.

Comparing Reyes and OpenGL on a Stream Architecture

CS 450: COMPUTER GRAPHICS TEXTURE MAPPING SPRING 2015 DR. MICHAEL J. REALE

Computer Graphics (CS 543) Lecture 8 (Part 1): Physically-Based Lighting Models

Transcription:

SGI OpenGL Shader Marc Olano SGI

Interactive Rendering Illusion of Presence 10 30 60 frames per second Immediate response Simple appearance

Multi-pass Rendering Improved appearance Build effects Per-frame or per-object Still interactive [Diefenbach97] [Peercy97] [Cabral99] [Kautz99]

What s in a Pass? Graphics hardware (as seen through OpenGL) application vertex operations pixel operations rasterize texture fragment operations frame buffer

Rendering Passes application vertex operations pixel operations rasterize texture application fragment operations frame buffer application vertex operations pixel operations vertex operations pixel operations rasterize texture rasterize texture fragment operations application frame buffer fragment operations application frame buffer vertex operations pixel operations vertex operations pixel operations rasterize texture rasterize texture fragment operations frame buffer fragment operations frame buffer

Multi-Pass = SIMD Single Instruction, Multiple Data Classic SIMD Thousands/millions of processors Thinking Machines, PixelFlow,... Not small-scale SIMD (MMX, etc.) Shading languages use SIMD model Describe shading for one point Apply for every point on surface

Multi-Pass = SIMD General SIMD Shared Control Processor Array Per-PE ALU Per-PE Memory Per-PE Conditionals OpenGL Application Pixel Array Fragment ops FB / Texture Alpha / Stencil

What s it Mean? We can create a compiler High-level language in OpenGL out

Isn t That Slow? No! Like drawing a few extra objects Optimize to compress passes Target hardware extensions

OpenGL Shader ISL OpenGL Shader Plain OpenGL IR extensions NV extensions Other extensions

About ISL Things exposed in ISL Pass count: passes <= statements Optimize to fewer Range: clamped 0 1 Texturing limits No per-pixel computed texture coordinates Can use per-vertex texture coordinates

Example 1 Shiny Bump Map Dependent texturing? ISL lookup function

Lookup-base Environment ISL s run anywhere philosophy 1D environment Internally, same as texture lookup

Procedural Environment Can build with ISL code repeat(h) { // Fresnel component uniform float f = fresnel(2*i/(n-1) 1, refract); } // color spline for ground groundsky[i] = spline(i/(h-1),{ color(.3,.6,.1,f), color(.3,.6,.1,f), color(.6,.6,.1,f), color(.4,.7,.1,f), color(.4,.4,.1,f), color(.3,.3,.1,f)}); i = i+1;

Procedural Environment And the sky... repeat(h) { // Fresnel component uniform float f = fresnel(2*i/(n-1) 1, refract); } // color spline for ground groundsky[i] = spline((i-h)/(h-1),{ color(1.,1.,1.,f), color(1.,1.,1.,f), color(.3,.7,.9,f), color(.3,.7,.9,f), color(.3,.7,.9,f), color(.3,.7,.9,f)}); i = i+1;

Bump Map Makes smooth surface appear bumpy Several choices Evaluate bump math per-fragment Embossed bumps Normal map

Normal Map Normal range 1 to 1 Color range 0 to 1 Normal map is just a texture R =.5 N X +.5 G =.5 N Y +.5 B =.5 N Z +.5

Bumped Normal Map Perturb in tangent directions + renormalize

Scale & Transform Normal // rescale normal vectors from 0..1 to -1..1 and back uniform matrix nscale = translate(-.5,-.5,-.5) *scale(2,2,2); uniform matrix nunscale = scale(.5,.5,.5) *translate(.5,.5,.5); // transform -1..1 normal from object to world space parameter matrix nm = inverse(affine(shadermatrix)); // set rgb to y (vertical) component and alpha to z // so one lookup can do both environment map and Fresnel uniform matrix gggb = matrix(0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0);

Actual shading code FB = texture(nmap); FB = transform(nscale * nm * nunscale * gggb); FB = lookup(groundsky);

Demo

Example 2 Homomorphic BRDF Factorization

Factorization V N H L

Factored Textures L Shadowing N Microfacet V Masking

The Shader surface BRDF( uniform string brdfp = "brdf p.rgb"; uniform string brdfq = "brdf q.rgb"; uniform color brdfc = color(1,1,1,1)) { FB = diffuse(); FB *= texture(brdfp, 1, 1); FB *= texture(brdfq, 1, 2); FB *= texture(brdfp, 1, 3); FB *= brdfc; }

Texture Coordinates texture( texture, matrix, texcoord_set) Passed to application draw callback Per-vertex application code Vertex programs OpenGL Shader 3.0 includes vertex program emulation

Demo Homomorphic BRDF Factorization

Example 3 Parameterized Wood

Need Some Bands Start with a simple ramp project("wave.bw", inverse(shadermatrix)* ringcenterxlate* ringaxisrotate* ringscale* texturecenterxlate);

Turn into Rings if (FB[0] < lighttodark) FB = darkwood; else FB = lightwood;

Differing Specular FB = diffuse(); varying color dif=fb; FB = environment("highlight.bw"); varying color spec=fb; if (FB[0] < lighttodark) { FB = darkwood; FB *= dif; varying color a = FB; } FB = darkgloss; FB *= spec; FB += a;

Turbulent Rings FB = project( turbulence.bw,...); FB *= ringnoisescale; FB += project( wave.bw,...);

Fine Grain FB = darkgloss; FB.a = project( noise.bw,...); FB = over(darkgraingloss); FB *= spec; FB += a;

Demo

Bonus Example Level-of-detail Shaders

Level-of-detail Shaders Add conditionals to adjust complexity Distance Importance Time Available texture

Level-of-detail Automatic Add conditionals Change hardware mapping rules in each branch Semi-automatic Use LOD building blocks Manual Add conditionals Hand-code levels

Demo