Model rendering method and device, storage medium and electronic device
By disassembling the three-dimensional model into blocks and mapping it to a two-dimensional plane and merging the texture coordinates, the technical effect of reducing memory usage in a three-dimensional scene is achieved, and the model optimization problem in the existing technology is solved.
Patent Information
- Application Number
- CN202411272827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-17
AI Technical Summary
In three-dimensional scenarios, it is difficult for the existing technology to reduce memory usage while ensuring the rendering quality of the model. The solution to reduce the memory usage of the model is mainly to reduce the map resolution. However, when the map resolution is reduced to a certain level, it is impossible to further optimize the memory usage. It does not affect the rendering quality.
By disassembling the three-dimensional model into multiple blocks and mapping its three-dimensional spatial coordinates to a two-dimensional plane, we obtain the texture coordinates of the map, and then merge multiple maps into a second map with the same resolution, and use the second map to match the model Perform rendering to reduce the memory usage of the model.
It effectively reduces the memory usage of the model's map, so that the optimized model can reduce memory usage while ensuring quality, solves the problem of model optimization in three-dimensional scenarios, and realizes the possibility of using high-quality models on mobile devices.
Smart Images

Figure CN119152099A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a model rendering method and device, a storage medium, and an electronic device. Background Art
[0002] In 3D scenes, the common solution in the industry to reduce the memory usage of models is to continuously reduce the quality until the memory occupied by the model is reduced to an acceptable range. Reducing the quality mainly starts from two aspects: streamlining the structure of the model itself and compressing the textures on the surface of the model. Among them, compressing the textures on the surface of the model is more efficient.
[0003] In the related art, a method to reduce the memory usage of textures is to reduce the resolution of the textures of the model. However, there is a situation where the resolution of the textures has been reduced to the lower limit that can maintain the rendering quality of the model, but the memory usage of the model cannot be reduced.
[0004] Regarding the related technologies, in three-dimensional scenes, how to optimize the model so that the optimized model can reduce memory usage while ensuring the quality, and no effective solution has been proposed.
[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0006] The embodiments of the present application provide a model rendering method and device, a storage medium and an electronic device to at least solve the problem in the related art of how to optimize the model in a three-dimensional scene so that the optimized model can reduce memory usage while ensuring quality.
[0007] According to one aspect of an embodiment of the present application, a model rendering method is provided, including: decomposing a first model into multiple blocks, and mapping the three-dimensional spatial coordinates of the multiple blocks to a two-dimensional plane respectively, to obtain map texture coordinates corresponding to the first model, wherein the map texture coordinates are used to indicate the mapping coordinates of the three-dimensional spatial coordinates of any point on the first model on the two-dimensional plane; merging multiple first maps used to render the first model into a second map through the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map; and rendering the first model through the second map to obtain a second model.
[0008] In an exemplary embodiment, the three-dimensional space coordinates of the multiple blocks are respectively mapped to a two-dimensional plane to obtain the mapping texture coordinates corresponding to the first model, including: determining a first point in each block, wherein the first point is a reference point for mapping the three-dimensional space coordinates of each block to a two-dimensional plane; extracting a second point and a third point in each block according to the first point; mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to a first area and a second area on the two-dimensional plane, respectively, to obtain the mapping texture coordinates, wherein the first area and the second area have the same area, and the range of the two-dimensional plane is a preset range.
[0009] In an exemplary embodiment, extracting the second point and the third point in each block based on the first point includes: determining the angle between a fourth point in each block and the first point, wherein the fourth point is any point among the remaining points in each block except the first point; determining the fourth point whose angle with the first point is greater than a preset angle as the second point; and determining the fourth point whose angle with the first point is less than or equal to the preset angle as the third point.
[0010] In an exemplary embodiment, before mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to the first area and the second area on the two-dimensional plane respectively, the method further includes: determining whether the amount of information included in the third map corresponding to each block is greater than a preset threshold, wherein the third map is the map corresponding to each block in the multiple first maps; when the amount of information is greater than the preset threshold, setting a first area coefficient for each block; when the amount of information is less than or equal to the preset threshold, setting a second area coefficient for each block, wherein the first area coefficient is greater than the second area coefficient, and both the first area coefficient and the second area coefficient are used to indicate the area allowed to be occupied by each block when projected onto the two-dimensional plane.
[0011] In an exemplary embodiment, determining whether the amount of information included in the third map corresponding to each block is greater than a preset threshold includes: obtaining a map name of the third map; extracting a first field from the map name; when the first field is the same as a preset field, determining that the amount of information included in the third map is greater than the preset threshold; when the first field is different from the preset field, determining that the amount of information included in the third map is less than or equal to the preset threshold.
[0012] In an exemplary embodiment, multiple first maps used to render the first model are merged into a second map through the map texture coordinates, including: determining a target block corresponding to each first map among the multiple blocks; and outputting the map information included in the fifth point on each first map to a third area corresponding to the target block on the two-dimensional plane according to the map texture coordinates to obtain the second map.
[0013] In an exemplary embodiment, the first model is rendered using the second map to obtain the second model, including: acquiring the map information of any point of the first model from the second map using the map texture coordinates; and rendering the first model using the map information of any point to obtain the second model.
[0014] According to another aspect of an embodiment of the present application, a model rendering device is also provided, including: a disassembly module, used to disassemble a first model into multiple blocks, and map the three-dimensional space coordinates of the multiple blocks to a two-dimensional plane respectively, to obtain the map texture coordinates corresponding to the first model, wherein the map texture coordinates are used to indicate the mapping coordinates of the three-dimensional space coordinates of any point on the first model on the two-dimensional plane; a merging module, used to merge multiple first maps used to render the first model into a second map through the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map; a rendering module, used to render the first model through the second map to obtain a second model.
[0015] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned model rendering method when running.
[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the model rendering method through the computer program.
[0017] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned model rendering method is implemented.
[0018] Through the present application, the first model is disassembled into multiple blocks, and the three-dimensional space coordinates of the multiple blocks are respectively mapped to the two-dimensional plane to obtain the texture coordinates of the map corresponding to the first model, wherein the texture coordinates of the map are used to indicate the mapping coordinates of the three-dimensional space coordinates of any point on the first model on the two-dimensional plane; then the multiple first maps used to render the first model are merged into a second map with the same resolution as the multiple first maps through the texture coordinates of the map; finally, the first model is rendered through the second map to obtain the second model. That is to say, by mapping the three-dimensional space coordinates of the three-dimensional model to obtain the texture coordinates of the map, and merging the multiple first maps into the second map with the same resolution as the multiple first maps according to the texture coordinates of the map, the memory occupation of the model's map can be directly reduced, so that the memory occupation of the second model obtained by rendering the second map is also reduced. Therefore, the above technical solution is adopted to solve the problem of how to optimize the model in the three-dimensional scene in the related technology so that the optimized model can reduce the memory occupation while ensuring the quality; and the technical effect of reducing the memory occupation while ensuring the quality of the model is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application 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 labor.
[0021] Figure 1 is a schematic diagram of a hardware environment of an optional model rendering method according to an embodiment of the present application;
[0022] Figure 2 is a flowchart of an optional model rendering method according to an embodiment of the present application;
[0023] Figure 3 is a first texture schematic diagram of an optional model rendering method according to an embodiment of the present application;
[0024] Figure 4 is a second texture schematic diagram of an optional model rendering method according to an embodiment of the present application;
[0025] Figure 5 is a schematic diagram of a washing machine model according to an optional model rendering method of an embodiment of the present application;
[0026] Figure 6is a schematic diagram of a low-quality rendering effect of an optional model rendering method according to an embodiment of the present application;
[0027] Figure 7 is a schematic diagram of a bump map of an optional model rendering method according to an embodiment of the present application;
[0028] Figure 8 is a schematic diagram of a model rendering effect with a bump map according to an optional model rendering method of an embodiment of the present application;
[0029] Fig. 9 is a schematic diagram of a model rendering effect without a bump map according to an optional model rendering method of an embodiment of the present application;
[0030] Fig.10 is another flow chart of an optional model rendering method according to an embodiment of the present application;
[0031] Fig.11 It is a structural block diagram of an optional model rendering device according to an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the solution of the present application, 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 only 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 creative work should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] According to one aspect of an embodiment of the present application, a model rendering method is provided. The model rendering method is widely used in smart home (Smart Home), smart home, smart home device ecology, smart house (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned model rendering method can be applied to Figure 1 In the hardware environment shown in FIG. 1 , a plurality of terminal devices 102 and a server 104 are formed. Figure 1 As shown, the server 104 is connected to multiple terminal devices 102 via a network, and can be used to provide services (such as application services, etc.) for the terminals or clients installed on the terminals. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0035] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0036] In this embodiment, a model rendering method is provided, including but not limited to being applied to computer devices, smart terminals, etc. Figure 2 is a flowchart of a model rendering method according to an embodiment of the present application, the process comprising the following steps:
[0037] Step S202: Decomposing the first model into a plurality of blocks, and mapping the three-dimensional space coordinates of the plurality of blocks to a two-dimensional plane respectively, to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used to indicate the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane;
[0038] Step S204: merging a plurality of first maps used for rendering the first model into a second map through the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map;
[0039] Step S206: Rendering the first model using the second map to obtain a second model.
[0040] Through the above steps, the first model is disassembled into multiple blocks, and the three-dimensional space coordinates of the multiple blocks are respectively mapped to the two-dimensional plane to obtain the texture coordinates of the map corresponding to the first model, wherein the texture coordinates of the map are used to indicate the mapping coordinates of the three-dimensional space coordinates of any point on the first model on the two-dimensional plane; then the multiple first maps used to render the first model are merged into a second map with the same resolution as the multiple first maps through the texture coordinates of the map; finally, the first model is rendered through the second map to obtain the second model. That is to say, by mapping the three-dimensional space coordinates of the three-dimensional model to obtain the texture coordinates of the map, and merging the multiple first maps into the second map with the same resolution as the multiple first maps according to the texture coordinates of the map, the memory occupation of the model's map can be directly reduced, so that the memory occupation of the second model obtained by rendering the second map is also reduced. Therefore, the above technical solution solves the problem of how to optimize the model in the three-dimensional scene in the related technology so that the optimized model reduces the memory occupation while ensuring the quality; and achieves the technical effect of reducing the memory occupation while ensuring the quality of the model.
[0041] In an exemplary embodiment, the three-dimensional space coordinates of the multiple blocks are respectively mapped to a two-dimensional plane to obtain the mapping texture coordinates corresponding to the first model, including: determining a first point in each block, wherein the first point is a reference point for mapping the three-dimensional space coordinates of each block to a two-dimensional plane; extracting a second point and a third point in each block according to the first point; mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to a first area and a second area on the two-dimensional plane, respectively, to obtain the mapping texture coordinates, wherein the first area and the second area have the same area, and the range of the two-dimensional plane is a preset range.
[0042] Optionally, determining the first point in each block includes at least one of the following: taking any point in each block as the first point; taking a point in each block at a preset point as the first point. The preset point may specifically include but is not limited to: the upper left corner, the center point, etc. of each block.
[0043] Optionally, the range of the two-dimensional plane may be consistent with the range of the first map, the first region and the second region are both within the two-dimensional plane, and the first regions may be adjacent or non-adjacent.
[0044] Furthermore, extracting the second point and the third point in each block based on the first point includes: determining the angle between a fourth point in each block and the first point, wherein the fourth point is any point among the remaining points in each block except the first point; determining the fourth point whose angle with the first point is greater than a preset angle as the second point; and determining the fourth point whose angle with the first point is less than or equal to the preset angle as the third point.
[0045] For example, the preset angle may be 30 degrees, 45 degrees, etc. It should be noted that if the second point and the third point can be extracted from each block, each block needs to be projected into two areas of the two-dimensional plane; if only one of the second point and the third point can be extracted from each block, each block can be projected into one area of the two-dimensional plane.
[0046] In another embodiment, multiple preset angles can be set to map each block in a finer granularity. The relationship between the first number of regions mapped to each block on the two-dimensional plane and the second number of the multiple preset angles is: first number=second number+1.
[0047] In an exemplary embodiment, before mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to the first area and the second area on the two-dimensional plane respectively, the method further includes: determining whether the amount of information included in the third map corresponding to each block is greater than a preset threshold, wherein the third map is the map corresponding to each block in the multiple first maps; when the amount of information is greater than the preset threshold, setting a first area coefficient for each block; when the amount of information is less than or equal to the preset threshold, setting a second area coefficient for each block, wherein the first area coefficient is greater than the second area coefficient, and both the first area coefficient and the second area coefficient are used to indicate the area allowed to be occupied by each block when projected onto the two-dimensional plane.
[0048] It is understandable that common types of maps for 3D models include: surface color map, metalness map, roughness map, ambient occlusion map, bump map. Among the above types of maps, there are information-intensive maps, for example, surface color map is usually an information-intensive map; wherein, an information-intensive map is a map whose information content is greater than a preset threshold.
[0049] In order to enable the information-intensive texture to still achieve high-quality rendering of the first model after being mapped to the second texture, a larger area coefficient (ie, the first area coefficient) needs to be set for the information-intensive texture.
[0050] Furthermore, determining whether the amount of information included in the third map corresponding to each block is greater than a preset threshold includes: obtaining the map name of the third map; extracting a first field from the map name; when the first field is the same as the preset field, determining that the amount of information included in the third map is greater than the preset threshold; when the first field is different from the preset field, determining that the amount of information included in the third map is less than or equal to the preset threshold.
[0051] Optionally, when configuring multiple first stickers, the target object (for example, a model designer) will mark the sticker name of the first sticker whether the first sticker is an information-intensive sticker. Exemplarily, when the preset field is "1", the extracted first field may be "1" or "0"; thus, it can be determined whether the third sticker is an information-intensive sticker. Optionally, the preset field may also be some special symbols, an English or Chinese word, etc., which is not limited in the embodiments of the present application.
[0052] In an exemplary embodiment, multiple first maps used to render the first model are merged into a second map through the map texture coordinates, including: determining a target block corresponding to each first map among the multiple blocks; and outputting the map information included in the fifth point on each first map to a third area corresponding to the target block on the two-dimensional plane according to the map texture coordinates to obtain the second map.
[0053] Optionally, in the process of outputting the mapping information of the target block to the third area, the embodiment of the present application can also allocate a pixel interval to the target block through a modifier. The range of the pixel interval is between 0 and 1, and different target blocks are allocated different pixel intervals. The modifier can be a UVW_Unwrap modifier.
[0054] It should be noted that, since common types of textures for 3D models include: surface color texture, metalness texture, roughness texture, ambient occlusion texture, and bump texture, multiple first textures will also be classified and merged into different types of second textures, that is, surface color textures in multiple first textures will be merged into one second texture of surface color type. Figure 3 As shown, there are 24 images in total. After the texture coordinates are mapped, the following is obtained: Figure 4 The 5 stickers shown.
[0055] In an exemplary embodiment, the first model is rendered using the second map to obtain the second model, including: acquiring the map information of any point of the first model from the second map using the map texture coordinates; and rendering the first model using the map information of any point to obtain the second model.
[0056] Optionally, in the process of rendering the first model through the second map, first determine the type of map information to be extracted (i.e., one of the surface color map, metalness map, roughness map, ambient occlusion map, and bump map), so as to determine the corresponding second map; determine the block to be rendered corresponding to the map information on the first model, and the pixel interval corresponding to the block to be rendered; determine the map information extraction area corresponding to the block to be rendered from the second map through the pixel interval; extract the map information from the map information extraction area through the map texture coordinates to render the first model to obtain the second model.
[0057] Obviously, the above-described embodiments are only a part of the embodiments of the present application, not all of the embodiments. In order to better understand the above-mentioned model rendering method, the above-mentioned process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:
[0058] The core assets of three-dimensional software, such as three-dimensional games, three-dimensional design tools, three-dimensional maps, and VR / MR applications, are models. The "quality and quantity" of the models are of decisive significance to the success of three-dimensional products. At present, the model production process is very mature, and both quality and quantity can be guaranteed. But higher quality inevitably means higher memory usage. Too much memory may not be a problem for high-performance desktops, but on mobile devices, especially on mobile phones, too much memory will cause the program to crash. This results in that although a lot of high-quality models have been accumulated, they cannot be used in user-oriented products. Therefore, how to optimize the model so that it can reduce memory usage while ensuring quality is the problem to be solved by the optional embodiments of this application.
[0059] Quality and memory are two mutually exclusive things, just like positive poles repel each other. This is the rule of the physical world and cannot be avoided. Therefore, the common solution to this problem in the industry is to continuously reduce the quality until the memory is reduced to an acceptable range. Reducing quality mainly starts from two aspects: streamlining the structure of the model itself and compressing the texture on the surface of the model. Optimizing the latter is more efficient because the density of information carried by the texture is much higher than the simple spatial position.
[0060] It should be noted that texture compression does not mean using image compression technologies such as JPEG and PNG to encode images to reduce their size in network transmission or disk storage. This is meaningless for memory optimization because the compressed images must be decompressed before they can be used. Therefore, the "most direct" method currently used by the industry to reduce texture memory is to reduce its resolution. For example, compressing the original 2048x2048 resolution image to 512x512, the memory usage of the texture will be effectively reduced. However, this processing method does not take into account the issue of "effective space utilization of images". This results in that when there are a large number of model textures, even if each image is compressed to a very low resolution, a large amount of space is wasted for each image, so in the end it is still impossible to reduce its memory usage to an acceptable range.
[0061] As Figure 5 Taking the washing machine model shown in the figure as an example, the number of textures generated by the common model making process in the industry is as follows: Figure 3 As many as 24 are shown, the memory usage reaches 268.6MB*. According to experience, the memory usage of a single model should be controlled below 10MB, so the model must be optimized for use on mobile devices. However, even if the resolution is reduced to 512x512, the memory usage is still 17MB. However, the rendering quality has dropped to the acceptable lower limit and cannot be compressed further. Figure 6 As shown, Figure 6 The low-quality rendering effect is shown in the figure. Figure 6 As can be seen in the figure, the icons rendered on the washing machine model are not clear. Therefore, the current scheme of compressing resolution has reached a dead end and it is impossible to further optimize memory while ensuring rendering quality.
[0062] In summary, reducing memory usage by compressing image resolution only solves the memory usage problem of a single image, but cannot solve the problem of memory accumulation caused by too many images. In addition, the rendering quality of the model is actually related to the image. For every image missing, the rendering of the model will lose some details. Therefore, it is impossible to reduce the memory usage of images by deleting images. Figure 7 Take the bump map shown in the figure for example. If you delete the bump map, the metal bump details in the washing machine drum will be lost, and the rendered model will look different. Figure 8 The effect shown is changed to Fig. 9 The effect shown.
[0063] Therefore, under the condition of ensuring the model rendering quality without losing details, compressing the image resolution can no longer further optimize the memory usage. However, an optional embodiment of the present application will combine multiple textures into one texture by a special means, which can reduce the memory usage while retaining all the textures.
[0064] It should be noted that if the maps are simply spliced together, which is called "stitched maps", it cannot solve the problem of how to optimize the model in a three-dimensional scene to reduce memory usage while ensuring quality, because the splicing process will continuously increase the resolution of the final image, and it will not be possible to reduce the final memory usage. The optional embodiment of the present application is to merge multiple images together in a "similar" stacking manner, and the resolution of the final image is the same as the merged image (equivalent to the resolution of each first map and the second map in the above embodiment being consistent). In this way, the memory usage changes from being linearly related to the number of images to a constant.
[0065] The optional embodiment of the present application will merge multiple pictures together in a "similar" stacking manner, but if it is simply stacked, there will inevitably be overlapping parts of multiple maps, so the final stacking result will be messed up. It is easy to think that the shape of the graphics inside the picture can be analyzed, and then the position of each graphic can be reasonably arranged when stacking to avoid the problem of stacking confusion. But in fact, the internal shape of the picture may be strange, and it is very difficult to analyze the shape of each graphic. Therefore, the optional embodiment of the present application adopts a reverse idea, using the model instead of the picture as the processing entrance, by disassembling the model into a large number of small blocks (equivalent to the multiple blocks in the above embodiment), and then projecting the three-dimensional space coordinates of these small blocks onto a two-dimensional plane, thereby obtaining a set of texture coordinates of the map*, and then re-outputting the color of the object (equivalent to the map information in the above embodiment) to a picture according to the texture coordinates, and a perfectly merged map (equivalent to the second map in the above embodiment) is obtained. Specifically, for small blocks, points within 30 degrees and points outside 30 degrees can be extracted separately, and the points can be mapped to a two-dimensional plane.
[0066] It should be noted that the texture coordinates are used to map three-dimensional space coordinates to two-dimensional texture coordinates, that is, they indicate where any point on the three-dimensional object (ie, the first model) should extract color from the map (ie, the second map).
[0067] In the specific implementation process, some special cases need to be considered: the texture on the surface of some objects (i.e. the first texture) contains dense information (such as text, patterns, etc.). At this time, when the surface of the object is projected onto a two-dimensional plane, it should occupy a larger projection area (i.e. have a first area coefficient). Because the larger the projection area, the larger the area it occupies in the final output image, and the clearer the information it reflects. Some objects do not need to participate in the texture merging process, such as transparent glass, large screen panels, etc.
[0068] Taking the above into consideration, the execution process of the optional embodiment of the present application is as follows: Fig.10 As shown, including:
[0069] Step 1: Input the original model (equivalent to the first model).
[0070] Step 2, obtain the texture coordinates of the map. Including but not limited to: analyzing the type of model map; determining whether it is an information-intensive map, if so, setting a larger projection area coefficient (equivalent to the first area coefficient), if not, setting a general projection area coefficient (equivalent to the second area coefficient). After setting the projection area coefficient, the projection area coefficient is given to the FlattenUVW projection operation in the modeling software process.
[0071] In step 2, the modeling software process includes: selecting all model objects (that is, multiple blocks obtained by disassembly); adding UVW_Unwrap modifier; performing FlattenUVW projection operation; and obtaining mapping texture coordinates.
[0072] Step 3, get the perfect merged map (i.e., the second map). Provide the five types of maps (i.e., multiple first maps) of surface color map, metalness map, roughness map, ambient occlusion map, and bump map to the Standard material for baking in the modeling software process. It should be noted that the surface color map, metalness map, roughness map, ambient occlusion map, and bump map correspond to Figure 4 base_color_map, metalness_map, Roughness_Map, diff_rough_map, bump_map in .
[0073] Step 3 includes the modeling software process: creating a Standard material for baking; rendering with Scanline renderer to get a perfectly merged map.
[0074] Step 4, merge the object and the texture (equivalent to rendering the first model through the second texture). Specifically, paste the perfectly merged texture back to the model object to be merged, and use the Scanline renderer to render to obtain the object with the merged texture. And before rendering, analyze the type of model object to determine whether it needs to be merged. If it needs to be merged, the model object is used as the model object to be merged. If not, directly obtain the object without the merged texture.
[0075] Step 5: Output a new model (ie, a second model). The new model is obtained by using the object without the merged texture and the object with the merged texture, and is output.
[0076] After executing the above process, the output mapping result is as follows: Figure 4 As shown in the figure, we can see that the number of textures has been reduced from 24 to 5, and there will always be 5. This is because the textures will be merged together according to their types, and the number of textures merged in the end is only related to the number of texture types. At this time, the memory usage of the model has dropped from 17MB to less than 10MB, which meets the requirements for use on mobile devices.
[0077] In summary, the optional embodiment of the present application efficiently and safely stacks multiple pictures that could not be directly stacked (there will be no problem of graphic overlap). Therefore, the relationship between the image memory usage and "the number of stickers" is converted into "the type of stickers", so as to further optimize the memory usage of stickers on the basis of compression resolution, and finally reach the standard for use on mobile devices. Therefore, the optional embodiment of the present application can achieve the technical effect that no matter how sophisticated the model is, the final memory usage can be maintained within an acceptable range.
[0078] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0079] In this embodiment, a model rendering device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0080] Fig.11 is a structural block diagram of an optional model rendering device according to an embodiment of the present application, the device comprising:
[0081] A disassembly module 1102 is used to disassemble the first model into multiple blocks, and respectively map the three-dimensional space coordinates of the multiple blocks to a two-dimensional plane to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used to indicate the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane;
[0082] A merging module 1104, configured to merge a plurality of first maps used for rendering the first model into a second map by using the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map;
[0083] The rendering module 1106 is used to render the first model using the second map to obtain a second model.
[0084] Through the above device, the first model is disassembled into multiple blocks, and the three-dimensional space coordinates of the multiple blocks are respectively mapped to the two-dimensional plane to obtain the texture coordinates of the map corresponding to the first model, wherein the texture coordinates of the map are used to indicate the mapping coordinates of the three-dimensional space coordinates of any point on the first model on the two-dimensional plane; then the multiple first maps used to render the first model are merged into a second map with the same resolution as the multiple first maps through the texture coordinates of the map; finally, the first model is rendered through the second map to obtain the second model. That is to say, by mapping the three-dimensional space coordinates of the three-dimensional model to obtain the texture coordinates of the map, and merging the multiple first maps into the second map with the same resolution as the multiple first maps according to the texture coordinates of the map, the memory occupation of the model's map can be directly reduced, so that the memory occupation of the second model obtained by rendering the second map is also reduced. Therefore, the above technical solution solves the problem of how to optimize the model in the three-dimensional scene in the related technology so that the optimized model reduces the memory occupation while ensuring the quality; and achieves the technical effect of reducing the memory occupation while ensuring the quality of the model.
[0085] In an exemplary embodiment, the disassembly module 1102 is used to: determine a first point within each block, wherein the first point is a reference point for mapping the three-dimensional spatial coordinates of each block to a two-dimensional plane; extract a second point and a third point within each block based on the first point; map the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to a first area and a second area on the two-dimensional plane, respectively, to obtain the mapping texture coordinates, wherein the first area and the second area have the same area, and the range of the two-dimensional plane is a preset range.
[0086] In an exemplary embodiment, the disassembly module 1102 is used to: determine the angle between the fourth point in each block and the first point, wherein the fourth point is any point in each block except the first point; determine the fourth point whose angle with the first point is greater than a preset angle as the second point; determine the fourth point whose angle with the first point is less than or equal to the preset angle as the third point.
[0087] In an exemplary embodiment, before mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to the first area and the second area on the two-dimensional plane respectively, the device also includes a setting module, which is used to: determine whether the amount of information included in the third map corresponding to each block is greater than a preset threshold, wherein the third map is the map corresponding to each block in the multiple first maps; if the amount of information is greater than the preset threshold, set a first area coefficient for each block; if the amount of information is less than or equal to the preset threshold, set a second area coefficient for each block, wherein the first area coefficient is greater than the second area coefficient, and the first area coefficient and the second area coefficient are both used to indicate the area allowed to be occupied by each block when projected onto the two-dimensional plane.
[0088] In an exemplary embodiment, the setting module is also used to: obtain the sticker name of the third sticker; extract the first field from the sticker name; when the first field is the same as a preset field, determine that the amount of information included in the third sticker is greater than a preset threshold; when the first field is different from the preset field, determine that the amount of information included in the third sticker is less than or equal to the preset threshold.
[0089] In an exemplary embodiment, the merging module 1104 is used to: determine the target block corresponding to each first map among the multiple blocks; and output the map information included in the fifth point on each first map to the third area corresponding to the target block on the two-dimensional plane according to the map texture coordinates to obtain the second map.
[0090] In an exemplary embodiment, the rendering module 1106 is used to: obtain the texture information of any point of the first model from the second map through the texture coordinates of the map; and render the first model through the texture information of any point to obtain the second model.
[0091] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0092] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0093] S1, decomposing a first model into a plurality of blocks, and mapping the three-dimensional space coordinates of the plurality of blocks to a two-dimensional plane respectively, to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used to indicate the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane;
[0094] S2, merging a plurality of first maps used for rendering the first model into a second map through the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map;
[0095] S3: Render the first model using the second map to obtain a second model.
[0096] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0097] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0098] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0099] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0100] S1, decomposing a first model into a plurality of blocks, and mapping the three-dimensional space coordinates of the plurality of blocks to a two-dimensional plane respectively, to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used to indicate the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane;
[0101] S2, merging a plurality of first maps used for rendering the first model into a second map through the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map;
[0102] S3: Render the first model using the second map to obtain a second model.
[0103] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0104] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0105] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0106] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0107] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0108] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0109] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A model rendering method, characterized in that: include: Decomposing the first model into a plurality of blocks, and mapping the three-dimensional space coordinates of the plurality of blocks to a two-dimensional plane respectively, to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used to indicate the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane; Merging a plurality of first maps used for rendering the first model into a second map by using the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map; The first model is rendered using the second map to obtain a second model.
2. The model rendering method according to claim 1, characterized in that: Mapping the three-dimensional space coordinates of the plurality of blocks to two-dimensional planes respectively to obtain the texture coordinates of the first model, including: Determine a first point in each block, wherein the first point is a reference point for mapping the three-dimensional space coordinates of each block to a two-dimensional plane; Extracting a second point and a third point in each block according to the first point; The three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point are respectively mapped to the first area and the second area on the two-dimensional plane to obtain the mapping texture coordinates, wherein the first area and the second area have the same area, and the range of the two-dimensional plane is a preset range.
3. The model rendering method according to claim 2, characterized in that: Extracting the second point and the third point in each block according to the first point includes: Determine an angle between a fourth point in each block and the first point, wherein the fourth point is any point among the remaining points in each block except the first point; Determine a fourth point whose angle with the first point is greater than a preset angle as the second point; A fourth point whose angle with the first point is less than or equal to the preset angle is determined as the third point.
4. The model rendering method according to claim 2, characterized in that: Before mapping the three-dimensional coordinates of the second point and the three-dimensional coordinates of the third point to the first area and the second area on the two-dimensional plane respectively, the method further includes: Determine whether the amount of information included in the third map corresponding to each block is greater than a preset threshold, wherein the third map is the map corresponding to each block in the plurality of first maps; When the amount of information is greater than the preset threshold, setting a first area coefficient for each block; When the amount of information is less than or equal to the preset threshold, a second area coefficient is set for each block, wherein the first area coefficient is greater than the second area coefficient, and both the first area coefficient and the second area coefficient are used to indicate the area that each block is allowed to occupy when projected onto the two-dimensional plane.
5. The model rendering method according to claim 4, characterized in that: Determining whether the amount of information included in the third map corresponding to each block is greater than a preset threshold includes: Get the name of the third image. Extracting a first field from the map name; In the case where the first field is the same as the preset field, determining that the amount of information included in the third map is greater than a preset threshold; In a case where the first field is different from the preset field, it is determined that the amount of information included in the third map is less than or equal to a preset threshold.
6. The model rendering method according to claim 1, characterized in that: Merging a plurality of first maps used for rendering the first model into a second map by using the map texture coordinates, comprising: Determine a target block corresponding to each first map among the multiple blocks; The texture information included in the fifth point on each first texture is output to a third area corresponding to the target block on the two-dimensional plane according to the texture coordinates to obtain the second texture.
7. The model rendering method according to claim 1, characterized in that: Rendering the first model by using the second map to obtain a second model includes: Acquire the texture information of any point of the first model from the second map through the texture coordinates of the map; The first model is rendered using the mapping information of any point to obtain the second model.
8. A model rendering device, characterized in that: include: a disassembly module, used for disassembling the first model into a plurality of blocks, and mapping the three-dimensional space coordinates of the plurality of blocks to a two-dimensional plane respectively, to obtain a mapping texture coordinate corresponding to the first model, wherein the mapping texture coordinate is used for indicating the mapping coordinate of the three-dimensional space coordinate of any point on the first model on the two-dimensional plane; A merging module, configured to merge a plurality of first maps used for rendering the first model into a second map by using the map texture coordinates, wherein the resolution of each first map is consistent with that of the second map; A rendering module is used to render the first model using the second map to obtain a second model.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
