Render Pipeline & Light Rendering Path

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

The rendering pipeline can be roughly divided into 4 stages:

Application: The program stage is fully controllable, is driven by software, and the software usually runs in generalCPU.

share picture

ProgramAt the end of this stage, submit the geometric primitives to be rendered to the next stage of geometric processing , These are called rendering primitives(point, line, triangle). This is the most important task at this stage: Submit geometric primitives( rendering primitives) strong>. How to submit correctly on-demand becomes the key. Other things can also be done at this stage: collision detection, keyboard and mouse input, head-mounted display, rejection algorithm, etc. Geometry Processing:geometry processing, transformation, projection, etc. This stage includes drawing content, how to draw, in Where to draw. Usually executed onGPU, Programmable.

share picture

< p>Share a pictureShare a pictureshare picture Share picture < /span>

①Vertex coloring. 1 is to calculate the vertex coordinates, and the calculation of the vertex coordinates requires multiple transformations: modeling coordinates -> world coordinates -> observation coordinates; 2 is to calculate the vertex output data (such as normal and texture coordinates)

② Projection: Orthogonal and perspective projection. After orthogonal or perspective transformation, the coordinates are converted to clipping coordinate (also called homogeneous coordinates determine whether the camera is visible) strong>. Optional Process after projection:

Tessellation: surface subdivision, a set of vertices form a pitch, and a set of pitches form a triangle set. With the distance of the object from the camera, you can control the size of the generated triangle set, how close or far less.

Geometry Shading: Often used to simulate particle effects.

Stream output: Often used to simulate particle effects.

③ Clipping: Use the homogeneous coordinates generated in the projection stage for clipping, and perform perspective segmentation to obtain normalized device coordinatesalso known as Viewport coordinates are three-dimensional coordinates.

④ Screen Mapping: Map the obtained viewport coordinates to the screen to get screen coordinates (x, y) plus z_values, two-dimensional coordinates. Pay attention to distortion control

Modeling coordinates-(Model Transform)>World coordinates-(View Transform)> Observation coordinates-(Projection Transform)>Viewport coordinates(Screen mapping)>screen coordinates//Bold ones are operable to vertex positions

?

Rasteriztion:< /strong>RasterizationGPU to execute on, receive all transformed and projected vertices and their coloring data from the previous stage, and find all pixels in the primitive. Programmable

Share pictures

Share a pictureShare a picture

Triangle Setup(primitive assembly):In this stage, the differential calculation of the triangle and the edge division are performed.

Triangle Traversal : Triangle traversal. Finding which samples or pixels are inside a triangle is often called triangle traversal

????????????????

< p>Pixel Processing: GPUExecute. Pixel processing is the stage of calculating and operating pixel-by-pixel or sample-by-sampling point on the sampling points in pixels or primitives. Programmable

share picture

share picture share picture????????????????

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

Merging: The pixel color is stored incolor buffer,< /span>task1< span style="font-family:宋体; background-color:white">is responsible for merging the color of the fragment generated in the pixel coloring stage with the color in the current buffer; task2is responsible for solving visibility issues

?

0x01 Unity’s Rendering Path

?? ?? Determined by the rendering path. “How to apply lighting and which channel of the shader is used depends on which rendering path is used. Each channel in the shader transmits the type of light through its channel label”

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

ForwardBaseThe channel will immediately render the ambient light, Lightmaps, main direction lights, and unimportant vertex lights.

ForwardAddThe channel is used to enhance the pixel-by-pixel lighting, each Objects are illuminated by such light.

If the above two suitable lighting channels are not available in the shader, it will automatically switch toVertex Lit path.

?

inForward span>under rendering, some of the brightest light (default4one)The effect on each object is rendered by completely pixel-by-pixel lighting; secondly, each vertex accepts the most4 a light calculation; other lights are based onSHcalculate approximate values. Whether a light uses pixel-by-pixel lighting depends on:

(More than the default number of lights will be added to the ambient light)

The light rendering mode is set toNot ImportantAlways vertex by vertex/SH; setImportantalways pixel by pixel

The brightest directional light is always pixel by pixel

There is less light in the sceneQuality Setting Pixel Light Count, the excess light is rendered pixel by pixel and sorted by decreasing intensity

?

The rendering of each object Process:

Base pass applies a per-pixel light and all other per-vertex/SH lights

Other per-pixel lights are rendered in additional passes, one pass corresponds to one light< /p>

?

share picture ???????????????? Schematic. Assuming that the color and intensity of the A-H light and the render model are auto, the brightness sorting is based on distance.

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

???????? ???????? DG is the 4 most light received by per-vertex

???????????????? < /strong>GH is SH

???????????????? Overlap is to prevent light popping as much as possible. If there is a problem with the transition, first check the optical component render model and intensity. And Quality Setting pixel light count, and then check the code.

?

The number of visible light sources in the scene and the computational complexity increase linearly, which will affect the efficiency of the vertex shader

?

Base Pass

???? Base pass uses a per-pixel directional light and all SH/Vertex lights to render objects. This pass also adds all light maps and ambient light , And self-illumination from the shader. The directional light rendered by this pass can have shadows. But lightmaps will not accept SH light.

Additional Passes

Additional passes???? Render objects with extra per-pixel light. Unless the multi_compile_fwdadd _fullshadows variant is turned on.

Performance Considerations

????Spherical Harmonics lights are very Efficient. The CPU consumption is extremely small, and there is no additional burden for the GPU (because the base pass will always calculate the SH Lighting; it is related to the spherical harmonic lighting mechanism, no matter how many spherical harmonic lights exist, the consumption is the same of).

Disadvantages of SH lighting:

Calculate using the vertices of the object instead of pixels. Therefore, normal maps and Light Cookies are not supported.

The SH lighting function is a very low frequency lighting function. It will not have very sharp lighting transitions. In addition, it will only respond to Diffuse Lighting. For Specular Highlight, its frequency too low.

SH lighting is not local; point or spot SH lights close to some surface will “look wrong”. Will be abnormal.

?

② Deferred Shading path

< strong>//To be continued

Deferred Lighting path

// < /strong>

④ Vertex Lit Rendering path

?

0x100 to be added

??? ?TessellationDetailed explanation

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2310 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.