GEOMETRY SHADER. Breakdown  Basics  Review – graphics pipeline and shaders  What can the geometry shader do?  Working with the geometry shader  GLSL.

Slides:



Advertisements
Similar presentations
POST-PROCESSING SET09115 Intro Graphics Programming.
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Today: - Make sure everyone is set up with an OpenGL environment - OpenGL basics:
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
GLSL Applications: 1 of 2 Joseph Kider Source: Patrick Cozzi – Spring 2011 University of Pennsylvania CIS Fall 2011.
GLSL I May 28, 2007 (Adapted from Ed Angel’s lecture slides)
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
Pixel Shader Vertex Shader The Real-time Graphics Pipeline Input Assembler Rasterizer Output Merger.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
SET09115 Intro Graphics Programming
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
Geometry Shaders. Visualizing Normal Vectors  textbook calls this a “hedgehog plot” but (I think) that this is a misuse of the term  a hedgehog plot.
Geometric Objects and Transformations. Coordinate systems rial.html.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
GAM532 DPS932 – Week 2 Vertex Shaders. The Shader Pipeline Vertex Processing Primitive Assembly / Processing Rasterization Fragment Process Pixel Output.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Maths & Technologies for Games DirectX 11 – New Features Tessellation & Displacement Mapping CO3303 Week 19.
BUMP-MAPPING SET09115 Intro to Graphics Programming.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
OpenGL-ES 3.0 And Beyond Boston Photo credit :Johnson Cameraface OpenGL Basics.
Geometry Shader (GLSL)
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
Emerging Technologies for Games Capability Testing and DirectX10 Features CO3301 Week 6.
Ray Tracing using Programmable Graphics Hardware
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.
OpenGL Shading Language
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS The GPU.
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.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Shaders, part 2 alexandri zavodny.
The Graphic PipeLine
Deferred Lighting.
Introduction to OpenGL
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Models and Architectures
Introduction to Computer Graphics with WebGL
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Introduction to Computer Graphics with WebGL
Day 05 Shader Basics.
Chapter VI OpenGL ES and Shader
Introduction to Shaders
ICG 2018 Fall Homework1 Guidance
Chapter XVIII Surface Tessellation
Programming with OpenGL Part 3: Shaders
Hw03 : shader.
Computer Graphics Introduction to Shaders
© 2012 Elsevier, Inc. All rights reserved.
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
03 | Creating, Texturing and Moving Objects
Introduction to OpenGL
CS 480/680 Computer Graphics GLSL Overview.
CS 480/680 Part 1: Model Loading.
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

GEOMETRY SHADER

Breakdown  Basics  Review – graphics pipeline and shaders  What can the geometry shader do?  Working with the geometry shader  GLSL example  Examples  Fur, Fins  Particles

Recommended Reading  Geometry shader is pretty new concept  Real-Time Rendering mentions in passing  Course text has no real discussion  Do some searching online if you are interested in learning more

Basics

Review – Graphics Pipeline

Review – What are Shaders?  Shaders are small programs that run on the GPU  Shaders allow us to implement effects that we may wish for in our rendered scene  Lighting, texturing being the most basic  Three types of shader  Vertex  Geometry  Fragment (or pixel)

What is the Geometry Shader?  The geometry shader is the stage that occurs directly after the vertex shader stage  The geometry shader works with output from the vertex shader in the form of geometry objects  Points, lines, triangles  Can also include adjacency data

What Can the Geometry Shader Do?  Geometry shader can manipulate a whole piece of geometry  No longer manipulation of a single vertex  Geometry shader can also add geometry  No longer single vertex in, single vertex out  Combining these two features allows manipulation of your geometry in a new manner  And can create some neat effects

Example

Geometry Shader Input  The input into a geometry shader comes in the form of pieces of geometry  Points, lines, triangles, quads  The geometry shader may also take in an adjacency block  Vertices adjacent to the piece of geometry  The piece of geometry is basically an array of vertex positions

Geometry Shader Output  The geometry shader outputs a strip of the defined geometry type  e.g. triangles in, triangle strip out  The output operates by having a few extra functions in GLSL  EmitVertex() – emits a vertex to the next stage  EndPrimitive() – ends the vertex creation for the particular primitive  Possible to restrict the number of output vertices

Stream Output  It is also possible to output the data from the geometry shader stage of the pipeline  Output from the geometry shader can be used for further rendering if required  Useful for letting the GPU do point physics calculations  Each vertex has a position, velocity, acceleration, mass, etc.  Output is the new position, velocity

Questions?

Working with the Geometry Shader

GLSL Example Geometry Shader #version 330 compatibility layout(triangles) in; layout(triangle_strip, max_vertices=6) out; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; uniform mat4 modelMatrix; in vec4 normal[]; out vec4 vertex_color;

GLSL Example void main() { mat4 modelViewMatrix = viewMatrix * modelMatrix; mat4 viewProjectionMatrix = projectionMatrix * viewMatrix; int i; //====== First triangle - identical to the input one. for(i=0; i<3; i++) { vec4 view_pos = modelViewMatrix * gl_in[i].gl_Position; gl_Position = projectionMatrix * view_pos; vertex_color = vec4(0.0, 1.0, 0.0, 1.0); EmitVertex(); } EndPrimitive();

GLSL Example //====== Second triangle - translated version for(i=0; i<3; i++) { vec4 N = normal[i]; vec4 world_pos = modelMatrix * (gl_in[i].gl_Position + normalize(N) * 10.0); gl_Position = viewProjectionMatrix * world_pos; vertex_color = vec4(1.0, 1.0, 0.0, 1.0); EmitVertex(); } EndPrimitive(); }

Input Values  Notice that we can define the input value types using the layout specification  Layout can be used to tell GPU where to send particular pieces of data  The input layout is important for using the geometry shader correctly  Need to know the type of primitive we are dealing with  We can also declare incoming adjacent vertices

Output Values  Notice that we also set the outgoing data format for the geometry shader  Triangle strip in this instance  We can set the output data type, and the number of expected vertices  Useful when dealing with potentially large pieces of geometry

Questions?

Examples

Fur  om/watch?v=tuAC9Q Gx3vQ om/watch?v=tuAC9Q Gx3vQ

Point Sprite Expansion  om/watch?v=jpXgPkft RcM om/watch?v=jpXgPkft RcM

Dynamic Particles 

Morphing / Shape Manipulation 

Tesselation  

Questions?

To do this week…  Coursework, coursework, coursework  As mentioned, I’ll be in the Games Lab all week  Focus on getting the coursework in, then next week we’ll talk about the exam and module as a whole

Summary  Geometry shader allows us to do some pretty cool effects beyond the capabilities of the vertex and fragment shader  Geometric primitives approach  This is such a new area of graphics programming that materials are light on the ground  Dig around to see what you can find