Advanced Rendering & Shading

Similar documents
Shader Programming CgFX, OpenGL 2.0. Michael Haller 2003

CS GPU and GPGPU Programming Lecture 3: GPU Architecture 2. Markus Hadwiger, KAUST

Shaders (some slides taken from David M. course)

Sébastien Dominé, NVIDIA. CgFX

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

CS451Real-time Rendering Pipeline

Shaders in Eve Online Páll Ragnar Pálsson

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

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

CS GPU and GPGPU Programming Lecture 3: GPU Architecture 2. Markus Hadwiger, KAUST

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

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

Creating Real Shaders in FX Composer. Kevin Bjorke NVIDIA Corporation

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

Whitepaper. Using SAS with CgFX and FX file formats. Kevin Bjorke

Introduction to Shaders.

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

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

Evolution of GPUs Chris Seitz

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

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

3D Rasterization II COS 426

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

Zeyang Li Carnegie Mellon University

Graphics Hardware. Instructor Stephen J. Guy

Basics of GPU-Based Programming

Optimal Shaders Using High-Level Languages


High-Precision Shading and Geometry. Kevin Bjorke NVIDIA Corporation

CS 464 Review. Review of Computer Graphics for Final Exam

COMP371 COMPUTER GRAPHICS

Programming Graphics Hardware

Pipeline Integration with FX Composer. Chris Maughan NVIDIA Corporation

SGI OpenGL Shader. Marc Olano SGI

DirectX Programming #4. Kang, Seongtae Computer Graphics, 2009 Spring

Mattan Erez. The University of Texas at Austin

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

Shaders Part II. Traditional Rendering Pipeline

Could you make the XNA functions yourself?

Whitepaper. Using SAS with CgFX and FX file formats. Kevin Bjorke

lecture 18 - ray tracing - environment mapping - refraction

The Rasterization Pipeline

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

Deferred Rendering Due: Wednesday November 15 at 10pm

Point-Based rendering on GPU hardware. Advanced Computer Graphics 2008

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

Complex Shading Algorithms

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

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

Performance Tools. Raul Aguaviva, Sim Dietrich, and Sébastien Dominé

Technical Report. Mesh Instancing

NVIDIA Tools for Artists

CS 130 Final. Fall 2015

Rendering Objects. Need to transform all geometry then

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

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

FX Composer 1.5. Chris Maughan

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

Direct Rendering of Trimmed NURBS Surfaces

Forward rendering. Unity 5's rendering paths. Which lights get what treatment?

It s All Done with Mirrors. GPU Gems Showcase Kevin Bjorke, NVIDIA GDC2004

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

CPSC / Texture Mapping

Spring 2009 Prof. Hyesoon Kim

OpenGL shaders and programming models that provide object persistence

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

Spring 2011 Prof. Hyesoon Kim

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

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

Programming Graphics Hardware. GPU Applications. Randy Fernando, Cyril Zeller

CS 4620 Program 3: Pipeline

NVIDIA FX Composer. Developer Presentation June 2004

Learn the fundamentals of shader writing in unity in this complete tutorial series.

THE AUSTRALIAN NATIONAL UNIVERSITY Final Examinations(Semester 2) COMP4610/COMP6461 (Computer Graphics) Final Exam

Technical Report. Anisotropic Lighting using HLSL

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

CHAPTER 1 Graphics Systems and Models 3

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

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

Hardware-Assisted Relief Texture Mapping

Illumination and Shading

Lecture 10: Shading Languages. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

Rippling Reflective and Refractive Water

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Cg 2.0. Mark Kilgard

Introduction to Programmable GPUs CPSC 314. Real Time Graphics

Visualisatie BMT. Rendering. Arjan Kok

Computer Graphics Coursework 1

User Guide. DU _v04 April 2005

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Pump Up Your Pipeline

CS 354R: Computer Game Technology

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Game Graphics Programmers

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

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

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

Graphics and Interaction Rendering pipeline & object modelling

Transcription:

Advanced Rendering & Shading Seminar 3 Advanced Rendering and Shading

Pluto Computer room with NVidia 6600 graphics cards All remaining assignment examination slots are in this room Advanced Rendering and Shading 2

Preparations fxfiles.zip available for download from course web page Create effects folder and unpack into it FX Composer User Guide Introduction to the DirectX High-Level Shading Language Work at home: Use FX Composer 1.8! Advanced Rendering and Shading 3

FXComposer UI panels Advanced Rendering and Shading 4

FX Composer Editor for materials expressed in shader language Materials stored in effect files (.fx) Semantics & Annotations Tweakables Shader code (vertex and pixel) Techniques Advanced Rendering and Shading 5

FX Composer how to Create fxcomposer project Create new material (effect) Tweak an effect Add scene object Edit scene object properties Advanced Rendering and Shading 6

FXComposer configuration Not necessary for assignment! But nice to know FXComposer manual page 27 fxcomposer_config.xml standard materials fxmapping.xml semantics and annotations defaultscene.fx rendering method used by fxcomposer expressed in xml, see manual chapter 3 Advanced Rendering and Shading 7

Semantics & Annotations Input semantics are names used to link the given shader input to an output of the previous stage of the graphics pipeline Output semantics are used to specify how data generated by the shader should be linked to the inputs of the next stage. For example, the output semantics for a vertex shader are used to link the outputs with the interpolators in the rasterizer to generate input data for the pixel shader. Global variables can have annotations, which can be queried using effects. One or more annotations can be attached to any parameter. Annotations are metadata that can be attached to any parameter. They are specified inside of angle brackets (< >). Advanced Rendering and Shading 8

