Model rendering method and device

By mixing the first map and transition map of the three-dimensional virtual model, the rendering of seasonal replacement is achieved, which solves the problems of long time, high cost and large size caused by artificial art resources, and improves development efficiency and immersive experience.

CN113936088BActive Publication Date: 2025-08-29NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111290834.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-02
Publication Date
2025-08-29
Estimated Expiration
2041-11-02

AI Technical Summary

Technical Problem

In the prior art, artificially producing art resources of different seasons leads to a longer production time, higher cost and larger body size in game scenes.

Method used

By obtaining the first map and transition map of the three-dimensional virtual model, mixing and generating the target map, and rendering the three-dimensional virtual model based on the target map, achieving the performance of seasonal replacement and avoiding artificial art resources.

Benefits of technology

It improves the speed and efficiency of the development process, reduces development costs, reduces the volume of the package, and enhances the player's immersive experience and the realism of the game scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113936088B_ABST
    Figure CN113936088B_ABST
Patent Text Reader

Abstract

The present invention discloses a model rendering method and device. The method comprises: obtaining a first texture of a three-dimensional virtual model, wherein the first texture is used to represent the material used by the three-dimensional virtual model in the first season of a game scene; obtaining a transition texture of the three-dimensional virtual model, wherein the transition texture is used to represent the changing state of the material used by the three-dimensional virtual model during the transition from the first season to the second season; mixing the first texture and the transition texture to generate a target texture; and rendering the three-dimensional virtual model based on the target texture. The present invention solves the technical problem in related technologies of manually producing art resources for different seasons, which results in long production time, high production costs, and a large package size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a model rendering method and device. Background Art

[0002] Currently, seasonal expressions in game scenes are all reflected through art resources, which require manual production based on the characteristics of different seasons. This takes a long time and is costly, and the resulting game installation package is also large.

[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0004] The embodiments of the present invention provide a model rendering method and device to at least solve the technical problems in the related art of manually producing art resources for different seasons, which results in long production time, high production cost, and large package size.

[0005] According to one aspect of an embodiment of the present invention, a model rendering method is provided, which includes: obtaining a first map of a three-dimensional virtual model, wherein the first map is used to represent the material used by the three-dimensional virtual model in the first season in a game scene; obtaining a transition map of the three-dimensional virtual model, wherein the transition map is used to represent the change state of the material used by the three-dimensional virtual model during the transition from the first season to the second season; mixing the first map and the transition map to generate a target map; and rendering the three-dimensional virtual model based on the target map.

[0006] Optionally, obtaining a transition map of a three-dimensional virtual model includes: determining a second map based on the type of the three-dimensional virtual model, wherein the second map is used to represent the material used by the three-dimensional virtual model in the second season; generating a mask map corresponding to the first map, wherein the mask map is used to represent the part of the first map that changes at a preset moment of transition from the first season to the second season; and adding the mask map to a preset channel of the second map to obtain a transition map.

[0007] Optionally, determining the second texture based on the type of the three-dimensional virtual model includes: determining, according to the type of the three-dimensional virtual model, that the second texture is a material texture used by part or all of the three-dimensional virtual model in the second season.

[0008] Optionally, based on the type of the three-dimensional virtual model, determining that the second map is a material map used for part or all of the three-dimensional virtual model in the second season includes: when the type of the three-dimensional virtual model is a first preset type, determining that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a cover covering the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the season changes; when the type of the three-dimensional virtual model is a second preset type, determining that the second map is a material map used by the cover covering the three-dimensional virtual model in the second season, wherein the second preset type is used to characterize that the material map of the three-dimensional virtual model remains unchanged when the season changes.

[0009] Optionally, based on the type of the three-dimensional virtual model, determining the second map includes: when the type of the three-dimensional virtual model is the ground, determining the second map as the material map used by the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a tree, determining the second map as the material map used by the first part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is grass, determining the second map as the material map used by the second part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a preset item, determining the second map as the material map used by the first covering on the three-dimensional virtual model in the second season, wherein the material map of the preset item remains unchanged when the seasons change; when the type of the three-dimensional virtual model is a building or road surface, determining the second map as the material map used by the second covering on the three-dimensional virtual model in the second season.

[0010] Optionally, when the type of the three-dimensional virtual model is a ground surface, generating a mask map corresponding to the first map includes: generating the mask map based on the first map; and determining a value range of the mask map based on a preset time.

[0011] Optionally, when the type of the three-dimensional virtual model is a tree, generating a mask map corresponding to the first map includes: determining a grayscale value corresponding to a preset moment, wherein the grayscale value is used to represent the grayscale value of a preset channel of the first map, and different grayscale values ​​correspond to different parts of the three-dimensional virtual model; generating a mask map based on the grayscale value.

[0012] Optionally, when the type of the three-dimensional virtual model is grass, generating a mask map corresponding to the first map includes: obtaining a first channel map and a second channel map corresponding to the grass, wherein the first channel map is used to represent the three-dimensional virtual model, and the second channel map is used to represent other part models in the three-dimensional virtual model except the second part model; obtaining the difference between the first channel map and the second channel map to obtain the mask map.

