Render Pipeline & lighting rendering path

0x00 Rendering Pipeline "A chain is no stronger than its weakest link."

Rendering pipeline can be roughly divided into four stages:

Application: procedural stage fully controllable, driven by software, the software typically runs in general the CPU .

Program at the end of this period, the geometric primitives to be rendered submitted to the next stage of geometry processing, these are called rendering primitives ( points, lines, triangles ) .

This is the most important task at this stage: submission of geometric primitives ( rendering primitives ) . How to properly submit a key demand.

This stage also do something else: collision detection, mouse and keyboard input, wearing a show that removing algorithm

 

Geometry Processing: geometry processing, transformation and projection, rendering content including the stage, how to draw, in which drawing. Typically GPU execution on programmable .

① vertex shader. 1 is calculated vertex coordinates, vertex coordinate calculation take multiple transformation: Modeling Coordinate -> world coordinates -> observation coordinate ; 2 vertex is calculated output data (e.g., normal, and texture coordinates)

② Projection: orthogonal and perspective projection. After orthogonal or perspective transformation after the coordinates into Clipping Coordinate (also called homogeneous coordinates determine where the camera is visible) . After the projection is optional Optional Process:

The Tessellation : tessellation, a group composed of a Pitch vertices, a set of triangles will form a set of pitch. As the object distance from the camera can be controlled to generate a set of triangles size, less near far.

  Shading the Geometry : particle effects commonly used in the simulation.

  Output Stream : particle effects commonly used in the simulation.

③ Clipping: projection phase using homogeneous coordinates generated cropping performed perspective divide to obtain normalized device coordinates are also referred to as the viewport coordinates , three-dimensional coordinates.

④ Screen Mapping: The resulting viewport coordinates onto the screen is screen coordinates (x, y) plus z_values, two-dimensional coordinates. Note distortion control

Modeling coordinates - (the Model the Transform) > world coordinates - (View the Transform) > observed coordinates - (Projection the Transform) > viewport coordinates - (Screen Mapping) > // screen coordinates of vertex positions bold is operable

 

Rasteriztion: rasterization GPU performed on all the converted reception stage and projection data from the vertex shader and find all the pixels within the primitives. Programmable

Triangle the Setup (primitive Assembly) : triangle difference calculation is performed at this stage, the edge equipartition.

Triangle Traversal:三角形遍历。Finding which samples or pixels are inside a triangle is often called triangle traversal

                

Processing Pixel: GPU execution. Pixel sampling points within the process is a pixel-by-pixel, or primitive or point by point and calculates the sampling phase of operation. Programmable

                

Pixel Shading : programmable pixel shading calculations are all at this stage.

section Merging : color pixel stored in the Color Buffer , task 1 is responsible for generating a pixel shading stage merged with the color of the fragment in the current color buffer; task 2 is responsible for addressing the problem of visibility

 

0x01 Unity's Rendering Pipeline

Decisions by rendering path. "How to Apply light and using a shader which depends on which channel rendering path, the shader each channel, via its channel to transfer illumination type label"

 

① Forward Rendering path-ForwardBase and ForwardAdd passes are used.

ForwardBase channel immediately rendered ambient light, light maps, and the main directional light unimportant vertex light.

ForwardAdd channel is used to enhance the per-pixel lighting, each object is illuminated by such light is invoked.

If the two shader is not suitable light path is automatically switched to Vertex Lit path .

 

In Forward the rendering some of the most bright light ( default . 4 th ) effects on each object is rendered completely by-pixel lighting mode; secondly accepts up to each vertex . 4 optical calculation;

Other light to SH calculate the approximation. A light depending on whether to use per-pixel lighting :( quantity exceeds the ambient light will be added to the light )

Light rendering mode to Not Important always per vertex / SH ; set Important always pixel by pixel

Directional light is always the brightest pixel by pixel

Less than the light in the scene at Quality the Setting the Count Pixel Light , extra-by-pixel rendering light intensity sort descending press

 

Each object rendering process:

Application of a Base pass light of all other per-pixel per-vertex / SH light

Other per-pixel rendering pass additional light, a light corresponding to a pass

 

 schematic diagram. AH assumed that the color and intensity of light and render model is auto, based on the distance ordering .

                

                 AD is the brightest light using per-pixel rendering (default 4)

                 Up to per-vertex DG is received by four light

                 GH is SH

 Overlap as much as possible to prevent light popping, first check if there is a problem of transition optical components render model, intensity, and Quality Setting pixel light count, and finally the whole code.

 

Then the number of visible light sources in the scene and the computational complexity is linear growth, affect the efficiency of the vertex shader

 

Base Pass

  Base pass with a per-pixel and a directional light to all SH / Vertex rendering object light, which also increases the channel maps all light, ambient light, and from the self-luminous shader.

The channel may have rendered directional light shadow. SH Lightmap but not accept light.

Additional Passes

  Additional passes with additional per-pixel rendering of the object light. Unless turned multi_compile_fwdadd _fullshadows variant variants.

Performance Considerations

  Spherical Harmonics lights (spherical harmonic light) very efficient. CPU consumption is extremely small, for GPU is no additional burden (because the base pass would have been originally calculated SH Lighting;

Mechanisms and spherical harmonic illumination light, no matter how many spherical harmonic light exist, consumption is the same)

SH illumination disadvantages:

Calculated using the vertices of the object, rather than pixels. It does not support normal mapping and Light Cookies.

SH illumination function is a kind of very low frequency illumination function, there will be very sharp transition illumination, will only further in response Diffuse Lighting (diffuse reflection), for Specular Highlight (specular light) whose frequency is too low.

SH lighting is not local; point or spot SH lights close to some surface will "look wrong" not partial spherical harmonic illumination, the point light source or in the form of SH Light spot will appear abnormal when approaching some surfaces.

 

② Deferred Shading path

//to be continued

Deferred Lighting path

//

④ Vertex Lit Rendering path

 

0x100 To be added

    Tessellation Detailed

Guess you like

Origin www.cnblogs.com/baolong-chen/p/11618939.html
Recommended