Model shadow effect generation method, device and electronic equipment

By sampling and interpolating the normal map in multiple dimensions and combining it with ambient light parameters, a realistic shadow effect is generated, which solves the problems of fixed shadow effects and high overhead in model rendering, and realizes flexible changes in shadow effects and efficient rendering.

CN115439596BActive Publication Date: 2026-07-21NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETEASE (HANGZHOU) NETWORK CO LTD
Filing Date
2022-07-28
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve realistic shadow effects and efficient rendering in model rendering, especially due to the problem of fixed lighting and shadow effects or high computational overhead from multiple iterations.

Method used

By sampling and interpolating the normal map of the target model in multiple dimensions, and combining the illumination angle and height of the ambient light source, the diffuse color performance coefficient is adjusted to generate color data with shadow effects.

Benefits of technology

It achieves realistic shadow effects that change with ambient light, while reducing rendering computation overhead and eliminating the need for additional shadow effect textures and multiple iterations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115439596B_ABST
    Figure CN115439596B_ABST
Patent Text Reader

Abstract

The application provides a model shadow effect generation method and device and electronic equipment; wherein the method comprises: performing first sampling processing on a normal map of a target model to obtain a first direction map in multiple dimension directions; performing first interpolation mixing processing on the first direction map based on an illumination angle component of an environment light source in the multiple dimension directions to obtain a first processing result; performing offset processing on a UV coordinate value of the normal map based on an illumination height of the environment light source, performing second sampling processing on the normal map to obtain a second direction map; performing second interpolation mixing processing on the first direction map and the second direction map based on the illumination angle component to obtain a second processing result; and determining a diffuse reflection color performance coefficient of the target model based on the first processing result and the second processing result. This way can make the shadow effect change with the change of the environment light source, and the performance is more realistic; and the rendering operation cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model rendering, and in particular to a method, apparatus, and electronic device for generating model shadow effects. Background Technology

[0002] To reduce model production costs and rendering overhead, finished models typically have few bumps on their surfaces. During model rendering, normal maps can be used to add bump effects to the model's surface. However, since bump effects are achieved through normal map rendering, the model's surface does not actually have corresponding bump surfaces. Therefore, when the model is placed in a virtual scene with light sources, it cannot produce relatively realistic lighting and shadow effects based on bump effects.

[0003] In related technologies, the lighting and shadow effects of a model can be rendered using light and shadow mapping, but the lighting effects rendered by this method are fixed, and the number of textures needs to be increased, resulting in a large rendering computational overhead; the lighting and shadow effects can also be rendered using multi-sample normal mapping, but this method requires multiple iterations of computation, and the rendering computational overhead is still very large. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for generating model shadow effects, so that the shadow effects can change with the changes of ambient light source, making the performance more realistic; at the same time, the rendering computation overhead is reduced.

[0005] In a first aspect, embodiments of the present invention provide a method for generating a model shadow effect. The method includes: performing a first sampling process on a normal map of a target model to obtain a first directional map in multiple dimensions; the first directional map includes normal components in the corresponding dimensional directions; performing a first interpolation and mixing process on the first directional map in multiple dimensions based on the illumination angle components of an ambient light source in multiple dimensions to obtain a first processing result; wherein the ambient light source is located in the three-dimensional space where the target model is located; performing an offset process on the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source, and performing a second sampling process on the normal map using the offset UV coordinate values ​​to obtain a second directional map in multiple dimensions; performing a second interpolation and mixing process on the first directional map and the second directional map based on the illumination angle components in multiple dimensions to obtain a second processing result; determining the diffuse color performance coefficient of the target model based on the first processing result and the second processing result, and adjusting the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with a shadow effect; wherein the color data with a shadow effect is used to control the target model to generate a shadow effect in three-dimensional space.

[0006] Secondly, embodiments of the present invention provide a device for generating model shadow effects. The device includes: a first sampling module, used to perform a first sampling process on the normal map of a target model to obtain a first orientation map in multiple dimensions; the first orientation map includes: normal components in the corresponding dimensional directions; a first processing module, used to perform a first interpolation and mixing process on the first orientation map in multiple dimensions based on the illumination angle components of an ambient light source in multiple dimensions to obtain a first processing result; wherein the ambient light source is located in the three-dimensional space where the target model is located; and a second sampling module, used to perform a biasing process on the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source. The system performs a shifting process and then uses the offset UV coordinate values ​​to perform a second sampling process on the normal map, resulting in a second orientation map in multiple dimensions. A second processing module performs a second interpolation and blending process on the first and second orientation maps based on the illumination angle components in multiple dimensions, resulting in a second processing result. A color data processing module determines the diffuse color performance coefficient of the target model based on the first and second processing results, and adjusts the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with shadow effects. The color data with shadow effects is used to control the target model to generate shadow effects in three-dimensional space.

[0007] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described method for generating model shadow effects.

[0008] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for generating model shadow effects.

[0009] The embodiments of the present invention bring the following beneficial effects:

[0010] The aforementioned method, apparatus, and electronic device for generating shadow effects of a model perform a first sampling process on the normal map of the target model to obtain a first directional map in multiple dimensions. The first directional map includes normal components in the corresponding dimensional directions. Based on the illumination angle components of the ambient light source in multiple dimensions, the first directional map in multiple dimensions is subjected to a first interpolation and blending process to obtain a first processing result. The ambient light source is located in the three-dimensional space where the target model is situated. Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map is subjected to a second sampling process using the offset UV coordinate values ​​to obtain a second directional map in multiple dimensions. Based on the illumination angle components in multiple dimensions, the first directional map and the second directional map are subjected to a second interpolation and blending process to obtain a second processing result. Based on the first and second processing results, the diffuse color performance coefficient of the target model is determined, and the initial color data of the target model is adjusted based on the diffuse color performance coefficient to obtain color data with shadow effects. The color data with shadow effects is used to control the target model to generate shadow effects in three-dimensional space.

[0011] In the above method, the normal components of the normal map in multiple dimensions are processed by the illumination angle and illumination height of the ambient light source to obtain color performance coefficients. These color performance coefficients are then used to adjust the initial color of the target model, thereby obtaining color data with shadow effects. This allows the target model to produce shadow effects under the influence of ambient light in three-dimensional space, and these shadow effects can change with changes in the ambient light source, resulting in a more realistic appearance. At the same time, this method does not require additional shadow effect maps or multiple iterations of the normal map, resulting in lower rendering computation overhead.

[0012] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0013] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0014] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0015] Figure 1 A flowchart illustrating a method for generating model shadow effects according to an embodiment of the present invention;

[0016] Figure 2 A schematic diagram of a normal map and normal components provided in an embodiment of the present invention;

[0017] Figure 3 A first direction map corresponding to multiple dimensions is provided in an embodiment of the present invention;

[0018] Figure 4 This is a schematic diagram of initial color data and color data with shadow effects provided in an embodiment of the present invention;

[0019] Figure 5 A schematic diagram of a device for generating model shadow effects provided in an embodiment of the present invention;

[0020] Figure 6 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] The terminology used in this embodiment will be described below.

[0023] 1. UV

[0024] UVs are two-dimensional texture coordinates residing on the vertices of a polygon mesh. They define a two-dimensional texture coordinate system called the UV texture space. UVs provide a connection between the model surface and the texture image, and are responsible for determining which vertex on the model surface a point (also called a pixel) in the texture image should be placed on, thus allowing the entire texture to be overlaid onto the model. Without UVs, a polygon mesh cannot be textured.

[0025] In computer graphics, there are two crucial coordinate systems for 3D models: the (X, Y, Z) coordinates of the vertices and the UV coordinates of the texture map. Simply put, the UV coordinates are the basis for mapping textures onto the model's surface. More broadly, they should be (U, V, W) coordinates (to distinguish them from XYZ coordinates). U and V represent the texture map's coordinates in the horizontal and vertical directions of the display, typically ranging from 0 to 1. In other words, they can represent the U-th pixel horizontally (or the image width) and the V-th pixel vertically (or the image height). The W coordinate is perpendicular to the display surface and is commonly used for procedural mapping or specific 3D mapping techniques. However, W is usually not used in games, hence it's often simply referred to as the UV coordinates.

[0026] 2.AO

[0027] AO, also known as Ambient Occlusion, describes the effect of objects blocking diffuse light when they intersect or are close together. It can solve or improve problems such as light leaks, blurry shadows, and unclear shadows. It also addresses issues like unclear depictions of gaps, wrinkles, corners, and small objects in a scene, comprehensively improving details, especially shadows, enhancing the sense of depth and realism in space, and strengthening the contrast between light and dark areas, thus enhancing the artistic quality of the image. The most noticeable effect of AO on players is the difference in brightness; without AO, the lighting is slightly brighter, while with AO enabled, details, especially shadows, become more pronounced.

[0028] During model rendering, normal mapping adds a sense of bump and texture to the model's surface, reducing the need to create numerous uneven surfaces during model production and thus lowering the cost of creating the model on the actual mesh and reducing rendering overhead. However, normal mapping alone only adds a sense of depth and bump; it cannot generate lighting and shadow effects based on this texture. To increase the realism of the rendering, lighting and shadow effects are indispensable. Furthermore, in 3D physics engines, the parts of the model with normal mapping applied do not actually have surface undulations and cannot generate shadow effects based on the model's physical structure.

[0029] Traditional methods for enhancing the self-shadow effect of an object's surface often use an Ambient Occlusion (AO) map, which uses a texture map that records the shadow information of the object's surface position to sample and generate the shadow effect. AO maps often require an additional texture map to be sampled during rendering. When the object's material is complex, the increased number of texture maps leads to additional computational overhead. Moreover, the sampling effect of an AO map is a fixed shadow effect that does not change with the direction of lighting.

