460 likes | 496 Views
OpenGL Rendering pipeline. 陳雅暄 李晨維. Outline. Introduction to OpenGL Rendering pipeline Q&A. OpenGL. Created in 1991 by Silicon Graphics. Now it is managed by the Khronos consortium A library of functions (e.g., glDrawArrays ) and constants (e.g., GL_TRIANGLES )
E N D
OpenGLRendering pipeline 陳雅暄 李晨維
Outline • Introduction to OpenGL • Rendering pipeline • Q&A
OpenGL • Created in 1991 by Silicon Graphics. Now it is managed by the Khronos consortium • A library of functions (e.g., glDrawArrays) and constants (e.g., GL_TRIANGLES) • The API interacts with the graphics processing unit (GPU) • Language-independent: has many bindings, e.g., WebGL. • Platform-independent: works on Win/Linux/..
OpenGL – Libraries • OpenGL doesn’t support input or windowing • GLUT (or GLFW) is used to create a context • Platform-dependent extensions can be provided by vendors. Identified by ARB, EXT, .. • GLEW wraps the extraction of functionality
Vertex specification • List an ordered list of vertices that define 1.The boundaries of the primitive (Points, Lines or Polygons). 2.Colors of each vertices. 3.Texture coordinates.
Vertex specification Vertex specification • Common object format: .obj, .stl, .3ds • Common object format: .obj, .stl, .3ds Vertex coordainates Texture coordainates Vertex normal Face element
Read an obj file • Read an object with tiny_obj_loader
VBO - Vertex Buffer Object • VBO : Vertex buffer object. It can store a large number of vertices in the GPU’s memory • It usually stores something like positions, texture coordinates, normal vectors or indices
VAO - Vertex Array Object • VAO : Vertex array object. It can be bound vertex buffer objects
EBO - Element Buffer Objects • When we try to draw a rectangle, there is some overlap on the vertices specified. With EBO Without EBO
3D Coordinate and Texture Coordinate 3D Texture
Vertex Shader • Vertex Shader is a program written in GLSL that manipulate the vertex data. • The goal of vertex shader is to calculate final vertex color of each vertex.
Tessellation • This shader stage is optional. • Divided into smoother mesh of triangles.
Geometry Shader • This shader stage is optional. • Convert primitives to different types. • For example, point primitive can become lines.
Vertex Post-processing • This is a fixed function stage. • The most important part of this stage is Clipping.
Perspective and Orthogonal rendering (Field of View) perspective orthogonal
Rasterization The output of rasterization is a fragments.
Fragment Shader (pixel shader) • User-written program in GLSL calculates the color of each fragment that user sees on the screen.
Per-sample operations • There are few tests that are performed based on user has activated them or not. • For example: • Pixel ownership test, Scissor Test, Stencil Test, Depth Test.
Stencil Test *GLFW does this automatically so we don't have to tell GLFW to create one *By using the stencil buffer we can thus discard certain fragments based on the fragments of other drawn objects in the scene.
Depth Test Today most GPUs support a hardware feature called early depth testing. Early depth testing allows the depth test to run before the fragment shader runs.
New OpenGL vs Old OpenGL • New version uses GLFW (or GLAD) : Old version uses GLUT (freeGLUT) • New version has implementable shader : Old Version does not. • New version can render scene when ever you want. Old version has fixed pipeline. https://blog.csdn.net/Bill_Ming/article/details/7662809 Not recommended