[0013] Optionally, when the type of the three-dimensional virtual model is a preset object, generating a mask map corresponding to the first map includes: determining the coverage of the first covering on the model; and generating the mask map based on the coverage and the first map.

[0014] Optionally, when the type of the three-dimensional virtual model is a building or a road surface, generating the mask map corresponding to the first map includes: generating the mask map based on a value of a preset channel of the first map.

[0015] According to another aspect of an embodiment of the present invention, a model rendering device is also provided, including: a first acquisition module for acquiring a first map of a three-dimensional virtual model, wherein the first map is used to represent the material used by the three-dimensional virtual model in the first season in the game scene; a second acquisition module for acquiring a transition map of the three-dimensional virtual model, wherein the transition map is used to represent the change state of the material used by the three-dimensional virtual model during the transition from the first season to the second season; a mixing module for mixing the first map and the transition map to generate a target map; and a rendering module for rendering the three-dimensional virtual model based on the target map.

[0016] Optionally, the generation module includes: a determination unit for determining a second map based on the type of the three-dimensional virtual model, wherein the second map is used to represent the material used by the three-dimensional virtual model in the second season; a generation unit for generating a mask map corresponding to the first map, wherein the mask map is used to represent the part of the first map that changes at a preset moment of transition from the first season to the second season; and an adding unit for adding the mask map to a preset channel of the second map to obtain a transition map.

[0017] Optionally, the determining unit is further configured to determine, based on the type of the three-dimensional virtual model, that the second texture is a material texture used by part or all of the three-dimensional virtual model in the second season.

[0018] Optionally, the determination unit is also used to, when the type of the three-dimensional virtual model is a first preset type, determine that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a cover covering the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the seasons change; and when the type of the three-dimensional virtual model is a second preset type, determine that the second map is a material map used by the cover covering the three-dimensional virtual model in the second season, wherein the second preset type is used to characterize that the material map of the three-dimensional virtual model remains unchanged when the seasons change.

[0019] Optionally, the determination unit is also used to, when the type of the three-dimensional virtual model is the surface, determine that the second map is the material map used by the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a tree, determine that the second map is the material map used by the first part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is grass, determine that the second map is the material map used by the second part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a preset object, determine that the second map is the material map used by the first cover covering the three-dimensional virtual model in the second season, wherein the material map of the preset object remains unchanged when the seasons change; when the type of the three-dimensional virtual model is a building or a road surface, determine that the second map is the material map used by the second cover covering the three-dimensional virtual model in the second season.

[0020] Optionally, the generating unit is further configured to generate a mask map based on the first map when the type of the three-dimensional virtual model is a ground surface, and determine a value range of the mask map based on a preset time.

[0021] Optionally, the generation unit is also used to determine the grayscale value corresponding to a preset moment when the type of the three-dimensional virtual model is a tree, and to generate a mask map based on the grayscale value, wherein the grayscale value is used to represent the grayscale value of a preset channel of the first map, and different grayscale values ​​correspond to different parts of the three-dimensional virtual model.

[0022] Optionally, the generation unit is also used to obtain the first channel map and the second channel map corresponding to the grass when the type of the three-dimensional virtual model is grass, and obtain the difference between the first channel map and the second channel map to obtain a mask map, wherein the first channel map is used to represent the three-dimensional virtual model, and the second channel map is used to represent other partial models in the three-dimensional virtual model except the second partial model.

[0023] Optionally, the generating unit is further configured to, when the type of the three-dimensional virtual model is a preset object, determine a coverage range of the first covering on the model, and generate a mask map based on the coverage range and the first map.

[0024] Optionally, the generating unit is further configured to generate a mask map based on a value of a preset channel of the first map when the type of the three-dimensional virtual model is a building or a road surface.

[0025] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the model rendering method in the above embodiment.

[0026] According to another aspect of an embodiment of the present invention, an electronic device is also provided, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a program that can be executed by the at least one processor, and when the program is executed by the at least one processor, the model rendering method in the above embodiment is executed.

[0027] In an embodiment of the present invention, a first texture of a three-dimensional virtual model is obtained by mixing material textures, and a transition texture of the three-dimensional virtual model is obtained. The first texture and the transition texture are then mixed to generate a target texture. Finally, the three-dimensional virtual model is rendered based on the target texture, thereby achieving the purpose of adding seasonal changes to the three-dimensional virtual model. It is easy to notice that by generating a transition texture and superimposing it with the first texture, seasonal changes can be expressed on the material without the need for artists to produce corresponding art resources. This achieves the technical effect of improving the speed and efficiency of the development process, reducing the cost of the development process, thereby reducing the package size, enhancing the player's immersive experience, and increasing the realism of the game scene. This solves the technical problem in the related art of manually producing art resources for different seasons, which results in long production time, high production costs, and a large package size. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0029] Figure 1 is a flowchart of a model rendering method according to an embodiment of the present invention;

[0030] Figure 2 is a schematic diagram of seasonal changes in a three-dimensional virtual model of an optional surface type according to an embodiment of the present invention;

[0031] Figure 3a is a schematic diagram of an original material map of an optional three-dimensional virtual model of a tree type according to an embodiment of the present invention;

