[Feng yuchong] The shader of the unity3d tutorial book: Basic knowledge

Source: Internet
Author: User

Basics: Basic knowledge



The following content does not need to be read and understood immediately when getting started. It is recommended that you come back from time to time for further study.

What is GPU? GPU: Graphic Processing Unit ". Graphics cards include (GPU, video memory, video card bios, and graphics card PCB ). What is shader? Shader program: GPU-executed program that operates on 3D objects.
What types of shader are available? CG: fully compatible with DirectX 9.0 or later and OpenGL. Compile the GPU assembly code at runtime or in advance. HLSL: Mainly used for direct3d. Platform: Windows. Glsl: Mainly used for OpenGL.Platform: mobile platform (IOS, Android), MAC (only use when you target Mac OS X or OpenGL ES 2.0)
Why select CG in the shader? Because CG/HLSL supports more platforms than glsl.
What is CG output in unity3d? Windows platform: direct3d, GPU assembly code Mac: OpenGL GPU assembly code FLASH: Flash GPU assembly code IOS/Android: unity will convert CG to glsl code. Conclusion: In addition to converting CG to glsl code on the mobile platform, other platforms are converted to assembly code.
What is buffering? A pixel has the following buffer color cache color buffer/Pixel Buffer: stores the color of the point to be displayed, rgba value depth cache depth buffer/Z buffer: stores the depth of the point, Z template Buffer: generally used to restrict rendering areas. For more advanced usage, You need to combine the depth buffer. For example, the template buffer value of a pixel will change as it passes the depth buffer test. Cumulative cache accumulation Buffer: similar to the color buffer, it also stores an rgba value. The cumulative cache is designed to synthesize multiple images. The cumulative cache provides a way to achieve "multiple exposures (multiple
Exposures. Using the cumulative cache can produce a lot of image effects to improve the authenticity of the image, including: Anti-sample, motion blur, soft shadow, depth field (depth of field) and convolution. To produce these effects, the image must be rendered multiple times, the scene location (or the selected object) must be slightly changed, incrementally changed, and then the results are accumulated.
What is a primitive assembly? transformed vertices are fitted with geometric elements.
What is Rasterization (Rasterization) the term Rasterization can be used to convert a vector image into a raster image. 3D rendering mainly refers to the process of converting triangles and other elements (vectors) into pixel fragments. Or decide which pixel geometric elements are covered. The raster result is a set of pixel locations and fragments.
What is raster operation? It refers to a series of operations last executed after fragment is processed and before the frame cache is updated. Through cropping, deep testing, Alpha testing, Alpha mixing, etc.
Is fragment equal to pixel? Pixel (displayed on the screen) Minimum image unit pixel: the content of a pixel in the frame cache, usually the color. Fragment: A potential State required to update a pixel. Fragment outputs the color of the current fragment function in this pixel, which does not represent the final color of this pixel. The color shown at the end is the final result of the superposition of all fragments of the vertex.
Programs that operate on 3D objects and are executed by GPU
Geometry shader: The ry shader can add or delete vertices from a polygon mesh. It can generate geometric structures and increase model details too heavily for the CPU. Direct3d version 10 adds an API that supports geometric coloring devices,
Become part of the Shader Model 4.0. OpenGL can only use one of its plug-ins to use the geometric coloring tool, but it is very likely that this function will be merged in version 3.1. The output of the geometric shader is connected to the input of the grating. But it is not practical.
What is tessellation?
For dx11. this technology consumes a large amount of hardware resources, so developers will not use it everywhere in the scenario. Generally, they only consider the player's perspective and outline edge. Using GPU hardware acceleration, you can split the existing 3D model triangles into smaller and more meticulous triangles, that is, greatly increasing the number of triangles to make the rendering object surface and edge smoother and finer.


                                Coordinate System

In computer 3D, the 3D coordinate system is mainly used,The Cartesian coordinate system, also known as the Cartesian coordinate system.
When the X axis is right, Y is up, and Z is in the screen, it is the left-hand coordinate system.
When the X axis is right, Y is up, and Z is facing you outside the screen, it is the right-hand coordinate system.
Therefore, unity uses the left-hand coordinate system.
D3d left-hand refers to the cropped space (X, Y, Z, W) z = z/W[0, 1]
OpenGL uses the right hand, that is, in the cropping space (X, Y, Z, W) z = (z/W + 1)/2, that is, [-]

# Maid target 3.0  : Defines the Shader Model as Shader Model 3.0,
2.0, direct3d 9 (default ). Supports 32 maps + 64 computations
3.0,
Direct3d 9. Supports 512 maps + 512 computations
4.0,
Only DirectX 11 is supported.
5.0,
Only DirectX is supported.
11.

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.