Virtual scene rendering method, device, electronic device and storage medium
By deduplication of the elements in HLOD technology in virtual scene rendering, unified target material data and texture data are generated, the memory usage problem caused by repeated elements in texture data is solved, and more efficient memory usage and consistent Rendering effect.
Patent Information
- Application Number
- CN202111643381.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The existing HLOD technology has a lot of duplication when generating texture data, resulting in excessive memory resource utilization.
By obtaining the data to be rendered for each enclosure in the model cluster of the virtual scene, deduplication of the primitives based on the material data corresponding to the mesh, and generating unified target material data and texture data.
Reduces the number of primitives in texture data, avoids excessive use of memory resources, saves memory, and improves rendering effect and consistency.
Smart Images

Figure CN114219886B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer graphics processing, and in particular to a virtual scene rendering method, device, electronic device and storage medium. Background Art
[0002] Hierarchical Level of Detail (HLOD) technology combines pre-existing Static Mesh Actors into a single HLOD proxy model and material. Because HLOD can reduce multiple draw calls for each proxy model to one call instead of one draw call for each Static Mesh Actor, it helps reduce the number of Actors that need to be rendered in the scene, improving performance by reducing the number of draw calls per frame.
[0003] However, the existing HLOD technology generates corresponding meshes, materials, and textures for each bounding volume. As too many textures are generated and there are a lot of repetitions in these textures, memory resources are over-occupied. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present application provide a virtual scene rendering method, device, electronic device and storage medium.
[0005] According to one aspect of an embodiment of the present application, a virtual scene rendering method is provided, comprising:
[0006] Acquire the data to be rendered corresponding to each bounding volume in the model cluster of the virtual scene, wherein the bounding volume includes at least one model, each of the models is divided into a plurality of grids, the grids contain references to the data to be rendered, and the data to be rendered includes: material data and texture data referenced by the grids, and the texture data contains primitives referenced by the grids;
[0007] Based on the material data corresponding to the grid, all the primitives in the model cluster are deduplicated to obtain the target primitive corresponding to the model cluster;
[0008] Generate target material data corresponding to the model cluster, and generate target texture data corresponding to the model cluster according to the target primitive;
[0009] The models in each of the bounding volumes in the model cluster are rendered according to the target material data and the target texture data to obtain a rendered model cluster.
[0010] Optionally, generating target material data corresponding to the model cluster includes:
[0011] Acquire material data corresponding to each mesh in the model cluster, wherein the material data includes normal information corresponding to each pixel point;
[0012] After deduplication of the material data, the material data are merged to obtain the target material data.
[0013] Optionally, rendering the models in each of the bounding volumes in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster includes:
[0014] Regenerate a target mesh for the model in each of the bounding volumes according to the target material data and the target texture data, wherein the target mesh contains a reference relationship with the target material data and the target texture data;
[0015] Based on the target material data and target texture data referenced by the target grid, the model to which the target grid belongs is rendered to obtain a rendered model cluster.
[0016] Optionally, based on the material data corresponding to the grid, all the primitives in the model cluster are deduplicated to obtain the target primitive corresponding to the model cluster, including:
[0017] For meshes that reference the same material data, retaining the primitive referenced by any of the meshes as the target primitive;
[0018] Set the mesh with the same material data as the target primitive.
[0019] Optionally, generating target texture data corresponding to the model cluster according to the target primitive includes:
[0020] Collecting all the target primitives into a target image;
[0021] The target texture data is generated according to the target image.
[0022] Optionally, all the target primitives are assembled into a target image, including:
[0023] Obtaining a preset minimum image element size among the target image elements and a maximum image size corresponding to the target image;
[0024] Calculating, according to the number of picture elements of the target picture element, an actual image size of the target image and an actual picture element size of the target picture element, so that the actual image size is less than or equal to the maximum image size, and the actual picture element size of the target picture element is greater than or equal to the minimum picture element size, wherein the image size is W x H, and W and H are powers of 2;
[0025] The target image is generated according to the actual image size and the actual primitive size.
[0026] Optionally, when the calculated image size of the target image is larger than the maximum image size, the method further includes:
[0027] Executing a preset reminder operation, wherein the preset reminder operation is used to indicate that a resource is not used properly;
[0028] And / or, detecting the similarity between the target graphic elements; when the similarity is greater than or equal to a preset threshold, outputting prompt information for the target graphic elements whose similarity is greater than or equal to the preset threshold.
[0029] According to another aspect of an embodiment of the present application, a virtual scene rendering device is provided, comprising:
[0030] An acquisition module is used to acquire data to be rendered corresponding to each bounding volume in a model cluster of a virtual scene, wherein the bounding volume includes at least one model, each of which is divided into a plurality of grids, wherein the grids include references to the data to be rendered, and wherein the data to be rendered includes: material data and texture data referenced by the grids, wherein the texture data includes primitives referenced by the grids;
[0031] A deduplication module, used for deduplicating all primitives in the model cluster based on material data corresponding to the grid, to obtain target primitives corresponding to the model cluster;
[0032] A generating module, used to generate target material data corresponding to the model cluster, and generate target texture data corresponding to the model cluster according to the target primitive;
[0033] A rendering module is used to render the models in each of the bounding volumes in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster.
[0034] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0035] According to another aspect of the embodiment of the present application, there is provided an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0036] The memory is used to store computer programs;
[0037] The processor is used to implement the above method steps when executing a computer program.
[0038] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the above method steps are implemented.
[0039] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0040] The meshes of the models in all bounding volumes of a model cluster are counted, and the primitives referenced by the meshes are deduplicated based on the material data corresponding to the meshes, and finally a unified material data and texture data is generated for all bounding volumes of the model cluster. Since a large number of duplicate primitives are removed from the texture data, the number of primitives contained in the final generated texture data is reduced, thereby avoiding excessive occupation of memory resources and saving memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0043] Figure 1 A flowchart of a virtual scene rendering method provided in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of each bounding volume in a model cluster provided in an embodiment of the present application;
[0045] Figure 3 A schematic diagram of removing the primitives in the texture picture corresponding to the previous bounding volume provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a primitive in a texture image corresponding to another bounding volume before deduplication provided in an embodiment of the present application;
[0047] Figure 5 A schematic diagram of a target image after deduplication provided in an embodiment of the present application;
[0048] Figure 6 A schematic diagram of target material data and target texture data corresponding to the model cluster provided in an embodiment of the present application;
[0049] Figure 7 A block diagram of a virtual scene rendering device provided in an embodiment of the present application;
[0050] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0052] The existing HLOD technology has different numbers of meshes contained in different bounding volumes, that is, the number of primitives contained in the texture data corresponding to each bounding volume is different. The bounding volume containing more objects contains more primitives in the texture data, but the size of the texture image generated by each bounding volume is the same. For a bounding volume containing many models, due to the large number of primitives, a higher compression rate is required for each primitive, so the final texture image corresponding to the bounding volume has low clarity, blurred display, and poor rendering of the model. Models located in different bounding volumes will be displayed inconsistently due to the different compression rates of the primitives in the texture data corresponding to the bounding volume.
[0053] The embodiment of the present application counts the meshes of the models in all bounding volumes of a model cluster, deduplicates the primitives referenced by the meshes based on the material data corresponding to the meshes, and finally generates a unified material data and texture data for all bounding volumes in the model cluster. Since a large number of duplicate primitives are removed from the texture data, the number of primitives included in the final generated texture data is reduced, thereby avoiding excessive occupation of memory resources and saving memory.
[0054] In addition, the same texture data is used for all bounding volumes, and the size of each primitive in the texture data is the same. Due to primitive deduplication, the number of primitives included in the final texture data is reduced, and the final texture image corresponding to the bounding volume has high clarity and better rendering of the model. Moreover, different bounding volumes use the same texture data, and the display effect of models located in different bounding volumes is consistent.
[0055] In the embodiment of the present application, unified material data and texture data are generated based on a model cluster. This is because when HLOD generates clusters, the similarity of model styles in the same model cluster is high, which results in the generation of a large number of duplicate primitives. Different model clusters have their own characteristics, and the probability of the same primitives appearing is low. Moreover, if multiple clusters use unified texture data, the texture data will contain too many primitives, and it may not be possible to use one texture image to store all the primitives. Multiple texture images are required to store them, which may cause some grids to reference multiple texture images. Multiple texture sampling will be performed during rendering, greatly increasing the rendering complexity.
[0056] First, a virtual scene rendering method provided by an embodiment of the present invention is introduced below.
[0057] Figure 1 A flowchart of a virtual scene rendering method provided in an embodiment of the present application. Figure 1 As shown, the method includes the following steps S11-S14.
[0058] Step S11, obtaining the data to be rendered corresponding to each bounding volume in the model cluster of the virtual scene, wherein the bounding volume includes at least one model, each model is divided into multiple grids, the grid contains a reference relationship to the data to be rendered, and the data to be rendered includes: material data and texture data referenced by the grid, and the texture data contains the primitives referenced by the grid.
[0059] Among them, scene rendering is the process of projecting pre-built scene materials into digital images. In HLOD technology, the entire virtual scene is divided into several model clusters, that is, the models in the virtual scene are grouped. The model clusters can be automatically divided by clustering algorithms, or by setting cluster constraints, such as material type or material static switch value, etc., to divide the models according to cluster constraints. Usually, the models in a cluster are relatively uniform in style.
[0060] A model cluster can be divided into multiple bounding volumes according to the spatial position. Each bounding volume includes at least one model, and each model is divided into multiple meshes. Each mesh contains references to the data to be rendered, including vertex coordinates (vertex), vertex color (color), normal (normal), texture coordinates (uv), triangle drawing sequence (triangle), etc.
[0061] The material data in the data to be rendered includes the normal information corresponding to each pixel of the model, that is, a normal is drawn at each point on the concave and convex surface of the model, and the direction of the normal is marked by the RGB color channel. The normal information may include a normal map. The texture data in the data to be rendered includes images, functions or other data sources used to change the appearance of the surface of the object. In this embodiment, the texture data includes primitives stored in the memory, which can be mapped to the surface of the model to be rendered through UV coordinates. A reference relationship is established in advance between the grid and the primitive.
[0062] Step S12: based on the material data corresponding to the grid, all the primitives in the model cluster are deduplicated to obtain the target primitive corresponding to the model cluster.
[0063] Since the styles of the models in the same model cluster are similar, there are a large number of meshes with the same material. In the texture data generated by HLOD for each bounding volume, the primitives corresponding to these meshes are also the same, that is, meshes with the same material have the same referenced primitives. For meshes that reference the same material, only one referenced primitive can be retained.
[0064] Step S13, generating target material data corresponding to the model cluster, and generating target texture data corresponding to the model cluster according to the target primitive.
[0065] Since the material data and texture data corresponding to each bounding volume in the entire model cluster are repeated, the final target material data and target texture data are obtained after deduplication of the material data or texture data.
[0066] Step S14, rendering the models in each bounding volume in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster.
[0067] In this embodiment, the meshes of the models in all bounding volumes of a model cluster are counted, and the primitives referenced by the meshes are deduplicated based on the material data corresponding to the meshes, and finally a unified material data and texture data are generated for all bounding volumes of the model cluster. Since a large number of duplicate primitives are removed from the texture data, the number of primitives included in the finally generated texture data is reduced, thereby avoiding excessive occupation of memory resources and saving memory.
[0068] In addition, the same texture data is used for all bounding volumes, and the size of each primitive in the texture data is the same. Due to primitive deduplication, the number of primitives included in the final texture data is reduced, and the final texture image corresponding to the bounding volume has high clarity and better rendering of the model. Moreover, different bounding volumes use the same texture data, and the display effect of models located in different bounding volumes is consistent.
[0069] In an optional embodiment, in the above step S13, generating target material data corresponding to the model cluster includes:
[0070] Step A1, obtaining material data corresponding to each mesh in the model cluster, the material data including normal information corresponding to each pixel point;
[0071] Step A2: After removing duplicates from the material data, merge them to obtain target material data.
[0072] During art production, in a model cluster, the same material generally uses the same identifier. For example, the model of a door has a material identifier of "door", and the model of a window has a material identifier of "window". Therefore, the material identifier of the material data can be used to determine whether each mesh references the same material data. In another case, there may be some differences in the identifiers used for the same material. For example, the model of a door has material identifiers corresponding to "door 1", "door 2", "door 3"... In this case, the material data corresponding to these material identifiers can also be determined to be the same. In an optional embodiment, it is also possible to determine whether the material data is the same by comparing the normal information contained in the material data, such as the Normal map.
[0073] For multiple identical material data, only one copy can be retained, that is, meshes with the same material all reference the same material data and the same texture data. After the material data is deduplicated, the remaining different material data are merged together to obtain a target material data for subsequent rendering of the entire model cluster.
[0074] For example, in the prior art, a model cluster has 9 bounding volumes, and a corresponding material ball is generated for each bounding volume. Since the model styles in the entire model cluster are highly similar, the material balls corresponding to each bounding volume are also highly similar. In some model clusters, the material balls corresponding to each bounding volume are even the same. Therefore, the material data can be deduplicated and the remaining different material data can be merged into one material ball, that is, the entire model cluster references this one material ball, thereby reducing the amount of material data stored in the memory.
[0075] In an optional embodiment, the above step S12, the operation of deduplicating primitives, includes:
[0076] Step B1, for meshes that reference the same material data, retain the primitive referenced by any of the meshes as the target primitive;
[0077] Step B2, setting the mesh reference target primitive with the same material data.
[0078] For example, for all meshes that reference the material data "door", only the primitive referenced by one of the meshes is retained, that is, the meshes with the same material data only correspond to one primitive; or, for all the material data "door 1", "door 2", "door 3", etc., only the primitive referenced by one of the meshes is retained. In the end, meshes with the same material all reference the same primitive. Reduce the amount of texture data stored in memory.
[0079] In an optional embodiment, the above step S13, merging the deduplicated primitives into one image, includes:
[0080] Step C1, collect all target primitives into a target image;
[0081] Step C2, generating target texture data according to the target image.
[0082] In the above step C1, when combining the target primitive into the target image, the size of the primitive and the size of the target image may be limited to ensure the clarity of the primitive and avoid the target image being too large. Step C1 includes:
[0083] Step D1, obtaining the minimum image element size in the preset target image elements and the maximum image size corresponding to the target image;
[0084] Step D2, calculating the actual image size of the target image and the actual pixel size of the target pixel according to the pixel number of the target pixel, so that the image size is less than or equal to the maximum image size, and the pixel size of the target pixel is greater than or equal to the minimum pixel size, wherein the image size is W x H, and W and H are powers of 2;
[0085] Step D3, generating a target image according to the actual image size and the actual primitive size.
[0086] Optionally, the target image may be a rectangular or square image, that is, W and H may be unequal or equal.
[0087] For example, the maximum image size corresponding to the target image is 2048×2048, and the minimum image size corresponding to each element is 128×128, then the target image can accommodate a maximum of 256 elements. If 31 target elements are obtained after deduplication, the maximum image size and minimum element size that meet the preset maximum image size and minimum element size are automatically adapted.
[0088] If the size of each target primitive is 128×128, a 1024×1024 target image can be generated; or, according to actual needs, such as rendering effect requirements, the target primitive size can be set to 256×256 to generate a 2048×2048 target image.
[0089] In an optional embodiment, in the process of generating a target image, when the calculated image size of the target image is larger than the maximum image size, the method further includes: executing a preset reminder operation, the preset reminder operation is used to indicate that resources are not being used reasonably; and / or, detecting the similarity between target graphic elements; when the similarity is greater than or equal to a preset threshold, outputting prompt information for the target graphic element whose similarity is greater than or equal to the preset threshold.
[0090] For example, the maximum image size corresponding to the preset target image is 2048×2048, and the minimum image size corresponding to each image element is 128×128, then the target image can accommodate up to 256 images. In theory, the target image can contain target images corresponding to any cluster. If the number of target images exceeds 256, it means that the production of the cluster has not reused the same resources as much as possible, or the same resources are stored in multiple copies, or the production itself uses too many unconventional operations. At this time, a reminder operation can be triggered, such as a pop-up window reminder, or a message or email can be sent to the production staff to remind them to check the scene production.
[0091] In an optional embodiment, when the number of target primitives exceeds the maximum number of primitives that the target image can accommodate, it is also possible to analyze whether there are primitives with high similarity or completely identical in the current target primitives, and prompt these identical or similar primitives. Optionally, duplicate removal can be performed directly for identical primitives until the target primitive data is less than the maximum number of primitives that the target image can accommodate or the final target primitives are all different.
[0092] In an optional embodiment, the above step S14 includes:
[0093] Step E1, regenerating a target mesh for the model in each bounding volume according to the target material data and the target texture data, wherein the target mesh contains a reference relationship with the target material data and the target texture data;
[0094] Step E2, based on the target material data and target texture data referenced by the target mesh, the model to which the target mesh belongs is rendered to obtain a rendered model cluster.
[0095] Since unified target material data and target texture data are generated for the entire model cluster through steps S11-S13, it is necessary to recalculate the reference relationship of each mesh to the target material data and target texture data, that is, the normal, UV and other information corresponding to each vertex. After obtaining the target mesh after the recalculated reference relationship, each model is rendered according to the target material data and target texture data referenced by each target mesh, and finally a rendered model cluster is obtained to realize the rendering of the virtual scene.
[0096] The above method embodiment is described in detail below with a specific example.
[0097] like Figure 2 As shown in Figure 1, a model cluster of a game scene has 9 bounding volumes, and the texture images corresponding to the 9 bounding volumes contain 876 primitives in total. Figure 3 As shown, in the texture data of each bounding volume, the primitive repetition is high.
[0098] Since the number of grids in each bounding volume is different, the size of the final texture image corresponding to each bounding volume is consistent but the number of primitives contained is different, which leads to different resolutions of the same primitives in the final texture image corresponding to each bounding volume. Figure 3 As shown in , the number of primitives in the final texture image corresponding to the bounding volume containing more models is large, and the primitive compression rate is too large, resulting in blurry display. Figure 4 As shown in the figure, the number of primitives in the final texture image corresponding to the bounding volume containing fewer models is small, so the primitive compression rate is too small and the display is clear. In the texture images corresponding to the two bounding volumes, the resolution of the same primitive is different, so the rendering effect of the same model is different during rendering.
[0099] Through the above method embodiment, the primitives contained in the texture data of the 9 bounding volumes are deduplicated, such as Figure 5 As shown in , after deduplication, the remaining 31 primitives are placed in a final texture image. After deduplication of the material data corresponding to each grid, the final material data is obtained. Figure 6 As shown, the model cluster retains one copy of the final target material data, and the final target texture image is 1.
[0100] After obtaining 31 target primitives, the most suitable target image size and target primitive size are automatically adapted according to the preset maximum image size of the target image of 2048×2048 and the minimum primitive size corresponding to each primitive of 128×128. For example, if the 31 target primitives are saved in a 1024×1024 target image, the size of each target primitive is 128×128.
[0101] From the above examples, it can be seen that each bounding volume in the model cluster is rendered using the same material data and texture data, thereby avoiding excessive occupation of memory resources by the data to be rendered, saving memory, and the resolution of the target primitives is consistent, there is no excessive compression, and the model rendering effect is better; the same models located in different bounding volumes are rendered using the same texture data, and the display effects of these models are consistent.
[0102] The following are device embodiments of the present application, which can be used to execute method embodiments of the present application.
[0103] Figure 7 This is a block diagram of a virtual scene rendering device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 7 As shown, the device comprises:
[0104] The acquisition module 81 is used to acquire the data to be rendered corresponding to each bounding volume in the model cluster of the virtual scene, the bounding volume includes at least one model, each model is divided into multiple grids, the grids contain references to the data to be rendered, the data to be rendered includes: material data and texture data referenced by the grids, the texture data contains the primitives referenced by the grids;
[0105] A deduplication module 82, used to deduplicate all primitives in the model cluster based on material data corresponding to the grid, and obtain target primitives corresponding to the model cluster;
[0106] A generating module 83, used to generate target material data corresponding to the model cluster, and to generate target texture data corresponding to the model cluster according to the target primitive;
[0107] The rendering module 84 is used to render the models in each bounding volume in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster.
[0108] Optionally, the generation module 83 is used to obtain material data corresponding to each mesh in the model cluster, where the material data includes normal information corresponding to each pixel point; after deduplication of the material data, the material data is merged to obtain target material data.
[0109] Optionally, a rendering module 84 is used to regenerate a target mesh for the model in each bounding volume based on the target material data and the target texture data, wherein the target mesh contains a reference relationship with the target material data and the target texture data; based on the target material data and the target texture data referenced by the target mesh, the model to which the target mesh belongs is rendered to obtain a rendered model cluster.
[0110] Optionally, the deduplication module 82 is used to retain the primitives referenced by any of the meshes that reference the same material data as target primitives; and set the target primitives to be referenced by the meshes with the same material data.
[0111] Optionally, the generating module 83 is used to collect all target primitives into a target image; and generate target texture data according to the target image.
[0112] Optionally, a generation module 83 is used to obtain the minimum primitive size among the preset target primitives and the maximum image size corresponding to the target image; calculate the actual image size of the target image and the actual primitive size of the target primitive based on the number of primitives in the target primitive, so that the actual image size is less than or equal to the maximum image size, and the actual primitive size of the target primitive is greater than or equal to the minimum primitive size, wherein the image size is W x H, W and H are powers of 2; and generate the target image based on the actual image size and the actual primitive size.
[0113] Optionally, the device also includes: when the calculated image size of the target image is larger than the maximum image size, executing a preset reminder operation, the preset reminder operation is used to indicate that resources are not used reasonably; and / or, detecting the similarity between target graphics elements; when the similarity is greater than or equal to a preset threshold, outputting prompt information for the target graphics elements whose similarity is greater than or equal to the preset threshold.
[0114] The present application also provides an electronic device, such as Figure 8 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .
[0115] Memory 1503, used for storing computer programs;
[0116] The processor 1501 is used to implement the steps of the above method embodiment when executing the computer program stored in the memory 1503.
[0117] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0118] The communication interface is used for communication between the above electronic device and other devices.
[0119] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0120] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0121] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method embodiment described below are implemented.
[0122] It should be noted that, for the above-mentioned device, electronic device and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0123] It should be further noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0124] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A virtual scene rendering method, characterized in that: include: Acquire the data to be rendered corresponding to each bounding volume in the model cluster of the virtual scene, wherein the bounding volume includes at least one model, each of the models is divided into a plurality of grids, the grids contain references to the data to be rendered, and the data to be rendered includes: material data and texture data referenced by the grids, and the texture data contains primitives referenced by the grids; Based on the material data corresponding to the grid, all the primitives in the model cluster are deduplicated to obtain the target primitive corresponding to the model cluster; Generate target material data corresponding to the model cluster, and generate target texture data corresponding to the model cluster according to the target primitive; The models in each of the bounding volumes in the model cluster are rendered according to the target material data and the target texture data to obtain a rendered model cluster.
2. The method according to claim 1, characterized in that The generating target material data corresponding to the model cluster includes: Acquire material data corresponding to each mesh in the model cluster, wherein the material data includes normal information corresponding to each pixel point; After deduplication of the material data, the material data are merged to obtain the target material data.
3. The method according to claim 2, characterized in that The step of rendering the models in each of the bounding volumes in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster includes: Regenerate a target mesh for the model in each of the bounding volumes according to the target material data and the target texture data, wherein the target mesh contains a reference relationship with the target material data and the target texture data; Based on the target material data and target texture data referenced by the target grid, the model to which the target grid belongs is rendered to obtain a rendered model cluster.
4. The method according to claim 1, characterized in that Based on the material data corresponding to the grid, all the primitives in the model cluster are deduplicated to obtain the target primitive corresponding to the model cluster, including: For meshes that reference the same material data, retaining the primitive referenced by any of the meshes as the target primitive; Set the mesh with the same material data as the target primitive.
5. The method according to claim 1, characterized in that Generating target texture data corresponding to the model cluster according to the target primitives includes: Collecting all the target primitives into a target image; The target texture data is generated according to the target image.
6. The method according to claim 5, characterized in that All of the target primitives are assembled into a target image, including: Obtaining a preset minimum image element size among the target image elements and a maximum image size corresponding to the target image; Calculating, according to the number of picture elements of the target picture element, an actual image size of the target image and an actual picture element size of the target picture element, so that the actual image size is less than or equal to the maximum image size, and the actual picture element size of the target picture element is greater than or equal to the minimum picture element size, wherein the image size is W x H, and W and H are powers of 2; The target image is generated according to the actual image size and the actual primitive size.
7. The method according to claim 6, characterized in that When the calculated image size of the target image is larger than the maximum image size, the method further includes: Executing a preset reminder operation, wherein the preset reminder operation is used to indicate that a resource is not used properly; And / or, detecting the similarity between the target graphic elements; when the similarity is greater than or equal to a preset threshold, outputting prompt information for the target graphic elements whose similarity is greater than or equal to the preset threshold.
8. A virtual scene rendering device, characterized in that: include: An acquisition module is used to acquire data to be rendered corresponding to each bounding volume in a model cluster of a virtual scene, wherein the bounding volume includes at least one model, each of which is divided into a plurality of grids, wherein the grids include references to the data to be rendered, and wherein the data to be rendered includes: material data and texture data referenced by the grids, wherein the texture data includes primitives referenced by the grids; A deduplication module, used for deduplicating all primitives in the model cluster based on material data corresponding to the grid, to obtain target primitives corresponding to the model cluster; A generating module, used to generate target material data corresponding to the model cluster, and generate target texture data corresponding to the model cluster according to the target primitive; A rendering module is used to render the models in each of the bounding volumes in the model cluster according to the target material data and the target texture data to obtain a rendered model cluster.
9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the method steps described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Large-scale building scene rendering acceleration method, system and device and storage medium
CN110443893A
Method for visually displaying dynamic layout of incremental primitives, terminal device and storage medium
CN110851225A