[0030] Another approach uses normal maps to generate shadow orientation and detail effects. This technique can generate self-shadows using only normal maps at the texture level, reducing the overall number of sampled textures. However, the original method uses multiple iterative calculation loops, often requiring more than 16 iterations, which puts a certain strain on computational performance.

[0031] Based on the above, embodiments of the present invention provide a method, apparatus, and electronic device for generating model shadow effects. This technology can be applied to the model rendering process, especially to the process of adding light and shadow effects and shadow effects to the model.

[0032] First, see Figure 1 The flowchart shown illustrates a method for generating shadow effects on a model. This method includes the following steps:

[0033] Step S102: Perform a first sampling process on the normal map of the target model to obtain a first orientation map in multiple dimensions; the first orientation map includes: normal components in the corresponding dimension.

[0034] Normal mapping involves creating normals at every point on the uneven surface of a target model, using RGB color channels to indicate the direction of these normals. If the target model has few uneven surfaces, the surface roughness can be increased by adjusting the normal map. Three-dimensional space is typically divided into three dimensions: X, Z, and Y. Each location in the normal map stores the normal components along the X, Y, and Z dimensions, allowing the final normal direction to be calculated.

[0035] Each position in the normal map can be represented by UV coordinates. During the first sampling process described above, each position in the normal map can be sampled one by one using UV coordinates. In actual implementation, multiple dimensional directions can be pre-defined, such as X-axis, Y-axis, and Z-axis, or positive X-axis, negative X-axis, positive Y-axis, negative Y-axis, positive Z-axis, and negative Z-axis. These multiple dimensional directions can include all or some of the aforementioned dimensional directions. For each dimensional direction, the normal map can be sampled once. Taking the positive X-axis as an example, the normal component at each position in the normal map is detected using UV coordinates. If the normal component in the X-axis at that position is positive, then the normal component at that position is sampled.

[0036] After the first sampling process, the above steps can obtain multiple first orientation maps, with each dimension direction corresponding to a first orientation map; taking the positive X dimension direction as an example, the first orientation map corresponding to this dimension direction stores the normal components of the X dimension direction at the positions where the normal components of the X dimension direction are positive.

[0037] Step S104: Based on the illumination angle components of the ambient light source in multiple dimensions, perform a first interpolation and mixing process on the first orientation map in multiple dimensions to obtain a first processing result; wherein, the ambient light source is located in the three-dimensional space where the target model is located.

[0038] In order to realistically display the target model in a 3D space with ambient light, it is usually necessary to render the shadow effect of the target model. Therefore, in this embodiment, when generating the shadow effect of the target model, it is necessary to refer to the lighting parameters of the ambient light source so that the shadow effect of the target model matches the lighting angle, lighting height, etc. of the light source. At the same time, when the ambient light source changes, such as changes in lighting angle or lighting height, the shadow effect of the target model changes accordingly, so that the shadow effect is flexible and varied, and the visuals are more realistic.

[0039] In practical implementation, the illumination angle of the ambient light source can be calculated based on parameters such as its orientation and rotation angle. This illumination angle can then be decomposed into multiple dimensions to obtain illumination angle components in each dimension. It's understood that the larger the illumination angle component of the ambient light source in a certain dimension, the more pronounced the shadow of the target model will be in that dimension. Based on this, the weights of the first orientation map corresponding to each dimension can be determined based on the illumination angle components in multiple dimensions. These weights are then used to perform a first interpolation blending process on the first orientation maps in multiple dimensions. Various interpolation functions can be used to implement this first interpolation blending process, such as spline interpolation, Newton interpolation, and Lagrange polynomial interpolation.

[0040] Step S106: Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map is sampled a second time using the offset UV coordinate values ​​to obtain a second orientation map in multiple dimensions.

[0041] Generally, the higher the ambient light source's illumination height, the smaller the shadow area; conversely, the lower the illumination height, the larger the shadow area. In this step, the ambient light source's illumination height is used to offset the UV coordinate values ​​of the normal map. For a given location in the normal map, the further the offset UV coordinate values ​​are from the original UV coordinate values, the larger the resulting shadow area. Using the illumination height as a parameter for the normal map's UV coordinate values ​​in the above steps yields a more reasonable shadow area. In one implementation, the illumination angle can also be referenced. Weights are determined based on the illumination angle components in each dimension, and the initial coordinates for interpolation blending are determined based on the illumination height, thus obtaining the offset UV coordinate values.

[0042] When performing the second sampling process, the process of the first sampling process described above can be referred to. Since the UV coordinate values ​​have shifted, the second directional pattern obtained by sampling will also be different from the first directional pattern.

[0043] Step S108: Based on the illumination angle components in multiple dimensions, perform a second interpolation and mixing process on the first and second orientation maps to obtain a second processing result;

[0044] Through the above steps, each dimension corresponds to a first orientation map and a second orientation map. The weights of the first orientation map and the second orientation map in each dimension can be determined based on the illumination angle components across multiple dimensions. A second interpolation mixing process is then performed on the first and second orientation maps across multiple dimensions using these weights. Various interpolation functions can be used to implement this second interpolation mixing process, such as spline interpolation, Newton interpolation, and Lagrange polynomial interpolation.

[0045] Step S110: Based on the first processing result and the second processing result, determine the diffuse color performance coefficient of the target model, and adjust the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with shadow effect; wherein, the color data with shadow effect is used to control the target model to generate shadow effect in three-dimensional space.

[0046] For a specific area on the target model, a color texture can be selected for that area using a color map. When a shadow is generated in that area, it may affect parameters such as brightness, clarity, and saturation. In actual implementation, the first and second processing results can be calculated to obtain the diffuse color representation coefficient of the target model. Specifically, the first and second processing results can be weighted, multiplied, or subtracted. This diffuse color representation coefficient adjusts the initial color data of the target model, which can be in the form of a texture or other data formats. The diffuse color representation coefficient can be added to or multiplied by the initial color data to obtain the color data with the shadow effect. When rendering the surface color of the target model using the color data with the shadow effect, this color can exhibit a shadow effect in certain areas.

[0047] The above-mentioned method for generating shadow effects in the model involves: performing a first sampling process on the normal map of the target model to obtain a first directional map in multiple dimensions; the first directional map includes: normal components in the corresponding dimensional directions; performing a first interpolation and blending process on the first directional map in multiple dimensions based on the illumination angle components of the ambient light source in multiple dimensions to obtain a first processing result; wherein, the ambient light source is located in the three-dimensional space where the target model is located; based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map is then subjected to a second sampling process using the offset UV coordinate values ​​to obtain a second directional map in multiple dimensions; performing a second interpolation and blending process on the first directional map and the second directional map based on the illumination angle components in multiple dimensions to obtain a second processing result; based on the first and second processing results, the diffuse color performance coefficient of the target model is determined, and the initial color data of the target model is adjusted based on the diffuse color performance coefficient to obtain color data with shadow effects; wherein, the color data with shadow effects is used to: control the target model to generate shadow effects in three-dimensional space.

[0048] In the above method, the normal components of the normal map in multiple dimensions are processed by the illumination angle and illumination height of the ambient light source to obtain color performance coefficients. These color performance coefficients are then used to adjust the initial color of the target model, thereby obtaining color data with shadow effects. This allows the target model to produce shadow effects under the influence of ambient light in three-dimensional space, and these shadow effects can change with changes in the ambient light source, resulting in a more realistic appearance. At the same time, this method does not require additional shadow effect maps or multiple iterations of the normal map, resulting in lower rendering computation overhead.

[0049] The following examples further illustrate the specific sampling method of the first direction mapping in multiple dimensions.

[0050] In one approach, a normal map of the target model is obtained; wherein the normal map includes at least: normal components in the X-dimensional direction and normal components in the Y-dimensional direction in three-dimensional space; based on the UV coordinate values ​​of the normal map, the normal map is sampled to obtain a first orientation map corresponding to multiple dimensional directions; the multiple dimensional directions include: positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction and negative Y-dimensional direction.

[0051] Typically, a normal map has three channels: RGB. Since three-dimensional space includes three dimensions (X, Y, and Z), each channel in the normal map can store the normal component in one dimension. In this embodiment, the normal components in the X and Y dimensions of the three-dimensional space are needed; these X and Y dimensions form a horizontal plane in the three-dimensional space. The normal component in the X dimension can be stored in the first channel of the normal map, such as the R channel; the normal component in the Y dimension can be stored in the second channel of the normal map, such as the G channel. The first and second channels are usually different; they can be any two of the RGB channels mentioned above.

[0052] Figure 2 As an example, Figure 2 In (a), the map is a normal map, and the graphic in (a) is a bubble graphic; Figure 2 (b) in the diagram represents the normal component in the R channel. This R channel stores the normal component in the X-dimensional direction, which corresponds to the left and right horizontal directions. Observing (b), we can see that the black and white color of the bubble gradually changes from left to right. Figure 2 (c) in the diagram represents the normal component in the G channel. This G channel stores the normal component in the Y-dimensional direction, which corresponds to the vertical direction. Observing (c), we can see that the black and white color of the bubble gradually changes from top to bottom. Figure 2 (d) in the diagram represents the normal component in the B channel. This B channel stores the normal component in the Z-dimensional direction, which corresponds to the direction perpendicular to the paper. Observing (d), we can see that the black and white colors of the bubble gradually change from the center to the surrounding area.

[0053] Based on the XYZ three-dimensional directions in three-dimensional space, this embodiment further divides the dimensional directions, including the positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction, and negative Y-dimensional direction. For each dimensional direction, the normal map is sampled to obtain the first direction map corresponding to that dimensional direction.

[0054] In one specific approach, for the aforementioned positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction, and negative Y-dimensional direction, the first direction map for each direction is obtained through the following methods (01)-(04):

[0055] (01) Based on the UV coordinate values ​​of the normal map, sample the normal components that are greater than zero in the first channel of the normal map to obtain the normal components in the positive X dimension direction, and use the normal components in the positive X dimension direction as the first direction map corresponding to the positive X dimension direction.

