Week 4 Lecture 1: OpenGL 3.x & 4.x. 2 Objectives Changes in OpenGL 3.x 4.x Changes in GLSL 1.3/4/5 4.x.

Slides:



Advertisements
Similar presentations
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Advertisements

Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
POST-PROCESSING SET09115 Intro Graphics Programming.
Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
Tesselation Shaders. Tesselation  dictionary definition of tesselate is the forming of a mosaic.
Addition 1’s to 20.
25 seconds left…...
Week 1.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
An Introduction to the OpenGL Shading Language Keith O’Conor.
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.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
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.
Status – Week 277 Victor Moya.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
GEOMETRY SHADER. Breakdown  Basics  Review – graphics pipeline and shaders  What can the geometry shader do?  Working with the geometry shader  GLSL.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
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.
OpenGL 3.0 Texture Arrays Presentation: Olivia Terrell, Dec. 4, 2008.
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.
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
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.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
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
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.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 GPU.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
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.
Shader.
Programmable Pipelines
The Graphic PipeLine
Graphics on GPU © David Kirk/NVIDIA and Wen-mei W. Hwu,
Introduction to OpenGL
Chapter 6 GPU, Shaders, and Shading Languages
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
Graphics Processing Unit
Introduction to Computer Graphics with WebGL
ICG 2018 Fall Homework1 Guidance
Programming with OpenGL Part 3: Shaders
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Introduction to OpenGL
CS 480/680 Computer Graphics GLSL Overview.
Introduction to Computer Graphics with WebGL
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

Week 4 Lecture 1: OpenGL 3.x & 4.x

2 Objectives Changes in OpenGL 3.x 4.x Changes in GLSL 1.3/4/5 4.x

3 Fixed Function / Immediate Mode OpenGL 3.x deprecated stuff includes: ­immediate mode (Begin/End etc) ­Vertex specification ­Vertex Arrays ­Matrices ­Texture Coordinates ­Lighting ­All fixed-function options ­pixel formats with colour palettes

4 I Need My Immediate Mode! Why have they done this? Shaders! Shader performance is so much better that immediate mode is no longer competative. Direct X Direct X was outperforming OpenGL since Direct X 10 Hardware New Graphics cards were reducing fixed functionality support in order to focus on gpu.

5 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 No, Really, I want immediate mode. Ok, immediate mode is still available if you include OpenGL’s compatibility profile. A core profile and a compatibility profile exist… int attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, major, WGL_CONTEXT_MINOR_VERSION_ARB, minor, WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 0 }; PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB"); if(wglCreateContextAttribsARB != NULL) { m_hrc = wglCreateContextAttribsARB(pDC->m_hDC,0, attribs); }

6 Shaders OpenGL 3.x Shader Versions 1.40 and 1.50 Geometry Shader OpenGL 4.x Shader Version 4.x Tessolation Shaders Control shader Primitive Generator Evaluation shader

7 Vertex Shader Frame Buffer Fragment Shader CPU vertices fragments Rasterizer fragments OpenGL 2.x Shaders

8 Vertex Shader Frame Buffer Fragment Shader CPU Rasterizer OpenGL 3.x Shaders Geometry Shader vertices primitives fragments

9 Vertex Shader Frame Buffer Fragment Shader CPU Rasterizer OpenGL 4.x Shaders Geometry Shader vertices primitives fragments Primitive generator Control Shader Evaluation shader Optional Tessellation Shaders

10 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Geometry Shaders Take vertices (of a primitive) Output Primitives (triangle strip, points, line) Can create new vertices, unlike vertex shaders, which are limited to a 1:1 input to output ratio. Layered rendering; this means that the GS can specifically say that a primitive is to be rendered to a particular layer of the framebuffer.

11 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Geometry Shaders #version 150 layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; void main() { for(int i = 0; i < gl_in.length(); i++) { gl_Position = gl_in[i].gl_Position; EmitVertex(); } EndPrimitive(); }

12 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Uniform Buffer Objects Allow blocks of data to be transferred as a single variable to shader. Need a layout parameter to define memory layout. uniform BlockName { vec3 blockMember1, blockMember2; float blockMember3; } glslBlockName;

13 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Example (Projection/Model Matrix now need to be manually passed) #version 140 uniform Transformation { mat4 projection_matrix; mat4 modelview_matrix; }; in vec3 vertex; void main() { gl_Position = projection_matrix * modelview_matrix * vec4(vertex, 1.0); }

