Computer Graphics Learning (3) - The Basics: programmable rendering pipeline

3.1 rendering pipeline development

  1. Graphical programming development

    • Early graphics programming: call the library hardware provided by suppliers (for drawing primitives and library property does not exist)
    • Generate a graphical standard: Supplier standard hardware graphics database, enables independent apparatus generates an image in the manner
      • GKS (Graphical Kernel System, Graphical Kernel System)
      • PHISS (Programmer's Hierarchical Interactive Graphics System, Programmer's Hierarchical Interactive Graphics System)
      • OpenGL
    • Fixed line
      • Graphics API provides a standard interface for operating the hardware; from the inside is achieved, API requests for proposed various programmers sketch membered or attributes are used to process a fixed manner
      • This implementation is commonly referred to internal fixed-function rendering pipeline
    • Secured to programmable
      • Hooks of the hook function occurs: a fixed function pipeline break out using a programmable shader pipeline to modify the behavior of certain steps of
    • Programmable pipeline
  2. GPU-based programmable rendering pipeline

    • Function: Determine the course of a given drawing or generating a two-dimensional image under various conditions where the virtual camera, three-dimensional object, a light source, illumination pattern, texture and the like

    • Three conceptual stage pipeline

      • Application phase: the need to draw out on the screen geometry, i.e. drawing primitives, such as points, lines, rectangles, etc., is input to the next stage of the rendering pipeline. Specifically includes primitive vertex data, the camera position, light texture parameters.
      • Set the stage: the vertex data screen map. need:
        • The individual elements into the world coordinate system, which is the model transformation
        • The light texture lighting calculation at the apex of the material coloring effect
        • The position of the camera, shooting range and clipping conversion was observed
        • Finally, the screen mapping, three-dimensional model is the transition to the screen coordinates
      • Raster stage: the correct color for each pixel, to draw the whole pattern

      4 %% W} $% 3WYJBT2V9 DQZ} SEc

3.2 programmable rendering pipeline

  1. GPU rendering pipeline work process

    img

  2. Geometric phase

    • Vertex shader:
      • Model Transformation: Model coordinate system -> world coordinate system, all the model into a coordinate system
      • View transform: establishing observation coordinate system
      • Vertex shader: determining a lighting effect on the upper apex of the material
    • Geometry, tessellation shader
    • Cutting: standardized observation space
    • Screen mapping: convert two-dimensional data
  3. Rasterization stage

    • Triangle set
    • A triangle traversal
    • Fragment shader
    • Piece original operation
      • Fragment -> stencil test -> Depth Test -> color mixing -> the frame buffer

        3.3 shader programming

  4. Shader Language Shading Language

  5. GLSL (OpenGL Shading Language) OpenGL shader language

    • Vertex shader Vertex Shader, geometry shader Geometry Shader, tessellation shader Tessellation Shader, fragment shader Fragment Shader

    • Used in OpenGL shader process:

      • Create a shader objects
      • Source objects associated shader
      • Shader compiler
      • Create a program object
      • Associating shader object to a program object
    • OpenGL communication with

      • OpenGL passed via a uniform set of data to all global variables shader
    • type of data

      • Scalar: integer (int), unsigned integer (uint), Boolean type (bool) and float (float)

      • Vector: A vector can have three, four components

        vec4 a=vec4(1.0,2.0,3.0,4.0);

      • matrix

        mat2 m mat2 (1.0,2.0,3.0,4.0);

      • Structures and arrays: the base member or structure type of the array may be any type of data

        // lightsource light source

        struct lightsource{

        vec3 color; // color

        vec3 position; // position

        }

        lightsource spotlight [10]; // 10 light sources

    • Control structure

      • Loop structure: for, while, and do-while
      • Selection cycle: if-then, if-then-else, GLGL3.0 version introduces switch structure
      • Note: goto statements and labels are not allowed
  6. EBO, VBO 和 VAO

    • EBO
      • Element Buffer Object, also known as IBO: Index Buffer Object, index buffer objects
      • Mainly used to store the index information of the vertices
    • FEB
      • Vertex Buffer Object, vertex buffer objects, is mainly used to store various information vertices
      • Benefits: vertex information model into VBO, so each painting model, the data is no longer taken from the sphere of influence of CPU's memory, but the memory taken directly from the GPU in order to improve efficiency
    • VAO
      • Vertex Array Object, vertex array objects
      • VAO is a saved state of all the vertex data binding properties, which stores the desired object format and VBO vertex data of the vertex data reference

Guess you like

Origin www.cnblogs.com/maeryouyou/p/11986584.html