[0032] Figure 3b is a schematic diagram of an alpha map of an optional three-dimensional virtual model of a tree type according to an embodiment of the present invention;

[0033] Figure 4a is a schematic diagram of an optional original material map of a three-dimensional virtual model of a grass type according to an embodiment of the present invention;

[0034] Figure 4b is a schematic diagram of an alpha map of an optional three-dimensional virtual model of a grass type according to an embodiment of the present invention;

[0035] Figure 4c is a schematic diagram of a mask map of an optional three-dimensional virtual model of a grass type according to an embodiment of the present invention;

[0036] Figure 5 is a schematic diagram of seasonal changes in a three-dimensional virtual model of an optional rock type according to an embodiment of the present invention;

[0037] Figure 6a is a schematic diagram of an original material map of a three-dimensional virtual model of an optional road type according to an embodiment of the present invention;

[0038] Figure 6b is a schematic diagram of a mask map of an optional three-dimensional virtual model of a grass type according to an embodiment of the present invention;

[0039] Figure 7 2 is a schematic diagram of a model rendering device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0041] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention 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 numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes 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.

[0042] According to an embodiment of the present invention, a model rendering method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0043] Figure 1 is a flow chart of a model rendering method according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:

[0044] Step S102 : obtaining a first texture of the three-dimensional virtual model, wherein the first texture is used to represent a material used by the three-dimensional virtual model in the first season in the game scene.

[0045] The aforementioned three-dimensional virtual model may be a model that needs to be enhanced with seasonal representations. This model can be displayed on a graphical user interface for user viewing. For example, still using the graphical user interface as a game interface, the three-dimensional virtual model may include models of the ground, road surface, buildings, trees, and grass. The same three-dimensional virtual model may appear differently in different seasons, and different three-dimensional virtual models may also appear differently in the same season. For example, in the case of a three-dimensional virtual model consisting of trees and grass, the leaves of trees are green in spring and fall in autumn, while the grass blooms in spring.

[0046] The first texture in the above steps can be the original material texture of the 3D virtual model. If seasonal changes are not considered, the 3D virtual model can be rendered directly using the original material texture. If seasonal changes are considered, a blending method can be used to represent seasonal changes based on the original material texture. In this embodiment of the present invention, artists can pre-create material textures for different seasons, thereby achieving seasonal changes based on these textures.

[0047] The first season in the above steps may be the current season in the game scene, serving as the starting season for the season change, and this season has nothing to do with the season in the real environment.

[0048] Step S104 : obtaining a transition map of the three-dimensional virtual model, wherein the transition map is used to represent a change state of a material used by the three-dimensional virtual model during a transition from the first season to the second season.

[0049] The second season in the above steps can be another season in the game scene, serving as the ending season of the season change. For example, it can be an adjacent season to the first season, or another season. In this embodiment of the present invention, in order to improve the quality of the season change performance, the second season can be the season after the first season.

[0050] In an optional embodiment, a transition map can be generated by adjusting the transparency of different regions in the texture map used by the 3D virtual model in the second season. The regions in the texture map used by the 3D virtual model in the first season can be determined based on the regions requiring transparency adjustment in the second season. For example, for trees, the leaves change from summer to autumn, and the leaves and trunks change from autumn to winter. Furthermore, the transparency of these regions can be determined based on the timing of the seasonal transition, with longer seasonal transitions resulting in lower transparency.

[0051] For example, taking the transition from autumn to winter as an example, at the beginning of the transition, the material texture used by the three-dimensional virtual model in the first season does not change, and the transition texture generated at this time is completely transparent, and the user cannot see the material texture used in the second season; at the end of the transition, the material texture used by the three-dimensional virtual model in the first season changes to the material texture used in the second season, and the transition texture generated at this time is completely opaque, and the user can see the material texture used in the second season; during the transition process, the material texture used by the three-dimensional virtual model in the first season gradually changes, and the transparency of the transition texture generated at this time gradually decreases, and the material texture used in the second season seen by the user becomes clearer and clearer.

[0052] Step S106: Mix the first texture and the transition texture to generate a target texture.

[0053] In an optional embodiment, the first map and the transition map can be mixed using a lerp function, that is, the transition map can be superimposed on the first map to obtain a target map. For the user, as the time of season change becomes longer, the transparency of the material map used in the second season becomes lower and lower, and the material map used in the second season that the user can see becomes clearer and clearer, while the material map used in the first season becomes more and more blurred.

[0054] For example, still taking the transition from autumn to winter as an example, at the beginning of the transition, the material map used by the three-dimensional virtual model in the first season does not change, and the transition map generated at this time is completely transparent, and the user can only see the material map used in the first season; at the end of the transition, the material map used by the three-dimensional virtual model in the first season changes to the material map used in the second season, and the transition map generated at this time is completely opaque, and the user can only see the material map used in the second season; during the transition process, the material map used by the three-dimensional virtual model in the first season gradually changes, and the transparency of the generated transition map gradually decreases, and the material map used in the first season seen by the user becomes more and more blurred, while the material map used in the second season becomes clearer and clearer.