[0056] (02) Based on the UV coordinate values ​​of the normal map, sample the normal components that are less than or equal to zero in the first channel of the normal map to obtain the normal components in the negative X dimension direction. Negate the normal components in the negative X dimension direction to obtain the first direction map corresponding to the negative X dimension direction.

[0057] In the first channel, such as the R channel, normal components in the positive X-axis direction and normal components in the negative X-axis direction are usually stored simultaneously. The value range of the normal component in the positive X-axis direction is [0,1]. During sampling, if the normal component in the first channel corresponding to a certain UV coordinate is located in [0,1], it means that the normal component belongs to the normal component in the positive X-axis direction. At this time, the normal component corresponding to the UV coordinate is stored in the first direction pattern corresponding to the positive X-axis direction.

[0058] Typically, the normal component in the negative X-axis direction ranges from -1 to 0. Since negative normal components are displayed as black, their specific values ​​are indistinguishable. To avoid this, during sampling, if the normal component in the first channel corresponding to a certain UV coordinate is in the range of -1 to 0, it indicates that the normal component belongs to the negative X-axis direction. In this case, the normal component corresponding to that UV coordinate is negative, resulting in a positive normal component, which is then stored in the first direction map in the negative X-axis direction.

[0059] (03) Based on the UV coordinate values ​​of the normal map, sample the normal components that are greater than zero in the second channel of the normal map to obtain the normal components in the positive Y dimension direction, and use the normal components in the positive Y dimension direction as the first direction map corresponding to the positive Y dimension direction.

[0060] (04) Based on the UV coordinate values ​​of the normal map, sample the normal components that are less than or equal to zero in the second channel of the normal map to obtain the normal components in the negative Y dimension direction. Negate the normal components in the negative Y dimension direction to obtain the first direction map corresponding to the negative Y dimension direction.

[0061] Similarly, in the second channel, such as the G channel, normal components in the positive Y dimension and the negative Y dimension are usually stored simultaneously. The normal components in the positive Y dimension range from [0,1]. During sampling, if the normal component in the second channel corresponding to a certain UV coordinate is located in [0,1], it means that the normal component belongs to the normal component in the positive Y dimension. At this time, the normal component corresponding to the UV coordinate is stored in the first direction map corresponding to the positive Y dimension.

[0062] Typically, the normal component in the negative Y-axis ranges from -1 to 0. Since negative normal components are displayed as black, their specific values ​​are indistinguishable. To avoid this, during sampling, if the normal component in the second channel corresponding to a certain UV coordinate is in the range of -1 to 0, it indicates that the normal component belongs to the negative Y-axis. In this case, the normal component corresponding to that UV coordinate is negative, resulting in a positive normal component, which is then stored in the first direction map in the negative Y-axis direction.

[0063] Figure 3 As an example, Figure 3 (a) shows the first orientation pattern in the positive X-axis direction. Observing (a), we can see that the positive X-axis direction is located on the right side of each bubble. Therefore, the color value of the area on the right side of the bubble is larger and the brightness is higher. Figure 3 (b) shows the first orientation pattern in the negative Y dimension. Observing (b), it can be seen that the negative Y dimension is located on the bottom side of each bubble. Therefore, the color value of the area on the bottom side of the bubble is larger and the brightness is higher. Figure 3 (c) shows the first orientation pattern in the negative X dimension. Observing (c), we can see that the negative X dimension is located to the left of each bubble. Therefore, the color value of the area to the left of the bubble is larger and the brightness is higher. Figure 3 (d) shows the first orientation pattern in the positive Y dimension. Observing (d), we can see that the positive Y dimension is located on the upper side of each bubble. Therefore, the color value of the upper area of ​​the bubble is larger and the brightness is higher.

[0064] In practice, the normal map can be sampled using the sampling function Sample.

[0065] Normal=Sample(NormalTex,Texcoord)

[0066] Wherein, Normal represents the sampling result of the normal map, i.e., the first direction map mentioned above; NormalTex represents the normal map; Texcoord represents the UV mapping coordinates corresponding to the normal map, i.e., the UV coordinate values ​​mentioned above.

[0067] Before performing the first interpolation and mixing process, it is necessary to determine the illumination angle of the ambient light source.

[0068] Specifically, the illumination angle of the ambient light source is determined based on the rotation value of the ambient light source; wherein, the illumination angle includes: the illumination angle of the ambient light source on the horizontal plane in three-dimensional space; the horizontal plane includes the plane containing the X-dimensional direction and the Y-dimensional direction in three-dimensional space.

[0069] The rotation value of the ambient light source can be obtained from its light source properties. This rotation value can be represented as R=(Rx,Ry,Rz); where Rx represents the rotation angle of the ambient light source around the X-dimensional direction in three-dimensional space; Ry represents the rotation angle of the ambient light source around the Y-dimensional direction in three-dimensional space; and Rz represents the rotation angle of the ambient light source around the Z-dimensional direction in three-dimensional space.

[0070] In actual implementation, a first angle value, rotated around the Z-dimensional direction in three-dimensional space, is extracted from the ambient light source, and the illumination angle of the ambient light source is determined based on the first angle value. Here, the first angle value is equivalent to Rz mentioned above, and the value range of the first angle value can be [-180, 180].

[0071] After obtaining the illumination angle, the illumination angle components in each dimension are needed during the subsequent first interpolation and mixing process. To facilitate subsequent processing, the illumination angle can be calculated using the following formula:

[0072] Angle = (270 - Rz) / 90 - 1;

[0073] Where Angle represents the illumination angle and Rz represents the first angle value.

[0074] In the above formula, the illumination angle is mapped to the numerical range [0,4] based on the four dimensions: positive X-axis, negative X-axis, positive Y-axis, and negative Y-axis. Specifically, when Rz = 180 degrees, Angle = 0, corresponding to the positive X-axis; when Rz = 90 degrees, Angle = 1, corresponding to the negative X-axis; when Rz = 0 degrees, Angle = 2, corresponding to the negative X-axis; when Rz = -90 degrees, Angle = 3, corresponding to the positive Y-axis; when Rz = -180 degrees, Angle = 4; Rz = 180 and Rz = -180 degrees coincide in direction.

[0075] Based on the above, the first interpolation and mixing process is performed on the first orientation map in multiple dimensions to obtain the first processing result, which can be achieved in the following ways (11)-(14):

[0076] (11) Using the illumination angle component of the ambient light source in the positive X-dimensional direction as the interpolation weight, perform the first interpolation mixing process on the first orientation pattern corresponding to the positive X-dimensional direction and the first orientation pattern corresponding to the positive Y-dimensional direction to obtain the first intermediate result;

[0077] In this embodiment, the Lerp function is used as the interpolation function for illustration. The first intermediate result L1 mentioned above can be achieved by the following formula:

[0078] L1= Lerp(Normal.r,Normal.g,clamp(Angle))

[0079] = Normal.r+(Normal.g- Normal.r) clamp(Angle);

[0080] Where Normal.r represents the first orientation pattern corresponding to the positive X-axis, and Normal.g represents the first orientation pattern corresponding to the positive Y-axis; clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle) is within the range [0,1], i.e., 90-180 degrees. Therefore, clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction.

[0081] (12) The illumination angle component of the ambient light source in the negative Y dimension direction is used as the interpolation weight to perform the first interpolation mixing process on the first intermediate result and the first direction pattern corresponding to the negative X dimension direction to obtain the second intermediate result;

[0082] The second intermediate result L2 mentioned above can be achieved using the following formula:

[0083] L2= Lerp(L1,-Normal.r,clamp(Angle-1))

[0084] =L1+(-Normal.r-L1) clamp(Angle-1);

[0085] Where L1 represents the first intermediate result mentioned above, -Normal.r represents the first orientation pattern corresponding to the negative X-dimensional direction, and clamp(Angle-1) represents the illumination angle component of the ambient light source in the negative Y-dimensional direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle-1) is within the range [1,2], i.e., 0-90 degrees. Therefore, clamp(Angle-1) is the illumination angle component of the ambient light source in the negative Y-dimensional direction.

[0086] (13) The illumination angle component of the ambient light source in the negative X dimension direction is used as the interpolation weight to perform the first interpolation mixing process on the second intermediate result and the first orientation pattern corresponding to the negative Y dimension direction to obtain the third intermediate result;

[0087] The aforementioned third intermediate result L3 can be achieved using the following formula:

[0088] L3= Lerp(L2,-Normal.g,clamp(Angle-2))

[0089] =L2 + (-Normal.g –L2) clamp(Angle-2);

[0090] Where L2 represents the second intermediate result mentioned above, -Normal.g represents the first orientation pattern corresponding to the negative Y-axis direction, and clamp(Angle-2) represents the illumination angle component of the ambient light source in the negative X-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle-2) is within the range [2,3], i.e., -90 to 0 degrees. Therefore, clamp(Angle-2) is the illumination angle component of the ambient light source in the negative X-axis direction.

[0091] (14) The illumination angle component of the ambient light source in the positive Y dimension direction is used as the interpolation weight to perform the first interpolation mixing process on the third intermediate result and the first direction map corresponding to the positive X dimension direction to obtain the first processing result.

[0092] The first processing result, AngleNormal, can be achieved using the following formula:

[0093] AngleNormal=Lerp(L3,Normal.r,clamp(Angle-3))

[0094] =L3+(Normal.r–L3) clamp(Angle-3);

[0095] Where L3 represents the third intermediate result mentioned above, Normal.r represents the first orientation pattern corresponding to the positive X-axis direction, and clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle-3) is within the range [3,4], i.e., -180 to 90 degrees. Therefore, clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction.

[0096] In summary, the first processing result, AngleNormal, can be calculated using the following formula:

[0097] AngleNormal=Lerp(Lerp(Lerp(Lerp(Normal.r,Normal.g,clamp(Angle)), -Normal.r, clamp(Angle-1)), -Normal.g, clamp(Angle-2)), Normal.r, clamp(Angle-3)).

