In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
The purpose of this article is to share with you what the image rendering process is in unity3d. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The related noun GPU (Graphic Processor Unit)
Graphics processing unit
GLSL (OpenGL Shading Language) coloring language
Is a language used for shading programming in OpenGL, that is, short custom programs written by developers, which are executed on the GPU of the graphics card, replacing part of the fixed rendering pipeline and making the different levels of the rendering pipeline programmable. For example: view conversion, projection conversion and so on. The shader code for GLSL is divided into two parts: Vertex Shader (vertex shader) and Fragment (fragment shader)
Vertex shader (VertexShader)
It is generally used to handle the transformation of each vertex of the graph (rotation / translation / projection, etc.)
Vertex shaders are programs used in OpenGL to calculate vertex attributes. Vertex shaders are programs that operate on a per-vertex basis, that is, each vertex data executes a vertex shader once, of course, in parallel, and the data of other vertices cannot be accessed during vertex shader operations.
Generally speaking, the typical vertex attributes that need to be calculated mainly include vertex coordinate transformation, lighting operation per vertex and so on. It is here that vertex coordinates are transformed from their own coordinate system to normalized coordinate system.
Chip element Shader Program (FragmentShader)
It is generally used to process the color calculation and filling of each pixel in the drawing.
A clip shader is a program in OpenGL that calculates the color of a clip (pixel). Fragment shaders are pixel-by-pixel programs, that is, each pixel executes the clip shader once, also in parallel.
Vertex & Vertex data
A vertex refers to the data of its vertex position when we draw a graph. This data can be stored directly in an array or cached in GPU memory.
To draw a picture, you usually draw the skeleton of the image, and then fill it with color. Vertex data is the skeleton of the image, and the image in OpenGL is composed of elements. In OpenGLES, there are three types of entities: points, lines, and triangles.
Vertex array (VertexArray) & vertex buffer (VertexBuffer)
Developers can choose to set function pointers and pass vertex data directly from memory when the drawing method is called, that is to say, this part of the data is previously stored in memory, which is called vertex array. A higher performance approach is to allocate a piece of video memory in advance and pass vertex data into the video memory in advance. This part of the video memory is called vertex buffer.
Rasterization (Rasterization)
It is the process of converting vertex data into chip elements, and the graph is transformed into images composed of grids. The mathematical description of the object and the color information related to the object are converted into the pixels used for the corresponding position on the screen and the colors used to fill the pixels.
Rasterization involves two parts of the work. First, determine which integer grid areas in the window coordinates are occupied by basic elements; second, assign a color value and a depth value to each area.
Textur
It can be understood as a picture.
Workflow for picture loading
UIImage * image = [UIImage imageWithContentsOfFile:@ "filePath"]
Load a picture from disk, and the picture is not unzipped at this time
ImageView.image = image
Then assign the generated UIImage to UIImageView, which confirms that the picture is displayed before CPU starts decoding
Then an implicit CATransaction captures the change of the UIImageView layer tree
When the next runloop of the main thread arrives, Core Animation submits the implicit transaction, which may copy the image.
Depending on factors such as whether the picture is byte aligned, this copy operation may involve some or all of the following steps:
Allocates memory buffers to manage file IO decompression operations.
Read file data from disk to memory.
The compressed picture data is decoded into an uncompressed bitmap form.
Finally, CALayer in Core Animation renders UIImageView layers with uncompressed bitmap data.
CPU calculates the Frame of the image. After the image is decompressed, it will be handed over to GPU to render the image.
Decompress
The decompression is performed by default in the main thread.
Decompressing an image is a very time-consuming CPU operation, so CPU decompresses it only when you confirm that you want to display it.
Unzipped images will be cached and will not be decompressed repeatedly.
The child thread is forced to decompress the picture in advance, and the principle of forced decompression is to redraw the picture to get a new decompressed bitmap. Among them, the core function used is CGBitmapContextCreate.
Specific division of labor in CPU / GPU rendering process
CPU: calculation view frame, image decoding, need to draw texture image through the data bus to GPU
GPU: texture blending, vertex transformation and calculation, pixel filling calculation, rendering to frame buffer.
Clock signal: vertical synchronization signal V-Sync / horizontal synchronization signal H-Sync.
IOS device double buffering mechanism: the display system usually introduces two frame buffers, which are accomplished by the cooperation of CPU and GPU.
Rendering proc
GPU acquires the coordinates of the picture
Hand the coordinates to the vertex shader (vertex calculation)
Rasterize the picture (get the pixels on the screen corresponding to the picture)
Chip element shader calculation (calculates the final displayed color value for each pixel)
Render from the frame cache to the screen
Thank you for reading! This is the end of the article on "what is the process of picture rendering in unity3d". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.