[0055] Step S108 , rendering the three-dimensional virtual model based on the target map.

[0056] In an optional embodiment, a shader may be used to render the three-dimensional virtual model, and the specific rendering process is not described in detail here.

[0057] By adopting the solution provided by the above embodiment of the present invention, a first texture of a three-dimensional virtual model is obtained by mixing material textures, and a transition texture of the three-dimensional virtual model is obtained. Then, the first texture and the transition texture are mixed to generate a target texture. Finally, the three-dimensional virtual model is rendered based on the target texture, thereby achieving the purpose of adding seasonal changes to the three-dimensional virtual model. It is easy to notice that by generating a transition texture and superimposing it with the first texture, seasonal changes can be expressed on the material without the need for artists to produce corresponding art resources. This achieves the technical effect of improving the speed and efficiency of the development process, reducing the cost of the development process, thereby reducing the package size, enhancing the player's immersive experience, and increasing the realism of the game scene. This solves the technical problem in the related art of manually producing art resources for different seasons, which leads to long production time, high production costs, and a large package size.

[0058] Optionally, obtaining a transition map of a three-dimensional virtual model includes: determining a second map based on the type of the three-dimensional virtual model, wherein the second map is used to represent the material used by the three-dimensional virtual model in the second season; generating a mask map corresponding to the first map, wherein the mask map is used to represent the part of the first map that changes at a preset moment of transition from the first season to the second season; and adding the mask map to a preset channel of the second map to obtain a transition map.

[0059] The preset time in the above steps can be any time when the seasons change in the game scene and has nothing to do with the time in the real world.

[0060] The preset channel in the above steps can be the alpha channel of the second map, where the alpha channel is an 8-bit grayscale channel that uses 256 levels of grayscale to record the transparency information in the image and define transparent, opaque and semi-transparent areas, where white represents opaque, black represents transparent, and gray represents semi-transparent.

[0061] In an optional embodiment, for different types of 3D virtual models, the parts of the 3D virtual models that change are different. Therefore, the material map used in the second season can be determined based on the type of the 3D virtual model. In addition, the changing area and degree of change of the material map used in the first season can be determined in combination with the different times of seasonal changes, and then a corresponding mask map is generated. The longer the time of seasonal change, the greater the degree of change of the material map used in the first season, and the greater the value range in the mask map. Finally, the mask map is added to the alpha channel of the material map used in the second season to obtain a transition map. The greater the value range of the mask map, the lower the transparency of the material map used in the second season.

[0062] Optionally, determining the second texture based on the type of the three-dimensional virtual model includes: determining, according to the type of the three-dimensional virtual model, that the second texture is a material texture used by part or all of the three-dimensional virtual model in the second season.

[0063] In an alternative embodiment, for different types of 3D virtual models, the material changes often occur in different locations during seasonal transitions. For example, for a 3D virtual model of a tree, the leaves change color during the transition from summer to autumn. Therefore, the second texture may be the leaves of the tree. However, the tree itself remains unchanged during the transition from spring to summer. Therefore, the specific location where the material changes during seasonal transitions can be determined based on the type of 3D virtual model.

[0064] Optionally, based on the type of the three-dimensional virtual model, determining that the second map is a material map used for part or all of the three-dimensional virtual model in the second season includes: when the type of the three-dimensional virtual model is a first preset type, determining that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a cover covering the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the season changes; when the type of the three-dimensional virtual model is a second preset type, determining that the second map is a material map used by the cover covering the three-dimensional virtual model in the second season, wherein the second preset type is used to characterize that the material map of the three-dimensional virtual model remains unchanged when the season changes.

[0065] In an alternative embodiment, for different types of 3D virtual models, the material of the parts that change during seasonal transitions can be determined. For example, for a 3D virtual model of a tree, the leaves of the tree will change during the transition from summer to autumn, while the tree itself will remain unchanged during the transition from spring to summer. Therefore, the specific parts of the model that change material during seasonal transitions can be determined based on the type of 3D virtual model.

[0066] Optionally, based on the type of the three-dimensional virtual model, determining the second map includes: when the type of the three-dimensional virtual model is the ground, determining the second map as the material map used by the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a tree, determining the second map as the material map used by the first part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is grass, determining the second map as the material map used by the second part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a preset item, determining the second map as the material map used by the first covering on the three-dimensional virtual model in the second season, wherein the material map of the preset item remains unchanged when the seasons change; when the type of the three-dimensional virtual model is a building or road surface, determining the second map as the material map used by the second covering on the three-dimensional virtual model in the second season.

[0067] In an optional embodiment, for a three-dimensional virtual model of a ground surface type, seasonal changes are manifested as falling leaves, snow, etc. Therefore, the second map can be a material map of the ground surface covered with fallen leaves or snowflakes.

[0068] For the three-dimensional virtual model of the tree type, the change of seasons is manifested as the leaves changing color, falling, withering, and being covered with snow. Therefore, the first part of the model can be the leaves, and the second map can be the material map of the leaves after changing color; the first part of the model can also be the trunk, and the second map can be the material map after the leaves fall; the first part of the model can also be the part of the tree covered with snow, and the second map can be the material map of the trunk after being covered with snow.