[0098] Furthermore, the UV coordinate values ​​of the normal map need to be offset. Before that, the lighting angle of the ambient light source needs to be obtained.

[0099] Specifically, a second angle value, representing the rotation of the ambient light source around the X-axis in three-dimensional space, is extracted from the ambient light source. The illumination height of the ambient light source is then determined based on this second angle value. The second angle value can be Rx from the aforementioned rotation value, representing the angle by which the ambient light source rotates around the X-axis in three-dimensional space. The illumination height (Height) can be calculated using the following formula:

[0100] Height = Rx / 30

[0101] Where Rx represents the second angle value of rotation around the X-dimensional direction in three-dimensional space, and the value range can be [0, 360].

[0102] When offsetting the UV coordinate values ​​of a normal map based on the ambient light's illumination height, the height offset value corresponding to the illumination height must first be determined based on a preset minimum offset value. Then, based on the illumination angle components of the ambient light in multiple dimensions, a third interpolation and blending process is performed on the height offset value to obtain the UV coordinate offset values ​​of the normal map. During the coordinate offset process, not only the illumination height but also the illumination angle components of the ambient light in multiple dimensions must be considered.

[0103] The height offset value Bias mentioned above can be calculated using the following formula:

[0104] Bias=clamp((1-Height) / (1 / minbias)+minbias)

[0105] Here, Height represents the lighting height, and minbias represents the minimum offset value. This minimum offset value can be preset and is usually set to a small value, such as 0.0001, so as to ensure that the edges of the shadows are relatively smooth.

[0106] The following describes the specific implementation methods of UV coordinate offset, including the following methods (21)-(24):

[0107] (21) The illumination angle component of the ambient light source in the positive X-dimensional direction is used as the interpolation weight to perform a third interpolation mixing process on the first coordinate value and the second coordinate value to obtain the first intermediate coordinate; wherein, the X value of the first coordinate value is the height offset value; and the Y value of the second coordinate value is the negative value of the height offset value.

[0108] Specifically, the first intermediate coordinates (X1, Y1) can be calculated using the following formula:

[0109] (X1,Y1)=Lerp((Bias,0),(0,-Bias),clamp(Angle))

[0110] =(Bias,0)+((0,-Bias)- (Bias,0)) clamp(Angle);

[0111] Where (Bias,0) represents the first coordinate value, with a Y value of 0; (0,-Bias) represents the second coordinate value, with an X value of 0; and clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, it takes the value 0; when the target value is greater than 1, it takes the value 1. Therefore, the illumination angle corresponding to clamp(Angle) is within the range [0,1], i.e., 90-180 degrees. In other words, clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction.

[0112] (22) The illumination angle component of the ambient light source in the negative Y dimension direction is used as the interpolation weight to perform a third interpolation mixing process on the first intermediate coordinate and the third coordinate value to obtain the second intermediate coordinate; wherein, the X value of the third coordinate value is the negative value of the height offset value;

[0113] Specifically, the second intermediate coordinate (X2, Y2) can be calculated using the following formula:

[0114] (X2,Y2)=Lerp((X1,Y1),(-Bias,0),clamp(Angle-1))

[0115] =(X1,Y1)+((-Bias,0)-(X1,Y1)) clamp(Angle-1);

[0116] Where (X1,Y1) represents the first intermediate coordinate; (-Bias,0) represents the third coordinate value, with the Y value of the third coordinate value being 0; and clamp(Angle-1) represents the illumination angle component of the ambient light source in the negative Y-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. Therefore, the illumination angle corresponding to clamp(Angle-1) is within the range [1,2], i.e., 0-90 degrees. In other words, clamp(Angle-1) is the illumination angle component of the ambient light source in the negative Y-axis direction.

[0117] (23) The illumination angle component of the ambient light source in the negative X dimension direction is used as the interpolation weight to perform a third interpolation mixing process on the second intermediate coordinate and the fourth coordinate value to obtain the third intermediate coordinate; where the Y value of the fourth coordinate value is the height offset value.

[0118] Specifically, the third intermediate coordinate (X3, Y3) can be calculated using the following formula:

[0119] (X3,Y3)=Lerp((X2,Y2),(0,Bias),clamp(Angle-2))

[0120] =(X2,Y2)+((0,Bias)-(X2,Y2)) clamp(Angle-2);

[0121] Where (X2, Y2) represents the second intermediate coordinate; (0, Bias) represents the fourth coordinate value, with the X value of the fourth coordinate value being 0; and clamp(Angle-2) represents the illumination angle component of the ambient light source in the negative X-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0, 1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. Therefore, the illumination angle corresponding to clamp(Angle-2) is within the range [2, 3], i.e., -90 to 0 degrees. Thus, clamp(Angle-2) represents the illumination angle component of the ambient light source in the negative X-axis direction.

[0122] (24) The illumination angle component of the ambient light source in the positive Y dimension direction is used as the interpolation weight. The third intermediate coordinate and the first coordinate value are subjected to third interpolation mixing to obtain the UV coordinate offset value of the normal map.

[0123] Specifically, the UV coordinate offset value UVBias can be calculated using the following formula:

[0124] UVBias =Lerp((X3,Y3),(Bias,0),clamp(Angle-3))

[0125] =(X3,Y3)+((Bias,0)-(X3,Y3)) clamp(Angle-3);

[0126] Where (X3,Y3) represents the third intermediate coordinate; (Bias,0) represents the first coordinate value mentioned above, with the Y value of the first coordinate value being 0; and clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. Therefore, the illumination angle corresponding to clamp(Angle-3) is within the range [3,4], i.e., -180 to 90 degrees. In other words, clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction.

[0127] The aforementioned UV coordinate offset values, i.e., the offset UV coordinate values, are used to sample the normal map again, resulting in a second direction map in multiple dimensions. In practical implementation, the Sample function can be used to sample the normal map, as shown below:

[0128] NormalBias=Sample(NormalTex,UVBias)

[0129] Wherein, NormalBias represents the second orientation map; NormalTex represents the normal map; and UVBias represents the UV coordinate offset value mentioned above. The process of sampling the normal map using the UV coordinate offset value is described as follows (31)-(34):

[0130] (31) Based on the UV coordinate offset value of the normal map, sample the normal components that are greater than zero in the first channel of the normal map to obtain the normal components in the positive X dimension direction, and use the normal components in the positive X dimension direction as the second direction map corresponding to the positive X dimension direction.

[0131] (32) Based on the UV coordinate offset value of the normal map, sample the normal components that are less than or equal to zero in the first channel of the normal map to obtain the normal components in the negative X dimension direction. Negate the normal components in the negative X dimension direction to obtain the second direction map corresponding to the negative X dimension direction.

[0132] In the first channel, such as the R channel, normal components in the positive X-axis direction and normal components in the negative X-axis direction are usually stored simultaneously. The value range of the normal component in the positive X-axis direction is [0,1]. During sampling, if the normal component in the first channel corresponding to a certain UV coordinate is located in [0,1], it means that the normal component belongs to the normal component in the positive X-axis direction. At this time, the normal component corresponding to the UV coordinate is stored in the second direction pattern corresponding to the positive X-axis direction.

[0133] Typically, the normal component in the negative X-axis direction ranges from -1 to 0. Since negative normal components are displayed as black, their specific values ​​are indistinguishable. To avoid this, during sampling, if the normal component in the first channel corresponding to a certain UV coordinate is in the range of -1 to 0, it indicates that the normal component belongs to the negative X-axis direction. In this case, the normal component corresponding to that UV coordinate is negative, resulting in a positive normal component, which is then stored in the second direction map in the negative X-axis direction.

[0134] (33) Based on the UV coordinate offset value of the normal map, sample the normal components that are greater than zero in the second channel of the normal map to obtain the normal components in the positive Y dimension direction, and use the normal components in the positive Y dimension direction as the second direction map corresponding to the positive Y dimension direction.

[0135] (34) Based on the UV coordinate offset value of the normal map, sample the normal components that are less than or equal to zero in the second channel of the normal map to obtain the normal components in the negative Y dimension direction. Then, process the negative normal components in the negative Y dimension direction to obtain the second direction map corresponding to the negative Y dimension direction.

[0136] Similarly, in the second channel, such as the G channel, normal components in the positive Y-axis direction and normal components in the negative Y-axis direction are usually stored simultaneously. The normal components in the positive Y-axis direction have a value range of [0,1]. During sampling, if the normal component in the second channel corresponding to a certain UV coordinate is located in [0,1], it means that the normal component belongs to the normal component in the positive Y-axis direction. At this time, the normal component corresponding to the UV coordinate is stored in the second direction map corresponding to the positive Y-axis direction.

[0137] Typically, the normal component in the negative Y-axis ranges from -1 to 0. Since negative normal components are displayed as black, their specific values ​​are indistinguishable. To avoid this, during sampling, if the normal component in the second channel corresponding to a certain UV coordinate is in the range of -1 to 0, it indicates that the normal component belongs to the negative Y-axis. In this case, the normal component corresponding to that UV coordinate is negative, resulting in a positive normal component, which is then stored in the second direction map in the negative Y-axis direction.

[0138] After obtaining the first and second orientation patterns, a second interpolation and mixing process needs to be performed on the two orientation patterns to obtain the second processing result. Specifically, the second processing result can be obtained through the following methods (41)-(45):

[0139] (41) Using the illumination angle component of the ambient light source in the positive X-dimensional direction as the interpolation weight, perform a second interpolation mixing process on the second orientation pattern corresponding to the positive X-dimensional direction and the first orientation pattern corresponding to the positive Y-dimensional direction to obtain the first interpolation result;

[0140] In this embodiment, the Lerp function is used as the interpolation function for illustration. The first interpolation result S1 described above can be achieved by the following formula:

[0141] S1= Lerp(NormalBias.r,Normal.g,clamp(Angle))

[0142] = NormalBias.r + (Normal.g - NormalBias.r) clamp(Angle);

[0143] Here, NormalBias.r represents the second orientation pattern corresponding to the positive X-axis, and Normal.g represents the first orientation pattern corresponding to the positive Y-axis. clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction. Angle is the illumination angle of the ambient light source. The clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. Therefore, the illumination angle corresponding to clamp(Angle) is within the range [0,1], i.e., 90-180 degrees. In other words, clamp(Angle) represents the illumination angle component of the ambient light source in the positive X-axis direction.

[0144] (42) Using the illumination angle component of the ambient light source in the negative Y dimension as the interpolation weight, perform a second interpolation mixing process on the first interpolation result and the second orientation pattern corresponding to the negative X dimension to obtain the second interpolation result;

[0145] The second interpolation result S2 mentioned above can be achieved by the following formula:

[0146] S2= Lerp(S1, -NormaBiasl.r, clamp(Angle-1))

[0147] = S1 + (-NormaBiasl.r - S1) clamp(Angle-1);

[0148] Where S1 represents the first interpolation result, -NormaBiasl.r represents the second orientation pattern corresponding to the negative X-dimensional direction, and clamp(Angle-1) represents the illumination angle component of the ambient light source in the negative Y-dimensional direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle-1) is within the range [1,2], i.e., 0-90 degrees. Therefore, clamp(Angle-1) is the illumination angle component of the ambient light source in the negative Y-dimensional direction.

[0149] (43) Using the illumination angle component of the ambient light source in the negative X dimension as the interpolation weight, perform a second interpolation mixing process on the second interpolation result and the second orientation pattern corresponding to the negative Y dimension to obtain the third interpolation result;

[0150] The third interpolation result S3 mentioned above can be achieved by the following formula:

[0151] S3= Lerp(S2,-NormalBias.g,clamp(Angle-2))

[0152] =S2+(-NormalBias.g–S2) clamp(Angle-2);

[0153] Where S2 represents the second interpolation result, -NormalBias.g represents the second orientation pattern corresponding to the negative Y-axis direction, and clamp(Angle-2) represents the illumination angle component of the ambient light source in the negative X-axis direction. Here, Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. In this case, the illumination angle corresponding to clamp(Angle-2) is within the range [2,3], i.e., -90 to 0 degrees. Therefore, clamp(Angle-2) represents the illumination angle component of the ambient light source in the negative X-axis direction.

[0154] (44) Using the illumination angle component of the ambient light source in the positive Y dimension as the interpolation weight, perform a second interpolation mixing process on the third interpolation result and the second orientation pattern corresponding to the positive X dimension to obtain the fourth interpolation result.

[0155] The fourth interpolation result S4 mentioned above can be achieved by the following formula:

[0156] S4=Lerp(S3,NormalBias.r,clamp(Angle-3))

[0157] =S3+(NormalBias.r–S3) clamp(Angle-3);

[0158] Here, S3 represents the third interpolation result, NormalBias.r represents the second orientation pattern corresponding to the positive X-axis direction, and clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction. Angle is the illumination angle of the ambient light source; the clamp function is used to limit the target value within the brackets to the range [0,1]. When the target value is less than 0, the value is 0; when the target value is greater than 1, the value is 1. Therefore, the illumination angle corresponding to clamp(Angle-3) is within the range [3,4], i.e., -180 to 90 degrees. Thus, clamp(Angle-3) represents the illumination angle component of the ambient light source in the positive Y-axis direction.

[0159] (45) Perform an up-rounding operation on the fourth interpolation result to obtain the rounded result, and add a specified value to the negative value of the rounded result to obtain the second processing result.

[0160] The second processing result, ShadowNormal, can be achieved using the following formula:

[0161] ShadowNormal=1-Ceil(S4);

[0162] Where Ceil represents the round-up operation; S4 represents the fourth interpolation result; and the specified value in this formula is 1.

[0163] In summary, the second processing result, ShadowNormal, can be calculated using the following formula:

[0164] ShadowNormal=1-Ceil(Lerp(Lerp(Lerp(Lerp(NormalBias.r,Normal.g,clamp(Angle)),-NormaBiasl.r,clamp(Angle-1)),-NormalBias.g,clamp(Angle-2)),NormalBias.r,clamp(Angle-3))).

[0165] Furthermore, the difference between the first processing result and the second processing result is calculated, and the difference is determined as the diffuse color performance coefficient of the target model; the product of the diffuse color performance coefficient and the initial color data of the target model is determined as the color data with shadow effect.

[0166] The first processing result mentioned above is also called the normal sampling result of the lighting direction, and the second processing result mentioned above is also called the shadow normal sampling result. By subtracting the normal sampling result of the lighting direction from the shadow normal sampling result, the diffuse color representation coefficient can be obtained. This coefficient, applied to the diffuse color, can achieve the effect of shadow direction and shadow detail in the normal map, as shown in the following formula:

[0167] BaseColor=OriginBase (AngleNormal-ShadowNormal)

[0168] Where BaseColor represents color data with a shadow effect; OriginBase represents the initial color data of the target model; AngleNormal represents the first processing result; and ShadowNormal represents the second processing result.

[0169] Figure 4 As an example, where, Figure 4 In the diagram, (a) represents the initial color data of the target model, and (b) represents the color data with shadow effects. Comparing (a) and (b), it can be seen that after adding the effects, the surface details of the model are clearer and have a more three-dimensional effect.

[0170] In this embodiment, the method described above can calculate the object's shadow details using only the normal map, reducing the performance overhead of sampling multiple maps. Compared to existing techniques for adding image shadow details using normal maps, this method reduces the number of computation iterations and lowers performance pressure. It has significant application value for generating self-shadow effects for a large number of fixed objects in a scene during rendering.

[0171] For ease of comparison, the following is a solution from related technologies for generating shadow effects on normal maps, described as follows:

[0172] A normal map offset limit is set. Based on the lighting direction and the number of samples, the normal map is offset once during each sampling process, and the shadow area is calculated once. The shadow areas calculated multiple times are added together to obtain the final shadow area. Finally, the shadow direction and shadow detail effects are generated by obtaining the normal map using the same method. The formula for calculating the normal offset is as follows:

[0173] Shadowed=Sample(NormalTex,UV.xy+lightdir BiasScale

[0174] Where lightdir represents the lighting direction, and BiasScale represents the amount by which the normal map needs to be offset along the lighting direction. Therefore, the formula for calculating the shadow area is as follows:

[0175] Shadow=0

[0176] While (BiasScale) <MaxScale)

