A method, device, equipment and medium for adjusting color of a model target area
By obtaining the target map of the 3D model and rendering it in different regions, the problem of affecting the color of other regions in the existing technology when adjusting the color of the target region is solved, and efficient color adjustment and art style control are achieved.
Patent Information
- Application Number
- CN202411944723.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-04
AI Technical Summary
When adjusting the color of the target area of the 3D model, the lighting of the entire game scene needs to be modified, resulting in the color of other areas also changing, which is difficult to control the art style and increases rendering energy consumption.
By obtaining the target map of the model to be rendered, determine the target area on the model surface, and render it in different regions according to the color parameters of the target area and other regions, and adjust the color of the target area.
The color adjustment of the target area is achieved, the color and texture of other areas remains unchanged, the rendering energy consumption is reduced, and the control accuracy of the art style is improved.
Smart Images

Figure CN119746400A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model rendering, and in particular to a method, device, equipment and medium for adjusting the color of a target area of a model. Background Art
[0002] In the field of computer multimedia, physically based rendering PBR (Physically Based Rendering) is used to render 3D models, so that the 3D models can bring close to realistic light and shadow performance. However, for art style projects that require cleaner color images, it is often not necessary for the color performance to be too realistic. Instead, it is more necessary to retain most of the model texture while allowing the target area to have a more transparent artistic performance.
[0003] The current method is to adjust the color of the target area by adding lighting to the game scene, or adjusting the intensity of the main light source and ambient light, etc. However, these methods involve modifying the lighting of the entire game scene, which will adjust the color of all areas, affecting the color and texture of other areas. In addition, it is difficult to control the art and requires repeated adjustments, and it will also increase additional rendering energy consumption. Summary of the invention
[0004] The purpose of the present invention is to provide a method, device, equipment and medium for color adjustment of a target area of a model in view of the deficiencies in the above-mentioned prior art, so as to render the model to be rendered in different areas by determining the rendering color parameters of the target area and the rendering color parameters of other areas, thereby achieving color adjustment of the target area.
[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for adjusting the color of a model target area, comprising:
[0007] Get the target texture of the model to be rendered;
[0008] Determining a target area on a model surface of the model to be rendered according to the target map;
[0009] Determine rendering color parameters of other areas on the model surface and rendering color parameters of the target area according to color parameters of each pixel point on the model surface and preset color saturation parameters;
[0010] The model to be rendered is rendered according to the rendering color parameters of the other areas and the rendering color parameters of the target area.
[0011] In an optional embodiment, the target map includes: a base color map, a metalness map, and a preset shadow mask map, and determining the target area on the model surface of the model to be rendered according to the target map includes:
[0012] Determining a light-colored area on the surface of the model according to the basic color map;
[0013] Determining a non-metallic area on the surface of the model according to the metalness map;
[0014] Determining a dark area on the surface of the model according to the preset shadow mask image;
[0015] The target area is determined according to the light-colored area, the non-metallic area, and the dark area.
[0016] In an optional implementation, determining the light-colored area on the surface of the model according to the basic color map includes:
[0017] Determine, according to the basic color parameters of each pixel in the basic color map, a first color brightness parameter of each pixel on the surface of the model;
[0018] Determining first area marking information of each pixel point according to a first color brightness parameter of each pixel point and a preset minimum brightness threshold parameter;
[0019] The light-colored area is determined according to the first area marking information of each pixel point.
[0020] In an optional embodiment, determining the non-metallic area on the surface of the model according to the metalness map includes:
[0021] Determine the metalness parameter of each pixel point on the surface of the model according to the metalness map;
[0022] Determining second region marking information of each pixel point according to the metalness parameter of each pixel point and a preset maximum metalness threshold parameter;
[0023] The non-metal area is determined according to the second area marking information of each pixel point.
[0024] In an optional implementation, determining the dark area of the model surface according to the preset shadow mask map includes:
[0025] Determining initial lighting rendering parameters of each pixel point on the surface of the model according to the lighting direction and normal direction of each pixel point on the surface of the model;
[0026] Determining target lighting rendering parameters for each pixel point according to the preset shadow mask image and the initial lighting rendering parameters for each pixel point;
[0027] Determining third region marking information of each pixel point according to the target illumination rendering parameter of each pixel point and a preset maximum illumination parameter threshold;
[0028] The dark area is determined according to the third area marking information of each pixel.
[0029] In an optional embodiment, determining the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter includes:
[0030] Calculating second color brightness parameters of each pixel point on the model surface of the model to be rendered according to the color parameters of each pixel point;
[0031] Calculating a target rendering color parameter of each pixel on the surface of the model according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter;
[0032] According to the mask parameters of the target area, a linear difference operation is performed on the color parameters of each pixel and the target rendering color parameters of each pixel to obtain the rendering color parameters of the other areas and the rendering color parameters of the target area.
[0033] In an optional embodiment, calculating the target rendering color parameter of each pixel on the model surface according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter includes:
[0034] According to the preset color saturation parameter, a linear difference operation is performed on the color parameter of each pixel and the second color brightness parameter of each pixel to obtain a target rendering color parameter of each pixel.
[0035] In a second aspect, an embodiment of the present application further provides a color adjustment device for a model target area, comprising:
[0036] An acquisition module is used to obtain a target texture of a model to be rendered;
[0037] A determination module, used to determine a target area on the model surface of the model to be rendered according to the target map;
[0038] The determination module is further used to determine the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter;
[0039] A rendering module is used to render the model to be rendered according to the rendering color parameters of the other areas and the rendering color parameters of the target area.
[0040] In a third aspect, an embodiment of the present application further provides a computer device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the computer device is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the color adjustment method of the model target area as described in any one of the first aspects.
[0041] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the color adjustment method of the model target area as described in any one of the first aspects are executed.
[0042] The beneficial effects of this application are:
[0043] The embodiment of the present application provides a method, device, equipment and medium for adjusting the color of a target area of a model, the method comprising: obtaining a target map of a model to be rendered, determining a target area on a model surface of the model to be rendered according to the target map; determining rendering color parameters of other areas on the model surface and rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and a preset color saturation parameter, and rendering the model to be rendered according to the rendering color parameters of other areas and the rendering color parameters of the target area. In the method of the present application, the target area is determined from the model surface of the model to be rendered by the target map, and then the rendering color parameters of the target area and the rendering color parameters of other areas are determined. Since the rendering color parameters of the target area are different from the rendering color parameters of the other areas, the model to be rendered can be rendered in different areas. For example, if only the color of the target area needs to be adjusted and the colors of other areas remain unchanged, the rendering color parameters of the target area need to be re-determined, and the rendering color parameters of other areas need to be ensured to remain unchanged. Finally, according to the rendering color parameters of other areas and the rendering color parameters of the target area, the model to be rendered is rendered in different areas, without adjusting the colors of all areas on the model surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 One of the flowcharts of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0046] Figure 2 A second flowchart of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0047] Figure 3 A third flowchart of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0048] Figure 4 A fourth flowchart of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0049] Figure 5 A fifth flow chart of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0050] Figure 6 A sixth flowchart of a method for adjusting the color of a model target area provided in an embodiment of the present application;
[0051] Figure 7 A comparison diagram of a model to be rendered before and after rendering provided in an embodiment of the present application;
[0052] Figure 8 A schematic diagram of functional modules of a color adjustment device for a model target area provided in an embodiment of the present application;
[0053] Fig. 9 A schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, 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 described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0055] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0056] In the description of the present application, it should be noted that if the terms "upper", "lower", etc. appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the drawings, or is the orientation or position relationship in which the product of the application is usually placed when used. It is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.
[0057] In addition, the terms "first", "second", etc. in the specification 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 data 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 that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0058] It should be noted that, in the absence of conflict, the features in the embodiments of the present application may be combined with each other.
[0059] In order to perform partition rendering on the target area and other areas in the model to be rendered and achieve color adjustment of the target area, an embodiment of the present application provides a color adjustment method for the target area of the model. In the pixel shader stage, the rendering color parameters of the target area on the model surface of the model to be rendered and the rendering color parameters of other areas are determined according to the color parameters of each pixel point on the model surface and the preset color saturation parameters. Finally, according to the rendering color parameters of other areas and the rendering color parameters of the target area, the model to be rendered is partitioned and rendered, so that the color performance of the target area of the rendered model is more transparent and clean.
[0060] The color adjustment method of the model target area provided by the embodiment of the present application is explained in detail below with reference to the accompanying drawings through specific examples. The color adjustment method of the model target area provided by the embodiment of the present application can be implemented by a computer device pre-installed with: a color adjustment algorithm or detection software for the model target area, by running the algorithm or software. The computer device can be, for example, a server or a terminal, and the terminal can be a user's computer. Figure 1 One of the flow charts of a method for adjusting the color of a model target area provided in an embodiment of the present application; Figure 1 As shown, the method includes:
[0061] S101, obtaining a target texture of a model to be rendered.
[0062] S102: Determine a target area on the model surface of the model to be rendered according to the target map.
[0063] In this embodiment, at the pixel shader stage, a target map of the model to be rendered is first obtained, and a target area on the surface of the model is determined by the target map.
[0064] Optionally, the target map includes: a base color map, a metalness map, and a preset shadow mask map.
[0065] The basic color map includes: the basic color value of each pixel, the metalness map includes: the metalness of each pixel, and the preset shadow mask map includes: the shadow information caused by other models on the model surface of the model to be rendered.
[0066] S103 , determining rendering color parameters of other areas on the model surface and rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter.
[0067] S104: Rendering the model to be rendered according to the rendering color parameters of other regions and the rendering color parameters of the target region.
[0068] Specifically, in order to adjust the color of the target area, the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area are determined according to the color parameters of each pixel point on the model surface and the preset color saturation parameters, so that when rendering the model to be rendered, the other areas are rendered according to the rendering color parameters of other areas, and the target area is rendered according to the rendering color parameters of the target area.
[0069] Among them, this embodiment determines the rendering color parameters of other areas and the rendering color parameters of the target area. However, in order to adjust the color of only the target area on the surface of the model, so that the color performance of the light-colored non-metallic dark area after rendering is more transparent and clean, and the color and texture of other areas are retained, the rendering color parameters of other areas are still the original rendering color parameters of the model to be rendered, and the rendering color parameters of the target area are the re-determined rendering color parameters.
[0070] It should be noted that if other areas are metal areas, the metal texture in the model comes from the clear contrast between light and dark. If the color of the metal area is adjusted, it will affect the metal texture of the model. Therefore, the color of the metal area is not adjusted. If other areas are black or dark areas, if the color of the black or dark areas is adjusted, it will affect the three-dimensional sense of the model. Therefore, the color of the black or dark areas is not adjusted.
[0071] In summary, the embodiment of the present application provides a method for adjusting the color of a target area of a model, including: obtaining a target map of a model to be rendered, determining a target area on a model surface of the model to be rendered according to the target map; determining rendering color parameters of other areas on the model surface and rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter, and rendering the model to be rendered according to the rendering color parameters of other areas and the rendering color parameters of the target area. In the method of the present application, the target area is determined from the model surface of the model to be rendered by the target map, and then the rendering color parameters of the target area and the rendering color parameters of other areas are determined. Since the rendering color parameters of the target area are different from the rendering color parameters of other areas, the model to be rendered can be rendered in different areas. For example, if only the color of the target area needs to be adjusted and the colors of other areas remain unchanged, it is necessary to re-determine the rendering color parameters of the target area and ensure that the rendering color parameters of other areas remain unchanged. Finally, according to the rendering color parameters of other areas and the rendering color parameters of the target area, the model to be rendered is rendered in different areas, without adjusting the colors of all areas on the model surface.
[0072] Based on a color adjustment method for a model target area provided in the above embodiment, an embodiment of the present application provides another possible implementation of a color adjustment method for a model target area by determining a target area. Figure 2 The second flowchart of a method for adjusting the color of a model target area provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, according to the target map, determining the target area on the model surface of the model to be rendered includes:
[0073] S201. Determine the light-colored area on the surface of the model according to the basic color map.
[0074] S202. Determine the non-metallic area on the surface of the model according to the metalness map.
[0075] S203: Determine the dark area on the model surface according to a preset shadow mask image.
[0076] S204: Determine a target area according to the light-colored area, the non-metallic area, and the dark area.
[0077] In this embodiment, the light-colored area on the model surface is determined according to the basic color map and the UV coordinates of each pixel in the model, and then the non-metallic area on the model surface is determined according to the metalness map and the UV coordinates of each pixel in the model. The dark area on the model surface is determined according to the preset shadow mask map and the illumination direction and normal direction of each pixel in the model. Finally, the target area is determined based on the light-colored area, the non-metallic area and the dark area, wherein the target area is the light-colored non-metallic dark area.
[0078] Specifically, the light-colored area, the non-metallic area, and the dark area are multiplied to determine the target area. The calculation formula is expressed as:
[0079] adjustMask=diffuseMask*metalMask*darkMask
[0080] Among them, adjustMask represents the target area, diffuseMask represents the light-colored area, metalMask represents the non-metallic area, and darkMask represents the dark area.
[0081] It should be noted that the light-colored area, the non-metallic area, and the dark area are all marked by a 0-1 range, and the 0-1 range of the target area can be determined by performing a multiplication process on the light-colored area, the non-metallic area, and the dark area.
[0082] In the method provided in the embodiment of the present application, the light-colored area on the surface of the model is determined according to the basic color map, the non-metallic area on the surface of the model is determined according to the metalness map, the dark area on the surface of the model is determined according to the preset shadow mask map, and the target area is determined according to the light-colored area, the non-metallic area and the dark area. The light-colored area, the non-metallic area and the dark area on the surface of the model are determined respectively by the basic color map, the metalness map and the preset shadow mask map, and finally the target area, i.e., the light-colored non-metallic dark area, is obtained by multiplying them.
[0083] Based on the color adjustment method of a model target area provided by determining the target area in the above embodiment, the embodiment of the present application provides another possible implementation of the color adjustment method of the model target area by determining the light-colored area. Figure 3 The third flow chart of a method for adjusting the color of a model target area provided in an embodiment of the present application. Figure 3 As shown, according to the basic color map, the light-colored area on the model surface is determined, including:
[0084] S301 . Determine a first color brightness parameter of each pixel point according to a basic color parameter of each pixel point in a basic color map.
[0085] In this embodiment, the basic color value of each pixel in the basic color map is determined according to the basic color map and the UV coordinates of each pixel. The basic color value diffuseColor of each pixel is expressed as: diffuseColor=sample(diffuseTexture,UV), wherein diffuseTexture is represented as the basic color map, and the sample function is used to determine the basic color value diffuseColor of each pixel according to the basic color map diffuseTexture and the UV coordinates of each pixel.
[0086] According to the basic color value diffuseColor of each pixel, the first color brightness parameter of each pixel is determined. The first color brightness parameter diffuseBrightness of each pixel is expressed as: diffuseBrightness=diffuseColor.r*0.3+diffuseColor.g*0.59+diffuseColor.b*0.11, where r, g, and b represent the RGB components of the basic color value, and 0.3, 0.59, and 0.11 represent the coefficients corresponding to the RGB components, respectively, and there is no restriction here.
[0087] S302: Determine first region marking information of each pixel according to a first color brightness parameter of each pixel and a preset minimum brightness threshold parameter.
[0088] S303: Determine a light-colored area according to the first area marking information of each pixel.
[0089] Specifically, the first region marking information of each pixel is expressed as:
[0090] diffuseMask=saturate((diffuseBrightness-0.56)*2.5)
[0091] Among them, diffuseMask is represented as a light-colored area, and the saturate function can limit the result of the first color brightness parameter of each pixel point to between 0 and 1, and determine the first area marking information of each pixel point, that is, 0-1, and 0.56 and 2.5 are preset minimum brightness threshold parameters.
[0092] If the first color brightness parameter diffuseBrightness of the current pixel is greater than 0.96, the first area marking information of the current pixel is 1, indicating that the current pixel is in the area with the highest color brightness, for example, in the white area. If the first color brightness parameter diffuseBrightness of the current pixel is less than 0.56, the first area marking information of the current pixel is 0, indicating that the current pixel is in the area with the lowest color brightness, for example, in the black area. If 0.56≤the first color brightness parameter diffuseBrightness≤0.96 of the current pixel, the first area marking information of the current pixel is a linear transition from 0 to 1. The closer the first color brightness parameter of the current pixel is to 0.96, the closer the corresponding first area marking information is to 1. The closer the first color brightness parameter of the current pixel is to 0.56, the closer the corresponding first area marking information is to 0.
[0093] Finally, according to the first area marking information of each pixel point, the pixel points corresponding to the larger first area marking information are recorded, and it is determined that the area formed by the recorded pixel points is a light-colored area.
[0094] In the method provided in the embodiment of the present application, the first color brightness parameter of each pixel is determined according to the basic color parameter of each pixel in the basic color map, the first area marking information of each pixel is determined according to the first color brightness parameter of each pixel and the preset minimum brightness threshold parameter, and the light-colored area is determined according to the first area marking information of each pixel. The first area marking information of each pixel is determined by processing the first color brightness parameter of each pixel and the preset minimum brightness threshold parameter, thereby determining the light-colored area on the model surface.
[0095] The embodiment of the present application provides another possible implementation of the color adjustment method of the model target area by determining the non-metal area. Figure 4 FIG4 is a flow chart of a method for adjusting the color of a model target area provided in an embodiment of the present application. Figure 4 As shown, according to the metalness map, the non-metallic area on the model surface is determined, including:
[0096] S401. Determine the metalness parameter of each pixel on the surface of the model according to the metalness map.
[0097] In this embodiment, the metalness parameter metalness of each pixel is determined according to the metalness map and the UV coordinates of each pixel.
[0098] S402 : Determine second region marking information of each pixel according to a metalness parameter of each pixel and a preset maximum metalness threshold parameter.
[0099] S403: Determine a non-metal region according to the second region marking information of each pixel.
[0100] Specifically, the second region marking information of each pixel is expressed as:
[0101] metalMask=1–saturate((metalness–0.5)*2.5)
[0102] Among them, metalMask represents the non-metal area, and the saturate function can limit the result of the metalness parameter of each pixel point to between 0 and 1, and determine the second area marking information of each pixel point, that is, 0-1, 1, 0.5, and 2.5 as the preset maximum metalness threshold parameters.
[0103] If the metalness parameter metalMask of the current pixel is greater than 0.9, the second region marking information of the current pixel is 0, indicating that the current pixel is in the region with the strongest metalness. If the metalness parameter metalMask of the current pixel is less than 0.5, the second region marking information of the current pixel is 1, indicating that the current pixel is in the region with the weakest metalness. If 0.5≤the metalness parameter metalMask≤0.9 of the current pixel, the second region marking information of the current pixel is a linear transition from 0 to 1. The closer the metalness parameter of the current pixel is to 0.9, the closer the corresponding second region marking information is to 0. The closer the metalness parameter of the current pixel is to 0.5, the closer the corresponding second region marking information is to 1.
[0104] Finally, according to the second region marking information of each pixel point, the pixel points corresponding to the larger second region marking information are recorded, and it is determined that the region formed by the recorded pixel points is a non-metal region.
[0105] In the method provided in the embodiment of the present application, the metal parameter of each pixel on the surface of the model is determined based on the metal map, the second region marking information of each pixel is determined based on the metal parameter of each pixel and the preset maximum metal threshold parameter, and the non-metal region is determined based on the second region marking information of each pixel. The metal parameter of each pixel and the preset maximum metal threshold parameter are processed to determine the second region marking information of each pixel, thereby determining the non-metal region on the surface of the model.
[0106] The embodiment of the present application provides another possible implementation of the color adjustment method of the model target area by determining the dark area. Figure 5 FIG5 is a flow chart of a method for adjusting the color of a model target area provided in an embodiment of the present application. Figure 5 As shown, according to the preset shadow mask map, the dark area of the model surface is determined, including:
[0107] S501 . Determine initial illumination rendering parameters for each pixel on the model surface according to the illumination direction and normal direction of each pixel on the model surface.
[0108] In this embodiment, the illumination direction and the normal direction of each pixel are calculated by dot multiplication to determine the initial illumination rendering parameters of each pixel on the surface of the model, wherein the dot multiplication calculation formula is expressed as: NdotL=dot(lightDirection,normal), wherein NdotL represents the initial illumination rendering parameters of each pixel, dot(lightDirection,normal) represents the dot multiplication function, lightDirection represents the illumination direction of each pixel, and normal represents the normal direction of each pixel. The illumination direction and the normal direction of each pixel are calculated by dot multiplication to determine the cosine value of the angle between the illumination direction and the normal direction of each pixel, that is, the initial illumination rendering parameters of each pixel are determined. The initial illumination rendering parameters can represent the brightness of each pixel in the model. The value range of the initial illumination rendering parameters of each pixel is -1 to 1. If the initial illumination rendering parameter of the current pixel is -1, it represents that the current pixel is in the dark area of illumination. If the initial illumination rendering parameter of the current pixel is 1, it represents that the current pixel is in the bright area of illumination.
[0109] S502: Determine target lighting rendering parameters for each pixel point according to a preset shadow mask image and initial lighting rendering parameters for each pixel point.
[0110] Specifically, the target lighting rendering parameter NdotLFixed of each pixel is expressed as: NdotLFixed=min(saturate(NdotL),shadowMap), where shadowMap represents a preset shadow mask map, which includes information in the shadow area caused by other models, and is represented by 0 to 1. 0 indicates that the current pixel is blocked by other models in the lighting direction, and is in the shadow of the preset shadow mask map. 1 indicates that the current pixel is not blocked by other models in the lighting direction.
[0111] The saturate function returns the negative value of the initial lighting rendering parameter NdotL (i.e., the part where the normal is facing away from the lighting direction) to 0, and adjusts the value range of the initial lighting rendering parameter of each pixel from -1 to 1 to 0 to 1.
[0112] Then, the preset shadow mask image is compared with the initial lighting rendering parameters of each pixel, and the minimum value is taken as the target lighting rendering parameter of each pixel.
[0113] S503 . Determine third region marking information of each pixel point according to the target illumination rendering parameter of each pixel point and a preset maximum illumination parameter threshold.
[0114] S504: Determine a dark area according to the third area marking information of each pixel.
[0115] Specifically, the third region marking information of each pixel is expressed as:
[0116] darkMask=1–saturate((NdotLFixed–0.2)*3.333)
[0117] Among them, darkMask represents the dark area, and the saturate function can limit the result of the target lighting rendering parameter of each pixel point to between 0 and 1, and determine the third area marking information of each pixel point, that is, 0-1, 1, 0.2, and 3.333 are the preset maximum lighting parameter thresholds.
[0118] If the target lighting rendering parameter NdotLFixed of the current pixel is greater than 0.5, the third area marking information of the current pixel is 0, indicating that the current pixel is in the bright area of the lighting; if the target lighting rendering parameter NdotLFixed of the current pixel is less than 0.2, the third area marking information of the current pixel is 1, indicating that the current pixel is in the dark area of the lighting; if 0.2≤the target lighting rendering parameter NdotLFixed≤0.5 of the current pixel, the third area marking information of the current pixel is a linear transition from 0 to 1; the closer the target lighting rendering parameter of the current pixel is to 0.5, the closer the corresponding third area marking information is to 0; the closer the target lighting rendering parameter of the current pixel is to 0.2, the closer the corresponding third area marking information is to 1.
[0119] Finally, according to the third area marking information of each pixel point, the pixel points corresponding to the larger third area marking information are recorded, and the area formed by the recorded pixel points is determined to be the dark area.
[0120] In the method provided in the embodiment of the present application, the initial lighting rendering parameters of each pixel on the model surface are determined according to the lighting direction and normal direction of each pixel on the model surface, the target lighting rendering parameters of each pixel are determined according to the preset shadow mask map and the initial lighting rendering parameters of each pixel, the third area marking information of each pixel is determined according to the target lighting rendering parameters of each pixel and a preset maximum lighting parameter threshold, and the dark area is determined according to the third area marking information of each pixel. By combining the preset shadow mask map, the shadow area caused by the occlusion of the model surface of the model to be rendered by other models is taken into account to determine the target lighting rendering parameters of each pixel, and then the target lighting rendering parameters of each pixel and the preset maximum lighting parameter threshold are processed to determine the third area marking information of each pixel, thereby determining the dark area on the model surface.
[0121] The embodiment of the present application provides another possible implementation of the color adjustment method of the target area of the model by determining the rendering color parameters of the target area. Figure 6 The sixth flow chart of a method for adjusting the color of a model target area provided in an embodiment of the present application. Figure 6 As shown, according to the color parameters of each pixel point on the model surface and the preset color saturation parameters, the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area are determined, including:
[0122] S601 . Calculate a second color brightness parameter of each pixel on a model surface of a model to be rendered according to a color parameter of each pixel.
[0123] In this embodiment, by adopting the physical rendering PBR algorithm, the red, green and blue three-channel values of each pixel point on the model surface of the rendered model are calculated to obtain the color parameter PBRResult of each pixel point. The color parameter PBRResult is an array composed of the red, green and blue three-channel values.
[0124] The second color brightness parameter is expressed as: PBRResultBrightness=PBRResult.r*0.3+PBRResult.g*0.59+PBRResult.b*0.11, where PBRResultBrightness is expressed as the second color brightness parameter, r, g, and b represent the RGB components of the color parameter PBRResult, respectively, and 0.3, 0.59, and 0.11 are coefficients corresponding to the RGB components, respectively, and are not limited here.
[0125] S602 : Calculate a target rendering color parameter of each pixel on the model surface according to the second color brightness parameter of each pixel, the color parameter of each pixel, and a preset color saturation parameter.
[0126] In order to adjust the color of each pixel in the target area, the target rendering color parameter of each pixel on the model surface is determined according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter.
[0127] Optionally, according to a preset color saturation parameter, a linear difference operation is performed on the color parameter of each pixel and the second color brightness parameter of each pixel to obtain a target rendering color parameter of each pixel.
[0128] Among them, the target rendering color parameter calculation formula is expressed as: SaturationUpResult=lerp(PBRResultBrightness,PBRResult,SaturationUp), wherein SaturationUpResult represents the target rendering color parameter, SaturationUp represents the preset color saturation parameter, which can be set to 3 and is not limited here, and the lerp function is a linear interpolation function.
[0129] By performing a linear difference operation on the color parameter of each pixel and the second color brightness parameter of each pixel, the target rendering color parameter of each pixel is determined, that is, the saturation and brightness of the color of each pixel are improved to determine the improved rendering color parameter.
[0130] S603 , performing a linear interpolation operation on the color parameters of each pixel and the target rendering color parameters of each pixel according to the mask parameters of the target area, to obtain rendering color parameters of other areas and the rendering color parameters of the target area.
[0131] Since the color parameters of each pixel in the model to be rendered are adjusted, the target rendering color parameters of each pixel are obtained. In order to adjust the color of the target area only, the color parameters of each pixel and the target rendering color parameters of each pixel are linearly interpolated according to the mask parameters of the target area. Specifically, the calculation formula is: FinalResult=lerp(PBRResult,SaturationUpResult,adjustMask), wherein adjustMask represents the target area, including the mask parameters, and FinalResult is represented as the rendering color parameters of each pixel. Through linear interpolation operation, the rendering color parameters of each pixel in the target area are determined to be the target rendering color parameters SaturationUpResult corresponding to each pixel, and the rendering color parameters of each pixel in other areas are the color parameters PBRResult corresponding to each pixel. Finally, the rendering color parameters of each pixel in the model to be rendered are determined.
[0132] In the method provided in the embodiment of the present application, the second color brightness parameter of each pixel on the model surface of the model to be rendered is calculated according to the color parameter of each pixel, the target rendering color parameter of each pixel on the model surface is calculated according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter, and the color parameter of each pixel and the target rendering color parameter of each pixel are linearly interpolated according to the mask parameter of the target area to obtain the rendering color parameters of other areas and the rendering color parameters of the target area. First, the color parameters of all pixels in the model to be rendered are adjusted to obtain the target rendering color parameters, and then the rendering color parameters of other areas and the rendering color parameters of the target area are determined according to the mask parameter of the target area, so that the rendering color parameters of the target area are the target rendering color parameters, and the rendering color parameters of other areas are also color parameters, so that the color adjustment of each pixel only in the target area is achieved.
[0133] Figure 7 A comparison diagram of a model to be rendered before and after rendering provided in an embodiment of the present application, such as Figure 7 As shown, the left picture is the model before the model to be rendered, that is, the initial model to be rendered, and the right picture is the model after the model to be rendered is rendered according to the rendering color parameters of other areas and the rendering color parameters of the target area. For example, if area A is determined as the target area, it can be seen that the color in area A in the left picture is too realistic, resulting in darker colors, and the artistic effect of the clothes is dirty and black. However, this application determines the rendering color parameters of area A and the rendering color parameters of other areas, and after the model to be rendered is rendered, area A in the right picture has a cleaner and more transparent artistic expression, and the colors of other areas are not adjusted, and the colors and textures of other areas are retained.
[0134] In the method of the present application, by determining the target area, i.e., the light-colored non-metallic dark area, from the model surface of the model to be rendered, then determining the rendering color parameters of the target area and the rendering color parameters of other areas, and finally rendering the model to be rendered, the target area that requires color adjustment can be accurately determined, and by adjusting the rendering color parameters, the rendered model can retain the texture of the model while giving the light-colored non-metallic dark area a more transparent and clean artistic expression. There is no need to adjust the color of the light-colored non-metallic dark area by adjusting the ambient light or increasing the light, thereby avoiding additional rendering energy consumption.
[0135] The following is a corresponding explanation of the color adjustment device and computer equipment for executing any of the above embodiments of the present application. The specific implementation process and the technical effects produced are the same as those of the corresponding method embodiments mentioned above. For the sake of brief description, the parts not mentioned in this embodiment can refer to the corresponding contents in the method embodiments.
[0136] Figure 8 This is a functional module diagram of a color adjustment device for a model target area provided in an embodiment of the present application. Figure 8 As shown, the color adjustment device 100 of the model target area includes:
[0137] An acquisition module 110 is used to acquire a target texture of a model to be rendered;
[0138] A determination module 120, configured to determine a target area on a model surface of a model to be rendered according to a target map;
[0139] The determination module 120 is further used to determine the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter;
[0140] The rendering module 130 is used to render the model to be rendered according to the rendering color parameters of other regions and the rendering color parameters of the target region.
[0141] Optionally, the target map includes: a base color map, a metalness map and a preset shadow mask map. The determination module 120 is also used to determine the light-colored area on the model surface according to the base color map; determine the non-metallic area on the model surface according to the metalness map; determine the dark area on the model surface according to the preset shadow mask map; and determine the target area based on the light-colored area, the non-metallic area and the dark area.
[0142] Optionally, the determination module 120 is also used to determine the first color brightness parameter of each pixel on the model surface based on the basic color parameters of each pixel in the basic color map; determine the first area marking information of each pixel based on the first color brightness parameter of each pixel and a preset minimum brightness threshold parameter; and determine the light-colored area based on the first area marking information of each pixel.
[0143] Optionally, the determination module 120 is also used to determine the metalness parameters of each pixel on the model surface based on the metalness map; determine the second area marking information of each pixel based on the metalness parameters of each pixel and a preset maximum metalness threshold parameter; and determine the non-metal area based on the second area marking information of each pixel.
[0144] Optionally, the determination module 120 is also used to determine the initial lighting rendering parameters of each pixel on the model surface according to the lighting direction and normal direction of each pixel on the model surface; determine the target lighting rendering parameters of each pixel according to a preset shadow mask image and the initial lighting rendering parameters of each pixel; determine the third area marking information of each pixel according to the target lighting rendering parameters of each pixel and a preset maximum lighting parameter threshold; determine the dark area according to the third area marking information of each pixel.
[0145] Optionally, the determination module 120 is further used to calculate the second color brightness parameter of each pixel on the model surface of the model to be rendered according to the color parameter of each pixel; calculate the target rendering color parameter of each pixel on the model surface according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter; perform linear interpolation operation on the color parameter of each pixel and the target rendering color parameter of each pixel according to the mask parameter of the target area to obtain the rendering color parameters of other areas and the rendering color parameters of the target area.
[0146] Optionally, the determination module 120 is further configured to perform a linear difference operation on the color parameter of each pixel and the second color brightness parameter of each pixel according to a preset color saturation parameter to obtain a target rendering color parameter of each pixel.
[0147] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0148] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0149] Fig. 9 Schematic diagram of a computer device provided in an embodiment of the present application, which can be used for color adjustment of a target area of a model. Fig. 9As shown, the computer device 200 includes: a processor 210 , a storage medium 220 , and a bus 230 .
[0150] The storage medium 220 stores machine-readable instructions executable by the processor 210. When the computer device is running, the processor 210 communicates with the storage medium 220 via the bus 230, and the processor 210 executes the machine-readable instructions. The execution method includes:
[0151] Obtain a target map of the model to be rendered; determine a target area on the model surface of the model to be rendered based on the target map; determine rendering color parameters of other areas on the model surface and rendering color parameters of the target area based on color parameters of each pixel point on the model surface and preset color saturation parameters; render the model to be rendered based on the rendering color parameters of other areas and rendering color parameters of the target area.
[0152] Optionally, the target map includes: a base color map, a metalness map, and a preset shadow mask map. According to the target map, determining a target area on the model surface of the model to be rendered includes:
[0153] According to the basic color map, the light-colored area on the model surface is determined; according to the metalness map, the non-metallic area on the model surface is determined; according to the preset shadow mask map, the dark area on the model surface is determined; according to the light-colored area, non-metallic area and dark area, the target area is determined.
[0154] Optionally, according to the base color map, determine the light-colored area of the model surface, including:
[0155] According to the basic color parameters of each pixel in the basic color map, the first color brightness parameters of each pixel on the model surface are determined; according to the first color brightness parameters of each pixel and the preset minimum brightness threshold parameter, the first area marking information of each pixel is determined; according to the first area marking information of each pixel, the light-colored area is determined.
[0156] Optionally, non-metallic areas on the model surface are determined based on the metalness map, including:
[0157] According to the metalness map, the metalness parameters of each pixel on the model surface are determined; according to the metalness parameters of each pixel and a preset maximum metalness threshold parameter, the second area marking information of each pixel is determined; according to the second area marking information of each pixel, the non-metal area is determined.
[0158] Optionally, determining the dark area on the surface of the model according to a preset shadow mask map includes:
[0159] Determine the initial lighting rendering parameters of each pixel on the model surface according to the lighting direction and normal direction of each pixel on the model surface; determine the target lighting rendering parameters of each pixel according to the preset shadow mask map and the initial lighting rendering parameters of each pixel; determine the third area marking information of each pixel according to the target lighting rendering parameters of each pixel and the preset maximum lighting parameter threshold; determine the dark area according to the third area marking information of each pixel.
[0160] Optionally, according to the color parameters of each pixel point on the model surface and the preset color saturation parameter, the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area are determined, including:
[0161] According to the color parameters of each pixel, the second color brightness parameters of each pixel on the model surface of the model to be rendered are calculated; according to the second color brightness parameters of each pixel, the color parameters of each pixel, and the preset color saturation parameters, the target rendering color parameters of each pixel on the model surface are calculated; according to the mask parameters of the target area, the color parameters of each pixel and the target rendering color parameters of each pixel are linearly interpolated to obtain the rendering color parameters of other areas and the rendering color parameters of the target area.
[0162] Optionally, calculating a target rendering color parameter of each pixel on the model surface according to the second color brightness parameter of each pixel, the color parameter of each pixel, and a preset color saturation parameter includes:
[0163] According to the preset color saturation parameter, a linear difference operation is performed on the color parameter of each pixel and the second color brightness parameter of each pixel to obtain a target rendering color parameter of each pixel.
[0164] Optionally, the present application further provides a storage medium 220 on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method embodiment are executed.
[0165] When the program is executed by the processor, the execution method may include:
[0166] Obtain a target map of the model to be rendered; determine a target area on the model surface of the model to be rendered based on the target map; determine rendering color parameters of other areas on the model surface and rendering color parameters of the target area based on color parameters of each pixel point on the model surface and preset color saturation parameters; render the model to be rendered based on the rendering color parameters of other areas and rendering color parameters of the target area.
[0167] Optionally, the target map includes: a base color map, a metalness map, and a preset shadow mask map. According to the target map, determining a target area on the model surface of the model to be rendered includes:
[0168] According to the basic color map, the light-colored area on the model surface is determined; according to the metalness map, the non-metallic area on the model surface is determined; according to the preset shadow mask map, the dark area on the model surface is determined; according to the light-colored area, non-metallic area and dark area, the target map is determined.
[0169] Optionally, according to the base color map, determine the light-colored area of the model surface, including:
[0170] According to the basic color parameters of each pixel in the basic color map, the first color brightness parameters of each pixel on the model surface are determined; according to the first color brightness parameters of each pixel and the preset minimum brightness threshold parameter, the first area marking information of each pixel is determined; according to the first area marking information of each pixel, the light-colored area is determined.
[0171] Optionally, non-metallic areas on the model surface are determined based on the metalness map, including:
[0172] According to the metalness map, the metalness parameters of each pixel on the model surface are determined; according to the metalness parameters of each pixel and a preset maximum metalness threshold parameter, the second area marking information of each pixel is determined; according to the second area marking information of each pixel, the non-metal area is determined.
[0173] Optionally, determining the dark area on the surface of the model according to a preset shadow mask map includes:
[0174] Determine the initial lighting rendering parameters of each pixel on the model surface according to the lighting direction and normal direction of each pixel on the model surface; determine the target lighting rendering parameters of each pixel according to the preset shadow mask map and the initial lighting rendering parameters of each pixel; determine the third area marking information of each pixel according to the target lighting rendering parameters of each pixel and the preset maximum lighting parameter threshold; determine the dark area according to the third area marking information of each pixel.
[0175] Optionally, according to the color parameters of each pixel point on the model surface and the preset color saturation parameter, the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area are determined, including:
[0176] According to the color parameters of each pixel, the second color brightness parameters of each pixel on the model surface of the model to be rendered are calculated; according to the second color brightness parameters of each pixel, the color parameters of each pixel, and the preset color saturation parameters, the target rendering color parameters of each pixel on the model surface are calculated; according to the mask parameters of the target area, the color parameters of each pixel and the target rendering color parameters of each pixel are linearly interpolated to obtain the rendering color parameters of other areas and the rendering color parameters of the target area.
[0177] Optionally, calculating a target rendering color parameter of each pixel on the model surface according to the second color brightness parameter of each pixel, the color parameter of each pixel, and a preset color saturation parameter includes:
[0178] According to the preset color saturation parameter, a linear difference operation is performed on the color parameter of each pixel and the second color brightness parameter of each pixel to obtain a target rendering color parameter of each pixel.
[0179] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, 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 devices or units, which can be electrical, mechanical or other forms.
[0180] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0181] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0182] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0183] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for adjusting the color of a model target area, characterized in that: include: Get the target texture of the model to be rendered; Determining a target area on a model surface of the model to be rendered according to the target map; Determining rendering color parameters of other areas on the model surface and rendering color parameters of the target area according to color parameters of each pixel point on the model surface and preset color saturation parameters; The model to be rendered is rendered according to the rendering color parameters of the other areas and the rendering color parameters of the target area.
2. The method according to claim 1, characterized in that The target map includes: a basic color map, a metalness map, and a preset shadow mask map. Determining the target area on the model surface of the model to be rendered according to the target map includes: Determining a light-colored area on the surface of the model according to the basic color map; Determining a non-metallic area on the surface of the model according to the metalness map; Determining a dark area on the surface of the model according to the preset shadow mask image; The target area is determined according to the light-colored area, the non-metallic area, and the dark area.
3. The method according to claim 2, characterized in that Determining the light-colored area on the surface of the model according to the basic color map includes: Determine a first color brightness parameter of each pixel point according to a basic color parameter of each pixel point in the basic color map; Determining first area marking information of each pixel point according to a first color brightness parameter of each pixel point and a preset minimum brightness threshold parameter; The light-colored area is determined according to the first area marking information of each pixel point.
4. The method according to claim 2, characterized in that: Determining the non-metallic area on the surface of the model according to the metalness map includes: Determining the metallicity parameter of each pixel according to the metallicity map; Determining second region marking information of each pixel point according to the metalness parameter of each pixel point and a preset maximum metalness threshold parameter; The non-metal area is determined according to the second area marking information of each pixel point.
5. The method according to claim 2, characterized in that: Determining the dark area on the surface of the model according to the preset shadow mask map includes: Determining initial lighting rendering parameters of each pixel point according to the lighting direction and normal direction of each pixel point on the surface of the model; Determining target lighting rendering parameters for each pixel point according to the preset shadow mask image and the initial lighting rendering parameters for each pixel point; Determining third region marking information of each pixel point according to the target illumination rendering parameter of each pixel point and a preset maximum illumination parameter threshold; The dark area is determined according to the third area marking information of each pixel.
6. The method according to claim 1, characterized in that The step of determining the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area according to the color parameters of each pixel on the model surface and the preset color saturation parameter includes: Calculating second color brightness parameters of each pixel point on the model surface of the model to be rendered according to the color parameters of each pixel point; Calculating a target rendering color parameter of each pixel on the surface of the model according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter; According to the mask parameters of the target area, a linear difference operation is performed on the color parameters of each pixel and the target rendering color parameters of each pixel to obtain the rendering color parameters of the other areas and the rendering color parameters of the target area.
7. The method according to claim 6, characterized in that The step of calculating the target rendering color parameter of each pixel on the surface of the model according to the second color brightness parameter of each pixel, the color parameter of each pixel, and the preset color saturation parameter includes: According to the preset color saturation parameter, a linear difference operation is performed on the color parameter of each pixel and the second color brightness parameter of each pixel to obtain a target rendering color parameter of each pixel.
8. A color adjustment device for a model target area, characterized in that: include: An acquisition module is used to obtain a target texture of a model to be rendered; A determination module, used to determine a target area on the model surface of the model to be rendered according to the target map; The determination module is further used to determine the rendering color parameters of other areas on the model surface and the rendering color parameters of the target area according to the color parameters of each pixel point on the model surface and the preset color saturation parameter; A rendering module is used to render the model to be rendered according to the rendering color parameters of the other areas and the rendering color parameters of the target area.
9. A computer device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the computer device is running, the processor and the storage medium communicate through the bus, and the processor executes the program instructions to perform the steps of the color adjustment method of the model target area as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for adjusting the color of the model target area according to any one of claims 1 to 7 are executed.