[0069] For a three-dimensional virtual model of a grass type, seasonal changes are manifested as flowering, etc. Therefore, the second part of the model can be the flower part on the grass, and the second map can be the material map of the grass after flowering.

[0070] For three-dimensional virtual models of preset objects (such as rocks, props, etc.), seasonal changes are manifested as falling leaves, snow, etc. Therefore, the first covering can be fallen leaves, snowflakes, etc., and the second map can be the material map of the preset object after being covered with fallen leaves or snowflakes.

[0071] For three-dimensional virtual models of buildings or road types, seasonal changes are manifested as fallen leaves, snow, etc. Therefore, the second covering can also be fallen leaves, snowflakes, etc., and the second map can be the material map of the building or road covered with fallen leaves or snowflakes.

[0072] Optionally, when the type of the three-dimensional virtual model is a ground surface, generating a mask map corresponding to the first map includes: generating the mask map based on the first map; and determining a value range of the mask map based on a preset time.

[0073] In an optional embodiment, for a three-dimensional virtual model of a ground surface type, two ground surface maps that need to be replaced in adjacent seasons can be sampled to generate a mask map, and the value range in the mask map is determined based on the time of the current season change. The longer the season change time, the more value ranges in the mask map. Finally, the values ​​that need to be transformed at this stage are placed in the alpha channel of the last replaced map. For example, Figure 2 As shown, when changing from autumn to winter, the mask map of the transition effect is placed in the alpha channel of the winter map.

[0074] In an embodiment of the present invention, a mask can be obtained through the u_season_factors interface and tex_mask algorithm provided by the program, wherein the definition of the u_season_factors interface is as follows: u_season_factors.x represents a change from winter to spring, u_season_factors.y represents a change from spring to summer, u_season_factors.z represents a change from summer to autumn, and u_season_factors.w represents a change from autumn to winter.

[0075] The above method can be implemented by the following formula:

[0076] tex_mask_autum = saturate(pow(max(autumn_blend_tex.a+((u_season_factors.z+u_season_factors.w)*2.0-1.0),0.0),3.0)); / / Calculate the mask of autumn changes

[0077] tex_mask_snow = saturate(smoothstep(0.4, 1.0, pow(max(snow_blend_tex.a+(u_season_factors.w*2.0-1.0), 0.0), 3.0))); / / Calculate the mask for winter changes

[0078] season_color=lerp(half4(diffuse_color.xyz,1.0),spring_blend_tex,u_season_factors.x); / / Transition spring texture

[0079] season_color = lerp(season_color,autumn_blend_tex,tex_mask_autum); / / Transition autumn texture

[0080] season_color = lerp(season_color,snow_blend_tex,tex_mask_snow); / / Transition winter texture

[0081] Among them, autumn_blend_tex represents the map of the ground surface in autumn, autumn_blend_tex.a represents the alpha channel of the map of the ground surface in autumn, snow_blend_tex represents the map of the ground surface in winter, snow_blend_tex.a represents the alpha channel of the map of the ground surface in winter, diffuse_color.xyz represents the original map of the ground surface, that is, the map of the transition to summer; spring_blend_tex represents the map of the ground surface in spring.

[0082] Optionally, when the type of the three-dimensional virtual model is a tree, generating a mask map corresponding to the first map includes: determining a grayscale value corresponding to a preset moment, wherein the grayscale value is used to represent the grayscale value of a preset channel of the first map, and different grayscale values ​​correspond to different parts of the three-dimensional virtual model; generating a mask map based on the grayscale value.

[0083] In an optional embodiment, for the three-dimensional virtual model of tree types, trees are divided into broad-leaved trees and coniferous trees. The change effect is achieved by dyeing the leaves in spring, summer and autumn. Broad-leaved trees will shed their leaves and wither in winter. Therefore, the alpha channel of the leaf map of the broad-leaved tree is multi-processed. The multi-processing mainly refers to dividing the alpha value range of 0-255 into three parts. The grayscale 0-64 is used as the leaf part, and mapping it to [0-1] is a value of about 0.25. The alpha value is subtracted by 0.3 and multiplied by a value greater than 5 before truncating to obtain a mask after removing the leaves. In this way, the change from falling leaves in autumn to winter can be achieved. 75-128 is the trunk part, which always exists and is displayed. 128-255 is the snow part. The alpha value can be subtracted by 0.5 and multiplied by 2 and truncated to obtain a snow mask. This range can be used to adopt snow maps or colors. There is no need to make the withered part of the coniferous trees, so the grayscale range of the snow is 128-255, and the grayscale range of the leaves is 75-128.

[0084] In an embodiment of the present invention, the above method can be implemented by the following formula:

[0085] snowdirty = saturate(saturate(diffuse_color.w-0.5)*2.0); / / snow mask

[0086] leafalpha=saturate((diffuse_color.w-0.3)*5.0); / / leaf mask

[0087] diffuse_color.a*=4.0;

[0088] Among them, diffuse_color.w represents the alpha channel of the leaf map.