[0177] {

[0178] Shadowed=Sample(NormalTex, UV.xy+lightdir BiasScale

[0179] Shadow += Shadowed

[0180] BiasScale += 1 / SampleCount

[0181] }

[0182] Here, Shadow represents the shadow area after normal offset, SampleCount represents the number of samples, and MaxScale represents the maximum offset limit. When the normal offset is less than the maximum offset, normal map offset is performed to calculate the current shadow area. The current offset value is then increased according to the number of samples. The shadow areas obtained in each step are then superimposed, and the final shadow area is obtained based on the number of samples. This process calculates the final normal map shadow effect.

[0183] This method produces jagged edge shadows when the number of samples is small, and can obtain smooth edges when the number of samples is large. However, the system performance will also increase as the number of samples increases. Therefore, this embodiment uses the method described above to create a performance-optimized solution that increases the direction and detail of image shadows based on the normal map.

[0184] For the corresponding method embodiments described above, see [link to relevant documentation]. Figure 5 The diagram shows a structural schematic of a device for generating model shadow effects. The device includes:

[0185] The first sampling module 50 is used to perform a first sampling process on the normal map of the target model to obtain a first orientation map in multiple dimensions; the first orientation map includes: normal components in the corresponding dimension direction;

[0186] The first processing module 52 is used to perform a first interpolation and mixing process on a first orientation map in multiple dimensions based on the illumination angle components of the ambient light source in multiple dimensions, to obtain a first processing result; wherein the ambient light source is located in the three-dimensional space where the target model is located.

[0187] The second sampling module 54 is used to offset the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source, and to perform a second sampling process on the normal map using the offset UV coordinate values ​​to obtain a second direction map in multiple dimensions.

[0188] The second processing module 56 is used to perform a second interpolation and mixing process on the first and second orientation maps based on the illumination angle components in multiple dimensions to obtain a second processing result.

[0189] The color data processing module 60 is used to determine the diffuse color performance coefficient of the target model based on the first processing result and the second processing result, and adjust the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with shadow effect; wherein, the color data with shadow effect is used to control the target model to generate shadow effect in three-dimensional space.

[0190] The aforementioned device for generating shadow effects on a model performs a first sampling process on the normal map of the target model to obtain a first directional map in multiple dimensions. The first directional map includes normal components in the corresponding dimensional directions. Based on the illumination angle components of the ambient light source in multiple dimensions, the first directional map in multiple dimensions is subjected to a first interpolation and blending process to obtain a first processing result. The ambient light source is located in the three-dimensional space where the target model is situated. Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map is subjected to a second sampling process using the offset UV coordinate values ​​to obtain a second directional map in multiple dimensions. Based on the illumination angle components in multiple dimensions, the first directional map and the second directional map are subjected to a second interpolation and blending process to obtain a second processing result. Based on the first and second processing results, the diffuse color performance coefficient of the target model is determined, and the initial color data of the target model is adjusted based on the diffuse color performance coefficient to obtain color data with shadow effects. The color data with shadow effects is used to control the target model to generate shadow effects in three-dimensional space.

[0191] In the above method, the normal components of the normal map in multiple dimensions are processed by the illumination angle and illumination height of the ambient light source to obtain color performance coefficients. These color performance coefficients are then used to adjust the initial color of the target model, thereby obtaining color data with shadow effects. This allows the target model to produce shadow effects under the influence of ambient light in three-dimensional space, and these shadow effects can change with changes in the ambient light source, resulting in a more realistic appearance. At the same time, this method does not require additional shadow effect maps or multiple iterations of the normal map, resulting in lower rendering computation overhead.

[0192] The aforementioned first sampling module is further configured to: acquire the normal map of the target model; wherein the normal map includes at least: normal components in the X-dimensional direction and normal components in the Y-dimensional direction in three-dimensional space; based on the UV coordinate values ​​of the normal map, perform sampling processing on the normal map to obtain a first direction map corresponding to multiple dimensional directions; the multiple dimensional directions include: positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction and negative Y-dimensional direction.

[0193] The normal components in the X-axis direction are stored in the first channel of the normal map; the normal components in the Y-axis direction are stored in the second channel of the normal map; the first sampling module is further configured to: sample normal components greater than zero in the first channel of the normal map based on the UV coordinate values ​​of the normal map, to obtain the normal components in the positive X-axis direction, and use the normal components in the positive X-axis direction as the first direction map corresponding to the positive X-axis direction; sample normal components less than or equal to zero in the first channel of the normal map based on the UV coordinate values ​​of the normal map, to obtain the normal components in the negative X-axis direction, and use the negative normal components as the first direction map corresponding to the positive X-axis direction; and sample normal components less than or equal to zero in the first channel of the normal map based on the UV coordinate values ​​of the normal map, to obtain the normal components in the negative X-axis direction, and use the negative normal components as the first direction map corresponding to the positive X-axis direction. The normal components in the X-axis direction are negatively processed to obtain the first orientation map corresponding to the negative X-axis direction. Based on the UV coordinate values ​​of the normal map, the normal components greater than zero are sampled in the second channel of the normal map to obtain the normal components in the positive Y-axis direction, and the normal components in the positive Y-axis direction are used as the first orientation map corresponding to the positive Y-axis direction. Based on the UV coordinate values ​​of the normal map, the normal components less than or equal to zero are sampled in the second channel of the normal map to obtain the normal components in the negative Y-axis direction, and the normal components in the negative Y-axis direction are negatively processed to obtain the first orientation map corresponding to the negative Y-axis direction.

[0194] The aforementioned device also includes an angle determination module, used to: determine the illumination angle of the ambient light source based on the rotation value of the ambient light source; wherein, the illumination angle includes: the illumination angle of the ambient light source on the horizontal plane in three-dimensional space; the horizontal plane includes the plane containing the X-dimensional direction and the Y-dimensional direction in three-dimensional space.

[0195] The aforementioned angle determination module is also used to: extract a first angle value from the ambient light source, rotating around the Z-dimensional direction in three-dimensional space, and determine the illumination angle of the ambient light source based on the first angle value.

[0196] The aforementioned first processing module is further configured to: use the illumination angle component of the ambient light source in the positive X-dimensional direction as interpolation weights to perform a first interpolation mixing process on the first orientation pattern corresponding to the positive X-dimensional direction and the first orientation pattern corresponding to the positive Y-dimensional direction to obtain a first intermediate result; use the illumination angle component of the ambient light source in the negative Y-dimensional direction as interpolation weights to perform a first interpolation mixing process on the first intermediate result and the first orientation pattern corresponding to the negative X-dimensional direction to obtain a second intermediate result; use the illumination angle component of the ambient light source in the negative X-dimensional direction as interpolation weights to perform a first interpolation mixing process on the second intermediate result and the first orientation pattern corresponding to the negative Y-dimensional direction to obtain a third intermediate result; and use the illumination angle component of the ambient light source in the positive Y-dimensional direction as interpolation weights to perform a first interpolation mixing process on the third intermediate result and the first orientation pattern corresponding to the positive X-dimensional direction to obtain a first processing result.

[0197] The aforementioned device also includes a height determination module, used to: extract a second angle value from the ambient light source, rotating around the X-dimensional direction in three-dimensional space, and determine the illumination height of the ambient light source based on the second angle value.

[0198] The second sampling module is also used to: determine the height offset value corresponding to the illumination height based on the preset minimum offset value; and perform a third interpolation and mixing process on the height offset value based on the illumination angle components of the ambient light source in multiple dimensions to obtain the UV coordinate offset value of the normal map.

[0199] The second sampling module is further configured to: use the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weight to perform a third interpolation mixing process on the first coordinate value and the second coordinate value to obtain a first intermediate coordinate; wherein, the X value of the first coordinate value is the height offset value; and the Y value of the second coordinate value is the negative value of the height offset value; use the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weight to perform a third interpolation mixing process on the first intermediate coordinate and the third coordinate value to obtain a second intermediate coordinate; wherein, the X value of the third coordinate value is the negative value of the height offset value; use the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weight to perform a third interpolation mixing process on the second intermediate coordinate and the fourth coordinate value to obtain a third intermediate coordinate; wherein, the Y value of the fourth coordinate value is the height offset value; and use the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weight to perform a third interpolation mixing process on the third intermediate coordinate and the first coordinate value to obtain the UV coordinate offset value of the UV coordinate value of the normal map.

[0200] The second processing module described above is further configured to: use the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weights to perform a second interpolation mixing process on the second orientation pattern corresponding to the positive X-axis direction and the first orientation pattern corresponding to the positive Y-axis direction to obtain a first interpolation result; use the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weights to perform a second interpolation mixing process on the first interpolation result and the second orientation pattern corresponding to the negative X-axis direction to obtain a second interpolation result; use the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weights to perform a second interpolation mixing process on the second interpolation result and the second orientation pattern corresponding to the negative Y-axis direction to obtain a third interpolation result; use the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weights to perform a second interpolation mixing process on the third interpolation result and the second orientation pattern corresponding to the positive X-axis direction to obtain a fourth interpolation result; perform an up-rounding operation on the fourth interpolation result to obtain a rounded result; and add a specified value to the negative value of the rounded result to obtain a second processing result.

[0201] The aforementioned color data processing module is also used to: calculate the difference between the first processing result and the second processing result, and determine the difference as the diffuse color performance coefficient of the target model; and determine the color data with shadow effect by multiplying the diffuse color performance coefficient with the initial color data of the target model.

[0202] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the above-described method for generating model shadow effects. This electronic device can be a server or a touch terminal device.

[0203] See Figure 6 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for generating model shadow effects.

[0204] Furthermore, Figure 6 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.

[0205] The memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0206] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0207] The processor in the aforementioned electronic device, by executing machine-executable instructions, can perform the following operations in the method for generating the shadow effect of the aforementioned model:

[0208] The normal map of the target model undergoes a first sampling process to obtain a first orientation map in multiple dimensions. This first orientation map includes normal components in the corresponding dimensional directions. Based on the illumination angle components of the ambient light source in multiple dimensions, the first orientation map in multiple dimensions undergoes a first interpolation and blending process to obtain a first processing result. The ambient light source is located in the 3D space where the target model is situated. Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map undergoes a second sampling process using the offset UV coordinate values ​​to obtain a second orientation map in multiple dimensions. Based on the illumination angle components in multiple dimensions, the first and second orientation maps undergo a second interpolation and blending process to obtain a second processing result. Based on the first and second processing results, the diffuse color performance coefficient of the target model is determined. Based on the diffuse color performance coefficient, the initial color data of the target model is adjusted to obtain color data with a shadow effect. This color data with a shadow effect is used to control the shadow effect generated by the target model in 3D space.

[0209] Obtain the normal map of the target model; wherein the normal map includes at least: normal components in the X-dimensional direction and normal components in the Y-dimensional direction in 3D space; based on the UV coordinate values ​​of the normal map, sample the normal map to obtain a first direction map corresponding to multiple dimensional directions; the multiple dimensional directions include: positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction and negative Y-dimensional direction.

[0210] The normal components in the X-axis direction are stored in the first channel of the normal map; the normal components in the Y-axis direction are stored in the second channel of the normal map; based on the UV coordinate values ​​of the normal map, the normal components greater than zero are sampled in the first channel of the normal map to obtain the normal components in the positive X-axis direction, and these normal components are used as the first direction map corresponding to the positive X-axis direction; based on the UV coordinate values ​​of the normal map, the normal components less than or equal to zero are sampled in the first channel of the normal map to obtain the normal components in the negative X-axis direction, and these normal components are used as the first direction map corresponding to the positive X-axis direction. Linear components are negativeized to obtain the first orientation map corresponding to the negative X-dimensional direction. Based on the UV coordinate values ​​of the normal map, normal components greater than zero are sampled in the second channel of the normal map to obtain the normal components in the positive Y-dimensional direction, which are then used as the first orientation map corresponding to the positive Y-dimensional direction. Based on the UV coordinate values ​​of the normal map, normal components less than or equal to zero are sampled in the second channel of the normal map to obtain the normal components in the negative Y-dimensional direction, which are then negativeized to obtain the first orientation map corresponding to the negative Y-dimensional direction.

[0211] Based on the rotation value of the ambient light source, the illumination angle of the ambient light source is determined; wherein, the illumination angle includes: the illumination angle of the ambient light source on the horizontal plane in three-dimensional space; the horizontal plane includes the plane containing the X-dimensional direction and the Y-dimensional direction in three-dimensional space.

[0212] Extract the first angle value of the ambient light source by rotating around the Z-dimensional direction in three-dimensional space, and determine the illumination angle of the ambient light source based on the first angle value.

[0213] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weights, a first interpolation mixing process is performed on the first directional pattern corresponding to the positive X-axis direction and the first directional pattern corresponding to the positive Y-axis direction to obtain a first intermediate result. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weights, a first interpolation mixing process is performed on the first intermediate result and the first directional pattern corresponding to the negative X-axis direction to obtain a second intermediate result. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weights, a first interpolation mixing process is performed on the second intermediate result and the first directional pattern corresponding to the negative Y-axis direction to obtain a third intermediate result. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weights, a first interpolation mixing process is performed on the third intermediate result and the first directional pattern corresponding to the positive X-axis direction to obtain a first processed result.