Semantics & Annotations float4x4 worldviewproj : WorldViewProjection; float4x4 world : World; float4x4 worldinversetranspose : WorldInverseTranspose; float4x4 viewinverse : ViewInverse; float shininess : SpecularPower < string UIWidget = "slider"; float UIMin = 1.0; float UIMax = 128.0; float UIStep = 1.0; string UIName = "specular power"; > = 30.0; Tweakable Advanced Rendering and Shading 9

Shader code Previous lecture... Advanced Rendering and Shading 10

Technique Contains a number of passes Each pass may contain a vertex and a pixel shader and device state information Profile 2.a in FXComposer examples NVidia-specific 2.a can in most instances be replaced with standard 2.0 Advanced Rendering and Shading 11

First.fx // An empty material, which simply transforms the vertex and sets the color. /*********** Parameters ******/ float4x4 ModelViewProj : WorldViewProjection; /*********** Vertex shader ******/ void simplevs(float4 position : POSITION, out float4 clipposition : POSITION, out float4 color : COLOR) { clipposition = mul( position, ModelViewProj); color = float4(1.0, 1.0, 0.0, 1.0); } technique simple { pass p0 {!! VertexShader = compile vs_1_1 simplevs(); } } Advanced Rendering and Shading 12

Green Pixel Shader first.fx is a color vertex shader PS semantics OUT: COLOR Advanced Rendering and Shading 13

Bulging shader Semantics: IN: POSITION, NORMAL OUT: POSITION Bulging = move vertex along normal direction Advanced Rendering and Shading 14

Phong reflection You have access to Gouraud shader! Per pixel instead of per vertex Move calculations to the pixel shader Advanced Rendering and Shading 15

Phong shader Semantics VS IN: POSITION, NORMAL OUT: POSITION, TEXCOORDn PS IN: TEXCOORDn OUT: COLOR worldnormal worldeye worldlight Intrinsic for reflection calculation: -reflect(l,n) Advanced Rendering and Shading 16

Phong with Bulging Bulging = move vertex along normal direction Animate to grow and shrink hint: float t : Time; Advanced Rendering and Shading 17

Phong with Texture kd Pick material constant from texture instead of keeping it constant Look at Texturing.fx Advanced Rendering and Shading 18

Phong with Bump mapping Hint: look at hemibump.fx Vertex shader Tangent space base vectors (given in object space) Normal (semantic: NORMAL) Tangent (semantic: TANGENT) Binormal (semantic: BINORMAL) Need tangent space base vectors in world space! UV for bump normal map (semantic: TEXCOORD0) Pixel shader Read bump normal from texture (vector c) Perturbed world normal = c.x*wx+c.y*wy+c.z*wz Bump normal stored in RGB space! c.xyz = tex2d(...) - (0.5,0.5,0.5) Advanced Rendering and Shading 19

Environment + Bump mapping Create effect that combines environment and bump mapping Hint: study hemibump.fx and reflection.fx Advanced Rendering and Shading 20

Animated bump heights Environment mapping + bump mapping Animate bump mapped heights Advanced Rendering and Shading 21

Combination Phong + environment + bump + animated bump heights + bulging Advanced Rendering and Shading 22

Texture twisting Advanced Rendering and Shading 23

Texture twisting a = twisting * (1.0/(length(uvpos.xy)+0.1)) uvpos <- TEXCOORD0 Advanced Rendering and Shading 24

Vertex twisting Advanced Rendering and Shading 25

Vertex twisting angle = twisting * length(pos.xy) Twist is performed in clip space Advanced Rendering and Shading 26

Mandelbrot Advanced Rendering and Shading 27

Mandelbrot Parameters: S: 0-10, X: -2-2, Y: -2-2 Varying input: u,v: 0-1 (TEXCOORD0) Complex function: (c_real,c_imag) = S*(u-0.5,v-0.5) + (X,Y) Iterate k times (init: (r,i)=(c_real, c_imag)) (r,i) = (r*r-i*i+c_real, 2*r*i+c_imag) If dist_square > 4 then outside else inside dist_square = r*r+i*i PS 2.0 unrolls loops! Limited number of instructions! Try ps_2_a or ps_3_0 Advanced Rendering and Shading 28

Wood Color lightwood = float4(0.5,0.2,0.067,1) Color darkwood = float4(0.3,0.154,0.056,1) WoodColor: lerp(lightwood, darkwood, b) (PS) Help functions: SmoothPulseTrain(e0, e1, e2, e3, period, x) Return SmoothPulse(e0, e1, e2, e3, fmod(x,period) SmoothPulse(e0, e1, e2, e3, x) Return smoothstep(e0, e1,x) smoothstep(e2, e3,x) b = SmoothPulseTrain(0.1, 0.55, 0.7, 0.95, 2, woodradius) WoodRadius (radius from z axis) (VS) perturbedpos = scaledpos.xyz + (1,0.5,0.2)*noise3d(0.5*scaledPos.xyz) r = length(perturbedpos.xy) + 1.1 * noise3d(0.2*scaledpos.xyz) + 1.5 * noise1d (0.1*scaledPos.z) ScaledPos = scale*pos. //Scale factor in reference image = 40 Noise functions from perlin.zip from the course homepage. Quality depends on tessellation! Why not noise in pixel shader? GPU Gems 2 chapter 26 if someone wants to try (might run into instruction length problems). Advanced Rendering and Shading 29