[0089] For example, for Figure 3a The first map shown and Figure 3b The alpha map shown has grayscale values ​​of 128-255 for the snow (which can be painted on with a dry medium brush), the whitest part of the image; grayscale values ​​of 75-128 for the alpha channel (tree trunks); and grayscale value 64 for the leaves (used for falling leaves, the best value to control is 64).

[0090] Optionally, when the type of the three-dimensional virtual model is grass, generating a mask map corresponding to the first map includes: obtaining a first channel map and a second channel map corresponding to the grass, wherein the first channel map is used to represent the three-dimensional virtual model, and the second channel map is used to represent other part models in the three-dimensional virtual model except the second part model; obtaining the difference between the first channel map and the second channel map to obtain the mask map.

[0091] In an optional embodiment, for the three-dimensional virtual model of the grass type, the effect of flowering in spring and summer is added to the grass, such as Figure 4a As shown, first of all, there needs to be flowers in the first map, such as Figure 4b As shown, the alpha map (i.e. the second channel map mentioned above) should remove the part corresponding to the flower, so that the flower is not displayed in the default state, and then Figure 4c As shown, an additional alpha map (the first channel map mentioned above) is needed, referred to as a mask. The mask contains the entire range of flowers and plants. Subtracting the alpha map from the mask gives the flower portion, referred to as flower_mask (the mask map mentioned above). According to the art design, the flowers are various colors in spring and turn white in summer. During the spring and summer seasons, the alpha map is subtracted from the mask to obtain the flower range, and the flower portion is colored in spring.

[0092] In an embodiment of the present invention, the above method can be implemented by the following formula:

[0093] half4 alpha_tex = t_alpha_tex.Sample(s_alpha_tex,uv0); / / alpha map

[0094] mask = saturate((alpha_tex.r-0.5)*2.0); / / Highlight mask

[0095] flower_alpha=alpha_tex.r*4.0; / / mask containing flowers

[0096] flower_mask=saturate(step(0.0,flower_alpha)-step(0.2,p.diffuse_color.w));

[0097] p.diffuse_color.w=lerp(p.diffuse_color.w,flower_alpha,smoothstep(0.4,1.0,u_season_factors.x+u_season_factors.y)); / / Flowering effect mask

[0098] Among them, Sample() is an existing sampling formula used to sample and obtain a texture.

[0099] Optionally, when the type of the three-dimensional virtual model is a preset object, generating a mask map corresponding to the first map includes: determining the coverage of the first covering on the model; and generating the mask map based on the coverage and the first map.

[0100] In an optional embodiment, for a three-dimensional virtual model of a preset item type, such as Figure 5 As shown, we first processed the leaf-covering part. Fallen leaves only appear on models with grass or moss on top, such as rocks, so we added a macro. The artist needs to manually enable and disable it, filter the models to be added, and generate a mask map. Then we processed the snow-covering part. Snow covers almost all pre-set items. The algorithm removes the side and bottom covers, but leaves an adjustable range on the sides as a mask map for adding seasonal textures.

[0101] In the embodiment of the present invention, the fallen leaves portion can be realized by the following formula:

[0102] half tex_mask=saturate(autumn_blend_tex.a+u_season_factors.z*2.0-1.0);

[0103] tex_mask=tex_mask*tex_mask*tex_mask;

[0104] season_mask=p.world_normal.y*0.5+0.5;

[0105] season_mask=season_mask-0.206;

[0106] season_mask=saturate(2.0*season_mask*season_mask*season_mask);

[0107] half shadow_mask=saturate(p.world_normal.y);

[0108] season_mask*=tex_mask*shadow_mask;

[0109] Among them, p.world_normal.y represents the upward range of the Y axis in the world space.

[0110] In the embodiment of the present invention, the snow cover part can be realized by the following formula:

[0111] half tex_mask=snow_blend_tex.a+u_season_factors.w*2.0-1.0;

[0112] tex_mask=tex_mask*tex_mask*tex_mask;

[0113] tex_mask = smoothstep(0.4,1.0,tex_mask); / / Switch season mask

[0114] season_mask=pow(p.world_normal.y*0.5+0.5,u_seasontex_range);

[0115] halfshadow_mask = saturate(p.world_normal.y); / / Eliminate back-y direction

[0116] season_mask*=tex_mask*shadow_mask;

[0117] Among them, u_seasontex_range represents the adjustable range value.

[0118] Optionally, when the type of the three-dimensional virtual model is a building or a road surface, generating the mask map corresponding to the first map includes: generating the mask map based on a value of a preset channel of the first map.

[0119] In an optional embodiment, for a 3D virtual model of a building or road, the alpha channel of the first texture is used as a mask for the fallen leaves and snow textures to obtain a mask texture, wherein the original texture is used in spring and summer. Figure 6a The original material map of the road shown in Figure 6b The mask map shown.

[0120] In an embodiment of the present invention, the above method can be implemented by the following formula:

[0121] half dirtymask=1.0-dirty_tex;

[0122] dirtymask=pow(dirtymask,u_seasontex_range);

[0123] season_mask=saturate(dirtymask*u_season_factors.z);

[0124] Among them, dirtymask represents the mask of the fallen leaves and snow map, dirty_tex represents the original material map, and u_seasontex_range represents the adjustable range value. The larger the value, the smaller the seasonal change effect.