[0214] Extract the second angle value of the ambient light source by rotating it around the X-dimensional direction in three-dimensional space, and determine the illumination height of the ambient light source based on the second angle value.

[0215] Based on the preset minimum offset value, the height offset value corresponding to the illumination height is determined; based on the illumination angle components of the ambient light source in multiple dimensions, the height offset value is subjected to a third interpolation and mixing process to obtain the UV coordinate offset value of the normal map's UV coordinate value.

[0216] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weight, a third interpolation blending process is performed on the first and second coordinate values ​​to obtain the first intermediate coordinates; where the X-value of the first coordinate value is the height offset value; and the Y-value of the second coordinate value is the negative value of the height offset value. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weight, a third interpolation blending process is performed on the first and third intermediate coordinates to obtain the second intermediate coordinates; where the X-value of the third coordinate value is the negative value of the height offset value. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weight, a third interpolation blending process is performed on the second and fourth intermediate coordinates to obtain the third intermediate coordinates; where the Y-value of the fourth coordinate value is the height offset value. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weight, a third interpolation blending process is performed on the third intermediate coordinates and the first coordinate value to obtain the UV coordinate offset value of the normal map's UV coordinates.

[0217] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weights, a second interpolation blending process is performed on the second directional pattern corresponding to the positive X-axis direction and the first directional pattern corresponding to the positive Y-axis direction to obtain a first interpolation result. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weights, a second interpolation blending process is performed on the first interpolation result and the second directional pattern corresponding to the negative X-axis direction to obtain a second interpolation result. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weights, a second interpolation blending process is performed on the second interpolation result and the second directional pattern corresponding to the negative Y-axis direction to obtain a third interpolation result. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weights, a second interpolation blending process is performed on the third interpolation result and the second directional pattern corresponding to the positive X-axis direction to obtain a fourth interpolation result. The fourth interpolation result is then rounded up to obtain a rounded result. A specified value is added to the negative value of the rounded result to obtain a second processing result.

[0218] Calculate the difference between the first processing result and the second processing result, and determine the difference as the diffuse color performance coefficient of the target model; multiply the diffuse color performance coefficient by the initial color data of the target model to determine the color data with shadow effect.

[0219] In the above method, the normal components of the normal map in multiple dimensions are processed by the illumination angle and illumination height of the ambient light source to obtain color performance coefficients. These color performance coefficients are then used to adjust the initial color of the target model, thereby obtaining color data with shadow effects. This allows the target model to produce shadow effects under the influence of ambient light in three-dimensional space, and these shadow effects can change with changes in the ambient light source, resulting in a more realistic appearance. At the same time, this method does not require additional shadow effect maps or multiple iterations of the normal map, resulting in lower rendering computation overhead.

[0220] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for generating the model shadow effect.

[0221] The machine-executable instructions stored in the aforementioned machine-readable storage medium can be executed to perform the following operations in the method for generating the shadow effect of the aforementioned model:

[0222] The normal map of the target model undergoes a first sampling process to obtain a first orientation map in multiple dimensions. This first orientation map includes normal components in the corresponding dimensional directions. Based on the illumination angle components of the ambient light source in multiple dimensions, the first orientation map in multiple dimensions undergoes a first interpolation and blending process to obtain a first processing result. The ambient light source is located in the 3D space where the target model is situated. Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map undergoes a second sampling process using the offset UV coordinate values ​​to obtain a second orientation map in multiple dimensions. Based on the illumination angle components in multiple dimensions, the first and second orientation maps undergo a second interpolation and blending process to obtain a second processing result. Based on the first and second processing results, the diffuse color performance coefficient of the target model is determined. Based on the diffuse color performance coefficient, the initial color data of the target model is adjusted to obtain color data with a shadow effect. This color data with a shadow effect is used to control the shadow effect generated by the target model in 3D space.

[0223] Obtain the normal map of the target model; wherein the normal map includes at least: normal components in the X-dimensional direction and normal components in the Y-dimensional direction in 3D space; based on the UV coordinate values ​​of the normal map, sample the normal map to obtain a first direction map corresponding to multiple dimensional directions; the multiple dimensional directions include: positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction and negative Y-dimensional direction.

[0224] The normal components in the X-axis direction are stored in the first channel of the normal map; the normal components in the Y-axis direction are stored in the second channel of the normal map; based on the UV coordinate values ​​of the normal map, the normal components greater than zero are sampled in the first channel of the normal map to obtain the normal components in the positive X-axis direction, and these normal components are used as the first direction map corresponding to the positive X-axis direction; based on the UV coordinate values ​​of the normal map, the normal components less than or equal to zero are sampled in the first channel of the normal map to obtain the normal components in the negative X-axis direction, and these normal components are used as the first direction map corresponding to the positive X-axis direction. Linear components are negativeized to obtain the first orientation map corresponding to the negative X-dimensional direction. Based on the UV coordinate values ​​of the normal map, normal components greater than zero are sampled in the second channel of the normal map to obtain the normal components in the positive Y-dimensional direction, which are then used as the first orientation map corresponding to the positive Y-dimensional direction. Based on the UV coordinate values ​​of the normal map, normal components less than or equal to zero are sampled in the second channel of the normal map to obtain the normal components in the negative Y-dimensional direction, which are then negativeized to obtain the first orientation map corresponding to the negative Y-dimensional direction.

[0225] Based on the rotation value of the ambient light source, the illumination angle of the ambient light source is determined; wherein, the illumination angle includes: the illumination angle of the ambient light source on the horizontal plane in three-dimensional space; the horizontal plane includes the plane containing the X-dimensional direction and the Y-dimensional direction in three-dimensional space.

[0226] Extract the first angle value of the ambient light source by rotating around the Z-dimensional direction in three-dimensional space, and determine the illumination angle of the ambient light source based on the first angle value.

[0227] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weights, a first interpolation mixing process is performed on the first directional pattern corresponding to the positive X-axis direction and the first directional pattern corresponding to the positive Y-axis direction to obtain a first intermediate result. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weights, a first interpolation mixing process is performed on the first intermediate result and the first directional pattern corresponding to the negative X-axis direction to obtain a second intermediate result. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weights, a first interpolation mixing process is performed on the second intermediate result and the first directional pattern corresponding to the negative Y-axis direction to obtain a third intermediate result. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weights, a first interpolation mixing process is performed on the third intermediate result and the first directional pattern corresponding to the positive X-axis direction to obtain a first processed result.

[0228] Extract the second angle value of the ambient light source by rotating it around the X-dimensional direction in three-dimensional space, and determine the illumination height of the ambient light source based on the second angle value.

[0229] Based on the preset minimum offset value, the height offset value corresponding to the illumination height is determined; based on the illumination angle components of the ambient light source in multiple dimensions, the height offset value is subjected to a third interpolation and mixing process to obtain the UV coordinate offset value of the normal map's UV coordinate value.

[0230] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weight, a third interpolation blending process is performed on the first and second coordinate values ​​to obtain the first intermediate coordinates; where the X-value of the first coordinate value is the height offset value; and the Y-value of the second coordinate value is the negative value of the height offset value. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weight, a third interpolation blending process is performed on the first and third intermediate coordinates to obtain the second intermediate coordinates; where the X-value of the third coordinate value is the negative value of the height offset value. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weight, a third interpolation blending process is performed on the second and fourth intermediate coordinates to obtain the third intermediate coordinates; where the Y-value of the fourth coordinate value is the height offset value. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weight, a third interpolation blending process is performed on the third intermediate coordinates and the first coordinate value to obtain the UV coordinate offset value of the normal map's UV coordinates.

[0231] Using the illumination angle component of the ambient light source in the positive X-axis direction as interpolation weights, a second interpolation blending process is performed on the second directional pattern corresponding to the positive X-axis direction and the first directional pattern corresponding to the positive Y-axis direction to obtain a first interpolation result. Using the illumination angle component of the ambient light source in the negative Y-axis direction as interpolation weights, a second interpolation blending process is performed on the first interpolation result and the second directional pattern corresponding to the negative X-axis direction to obtain a second interpolation result. Using the illumination angle component of the ambient light source in the negative X-axis direction as interpolation weights, a second interpolation blending process is performed on the second interpolation result and the second directional pattern corresponding to the negative Y-axis direction to obtain a third interpolation result. Using the illumination angle component of the ambient light source in the positive Y-axis direction as interpolation weights, a second interpolation blending process is performed on the third interpolation result and the second directional pattern corresponding to the positive X-axis direction to obtain a fourth interpolation result. The fourth interpolation result is then rounded up to obtain a rounded result. A specified value is added to the negative value of the rounded result to obtain a second processing result.

[0232] Calculate the difference between the first processing result and the second processing result, and determine the difference as the diffuse color performance coefficient of the target model; multiply the diffuse color performance coefficient by the initial color data of the target model to determine the color data with shadow effect.

[0233] In the above method, the normal components of the normal map in multiple dimensions are processed by the illumination angle and illumination height of the ambient light source to obtain color performance coefficients. These color performance coefficients are then used to adjust the initial color of the target model, thereby obtaining color data with shadow effects. This allows the target model to produce shadow effects under the influence of ambient light in three-dimensional space, and these shadow effects can change with changes in the ambient light source, resulting in a more realistic appearance. At the same time, this method does not require additional shadow effect maps or multiple iterations of the normal map, resulting in lower rendering computation overhead.

[0234] The computer program products of the model shadow effect generation method, apparatus and electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.

