Image rendering method and device, electronic device, and storage medium
By adjusting the H5 game rendering order to merge non-overlapping batches and using valid pixel area judgment, the problem of screen freeze caused by multiple rendering batches was solved, and rendering performance and accuracy were improved.
Patent Information
- Application Number
- CN202210590642.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-05-27
AI Technical Summary
Existing technologies make it difficult to effectively reduce rendering batches and improve single-batch rendering efficiency in H5 games, resulting in screen freezes. Existing methods such as merging consecutive batches of the same material, texture synthesis, and dynamic merging of batches have problems such as unsatisfactory results or large judgment errors.
By obtaining the initial rendering order and material information of the image to be rendered, adjusting the rendering order to merge non-overlapping batches, and using the bounding box of the valid pixel area when judging coverage, the rendering batches are reduced and the hit rate of reading map information from the cache is improved.
Without affecting the original image effect, it effectively reduces rendering batches, improves rendering performance, reduces screen freezes, and enhances the accuracy and efficiency of the rendering process.
Smart Images

Figure CN114949848B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and in particular to an image rendering method and device, an electronic device, and a storage medium. BACKGROUND
[0002] H5 games refer to web games on mobile terminals, which do not need to download game packages, and the mobile terminal can directly play games in the mobile terminal browser in a networked state. H5 games are a popular game type on the market at present.
[0003] One of the bases for achieving the feature of H5 games that they can be played immediately upon clicking is the smoothness of the game screen. The smoothness requires that the speed of generating image frames reach a certain requirement. Each image frame contains multiple different controls, and therefore, the process of generating an image frame is the process of rendering multiple controls in the image. Generally, one control corresponds to one rendering batch, and a rendering request is submitted for each batch processed. If the number of batches rendered is large, it is difficult to ensure that each batch is processed in time, and if it cannot be processed in time, it will cause the screen to lag. Therefore, reducing the number of rendering batches and improving the rendering efficiency of a single batch are methods for improving rendering performance and are also methods for improving the smoothness of the screen.
[0004] In the prior art, there are generally three ways to improve rendering performance. The first way is to reduce the number of rendering batches by merging batches of continuous same materials, but in fact, batches of continuous same materials occur less frequently, and therefore, the actual effect of this method is not ideal. The second way is to combine all the batches of maps into one to reduce the number of rendering batches, but in fact, the interface is complex and variable, and the use of the map combination method not only cannot meet the actual demand, but also requires manual intervention, has high production requirements and high cost. The third way is to dynamically merge batches, that is, for two batches A and B of the same material, it is determined whether all batches between the two batches have a covering relationship with batch B, and if not, batches A and B are merged to reduce the number of rendering batches. Although the third way is better than the first way in reducing the number of rendering batches, and the third way can be applied to a larger range of scenarios than the second way, the third way only considers reducing the number of rendering batches and cannot improve the rendering efficiency of a single batch, so the effect is still not ideal. Moreover, in the process of determining whether the two batches have a covering relationship, the third way uses the map information of the batch, that is, the map size, but in fact, the map size is generally larger than the map visible area, and using the map size to determine whether the two batches have a covering relationship will increase the probability of the determination result being covering, which will also affect the merging of the batches.
[0005] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. Summary of the Invention
[0006] In view of the above problems, the present application is proposed to provide an image rendering method and apparatus, an electronic device, and a storage medium that overcome the above problems or at least partially solve the above problems, including:
[0007] An image rendering method, the method comprising:
[0008] Obtaining the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information;
[0009] Searching for a first batch and a second batch with the same texture information in all the batches, and obtaining a first intermediate batch between the first batch and the second batch according to the initial rendering order;
[0010] determining whether the second batch and the first intermediate batch overlap each other; if the second batch and the first intermediate batch do not overlap each other, adjusting the rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch, and updating the initial rendering order to obtain the first rendering order;
[0011] Searching for a third batch and a fourth batch with the same material information among batches with a continuous first rendering order and the same mapping information, and obtaining a second intermediate batch between the third batch and the fourth batch;
[0012] If the fourth batch and the second intermediate batch do not overlap each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch.
[0013] An image rendering method, the method comprising:
[0014] Obtaining the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information;
[0015] Searching for a fifth batch and a sixth batch having the same material information among all the batches, and obtaining a third intermediate batch between the fifth batch and the sixth batch according to the initial rendering order;
[0016] If the sixth batch and the third intermediate batch do not overlap each other, or the third intermediate batch cannot be obtained, merging the sixth batch and the fifth batch into one batch, and updating the initial rendering order to obtain a third rendering order;
[0017] Searching for a seventh batch and an eighth batch having the same texture information among all batches corresponding to the third rendering order, and obtaining a fourth intermediate batch between the seventh batch and the eighth batch according to the third rendering order;
[0018] If the eighth batch and the fourth intermediate batch do not overlap each other, the rendering order of the eighth batch is adjusted so that the rendering order of the eighth batch is continuous with the rendering order of the seventh batch.
[0019] An image rendering method, the method comprising:
[0020] Obtaining the initial rendering order of all batches in the image to be rendered, and the material information of all batches, wherein the material information includes mapping information; the mapping information includes valid pixel areas and invalid pixel areas;
[0021] Searching for a ninth batch and a tenth batch having the same material information among all the batches, and obtaining a fifth intermediate batch between the ninth batch and the tenth batch according to the initial rendering order;
[0022] determining whether the tenth batch and the fifth intermediate batch overlap each other based on the valid pixel area in the mapping information of the tenth batch and the valid pixel area in the mapping information of the fifth intermediate batch;
[0023] If the tenth batch and the fifth intermediate batch do not overlap each other, or the fifth intermediate batch cannot be obtained, the tenth batch and the ninth batch are merged into one batch.
[0024] An image rendering device, comprising:
[0025] A first acquisition module is used to acquire the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information;
[0026] A second acquisition module is configured to search for a first batch and a second batch having the same texture information in all the batches, and acquire a first intermediate batch between the first batch and the second batch according to the initial rendering order;
[0027] a first adjusting module configured to adjust a rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch if the second batch and the first intermediate batch do not overlap each other, and to update the initial rendering order to obtain a first rendering order;
[0028] The third obtaining module is configured to, in the batches that are continuous in the first rendering sequence and have the same mapping information, find third and fourth batches that have the same material information, and obtain a second intermediate batch between the third and fourth batches.
[0029] The first merging module is configured to, if the fourth batch and the second intermediate batch do not overlap with each other or the second intermediate batch cannot be obtained, merge the fourth batch and the third batch into one batch.
[0030] An image rendering device, the device comprising:
[0031] The fourth obtaining module is configured to obtain an initial rendering sequence of all batches in a to-be-rendered image, and material information of all batches, the material information including mapping information.
[0032] The fifth obtaining module is configured to find fifth and sixth batches that have the same material information in the all batches, and obtain a third intermediate batch between the fifth and sixth batches according to the initial rendering sequence.
[0033] The second merging module is configured to, if the sixth batch and the third intermediate batch do not overlap with each other or the third intermediate batch cannot be obtained, merge the sixth batch and the fifth batch into one batch, and update the initial rendering sequence to obtain a third rendering sequence.
[0034] The sixth obtaining module is configured to find seventh and eighth batches that have the same mapping information in all batches corresponding to the third rendering sequence, and obtain a fourth intermediate batch between the seventh and eighth batches according to the third rendering sequence.
[0035] The second adjusting module is configured to, if the eighth batch and the fourth intermediate batch do not overlap with each other, adjust the rendering sequence of the eighth batch so that the rendering sequence of the eighth batch is continuous with the rendering sequence of the seventh batch.
[0036] An image rendering device, the device comprising:
[0037] The seventh obtaining module is configured to obtain an initial rendering sequence of all batches in a to-be-rendered image, and material information of all batches, the material information including mapping information; the mapping information including a valid pixel region and an invalid pixel region.
[0038] The eighth obtaining module is configured to find ninth and tenth batches that have the same material information in the all batches, and obtain a fifth intermediate batch between the ninth and tenth batches according to the initial rendering sequence.
[0039] an overlap determination module, configured to determine whether the tenth batch and the fifth intermediate batch overlap each other based on the valid pixel area in the mapping information of the tenth batch and the valid pixel area in the mapping information of the fifth intermediate batch;
[0040] The third merging module is configured to merge the tenth batch and the ninth batch into one batch if the tenth batch and the fifth intermediate batch do not overlap each other or the fifth intermediate batch cannot be obtained.
[0041] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the image rendering method described above when executed by the processor.
[0042] A computer-readable storage medium stores a computer program, which implements the steps of the image rendering method described above when executed by a processor.
[0043] This application has the following advantages:
[0044] In an embodiment of the present application, by obtaining the initial rendering order of all batches in the image to be rendered, and the material information of all batches, the material information includes mapping information; searching for the first batch and the second batch with the same mapping information in all batches, and obtaining the first intermediate batch between the first batch and the second batch according to the initial rendering order; if the second batch and the first intermediate batch do not overlap each other, adjusting the rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch, and updating the initial rendering order to obtain the first rendering order; in the batches with continuous first rendering order and the same mapping information, searching for the third batch and the fourth batch with the same material information, and obtaining the second intermediate batch between the third batch and the fourth batch; if the fourth batch and the second intermediate batch do not overlap each other, or the second intermediate batch does not exist, merging the fourth batch and the third batch into one batch; it is possible to effectively reduce the rendering batches without affecting the original effect of the image to be rendered. In addition, the embodiment of the present application also adjusts the rendering order of batches with different material information but the same mapping information to be continuous, which can increase the hit rate of reading mapping information from the cache during the rendering process, reduce the number of times mapping data is loaded from the video memory, and improve rendering performance and reduce screen freezes.
[0045] Furthermore, in the process of determining whether two batches overlap each other, the embodiment of the present application makes a determination based on the effective pixel area in the mapping information of the batches, which can reduce misjudgments and improve the accuracy of the determination results.
[0046] Of course, any product implementing the present application does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the description of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0048] Figure 1 This is a flowchart of the steps of an image rendering method according to an embodiment of the present application;
[0049] Figure 2 A schematic diagram of a texture map corresponding to a control of a sequence frame animation effect according to an embodiment of the present application;
[0050] Figure 3 A schematic diagram of a data reading process of a cache system and a processing core of an image processing hardware according to an embodiment of the present application;
[0051] Figure 4 A flowchart of another image rendering method according to an embodiment of the present application;
[0052] Figure 5 This is a flowchart of the steps of another image rendering method according to an embodiment of the present application;
[0053] Figure 6 A schematic diagram of a rendering tree of an image to be rendered in an example of this application;
[0054] Figure 7 Schematic diagram of the relationship between the effective pixel areas and the texture information corresponding to special effects 1, 2, and 3 in an example of this application;
[0055] Figure 8 A schematic diagram of a rendering tree of an image to be rendered in an example of this application;
[0056] Figure 9 A schematic diagram of a rendering tree of an image to be rendered in another example of the present application;
[0057] Figure 10 This is a schematic diagram of a rendering tree of an image to be rendered in another example of the present application. DETAILED DESCRIPTION
[0058] To make the above-mentioned purposes, features, and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and specific embodiments. It is apparent that the embodiments described are only a portion of the embodiments of this application, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments in this application without inventive effort are also within the scope of protection of this application.
[0059] Rendering, also known as drawing, refers to the process of generating an image based on data. Computer programs create a vivid visual experience by repeatedly rendering images and then displaying them on the screen. It can be seen that the program rendering performance (that is, the number of image frames that can be rendered per second, or the rendering time required for each frame of image) is an important factor in determining whether the picture can be presented smoothly. The level of rendering performance is related to the number of rendering batches and the speed at which each rendering batch is processed. In the prior art, the methods for improving rendering performance are not ideal. For details, please refer to the description in the background technology section.
[0060] In view of this, an embodiment of the present application provides an image rendering method, which obtains the initial rendering order of all batches in the image to be rendered, and the material information of all batches, the material information including the texture information. When different batches do not overlap each other, their rendering order can be adjusted to merge batches with the same material information into one batch for rendering, which can effectively reduce the rendering batches without affecting the original effect of the image to be rendered; continuously rendering batches with different material information but the same texture information can increase the hit rate of reading the texture information from the cache during the rendering process and reduce the number of times the texture data is loaded from the video memory; in addition, in the process of judging whether two batches overlap each other, the judgment is made based on the effective pixel area in the texture information of each batch, rather than based on the complete size information in the texture information, which can reduce misjudgment and improve the accuracy of the coverage judgment result; ultimately, the rendering performance is improved and the screen freeze effect is reduced.
[0061] Reference Figure 1 , shows a flowchart of the steps of an image rendering method provided by an embodiment of the present application. In the embodiment of the present application, the method may include the following steps:
[0062] Step 101: obtaining the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information;
[0063] Step 102: searching for a first batch and a second batch having the same texture information in all the batches, and obtaining a first intermediate batch between the first batch and the second batch according to the initial rendering order;
[0064] In step 103, it is judged whether the second batch and the first intermediate batch cover each other. If the second batch and the first intermediate batch do not cover each other, the rendering order of the second batch is adjusted so as to make the rendering order of the second batch continuous with the rendering order of the first batch, and the initial rendering order is updated to obtain a first rendering order.
[0065] In step 104, in the batches with the same first rendering order and the same map information, a third batch and a fourth batch with the same material information are searched, and a second intermediate batch between the third batch and the fourth batch is obtained.
[0066] In step 105, if the fourth batch and the second intermediate batch do not cover each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch.
[0067] In the embodiment of the present application, the initial rendering order of all batches in a to-be-rendered image and the material information of all batches are obtained, the material information including map information. In all batches, a first batch and a second batch with the same map information are searched, and a first intermediate batch between the first batch and the second batch is obtained according to the initial rendering order. It is judged whether the second batch and the first intermediate batch cover each other. If the second batch and the first intermediate batch do not cover each other, the rendering order of the second batch is adjusted so as to make the rendering order of the second batch continuous with the rendering order of the first batch, and the initial rendering order is updated to obtain a first rendering order of all batches. In the batches with the same first rendering order and the same map information, a third batch and a fourth batch with the same material information are searched, and a second intermediate batch between the third batch and the fourth batch is obtained. If the fourth batch and the second intermediate batch do not cover each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch. The rendering batches can be effectively reduced without affecting the original effect of the to-be-rendered image. In addition, the rendering batches with different material information but the same map information are adjusted to have a continuous rendering order, which can increase the hit rate of reading map information from a cache in a rendering process, reduce the number of times of loading map data from a display memory, improve rendering performance, and reduce picture lag.
[0068] In the following, the image rendering method in the example embodiment will be further described.
[0069] In step 101, the initial rendering order of all batches in a to-be-rendered image and the material information of all batches are obtained, the material information including map information.
[0070] In this embodiment, the electronic device can determine the image to be rendered according to a predetermined frame rate, or it can determine the image to be rendered by receiving relevant operations from the user, and this application does not impose any restrictions on this. The image to be rendered is composed of multiple controls, each control corresponds to a batch, and the initial rendering order refers to the rendering queue of the batch corresponding to all controls in the image to be rendered, which can be obtained by performing a depth-first traversal on the rendering tree of the image to be rendered. It can be understood that in the process of designing the image to be rendered, the designer will use the rendering tree method to determine the rendering order corresponding to each control. When the controls are rendered according to the rendering order of the rendering tree, an image that meets the requirements can be obtained.
[0071] Material information refers to a collection of texture information and other information, where the other information may include lighting data information, rendering status data information, etc. It can be understood that controls with the same material information have the same visual properties.
[0072] Step 102 : searching for a first batch and a second batch having the same texture information in all the batches, and obtaining a first intermediate batch between the first batch and the second batch according to the initial rendering order.
[0073] Typically, within the render queue for a single frame, there are multiple batches with identical texture information. The first and second batches are used to distinguish between batches, and there's no mandatory order of precedence. In other words, the first batch can be rendered before or after the second batch.
[0074] Exemplarily, the process of searching for the first batch and the second batch with the same texture information may include: searching for the second batch with the same texture information as the first batch after the rendering order based on the first batch with the earlier rendering order, or searching for the second batch with the same texture information as the first batch after the rendering order based on the first batch with the later rendering order.
[0075] The first intermediate batch can be a single batch or multiple batches. For example, in render queues A, B, C, D, E, and F, if batches A and E use the same texture information, then the first batch is batch A, the second batch is batch E, and the first intermediate batch includes batches B, C, and D. If the first batch is adjacent to the second batch, the first intermediate batch does not exist and can be ignored.
[0076] Step 103: Determine whether the second batch and the first intermediate batch overlap each other. If the second batch and the first intermediate batch do not overlap each other, adjust the rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch, and update the initial rendering order to obtain the first rendering order.
[0077] When two batches overlap each other, it means that the change in the rendering order of the two batches will affect the final presentation effect; when the two batches do not overlap each other, it means that the change in the rendering order of the two batches will not affect the final presentation effect. Therefore, in this embodiment, when it is determined that the second batch and the first intermediate batch do not overlap each other, the rendering order of the second batch is adjusted so that the rendering order of the two batches with the same mapping information is continuous; after adjusting the rendering order of all batches with the same mapping information, the initial rendering order of all batches is updated to obtain the first rendering order of all batches. Among them, when the first intermediate batch includes multiple batches, determining that the second batch and the first intermediate batch do not overlap each other means that the second batch and all batches of the first intermediate batch do not overlap each other. Specifically, whether the second batch and the first intermediate batch overlap each other can be determined by judging whether each batch of the second batch and the first intermediate batch overlaps each other.
[0078] For example, assuming that the initial rendering order is six batches of A, B, C, D, E, and F, batch A and batch E use the same texture information, batch B uses the same texture information as batch D and batch F, and all batches do not overlap each other. Through the above step 103, A and E can be adjusted to adjacent positions, and B can be adjusted to adjacent positions with D and F, resulting in a first rendering order of: A, E, B, D, F, C, or a first rendering order of: C, A, E, B, D, F, or a first rendering order of: A, E, C, B, D, F, or a first rendering order of: B, D, F, C, A, E.
[0079] In some optional embodiments of the present application, the process of determining whether the second batch and the first intermediate batch overlap each other, that is, the process of determining whether the two batches overlap each other, may include:
[0080] Determining a bounding box of the second batch based on the mapping information of the second batch, and determining a bounding box of the first intermediate batch based on the mapping information of the first intermediate batch;
[0081] Determine whether the bounding boxes of the second batch overlap with the bounding boxes of the first intermediate batch;
[0082] If there is overlap, the second batch and the first intermediate batch are determined to cover each other;
[0083] If there is no overlap, it is determined that the second batch and the first intermediate batch do not overlap each other.
[0084] In this embodiment, the texture information may refer to the size of the texture, and the bounding box may include an axial bounding box, an oriented bounding box, a polygon mesh bounding box, etc. For ease of calculation, an axial bounding box, such as an AABB bounding box, is preferred. To determine whether the bounding boxes of the second batch overlap with the bounding boxes of the first intermediate batch, a collision may be detected between the bounding boxes of the second batch and the bounding boxes of the first intermediate batch. If no collision occurs, it is determined that the second batch and the first intermediate batch do not overlap. If there is a collision between the bounding box of the second batch and the bounding box of any batch in the first intermediate batch, it is determined that the second batch and the first intermediate batch overlap.
[0085] This embodiment uses a bounding box to determine whether there is an overlapping relationship between two batches, which can reduce computational complexity and improve the efficiency of determining whether the rendering order of the two batches can be adjusted.
[0086] In some scenarios, the map information may include valid pixel areas and invalid pixel areas, where the valid pixel area refers to the area composed of pixels with a transparency not equal to 0 (i.e., the Alpha value is not 0), also known as the visible area; the invalid pixel area refers to the area composed of pixels with a transparency of 0 (i.e., the Alpha value is 0). It can be understood that the valid pixel area is less than or equal to the map size.
[0087] For example, refer to Figure 2 For the texture corresponding to a control of a sequence frame animation effect, in order to facilitate calculation, the maximum effective pixel area of all frame images of the sequence frame animation effect of the control is generally used as the texture size of each frame image of the control, such as Figure 2 The controls for the sequence frame animation effect include three frames of images. The maximum effective pixel area of the three frames corresponds to a texture size of w×h. However, for one of the frames, only a part of the texture is actually used. For example, Figure 2 When displaying a frame, the actual portion of the texture used is the valid pixel area in the texture information of that frame. Therefore, directly using the texture information to determine the bounding box will increase the probability of collision between the two batches, thereby affecting the effectiveness of the adjustment order and the subsequent batch merging.
[0088] Therefore, in the case where the map information includes valid pixel areas and invalid pixel areas, in some optional embodiments of the present application, before the above-mentioned if the second batch and the first intermediate batch do not overlap each other, a process of determining whether the second batch and the first intermediate batch overlap each other is further included. This process may include:
[0089] Determine a bounding box of the second batch according to the valid pixel area in the mapping information of the second batch, and determine a bounding box of the first intermediate batch according to the valid pixel area in the mapping information of the first intermediate batch;
[0090] Determine whether the bounding boxes of the second batch overlap with the bounding boxes of the first intermediate batch;
[0091] If there is overlap, the second batch and the first intermediate batch are determined to cover each other;
[0092] If there is no overlap, it is determined that the second batch and the first intermediate batch do not overlap each other.
[0093] The process of determining the valid pixel area in each batch of mapping information may include:
[0094] Obtain all pixel data in each batch of texture information in the image to be rendered;
[0095] Determine whether the pixel data is a valid pixel according to the Alpha value in the pixel data;
[0096] The valid pixel area corresponding to the mapping information is determined according to the determined valid pixel points.
[0097] Exemplarily, all pixel data in the mapping information of each batch in the image to be rendered can be obtained offline, and whether the pixel data is a valid pixel can be determined based on the Alpha value in the pixel data. Based on all the valid pixels determined, the valid pixel area of the mapping information can be determined, and then, the corresponding bounding box can be determined based on the valid pixel area, and the information of the bounding box of each batch can be recorded in the configuration file corresponding to the image to be rendered, or the information of the valid pixel area of each batch can be recorded in the configuration file corresponding to the image to be rendered.
[0098] For example, in determining the bounding box, the normalized device coordinate system can be used to determine the maximum and minimum values of the valid pixel area on the X axis, as well as the maximum and minimum values on the Y axis. These four values can be used to obtain the corresponding minimum AABB bounding box. The advantage of using the normalized device coordinate system is that it eliminates the need for coordinate conversion.
[0099] This embodiment uses the valid pixel area in each batch's texture information to determine the corresponding bounding box. Compared to methods that directly use texture information to determine the corresponding bounding box, this reduces the probability of collision between batches and improves the effectiveness of reordering and subsequent batch merging. Furthermore, by combining offline calculations, this improves the effectiveness of merging and reordering without affecting data processing speed during rendering.
[0100] In step 104 , among the batches with the first rendering sequence being continuous and with the same mapping information, a third batch and a fourth batch with the same material information are searched, and a second intermediate batch between the third batch and the fourth batch is obtained.
[0101] After adjusting the batches with the same texture information to a continuous rendering order, this embodiment searches for the third and fourth batches with the same material information from all batches with a continuous rendering order and the same texture information, and obtains the second intermediate batch between the third and fourth batches.
[0102] Among them, the process of searching for the third and fourth batches with the same material information is similar to the process of searching for the first and second batches with the same texture information as mentioned above. The rendering order of the third batch can be before or after the fourth batch; the fourth batch with the later rendering order and the same material information as the third batch can be searched based on the third batch with the earlier rendering order, or the fourth batch with the earlier rendering order and the same material information as the third batch can be searched based on the third batch with the later rendering order.
[0103] For example, the initial rendering order is six batches of A, B, C, D, E, and F. Batch A and batch E use the same material information (including the same texture information), batch B and batch F use the same material information, and also use the same texture information as batch D, and all batches do not overlap. After processing through steps 101-103 above, six batches are obtained with a first rendering order of C, A, E, B, D, and F. Among the batches with a continuous first rendering order and the same texture information, the third and fourth batches with the same material information are searched. Assuming that the third batch is F, the fourth batch with the same material information as F is searched among B, D, and F. At this time, the fourth batch is B, and the second intermediate batch between the third and fourth batches is batch D.
[0104] Step 105: If the fourth batch and the second intermediate batch do not overlap each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch.
[0105] When it is determined that the fourth batch and the second intermediate batch do not overlap with each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch. It can be understood that the rendering content of the fourth batch is merged into the rendering content of the third batch. After all batches with the same material information are merged, the first rendering order of all batches is updated to form a second rendering order. Among them, when the second intermediate batch includes multiple batches, determining that the fourth batch and the second intermediate batch do not overlap with each other means that the fourth batch and all batches of the second intermediate batch do not overlap with each other. Specifically, whether the fourth batch and the second intermediate batch overlap with each other can be determined by judging whether each batch of the fourth batch and the second intermediate batch overlaps with each other.
[0106] Continuing with the above example, assume that the first rendering order is six batches of C, A, E, B, D, and F. Batch A uses the same material information as batch E, and batch B uses the same material information as batch F. They also use the same texture information as batch D, and all batches do not overlap with each other. According to steps 104 and 105, it can be determined that batch A and batch E have the same material information and there is no second intermediate batch. In this case, batch A and batch E are directly merged to obtain batch AE. Batch B has the same material information as batch F and does not overlap with the second intermediate batch D. Therefore, batch B and batch F can be merged to obtain batch BF, and then the first rendering order is updated to form a second rendering order of: C, AE, D, BF, that is, the rendering batches at this time are 4 batches, which is less than the initial 6 rendering batches. In addition, batch D and batch BF, which have the same texture information, are adjacent in rendering order.
[0107] In some optional embodiments of the present application, before the above-mentioned if the fourth batch and the second intermediate batch do not overlap each other, a process of determining whether the fourth batch and the second intermediate batch overlap each other is further included. This process may include:
[0108] Determining a bounding box of the fourth batch based on the mapping information of the fourth batch, and determining a bounding box of the second intermediate batch based on the mapping information of the second intermediate batch;
[0109] Determine whether the bounding boxes of the fourth batch overlap with the bounding boxes of the second middle batch;
[0110] If there is overlap, the fourth batch and the second intermediate batch are determined to cover each other;
[0111] If there is no overlap, it is determined that the fourth batch and the second intermediate batch do not overlap each other.
[0112] Similar to the above determination of whether the second batch and the first intermediate batch overlap each other, the specific process can be referred to the above description and will not be repeated here. In this embodiment, the bounding box is determined according to the size of the texture, which can facilitate calculation.
[0113] In some optional embodiments of the present application, before the above-mentioned if the fourth batch and the second intermediate batch do not overlap each other, a process of determining whether the fourth batch and the second intermediate batch overlap each other is further included. The process may include:
[0114] Determine a bounding box of the fourth batch according to the valid pixel area in the fourth batch of mapping information, and determine a bounding box of the second intermediate batch according to the valid pixel area in the second intermediate batch of mapping information;
[0115] Determine whether the bounding boxes of the fourth batch overlap with the bounding boxes of the second middle batch;
[0116] If there is overlap, the fourth batch and the second intermediate batch are determined to cover each other;
[0117] If there is no overlap, it is determined that the fourth batch and the second intermediate batch do not overlap each other.
[0118] In this embodiment, considering that in some scenarios, the map information includes valid pixel areas and invalid pixel areas, determining the bounding box based on the valid pixel area can reduce the probability of collision between two batches, improve the batch merging effect, and thus reduce the number of rendering batches. The method for determining the valid pixel area and the bounding box can be found in the previous description and will not be repeated here.
[0119] It should be noted that, in the previous steps, the bounding boxes of each batch have been determined. In this step, the bounding boxes of each batch determined in the previous steps can be directly used to determine whether two batches overlap each other.
[0120] Furthermore, after merging batches with the same material information, the following steps are also included:
[0121] Updating the first rendering order to obtain a second rendering order;
[0122] Render each batch in the second rendering order in sequence, wherein, for batches with the same texture information and continuous rendering order, when rendering a batch in a later rendering order, obtain the texture information required by the batch in the later rendering order from the cache.
[0123] like Figure 3 As shown in the figure, the image processing hardware has a multi-level cache system, which mainly includes video memory and cache (also called cache). In the process of rendering an image, it is necessary to obtain the texture information of each rendering batch. The texture information obtained from the video memory needs to be stored in the cache before it can be used. If the required texture information is already stored in the cache, it can be obtained directly. Taking GPU hardware as an example, the process of reading texture information from the video memory to the cache requires the GPU read bandwidth, and reading data will also cause heat. However, the information that can be stored in the cache is limited. When the storage capacity of the cache is full and new information needs to be stored, the previously stored information will be removed; that is, if the texture information in the cache is not used in time, it is likely to be replaced by new information, and the same texture information will need to be repeatedly read from the video memory to the cache, resulting in a waste of resources. The embodiment of the present application adjusts the rendering order of batches with the same texture information to be continuous, thereby ensuring that in multiple rendering batches with the same texture information and continuous rendering order, the texture information only needs to be read from the video memory once at most, thereby improving the utilization rate of the texture information in the cache, that is, improving the hit rate of obtaining the texture information from the cache, reducing the number of times the texture data is read from the video memory to the cache, and thus reducing bandwidth and heat generation.
[0124] Furthermore, in some optional embodiments of the present application, the above method may further include:
[0125] Obtain all batches of images to be rendered and all batches of currently rendered images, and determine, based on the obtained batches of images to be rendered and all batches of currently rendered images, batches of images to be rendered that have different material information from the currently rendered images, and record them as batches to be rendered;
[0126] The batches to be rendered are rendered according to their initial rendering order in the image to be rendered.
[0127] The currently rendered image refers to the image displayed on the screen. It can be understood that the image to be rendered is the image that needs to be presented immediately after the currently rendered image. By comparing the image to be rendered with the currently rendered image, batches of the image to be rendered that have the same material information as the currently rendered image and batches of different material information are determined. Since the batch with the same material information is already displayed on the current screen, there is no need to render the batch with the same material information repeatedly. Only the batch with different material information needs to be rendered to present the image to be rendered on the screen, which also reduces the number of rendering batches and improves rendering performance.
[0128] Furthermore, during the rendering process of the batches to be rendered, the batches to be rendered can be processed in conjunction with steps 101-105 above to further improve rendering performance. For example, all batches of the image to be rendered and the rendering order of all batches can be determined by traversing the rendering tree of the image to be rendered. The batches in the currently rendered image can then be removed from the rendering order. The remaining batches are the batches to be rendered, and the rendering order of the remaining batches is the initial rendering order of the batches to be rendered. It is understood that all batches in step 101 at this time refer to the batches to be rendered.
[0129] The embodiment of the present application obtains the initial rendering order of all batches in the image to be rendered, and the material information of all batches, the material information including the texture information; searches for the first batch and the second batch with the same texture information in all batches, and obtains the first intermediate batch between the first batch and the second batch according to the initial rendering order; if the second batch and the first intermediate batch do not overlap each other, adjusts the rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch, and updates the initial rendering order to obtain the first rendering order of all batches; searches for the third batch and the third batch with the same material information in the batches with the same first rendering order and the same texture information. The fourth batch, and obtain the second intermediate batch between the third batch and the fourth batch; if the fourth batch and the second intermediate batch do not overlap each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch, and the first rendering order is updated to obtain the second rendering order; it can be achieved without affecting the original effect of the image to be rendered. The rendering batches are effectively reduced. In addition, the embodiment of the present application also adjusts the rendering batches with different material information but the same map information to a continuous rendering order, which can increase the hit rate of reading the map information from the cache during the rendering process, reduce the number of times the map data is loaded from the video memory, and improve the rendering performance and reduce the screen freeze.
[0130] Reference Figure 4 , shows a flowchart of the steps of an image rendering method provided by an embodiment of the present application. In the embodiment of the present application, the method may include the following steps:
[0131] Step 401 : Obtain the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information.
[0132] The implementation of this step can refer to the above step 101 and will not be described in detail.
[0133] Step 402 : searching for a fifth batch and a sixth batch with the same material information in all the batches, and obtaining a third intermediate batch between the fifth batch and the sixth batch according to the initial rendering order.
[0134] The fifth and sixth batches are used to distinguish different batches and are not necessarily in order. For example, the process of searching for the fifth and sixth batches with the same material information may include: based on the fifth batch that is rendered earlier, searching for the sixth batch that is rendered later and has the same material information as the fifth batch; or, based on the fifth batch that is rendered later, searching for the sixth batch that is rendered earlier and has the same material information as the fifth batch.
[0135] In step 403, if the sixth batch and the third intermediate batch do not cover each other, or the third intermediate batch cannot be obtained, the sixth batch and the fifth batch are merged into one batch, and the initial rendering order is updated to obtain a third rendering order.
[0136] When it is determined that the sixth batch and the third intermediate batch do not cover each other, or the third intermediate batch cannot be obtained, the sixth batch and the fifth batch are merged into one batch. It can be understood that the rendering content of the sixth batch is merged into the rendering content of the fifth batch, and after all batches with the same material information are merged, the initial rendering order of all batches is updated to obtain a third rendering order.
[0137] In some optional embodiments of the present application, the process of determining whether the sixth batch and the third intermediate batch cover each other can include:
[0138] determining a bounding box of the sixth batch according to the mapping information of the sixth batch, and determining a bounding box of the third intermediate batch according to the mapping information of the third intermediate batch;
[0139] determining whether the bounding box of the sixth batch and the bounding box of the third intermediate batch overlap;
[0140] if there is overlap, it is determined that the sixth batch and the third intermediate batch cover each other;
[0141] if there is no overlap, it is determined that the sixth batch and the third intermediate batch do not cover each other.
[0142] Similar to the determination of whether the second batch and the first intermediate batch cover each other, the bounding box can be determined according to the mapping size, which can facilitate calculation.
[0143] In some optional embodiments of the present application, the process of determining whether the sixth batch and the third intermediate batch cover each other can include:
[0144] determining a bounding box of the sixth batch according to the effective pixel region in the mapping information of the sixth batch, and determining a bounding box of the third intermediate batch according to the effective pixel region in the mapping information of the third intermediate batch;
[0145] determining whether the bounding box of the sixth batch and the bounding box of the third intermediate batch overlap;
[0146] if there is overlap, it is determined that the sixth batch and the third intermediate batch cover each other;
[0147] if there is no overlap, it is determined that the sixth batch and the third intermediate batch do not cover each other.
[0148] In this embodiment, considering that in some scenarios, the map information includes valid pixel areas and invalid pixel areas, determining the bounding box based on the valid pixel area can reduce the probability of collision between two batches, improve the batch merging effect, and thus reduce the number of rendering batches. The method for determining the valid pixel area and the bounding box can be found in the previous description and will not be repeated here.
[0149] Step 404 : Search for a seventh batch and an eighth batch having the same texture information among all batches corresponding to the third rendering order, and obtain a fourth intermediate batch between the seventh batch and the eighth batch according to the third rendering order.
[0150] After merging the batches with the same material information, the seventh and eighth batches with different material information but the same map information can be found from the second rendering order, and the fourth intermediate batch between the seventh and eighth batches can be obtained.
[0151] Step 405 : If the eighth batch and the fourth intermediate batch do not overlap each other, adjust the rendering order of the eighth batch so that the rendering order of the eighth batch is continuous with the rendering order of the seventh batch.
[0152] The same method as that used in step 403 above to determine whether two batches overlap each other is used to determine whether the eighth batch and the fourth intermediate batch overlap each other. If they do not overlap each other, the rendering order of the eighth batch is adjusted so that the rendering order of the two batches with the same texture information is continuous. After adjusting the rendering order of all batches with the same texture information, the third rendering order is updated to obtain the fourth rendering order. It should be noted that when the eighth batch is obtained by merging at least two batches, that is, the eighth batch includes multiple sub-batches, it is necessary to determine in turn whether each sub-batch overlaps with each batch included in the fourth intermediate batch. If any sub-batch in the eighth batch overlaps with any batch in the fourth intermediate batch, it is considered that the eighth batch and the fourth intermediate batch overlap each other; otherwise, it is considered that the eighth batch and the fourth intermediate batch do not overlap each other.
[0153] Furthermore, after merging batches with the same material information and adjusting the rendering order of batches with the same texture information to be continuous to obtain a fourth rendering order, it also includes: rendering each batch in the fourth rendering order in sequence, wherein, for batches with the same texture information and a continuous rendering order, when rendering a batch that comes later in the rendering order, the texture information required for the batch that comes later in the rendering order is obtained from the cache.
[0154] Furthermore, in some optional embodiments of the present application, the above method may further include:
[0155] Obtain all batches of images to be rendered and all batches of currently rendered images, and determine, based on the obtained batches of images to be rendered and all batches of currently rendered images, batches of images to be rendered that have different material information from the currently rendered images, and record them as batches to be rendered;
[0156] The batches to be rendered are rendered according to their initial rendering order in the image to be rendered.
[0157] The currently rendered image refers to the image displayed on the screen. By comparing the image to be rendered with the currently rendered image, batches of the image to be rendered that have the same material information as the currently rendered image and batches of different material information are determined. Since the batch with the same material information is already displayed on the current screen, there is no need to render the batches with the same material information repeatedly. Only the batches with different material information need to be rendered to present the image to be rendered on the screen, which also reduces the number of rendering batches and improves rendering performance.
[0158] Furthermore, during the rendering process of the batches to be rendered, the batches to be rendered can be processed in conjunction with steps 401-405 above to further improve rendering performance. For example, all batches of the image to be rendered and the rendering order of all batches can be determined by traversing the rendering tree of the image to be rendered. The batches in the currently rendered image can then be removed from the rendering order. The remaining batches are the batches to be rendered, and the rendering order of the remaining batches is the initial rendering order of the batches to be rendered. It is understood that all batches in step 401 at this time refer to the batches to be rendered.
[0159] The embodiment of the present application obtains the initial rendering order of all batches in the image to be rendered, and the material information of all batches; searches for the fifth and sixth batches with the same material information, and obtains the third intermediate batch between the fifth and sixth batches. When the sixth batch and the third intermediate batch do not overlap with each other, or the third intermediate batch cannot be obtained, the sixth batch and the fifth batch are merged into one batch for rendering, which can reduce the rendering batches, and the initial rendering order is updated to obtain the third rendering order; searches for the seventh and eighth batches with the same texture information in all batches corresponding to the third rendering order, and obtains the fourth intermediate batch between the seventh and eighth batches. When the eighth batch and the fourth intermediate batch do not overlap with each other, the eighth batch is adjusted to be continuous with the rendering order of the seventh batch, so as to realize continuous rendering of batches with the same texture information, so as to reduce the number of times the same texture information is obtained from the video memory, thereby improving the cache hit rate, reducing bandwidth and reducing heat.
[0160] Reference Figure 5, shows a flowchart of the steps of an image rendering method provided by an embodiment of the present application. In the embodiment of the present application, the method may include the following steps:
[0161] Step 501 : Obtain the initial rendering order of all batches in the image to be rendered, and the material information of all batches, wherein the material information includes mapping information; the mapping information includes valid pixel areas and invalid pixel areas.
[0162] The implementation of this step is similar to that of step 101, and reference may be made to the description of step 101. In addition, in this step, the texture information includes a valid pixel area and an invalid pixel area. It is understood that the valid pixel area is smaller than or equal to the texture size corresponding to the texture information.
[0163] Step 502 : searching for a ninth batch and a tenth batch having the same material information among all the batches, and obtaining a fifth intermediate batch between the ninth batch and the tenth batch according to the initial rendering order.
[0164] The implementation of this step is similar to that of the above step 104 , and reference may be made to the description of the above step 104 .
[0165] Step 503 : determining whether the tenth batch and the fifth intermediate batch overlap each other based on the valid pixel area in the mapping information of the tenth batch and the valid pixel area in the mapping information of the fifth intermediate batch.
[0166] In this step, when judging whether the tenth batch and the fifth intermediate batch overlap each other, the effective pixel area in the mapping information of the tenth batch and the effective pixel area in the mapping information of the fifth intermediate batch are used. This can reduce the probability of collision between the two batches, improve the effect of batch merging in subsequent steps, and thus reduce rendering batches.
[0167] Illustratively, the process of determining whether the tenth batch and the fifth intermediate batch overlap each other based on the valid pixel area in the tenth batch of mapping information and the valid pixel area in the fifth intermediate batch of mapping information may include:
[0168] Determine a bounding box of the tenth batch according to the valid pixel area in the mapping information of the tenth batch, and determine a bounding box of the fifth intermediate batch according to the valid pixel area in the mapping information of the fifth intermediate batch;
[0169] Determine whether the bounding box of the tenth batch overlaps with the bounding box of the fifth middle batch;
[0170] If there is overlap, the tenth batch and the fifth intermediate batch are determined to cover each other;
[0171] If there is no overlap, it is determined that the tenth batch and the fifth intermediate batch do not overlap each other.
[0172] The process of determining the valid pixel area in each batch of mapping information may include:
[0173] Obtain all pixel data in each batch of texture information in the image to be rendered;
[0174] Determine whether the pixel data is a valid pixel according to the Alpha value in the pixel data;
[0175] The valid pixel area corresponding to the mapping information is determined according to the determined valid pixel points.
[0176] Exemplarily, all pixel data in the mapping information of each batch in the image to be rendered can be obtained offline, and whether the pixel data is a valid pixel can be determined based on the Alpha value in the pixel data. Based on all the valid pixels determined, the valid pixel area of the mapping information can be determined, and then, the corresponding bounding box can be determined based on the valid pixel area, and the information of the bounding box of each batch can be recorded in the configuration file corresponding to the image to be rendered, or the information of the valid pixel area of each batch can be recorded in the configuration file corresponding to the image to be rendered.
[0177] For example, in determining the bounding box, the normalized device coordinate system can be used to determine the maximum and minimum values of the valid pixel area on the X axis, as well as the maximum and minimum values on the Y axis. These four values can be used to obtain the corresponding minimum AABB bounding box. Using the normalized device coordinate system eliminates the need for coordinate conversion.
[0178] This embodiment uses the valid pixel area in each batch's texture information to determine the corresponding bounding box. Compared to methods that directly use texture information to determine the corresponding bounding box, this reduces the probability of collisions between two batches and improves the effectiveness of subsequent batch merging. Furthermore, by combining offline calculations, this improves the effectiveness of merging and reordering without affecting data processing speed during rendering.
[0179] Step 504: If the tenth batch and the fifth intermediate batch do not overlap each other, or the fifth intermediate batch does not exist, then the tenth batch and the ninth batch are merged into one batch.
[0180] When it is determined that the tenth batch and the fifth intermediate batch do not overlap, or the fifth intermediate batch cannot be obtained, the tenth batch and the third batch are merged into one batch. It can be understood that the rendering content of the tenth batch is merged into the rendering content of the third batch. After all batches with the same material information are merged, the initial rendering order of all batches is updated to form the fifth rendering order. When the fifth intermediate batch includes multiple batches, determining that the tenth batch and the fifth intermediate batch do not overlap means that the tenth batch and all batches of the fifth intermediate batch do not overlap. Specifically, whether the tenth batch and the fifth intermediate batch overlap can be determined by judging whether each batch of the tenth batch and the fifth intermediate batch overlaps.
[0181] Furthermore, after merging the batches with the same material information to obtain the fifth rendering sequence, the method further includes: rendering each batch in the fifth rendering sequence in sequence.
[0182] Furthermore, in some optional embodiments of the present application, the above method may further include:
[0183] Obtain all batches of images to be rendered and all batches of currently rendered images, and determine, based on the obtained batches of images to be rendered and all batches of currently rendered images, batches of images to be rendered that have different material information from the currently rendered images, and record them as batches to be rendered;
[0184] The batches to be rendered are rendered according to their initial rendering order in the image to be rendered.
[0185] The currently rendered image refers to the image displayed on the screen. By comparing the image to be rendered with the currently rendered image, batches of the image to be rendered that have the same material information as the currently rendered image and batches of different material information are determined. Since the batch with the same material information is already displayed on the current screen, there is no need to render the batches with the same material information repeatedly. Only the batches with different material information need to be rendered to present the image to be rendered on the screen, which also reduces the number of rendering batches and improves rendering performance.
[0186] Furthermore, during the rendering process of the batches to be rendered, the batches to be rendered can be processed in combination with the above steps 501-504 to further improve rendering performance. For example, all batches of the image to be rendered and the rendering order of all batches can be determined by traversing the rendering tree of the image to be rendered. The batches in the currently rendered image can then be removed from the rendering order. The remaining batches are the batches to be rendered, and the rendering order of the remaining batches is the initial rendering order of the batches to be rendered. It is understood that all batches in step 501 at this time refer to the batches to be rendered.
[0187] The embodiment of the present application obtains the initial rendering order of all batches in the image to be rendered, as well as the material information of all batches, wherein the material information includes mapping information, and the mapping information includes valid pixel areas and invalid pixel areas; searches for the ninth and tenth batches with the same material information, and obtains the fifth intermediate batch between the ninth and tenth batches; determines whether the tenth batch and the fifth intermediate batch overlap each other based on the valid pixel areas in the mapping information of the tenth batch and the valid pixel areas in the mapping information of the fifth intermediate batch; if the tenth batch and the fifth intermediate batch do not overlap each other, or the fifth intermediate batch cannot be obtained, then merges the tenth batch and the ninth batch into one batch; determines whether the two batches overlap each other based on the valid pixel areas in the mapping information, which can reduce the probability of overlap between the two batches and improve the effect of batch merging. Furthermore, combined with offline calculation, it is achieved that while improving the effect of merging and adjusting the order, the data processing speed in the rendering process will not be affected.
[0188] In order to facilitate those skilled in the art to understand this solution, Figure 6 The specific examples shown explain and illustrate the image rendering method of the present application.
[0189] Figure 6 This is a schematic diagram of the rendering tree of an image to be rendered in an example of the present application. The image to be rendered may correspond to a "character equipment" interface commonly seen in games. The interface includes a control corresponding to a base plate and multiple controls corresponding to equipment grids. It can be understood that the interface includes a base plate and multiple equipment grids, and each equipment grid corresponds to an icon, a name, and special effects.
[0190] By performing a depth-first traversal of the render tree, the initial rendering order is: base → icon 1 → name 1 → special effect 1 → icon 2 → name 2 → special effect 2 → icon 3 → name 3 → special effect 3, for a total of 10 batches. Icon 1, icon 2, and icon 3 use the same material information, while name 1, name 2, and name 3 use different material information (including different texture information). Special effect 1, special effect 2, and special effect 3 use the same texture information in the material information, but use different lighting data information (for example, different shaders) or different rendering state data information (for example, different Alpha blending methods).
[0191] In this example, the base plate and other controls overlap each other, and the three types of controls, icons, names, and special effects, do not overlap each other. In addition, the display positions of different icons are inconsistent, so there will be no overlapping relationship between the icons, that is, the icons do not overlap each other. Similarly, the display positions of different names are inconsistent, so the names do not overlap each other; and special effects 1, special effects 2, and special effects 3 use sequence frame images to achieve special effects, that is, the texture information of special effects 1, special effects 2, and special effects 3 includes valid pixel areas and invalid pixel areas. The positional relationship between the texture information corresponding to special effects 1, special effects 2, and special effects 3 (the texture size is represented by dotted lines in the figure), and the positional relationship between the valid pixel areas corresponding to special effects 1, special effects 2, and special effects 3 (the valid pixel areas are represented by solid lines in the figure) are shown as follows. Figure 7 As shown, that is, in this example, the bounding boxes determined according to the mapping information corresponding to special effects 1, special effects 2 and special effects 3 have a collision, while the bounding boxes determined according to the valid pixel areas corresponding to special effects 1, special effects 2 and special effects 3 do not have a collision.
[0192] Using the method of a preferred embodiment of the present application, a corresponding bounding box is determined based on the effective pixel area in the texture information. When the second batch and the first intermediate batch do not overlap, the batches with the same texture information are adjusted to a continuous rendering order, resulting in a first rendering order of: base plate → icon 1 → icon 2 → icon 3 → name 1 → special effect 1 → special effect 2 → special effect 3 → name 2 → name 3. Next, a corresponding bounding box is determined based on the effective pixel area in the texture information. When the fourth batch and the second intermediate batch do not overlap, the batches with the same material information are merged, resulting in a second rendering order of: base plate → icon (icon 1, icon 2, icon 3) → name 1 → special effect 1 → special effect 2 → special effect 3 → name 2 → name 3, for a total of 8 rendering batches. Using the effective pixel area to determine the bounding box for collision detection can improve the accuracy of the collision detection results. By merging batches with the same material information, the rendering batches can be reduced and the rendering performance can be improved. At the same time, by adjusting special effects 1, special effects 2, and special effects 3 with different material information but the same texture information to a continuous rendering order, it can be ensured that when rendering special effects 2 and special effects 3, the texture information can be obtained from the cache, thereby improving the cache hit rate, thereby reducing the reading bandwidth and reducing heat.
[0193] Using the method of another preferred embodiment of the present application, the corresponding bounding box is determined based on the effective pixel area in the texture information. When the sixth batch and the third intermediate batch do not overlap, the batches with the same material information are merged to obtain the third rendering order: base plate → icon 1 (icon 1, icon 2, icon 3) → name 1 → special effect 1 → name 2 → special effect 2 → name 3 → special effect 3. Next, the corresponding bounding box is determined based on the effective pixel area in the texture information. When the eighth batch and the fourth intermediate batch do not overlap, the batches with the same texture information are adjusted to a continuous rendering order, to obtain the fourth rendering order: base plate → icon (icon 1, icon 2, icon 3) → name 1 → special effect 1 → special effect 2 → special effect 3 → name 2 → name 3, for a total of 8 rendering batches. Using the effective pixel area to determine the bounding box for collision detection can improve the accuracy of the collision detection results. By merging batches with the same material information, the rendering batches can be reduced and the rendering performance can be improved. At the same time, by adjusting special effects 1, special effects 2, and special effects 3 with different material information but the same texture information to a continuous rendering order, it can be ensured that when rendering special effects 2 and special effects 3, the texture information can be obtained from the cache, thereby improving the cache hit rate, thereby reducing the reading bandwidth and reducing heat.
[0194] Using the method of another preferred embodiment of the present application, the corresponding bounding box is determined based on the effective pixel area in the map information. When the sixth batch and the third intermediate batch do not overlap, the batches with the same material information are merged to obtain the third rendering order: base → icon 1 (icon 1, icon 2, icon 3) → name 1 → special effect 1 → name 2 → special effect 2 → name 3 → special effect 3, a total of 8 rendering batches. Using the effective pixel area to determine the bounding box for collision detection can improve the accuracy of the collision detection results. By merging batches with the same material information, the rendering batches can be reduced and the rendering performance can be improved.
[0195] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0196] Reference Figure 8 , shows a structural block diagram of an embodiment of an image rendering device of the present application, which is similar to the above Figure 1 Corresponding to the embodiment of the image rendering method shown, the image rendering device of this embodiment may include the following modules:
[0197] The first obtaining module 801 is configured to obtain initial rendering orders of all batches in a to-be-rendered image and material information of all the batches, wherein the material information comprises map information;
[0198] The second obtaining module 802 is configured to find a first batch and a second batch with the same map information in the all batches, and obtain a first intermediate batch between the first batch and the second batch according to the initial rendering orders.
[0199] The first adjusting module 803 is configured to, if the second batch and the first intermediate batch do not overlap with each other, adjust a rendering order of the second batch so that the rendering order of the second batch is continuous with a rendering order of the first batch, and update the initial rendering orders to obtain a first rendering order.
[0200] The third obtaining module 804 is configured to find a third batch and a fourth batch with the same material information in batches with the same map information and continuous rendering orders according to the first rendering order, and obtain a second intermediate batch between the third batch and the fourth batch.
[0201] The first merging module 805 is configured to, if the fourth batch and the second intermediate batch do not overlap with each other or the second intermediate batch cannot be obtained, merge the fourth batch and the third batch into one batch.
[0202] In an optional embodiment of the present application, the map information comprises a valid pixel region and an invalid pixel region, and the device further comprises:
[0203] The first bounding box determining module is configured to determine a bounding box of the second batch according to the valid pixel region in the map information of the second batch, and determine a bounding box of the first intermediate batch according to the valid pixel region in the map information of the first intermediate batch.
[0204] The first overlap judging module is configured to judge whether the bounding box of the second batch and the bounding box of the first intermediate batch overlap with each other.
[0205] The first coverage determining module is configured to, if there is overlap, determine that the second batch and the first intermediate batch overlap with each other.
[0206] The second coverage determining module is configured to, if there is no overlap, determine that the second batch and the first intermediate batch do not overlap with each other.
[0207] In an optional embodiment of the present application, the device further comprises:
[0208] The first order updating module is configured to update the first rendering order to obtain a second rendering order.
[0209] The first rendering module is configured to sequentially render each batch in the second rendering sequence, wherein for batches with the same mapping information and continuous rendering sequence, the mapping information required by a batch with a later rendering sequence is obtained from the cache when the batch is rendered.
[0210] In an optional embodiment of the present application, the device further comprises:
[0211] The pixel data obtaining module is configured to obtain all pixel data in the mapping information of each batch in the image to be rendered.
[0212] The effective pixel point determining module is configured to determine whether the pixel data is an effective pixel point according to the Alpha value in the pixel data.
[0213] The effective pixel region determining module is configured to determine an effective pixel region of corresponding mapping information according to the determined effective pixel point.
[0214] In an optional embodiment of the present application, the second obtaining module 802 comprises:
[0215] The first searching module is configured to search for a second batch with a later rendering sequence and the same mapping information as a first batch with an earlier rendering sequence according to the first batch, or
[0216] search for a second batch with an earlier rendering sequence and the same mapping information as a first batch with a later rendering sequence according to the first batch.
[0217] Reference is made to Figure 9 , which shows a structural block diagram of an embodiment of an image rendering device of the present application, and corresponds to the image rendering method embodiment shown in Figure 4 , the image rendering device of the present embodiment can comprise the following modules:
[0218] The fourth obtaining module 901 is configured to obtain an initial rendering sequence of all batches in an image to be rendered and material information of all batches, wherein the material information comprises mapping information.
[0219] The fifth obtaining module 902 is configured to search for a fifth batch and a sixth batch with the same material information in all batches, and obtain a third intermediate batch between the fifth batch and the sixth batch according to the initial rendering sequence.
[0220] The second merging module 903 is configured to merge the sixth batch and the fifth batch into one batch and update the initial rendering sequence to obtain a third rendering sequence if the sixth batch and the third intermediate batch do not overlap with each other or the third intermediate batch cannot be obtained.
[0221] a sixth acquisition module 904, configured to search for a seventh batch and an eighth batch having the same texture information among all batches corresponding to the third rendering order, and acquire a fourth intermediate batch between the seventh batch and the eighth batch according to the third rendering order;
[0222] The second adjusting module 905 is configured to adjust the rendering order of the eighth batch if the eighth batch and the fourth intermediate batch do not overlap each other, so that the rendering order of the eighth batch is continuous with the rendering order of the seventh batch.
[0223] In an optional embodiment of the present application, the mapping information includes a valid pixel area and an invalid pixel area, and the apparatus further includes:
[0224] a second bounding box determining module, configured to determine a bounding box for the sixth batch based on a valid pixel area in the sixth batch of mapping information, and to determine a bounding box for the third intermediate batch based on a valid pixel area in the third intermediate batch of mapping information;
[0225] a second overlap determination module, configured to determine whether the bounding boxes of the sixth batch overlap with the bounding boxes of the third intermediate batch;
[0226] a third overlap determination module, configured to determine that the sixth batch and the third intermediate batch overlap each other if there is overlap;
[0227] The fourth coverage determination module is configured to determine that the sixth batch and the third intermediate batch do not overlap each other if there is no overlap.
[0228] In an optional embodiment of the present application, the device further includes:
[0229] A second sequence updating module, configured to update the third rendering sequence to obtain a fourth rendering sequence;
[0230] The second rendering module is used to render each batch in the fourth rendering order in sequence, wherein, for batches with the same texture information and continuous rendering order, when rendering the batch later in the rendering order, the texture information required for the batch later in the rendering order is obtained from the cache.
[0231] In an optional embodiment of the present application, the device further includes:
[0232] A pixel data acquisition module is used to acquire all pixel data in each batch of texture information in the image to be rendered;
[0233] An effective pixel point determination module is used to determine whether the pixel point data is a valid pixel point according to the Alpha value in the pixel point data;
[0234] The effective pixel area determination module is used to determine the effective pixel area corresponding to the mapping information according to the determined effective pixel points.
[0235] In an optional embodiment of the present application, the fifth obtaining module 902 includes:
[0236] The second search module is configured to search, based on the fifth batch that is rendered earlier, for a sixth batch that is rendered later and has the same material information as the fifth batch, or
[0237] According to the fifth batch that is rendered later, a sixth batch that is rendered earlier and has the same material information as the fifth batch is searched.
[0238] Reference Figure 10 , shows a structural block diagram of an embodiment of an image rendering device of the present application, which is similar to the above Figure 5 Corresponding to the embodiment of the image rendering method shown, the image rendering device of this embodiment may include the following modules:
[0239] The seventh acquisition module 1001 is used to obtain the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes mapping information; the mapping information includes valid pixel areas and invalid pixel areas;
[0240] an eighth acquisition module 1002, configured to search for a ninth batch and a tenth batch having the same material information among all the batches, and acquire a fifth intermediate batch between the ninth batch and the tenth batch according to the initial rendering order;
[0241] an overlap determination module 1003 for determining whether the tenth batch overlaps the fifth intermediate batch based on the valid pixel area in the tenth batch of mapping information and the valid pixel area in the fifth intermediate batch of mapping information;
[0242] The third merging module 1004 is configured to merge the tenth batch and the ninth batch into one batch if the tenth batch and the fifth intermediate batch do not overlap each other or the fifth intermediate batch cannot be obtained.
[0243] In an optional embodiment of the present application, the coverage determination module 1003 includes:
[0244] a third bounding box determining module, configured to determine a bounding box for the tenth batch based on the valid pixel area in the mapping information of the tenth batch, and to determine a bounding box for the fifth intermediate batch based on the valid pixel area in the mapping information of the fifth intermediate batch;
[0245] a third overlap determination module, configured to determine whether the bounding boxes of the tenth batch overlap with the bounding boxes of the fifth intermediate batch;
[0246] a fifth overlap determination module, configured to determine that the tenth batch and the fifth intermediate batch overlap each other if overlap exists;
[0247] The sixth coverage determination module is configured to determine that the tenth batch and the fifth intermediate batch do not overlap each other if there is no overlap.
[0248] In an optional embodiment of the present application, the device further includes:
[0249] A pixel data acquisition module is used to acquire all pixel data in each batch of texture information in the image to be rendered;
[0250] An effective pixel point determination module is used to determine whether the pixel point data is a valid pixel point according to the Alpha value in the pixel point data;
[0251] The effective pixel area determination module is used to determine the effective pixel area corresponding to the mapping information according to the determined effective pixel points.
[0252] In an optional embodiment of the present application, the eighth obtaining module 1002 includes:
[0253] The third search module is configured to search, based on the ninth batch that is rendered earlier, for a tenth batch that is rendered later and has the same material information as the ninth batch, or
[0254] According to the ninth batch that is rendered later in the order of rendering, a tenth batch that is rendered earlier in the order of rendering and has the same material information as the ninth batch is searched.
[0255] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0256] An embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the steps of the image rendering method described above are implemented.
[0257] The embodiment of the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the image rendering method described above are implemented.
[0258] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0259] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0260] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0261] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0262] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0263] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0264] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0265] The above is a detailed introduction to an image rendering method and device, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. An image rendering method, characterized in that: The method comprises: Obtaining the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information; Searching for a first batch and a second batch with the same texture information in all the batches, and obtaining a first intermediate batch between the first batch and the second batch according to the initial rendering order; determining whether the second batch and the first intermediate batch overlap each other; if the second batch and the first intermediate batch do not overlap each other, adjusting the rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch, and updating the initial rendering order to obtain the first rendering order; Searching for a third batch and a fourth batch with the same material information among batches with a continuous first rendering order and the same mapping information, and obtaining a second intermediate batch between the third batch and the fourth batch; If the fourth batch and the second intermediate batch do not overlap each other, or the second intermediate batch cannot be obtained, the fourth batch and the third batch are merged into one batch.
2. The method according to claim 1, characterized in that The mapping information includes a valid pixel area and an invalid pixel area, and the determining whether the second batch and the first intermediate batch overlap each other includes: Determining a bounding box of the second batch according to the valid pixel area in the mapping information of the second batch, and determining a bounding box of the first intermediate batch according to the valid pixel area in the mapping information of the first intermediate batch; Determining whether the bounding boxes of the second batch overlap with the bounding boxes of the first intermediate batch; If there is overlap, it is determined that the second batch and the first intermediate batch overlap each other; If there is no overlap, it is determined that the second batch and the first intermediate batch do not overlap each other.
3. The method according to claim 1, characterized in that After merging the fourth batch and the third batch into one batch, the method further includes: Updating the first rendering order to obtain a second rendering order; Render each batch in the second rendering order in sequence, wherein, for batches with the same texture information and continuous rendering order, when rendering a batch in a later rendering order, obtain the texture information required by the batch in the later rendering order from the cache.
4. The method according to claim 2, characterized in that The method further comprises: Obtain all pixel data in each batch of texture information in the image to be rendered; Determine whether the pixel data is a valid pixel according to the Alpha value in the pixel data; The valid pixel area corresponding to the mapping information is determined according to the determined valid pixel points.
5. The method according to claim 1, wherein Find the first batch and the second batch with the same mapping information in all the batches, including: According to the first batch in the rendering order, find the second batch in the rendering order and with the same texture information as the first batch, or, According to the first batch that is rendered later, a second batch that is rendered earlier and has the same texture information as the first batch is searched.
6. An image rendering method, characterized in that: The method comprises: Obtaining the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information; Searching for a fifth batch and a sixth batch having the same material information among all the batches, and obtaining a third intermediate batch between the fifth batch and the sixth batch according to the initial rendering order; If the sixth batch and the third intermediate batch do not overlap each other, or the third intermediate batch cannot be obtained, merging the sixth batch and the fifth batch into one batch, and updating the initial rendering order to obtain a third rendering order; Searching for a seventh batch and an eighth batch having the same texture information among all batches corresponding to the third rendering order, and obtaining a fourth intermediate batch between the seventh batch and the eighth batch according to the third rendering order; If the eighth batch and the fourth intermediate batch do not overlap each other, the rendering order of the eighth batch is adjusted so that the rendering order of the eighth batch is continuous with the rendering order of the seventh batch.
7. An image rendering device, characterized in that: The device comprises: A first acquisition module is used to acquire the initial rendering order of all batches of the image to be rendered, and the material information of all batches, wherein the material information includes texture information; A second acquisition module is configured to search for a first batch and a second batch having the same texture information in all the batches, and acquire a first intermediate batch between the first batch and the second batch according to the initial rendering order; a first adjusting module configured to adjust a rendering order of the second batch so that the rendering order of the second batch is continuous with the rendering order of the first batch if the second batch and the first intermediate batch do not overlap each other, and to update the initial rendering order to obtain a first rendering order; A third acquisition module is configured to search for a third batch and a fourth batch with the same material information among batches with the same texture information and a continuous first rendering order, and to acquire a second intermediate batch between the third batch and the fourth batch; The first merging module is configured to merge the fourth batch and the third batch into one batch if the fourth batch and the second intermediate batch do not overlap each other or the second intermediate batch cannot be obtained.
8. An image rendering device, characterized in that: The device comprises: a fourth acquisition module, configured to acquire an initial rendering order of all batches of the image to be rendered, and material information of all batches, wherein the material information includes texture information; a fifth acquisition module, configured to search for a fifth batch and a sixth batch having the same material information among all the batches, and acquire a third intermediate batch between the fifth batch and the sixth batch according to the initial rendering order; a second merging module, configured to merge the sixth batch and the fifth batch into one batch if the sixth batch and the third intermediate batch do not overlap each other or the third intermediate batch cannot be obtained, and update the initial rendering order to obtain a third rendering order; a sixth acquisition module, configured to search for a seventh batch and an eighth batch having the same texture information among all batches corresponding to the third rendering order, and acquire a fourth intermediate batch between the seventh batch and the eighth batch according to the third rendering order; The second adjusting module is configured to adjust the rendering order of the eighth batch if the eighth batch and the fourth intermediate batch do not overlap each other, so that the rendering order of the eighth batch is continuous with the rendering order of the seventh batch.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the image rendering method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image rendering method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Rendering method and device
CN105631923A
Method and device for processing texture data in game, electronic equipment and storage medium
CN114296927A