[0125] Through the above steps, the present invention provides a four-season system, which can add four-season replacement performance based on the original materials used for various types of models in the game, and use shader algorithms to replace traditional production methods, so as to obtain high-quality four-season replacement performance with a faster, more efficient, and low-cost development process and acceptable performance overhead on mobile platforms; the addition of the four-season system can better enhance the player's immersive experience and increase the realism of the environment.

[0126] According to an embodiment of the present invention, a model rendering device is also provided, which can execute the model rendering method in the above embodiment. The specific implementation scheme and application scenario are the same as those in the above embodiment and will not be repeated here.

[0127] Optionally, a graphical user interface is provided by the electronic device, and the content displayed by the graphical user interface at least partially includes a three-dimensional virtual model.

[0128] Figure 7 is a schematic diagram of a model rendering device according to an embodiment of the present invention. Figure 7 As shown, the device includes:

[0129] The first acquisition module 72 is configured to acquire a first texture of the three-dimensional virtual model, wherein the first texture is used to represent a material used by the three-dimensional virtual model in the first season of the game scene.

[0130] The second acquisition module 74 is used to acquire a transition map of the three-dimensional virtual model, wherein the transition map is used to represent the change state of the material used by the three-dimensional virtual model during the transition from the first season to the second season.

[0131] The mixing module 76 is used to mix the first texture and the transition texture to generate a target texture.

[0132] The rendering module 78 is used to render the three-dimensional virtual model based on the target map.

[0133] Optionally, the second acquisition module includes: a determination unit for determining a second map based on the type of the three-dimensional virtual model, wherein the second map is used to represent the material used by the three-dimensional virtual model in the second season; a generation unit for generating a mask map corresponding to the first map, wherein the mask map is used to represent the part of the first map that changes at a preset moment of transition from the first season to the second season; and an adding unit for adding the mask map to a preset channel of the second map to obtain a transition map.

[0134] Optionally, the determining unit is further configured to determine, based on the type of the three-dimensional virtual model, that the second texture is a material texture used by part or all of the three-dimensional virtual model in the second season.

[0135] Optionally, the determination unit is also used to, when the type of the three-dimensional virtual model is a first preset type, determine that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a cover covering the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the seasons change; and when the type of the three-dimensional virtual model is a second preset type, determine that the second map is a material map used by the cover covering the three-dimensional virtual model in the second season, wherein the second preset type is used to characterize that the material map of the three-dimensional virtual model remains unchanged when the seasons change.

[0136] Optionally, the determination unit is also used to, when the type of the three-dimensional virtual model is the surface, determine that the second map is the material map used by the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a tree, determine that the second map is the material map used by the first part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is grass, determine that the second map is the material map used by the second part of the model in the three-dimensional virtual model in the second season; when the type of the three-dimensional virtual model is a preset object, determine that the second map is the material map used by the first covering on the three-dimensional virtual model in the second season, wherein the material map of the preset object remains unchanged when the seasons change; when the type of the three-dimensional virtual model is a building or a road surface, determine that the second map is the material map used by the second covering on the three-dimensional virtual model in the second season.

[0137] Optionally, the generating unit is further configured to generate a mask map based on the first map when the type of the three-dimensional virtual model is a ground surface, and determine a value range of the mask map based on a preset time.

[0138] Optionally, the generation unit is also used to determine the grayscale value corresponding to a preset moment when the type of the three-dimensional virtual model is a tree, and to generate a mask map based on the grayscale value, wherein the grayscale value is used to represent the grayscale value of a preset channel of the first map, and different grayscale values ​​correspond to different parts of the three-dimensional virtual model.

[0139] Optionally, the generation unit is also used to obtain the first channel map and the second channel map corresponding to the grass when the type of the three-dimensional virtual model is grass, and obtain the difference between the first channel map and the second channel map to obtain a mask map, wherein the first channel map is used to represent the three-dimensional virtual model, and the second channel map is used to represent other partial models in the three-dimensional virtual model except the second partial model.

[0140] Optionally, the generating unit is further configured to, when the type of the three-dimensional virtual model is a preset object, determine a coverage range of the first covering on the model, and generate a mask map based on the coverage range and the first map.

[0141] Optionally, the generating unit is further configured to generate a mask map based on a value of a preset channel of the first map when the type of the three-dimensional virtual model is a building or a road surface.

[0142] According to an embodiment of the present invention, a computer-readable storage medium is further provided. The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the model rendering method in the above embodiment.

[0143] According to an embodiment of the present invention, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a program that can be executed by the at least one processor, and when the program is executed by the at least one processor, the model rendering method in the above embodiment is executed.

[0144] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0145] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0146] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0147] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0148] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.

