Shadow baking method, apparatus, electronic device, and storage medium
By upsampling the boundaries of low-precision shadow maps and selecting high-precision boundary pixels to generate high-precision shadow maps, the problem of low shadow map baking efficiency in existing technologies is solved, and high-quality shadow maps are generated efficiently.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-03-05
- Publication Date
- 2026-05-22
AI Technical Summary
In existing technologies, the baking efficiency of high-precision shadow maps is low, resulting in excessively long calculation times.
By obtaining the boundary of the low-precision shadow map, upsampling is performed, and the upsampled low-precision boundary pixels are selected as high-precision boundaries to generate a high-precision shadow map, thus avoiding global processing of the entire low-precision shadow map.
It improves shadow baking efficiency, generates high-quality, high-precision shadow maps, and reduces computation time.
Smart Images

Figure CN115035231B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and more specifically to a shadow baking method, apparatus, electronic device, and storage medium. Background Technology
[0002] Shadow mapping is the process of adding shadows to 3D computer graphics. Shadow mapping can achieve realistic lighting and shadow effects without reducing the frame rate.
[0003] Because the higher the resolution of the shadow map and the more detailed the shadow effect, the longer the calculation time, the baking efficiency of high-precision shadow maps is currently low. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for shaded baking, which can improve baking efficiency.
[0005] This invention provides a shadow baking method, comprising:
[0006] Obtain the low-precision shadow texture of the target model in the scene;
[0007] Determine the low-precision boundaries in the low-precision shadow map;
[0008] The low-precision boundary is upsampled to obtain an upsampled low-precision boundary, which is composed of upsampled low-precision boundary pixels.
[0009] The upsampled low-precision boundary pixel is selected as the upsampled high-precision boundary pixel;
[0010] A high-precision shadow map of the target model is generated based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0011] This invention also provides a shading baking apparatus, comprising:
[0012] The acquisition unit is used to acquire low-precision shadow maps of target models in the scene;
[0013] A determining unit is used to determine the low-precision boundaries in the low-precision shadow map;
[0014] An upsampling unit is used to perform upsampling processing on the low-precision boundary to obtain an upsampled low-precision boundary, wherein the upsampled low-precision boundary is composed of upsampled low-precision boundary pixels.
[0015] The selection unit is used to select the upsampled low-precision boundary pixel as the upsampled high-precision boundary pixel;
[0016] The generation unit is used to generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0017] In some embodiments, the scene further includes a light source, and the selection unit includes:
[0018] A ray tracing subunit is used to perform ray tracing processing on the upsampled low-precision boundary pixel in the scene to obtain the connection state between the light source and the upsampled low-precision boundary pixel.
[0019] The low-precision sub-unit is used to generate an upsampled low-precision shadow map based on the connection state between the light source and the upsampled low-precision boundary pixels, and to determine the upsampled low-precision boundary of the upsampled low-precision shadow map, wherein the upsampled low-precision boundary is composed of upsampled high-precision boundary pixels.
[0020] In some embodiments, the connection state includes an accessible state and an obstructed state, and the ray tracing subunit is configured to:
[0021] When the upsampled low-precision boundary pixel and the light source are connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an accessible state.
[0022] When the upsampled low-precision boundary pixel and the light source are not connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an occlusion state.
[0023] In some embodiments, the upsampled low-precision shadow map is composed of upsampled high-precision shadow pixels, and the low-precision subunit is used for:
[0024] When the connection between the light source and the upsampled low-precision boundary pixel is in an occlusion state, the upsampled low-precision boundary pixel is determined as an upsampled high-precision shadow pixel.
[0025] The boundary pixels of the upsampled high-precision shadow pixels are defined as upsampled high-precision boundary pixels.
[0026] In some embodiments, the scene further includes a light source, and the acquisition unit includes:
[0027] A sub-unit is used to acquire a target model in the scene, wherein the target model is composed of target pixels;
[0028] The second ray tracing subunit is used to perform ray tracing processing on the target pixel in the scene to obtain the connection state between the light source and the target pixel;
[0029] The second low-precision subunit is used to obtain a low-precision shadow map of the target model based on the connection state between the light source and the target pixel.
[0030] In some embodiments, the connection state includes an accessible state and an obstructed state, and the second ray tracing subunit is configured to:
[0031] When the target pixel and the light source are connected, the connection state between the light source and the target pixel is determined to be an accessible state;
[0032] When the target pixel and the light source are not connected, the connection state between the light source and the target pixel is determined to be an occlusion state.
[0033] In some embodiments, the low-precision shadow map is composed of low-precision shadow pixels, and the second low-precision sub-unit is used for:
[0034] When the connection between the light source and the target pixel is in an accessible state, the target pixel is identified as a low-precision shadow pixel.
[0035] In some embodiments, the low-precision boundary is composed of low-precision boundary pixels, and the determining unit is configured to:
[0036] The boundary pixels of the low-precision shadow map are defined as low-precision boundary pixels.
[0037] In some embodiments, the upsampled high-precision boundary is composed of upsampled high-precision boundary pixels, and the generation unit includes:
[0038] A distance sub-unit is used to determine the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel;
[0039] The distance field sub-unit is used to perform distance field shadow map generation processing based on the distance to obtain a high-precision shadow map of the target model.
[0040] In some embodiments, the distance field subunit is used for:
[0041] Among the distances between the low-precision shadow pixels and all the upsampled high-precision boundary pixels, determine the shortest distance;
[0042] The shortest distance is used as the shadow factor of the low-precision shadow pixel;
[0043] A high-precision shadow map of the target model is determined, wherein the high-precision shadow map of the target model is composed of the low-precision shadow pixels having the shadow factor.
[0044] In some embodiments, the distance subunit is used for:
[0045] Display a diffusion radius control control, which is used to control the diffusion radius of the shadow;
[0046] In response to an operation of the diffusion radius control, the shadow diffusion area is determined;
[0047] The distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel located in the shadow diffusion region is calculated and determined as the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel.
[0048] In some embodiments, the upsampling unit is configured to:
[0049] Display precision control controls, which are used to control the precision of upsampling;
[0050] In response to an operation on the precision control control, an upsampling coefficient is determined;
[0051] Based on the upsampling coefficients, the low-precision boundary is interpolated to obtain the upsampled low-precision boundary.
[0052] This invention also provides an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute steps in any of the shadow baking methods provided in this invention.
[0053] This invention also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the shadow baking methods provided in this invention.
[0054] This invention can acquire a low-precision shadow map of a target model in a scene; determine the low-precision boundary in the low-precision shadow map; perform upsampling processing on the low-precision boundary to obtain an upsampled low-precision boundary, wherein the upsampled low-precision boundary is composed of upsampled low-precision boundary pixels; select upsampled high-precision boundary pixels from the upsampled low-precision boundary pixels; and generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking, wherein the upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0055] In this invention, only the low-precision boundaries in the low-precision shadow map can be upsampled, and the upsampled high-precision boundaries can be determined based on the upsampled low-precision boundaries. The upsampled high-precision boundaries are then used to generate high-precision shadow maps. This eliminates the need to perform the above series of processes on the entire low-precision shadow map, thus improving shadow baking efficiency. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1a This is a schematic diagram of a scenario for the shadow baking method provided in an embodiment of the present invention;
[0058] Figure 1b This is a schematic flowchart of the shadow baking method provided in an embodiment of the present invention;
[0059] Figure 1c This is a schematic diagram of a low-precision shadow map of the shadow baking method provided in an embodiment of the present invention;
[0060] Figure 1d This is a high-precision shadow mapping diagram of the shadow baking method provided in the embodiment of the present invention;
[0061] Figure 1e This is a schematic diagram of the connection state of the shadow baking method provided in the embodiment of the present invention;
[0062] Figure 1f This is a schematic diagram of the shadow and shadow boundary of the shadow baking method provided in the embodiment of the present invention;
[0063] Figure 1g This is a schematic diagram of distance calculation for the shadow baking method provided in this embodiment of the invention;
[0064] Figure 1h This is a schematic diagram illustrating the effect of the shadow baking method provided in an embodiment of the present invention;
[0065] Figure 2a This is a schematic diagram of the distance field shadow baking method provided in an embodiment of the present invention;
[0066] Figure 2b This is a schematic diagram of the boundary pixel buffer of the distance field shadow baking method provided in the embodiment of the present invention;
[0067] Figure 3 This is a schematic diagram of the structure of the shadow baking apparatus provided in an embodiment of the present invention;
[0068] Figure 4 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0069] The technical solutions of the embodiments 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, and 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.
[0070] This invention provides a shadow baking method, apparatus, electronic device, and storage medium.
[0071] Specifically, the shadow baking device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.
[0072] In some embodiments, the shadow baking apparatus may also be integrated into multiple electronic devices, such as multiple servers, with multiple servers implementing the shadow baking method of the present invention.
[0073] In some embodiments, the server may also be implemented as a terminal.
[0074] For example, refer to Figure 1a The electronic device can acquire a low-precision shadow map of a target model in a scene; determine the low-precision boundary in the low-precision shadow map; perform upsampling processing on the low-precision boundary to obtain an upsampled low-precision boundary, which is composed of the upsampled low-precision boundary pixels; select the upsampled low-precision boundary pixels as upsampled high-precision boundary pixels; and generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking, where the upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0075] The following sections provide detailed descriptions of each example. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0076] In this embodiment, a shadow baking method is provided, which can be applied to scenarios such as video games, animation production, and experimental simulation. Figure 1b As shown, the specific process of this shadow baking method can be as follows:
[0077] 101. Obtain the low-precision shadow map of the target model in the scene.
[0078] A scene refers to a virtual scene, which is a digital scene created by a computer through digital communication technology. It can be composed of virtual characters, objects, natural terrain, buildings, etc., such as the virtual scene in a video game.
[0079] The virtual scene can be a three-dimensional scene. In the three-dimensional scene, there can be one or more light sources, one or more three-dimensional models, etc. When the light source shines on the object model, shadow maps can be displayed on the ground of the scene or the surface of the object model to improve the realism of the scene.
[0080] The target model is a 3D model within a 3D scene. This 3D model can be an object model, a character model, a special effects model, etc. For example, the target model could be a game character model, a sofa model, a volumetric cloud effect model, a fireworks effect model, and so on.
[0081] Among them, low-precision shadow maps are shadow maps. Because they have not undergone further processing, the texture quality is low, often exhibiting significant jagged edges. For example, see the reference image. Figure 1c The low-precision shadow map in the image is blurry, with jagged edges, and lacks smoothness, making it visually unrealistic.
[0082] In contrast, the high-precision shadow map obtained by this method is also a shadow map. After a series of processing steps 102-105, the high-precision shadow map effectively eliminates jagged edges, and the texture quality is significantly improved compared to the low-precision shadow map. For example, refer to... Figure 1d The high-precision shadow map in the image makes the edges of the shadows cast by leaves on the ground clearer and smoother, resulting in a more realistic visual appearance.
[0083] Therefore, the low-precision shadow map has a lower texture quality than the high-precision shadow map.
[0084] There are several methods to obtain low-precision shadow maps of target models in a scene. For example, one can communicate with a texture database over a network to obtain low-precision shadow maps of target models in the scene; another example is to directly bake the target model in the scene to obtain low-precision shadow maps of target models in the scene, and so on.
[0085] For example, in some embodiments, the scene may include a light source, which refers to a virtual light source that can render lighting effects onto virtual objects in the scene, thereby simulating lighting effects in the real world. Step 101 may include the following steps:
[0086] (1) Obtain the target model in the scene. The target model is composed of target pixels;
[0087] (2) Perform ray tracing on the target pixel in the scene to obtain the connection state between the light source and the target pixel;
[0088] (3) Based on the connection state between the light source and the target pixel, obtain the low-precision shadow map of the target model.
[0089] This involves acquiring the model data of the target model in the scene and converting it into target pixels that constitute the target model through rasterization.
[0090] The model data can include information such as the coordinates, color, vertices, primitives, fragments, and textures of the game model.
[0091] Rasterization refers to converting a two-dimensional image into multiple gratings, each of which corresponds to a displayable pixel, thereby obtaining the target pixel of the target model.
[0092] A pixel, or image element, is the smallest unit displayed on a screen. A target pixel is a pixel that makes up the target model.
[0093] In this context, a vertex is a point where multiple lines, curves, or edges meet to form an angle; a primitive is a point, line segment, or polygon composed of multiple vertices; and a fragment is an image composed of multiple grids obtained by rasterizing primitives.
[0094] In this embodiment, the ray tracing technology of the graphics processing unit (GPU) can be used to determine the connection status between the light source and each target pixel.
[0095] Ray tracing can simulate the path of light in the real physical world. For example, a ray of light may start from a light source, hit an object along the way, and then be refracted or reflected, losing some light energy.
[0096] In this embodiment, ray tracing is achieved by sending rays from the target pixel to the light source. This allows for the determination of the visual connection between the target pixel and the light source along a specific trajectory. For example, if an obstacle exists between the target pixel and the light source, they are invisible and inaccessible, meaning the light source will not illuminate the target pixel, and therefore, the target pixel will not generate a shadow map. Conversely, if no obstacle exists between the target pixel and the light source, they are visible and accessible, meaning the light source can illuminate the target pixel, and therefore, the target pixel can generate a shadow map. Based on the connection state between the light source and the target pixel, it can be determined whether each target pixel in the target model can generate its corresponding shadow map, ultimately resulting in a low-precision shadow map of the entire target model. Each pixel in this low-precision shadow map corresponds to a target pixel that constitutes the target model.
[0097] Connectivity status represents whether it is possible to reach another point from a certain point along a specific trajectory. Connectivity status can include reachability status and occlusion status. Reachability status means that it is possible to reach another point from a certain point along a specific trajectory; occlusion status means that it is not possible to reach another point from a certain point along a specific trajectory.
[0098] Therefore, in some embodiments, the connection state step (2) "perform ray tracing on the target pixel in the scene to obtain the connection state between the light source and the target pixel" may include the following steps:
[0099] When the target pixel and the light source are connected, the connection state between the light source and the target pixel is defined as the accessible state;
[0100] Otherwise, the connection state between the light source and the target pixel is determined to be an occlusion state.
[0101] For example, refer to Figure 1e Starting from the target pixel, a virtual ray is sent towards the light source. Figure 1e As shown in the upper part, if the ray is not blocked by obstacles (such as other pixels), meaning it can reach the light source from the target pixel along the ray, then the target pixel and the light source are connected, and the connection state between the light source and the target pixel is determined as an accessible state. Otherwise, if as Figure 1e As shown in the lower half, the ray is blocked by an obstacle (such as other pixels), meaning that the ray can only reach the obstacle from the target pixel and cannot reach the light source. Therefore, the connection state between the light source and the target pixel is determined to be the occlusion state.
[0102] Since each accessible target pixel can generate its corresponding low-precision shadow pixel, the low-precision shadow pixels of all target pixels constitute a low-precision shadow map. Therefore, in some embodiments, the low-precision shadow map is composed of low-precision shadow pixels. Step (3) "Based on the connection state between the light source and the target pixel, obtain the low-precision shadow map of the target model and determine the low-precision boundary of the low-precision shadow map" may include the following steps:
[0103] When the connection between the light source and the target pixel is in an accessible state, the target pixel is defined as a low-precision shadow pixel.
[0104] 102. Determine the low-precision boundaries in the low-precision shadow map.
[0105] In this context, the low-precision boundary refers to the boundary between the shadow map region and the lighting region within the low-precision shadow map. For example, refer to... Figure 1f , Figure 1f The image shown is a low-precision shadow map (00) and its low-precision boundary map (10); the white portion of the low-precision shadow map (00) is the shadow map region 000, and the black portion is the lighting region 001; based on Figure 1f The low-precision shadow map (00) shown can be used to obtain the low-precision boundary 100, and the white part in the low-precision boundary map (10) is the low-precision boundary 100.
[0106] Boundary pixels in a low-precision shadow map can form a low-precision boundary. Boundary pixels refer to the outermost pixels in an image or a set of pixels.
[0107] The low-precision boundary is composed of low-precision boundary pixels.
[0108] 103. Upsample the low-precision boundary to obtain the upsampled low-precision boundary, which is composed of the pixels of the upsampled low-precision boundary.
[0109] Upsampling refers to using a series of processing methods to enlarge an image, thereby increasing its resolution.
[0110] In this embodiment, the low-precision boundary obtained in step 102 can be upsampled into a high-resolution low-precision boundary, which is composed of low-precision boundary pixels, so that each pixel in the high-resolution low-precision boundary can be subdivided in step 104 to obtain a high-quality upsampled high-precision boundary.
[0111] In this embodiment, upsampling can be performed using various methods. For example, upsampling can be achieved by interpolating the image, that is, inserting new pixels between the original image pixels using a suitable interpolation algorithm.
[0112] In some embodiments, to facilitate user control over the degree of upsampling and improve user experience, step 103 may include the following steps:
[0113] Display a precision control that controls the precision of upsampling;
[0114] The upsampling coefficient is determined in response to the operation of the precision control control;
[0115] Based on the upsampling coefficients, the low-precision boundary is interpolated to obtain the upsampled low-precision boundary.
[0116] Among them, precision control controls can be represented in the form of knobs, scroll bars, input boxes, etc.
[0117] The upsampling coefficient can be an interpolation factor, a resolution factor, etc. For example, if the upsampling coefficient is an interpolation factor and the user sets the interpolation factor to 2, then 2 pixels will be inserted between every pair of pixels in the original image. For example, if the upsampling coefficient is a resolution factor and the user sets the interpolation factor to 1.5, then after interpolating the original image with a resolution of 100*100, the final image with a resolution of 150*150 will be obtained.
[0118] 104. Select the low-precision upsampling boundary pixels as the high-precision upsampling boundary pixels.
[0119] Since the interpolated low-precision boundary (i.e., the upsampled low-precision boundary) only improves the resolution but not the quality, in this embodiment, the connection status of each upsampled low-precision boundary pixel can be judged again by the ray tracing method described in step 101, so as to filter out high-quality upsampled high-precision boundary pixels.
[0120] For example, in some embodiments, the scene may also include a light source, and step 104 may include the following steps:
[0121] (1) Perform ray tracing on the upsampled low-precision boundary pixels in the scene to obtain the connection state between the light source and the upsampled low-precision boundary pixels;
[0122] (2) Based on the connection state between the light source and the upsampled low-precision boundary pixels, an upsampled low-precision shadow map is generated, and the upsampled low-precision boundary of the upsampled low-precision shadow map is determined. The upsampled low-precision boundary is composed of upsampled high-precision boundary pixels.
[0123] In some embodiments, the connectivity state may include an accessible state and an occlusion state. Step (1) "Perform ray tracing on the upsampled low-precision boundary pixels in the scene to obtain the connectivity state between the light source and the upsampled low-precision boundary pixels" may include the following steps:
[0124] When the upsampled low-precision boundary pixel and the light source are connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined as the accessible state.
[0125] Otherwise, the connection state between the light source and the upsampled low-precision boundary pixels is determined to be an occlusion state.
[0126] Therefore, by analyzing the connection state between the light source and the upsampled low-precision boundary pixels, the upsampled high-precision boundary pixels can be filtered out from the upsampled low-precision boundary pixels.
[0127] For example, in some embodiments, if the connection between the light source and the upsampled low-precision boundary pixel is accessible, then the upsampled low-precision boundary pixel is determined to be an upsampled high-precision boundary pixel; if the connection between the light source and the upsampled low-precision boundary pixel is occluded, then the upsampled low-precision boundary pixel is determined not to be an upsampled high-precision boundary pixel.
[0128] After multiple rounds of filtering until all upsampled high-precision shadow pixels are selected, the image formed by these upsampled high-precision shadow pixels is the upsampled low-precision shadow map.
[0129] Therefore, in some embodiments, the upsampled low-precision shadow map is composed of upsampled high-precision shadow pixels, and step (2) "generates an upsampled low-precision shadow map based on the connection state between the light source and the upsampled low-precision boundary pixels, and determines the upsampled low-precision boundary of the upsampled low-precision shadow map, wherein the upsampled low-precision boundary is composed of upsampled high-precision boundary pixels" may include the following steps:
[0130] When the connection state between the light source and the upsampled low-precision boundary pixel is occluded, the upsampled low-precision boundary pixel is determined to be the upsampled high-precision shadow pixel.
[0131] The boundary pixels of the upsampled high-precision shadow pixels are defined as the upsampled high-precision boundary pixels.
[0132] Boundary pixels are pixels located at the outermost edge of an image or a set of pixels.
[0133] The specific steps for ray tracing and boundary determination described above can be found in step 101, and will not be repeated here.
[0134] 105. Generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the pixels of the upsampled high-precision boundary.
[0135] Finally, a high-precision shadow map can be generated based on the upsampled high-precision boundary obtained in step 104.
[0136] There are several ways to generate high-precision shadow maps based on upsampled high-precision boundaries. For example, the color of pixels within the upsampled high-precision boundary can be uniformly set to gray, while the color of pixels outside the upsampled high-precision boundary can be uniformly set to white.
[0137] For example, a high-precision shadow map can be generated based on an upsampled high-precision boundary using a distance field shadow map.
[0138] The distance field refers to the signed distance field (SDF). The SDF value can be used to describe the distance between a point and a space. If the SDF value is negative, it means that the point is inside the space. The larger the value, the closer it is to the space surface. If the SDF value is 0, it means that the point is on the space surface. If the SDF value is positive, it means that the point is outside the space. The smaller the value, the closer it is to the space surface.
[0139] In some embodiments, the upsampled high-precision boundary is composed of upsampled high-precision boundary pixels, and step 105 can be implemented using a distance field shadow mapping method, for example:
[0140] (1) Determine the distance between the upsampled high-precision boundary pixels and the low-precision shadow pixels;
[0141] (2) Based on the distance, perform distance field shadow map generation processing to obtain a high-precision shadow map of the target model.
[0142] In some embodiments, step (2) "generating a distance field shadow map based on distance to obtain a high-precision shadow map of the target model" may include the following steps:
[0143] Determine the shortest distance among the distances between low-precision shadow pixels and all upsampled high-precision boundary pixels;
[0144] Use the shortest distance as the shadow factor for the low-precision shadow pixel of y;
[0145] Determine the high-precision shadow map of the target model, which consists of low-precision shadow pixels with shadow factors.
[0146] The shadow factor can represent the shadow effect of each pixel in the shadow map. For example, 1 represents no shadow, 0 represents the maximum shadow effect, and a value between 0 and 1 means that the pixel has a certain shadow effect.
[0147] For example, refer to Figure 1g In the low-precision shadow pixels A~L, the low-precision shadow pixel F contains 5 upsampled high-precision boundary pixels, namely f2, f5, f10, f15, and f16. Therefore, the distance D between the upsampled high-precision boundary pixel f2 and the low-precision shadow pixel C can be determined. C-f2The distance D between the upsampled high-precision boundary pixel f5 and the low-precision shadow pixel C C-f5 The distance D between the upsampled high-precision boundary pixel f10 and the low-precision shadow pixel C C-f10 The distance D between the upsampled high-precision boundary pixel f15 and the low-precision shadow pixel C C-f15 The distance D between the upsampled high-precision boundary pixel f16 and the low-precision shadow pixel C C-f16 ,etc.
[0148] Then, the shortest distance between the low-precision shadow pixel F and the low-precision shadow pixel C among the five upsampled high-precision boundary pixels of the low-precision shadow pixel F is taken as the SDF value of the low-precision shadow pixel C. For example, if D C-f2 If the minimum value is found, then the SDF value of the low-precision shadow pixel C is recorded as D. C-f2 .
[0149] Finally, the SDF value of each low-precision shadow pixel can be obtained according to the above method. The shadow factor of the low-precision shadow pixel can be determined based on the SDF value, and then the high-precision shadow map of the target model can be determined.
[0150] For example, when the SDF value is greater than or equal to 0, the shadow factor of the low-precision shadow pixel is determined to be 0. When the SDF value is less than 0, the shadow factor of the low-precision shadow pixel is determined to be the negative reciprocal of the SDF value. Then, the gray value of the low-precision shadow pixel is set to the shadow factor, and so on, so that the edges of the high-precision shadow map appear to have a blurred effect in the real world.
[0151] In some embodiments, to facilitate user control of the SDF diffusion radius, thereby freely controlling the performance of the distance field shadow map and improving the user experience, the diffusion radius refers to the radius of the gradient shadow, such as... Figure 2a As shown in (7), gradient shadow refers to the visual effect where the shadow at the boundary of a real shadow gradually changes from dark to light and then becomes no shadow.
[0152] Therefore, step (1) "determining the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel" may include the following steps:
[0153] Display the diffusion radius control, which is used to control the diffusion radius of the shadow;
[0154] The shadow diffusion area is determined in response to the operation of the diffusion radius control;
[0155] The distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel located in the shadow diffusion region is calculated and determined as the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel.
[0156] For example, refer to Figure 1h , Figure 1hThe left image shows the final high-precision shadow map effect when the shadow diffusion area is small. Figure 1h The right image shows the final high-precision shadow map effect when the shadow diffusion area is large.
[0157] As can be seen from the above, the embodiments of the present invention can obtain a low-precision shadow map of a target model in a scene; determine the low-precision boundary in the low-precision shadow map; perform upsampling processing on the low-precision boundary to obtain an upsampled low-precision boundary, which is composed of the upsampled low-precision boundary pixels; select the upsampled low-precision boundary pixels as upsampled high-precision boundary pixels; and generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking, where the upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0158] Therefore, this solution eliminates the need to process the entire low-precision shadow map; processing only the low-precision boundaries yields higher-resolution, higher-quality upsampled high-precision boundaries. These upsampled high-precision boundaries are then used to generate a high-quality high-precision shadow map. Thus, this solution improves the baking efficiency of high-precision shadow maps.
[0159] The method described in the above embodiments will be further described in detail below.
[0160] In this embodiment, game baking will be used as an example to describe the method of the present invention in detail.
[0161] This approach no longer processes the entire low-precision shadow map, but only upsamples the low-precision boundary pixels to determine the connected upsampled high-precision boundary pixels. Finally, by calculating the distance from each upsampled high-precision boundary pixel to the neighboring low-precision shadow pixel, a distance field shadow map is obtained.
[0162] like Figure 2a As shown, the specific process of a shadow baking method is as follows:
[0163] (1) Obtain the low-precision boundary in the low-precision shadow map of the target model in the scene.
[0164] For example, by directly rasterizing the target model, information such as the position, normal vector, and color of each target pixel in the target model can be obtained.
[0165] By using ray tracing, rays are emitted from the target pixel toward the light source to determine the connection status between the light source and the target pixel.
[0166] Based on the connection state, the low-precision boundary pixels of the target model are obtained, thus obtaining the low-precision boundary of the target model.
[0167] (2) Determine the low-precision boundary pixel i in the low-precision boundary.
[0168] (3) Upsample the low-precision boundary pixel i to obtain M upsampled low-precision boundary pixels corresponding to the low-precision boundary pixel i.
[0169] In some embodiments, users need to configure whether to enable distance field shadow map baking.
[0170] In some embodiments, the user needs to specify the maximum upsampling factor before upsampling processing. The larger the maximum upsampling factor, the better the final distance field shadow map effect.
[0171] For example, if the maximum upsampling coefficient can be set to 6, then the low-precision boundary pixel i is subdivided into 6*6 high-resolution upsampled low-precision boundary pixels.
[0172] In some embodiments, the user may need to specify the distance field shadow map resolution before upsampling processing; a higher distance field shadow map resolution will produce better results.
[0173] (4) Perform ray tracing processing on the M upsampled low-precision boundary pixels in sequence to obtain the connection state between the light source and the upsampled low-precision boundary pixels.
[0174] Where M is a positive integer.
[0175] In some embodiments, all upsampled low-precision boundary pixels can be placed in a boundary pixel buffer. Ray tracing is then used again on the boundary pixel buffer to emit a ray from a certain upsampled low-precision boundary pixel to the light source, thereby determining the connection status between the light source and the upsampled low-precision boundary pixel.
[0176] For example, refer to Figure 2b If the maximum upsampling factor is 6 and the number of low-precision boundary pixels is N, then the size of the corresponding boundary pixel buffer is 6*6*N.
[0177] (5) Based on the connection state between the light source and the upsampled low-precision boundary pixel, determine the upsampled high-precision boundary pixel in the low-precision boundary pixel i among the M upsampled low-precision boundary pixels.
[0178] Based on the connection state, determine whether the upsampled low-precision boundary pixel is an upsampled high-precision boundary pixel, thereby obtaining the upsampled high-precision boundary.
[0179] (6) Return and execute step 2 until all low-precision boundary pixels have been determined, thus obtaining the upsampled high-precision boundary.
[0180] (7) A distance field shadow map is generated based on the upsampled high-precision boundary to obtain a high-precision shadow map of the target model, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the pixels of the upsampled high-precision boundary.
[0181] Through testing, this solution improves the performance of distance field shadow map baking by about 5 to 10 times in different scenarios. Therefore, this solution can improve baking efficiency.
[0182] To better implement the above methods, embodiments of the present invention also provide a shadow baking apparatus, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.
[0183] For example, in this embodiment, the method of the present invention will be described in detail by taking the example of a shadow baking device specifically integrated into a personal computer.
[0184] For example, such as Figure 3 As shown, the shadow baking apparatus may include an acquisition unit 301, a determination unit 302, an upsampling unit 303, a selection unit 304, and a generation unit 305, as follows:
[0185] (a) Acquisition Unit 301.
[0186] The acquisition unit 301 can be used to acquire low-precision shadow maps of target models in the scene.
[0187] In some embodiments, the scene may further include a light source, and the acquisition unit 301 may include an acquisition subunit, a second ray tracing subunit, and a second low-sperm unit, wherein:
[0188] (1) The sub-unit can be used to acquire the target model in the scene. The target model is composed of target pixels.
[0189] (2) The second ray tracing subunit can be used to perform ray tracing on the target pixel in the scene to obtain the connection state between the light source and the target pixel.
[0190] In some embodiments, the connectivity state may include an accessible state and an obstructed state, and the second ray tracing subunit may be used for:
[0191] When the target pixel and the light source are connected, the connection state between the light source and the target pixel is defined as the accessible state;
[0192] Otherwise, the connection state between the light source and the target pixel is determined to be an occlusion state.
[0193] (3) The second low-precision subunit can be used to obtain the low-precision shadow map of the target model based on the connection state between the light source and the target pixel.
[0194] In some embodiments, the low-precision shadow map is composed of low-precision shadow pixels, and the second low-precision sub-unit can be used for:
[0195] When the connection between the light source and the target pixel is in an accessible state, the target pixel is defined as a low-precision shadow pixel.
[0196] (ii) Determine unit 302.
[0197] The determination unit 302 can be used to determine the low-precision boundaries in the low-precision shadow map.
[0198] In some embodiments, the low-precision boundary is composed of low-precision boundary pixels, and the determining unit 302 can be used for:
[0199] The boundary pixels of the low-precision shadow map are defined as low-precision boundary pixels.
[0200] (iii) Upsampling unit 303.
[0201] The upsampling unit 303 can be used to upsample the low-precision boundary to obtain the upsampled low-precision boundary, which is composed of the upsampled low-precision boundary pixels.
[0202] In some embodiments, the upsampling unit 303 can be used for:
[0203] Display a precision control that controls the precision of upsampling;
[0204] The upsampling coefficient is determined in response to the operation of the precision control control;
[0205] Based on the upsampling coefficients, the low-precision boundary is interpolated to obtain the upsampled low-precision boundary.
[0206] (iv) Select unit 304.
[0207] The selection unit 304 can be used to select upsampled low-precision boundary pixels as upsampled high-precision boundary pixels.
[0208] In some embodiments, the scene may further include a light source, and the selection unit 304 may include a ray tracing sub-unit and a low-sperm unit, wherein:
[0209] (1) The ray tracing sub-unit can be used to perform ray tracing on upsampled low-precision boundary pixels in the scene to obtain the connection state between the light source and the upsampled low-precision boundary pixels.
[0210] In some embodiments, the connectivity state may include an accessible state and an obstructed state, and the ray tracing subunit may be used for:
[0211] When the upsampled low-precision boundary pixel and the light source are connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined as the accessible state.
[0212] Otherwise, the connection state between the light source and the upsampled low-precision boundary pixels is determined to be an occlusion state.
[0213] (2) Low-precision sub-units can be used to generate upsampled low-precision shadow maps based on the connection state between the light source and the upsampled low-precision boundary pixels, and determine the upsampled low-precision boundary of the upsampled low-precision shadow map. The upsampled low-precision boundary is composed of upsampled high-precision boundary pixels.
[0214] In some embodiments, the upsampled low-precision shadow map is composed of upsampled high-precision shadow pixels, and the low-precision sub-unit can be used for:
[0215] When the connection state between the light source and the upsampled low-precision boundary pixel is occluded, the upsampled low-precision boundary pixel is determined as the upsampled high-precision shadow pixel.
[0216] The boundary pixels of the upsampled high-precision shadow pixels are defined as upsampled high-precision boundary pixels.
[0217] (v) Generation unit 305.
[0218] The generation unit 305 can be used to generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
[0219] In some embodiments, the upsampled high-precision boundary is composed of upsampled high-precision boundary pixels, and the generation unit 305 may include a distance subunit and a distance field subunit, wherein:
[0220] (1) Distance sub-unit, which can be used to determine the distance between upsampled high-precision boundary pixels and low-precision shadow pixels.
[0221] In some embodiments, the distance subunit can be used for:
[0222] Display a diffusion radius control control, which is used to control the diffusion radius of the shadow;
[0223] The shadow diffusion area is determined in response to the operation of the diffusion radius control;
[0224] The distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel located in the shadow diffusion region is calculated and determined as the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel.
[0225] (2) The distance field sub-unit can be used to generate distance field shadow maps based on distance to obtain high-precision shadow maps of the target model.
[0226] In some embodiments, the distance field subunit can be used for:
[0227] Determine the shortest distance among the distances between low-precision shadow pixels and all upsampled high-precision boundary pixels;
[0228] Use the shortest distance as the shadow factor for the low-precision shadow pixel;
[0229] Determine the high-precision shadow map of the target model, which consists of low-precision shadow pixels with shadow factors.
[0230] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.
[0231] As can be seen from the above, the shadow baking apparatus of this embodiment comprises: an acquisition unit, which can be used to acquire a low-precision shadow map of the target model in the scene; a determination unit, which can be used to determine the low-precision boundaries in the low-precision shadow map; an upsampling unit, which can be used to perform upsampling processing on the low-precision boundaries to obtain upsampled low-precision boundaries, wherein the upsampled low-precision boundaries are composed of upsampled low-precision boundary pixels; a selection unit, which can be used to select upsampled low-precision boundary pixels as upsampled high-precision boundary pixels; and a generation unit, which can be used to generate a high-precision shadow map of the target model based on the upsampled high-precision boundaries, thereby realizing shadow baking, wherein the upsampled high-precision boundaries are composed of the upsampled high-precision boundary pixels.
[0232] Therefore, the embodiments of the present invention can improve baking efficiency.
[0233] This invention also provides an electronic device, which can be a terminal, a server, or other similar devices. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers, etc.
[0234] In some embodiments, the shadow baking apparatus may also be integrated into multiple electronic devices, such as multiple servers, with multiple servers implementing the shadow baking method of the present invention.
[0235] In this embodiment, the electronic device will be used as an example for detailed description, such as... Figure 4As shown, it illustrates a structural schematic diagram of the electronic device involved in an embodiment of the present invention, specifically:
[0236] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0237] The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby performing overall detection of the electronic device. In some embodiments, the processor 401 may include one or more processing cores; in some embodiments, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 401.
[0238] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0239] The electronic device also includes a power supply 403 that supplies power to the various components. In some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0240] The electronic device may also include an input module 404, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0241] The electronic device may also include a communication module 405. In some embodiments, the communication module 405 may include a wireless module, through which the electronic device can perform short-range wireless transmission, thereby providing users with wireless broadband internet access. For example, the communication module 405 can be used to help users send and receive emails, browse web pages, and access streaming media.
[0242] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows:
[0243] Obtain the low-precision shadow texture of the target model in the scene;
[0244] Determine the low-precision boundaries in the low-precision shadow map;
[0245] The low-precision boundary is upsampled to obtain the upsampled low-precision boundary, which is composed of the pixels of the upsampled low-precision boundary.
[0246] Select the low-precision upsampling boundary pixel as the high-precision upsampling boundary pixel;
[0247] A high-precision shadow map of the target model is generated based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the pixels of the upsampled high-precision boundary.
[0248] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0249] As can be seen from the above, this solution can improve baking efficiency.
[0250] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0251] To this end, embodiments of the present invention provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the shadow baking methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:
[0252] Obtain the low-precision shadow texture of the target model in the scene;
[0253] Determine the low-precision boundaries in the low-precision shadow map;
[0254] The low-precision boundary is upsampled to obtain the upsampled low-precision boundary, which is composed of the pixels of the upsampled low-precision boundary.
[0255] Select the low-precision upsampling boundary pixel as the high-precision upsampling boundary pixel;
[0256] A high-precision shadow map of the target model is generated based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the pixels of the upsampled high-precision boundary.
[0257] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0258] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of shadow map baking or game rendering provided in the above embodiments.
[0259] Since the instructions stored in the storage medium can execute the steps of any of the shadow baking methods provided in the embodiments of the present invention, the beneficial effects that any of the shadow baking methods provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0260] The foregoing has provided a detailed description of a shadow baking method, apparatus, electronic device, and computer-readable storage medium provided by embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for shading baking, characterized in that, include: Obtain a low-precision shadow map of the target model in the scene, wherein the low-precision shadow map is composed of low-precision shadow pixels; Determine the low-precision boundaries in the low-precision shadow map; The low-precision boundary is upsampled to obtain an upsampled low-precision boundary, which is composed of upsampled low-precision boundary pixels. The upsampled low-precision boundary pixel is selected as the upsampled high-precision boundary pixel; Generating a high-precision shadow map of the target model based on an upsampled high-precision boundary includes: determining the distance between the upsampled high-precision boundary pixels and the low-precision shadow pixels; determining the shortest distance among the distances between the low-precision shadow pixels and all the upsampled high-precision boundary pixels; using the shortest distance as the shadow factor of the low-precision shadow pixels; determining the high-precision shadow map of the target model, wherein the high-precision shadow map of the target model is composed of the low-precision shadow pixels having the shadow factor, thereby achieving shadow baking; and the upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels.
2. The shadow baking method as described in claim 1, characterized in that, The scene also includes a light source, and selecting the upsampled low-precision boundary pixel as the upsampled high-precision boundary pixel includes: In the scene, ray tracing is performed on the upsampled low-precision boundary pixels to obtain the connection state between the light source and the upsampled low-precision boundary pixels; Based on the connection state between the light source and the upsampled low-precision boundary pixels, an upsampled low-precision shadow map is generated, and the upsampled low-precision boundary of the upsampled low-precision shadow map is determined, wherein the upsampled low-precision boundary is composed of upsampled high-precision boundary pixels.
3. The shadow baking method as described in claim 2, characterized in that, The connectivity state includes an accessible state and an occluded state. The step of performing ray tracing processing on the upsampled low-precision boundary pixels in the scene to obtain the connectivity state between the light source and the upsampled low-precision boundary pixels includes: When the upsampled low-precision boundary pixel and the light source are connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an accessible state. When the upsampled low-precision boundary pixel and the light source are not connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an occlusion state.
4. The shadow baking method as described in claim 2, characterized in that, The upsampled low-precision shadow map is composed of upsampled high-precision shadow pixels. The process of generating the upsampled low-precision shadow map based on the connection state between the light source and the upsampled low-precision boundary pixels, and determining the upsampled low-precision boundary of the upsampled low-precision shadow map, includes: When the connection between the light source and the upsampled low-precision boundary pixel is in an occlusion state, the upsampled low-precision boundary pixel is determined as an upsampled high-precision shadow pixel. The boundary pixels of the upsampled high-precision shadow pixels are defined as upsampled high-precision boundary pixels.
5. The shadow baking method as described in claim 1, characterized in that, The scene also includes a light source, and obtaining the low-precision shadow map of the target model in the scene includes: Obtain the target model in the scene, wherein the target model is composed of target pixels; In the scene, ray tracing is performed on the target pixel to obtain the connection state between the light source and the target pixel; Based on the connection state between the light source and the target pixel, a low-precision shadow map of the target model is obtained.
6. The shadow baking method as described in claim 5, characterized in that, The connectivity state includes an accessible state and an occluded state. The step of performing ray tracing processing on the target pixel in the scene to obtain the connectivity state between the light source and the target pixel includes: When the target pixel and the light source are connected, the connection state between the light source and the target pixel is determined to be an accessible state; When the target pixel and the light source are not connected, the connection state between the light source and the target pixel is determined to be an occlusion state.
7. The shadow baking method as described in claim 5, characterized in that, The step of obtaining a low-precision shadow map of the target model based on the connection state between the light source and the target pixel, and determining the low-precision boundary of the low-precision shadow map, includes: When the connection between the light source and the target pixel is in an accessible state, the target pixel is identified as a low-precision shadow pixel.
8. The shadow baking method as described in claim 7, characterized in that, The low-precision boundary is composed of low-precision boundary pixels, and determining the low-precision boundary in the low-precision shadow map includes: The boundary pixels of the low-precision shadow map are defined as low-precision boundary pixels.
9. The shadow baking method as described in claim 1, characterized in that, Determining the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel includes: Display a diffusion radius control control, which is used to control the diffusion radius of the shadow; In response to an operation of the diffusion radius control, the shadow diffusion area is determined; The distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel located in the shadow diffusion region is calculated and determined as the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel.
10. The shadow baking method as described in claim 1, characterized in that, The upsampling process of the low-precision boundary to obtain the upsampled low-precision boundary includes: Display precision control controls, which are used to control the precision of upsampling; In response to the operation of the precision control control, the upsampling coefficient is determined; Based on the upsampling coefficients, the low-precision boundary is interpolated to obtain the upsampled low-precision boundary.
11. A shaded baking apparatus, characterized in that, include: The acquisition unit is used to acquire a low-precision shadow map of the target model in the scene, wherein the low-precision shadow map is composed of low-precision shadow pixels; A determining unit is used to determine the low-precision boundaries in the low-precision shadow map; An upsampling unit is used to perform upsampling processing on the low-precision boundary to obtain an upsampled low-precision boundary, wherein the upsampled low-precision boundary is composed of upsampled low-precision boundary pixels. The selection unit is used to select the upsampled low-precision boundary pixel as the upsampled high-precision boundary pixel; The generation unit is used to generate a high-precision shadow map of the target model based on the upsampled high-precision boundary, thereby realizing shadow baking. The upsampled high-precision boundary is composed of the upsampled high-precision boundary pixels. The generation unit includes: A distance sub-unit is used to determine the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel; A distance field sub-unit is used to determine the shortest distance among the distances between the low-precision shadow pixels and all the upsampled high-precision boundary pixels; use the shortest distance as the shadow factor of the low-precision shadow pixel; and determine the high-precision shadow map of the target model, wherein the high-precision shadow map of the target model is composed of the low-precision shadow pixels having the shadow factor.
12. The shaded baking apparatus as claimed in claim 11, characterized in that, The scene also includes a light source, and the selection unit includes: A ray tracing subunit is used to perform ray tracing processing on the upsampled low-precision boundary pixel in the scene to obtain the connection state between the light source and the upsampled low-precision boundary pixel. The low-precision sub-unit is used to generate an upsampled low-precision shadow map based on the connection state between the light source and the upsampled low-precision boundary pixels, and to determine the upsampled low-precision boundary of the upsampled low-precision shadow map, wherein the upsampled low-precision boundary is composed of upsampled high-precision boundary pixels.
13. The shaded baking apparatus as claimed in claim 12, characterized in that, The connectivity states include accessible and blocked states, and the optical tracing subunit is used for: When the upsampled low-precision boundary pixel and the light source are connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an accessible state. When the upsampled low-precision boundary pixel and the light source are not connected, the connection state between the light source and the upsampled low-precision boundary pixel is determined to be an occlusion state.
14. The shaded baking apparatus as claimed in claim 12, characterized in that, The upsampled low-precision shadow map is composed of upsampled high-precision shadow pixels, and the low-precision sub-unit is used for: When the connection between the light source and the upsampled low-precision boundary pixel is in an occlusion state, the upsampled low-precision boundary pixel is determined as an upsampled high-precision shadow pixel. The boundary pixels of the upsampled high-precision shadow pixels are defined as upsampled high-precision boundary pixels.
15. The shaded baking apparatus as claimed in claim 11, characterized in that, The scene also includes a light source, and the acquisition unit includes: A sub-unit is used to acquire a target model in the scene, wherein the target model is composed of target pixels; The second ray tracing subunit is used to perform ray tracing processing on the target pixel in the scene to obtain the connection state between the light source and the target pixel; The second low-precision subunit is used to obtain a low-precision shadow map of the target model based on the connection state between the light source and the target pixel.
16. The shaded baking apparatus as claimed in claim 15, characterized in that, The connection state includes an accessible state and an obstructed state, and the second optical tracing subunit is used for: When the target pixel and the light source are connected, the connection state between the light source and the target pixel is determined to be an accessible state; When the target pixel and the light source are not connected, the connection state between the light source and the target pixel is determined to be an occlusion state.
17. The shaded baking apparatus as claimed in claim 15, characterized in that, The low-precision shadow map is composed of low-precision shadow pixels, and the low-precision sub-units are used for: When the connection between the light source and the target pixel is in an accessible state, the target pixel is identified as a low-precision shadow pixel.
18. The shaded baking apparatus as claimed in claim 17, characterized in that, The low-precision boundary is composed of low-precision boundary pixels, and the determining unit is used for: The boundary pixels of the low-precision shadow map are defined as low-precision boundary pixels.
19. The shaded baking apparatus as claimed in claim 11, characterized in that, The distance subunit is used for: Display a diffusion radius control control, which is used to control the diffusion radius of the shadow; In response to an operation of the diffusion radius control, the shadow diffusion area is determined; The distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel located in the shadow diffusion region is calculated and determined as the distance between the upsampled high-precision boundary pixel and the low-precision shadow pixel.
20. The shaded baking apparatus as claimed in claim 11, characterized in that, The upsampling unit is used for: Display precision control controls, which are used to control the precision of upsampling; In response to an operation on the precision control control, an upsampling coefficient is determined; Based on the upsampling coefficients, the low-precision boundary is interpolated to obtain the upsampled low-precision boundary.
21. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps in the shadow baking method as described in any one of claims 1 to 10.
22. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the shadow baking method according to any one of claims 1 to 10.
23. A computer program product, characterized in that, The computer program product stores computer instructions adapted for loading by a processor to execute the shadow baking method according to any one of claims 1 to 10.