14 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Layout Defines memory structure of passed variables. For UBO it can be std140, packed, or shared. Packed or Shared needs the byte offset to access, std140 is more user friendly but may not be optimal. Layout can be set for other compound memory, e.g. row_major or colomn_major for matrices, triangles for vertex arrays etc.

15 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Tessellation Control Processor Programmable unit that operates on a patch of incoming vertices and their associated data, emitting a new output patch. Invoked for each vertex of the output patch. Each invocation can read the attributes of any vertex in the input or output patches, but can only write per- vertex attributes for the corresponding output patch vertex. As many shaders can run, the built-in function barrier() can be used to control execution order by synchronizing invocations, dividing tessellation control shader execution into a set of phases.

16 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Tessellation Evaluation Processor Evaluates the position and other attributes of a vertex generated by the tessellation primitive generator, using a patch of incoming vertices and their associated data. computes the position and attributes of a single vertex generated by the tessellation primitive generator. Reads the attributes of any vertex in the input patch, plus the tessellation coordinate, which is the relative location of the vertex in the primitive being tessellated. The executable writes the position and other attributes of the vertex.

17 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 What variables do we get for free? Vertex: in int gl_VertexID; in int gl_InstanceID; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; + Compatability Profile: in vec4 gl_Color; in vec4 gl_SecondaryColor; in vec3 gl_Normal; in vec4 gl_Vertex; in vec4 gl_MultiTexCoord0; in vec4 gl_MultiTexCoord1; in vec4 gl_MultiTexCoord2; in vec4 gl_MultiTexCoord3; in vec4 gl_MultiTexCoord4; in vec4 gl_MultiTexCoord5; in vec4 gl_MultiTexCoord6; in vec4 gl_MultiTexCoord7; in float gl_FogCoord;

18 What variables do we get for free? Geometry: in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[]; in int gl_PrimitiveIDIn; in int gl_InvocationID; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; }; out int gl_PrimitiveID; out int gl_Layer;

19 What variables do we get for free? Tessellation control language: in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[gl_MaxPatchVertices]; in int gl_PatchVerticesIn; in int gl_PrimitiveID; in int gl_InvocationID; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_out[]; patch out float gl_TessLevelOuter[4]; patch out float gl_TessLevelInner[2];

20 What variables do we get for free? tessellation evaluation language: in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[gl_MaxPatchVertices]; in int gl_PatchVerticesIn; in int gl_PrimitiveID; in vec3 gl_TessCoord; patch in float gl_TessLevelOuter[4]; patch in float gl_TessLevelInner[2]; out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; };

21 What variables do we get for free? Fragment: in vec4 gl_FragCoord; in bool gl_FrontFacing; in float gl_ClipDistance[]; in vec2 gl_PointCoord; in int gl_PrimitiveID; in int gl_SampleID; in vec2 gl_SamplePosition; out vec4 gl_FragColor; // deprecated out vec4 gl_FragData[gl_MaxDrawBuffers]; // deprecated out float gl_FragDepth; out int gl_SampleMask[];

22 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Compatibility Profile State uniform mat4 gl_ModelViewMatrix; uniform mat4 gl_ProjectionMatrix; uniform mat4 gl_ModelViewProjectionMatrix; uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords]; uniform mat3 gl_NormalMatrix; uniform mat4 gl_ModelViewMatrixInverse; uniform mat4 gl_ProjectionMatrixInverse; uniform mat4 gl_ModelViewProjectionMatrixInverse; uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords]; uniform mat4 gl_ModelViewMatrixTranspose; uniform mat4 gl_ProjectionMatrixTranspose; uniform mat4 gl_ModelViewProjectionMatrixTranspose; uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords]; uniform mat4 gl_ModelViewMatrixInverseTranspose; uniform mat4 gl_ProjectionMatrixInverseTranspose; uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose; uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords]; uniform float gl_NormalScale; uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];

23 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Compatibility Profile State struct gl_PointParameters { float size; float sizeMin; float sizeMax; float fadeThresholdSize; float distanceConstantAttenuation; float distanceLinearAttenuation; float distanceQuadraticAttenuation; }; struct gl_MaterialParameters { vec4 emission; // Ecm vec4 ambient; // Acm vec4 diffuse; // Dcm vec4 specular; // Scm float shininess; // Srm }; uniform gl_MaterialParameters gl_FrontMaterial; uniform gl_MaterialParameters gl_BackMaterial;