Animation rendering method and device based on 2D GPU perspective transformation technology
By using 2D GPU perspective transformation technology in the embedded system, key animation layers are determined and perspective transformation rendered, the problems of high CPU occupation and playback lag in 2.5D animation rendering under low hardware performance are solved, and efficient and smooth animation playback is achieved.
Patent Information
- Application Number
- CN202510496623.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-08-26
AI Technical Summary
It is difficult to achieve efficient 2.5D animation rendering and playback in embedded systems with low hardware performance, resulting in high CPU resource usage and stuttering playback.
Using 2D GPU perspective transformation technology, image processing is performed using 2D GPU by determining key animation layers, extracting basic plane images, calculating perspective transformation matrix, and performing perspective transformation and hybrid superimposed rendering.
Implement smooth 2.5D animation rendering in embedded systems with low hardware performance, reducing CPU and memory resource usage, and improving the real-time performance of animation playback.
Smart Images

Figure CN120543701A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a computer graphics rendering method. Background Art
[0002] Embedded systems lack graphics processing capabilities and hardware performance, making 3D image rendering difficult. 2.5D (pseudo-3D, also known as pseudo-3D or fake 3D) is a technology used in two-dimensional images, using 2D interfaces to transform images or scenes into 3D visual effects.
[0003] Implementing 2.5D animation rendering on low-performance embedded systems presents numerous challenges. A common approach is to export each frame of the 2.5D animation as a GIF or video file. Because embedded systems lack hardware decoding units, CPU software decoding of GIF or video files is required, despite CPU limitations. This 2.5D animation rendering method not only consumes significant CPU resources but can also cause playback lag when the embedded system is under heavy workloads. Summary of the Invention
[0004] The technical problem to be solved by this application is: how to achieve efficient 2.5D animation rendering and playback in an embedded system with low hardware performance.
[0005] To address the above-mentioned technical issues, the present application proposes an animation rendering method based on 2D GPU perspective transformation technology, comprising the following steps: Step S1: Determine the key animation layers of a 2.5D animation and extract the base plane image of each key animation layer. Step S2: Obtain the target coordinates and timestamps of the vertices of the image of each key animation layer in each frame. Step S3: When the embedded system needs to display a 2.5D animation, the 2D GPU calculates the perspective transformation matrix based on the original coordinates of the four vertices of the "base plane image of each key animation layer" and the target coordinates of the four vertices of the "image of each key animation layer in each frame." Step S4: The 2D GPU of the embedded system performs a perspective transformation on the corresponding base plane image based on the perspective transformation matrix of the "image of each key animation layer in each frame." After the perspective transformation, the images of different key animation layers in the same frame are mixed and overlaid and rendered, and the images are sent to the display buffer; the mixed and overlaid rendered images of each frame are displayed sequentially on the embedded system's display screen in the order of the timestamps.
[0006] Furthermore, in step S1, an automated script is first used to preliminarily screen out key animation layers from all animation layers of the 2.5D animation, and then manual analysis is performed to determine the final key animation layers.
[0007] Furthermore, in step S1, the base plane images of all key animation layers are saved as pictures or compressed formats that can be recognized by the 2D GPU of the embedded system, and are saved in a non-volatile memory of the embedded system.
[0008] Furthermore, in step S2, an automated script is used to first extract the local coordinates of the four vertices of the image in the respective layer coordinate systems from each key animation layer in each frame, and then obtain the four vertex coordinates in the plane coordinate system under the final rendering perspective through coordinate transformation, which are called target coordinates; the "plane coordinate system of the final rendering perspective" refers to the coordinate system established on a two-dimensional plane where all layers are projected onto the plane under the camera perspective.
[0009] Furthermore, in step S2, the target coordinates and timestamps of the vertices of the images of all key animation layers in all frames are saved in a lightweight text format that can be parsed by the CPU of the embedded system, and saved in a non-volatile memory of the embedded system.
[0010] Furthermore, in step S2, each frame of the 2.5D animation has a timestamp, and the target coordinates of the image extracted from the key animation layer of a certain frame use the timestamp of the frame.
[0011] Furthermore, in step S3, when the embedded system needs to display a 2.5D animation, the base plane image of each key animation layer of the 2.5D animation is loaded into the CPU's cache. The CPU decodes the base plane image of each key animation layer to obtain its width W and height H, thereby obtaining the original coordinates A(0,0), B(W,0), C(W,H), and D(0,H) of the four vertices of the base plane image of each key animation layer. The embedded system's CPU then parses the image to obtain the target coordinates A', B', C', and D' and timestamp of the four vertices of the image of each key animation layer in each frame. These two substeps may be performed either before or simultaneously. Finally, the embedded system's 2D GPU calculates a 3×3 perspective transformation matrix from the original coordinates to the target coordinates based on the original coordinates A, B, C, and D of the four vertices of the base plane image of each key animation layer and the target coordinates A', B', C', and D' of the four vertices of the image of each key animation layer in each frame.
[0012] Furthermore, after step S3 is executed, a corresponding perspective transformation matrix is calculated for the image of each key animation layer in each frame.
[0013] Furthermore, in step S4, the 2D GPU of the embedded system renders the "basic plane image of each key animation layer" from the cache to the display buffer with perspective transformation, and the perspective transformation utilizes the perspective transformation matrix corresponding to the basic plane image, thereby completing the transformation rendering of an image at that moment; other images of different key animation layers at that moment are also mixedly rendered from the cache to the display buffer with perspective transformation by the 2D GPU of the embedded system in the same way, thereby completing the mixed rendering of a frame of animation at that moment; the time interval of rendering different frames is controlled to meet the animation frame rate requirements; finally, the contents in the display buffer are sent to the display screen for display, and each frame of animation is displayed in the order of timestamps.
[0014] This application also proposes an animation rendering device based on 2D GPU perspective transformation technology, comprising a base plane image extraction unit, a target coordinate acquisition unit, a perspective transformation matrix calculation unit, and a perspective transformation and rendering unit. The base plane image extraction unit is used to identify key animation layers of a 2.5D animation and extract the base plane image of each key animation layer. The target coordinate acquisition unit is used to obtain the target coordinates and timestamps of the vertices of the image of each key animation layer in each frame. When an embedded system needs to display a 2.5D animation, the perspective transformation matrix calculation unit is used to calculate the perspective transformation matrix based on the original coordinates of the four vertices of the base plane image of each key animation layer and the target coordinates of the four vertices of the image of each key animation layer in each frame by the embedded system's 2D GPU. The perspective transformation and rendering unit is used to perform perspective transformation on the corresponding cached base plane image based on the perspective transformation matrix of the image of each key animation layer in each frame. After the perspective transformation, the images of different key animation layers in the same frame are mixed and overlaid and rendered on a channel-by-channel basis and sent to a display buffer. The mixed and overlaid rendered images of each frame are then displayed sequentially on the embedded system's display screen in the order of their timestamps.
[0015] The technical effect achieved by this application is: to realize smooth 2.5D animation rendering and playback in an embedded system with low hardware performance, and to use the 2D GPU (image processor) of the embedded system to perform perspective transformation on the plane image to realize efficient 2.5D animation rendering, which only requires extremely low CPU and memory resources. The drawing time of each frame of animation is very short and the real-time performance is high. It is particularly suitable for embedded systems with limited CPU performance and lack of hardware decoding units. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 This is a flowchart of the animation rendering method based on 2D GPU perspective transformation technology proposed in this application.
[0017] Figure 2 It is a diagram of the original coordinate position and target coordinate position of the base plane image in a certain frame of a key animation layer.
[0018] Figure 3 This is a structural diagram of the animation rendering device based on 2D GPU perspective transformation technology proposed in this application.
[0019] Description of the reference numerals in the figure: basic plane image extraction unit 1, target coordinate acquisition unit 2, perspective transformation matrix calculation unit 3, perspective transformation and rendering unit 4. DETAILED DESCRIPTION
[0020] See also Figure 1 The animation rendering method based on 2D GPU perspective transformation technology proposed in this application includes the following steps.
[0021] Step S1: Determine key animation layers for the 2.5D animation, extract the base plane images for each key animation layer, and save the base plane images for all key animation layers as images or compressed formats recognizable by the embedded system's 2D GPU. These files are stored in the embedded system's non-volatile memory (e.g., flash memory). The base plane images in these key animation layers serve as the basis for subsequent perspective transformations to form the 2.5D animation.
[0022] A 2.5D animation primarily consists of several key animation layers, in addition to camera layers, auxiliary layers, and so on. This step uses an automated script to initially screen the key animation layers from all the animation layers in the 2.5D animation, and then manually analyzes and determines the final key animation layers. For example, a 2.5D animation of a fluttering butterfly consists of a camera layer, two wing layers, a body layer, and the remaining auxiliary layers. An automated script removes the camera layer and some unnecessary auxiliary layers, ultimately manually determining the two wing layers and one body layer as the key animation layers.
[0023] Each key animation layer in each frame is an image. This step only extracts one image from each key animation layer, such as the image of each key animation layer in the first frame, which is called the base plane image of each key animation layer; the images of each key animation layer in subsequent frames are transformed based on their base plane images. For example, each wing layer in each frame is an image of a butterfly wing, and the shape, position, size, etc. of the wing images in different frames may be different. For another example, the body layer in each frame is an image of the butterfly body, and the shape, position, size, etc. of the body images in different frames may be different.
[0024] An example of an image format recognized by an embedded system's 2D GPU is a PNG image in RGBA8888 format, where the red, green, blue, and alpha (transparency) channels are each 8 bits. These image formats are supported by the 2D GPU and are easy to load and render in embedded devices.
[0025] An example of a compression format that can be recognized by a 2D GPU in an embedded system is ETC2. These compression formats are supported by 2D GPUs and are easy to load and render in embedded devices.
[0026] Step S2: Obtain the vertex coordinates (referred to as target coordinates) and timestamps of each key animation layer's image in each frame, and save the target coordinates and timestamps of the vertices of all key animation layers' images in all frames in a lightweight text format that can be parsed by the embedded system's CPU. The target coordinates are used for subsequent perspective transformation processing by the embedded system's 2D GPU.
[0027] For example, this step uses an automated script to first extract the local coordinates of the four vertices of each key animation layer in each frame, in their respective layer coordinate systems. Then, through coordinate transformation, the coordinates of the four vertices are obtained in the plane coordinate system of the final rendering perspective (called target coordinates). In most animation design software, multiple coordinate systems exist. One is the layer coordinate system, which is each layer's local coordinate system, with the anchor point being its coordinate origin. Another is the composite coordinate system, which is the coordinate system shared by all layers in the entire composition. This is also called the world coordinate system, with its origin in the upper left corner. The positive x-axis is horizontally to the right, the positive y-axis is vertically downward, and the positive z-axis is perpendicular to the screen. Finally, there is the camera coordinate system, a coordinate system established with the camera as its origin. The local coordinates here are referenced to the current layer coordinate system, with "local" referring to coordinates relative to the world coordinate system. The "plane coordinate system of the final rendering perspective" refers to the coordinate system established on the two-dimensional plane onto which all layers are projected from the camera's perspective.
[0028] Each frame of a 2.5D animation has a timestamp, and the target coordinates of the image extracted from the key animation layer of a certain frame use the timestamp of the frame.
[0029] The lightweight text format that the CPU of the embedded system can parse is, for example, JSON format or binary format. The "lightweight" feature can reduce the memory usage of the embedded system and speed up the data parsing of the CPU. These files are stored in the non-volatile memory (such as flash memory) of the embedded system.
[0030] Step S3: When the embedded system needs to display a 2.5D animation, the 2D GPU calculates a perspective transformation matrix based on the original coordinates of the four vertices of the "base plane image of each key animation layer" and the target coordinates of the four vertices of the "image of each key animation layer in each frame".
[0031] First, when the embedded system needs to display a 2.5D animation, the base plane image of each key animation layer of the 2.5D animation is loaded into the CPU cache. The CPU decodes the "base plane image of each key animation layer" to obtain the width W and height H of the "base plane image of each key animation layer", thereby obtaining the original coordinates A(0,0), B(W,0), C(W,H), and D(0,H) of the four vertices of the "base plane image of each key animation layer".
[0032] Subsequently, the CPU of the embedded system parses a lightweight text file that records the "target coordinates and timestamps of the vertices of the image of each key animation layer in each frame" to obtain the target coordinates A', B', C', D' and timestamps of the four vertices of the image of each key animation layer in each frame.
[0033] The order of the above two sub-steps is not limited and they can be performed in any order or at the same time.
[0034] Finally, the embedded system's 2D GPU calculates a 3×3 perspective transformation matrix from the original coordinates A, B, C, and D of the four vertices of the base plane image of each key animation layer to the target coordinates A', B', C', and D' of the four vertices of the image of each key animation layer in each frame. Each key animation layer image in each frame has a corresponding perspective transformation matrix.
[0035] See also Figure 2 The large rectangle represents the screen of the embedded system, with the upper left corner as the coordinate origin, the horizontal direction to the right as the x-axis, and the vertical direction downward as the y-axis. The shaded area on the left represents the base plane image of a key animation layer, which is a rectangle at the original coordinate position. The shaded area on the right represents the image of a key animation layer in a certain frame, which is an irregular trapezoid at the target coordinate position. The "base plane image of each key animation layer" and the "image of the key animation layer in each frame" are connected through the perspective transformation matrix. Before and after the perspective transformation, the shape, position, and size of the base plane image change.
[0036] Step S4: The embedded system's 2D GPU performs a perspective transformation on the cached base plane image based on the perspective transformation matrix of the image of each key animation layer in each frame. After the perspective transformation, the images of different key animation layers belonging to the same frame (i.e., with the same timestamp) are mixed and overlaid on a channel-by-channel basis and sent to the display buffer. The embedded system displays the mixed and overlaid rendered images of each frame on the display screen in the order of the timestamps.
[0037] In this step, the embedded system's 2D GPU uses the blit_rect() function to render the base plane image of each key animation layer from the cache into the display buffer with a perspective transformation. This perspective transformation utilizes the perspective transformation matrix corresponding to the base plane image, completing the transformation rendering of the image at that moment. The blit_rect() function copies an image block of a specified rectangular area from the source buffer, applies a matrix transformation, and renders it into the destination buffer. The embedded system's 2D GPU also uses the same method to blend and render other images of different key animation layers at that moment (i.e., with the same timestamp) from the cache into the display buffer with a perspective transformation, completing the blending rendering of a frame of animation at that moment. The time interval between rendering different frames is controlled to meet the animation frame rate requirements. Finally, the contents of the display buffer are sent to the display screen for display, where each frame of animation is displayed in the order of its timestamps.
[0038] See also Figure 3 The animation rendering device based on 2D GPU perspective transformation technology proposed in this application includes a basic plane image extraction unit 1, a target coordinate acquisition unit 2, a perspective transformation matrix calculation unit 3, and a perspective transformation and rendering unit 4. Figure 3 The device shown corresponds to Figure 1 The method shown.
[0039] The basic plane image extraction unit 1 is used to determine the key animation layers of the 2.5D animation, extract the basic plane image of each key animation layer, and save the basic plane images of all key animation layers as pictures or compressed formats that can be recognized by the 2D GPU of the embedded system.
[0040] The target coordinate acquisition unit 2 is used to obtain the target coordinates and timestamps of the vertices of the image of each key animation layer in each frame, and save the target coordinates and timestamps of the vertices of the images of all key animation layers in all frames in a lightweight text format that can be parsed by the CPU of the embedded system.
[0041] The perspective transformation matrix calculation unit 3 is used to calculate the perspective transformation matrix by the 2D GPU of the embedded system according to the original coordinates of the four vertices of the "base plane image of each key animation layer" and the target coordinates of the four vertices of the "image of each key animation layer in each frame" when the embedded system needs to display 2.5D animation.
[0042] The perspective transformation and rendering unit 4 is used to perform perspective transformation on the cached corresponding basic plane image according to the perspective transformation matrix of "the image of each key animation layer in each frame" by the 2D GPU of the embedded system, and the images belonging to the same frame after perspective transformation are mixed and superimposed and rendered by channel and sent to the display buffer; the mixed and superimposed rendered images of each frame are displayed in sequence on the display screen of the embedded system in the order of timestamps.
[0043] This application obtains the four vertex coordinates of each key animation layer in each frame of the 2.5D animation in advance and uses them as the target coordinates; uses the embedded system's 2D GPU to calculate its perspective transformation matrix based on the original coordinates and target coordinates of the four vertices of the base plane image; performs perspective transformation and rendering on the base plane image according to the perspective transformation matrix, and after mixing, forms a frame, which in turn forms a 2.5D animation. Compared with traditional GIF files and video playback methods, this application has the significant advantages of low memory usage and fast processing speed, and can achieve smooth 2.5D animation rendering and playback in embedded systems with limited CPU performance and lacking hardware decoding units.
[0044] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. An animation rendering method based on 2D GPU perspective transformation technology, characterized in that: The method includes the following steps: Step S1: determining the key animation layers of the 2.5D animation and extracting the base plane image of each key animation layer; Step S2: Obtain the target coordinates and timestamps of the vertices of the image of each key animation layer in each frame; Step S3: When the embedded system needs to display a 2.5D animation, the 2D GPU calculates a perspective transformation matrix based on the original coordinates of the four vertices of the "base plane image of each key animation layer" and the target coordinates of the four vertices of the "image of each key animation layer in each frame"; Step S4: The 2D GPU of the embedded system performs perspective transformation on the corresponding base plane image according to the perspective transformation matrix of "the image of each key animation layer in each frame", performs mixed overlay rendering on the images of different key animation layers belonging to the same frame after the perspective transformation, and sends them to the display buffer; the mixed overlay rendered images of each frame are displayed on the display screen of the embedded system in sequence according to the order of timestamps.
2. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S1, an automated script is first used to preliminarily screen out key animation layers from all animation layers of the 2.5D animation, and then a manual analysis is performed to determine the final key animation layers.
3. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S1, the base plane images of all key animation layers are saved as pictures or compressed formats that can be recognized by the 2D GPU of the embedded system, and are saved in the non-volatile memory of the embedded system.
4. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S2, an automated script is used to first extract the local coordinates of the four vertices of the image in the respective layer coordinate systems from each key animation layer in each frame, and then obtain the coordinates of the four vertices in the plane coordinate system at the final rendering perspective through coordinate transformation, which are called target coordinates. The "plane coordinate system of the final rendering perspective" refers to the coordinate system established on a two-dimensional plane where all layers are projected onto the plane from the camera perspective.
5. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S2, the target coordinates and timestamps of the vertices of the images of all key animation layers in all frames are saved in a lightweight text format that can be parsed by the CPU of the embedded system and stored in the non-volatile memory of the embedded system.
6. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S2, each frame of the 2.5D animation has a timestamp, and the target coordinates of the image extracted from the key animation layer of a certain frame use the timestamp of the frame.
7. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S3, when the embedded system needs to display a 2.5D animation, the base plane image of the key animation layer of the 2.5D animation is loaded into the CPU cache, and the CPU decodes the "base plane image of each key animation layer" to obtain the width W and height H of the "base plane image of each key animation layer", thereby obtaining the original coordinates A(0,0), B(W,0), C(W,H), and D(0,H) of the four vertices of the "base plane image of each key animation layer"; The CPU of the embedded system parses and obtains the target coordinates A', B', C', D' and timestamp of the four vertices of the image of each key animation layer in each frame; The above two sub-steps may be performed either in sequence or simultaneously; Finally, the embedded system's 2D GPU calculates a 3×3 perspective transformation matrix from the original coordinates A, B, C, and D of the four vertices of the "base plane image of each key animation layer" and the target coordinates A', B', C', and D' of the four vertices of the "image of each key animation layer in each frame." 8. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: After step S3 is executed, a corresponding perspective transformation matrix is calculated for the image of each key animation layer in each frame.
9. The animation rendering method based on 2D GPU perspective transformation technology according to claim 1 is characterized in that: In step S4, the 2D GPU of the embedded system renders the "base plane image of each key animation layer" from the cache to the display buffer with perspective transformation, and the perspective transformation uses the perspective transformation matrix corresponding to the base plane image, thereby completing the transformation rendering of an image at that moment; other images of different key animation layers at that moment are also mixed and rendered from the cache to the display buffer with perspective transformation in the same manner by the 2D GPU of the embedded system, thereby completing the mixed rendering of a frame of animation at that moment; the time interval of rendering different frames is controlled to meet the animation frame rate requirement; finally, the content in the display buffer is sent to the display screen for display, and each frame of animation is displayed in the order of the timestamps.
10. An animation rendering device based on 2D GPU perspective transformation technology, characterized in that: It includes a basic plane image extraction unit, a target coordinate acquisition unit, a perspective transformation matrix calculation unit, and a perspective transformation and rendering unit; The base plane image extraction unit is used to determine the key animation layers of the 2.5D animation and extract the base plane image of each key animation layer; The target coordinate acquisition unit is used to acquire the target coordinates and timestamps of the vertices of the image of each key animation layer in each frame; The perspective transformation matrix calculation unit is used to calculate the perspective transformation matrix by the 2D GPU of the embedded system according to the original coordinates of the four vertices of the "base plane image of each key animation layer" and the target coordinates of the four vertices of the "image of each key animation layer in each frame" when the embedded system needs to display 2.5D animation; The perspective transformation and rendering unit is used to perform perspective transformation on the cached corresponding basic plane image according to the perspective transformation matrix of "the image of each key animation layer in each frame" by the 2D GPU of the embedded system, and the images of different key animation layers belonging to the same frame after perspective transformation are mixed and superimposed and rendered by channel and sent to the display buffer; the mixed and superimposed rendered images of each frame are displayed in sequence on the display screen of the embedded system in the order of timestamps.