[0149] The above is only a preferred embodiment of the present invention. 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 invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A model rendering method, characterized in that: The method comprises: Obtaining a first texture of a three-dimensional virtual model, wherein the three-dimensional virtual model is used to represent the change of seasons, and the first texture is used to represent a material used by the three-dimensional virtual model in the first season in the game scene; Obtaining a transition map of the three-dimensional virtual model, wherein the transition map is used to represent a change in a material used by the three-dimensional virtual model during a transition from the first season to the second season, the transition map being generated by blending a second map with a mask map, the second map being used to represent a material used by the three-dimensional virtual model in the second season, and the mask map being used to represent a portion of the first map that changes at a predetermined moment in the transition from the first season to the second season; Mixing the first map and the transition map to generate a target map; Rendering the three-dimensional virtual model based on the target map; The method also includes: when the type of the three-dimensional virtual model is a first preset type, determining that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a cover covering the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the season changes.

2. The method according to claim 1, characterized in that Acquiring the transition map of the three-dimensional virtual model includes: determining a second map based on the type of the three-dimensional virtual model; generating a mask map corresponding to the first map; The mask map is added to the preset channel of the second map to obtain the transition map.

3. The method according to claim 2, characterized in that Determining the second map based on the type of the three-dimensional virtual model includes: According to the type of the three-dimensional virtual model, the second texture is determined to be a material texture used by part or all of the three-dimensional virtual model in the second season.

4. The method according to claim 2, characterized in that Determining the second map based on the type of the three-dimensional virtual model further includes: When the type of the three-dimensional virtual model is a second preset type, the second map is determined to be a material map used by the cover on the three-dimensional virtual model in the second season, wherein the second preset type is used to characterize that the material map of the three-dimensional virtual model remains unchanged when the seasons change.

5. The method according to claim 3 or 4, characterized in that Determining the second map based on the type of the three-dimensional virtual model includes: When the type of the three-dimensional virtual model is a ground surface, determining that the second map is a material map used by the three-dimensional virtual model in the second season; When the type of the three-dimensional virtual model is a tree, determining that the second map is a material map used by the first part of the model in the three-dimensional virtual model in the second season; When the type of the three-dimensional virtual model is grass, determining the second texture to be a material texture used by a second part of the model in the three-dimensional virtual model in the second season; When the type of the three-dimensional virtual model is a preset object, determining that the second texture is a material texture used by a first covering on the three-dimensional virtual model in the second season, wherein the material texture of the preset object remains unchanged when the season changes; In a case where the type of the three-dimensional virtual model is a building or a road surface, the second texture is determined to be a material texture used by a second covering on the three-dimensional virtual model in the second season.

6. The method according to claim 5, characterized in that When the type of the three-dimensional virtual model is the ground surface, generating the mask map corresponding to the first map includes: generating the mask map based on the first map; Based on the preset time, a value range of the mask map is determined.

7. The method according to claim 5, characterized in that When the type of the three-dimensional virtual model is the tree, generating the mask map corresponding to the first map includes: Determining a grayscale value corresponding to the preset moment, wherein the grayscale value is used to represent a grayscale value of a preset channel of the first map, and different grayscale values ​​correspond to different parts of the three-dimensional virtual model; The mask map is generated based on the grayscale value.

8. The method according to claim 5, characterized in that When the type of the three-dimensional virtual model is the bush, generating the mask map corresponding to the first map includes: Obtaining a first channel map and a second channel map corresponding to the grass, wherein the first channel map is used to represent the three-dimensional virtual model, and the second channel map is used to represent other partial models of the three-dimensional virtual model except the second partial model; Obtain a difference between the first channel map and the second channel map to obtain the mask map.

9. The method according to claim 5, characterized in that When the type of the three-dimensional virtual model is the preset object, generating the mask map corresponding to the first map includes: determining a coverage of the first covering on the model; The mask map is generated based on the coverage and the first map.

10. The method according to claim 5, characterized in that When the type of the three-dimensional virtual model is a building or a road, generating the mask map corresponding to the first map includes: The mask map is generated based on the value of the preset channel of the first map.

11. A model rendering device, characterized in that: include: A first acquisition module is configured to acquire a first texture of a three-dimensional virtual model, wherein the three-dimensional virtual model is used to represent the change of seasons, and the first texture is used to represent a material used by the three-dimensional virtual model in the first season in the game scene; a second acquisition module, configured to acquire a transition map of the three-dimensional virtual model, wherein the transition map is configured to represent a change in a material used by the three-dimensional virtual model during a transition from the first season to the second season, the transition map being generated by blending a second map with a mask map, the second map being configured to represent a material used by the three-dimensional virtual model in the second season, and the mask map being configured to represent a portion of the first map that changes at a preset moment in the transition from the first season to the second season; A mixing module, configured to mix the first map and the transition map to generate a target map; A rendering module, configured to render the three-dimensional virtual model based on the target map; The second acquisition module includes a determination unit for determining, when the type of the three-dimensional virtual model is a first preset type, that the second map is a material map used by the three-dimensional virtual model in the second season, or a material map used by a covering on the three-dimensional virtual model in the second season, wherein the first preset type is used to characterize that the material map of the three-dimensional virtual model will change when the season changes.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the model rendering method according to any one of claims 1 to 10.

13. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a program that can be executed by the at least one processor, and when the at least one processor executes the model rendering method according to any one of claims 1 to 10, the program is executed.

Citation Information

Patent Citations

  • Model rendering method, device and equipment and storage medium

    CN112274934A