Digital human shadow rendering method and device, equipment, storage medium and program product
By obtaining offline data of the target scene and the position of the digital human, and adjusting the shadow color, the problem of reduced realism in shadow rendering when the digital human moves in the shadow area is solved, and the realism of the digital human's shadow is improved.
Patent Information
- Application Number
- CN202510689697.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-09-05
AI Technical Summary
In the metaverse scene, shadows cannot be loaded when digital people move in shadow areas, resulting in reduced realism in shadow rendering.
By obtaining the offline data of the target scene and the position of the digital human, traversing the lighting color and initial shadow color of the pixel points, and adjusting the initial shadow color according to the shadow adjustable parameters input by the user, the target shadow color is generated, and finally the shadow rendering color of the digital human is determined.
The shadow loading of the digital human in the shadow area is realized, which improves the realism of the shadow rendering.
Smart Images

Figure CN120599113A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of metaverse technology, and in particular to a method, apparatus, device, storage medium, and program product for rendering shadows of digital humans. Background Art
[0002] Static shadow maps use offline rendering to create realistic shadows for static objects. In metaverse scenes, static shadow maps are currently baked using lightmaps to create static shadows. However, after a digital human is loaded into the map, when the digital human moves (for example, under the shade of a tree), the corresponding shadows cannot be loaded. As a result, when the digital human appears in the shadows, the lighting of the digital human remains that of normal lighting, meaning that there are no shadows on the digital human's face and body, reducing the realism of the shadow rendering. Summary of the Invention
[0003] The embodiments of the present application provide a method, apparatus, device, storage medium, and program product for digital human shadow rendering, which solve the current problem of being unable to perform shadow rendering on digital humans, resulting in reduced realism of shadow rendering.
[0004] In a first aspect, to achieve the above-mentioned objectives, embodiments of the present application provide a digital human shadow rendering method, comprising:
[0005] When monitoring that the digital human is loaded into the target scene, obtaining offline data associated with the target scene, wherein the offline data is related to a static shadow baking map of the target scene;
[0006] According to the offline data and the position of the digital human, traverse each pixel point corresponding to the digital human, and determine the illumination color and initial shadow color of the target pixel point currently traversed by the digital human;
[0007] When the target pixel point is located in the shadow area corresponding to the static shadow baking image, adjusting the initial shadow color according to the shadow adjustable parameter input by the user to obtain the target shadow color;
[0008] The target color of the digital human is determined according to the illumination color and the target shadow color, where the target color is the final color of the digital human shadow rendering.
[0009] The method further comprises:
[0010] Obtaining the area to be baked in the target scene;
[0011] Performing a light baking operation on the area to be baked to obtain a static shadow baking map corresponding to the area to be baked;
[0012] The identifier of the target scene, the position data of the area to be baked, and the static shadow baking map are bound to obtain the offline data.
[0013] According to the offline data and the position of the digital human, traversing each pixel point corresponding to the digital human, and determining the illumination color and initial shadow color of the target pixel point currently traversed by the digital human, includes:
[0014] Initialize rendering variables according to the offline data;
[0015] Determining a plurality of pixel points corresponding to the digital human according to the position of the digital human;
[0016] The plurality of pixel points are traversed, and the lighting color and the initial shadow color of the digital human at the target pixel point are determined according to the initialized rendering variables and the position of the digital human.
[0017] Wherein, determining the initial shadow color of the digital human at the target pixel point according to the initialized rendering variables and the position of the digital human includes:
[0018] Calculating the world space coordinates of the target pixel point;
[0019] determining a shadow area of the target scene according to the rendering variables;
[0020] When it is determined according to the world space coordinates that the target pixel point is located in the shadow area, texture sampling is performed based on the world space coordinates to obtain the initial shadow color.
[0021] The step of performing texture sampling based on the world space coordinates to obtain the initial shadow color includes:
[0022] Convert the world space coordinates into baking map sampling coordinates; wherein the origin of the coordinate system of the baking map sampling coordinates is located at the lower left corner of the shadow area, and (1, 1) of the coordinate system of the baking map sampling coordinates is located at the upper right corner of the shadow area;
[0023] Texture sampling is performed based on the baking image sampling coordinates to obtain the initial shadow color.
[0024] The adjustable shadow parameters include: shadow color amplification coefficient, shadow color mixing coefficient, color superposition coefficient and exponential power parameter;
[0025] The method of adjusting the initial shadow color according to the shadow adjustable parameters input by the user to obtain the target shadow color includes:
[0026] Using the shadow color magnification coefficient, the initial shadow color is multiplied to obtain a first shadow color;
[0027] Using the color superposition coefficient, superimposing the first shadow color to obtain a second shadow color;
[0028] Using the shadow color mixing coefficient, mix the second shadow color with white to obtain a third shadow color;
[0029] Using the exponential power parameter, performing exponential power processing on the third shadow color to obtain a fourth shadow color;
[0030] The fourth shadow color is limited to the first range to obtain the target shadow color.
[0031] In a second aspect, to achieve the above-mentioned objectives, embodiments of the present application provide a digital human shadow rendering device, comprising:
[0032] A first acquisition module is configured to acquire offline data associated with a target scene when detecting that a digital human is loaded into the target scene, wherein the offline data is related to a static shadow baking map of the target scene;
[0033] A first determination module is used to traverse each pixel point corresponding to the digital human according to the offline data and the position of the digital human, and determine the illumination color and initial shadow color of the target pixel point currently traversed by the digital human;
[0034] an adjustment module, configured to adjust the initial shadow color according to a shadow adjustable parameter input by a user to obtain a target shadow color when the target pixel point is located in a shadow area corresponding to the static shadow baking image;
[0035] The second determining module is used to determine the target color of the digital human according to the illumination color and the target shadow color, where the target color is the final color of the digital human's shadow rendering.
[0036] In the third aspect, in order to achieve the above-mentioned purpose, an embodiment of the present application provides a digital human shadow rendering device, including a transceiver, a processor, a memory, and a program stored on the memory and runnable on the processor; when the processor executes the program, the digital human shadow rendering method as described in the first aspect is implemented.
[0037] In a fourth aspect, in order to achieve the above-mentioned purpose, an embodiment of the present application provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, the digital human shadow rendering method as described in the first aspect is implemented.
[0038] In a fifth aspect, in order to achieve the above-mentioned purpose, an embodiment of the present application provides a computer program product, including computer instructions, which, when executed by a processor, implement the digital human shadow rendering method as described in the first aspect.
[0039] The beneficial effects of the above technical solution of this application are as follows:
[0040] The shadow rendering method of a digital human in an embodiment of the present application includes: when monitoring that a digital human is loaded into a target scene, obtaining offline data associated with the target scene, wherein the offline data is related to the static shadow baking map of the target scene; based on the offline data and the position of the digital human, traversing each pixel corresponding to the digital human, and determining the illumination color and initial shadow color of the target pixel currently traversed by the digital human; when the target pixel is located in the shadow area corresponding to the static shadow baking map, adjusting the initial shadow color according to the shadow adjustable parameter input by the user to obtain the target shadow color; determining the target color of the digital human based on the illumination color and the target shadow color, the target color being the final color of the shadow rendering of the digital human. In this way, when the digital human reaches the shadow area of the target scene, the shadow rendering of the digital human can be performed based on the user's needs, so that the digital human can be affected by the static shadow, that is, the digital human has a shadow effect, thereby enhancing the realism of the shadow. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a flowchart of a digital human shadow rendering method according to an embodiment of the present application;
[0042] Figure 2 This is a schematic diagram of the effect of a static shadow map in an embodiment of the present application;
[0043] Figure 3 Schematic diagram comparing the effects of vertex-by-vertex rendering and fragment-by-fragment rendering in an embodiment of the present application;
[0044] Figure 4 Schematic diagram of the principle of coordinate transformation in the embodiment of the present application;
[0045] Figure 5 Schematic diagram of a power function in an embodiment of the present application;
[0046] Figure 6 A schematic diagram of the effect of rendering a white object using the method of an embodiment of the present application;
[0047] Figure 7 This is a schematic diagram of the effect of rendering a white object without using the method of the embodiment of the present application;
[0048] Figure 8This is a structural diagram of a digital human shadow rendering device according to an embodiment of the present application;
[0049] Figure 9 This is a structural diagram of a digital human shadow rendering device according to an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the technical problems, technical solutions and advantages to be solved by this application clearer, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0051] It should be understood that references throughout this specification to "one embodiment" or "an embodiment" mean that a particular feature, structure, or characteristic associated with the embodiment is included in at least one embodiment of the present application. Therefore, the appearances of "in one embodiment" or "in an embodiment" throughout this specification do not necessarily refer to the same embodiment. Furthermore, these particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0052] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0053] Additionally, the terms "system" and "network" are often used interchangeably herein.
[0054] In the embodiments provided herein, it should be understood that "B corresponding to A" means that B is associated with A and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based solely on A; B can also be determined based on A and / or other information.
[0055] The embodiment of the present application provides a digital human shadow rendering method, such as Figure 1 As shown, the method includes:
[0056] Step 101: When monitoring that a digital human is loaded into a target scene, obtain offline data associated with the target scene, wherein the offline data is related to a static shadow baking map of the target scene.
[0057] First, the target scene is, for example, a 3D scene with the X and Z axes representing the ground surface and the Y axis representing the height. Second, the offline data is generated based on a static shadow baking map generated within the target scene. Based on this offline data, the static shadow baking map of the target scene can be obtained, facilitating subsequent shadow rendering of the digital human when the digital human is loaded into the shadow area corresponding to the static shadow baking map.
[0058] Step 102: traverse each pixel point corresponding to the digital human according to the offline data and the position of the digital human, and determine the illumination color and initial shadow color of the digital human at the target pixel point currently traversed.
[0059] Step 103 : When the target pixel point is located in the shadow area corresponding to the static shadow baking image, the initial shadow color is adjusted according to the shadow adjustable parameters input by the user to obtain a target shadow color.
[0060] Since the digital human should only be displayed with a shadow effect when it is in a shadow area, after step 102, it is necessary to preliminarily determine whether the currently traversed pixel point (target pixel point) is in the shadow area. If the target pixel point is in the shadow area, the above step 103 is executed. Otherwise, if the target pixel point is outside the shadow area, the initial shadow color is determined to be a preset shadow color, for example, the value of each channel of the preset shadow color is 1.
[0061] Step 104 : Determine the target color of the digital human according to the illumination color and the target shadow color. The target color is the final color of the digital human's shadow rendering.
[0062] In the shadow rendering method for a digital human in an embodiment of the present application, first, when a digital human is detected to be loaded into a target scene, offline data associated with the target scene is obtained, wherein the offline data is related to the static shadow baking map of the target scene; second, based on the offline data and the position of the digital human, each pixel corresponding to the digital human is traversed to determine the illumination color and initial shadow color of the target pixel currently traversed by the digital human; third, when the target pixel is located in the shadow area corresponding to the static shadow baking map, the initial shadow color is adjusted according to the shadow adjustable parameter input by the user to obtain the target shadow color; finally, based on the illumination color and the target shadow color, the target color of the digital human is determined, and the target color is the final color of the shadow rendering of the digital human. In this way, when the digital human reaches the shadow area of the target scene, the shadow rendering of the digital human can be performed based on the user's needs, so that the digital human can be affected by the static shadow, that is, the digital human has a shadow effect, thereby enhancing the realism of the shadow.
[0063] Furthermore, as an optional implementation, before step 101, the method further includes:
[0064] Obtain the area to be baked in the target scene. Here, the area to be baked corresponds to the aforementioned shadow area, that is, the area that needs to be baked offline to obtain a static shadow map. Among them, this step can be to set an axis-aligned bounding box (AABB) in the target scene, and the area enclosed by the AABB is the area to be baked. In other words, the area to be baked is obtained by setting an AABB in the target scene. Among them, AABB is a collective shape used to represent objects in three-dimensional space, and its boundaries are aligned with the coordinate axes; AABB can also be called an axial bounding box, an axis-aligned bounding box, etc.
[0065] Perform light baking operation on the area to be baked to obtain a static shadow baking map corresponding to the area to be baked. In this step, static shadow baking of the scene can be performed using the light map (LigntMap) technology in the AABB to obtain the shadow environment map of the bounding box area. An example effect diagram of this step is shown below: Figure 2 shown.
[0066] Here, assuming that the area to be baked is A, the baking area A is represented by the Min-Max representation method, then the baking area A can be expressed as:
[0067]
[0068] Among them, P min The coordinates of the point at the lower left corner of the baking area A, P max The coordinates of the point indicating the upper right corner of the baking area A.
[0069] After obtaining the baking area A, use a professional scene shadow baking tool to perform lighting baking operations on the surface of area A to obtain the shadow baking map of the area, set it as EnvMap', similar to Figure 2 .
[0070] Here, it should also be noted that, firstly, after the lighting baking operation is performed on the to-be-baked area in the above steps, other data baking maps are obtained, and the scene and character effects are fused on the other data baking maps to obtain a static shadow map; secondly, after obtaining the static shadow baking map, additional information can be expressed on the static shadow baking map and a texture can be generated.
[0071] The identifier of the target scene, the position data of the area to be baked, and the static shadow baking map are bound to obtain the offline data.
[0072] Here, it should be noted that, when the baking shadow map is generated according to the above-mentioned definition of the baking area A, the position data corresponding to the baking shadow map will also be generated, such as the world coordinate information data B (Xmin , Z min , X max , Z max ). Therefore, the above steps can associate the target scene with the static shadow baking map (such as the aforementioned EnvMap') and the shadow area data B in a one-to-one manner through [target scene identifier, {B, static shadow baking map}] to obtain offline data. The offline data is data that can be read by the execution subject (such as an application) of the digital human shadow rendering method of the embodiment of the present application at runtime.
[0073] As an optional implementation, step 102 includes:
[0074] Initialize rendering variables according to the offline data; wherein the rendering variables include, for example, global rendering parameters Game_Env_MapT and shadow area data Game_Env_AABB; wherein, Game_Env_MapT represents the static shadow baking map of the current scene (the aforementioned target scene), Game_Env_AABB = {X1, Y2, Z3, W4}, wherein X1 represents the world coordinate X-axis value of the lower left corner of the shadow area, Y2 represents the world coordinate Z-axis value of the lower left corner, Z3 represents the world coordinate X-axis value of the upper right corner of the shadow area, and W4 represents the world coordinate Z-axis value of the upper right corner of the shadow area.
[0075] According to the position of the digital human, a plurality of pixel points corresponding to the digital human are determined.
[0076] The plurality of pixel points are traversed, and the lighting color and the initial shadow color of the digital human at the target pixel point are determined according to the initialized rendering variables and the position of the digital human.
[0077] Here, it should be noted that the commonly used methods for calculating light color are vertex-by-vertex rendering and slice-by-slice rendering. The rendering effect diagram is as follows Figure 3 As shown, specifically, Figure 3 The left side shows the vertex-by-vertex rendering effect. Figure 3 The right side shows the fragment-by-fragment rendering effect. For the lighting and shadow calculation of the digital human, in order to achieve higher and more delicate picture quality, the embodiment of this application adopts a fragment-by-fragment rendering method, that is, the color calculation of lighting and shadow is placed in the fragment shader.
[0078] As mentioned above, shadow color calculation (or shadow rendering) is performed in the slice shader (pixel shader), and the world space coordinates of the target pixel point can be calculated in the vertex shader. Assume that the world space coordinates of the target pixel point are expressed as: P0 = {x, y, z, w}.
[0079] Specifically, after calculating the world space coordinates of the target pixel, the illumination color of the target pixel can be obtained based on the illumination model. Among them, commonly used illumination models include the Lambert model, the Phong model, the Blinn-Phong illumination model, the Rendering Equation (global illumination model), etc. In the above optional implementation method, it is assumed that the execution subject of the digital human shadow rendering method of the embodiment of the present application has its own set of illumination calculations, and obtains the illumination color of the target pixel through the illumination model algorithm. For example, the illumination color of the target pixel can be expressed as: color0 = {R, G, B, A}.
[0080] As a specific implementation, determining the initial shadow color of the digital human at the target pixel point according to the initialized rendering variables and the position of the digital human includes:
[0081] Calculate the world space coordinates of the target pixel point; as mentioned above, the world space coordinates P0 = {x, y, z, w} of the target pixel point can be calculated in the vertex shader.
[0082] Determine the shadow area of the target scene according to the rendering variables; wherein, this step can obtain the shadow area based on the parameter Game_Env_AABB={X1, Y2, Z3, W4} in the rendering variables.
[0083] When it is determined according to the world space coordinates that the target pixel point is outside the shadow area, texture sampling is performed based on the world space coordinates to obtain the initial shadow color.
[0084] That is, before performing texture sampling based on the world space coordinates to obtain the initial shadow color, the method further includes: determining whether the target pixel is located in the shadow area. If the target pixel is located in the shadow area, texture sampling is performed based on the world space coordinates to obtain the initial shadow color. If the target pixel is located outside the shadow area, the initial shadow color of the target pixel is determined to be the preset shadow color. In this case, the initial shadow color / preset shadow color is expressed as: shadowColor = {1, 1, 1}.
[0085] As a more specific implementation, the step of “performing texture sampling based on the world space coordinates to obtain the initial shadow color” in the above specific implementation includes:
[0086] 1) Convert the world space coordinates into baking map sampling coordinates; wherein the origin of the coordinate system of the baking map sampling coordinates is located at the lower left corner of the shadow area, and (1, 1) of the coordinate system of the baking map sampling coordinates is located at the upper right corner of the shadow area; that is, the baking map sampling coordinate system uses {X1, Y2} in the shadow area data Game_Env_AABB={X1, Y2, Z3, W4} in the rendering variable as the origin coordinates. An example of the specific coordinate conversion process of this step is:
[0087] As mentioned above, the target scene is a scene with the X and Z axes as the ground surface. Therefore, we can first construct a new two-dimensional coordinate system, assuming that: P(x, y) = (P0.x, P0.y), and then calculate the relative coordinate P of P(x, y) in the shadow area coordinate system / baked map sampling coordinate system. ’ (x, y), where P ’ (x, y) is the coordinate value of the target pixel point converted from the world space coordinate P0 to the baking image sampling coordinate system.
[0088] Specifically, such as Figure 4 As shown, assuming that the origin of the lower left corner of the two-dimensional coordinates of the shadow area is A1 (x, y), according to the definition of the shadow area data Game_Env_AABB = {X1, Y2, Z3, W4} in the aforementioned initialized rendering variables, it is determined that the following relationship exists:
[0089] A1(x, y) = (Game_Env_AABB.x, Game_Env_AABB.y); where Game_Env_AABB.x is initialized to X1 and Game_Env_AABB.y is initialized to Y2;
[0090] The x-axis length of the two-dimensional shadow area is Width = (Game_Env_AABB.z - A1.x); where Game_Env_AABB.z is initialized to Z3;
[0091] The height of the two-dimensional shadow area in the Y-axis direction Heigth = (Game_Env_AABB.z-A1.x), where Game_Env_AABB.w is initialized to W4.
[0092] Among them, due to P ’ (x, y) represents the relative coordinates of P(x, y) in the baking map sampling coordinate system, so P ’ (x, y) can also be expressed as the percentage of P(x, y) in the shaded area. The specific relationship is as follows:
[0093] P ’ .x = (Px - A1.x) / Width;
[0094] P ’ .y=(Py-A1.y) / Height;
[0095] P(x, y) = (P0.x, P0.z).
[0096] Finally, replace the known original variables P0 (x, y) and Game_Env_AABB (X1, Y2, Z3, W4) to get P ’ The final coordinate formula of (x, y) is as follows:
[0097] P ’ .x=(P0.x-Game_Env_AABB.X1) / (Game_Env_AABB.Z3-Game_Env_AABB.X1);
[0098] P ’ .y=(P0.y-Game_Env_AABB.Y2) / (Game_Env_AABB.W4-Game_Env_AABB.Y2).
[0099] 2) Performing texture sampling based on the baking image sampling coordinates to obtain the initial shadow color.
[0100] It's important to note that because P'(x, y) ranges from [0, 1] (i.e., from the lower-left corner (0, 0) to the upper-right corner (1, 1) of the bounding box), P' is the shadow texture sample UV value. Therefore, step 2) above can use the texture sampling function tex2D to perform color sampling (e.g., tex2D(Game_Env_MapT, P')) to obtain the initial shadow color shadowTex(r, g, b).
[0101] As an optional implementation method, the shadow adjustable parameters include: shadow color amplification coefficient, shadow color mixing coefficient, color overlay coefficient and exponential power parameter; for example, the shadow adjustable parameters can be expressed as: Game_Lightmap_Weight = {Xw, Yw, Zw, Ww}, where Xw represents the shadow color amplification coefficient, Yw represents the shadow color mixing coefficient, Zw represents the color overlay coefficient, and Ww represents the exponential power.
[0102] On this basis, step 103 includes:
[0103] Using the shadow color magnification factor, the initial shadow color is multiplied to obtain the first shadow color. This step specifically involves multiplying the initial shadow color RGB using the Game_Lightmap_Weight.x parameter value (the aforementioned Xw) to meet the application layer's requirement for a darker shadow color. Assuming the color obtained in the current step is colLitmap, then colLitmap(r, g, b) = Game_Lightmap_Weight.x * shadowTex.rgb.
[0104] Using the color overlay coefficient, the first shadow color is overlaid to obtain the second shadow color. This step is specifically as follows: using the Game_Lightmap_Weight.z parameter value (the aforementioned Zw) as the overlay color RGB value for color overlay. Assuming that the obtained color is color1 (the second shadow color), the RGB value of color1 is: color1(r, g, b) = colLitmap.rgb + (Game_Lightmap_Weight.z, Game_Lightmap_Weight.z, Game_Lightmap_Weight.z);
[0105] Using the shadow color mixing coefficient, the second shadow color is mixed with white to obtain a third shadow color; a specific example of this step is: using the Game_Lightmap_Weight.y parameter value (the aforementioned Yw) as the weight value for color mixing, mixing according to the weight value and white to obtain color2, then the RGB value of color2 is: color2(r, g, b) = Game_Lightmap_Weight.y*color1+(1-Game_Lightmap_Weight.y)*(1, 1, 1); (For example: when the color1 value is pure black (0, 0, 0) and the mixing weight is 0.5, the final color (third shadow color) color2(r, g, b) = (0.5, 0.5, 0.5) is gray).
[0106] Using the exponential power parameter, the third shadow color is subjected to exponential power processing to obtain the fourth shadow color; this step is specifically, for example, using the Game_Lightmap_Weight.w parameter value (Ww) as the exponent, using the power function concave-convex distribution (such as Figure 5 ), perform exponential power processing on the color to make the shadow color distribution have concave and convex characteristics. Assuming that the final color / fourth shadow color value is color3, then: color3(r, g, b) = pow(color2, Game_Lightmap_Weight.w).
[0107] The fourth shadow color is restricted to the first range to obtain the target shadow color. This step specifically includes, for example, using the clamp function to restrict the value range from 0 to 1: color3(r, g, b) = clamp(color3, 0, 1). Finally, shadowColor = color3 (here, the restricted fourth shadow color, i.e., the target shadow color) is obtained.
[0108] Here, it should be noted that step 103 can be implemented using the above optional implementation method, or a more complex or more product-specific empirical formula, such as convolution, to perform secondary processing on the initial shadow data to obtain the target shadow color.
[0109] As an optional implementation, step 104 includes:
[0110] The product of the illumination color and the target shadow color is used as the target color.
[0111] Below, Figure 6 and Figure 7 As an example, we show how to use the generated static shadow baking map (such as Figure 2 As shown), the method of the embodiment of the present application is used to render the white object under light, at the junction of tree shadows, and within the tree shadows (as shown in FIG. Figure 6 As shown in (the digital human rendering effect is the same), and the effect of rendering the white object without using the method of the embodiment of the present application (as shown in Figure 7 As shown). Figure 6 and Figure 7 It can be seen that the shadow rendering of the white object by the method of the embodiment of the present application allows the white object to be affected by the static shadow, has a shadow effect, and improves the realism of the shadow.
[0112] In the above embodiment of the present application, based on a specific scene (a 3D scene with the X and Z axes as the ground surface and the Y axis as the height), an AABB is set in this scene, and the LightMap technology is used within the AABB to perform static shadow baking of the scene, thereby obtaining a shadow environment map (the aforementioned static shadow baking map) of the area surrounded by the AABB. When the digital human walks in this 3D scene, the digital human's behavior can be monitored and parameters can be set for the rendering material to achieve real-time shadow rendering of the digital human, allowing the digital human to be affected by static shadows and have shadow effects, meeting the offline baking performance requirements while improving the shadow realism. Among them:
[0113] The embodiments of this application involve engineering processes for static shadow textures, shadow region data, 3D scenes, and digital human behavior. These processes include shadow data format definition, export processes, and how upper-layer applications, at runtime, use scene configurations, shadow data, and trigger shadow rendering processes in conjunction with digital human behavior. Through scene configuration, globally adjustable shadow parameters, shadow regions, and shadow textures can be dynamically configured, allowing each scene to have its own unique rendering effect configuration capabilities.
[0114] In the embodiment of the present application, the shadow area data will be recorded and the shadow global variable will be defined in the fragment shader. The world coordinate area of the shadow area bounding box will be used, and the lower left corner of the area will be agreed to be the origin and the upper right corner of the area will be (1, 1). The world coordinate system of the pixel point will be converted to the shadow area coordinate system, and the new coordinates will be used for shadow texture UV sampling.
[0115] The embodiments of this application also define global variables for adjustable shader shadow color parameters, which are bound to scenes to enable dynamic configuration of the parameters. At the same time, an adjustable shadow color calculation algorithm is used to enable shadow color to have color amplification, overlay, blending, and exponential color distribution functions, thus making shadow color more controllable.
[0116] In this way, the embodiment of the present application provides an entire process from exporting static shadow baking maps to rendering applications. This process can be used to perform real-time rendering of character environment shadows in any 3D shadow static baking scene, with high rendering efficiency and soft shadows, and the effect is closer to the real scene.
[0117] The embodiment of the present application also provides a digital human shadow rendering device, such as Figure 8 Shown, including:
[0118] A first acquisition module 801 is configured to acquire offline data associated with a target scene when detecting that a digital human is loaded into the target scene, wherein the offline data is related to a static shadow baking map of the target scene;
[0119] The first determination module 802 is used to traverse each pixel corresponding to the digital human according to the offline data and the position of the digital human, and determine the lighting color and initial shadow color of the target pixel currently traversed by the digital human;
[0120] An adjustment module 803 is configured to adjust the initial shadow color according to a shadow adjustable parameter input by a user to obtain a target shadow color when the target pixel point is located in a shadow area corresponding to the static shadow baking image;
[0121] The second determining module 804 is configured to determine a target color of the digital human according to the illumination color and the target shadow color, where the target color is the final color of the digital human's shadow rendering.
[0122] Wherein, the device further includes:
[0123] A second acquisition module is used to acquire the area to be baked in the target scene;
[0124] A light baking processing module, configured to perform a light baking operation on the area to be baked to obtain a static shadow baking map corresponding to the area to be baked;
[0125] The data processing module is used to bind the identifier of the target scene, the position data of the area to be baked and the static shadow baking map to obtain the offline data.
[0126] The first determining module 802 includes:
[0127] An initialization submodule, used to initialize rendering variables according to the offline data;
[0128] A first determining submodule, configured to determine a plurality of pixel points corresponding to the digital human according to the position of the digital human;
[0129] The second determining submodule is configured to traverse the plurality of pixel points and determine the lighting color and the initial shadow color of the digital human at the target pixel point according to the initialized rendering variables and the position of the digital human.
[0130] The second determining submodule includes:
[0131] A calculation unit, configured to calculate the world space coordinates of the target pixel point;
[0132] a determining unit, configured to determine a shadow area of the target scene according to the rendering variable;
[0133] A sampling unit is configured to, when it is determined according to the world space coordinates that the target pixel point is located within the shadow area, perform texture sampling based on the world space coordinates to obtain the initial shadow color.
[0134] Wherein, the sampling unit includes:
[0135] A coordinate conversion subunit, configured to convert the world space coordinates into baking map sampling coordinates; wherein the origin of the coordinate system of the baking map sampling coordinates is located at the lower left corner of the shadow area, and (1,1) of the coordinate system of the baking map sampling coordinates is located at the upper right corner of the shadow area;
[0136] The sampling subunit is configured to perform texture sampling based on the baking image sampling coordinates to obtain the initial shadow color.
[0137] The adjustment module 803 includes:
[0138] A first adjustment submodule is configured to use the shadow color magnification coefficient to perform a multiplication process on the initial shadow color to obtain a first shadow color;
[0139] a second adjustment submodule, configured to perform a superposition process on the first shadow color using the color superposition coefficient to obtain a second shadow color;
[0140] a third adjustment submodule, configured to mix the second shadow color with white using the shadow color mixing coefficient to obtain a third shadow color;
[0141] a fourth adjustment submodule, configured to perform exponential processing on the third shadow color using the exponential power parameter to obtain a fourth shadow color;
[0142] The data processing submodule is configured to limit the fourth shadow color to a first range to obtain the target shadow color.
[0143] It should be noted here that the above-mentioned digital human shadow rendering device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned digital human shadow rendering method embodiment, and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.
[0144] An embodiment of the present application also provides a digital human shadow rendering device, including a transceiver 910, a processor 900, a memory 920, and a program stored in the memory 920 and executable on the processor 900; wherein, when the processor 900 executes the program, the digital human shadow rendering method described above is implemented.
[0145] The transceiver 910 is configured to receive and send data under the control of the processor 900 .
[0146] Among them, Figure 9In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically various circuits of one or more processors represented by processor 900 and memory represented by memory 920, which are linked together. The bus architecture may also link together various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 910 may be a plurality of components, i.e., a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. For different devices, the user interface 930 may also be an interface capable of connecting external or internal devices as required, and the connected devices include but are not limited to a keypad, a display, a speaker, a microphone, a joystick, etc.
[0147] The processor 900 is responsible for managing the bus architecture and general processing, and the memory 920 can store data used by the processor 900 when performing operations.
[0148] The present application also provides a readable storage medium having a program stored thereon. When executed by a processor, the program implements the digital human shadow rendering method described above and achieves the same technical effect. To avoid repetition, the details are omitted here. The readable storage medium may be, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0149] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course, by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for executing the methods described in each embodiment of the present application.
[0150] Therefore, an embodiment of the present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the digital human shadow rendering method as described above and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0151] In embodiments of the present application, modules can be implemented in software so that they can be executed by various types of processors. For example, an identified executable code module can include one or more physical or logical blocks of computer instructions, for example, which can be constructed as objects, processes, or functions. Nevertheless, the executable code of the identified module does not need to be physically located together, but can include different instructions stored in different locations, which, when logically combined together, constitute the module and achieve the specified purpose of the module.
[0152] In fact, executable code module can be a single instruction or many instructions, and can even be distributed on a plurality of different code segments, distributed in the middle of different programs, and distributed across a plurality of memory devices.Similarly, operating data can be identified in the module, and can be implemented and organized in the data structure of any appropriate type according to any appropriate form.Described operating data can be collected as a single data set, or can be distributed in different locations (including on different storage devices), and can only be present on a system or network as an electronic signal at least in part.
[0153] When a module can be implemented using software, given the current state of hardware technology, those skilled in the art can build corresponding hardware circuits to implement the corresponding functions of the module, regardless of cost. The hardware circuits may include conventional very large scale integration (VLSI) circuits or gate arrays, as well as existing semiconductors such as logic chips and transistors, or other discrete components. Modules may also be implemented using programmable hardware devices, such as field programmable gate arrays, programmable array logic, or programmable logic devices.
[0154] The above exemplary embodiments are described with reference to the accompanying drawings. Many different forms and embodiments are possible without departing from the spirit and teachings of this application. Therefore, this application should not be construed as limited to the exemplary embodiments set forth herein. Rather, these exemplary embodiments are provided so that this application will be complete and impartial and will convey the scope of this application to those skilled in the art. In the drawings, component sizes and relative sizes may be exaggerated for clarity. The terminology used herein is for purposes of describing specific exemplary embodiments only and is not intended to be limiting. As used herein, unless the context clearly indicates otherwise, the singular forms "a," "an," and "the" are intended to encompass such plural forms. It will be further understood that the terms "comprising" and / or "including," when used in this specification, indicate the presence of the stated features, integers, steps, operations, components, and / or elements, but do not preclude the presence or addition of one or more other features, integers, steps, operations, components, elements, and / or groups thereof. Unless otherwise indicated, when stated, a range of values includes the upper and lower limits of that range and any subranges therebetween.
[0155] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A digital human shadow rendering method, characterized in that: include: When monitoring that the digital human is loaded into the target scene, obtaining offline data associated with the target scene, wherein the offline data is related to a static shadow baking map of the target scene; According to the offline data and the position of the digital human, traverse each pixel point corresponding to the digital human, and determine the illumination color and initial shadow color of the target pixel point currently traversed by the digital human; When the target pixel point is located in the shadow area corresponding to the static shadow baking image, adjusting the initial shadow color according to the shadow adjustable parameter input by the user to obtain the target shadow color; The target color of the digital human is determined according to the illumination color and the target shadow color, where the target color is the final color of the digital human shadow rendering.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining the area to be baked in the target scene; Performing a light baking operation on the area to be baked to obtain a static shadow baking map corresponding to the area to be baked; The identifier of the target scene, the position data of the area to be baked, and the static shadow baking map are bound to obtain the offline data.
3. The method according to claim 1, characterized in that According to the offline data and the position of the digital human, traverse each pixel point corresponding to the digital human to determine the illumination color and initial shadow color of the target pixel point currently traversed by the digital human, including: Initialize rendering variables according to the offline data; Determining a plurality of pixel points corresponding to the digital human according to the position of the digital human; The plurality of pixel points are traversed, and the lighting color and the initial shadow color of the digital human at the target pixel point are determined according to the initialized rendering variables and the position of the digital human.
4. The method according to claim 3, characterized in that Determining the initial shadow color of the digital human at the target pixel point according to the initialized rendering variables and the position of the digital human includes: Calculating the world space coordinates of the target pixel point; determining a shadow area of the target scene according to the rendering variables; When it is determined according to the world space coordinates that the target pixel point is located in the shadow area, texture sampling is performed based on the world space coordinates to obtain the initial shadow color.
5. The method according to claim 4, characterized in that Performing texture sampling based on the world space coordinates to obtain the initial shadow color includes: Convert the world space coordinates into baking map sampling coordinates; wherein the origin of the coordinate system of the baking map sampling coordinates is located at the lower left corner of the shadow area, and (1, 1) of the coordinate system of the baking map sampling coordinates is located at the upper right corner of the shadow area; Texture sampling is performed based on the baking image sampling coordinates to obtain the initial shadow color.
6. The method according to claim 1, wherein The adjustable shadow parameters include: shadow color amplification coefficient, shadow color mixing coefficient, color superposition coefficient and exponential power parameter; The method of adjusting the initial shadow color according to the shadow adjustable parameters input by the user to obtain the target shadow color includes: Using the shadow color magnification coefficient, the initial shadow color is multiplied to obtain a first shadow color; Using the color superposition coefficient, superimposing the first shadow color to obtain a second shadow color; Using the shadow color mixing coefficient, mix the second shadow color with white to obtain a third shadow color; Using the exponential power parameter, performing exponential power processing on the third shadow color to obtain a fourth shadow color; The fourth shadow color is limited to the first range to obtain the target shadow color.
7. A digital human shadow rendering device, characterized in that: include: A first acquisition module is configured to acquire offline data associated with a target scene when detecting that a digital human is loaded into the target scene, wherein the offline data is related to a static shadow baking map of the target scene; A first determination module is used to traverse each pixel point corresponding to the digital human according to the offline data and the position of the digital human, and determine the illumination color and initial shadow color of the target pixel point currently traversed by the digital human; an adjustment module, configured to adjust the initial shadow color according to a shadow adjustable parameter input by a user to obtain a target shadow color when the target pixel point is located in a shadow area corresponding to the static shadow baking image; The second determining module is used to determine the target color of the digital human according to the illumination color and the target shadow color, where the target color is the final color of the digital human's shadow rendering.
8. A digital human shadow rendering device, comprising a transceiver, a processor, a memory, and a program stored in the memory and executable on the processor; characterized in that: When the processor executes the program, the digital human shadow rendering method according to any one of claims 1 to 6 is implemented.
9. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the digital human shadow rendering method according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the digital human shadow rendering method according to any one of claims 1 to 6.
