[Feng yuchong] The shader of the unity3d tutorial book: The ninth lecture on render path

Source: Internet
Author: User
If the original article needs to be reproduced, please note: Reprinted from Fengyu Chong unity3d tutorial Institute

  
Lecture 9 of shader
Render path


Render path Definition
Render path is the lighting process.


Render path settings
You can set it in edit-> Project Settings-> player. For details, see. You can also set it directly in the Inspector Panel of the camera.

Render path
                                    
I:Vertex
Vertex vertex is the vertex illumination. As the name suggests, all illumination calculations are performed on the vertex. Therefore, all pixel operations are not supported, such as shadows, normal maps, and light cookies. An object generally has only one pass. The worst effect, the fastest running. Suitable for old devices or general mobile devices.

Ii. forward lighting
Forward lighting is based on shader. Supports pixel illumination (including normal textures and light cookies ). Supports real-time shadow from a single side to the light. Usually the brightest light (with the greatest impact on the environment) is checked in the render mode item important, corresponding to forward, and other use not important, corresponding to vertex.
Details:
(1) Use pixel computing for the brightest light sources
(2) second (up to four) Use vertex computing. Remaining use
(3) spherical harmonics (SH) computing is a fast approximation algorithm.

Judging order
1. If the render mode is not important, it must be Vertex computing or sh.
2. The direction of the highest brightness value must be pixel computing.
3. Important is about pixel computing.
If the number of light does not reach the pixel light count set in quaility setting. The vertex or sh is converted into pixels Based on the brightness value.

Bass pass: rendering the direction of a pixel computing. And all vertex calculations and sh direction light. After that, a corresponding pass. lightmap will be added for each added pixel-by-pixel computing light. The light in this step can have a shadow.
Additional pass: Extra pixel computing light with no shadow. That is to say, forward lighting only supports a shadow direction light.

SH:
Spherical harmonics is highly efficient and does not support light cookies and normal textures. It is slow to update and does not support mirror reflection,


3. Deferred Lighting
Deferred lighting provides the best lighting and shadow effects, with the highest performance requirements on devices. Unity pro is required. Mobile devices and flash devices are not supported.
Details: supported. Multiple lights with real-time shadows (for example, the effect of multiple lights playing on players in football ),It does not really support anti-aliasing, and does not support translucent. At least Shader Model 3.0. Illumination is calculated in the screen cropping space, so the complexity is based on the number of involved pixels, not the complexity of the scene model. Suitable for small-range light sources
Three phases:
Base pass: Specifies the buffer information of the cropping space, such as the depth buffer. The image is stored in an argb32 render texture, where RGB saves the point normal and a saves the mirror reflection intensity. If the depth can be read as texture, the depth will not be explicitly rendered. If it cannot be read, replace shader replacement with the Shadow, that is, camera. renderwithshader. The result of base pass is that the scene object is attached with a depth buffer and a texture that stores the normal and mirror intensity.
Lighting pass: only the BlinN-phong illumination model is supported. The shadow is also calculated in this step. The previously generated buffer is used to calculate the illumination in this step. The light buffer is also an argb32 render texture, the color of the RGB table diffuse reflection light, and the Table monochrome mirror light.
Final pass: combines the texture color with the stored illumination result. Lightmap is used in this step. Note: After the deferred lighting step is completed, it will go to forward lighting.


Render path comparison
                                 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.