Model Coloring Method, Device, Equipment, Medium and Program Product
By using the method of multiplying color gradient maps with maps in different game scenes, the problem of fixed 3D model shading effect is solved, and the flexible adjustment of the virtual model and better picture performance is achieved.
Patent Information
- Application Number
- CN202111661188.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2041-12-30
AI Technical Summary
In the prior art, the coloring results of the three-dimensional model rely on pre-drawn maps, resulting in a fixed coloring effect and cannot be flexibly adjusted.
By obtaining the color gradient maps corresponding to different game scenes, combining them with the virtual model's map for coloring, and multiplying the color gradient map with the map to achieve flexible coloring of the virtual model.
It improves the flexibility and picture expressiveness of virtual models, reduces the repeated drawing work of artists, and improves the coloring effect.
Smart Images

Figure CN114367105B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics technology, and in particular, to a model coloring method, apparatus, device, medium, and program product. Background Art
[0002] In a virtual game world, there are usually various three-dimensional models of different styles, such as character models. In order to improve the expressiveness of these models, game developers often color the surfaces of these three-dimensional models.
[0003] In the prior art, when coloring the surfaces of these three-dimensional models, it is usually the art staff who pre-draw the texture maps of the three-dimensional models, and then multiply the dot product value of the normal vector and the light direction by the color texture map to represent the bright and dark surfaces of the character's skin, and finally achieve the coloring of the three-dimensional model.
[0004] However, in this way of the prior art, the coloring result of the three-dimensional model depends on the pre-drawn texture map, and the coloring effect is relatively fixed and cannot be adjusted flexibly. Summary of the Invention
[0005] This application provides a model coloring method, apparatus, device, medium, and program product, which is used to solve the problem that the existing model coloring effect is fixed and cannot be adjusted flexibly.
[0006] In a first aspect, an embodiment of this application provides a model coloring method. A graphical user interface is provided through a terminal device, and the content displayed on the graphical user interface at least includes a current game scene and a virtual model in the current game scene. The method includes:
[0007] Obtain a color gradient map corresponding to the current game scene and a texture map of the virtual model. Different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different;
[0008] Color the surface of the virtual model according to the texture map and the color gradient map.
[0009] In a possible design of the first aspect, the obtaining the color gradient map corresponding to the current game scene includes:
[0010] Obtain the corresponding relationship between each color gradient map in a preset color atlas and a game scene. The preset color atlas includes at least two color gradient maps;
[0011] Select, according to the corresponding relationship, the color gradient map corresponding to the current game scene from the preset color atlas.
[0012] In another possible design of the first aspect, coloring the surface of the virtual model according to the texture map and the color gradient map includes:
[0013] Obtain the illumination value of the target area on the surface of the virtual model as the first coordinate value in the two-dimensional coordinates of the target area. The surface of the virtual model includes multiple target areas, and the illumination values of each target area are within a preset value range;
[0014] Determine the index of the color gradient map in the preset color map set, where the indices of the color gradient maps in the preset color map set are different from each other;
[0015] According to the index, determine the second coordinate value in the two-dimensional coordinates, and the second coordinate value is within the preset value range;
[0016] Perform color sampling on the color gradient map according to the first coordinate value and the second coordinate value to obtain the target color value corresponding to the target area;
[0017] Color the surface of the virtual model according to the texture map and the target color value.
[0018] In yet another possible design of the first aspect, obtaining the illumination value of the target area on the surface of the virtual model includes:
[0019] Obtain the pose of the virtual model in the game scene;
[0020] According to the pose, determine the world space normal direction vector and the light incident direction vector of the target area;
[0021] Dot-multiply the world space normal direction vector and the light incident direction vector to obtain a dot product result;
[0022] According to the dot product result and the gray value of the constant dark area in the virtual model, determine the illumination value of the target area on the surface of the virtual model.
[0023] In yet another possible design of the first aspect, determining the second coordinate value in the two-dimensional coordinates according to the index includes:
[0024] Obtain the total number of color gradient maps included in the preset color map set;
[0025] Calculate the second coordinate value according to the index of the color gradient map and the total number.
[0026] In yet another possible design of the first aspect, determining the light incident direction vector includes:
[0027] Obtain the world coordinates of the light source in the game scene and the coordinates of the target area;
[0028] Subtract the world coordinates of the light source from the coordinates of the target area to obtain a coordinate difference;
[0029] Normalize the coordinate difference to obtain the light incident direction vector.
[0030] In another possible design of the first aspect, the determining the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the always-dark area in the virtual model includes:
[0031] Perform an absolute value operation on the dot product result to obtain the dot product result after the operation;
[0032] Compare the dot product result after the operation with the gray value of the always-dark area, and select the smaller value as the illumination value of the target area.
[0033] In another possible design of the first aspect, the coloring of the surface of the virtual model according to the texture map and the target color value includes:
[0034] Multiply the texture map and the target color value to obtain a product result for coloring the surface of the virtual model.
[0035] In a second aspect, an embodiment of the present application provides a model coloring device, including:
[0036] An acquisition module, configured to acquire the color gradient map corresponding to the current game scene and the texture map of the virtual model. Different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different;
[0037] A coloring module, configured to color the surface of the virtual model according to the texture map and the color gradient map.
[0038] In a third aspect, an embodiment of the present application provides a terminal device, including: a processor, and a memory communicatively connected to the processor;
[0039] The memory stores computer execution instructions;
[0040] The processor executes the computer execution instructions stored in the memory to implement the above method.
[0041] In a fourth aspect, an embodiment of the present application provides a readable storage medium, in which computer instructions are stored, and when the computer instructions are executed by a processor, they are used to implement the above method.
[0042] In a fifth aspect, an embodiment of the present application provides a program product, including computer instructions which, when executed by a processor, implement the above-mentioned method.
[0043] The model coloring method, apparatus, device, medium, and program product provided by the embodiments of the present application, by setting color gradient maps corresponding to different game scenes, when a virtual model is in different game scenes, can obtain the corresponding color gradient maps and combine them with the texture map of the virtual model to color the virtual model, enabling the virtual model to be colored not only relying on the texture map, and improving the flexibility of virtual model coloring. Description of the Drawings
[0044] The drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application;
[0045] Figure 1 It is a schematic diagram of the scene of the model coloring method provided by the embodiments of the present application;
[0046] Figure 2 It is a schematic flowchart of the first embodiment of the model coloring method provided by the embodiments of the present application;
[0047] Figure 3 It is a schematic flowchart of the second embodiment of the model coloring method provided by the embodiments of the present application;
[0048] Figure 4 It is a schematic flowchart of the third embodiment of the model coloring method provided by the embodiments of the present application;
[0049] Figure 5 It is a schematic structural diagram of the model coloring apparatus provided by the embodiments of the present application;
[0050] Figure 6 It is a schematic structural diagram of the terminal device provided by the embodiments of the present application.
[0051] Through the above-mentioned drawings, the clear embodiments of the present application have been shown, and there will be more detailed descriptions later. These drawings and text descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Embodiments
[0052] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are some, but not all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.
[0053] First, the terms involved in this application are explained:
[0054] Texture map: It refers to a two-dimensional image that can present the information on the surface of a three-dimensional model. It is assigned to the surface of a wireframe polygon to give the three-dimensional model an appearance.
[0055] Figure 1 The following is a schematic diagram of the scenario of the model coloring method provided by the embodiments of this application. As Figure 1 shown, the terminal device 10 generally refers to a computer device or a mobile terminal (such as a smart phone), etc. When the target game is running on the terminal device 10, the game content will be displayed on the graphical user interface of the terminal device 10. Specifically, it may include a virtual model (such as a game character) controlled by the player. In the virtual world of the game, in order to ensure that the virtual model is more realistic, it is usually a three-dimensional solid model (not shown).
[0056] In real life, taking a game character as an example of a three-dimensional model, in order to make the game character more realistic, the skin surface of the game character (such as a cartoon game character) can also present various different colors. The color of the skin is mainly displayed on the graphical user interface after steps such as setting a texture map, binding the corresponding shader, and setting the rendering state in the game engine. Among them, the shader is a program segment specifically used to render graphics. Through the shader, the way the graphics card of the terminal device renders the game character can be customized to obtain the effect desired by game developers.
[0057] In the prior art, the common skin coloring method for cartoon game characters is mainly that the art personnel in game development first make the model resources of the cartoon game character, bake the color texture map, and then multiply the dot product value of the normal vector and the light direction vector in the game world by the color texture map to show the bright and dark sides of the skin of the cartoon game character. This coloring method, on the one hand, is relatively dependent on the subjective aesthetics of the art personnel, and the coloring effect only depends on the configured inherent color texture map. On the other hand, when the character skin needs to be adjusted according to the game environment, it often requires rewriting and drawing new texture map resources, which is time-consuming and laborious, with a large adjustment cost, and the final picture expressiveness also needs to be improved.
[0058] In view of the above problems, the model coloring method, device, equipment, medium and program product provided by the embodiments of the present application can create color gradient maps of different color systems corresponding to different game scenes according to the overall game style, and combine the color gradient maps with the textures of the virtual models to color the virtual models, which can more flexibly adjust the coloring of the virtual models, and coloring in combination with the color gradient maps can make the virtual models have better visual expressiveness and improve the coloring effect of the virtual models.
[0059] Next, the technical solutions of the present application will be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0060] Figure 2 FIG. is a schematic flowchart of the first embodiment of the model coloring method provided by the embodiments of the present application. This method can be applied to a terminal device, and the terminal device provides a graphical user interface, and the content displayed in the graphical user interface at least includes a game scene and a virtual model in the game scene. Among them, in the game world, there can be one or more game scenes. Exemplarily, the game scenes include a dusk scene, a rainy scene, and so on. As Figure 2 shown, the method can specifically include the following steps:
[0061] S201. Obtain the color gradient map corresponding to the current game scene and the texture of the virtual model.
[0062] Among them, different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different. Exemplarily, taking the game scene as a rainy scene, the rainy scene corresponds to a cool color system color gradient map (for example, a blue gradient map). Exemplarily, taking the game scene as a dusk scene, the dusk scene corresponds to a warm color system color gradient map (for example, a yellow gradient map).
[0063] In this embodiment, the virtual model can be a three-dimensional game character in the game world. The game character can be controlled by the player to move. When the player controls the game character to move in the game world, the game scene may change. Exemplarily, the change of the game scene can also be caused by the change of time in the game world, such as the dusk scene and the night scene, etc.
[0064] Among them, different color gradient maps are set corresponding to different game scenes. Exemplarily, the correspondence between the color gradient map and the game scene can be preset. For example, art personnel can create color gradient maps of different color systems according to the overall game style, and then set the corresponding game scenes for the color gradient maps of different color systems.
[0065] In this embodiment, a texture map refers to a two-dimensional picture that is inherently set on the surface of a game character. An artist can first create a game character model and then bake the color texture map corresponding to the game character model. Usually in the prior art, the texture map is attached to the surface of the game character to present the final appearance of the game character. A color gradient map refers to the gradient change of colors from light to dark or from dark to light in an image.
[0066] S202. Color the virtual model according to the texture map and the color gradient map.
[0067] In this embodiment, the baked texture map can be combined with the color gradient map corresponding to the current game scene through a shader to color the virtual model.
[0068] Among them, during the coloring process, color value sampling can be performed on the colors in the color gradient map to obtain color sampling values, and then multiplied by the texture map to obtain the final coloring effect.
[0069] By setting color gradient maps corresponding to different game scenes in the embodiments of the present application, when the virtual model is in different game scenes, the corresponding color gradient maps can be obtained and combined with the texture maps of the virtual model to color the virtual model, which can make the virtual model not only rely on the texture map for coloring, improving the flexibility of virtual model coloring.
[0070] In some embodiments, the step of "obtaining the color gradient map corresponding to the current game scene" in the above step S201 can be specifically implemented through the following steps:
[0071] Obtain the corresponding relationship between each color gradient map in the preset color map set and the game scene;
[0072] According to the corresponding relationship, select the color gradient map corresponding to the current game scene from the preset color map set.
[0073] Among them, the preset color map set includes at least two color gradient maps. Exemplarily, the preset color map set can be made by an artist in advance according to the game style, and includes multiple color gradient maps of different color systems.
[0074] In this embodiment, when an artist makes color gradient maps of different color systems, a corresponding game scene can be set for each color gradient map. For example, the game scene corresponding to the cold color system's blue-biased gradient map is the rainy scene. When the game character in the game is in the rainy scene, the blue-biased gradient map is used to combine with the texture map of the game character to color the game character.
[0075] Exemplarily, when there are multiple color gradient maps in the preset color atlas, corresponding indexes can be set for each color gradient map, and different game scenes can be identified at the same time. By establishing the corresponding relationship between the identification and the index, when the game character is in the current game scene, the corresponding color gradient map can be found from the corresponding relationship according to the identification of the current game scene.
[0076] In the embodiment of the present application, by establishing the corresponding relationship between each color gradient map and the game scene, the corresponding color gradient map can be found when the virtual model is in different game scenes, and the surface skin of the virtual model can be colored by combining the texture map of the virtual model itself, so that the virtual model can flexibly obtain different skin coloring effects in different game scenes, improving the coloring flexibility of the virtual model. When adjusting the skin color system, it is not necessary for artists to redraw texture map resources, reducing the investment of human resources and time.
[0077] In some embodiments, the above step S203 can be specifically implemented through the following steps:
[0078] Obtain the illumination value of the target area on the surface of the virtual model as the first coordinate value in the two-dimensional coordinates of the target area;
[0079] Determine the index of the color gradient map in the preset color atlas;
[0080] Determine the second coordinate value in the two-dimensional coordinates according to the index;
[0081] Perform color sampling on the color gradient map according to the first coordinate value and the second coordinate value to obtain the target color value corresponding to the target area;
[0082] Color the surface of the virtual model according to the texture map and the target color value.
[0083] Among them, the surface of the virtual model includes multiple target areas, and the illumination values of each target area are within the preset value range, the second coordinate value is within the preset value range, and the indexes of each color gradient map in the preset color atlas are different from each other. Exemplarily, the target area is a triangular patch, and the surface of the virtual model can be divided into several triangular patches. Among them, each triangular patch can have a corresponding world space normal and a light incident direction.
[0084] In this embodiment, the two-dimensional coordinates can be (U, V) image coordinates, where the first coordinate value is V and the second coordinate value is U. Both U and V are within [0, 1]. The preset value range is [0, 1], and the illumination value of the target area can be determined according to the world space normal of the target area and the incident light of the world light source. Among them, the world space normal direction and the light incident direction of different target areas may be different, resulting in different illumination values for different target areas. Among them, the world space refers to the virtual world space where the game character is located, and there is also a virtual world light source in the virtual world.
[0085] The preset color atlas contains several color gradient maps of different color systems, and each color gradient map has a corresponding index. Exemplarily, the preset color atlas can contain 10 color gradient maps of different color systems, where the index of the first color gradient map can be 1, the index of the second color gradient map can be 2,..., and the index of the tenth color gradient map can be 10.
[0086] Among them, the second coordinate value needs to be within the preset value range [0, 1] to facilitate subsequent sampling of the color gradient map using the two-dimensional coordinates. Specifically, the index can be divided by the preset value to make the division result fall within the preset value range [0, 1]. For example, the index of the first color gradient map is 1 and the preset value can be 10, then the second coordinate value can be 1 / 10 = 0.1. Among them, both the first coordinate value and the second coordinate value are within the preset value range [0, 1] to facilitate subsequent color sampling of the color gradient map.
[0087] In this embodiment, the target color value corresponding to the target area can be multiplied by the texture map to color the target area.
[0088] By obtaining the first coordinate value and the second coordinate value in the two-dimensional coordinates to sample the color gradient map in this embodiment of the application, the gradient color corresponding to the light and dark relationship can be obtained, and then the sampled color value is combined with the texture map to color the virtual model, which can make the visual performance of the virtual model more rich and improve the coloring effect.
[0089] Further, in some embodiments, the above step of "obtaining the illumination value of the target area on the surface of the virtual model" can be specifically implemented through the following steps:
[0090] Obtain the pose of the virtual model in the game scene;
[0091] According to the pose, determine the world space normal direction vector and the light incident direction vector of the target area;
[0092] Dot-multiply the world space normal direction vector and the light incident direction vector to obtain the dot-multiplication result;
[0093] Determine the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the constantly dark area in the virtual model.
[0094] In this embodiment, the surface of the virtual model can be the skin of a game character. The skin of the game character can be divided into several triangular patches, and each patch has a corresponding world space normal and incident light in the game world. Among them, taking the world space normal direction vector as N and the light incident direction vector as L as an example, the dot product result is N·L. Among them, according to the properties of the dot product, the dot product result N·L is within the preset value range [-1, 1].
[0095] Among them, the constantly dark area can refer to the area in the virtual model that cannot obtain light for a long time. For example, taking the virtual model as a game character, the constantly dark area can be the area under the collar of the game character. In this embodiment, the gray value of the constantly dark area is within the preset value range [0, 1].
[0096] In this embodiment, the color value of the target area on the surface of the virtual model can be obtained according to the dot product result and the gray value of the constantly dark area. Exemplarily, the value range of the dot product result N·L can be cropped, and the dot product result between [-1, 0] is cropped to [0, 1], and then the cropped dot product result is compared with the gray value of the constantly dark area, and the smaller value is taken as the illumination value of the target area.
[0097] In the embodiment of the present application, by obtaining the dot product of the world space normal direction vector and the light incident direction vector to obtain the dot product result, and comparing the dot product result with the constantly dark area in the virtual model, a calculation result with a certain corresponding relationship with the bright and dark distribution caused by the light illumination relationship can be obtained, improving the coloring effect of the virtual model.
[0098] In some embodiments, the above step "determine the second coordinate value in the two-dimensional coordinate according to the index" can be implemented by the following steps:
[0099] Obtain the total number of color gradient maps included in the preset color atlas;
[0100] Calculate the second coordinate value according to the index and the total number of the color gradient maps.
[0101] Among them, each color gradient map has an index value. Exemplarily, taking the example that the entire preset color atlas contains 10 equally divided color gradient maps, the index value of the color gradient map can be divided by the total number 10, so that the second coordinate value is within the preset value range [0, 1].
[0102] In the embodiments of the present application, the second coordinate value is calculated by using the index of the color gradient map and the total number of color gradient maps included in the preset color map set. When sampling the color gradient map through two-dimensional coordinates, the gradient color corresponding to the light and dark relationship can be obtained, improving the coloring effect of the virtual model.
[0103] In some embodiments, the above step of "determining the light incident direction vector" can be specifically implemented through the following steps:
[0104] Obtain the world coordinates of the light source in the game scene and the coordinates of the target area;
[0105] Subtract the world coordinates of the light source from the coordinates of the target area to obtain the coordinate difference;
[0106] Normalize the coordinate difference to obtain the light incident direction vector.
[0107] In this embodiment, in the game world, the light source can usually be a virtual sun, moon, or lighting lamp, etc. The surface of the virtual model is divided into several triangular patches (i.e., the target area), and each triangular patch has a corresponding coordinate, so that the light incident directions of different triangular patches are different.
[0108] In the embodiments of the present application, the coordinate difference is calculated and the coordinate difference is normalized to obtain the light incident direction vector. When performing a dot product later, the value range of the dot product result can be controlled to obtain the second coordinate value, which is convenient for subsequent sampling of the color gradient map and improves the surface force of the virtual model's picture.
[0109] In some embodiments, the above step of "determining the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the constant dark area in the virtual model" can be specifically implemented through the following steps:
[0110] Perform an absolute value operation on the dot product result to obtain the dot product result after the operation;
[0111] Compare the dot product result after the operation with the gray value of the constant dark area, and select the smaller value as the illumination value of the target area.
[0112] In this embodiment, the dot product result is between [-1, 1]. When an absolute value operation is performed on the dot product result, the dot product result between [-1, 0] will be clipped to [0, 1], so that all dot product results after the operation are within the preset value range [0, 1]. At the same time, the gray value of the constant dark area is usually also between [0, 1]. By comparing the dot product results of the target area with the gray value of the constant dark area, the smaller value is taken as the illumination value of the target area.
[0113] In the embodiment of the present application, by comparing the calculated dot product result with the gray value of the constant dark area and selecting the smaller value as the illumination value of the target area, a calculation result with a certain corresponding relationship with the bright and dark distribution caused by the light illumination relationship can be obtained, improving the coloring effect of the virtual model.
[0114] Exemplarily, based on the above embodiment, in some embodiments, the surface of the virtual model can be colored by multiplying the texture map with the target color value to obtain a product result.
[0115] Exemplarily, when coloring the surface of the virtual model, an edge light effect can also be added. Specifically, according to the above dot product result N·L, and the coordinate of each triangular patch and the line of sight direction obtained by subtracting the camera position coordinate and normalizing, the edge light effect can be calculated to color the virtual model.
[0116] Exemplarily, Figure 3 is a schematic flowchart of the second embodiment of the model coloring method provided by the embodiment of the present application. Taking a virtual cartoon game character as an example of the virtual model, as Figure 3 shown, the method may specifically include the following steps:
[0117] S301. Pre-manufacture color gradient maps of different color systems according to the game style requirements;
[0118] S302. Produce resources of the cartoon game character according to the original painting, and bake the color texture map of the skin of the cartoon game character;
[0119] S303. Import the resources, texture map and color gradient map into the coloring engine;
[0120] S304. Select the corresponding color gradient map of the color system according to the game scene;
[0121] S305. Use the color gradient map and the texture map as the input of the shader for coloring calculation;
[0122] S306. Obtain the final coloring result.
[0123] Exemplarily, Figure 4 is a schematic flowchart of the third embodiment of the model coloring method provided by the embodiment of the present application, as Figure 4 shown, the method may specifically include the following steps:
[0124] S401. Import resources such as the character model, character color texture map, constant dark area texture map, and color gradient maps corresponding to different game scenes;
[0125] S402. Create a material for rendering the character model and bind it to the model, and set the shader used for coloring and the resources to be used for the material;
[0126] S403. Obtain the world space discovery direction and the light incident direction of each triangular patch on the character's skin;
[0127] S404. Calculate the dot product result of the world space discovery direction vector and the light incident direction vector, and take the smaller value with the constant dark area texture map;
[0128] S405. Obtain the index of the color gradient map corresponding to the current game scene, and according to the index and the smaller value, obtain the two-dimensional coordinates and sample the color gradient map;
[0129] S406. Multiply the sampled color value by the character color texture map;
[0130] S407. Add the rim light effect;
[0131] S408. Obtain the shading result.
[0132] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiment of the present application. For the details not disclosed in the apparatus embodiment of the present application, please refer to the method embodiment of the present application.
[0133] Figure 5 The following is a schematic structural diagram of a model shading apparatus provided by an embodiment of the present application. The model shading apparatus can be integrated on a terminal device, or can be independent of the terminal device and cooperate with the terminal device to implement the technical solution. As Figure 5 shown, the model shading apparatus 50 may include an acquisition module 51 and a shading module 52.
[0134] Among them, the acquisition module 51 is used to acquire the color gradient map corresponding to the current game scene and the texture map of the virtual model. The shading module 52 is used to shade the surface of the virtual model according to the texture map and the color gradient map.
[0135] Among them, different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different.
[0136] In some embodiments, the above acquisition module may specifically be used for:
[0137] Obtain the correspondence between each color gradient map in the preset color atlas and the game scene, and the preset color atlas includes at least two color gradient maps;
[0138] According to the correspondence, select the color gradient map corresponding to the current game scene from the preset color atlas.
[0139] In some embodiments, the above shading module may specifically be used for:
[0140] Obtain the illumination value of the target area on the surface of the virtual model as the first coordinate value in the two-dimensional coordinates of the target area;
[0141] Determine the index of the color gradient map in the preset color atlas;
[0142] Determine the second coordinate value in the two-dimensional coordinates according to the index;
[0143] Perform color sampling on the color gradient map according to the first coordinate value and the second coordinate value to obtain the target color value corresponding to the target area;
[0144] Color the surface of the virtual model according to the texture map and the target color value.
[0145] Among them, the surface of the virtual model includes multiple target areas, and the illumination values of each target area are within a preset value range. The indices of each color gradient map in the preset color atlas are different from each other, and the second coordinate value is within the preset value range.
[0146] In some embodiments, the above coloring module can specifically be used for:
[0147] Obtain the pose of the virtual model in the game scene;
[0148] Determine the world space normal direction vector and the light incident direction vector of the target area according to the pose;
[0149] Dot-multiply the world space normal direction vector and the light incident direction vector to obtain the dot product result;
[0150] Determine the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the constantly dark area in the virtual model.
[0151] In some embodiments, the above coloring module can specifically be used for:
[0152] Obtain the total number of color gradient maps included in the preset color atlas;
[0153] Calculate the second coordinate value according to the index of the color gradient map and the total number.
[0154] In some embodiments, the above coloring model can specifically be used for:
[0155] Obtain the world coordinates of the light source in the game scene and the coordinates of the target area;
[0156] Subtract the world coordinates of the light source from the coordinates of the target area to obtain the coordinate difference;
[0157] Normalize the coordinate difference to obtain the light incident direction vector.
[0158] In some embodiments, the above coloring model can specifically be used for:
[0159] Perform an absolute value operation on the dot product result to obtain the dot product result after the operation;
[0160] Compare the dot product result after the operation with the gray value of the constant dark area, and select the smaller value as the illumination value of the target area.
[0161] In some embodiments, the above coloring model can specifically be used for:
[0162] Multiply the texture map by the target color value to obtain a product result for coloring the surface of the virtual model.
[0163] The device provided by the embodiments of the present application can be used to execute the methods in the above embodiments. The implementation principles and technical effects are similar and will not be elaborated here.
[0164] It should be noted that it should be understood that the division of each module of the above device is only a logical function division. In actual implementation, it can be fully or partially integrated into a physical entity, or physically separated. And these modules can all be implemented in the form of software called by a processing element; they can also all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the acquisition module can be a separately established processing element, or can be integrated in a certain chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a certain processing element of the above device to perform the functions of the above acquisition module. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together or independently implemented.
[0165] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0166] Figure 6 FIG. is a schematic structural diagram of a terminal device provided by an embodiment of the present application. As Figure 6 shown, the terminal device 60 includes: at least one processor 61, a memory 62, a bus 63, and a communication interface 64.
[0167] Among them: The processor 61, the communication interface 64, and the memory 62 complete communication with each other through the bus 63.
[0168] The communication interface 64 is used to communicate with other devices. The communication interface includes a communication interface for data transmission and a display interface or an operation interface for human-computer interaction, etc.
[0169] The processor 61 is used to execute the computer instructions stored in the memory 62, and specifically can execute the relevant steps in the method described in the above embodiments.
[0170] The processor 61 may be a central processing unit. One or more processors included in the terminal device can be of the same type of processor, such as one or more CPUs; or different types of processors, such as one or more CPUs and one or more ASICs.
[0171] The memory 62 is used to store computer instructions. The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0172] This embodiment also provides a readable storage medium storing computer instructions. When at least one processor of a terminal device executes the computer instructions, the terminal device executes the model coloring method provided by the above various embodiments.
[0173] This embodiment also provides a program product including computer instructions stored in a readable storage medium. At least one processor of the terminal device can read the computer instructions from the readable storage medium, and the execution of the computer instructions by at least one processor enables the terminal device to implement the model coloring method provided by the above various embodiments.
[0174] In this application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after; in a formula, the character " / " represents a "division" relationship between the associated objects before and after. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b, or c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple.
[0175] It can be understood that the various numerical numbers involved in the embodiments of this application are only for convenience of description and are not used to limit the scope of the embodiments of this application. In the embodiments of this application, the magnitudes of the sequence numbers of the above processes do not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.
[0176] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A model coloring method, characterized in that, Providing a graphical user interface through a terminal device, the content displayed on the graphical user interface at least includes the current game scene and a virtual model in the current game scene, and the method includes: Obtaining a color gradient map corresponding to the current game scene and a texture map of the virtual model, different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different; Coloring the virtual model according to the texture map and the color gradient map; The coloring the virtual model according to the texture map and the color gradient map includes: Obtaining the illumination value of a target area on the surface of the virtual model as the first coordinate value in the two-dimensional coordinates of the target area, the surface of the virtual model includes multiple target areas and the illumination values of each target area are within a preset value range; Determining the index of the color gradient map in a preset color map set, and the indexes of each color gradient map in the preset color map set are different from each other; Determining the second coordinate value in the two-dimensional coordinates according to the index, and the second coordinate value is within the preset value range; Performing color sampling on the color gradient map according to the first coordinate value and the second coordinate value to obtain a target color value corresponding to the target area; Coloring the surface of the virtual model according to the texture map and the target color value; The obtaining the illumination value of a target area on the surface of the virtual model includes: Obtaining the pose of the virtual model in the game scene; Determining the world space normal direction vector and the light incident direction vector of the target area according to the pose; Performing a dot product of the world space normal direction vector and the light incident direction vector to obtain a dot product result; Determining the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the constant dark area in the virtual model.
2. The method according to claim 1, characterized in that The obtaining the color gradient map corresponding to the current game scene includes: Obtaining the corresponding relationship between each color gradient map in a preset color map set and the game scene, and the preset color map set includes at least two color gradient maps; Selecting the color gradient map corresponding to the current game scene from the preset color map set according to the corresponding relationship.
3. The method according to claim 1, wherein The determining the second coordinate value in the two-dimensional coordinates according to the index includes: Obtaining the total number of color gradient maps included in the preset color map set; Calculating the second coordinate value according to the index of the color gradient map and the total number.
4. The method according to claim 1, wherein Determining the light incident direction vector includes: Obtaining the world coordinates of the light source in the game scene and the coordinates of the target area; Subtracting the world coordinates of the light source from the coordinates of the target area to obtain a coordinate difference; Normalizing the coordinate difference to obtain the light incident direction vector.
5. The method according to claim 1, characterized in that, The determining the illumination value of the target area on the surface of the virtual model according to the dot product result and the gray value of the constant dark area in the virtual model includes: Performing an absolute value operation on the dot product result to obtain the dot product result after the operation; Compare the dot product result after the operation with the grayscale value of the constant dark area, and select the smaller value as the illumination value of the target area.
6. The method according to claim 1, wherein The coloring of the surface of the virtual model according to the texture map and the target color value includes: Multiply the texture map and the target color value to obtain a product result for coloring the surface of the virtual model.
7. A model coloring device, characterized in that, Provide a graphical user interface through a terminal device, and the content displayed on the graphical user interface at least includes the current game scene and the virtual model in the current game scene. The device includes: An acquisition module for acquiring the color gradient map corresponding to the current game scene and the texture map of the virtual model. Different game scenes correspond to different color gradient maps, and the color systems of different color gradient maps are different; A coloring module for coloring the surface of the virtual model according to the texture map and the color gradient map; Specifically, the coloring module is configured to obtain the illumination value of the target area on the surface of the virtual model as the first coordinate value in the two-dimensional coordinates of the target area. The surface of the virtual model includes multiple target areas, and the illumination values of each target area are within a preset value range; determine the index of the color gradient map in a preset color atlas, and the indexes of each color gradient map in the preset color atlas are different from each other; according to the index, determine the second coordinate value in the two-dimensional coordinates, and the second coordinate value is within the preset value range; according to the first coordinate value and the second coordinate value, perform color sampling on the color gradient map to obtain the target color value corresponding to the target area; color the surface of the virtual model according to the texture map and the target color value; Specifically, the coloring module is configured to obtain the pose of the virtual model in the game scene; according to the pose, determine the world space normal direction vector and the light incident direction vector of the target area; perform a dot product of the world space normal direction vector and the light incident direction vector to obtain a dot product result; determine the illumination value of the target area on the surface of the virtual model according to the dot product result and the grayscale value of the constant dark area in the virtual model.
8. A terminal device, characterized in that, Including: A processor and a memory communicatively connected to the processor; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory to implement the method according to any one of claims 1-6.
9. A readable storage medium, characterized in that, Computer instructions are stored in the readable storage medium, and when the computer instructions are executed by a processor, they are used to implement the method according to any one of claims 1-6.
10. A program product, comprising computer instructions, characterized in that, When the computer instructions are executed by a processor, they implement the method according to any one of claims 1-6.