[Unity3d] several common rendering types: A Brief Introduction to normal shader

Source: Internet
Author: User

[I am not very familiar with this aspect, so I have reposted this article from the Internet and learned it together]

Unity3d comes with more than 60 shader. These shader are divided into five categories:

Normal, transparent, transparent cutout, self-llluminated, reflective.

Here we will briefly introduce the usage of nomral shader.

(1) normal shader family

This family has a total of 9 shader, all of which are for opaque objects.

 

(1) vertex-vertex:

One of the simplest shader is that all the light that shines on the object is rendered in a pass, and the light source is calculated only in the vertex. Therefore, there will be no pixel-based rendering effects, such as normal mapping, light cookies, and shadows. this shader is very sensitive to model partitioning (the process of changing an object from geometric description to Polygon representation). If you place a point light source on a vertex very close to a cube, the shader is used for the cube, and the light source is only calculated in the corner. The shader Based on Pixel illumination has no requirements for partitioning, And the shader has a good effect on the circular highlight. If you want the effect in the above cases, you can consider using a shader Based on Pixel illumination or adding a model split. (Increase the number of vertices)

In general, the rendering cost of This shader is relatively small. This shader contains two subshader, which correspond to the consortable pipelines and fixed pipelines respectively. Shader is the most basic shader supported by all hardware. If the device supports compiling pipelines, use the subshader that can be compiled into pipelines; otherwise, use fixed pipelines.

 

(2) Diffuse:

Diffuse is based on a simple illumination model named lambertian. The illumination intensity decreases with the decrease of the angle between the surface and the incident angle (that is, the maximum intensity when the light is perpendicular to the surface ). The illumination intensity is only related to the angle and is not related to the camera. Because this is a pixel-based shader, he has the advantage of this type of shader, and he needs the device to support programmable pipelines. If the device does not support it, he will automatically use the vertex-pilot shader.

In general, the shader rendering cost is relatively small.

 

 

(3) specular

Specular uses the same illumination model as diffuse, but adds a reflection highlight related to the observed angle. This is called the BlinN-phong illumination model. It contains a reflection strong light, which reflects the surface angle of the high-gloss object, the incident angle of the light, and the observer angle. This method is actually a feasible simulation of real-time light source fuzzy reflection. The Blur level is controlled by the shininess variable in inspector.

The alpha channel of the main texture is used as a specular map (sometimes called gloss map), which defines the reflective rate of the object. The entire black part of the Alpha in the texture is completely non-reflective (I .e., the reflectivity is 0% ). In contrast, the full-white part has a back-rate of 100%. This map is useful when your object has different reflectivity in different parts. For example, rust-stained metals have a low reflective rate, while polished metals have a high reflective rate. Lipsticks are more reflective than skins, while skins are more reflective than cotton. A well-crafted specular
Map will allow players to experience the situation. If the target device does not support programmable pipelines, the shader vertex-pilot is automatically used.

The rendering cost of This shader is relatively high.

 

 

(4) bumped diffuse

Like diffuse shader, This shader is based on the lambertian illumination model and uses the Normal mapping technology to increase the surface details of objects. Normal mapping does not change the shape of an object, but uses a special texture called normal map to display the surface details of an object by adding a split. In normal map, the color of each pixel represents the normal of the object where the pixel is located, and then the light is calculated using this normal (instead of the normal calculated by the object model. Normal
In the process of computing illumination, map "efficiently modifies" the entire model.

How to create normal maps: You can import a normal grayscale image (White indicates convex, black indicates concave). Unity will automatically convert it to normal map.

Technical details: normal map is a type of "tangent space normal map". tangent space (tangent space) is a space that follows the surface of a model object. In this space, the Z axis always points from the surface to the outside. The tangent space normal map is a bit complicated than the "Object Space normal map", but it has some advantages. 1) it can be used on various strange surfaces.
2) facilitates reuse between different regions or objects of the same object

For details about the difference between tangent space normal map and Object Space normal map, I will talk about it next time.

If the shader fails to be called, The shader diffuse will be called. Generally, the shader rendering cost is low.

 

 

(5) bumped specular

The same illumination model as specular. Compared with Specular, it uses a tangent space normal map to describe the changes of the surface normal vectors of objects and increase the details of objects. (For details about the normal map, see bumpped diffuse.) If the call fails, use the shader specular. Generally, the rendering cost of This shader is relatively high.

 

(6) parallax diffuse

Parallax normal mapped is the same as normal mapped, but it is better to simulate "depth. The extra depth effect is achieved through the height map. Height map is saved in the alpha channel of normal map. Black indicates the height, while white indicates the height. This is usually used to show cracks between stones or bricks.

The technology of Parallax mapping is very simple, so there will be some manual traces or abnormal results. In particular, the steep height conversion should be avoided in the height chart. Adjust the height value in the inspector to adjust the height range. Sometimes the object is not real and messy. Therefore, we recommend that you use a height chart with a gentle change in height or set a low value to make the surface look gentle.

The rendering cost of This shader is higher than that of bumped diffuse. If the shader fails to be called, bumped diffuse is automatically used.

 

 

(7) parallax specular

Compared with bumped spcular, a height map is added to describe depth details. For details about height map, see parallax diffuse. If the call fails, the shader bumped specular is called.

 

 

 

(8) decal

The shader's description in the Unity document is significantly different from that in unity3.0. This document was written in due to its aging nature. It is written in built-in shader on the official website, decal is implemented using a programmable pipeline. That is to say, if your machine does not support a programmable pipeline, diffuse is used. Because diffuse does not require a programmable pipeline, you can only use vertex-pipeline. In addition to the main texture, the shader uses the second texture to describe details. The second decal texture uses the alpha channel to determine whether to overwrite the main texture. The texture used for the sticker is only a supplement to the main texture. For example, if you have a brick wall, you can use a brick texture as the main texture, and then use a decal texture with an alpha channel to graffiti in different places on the wall.

 

 

(9) Diffuse detail

This is a common diffuse shader with some additional data shader. It allows you to define the second texture, called detail texture. When camera approaches, detail texture is gradually displayed, which is generally used for terrain. For example, when you use a low-resolution texture to pull up to the entire terrain. As camera gradually draws closer, low-resolution textures start to blur, which is not what we want. To avoid this effect, create a detail
Texture tile the terrain. In this mode, as camera gets closer, extra details will appear to avoid blurring.

The detail texture overwrites the main texture. The deep part in the detail texture will make the winner texture deeper, while the light part will make the main texture brighter, and the detail texture is usually light gray. (Unlike the decal texture in decal, decal texture is rgba, decal texture and main texture are controlled by Alpha, while detail texture is RGB, the RGB channels of the two textures are multiplied by X 2, that is, the color values in the detail texture.
= 0.5 will not change the color of the main texture,> 0.5 will become brighter, <0.5 deepen)


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.