[0235] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0236] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0237] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0238] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0239] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for generating shadow effects on a model, characterized in that, The method includes: The normal map of the target model is sampled to obtain a first orientation map in multiple dimensions; the first orientation map includes the normal components in the corresponding dimensional directions. Based on the illumination angle components of the ambient light source in the multiple dimensional directions, a first interpolation and mixing process is performed on the first orientation map in the multiple dimensional directions to obtain a first processing result; wherein, the ambient light source is located in the three-dimensional space where the target model is located; Based on the illumination height of the ambient light source, the UV coordinate values ​​of the normal map are offset, and the normal map is then sampled a second time using the offset UV coordinate values ​​to obtain a second direction map in the multiple dimensions. Based on the illumination angle components in the multiple dimensional directions, the first radiation pattern and the second radiation pattern are subjected to a second interpolation and mixing process to obtain a second processing result; Based on the first processing result and the second processing result, the diffuse color performance coefficient of the target model is determined, and the initial color data of the target model is adjusted based on the diffuse color performance coefficient to obtain color data with shadow effect; wherein, the color data with shadow effect is used to control the target model to generate shadow effect in the three-dimensional space; The step of determining the diffuse color performance coefficient of the target model based on the first processing result and the second processing result, and adjusting the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with shadow effect includes: calculating the difference between the first processing result and the second processing result, determining the difference as the diffuse color performance coefficient of the target model; and multiplying the diffuse color performance coefficient by the initial color data of the target model to determine the color data with shadow effect.

2. The method according to claim 1, characterized in that, The steps of performing a first sampling process on the normal map of the target model to obtain a first direction map in multiple dimensions include: Obtain the normal map of the target model; wherein, the normal map includes at least: normal components in the X-dimensional direction and normal components in the Y-dimensional direction in the three-dimensional space; Based on the UV coordinate values ​​of the normal map, the normal map is sampled to obtain a first direction map corresponding to the multiple dimensional directions; the multiple dimensional directions include: positive X-dimensional direction, negative X-dimensional direction, positive Y-dimensional direction and negative Y-dimensional direction.

3. The method according to claim 2, characterized in that, The normal component in the X-dimensional direction is stored in the first channel of the normal map; the normal component in the Y-dimensional direction is stored in the second channel of the normal map. The step of sampling the normal map based on the UV coordinate values ​​of the normal map to obtain the first direction map corresponding to the multiple dimensional directions includes: Based on the UV coordinate values ​​of the normal map, sample the normal components that are greater than zero in the first channel of the normal map to obtain the normal components in the positive X-dimensional direction, and use the normal components in the positive X-dimensional direction as the first direction map corresponding to the positive X-dimensional direction. Based on the UV coordinate values ​​of the normal map, sample normal components less than or equal to zero in the first channel of the normal map to obtain normal components in the negative X-dimensional direction. Negate the normal components in the negative X-dimensional direction to obtain the first direction map corresponding to the negative X-dimensional direction. Based on the UV coordinate values ​​of the normal map, the normal components that are greater than zero are sampled in the second channel of the normal map to obtain the normal components in the positive Y-dimensional direction. The normal components in the positive Y-dimensional direction are used as the first direction map corresponding to the positive Y-dimensional direction. Based on the UV coordinate values ​​of the normal map, sample normal components less than or equal to zero in the second channel of the normal map to obtain normal components in the negative Y-axis direction. Negate the normal components in the negative Y-axis direction to obtain the first orientation map corresponding to the negative Y-axis direction.

4. The method according to claim 1, characterized in that, Before the step of performing a first interpolation and mixing process on the first orientation map in the multiple dimensions based on the illumination angle components of the ambient light source in the multiple dimensions to obtain the first processing result, the method further includes: Based on the rotation value of the ambient light source, the illumination angle of the ambient light source is determined; wherein, the illumination angle includes: the illumination angle of the ambient light source on the horizontal plane in the three-dimensional space; the horizontal plane includes the plane containing the X-dimensional direction and the Y-dimensional direction in the three-dimensional space.

5. The method according to claim 4, characterized in that, The step of determining the illumination angle of the ambient light source based on its rotation value includes: Extract a first angle value from the ambient light source, rotating it around the Z-dimensional direction in the three-dimensional space, and determine the illumination angle of the ambient light source based on the first angle value.

6. The method according to claim 1, characterized in that, The step of performing a first interpolation and mixing process on a first orientation pattern in multiple dimensions based on the illumination angle components of the ambient light source in those multiple dimensions to obtain a first processing result includes: Using the illumination angle component of the ambient light source in the positive X-dimensional direction as the interpolation weight, the first orientation pattern corresponding to the positive X-dimensional direction and the first orientation pattern corresponding to the positive Y-dimensional direction are subjected to a first interpolation mixing process to obtain a first intermediate result. Using the illumination angle component of the ambient light source in the negative Y-dimensional direction as the interpolation weight, the first intermediate result and the first orientation map corresponding to the negative X-dimensional direction are subjected to a first interpolation mixing process to obtain the second intermediate result. Using the illumination angle component of the ambient light source in the negative X-dimensional direction as the interpolation weight, the second intermediate result and the first orientation map corresponding to the negative Y-dimensional direction are subjected to a first interpolation mixing process to obtain a third intermediate result. Using the illumination angle component of the ambient light source in the positive Y-axis direction as the interpolation weight, the third intermediate result and the first orientation map corresponding to the positive X-axis direction are subjected to a first interpolation mixing process to obtain a first processing result.

7. The method according to claim 1, characterized in that, Before the step of offsetting the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source, the method further includes: Extract a second angle value from the ambient light source, rotating it around the X-dimensional direction in the three-dimensional space, and determine the illumination height of the ambient light source based on the second angle value.

8. The method according to claim 1, characterized in that, The step of offsetting the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source includes: determining the height offset value corresponding to the illumination height based on a preset minimum offset value. Based on the illumination angle components of the ambient light source in the multiple dimensional directions, a third interpolation and mixing process is performed on the height offset value to obtain the UV coordinate offset value of the normal map's UV coordinate value.

9. The method according to claim 8, characterized in that, The step of performing a third interpolation blending process on the height offset value based on the illumination angle components of the ambient light source in multiple dimensions to obtain the UV coordinate offset value of the normal map includes: Using the illumination angle component of the ambient light source in the positive X-axis direction as the interpolation weight, a third interpolation mixing process is performed on the first coordinate value and the second coordinate value to obtain the first intermediate coordinate; wherein, the X value of the first coordinate value is the height offset value; and the Y value of the second coordinate value is the negative value of the height offset value. Using the illumination angle component of the ambient light source in the negative Y-axis direction as the interpolation weight, the first intermediate coordinate and the third coordinate value are subjected to a third interpolation mixing process to obtain the second intermediate coordinate; wherein, the X value of the third coordinate value is the negative value of the height offset value; Using the illumination angle component of the ambient light source in the negative X-dimensional direction as the interpolation weight, the second intermediate coordinate and the fourth coordinate value are subjected to a third interpolation mixing process to obtain the third intermediate coordinate; wherein, the Y value of the fourth coordinate value is the height offset value; Using the illumination angle component of the ambient light source in the positive Y-axis direction as the interpolation weight, the third intermediate coordinate and the first coordinate value are subjected to a third interpolation mixing process to obtain the UV coordinate offset value of the normal map.

10. The method according to claim 1, characterized in that, The step of performing a second interpolation and mixing process on the first and second radiation patterns based on the illumination angle components in the multiple dimensions to obtain a second processing result includes: Using the illumination angle component of the ambient light source in the positive X-dimensional direction as the interpolation weight, a second interpolation mixing process is performed on the second orientation pattern corresponding to the positive X-dimensional direction and the first orientation pattern corresponding to the positive Y-dimensional direction to obtain the first interpolation result. Using the illumination angle component of the ambient light source in the negative Y dimension as the interpolation weight, a second interpolation mixing process is performed on the first interpolation result and the second orientation pattern corresponding to the negative X dimension to obtain the second interpolation result. Using the illumination angle component of the ambient light source in the negative X-dimensional direction as the interpolation weight, the second interpolation result and the second orientation pattern corresponding to the negative Y-dimensional direction are subjected to a second interpolation mixing process to obtain a third interpolation result; Using the illumination angle component of the ambient light source in the positive Y-axis direction as the interpolation weight, a second interpolation mixing process is performed on the third interpolation result and the second orientation pattern corresponding to the positive X-axis direction to obtain the fourth interpolation result; The fourth interpolation result is rounded up to obtain a rounded result. A specified value is added to the negative value of the rounded result to obtain the second processing result.

11. A device for generating model shadow effects, characterized in that, The device includes: The first sampling module is used to perform a first sampling process on the normal map of the target model to obtain a first orientation map in multiple dimensions; the first orientation map includes: normal components in the corresponding dimension direction; The first processing module is used to perform a first interpolation and mixing process on the first orientation map in the multiple dimensions based on the illumination angle components of the ambient light source in the multiple dimensions, to obtain a first processing result; wherein the ambient light source is located in the three-dimensional space where the target model is located; The second sampling module is used to offset the UV coordinate values ​​of the normal map based on the illumination height of the ambient light source, and to perform a second sampling process on the normal map using the offset UV coordinate values ​​to obtain a second direction map in the multiple dimensional directions. The second processing module is used to perform a second interpolation and mixing process on the first radiation pattern and the second radiation pattern based on the illumination angle components in the multiple dimensional directions to obtain a second processing result. A color data processing module is used to determine the diffuse color performance coefficient of the target model based on the first processing result and the second processing result, and adjust the initial color data of the target model based on the diffuse color performance coefficient to obtain color data with shadow effect; wherein, the color data with shadow effect is used to control the target model to generate shadow effect in the three-dimensional space; The color data processing module is specifically used to: calculate the difference between the first processing result and the second processing result, and determine the difference as the diffuse color performance coefficient of the target model; and determine the color data with shadow effect by multiplying the diffuse color performance coefficient with the initial color data of the target model.

12. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the method for generating model shadow effects according to any one of claims 1-10.

13. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for generating model shadow effects according to any one of claims 1-10.