reprinted from the Wind Yu Chong Unity3d Tutorial College
The following content does not need to get started immediately read and understand, suggest gradually in-depth study, from time back to see can.
What is a GPU?gpu:graphic processing Unit, Chinese translates to "graphics processor". The graphics card includes (GPU, video memory, graphics card bios, graphics card PCB). What is shader?Shader Program: A program performed by the GPU that operates on a 3D object. What kinds of shader are there? CG: Fully compatible with DirectX 9.0 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 if you target Mac OS X or OpenGL ES 2.0) Why choose CG in shader?because CG/HLSL supports more platforms than GLSL. what does CG output in Unity3d? Windows platform: Direct3D, GPU assembler codeMAC:OPENGL GPU Assembler Codeflash:flash GPU Assembler Codeios/android:unity will convert CG into GLSL code. Summary: In addition to the mobile platform will convert CG into GLSL code, the rest of the platform is converted into assembly code. What is buffering? a buffer like the one known asColor Buffer/pixel Buffer: Stores the color that the point is about to display, the RGBA valueDepth Cache Depth buffer/z buffer: The depth at which the point is stored, zTemplate Cache stencil buffer: typically used as a limit rendering area. More advanced usage combines depth buffering, such as the template buffer value for a pixel that changes as it passes through the depth buffer test. Cumulative Cache Accumulation buffer: Similar to color buffering, it also stores an RGBA value. The cumulative cache is designed for compositing multiple images, and the cumulative cache provides a way to achieve "multiple exposure (multiple exposures)" in the scene at a good color resolution. Using the cumulative cache can produce many image effects to improve the authenticity of images, including: Anti-aliasing, motion blur, soft shadows, depth domains (depth of field), and convolution. To produce these effects, you must render the image several times, make small, incremental changes to the scene's location (or selected objects), and then accumulate the results. What is entity assembly (Primitive Assembly)transformed vertices are assembled into geometric entities What is rasterization (also translated Rasterize, rasterization)The term rasterize can be used for any process that transforms a vector graphic into a raster image. in 3D rendering, the process of converting elements (vectors) such as triangles into pixel fragments is the main point. Or the process that determines which pixel geometry is covered. The result of Rasterization is the collection of pixel locations and fragments What is raster operation (Raster operation)refers to the last sequence of operations performed before the frame cache is updated after the fragment fragment is processed. By including cropping, depth testing, alpha testing, alpha blending and more. is fragment fragment equal to pixels? Pixel point: the smallest image unit (which can be displayed on the screen)Pixel: The content of a pixel in a frame cache, usually a color. fragmentation: A state that updates the potential needs of a pixel. The fragment output is the color of the current fragment function at this pixel point and does not represent the final color of the pixel. The last color shown is the final result of all the fragments of this point being superimposed and so on. programs that operate on 3D objects and are executed by the GPU What is a terrain shader (Geometry Shader):geometry shaders can remove and delete vertices from the polygon mesh. It is able to perform the work of generating geometries that are too onerous for CPUs and adding model details. Direct3D version 10 adds an API that supports geometry shaders and becomes part of Shader Model 4.0. OpenGL can only use a geometry shader from one of its plugins, but it is most likely that the feature will be merged in version 3.1. The output of the geometry shader connects the input of the rasterizer. But it's not practical. What is tessellation?
For DX11. This technology consumes a lot of hardware resources, so the developer doesn't use it everywhere in the scene, typically only the player's view and silhouette edges are considered. With GPU hardware acceleration, the triangles of an existing 3D model are split to a finer, more granular level, which greatly increases the number of triangles, making the surfaces and edges of the rendered object smoother and finer.
Coordinates
In computer 3D, the 3D coordinate system is mainly used, Cartesian coordinate system (Cartesian coordinate system), also known as Cartesian coordinate system.
When the x-axis is right, Y is up, and Z is facing the screen, 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.
So, Unity uses a left-handed coordinate system.
D3D (x,y,z,w) z= z/w in the left-hand cutting space (0,1)
OpenGL uses the right hand, that is, in the clipping space (x,y,z,w) z= (z/w + 1)/2 i.e. [ -1,1]
#pragma target 3.0: Define the shader model for shader models 3.0,
2.0, Direct3D 9 (default default value). Supports 32 maps + 64 calculations
3.0, Direct3D 9. supports 512 maps + 512 calculations
4.0, only DirectX 11 is supported.
5.0,only supportDirectX 11.
Unity3d Tutorial Shader: Basics Basics