A local Blit cascade shadow mapping method based on tile-based partitioning algorithm
Patent Information
- Application Number
- CN202311837315.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2043-12-27
AI Technical Summary
但分帧更新可能会导致动态物体阴影出现瑕疵
[0031] Beneficial Effects: Compared with existing technologies, this invention provides an accelerated rendering method based on the fundamental idea of frame-by-frame updates and separate rendering of shadows for dynamic and static objects. In the generation of cascading shadows, this invention distinguishes between dynamic and static objects, rendering shadow maps for each type of object separately. This improves rendering performance by reducing the rendering and updating frequency of distant static objects. Utilizing the sparsity of dynamic objects, the shadow pixels of dynamic objects are represented in tiles, and tiles with shadow pixels are merged with the shadows of static objects through local blending, thus improving the rendering speed of real-time shadows. This invention simply and efficiently improves the rendering speed and accuracy of existing frame-by-frame update cascading shadow mapping algorithms.
Smart Images

Figure CN117765151B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of real-time rendering in computer graphics, and relates to cascaded shadow mapping technology, specifically a local Blit cascaded shadow mapping method based on the Tile-Based block algorithm. Background Technology
[0002] Shadow mapping involves drawing a scene shadow map from the light source's perspective, then drawing the scene from the camera's perspective to compare the depth of the shadow map with the light source's space. The purpose of shadow mapping is to simulate the shadow effects produced by light sources on objects in a 3D scene. Because real-time rasterization rendering pipelines do not conform to the physical rules of the real world, achieving photorealistic rendering is very difficult. Shadow mapping is a simple method for implementing real-time shadows and is currently the mainstream real-time rendering shadow technology.
[0003] Cascaded shadow mapping is an improvement on traditional shadow mapping. It divides the camera's view frustum into multiple levels, generating multiple shadow maps, each using a different resolution to improve the accuracy of shadows on distant objects. Therefore, it's primarily used for shadow effects from sunlight in open scenes. Cascaded shadows achieve optimal rendering by updating the transformation matrix and cascaded shadow maps every frame. On mobile devices, cascaded shadow mapping typically needs acceleration. For view frustums far from the camera, frame-by-frame updates can reduce performance overhead. However, frame-by-frame updates may cause imperfections in the shadows of dynamic objects. Real-time shadow rendering on mobile devices must consider hardware limitations. Updating the entire scene's shadow map every frame places considerable rendering pressure on mobile GPUs. Summary of the Invention
[0004] Purpose of the invention: To overcome the shortcomings of existing technologies, this invention provides a local Blit cascade shadow mapping method based on a Tile-Based block algorithm. This method separates the real-time shadow rendering and updating of static and dynamic objects. By dividing the shadow map using the Tile-Based block algorithm and merging the shadow maps of static and dynamic objects through locally Blit-matched tiles, the rendering speed of cascade shadows and the accuracy of dynamic object shadows are improved.
[0005] Technical Solution: To achieve the above objectives, this invention provides a local Blit cascaded shadow mapping method based on a Tile-Based block algorithm, comprising the following steps:
[0006] S1: Mark static and dynamic objects in the scene, and segment the camera view frust according to different strategies;
[0007] S2: Render the scene based on the position and direction of the light source, and obtain cascaded shadow maps of static and dynamic objects according to different update frequencies;
[0008] S3: Tile the cascaded shadow map of dynamic objects;
[0009] S4: Traverse all tiles and merge the dynamic object shadows with the static object shadows of the tiles that meet the pixel requirements through a local Blit operation;
[0010] S5: Obtain the standard device coordinate system vertex coordinates from the deferred rendering geometry buffer and restore the world space coordinates;
[0011] S6: Render the scene from the camera position and orientation, transform the vertices to the light space, and compare the depth of the vertex with the shadow map to determine whether it is a shadow and the level of the shadow.
[0012] Furthermore, the strategy for segmenting the camera's view frustum in step S1 is as follows: static objects are divided into multiple view frustum levels, while dynamic objects directly adopt the view frustum level of the 0th or more layers predefined by the static objects.
[0013] Furthermore, the method for rendering the scene from the light source position and direction in step S2 is as follows: the scene is rendered using orthographic projection based on the light source position and direction, and the vertex coordinates in the standard device coordinate system are obtained after perspective division, specifically expressed as:
[0014]
[0015] Where r, l, t, and b represent the rightmost, leftmost, topmost, and bottommost coordinates of the viewport, respectively, and f and n represent the far-plane and near-plane coordinates of the view frustum, respectively.
[0016] Furthermore, in step S2, the method for obtaining cascaded shadow maps of static and dynamic objects according to different update frequencies is as follows: for static objects, the distant part of the view frustum should be updated once every few frames, while static and dynamic objects closer to the camera should be updated every frame. The obtained shadow maps of static and dynamic objects are merged into a single shadow map, and the offset texture coordinates are calculated based on the shadow level when used, as specifically shown below:
[0017]
[0018] Where u and v represent texture coordinates transformed from screen space coordinates, u′ and v′ represent the left side of the texture mapped onto the shadow map, m and n represent the number of rows and columns of the cascaded shadow on a map, and i and j represent the offset of the texture coordinates on the horizontal and vertical coordinates, respectively.
[0019] Furthermore, the tile-based processing in step S3 involves dividing the shadow map into several tiles according to a certain strategy.
[0020] Furthermore, in step S4, all tiles are traversed. If any pixel in a tile is a shadow pixel, the entire tile will merge the shadow of the dynamic object with the shadow of the static object through a local Blit operation.
[0021] Furthermore, in step S4, the method for merging the shadows of dynamic and static objects is as follows: depending on the different standard device coordinate system specifications of mainstream graphics application interfaces, the minimum and maximum depths are taken as the merging result. The specific operation is as follows:
[0022] p(u,v)=min(p s (u,v).z,p d (u,v).z) (3)
[0023] Where p, p s p d These represent the pixels written by the fragment shader, the pixels of the dynamic object shadow map, and the pixels of the static object shadow map at the corresponding texture coordinates, respectively, where z represents the depth value of the sampled texture.
[0024] Further, step S5 specifically involves: reading the depth buffer from the deferred rendering geometry buffer, converting the depth to linear depth, and reconstructing the world space coordinates from the vertex coordinates in the standard device coordinate system based on the screen space coordinates. The specific operations are as follows:
[0025]
[0026] Among them z′, These are the depth values of the sampling depth buffer, the inverse of the observation matrix and the projection matrix, respectively, p ndc p w These are the vertex coordinates of the standard equipment coordinate system and the world space coordinates, respectively.
[0027] Further, step S6 specifically involves: rendering the scene from the camera position and orientation, transforming the vertices of the world space coordinate system to the light source space, and then transforming them to the screen space to obtain the texture coordinates of the sampled shadow map. The specific operations are as follows:
[0028]
[0029] Where p ndc ′、M vp ′ represents the standard device coordinates in the light source space, the light source space view transformation, and the projection transformation matrix, respectively. The texture coordinates of the UV sampling shadow map are used to determine whether a vertex is a shadow and its level by comparing the depth of the vertex in the standard device coordinates with the depth of the sampling shadow map.
[0030] The method of this invention is based on the Tile-Base block algorithm. It calculates shadow maps separately for static and dynamic objects, thereby reducing the update frequency of static object shadows and reducing overhead. However, the shadows of dynamic objects are more sensitive and need to be updated in real time. Therefore, the shadow maps of the first layer of static objects and the shadow maps of dynamic objects are merged in real time to improve the performance of cascaded shadow mapping.
[0031] Beneficial Effects: Compared with existing technologies, this invention provides an accelerated rendering method based on the fundamental idea of frame-by-frame updates and separate rendering of shadows for dynamic and static objects. In the generation of cascading shadows, this invention distinguishes between dynamic and static objects, rendering shadow maps for each type of object separately. This improves rendering performance by reducing the rendering and updating frequency of distant static objects. Utilizing the sparsity of dynamic objects, the shadow pixels of dynamic objects are represented in tiles, and tiles with shadow pixels are merged with the shadows of static objects through local blending, thus improving the rendering speed of real-time shadows. This invention simply and efficiently improves the rendering speed and accuracy of existing frame-by-frame update cascading shadow mapping algorithms. Attached Figure Description
[0032] Figure 1 This is an overall flowchart of the method of the present invention;
[0033] Figure 2 The tile provided in this embodiment. Detailed Implementation
[0034] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading this invention, any modifications of the invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.
[0035] like Figure 1 As shown, this invention provides a local Blit cascaded shadow mapping method based on the Tile-Based block algorithm, comprising the following steps:
[0036] S1: Mark static and dynamic objects in the scene, and segment the camera view frustum according to different strategies:
[0037] Mark static and dynamic objects in the scene: Mark them during the scene creation phase of the rendering engine, or use different shaders and materials.
[0038] Different strategies are used to segment the camera view frustum: static objects are segmented using a low-frequency, low-precision, and multi-level strategy; dynamic objects are segmented using a high-frequency, high-precision, and small-range strategy; static objects can be divided into more view frustum levels, while dynamic objects directly use the view frustum levels of the static objects, such as level 0 or higher.
[0039] Since shadow maps covering the entire scene cannot meet rendering requirements with limited map resolution, dynamic objects within the camera's view frustum are divided into multiple layers. This results in multiple shadow maps of the same resolution but different coverage areas. During rendering, the appropriate resolution shadow map is selected based on the object's location. Due to the pyramid structure of the view frustum, layers closer to the camera have higher resolution, which is more sensitive to the user. Dynamic objects are segmented directly using the 0th layer of the static object's view frustum, eliminating the need for conversion during merging. If a larger coverage area of the dynamic object's shadow is required, the number of view frustum layers can be increased based on the static object's view frustum.
[0040] In this embodiment, the static object is divided into three layers of truncated cones according to its distance, while the dynamic object directly adopts the first truncated cone of the static object.
[0041] S2: Render the scene based on the position and direction of the light source, and obtain cascaded shadow maps for static and dynamic objects according to different update frequencies:
[0042] The scene is rendered using orthographic projection based on the light source position and direction. After perspective division, the vertex coordinates in the standard device coordinate system are obtained, specifically represented as follows:
[0043]
[0044] Where r, l, t, and b represent the rightmost, leftmost, topmost, and bottommost coordinates of the viewport, respectively, and f and n represent the far-plane and near-plane coordinates of the view frustum, respectively.
[0045] The method for obtaining cascaded shadow maps for static and dynamic objects based on different update frequencies is as follows: When calculating shadows, the three layers of view frustum for static objects are rendered to obtain three shadow maps of the same precision, while the one layer of view frustum for dynamic objects obtains one shadow map. For objects that are close together, the first layer of shadow map for static objects and the shadow map for dynamic objects should be updated every frame. For objects that are far apart, the other layers of shadow maps for static objects should be updated every few frames to reduce the amount of real-time shadow calculation. Four shadow maps can be merged into one Atlas map. During rendering, a single large texture does not need to switch rendering states, so in this example, the performance is better than four small textures. When using it, the texture coordinates after offset are calculated according to the shadow level, as shown below:
[0046]
[0047] Where u and v represent texture coordinates transformed from screen space coordinates, u′ and v′ represent the left side of the texture mapped onto the shadow map, m and n represent the number of rows and columns of the cascaded shadow on a map, and i and j represent the offset of the texture coordinates on the horizontal and vertical coordinates, respectively.
[0048] S3: Tile the cascading shadow map of dynamic objects:
[0049] Following a SIMD hardware-friendly strategy, the shadow map is divided into several tiles, typically with a size that is a multiple of 4, such as 8*32; the tiles obtained in this embodiment are as follows: Figure 2 As shown.
[0050] S4: Traverse all tiles and merge the dynamic object shadows with the static object shadows of the tiles that meet the pixel requirements using a local Blit operation:
[0051] Traverse all tiles. If any pixel in a tile is a shadow pixel, then the entire tile will merge the shadows of dynamic objects with the shadows of static objects through a local Blit operation.
[0052] Here, "Blit" is a rendering term referring to two textures, one source and one destination, computed in the fragment shader. Typically, a blob sends the entire texture to the shader. A local blob, on the other hand, only sends a portion of the texture (i.e., a divided tile).
[0053] Depending on the different standard device coordinate system specifications of mainstream graphics application interfaces, the minimum and maximum depths are taken as the merged result. The specific operation is as follows:
[0054] p(u,v)=min(p s (u,v).z,p d (u,v).z) (3)
[0055] Where p, p s p d These represent the pixels written by the fragment shader, the pixels of the dynamic object shadow map, and the pixels of the static object shadow map at the corresponding texture coordinates, respectively, where z represents the depth value of the sampled texture.
[0056] After merging the dynamic object shadow map and the static object shadow map, in order to use the merged shadow map to calculate the rendering result, steps S5 and S6 need to be performed.
[0057] S5: Read the depth buffer from the deferred rendering geometry buffer, convert the depth to linear depth, and reconstruct the world space coordinates from the standard device coordinate system vertex coordinates based on the screen space coordinates. The specific operations are as follows:
[0058]
[0059] Among them z′, These are the depth values of the sampling depth buffer, the inverse of the observation matrix and the projection matrix, respectively, p ndc p w These are the vertex coordinates of the standard equipment coordinate system and the world space coordinates, respectively.
[0060] S6: Render the scene from the camera position and orientation, transform the vertices of the world space coordinate system to the light source space, and then transform them to the screen space to obtain the texture coordinates of the sampled shadow map. The specific operations are as follows:
[0061]
[0062] Where p ndc ′、M vp ′ represents the standard device coordinates in the light source space, the light source space view transformation, and the projection transformation matrix, respectively. The texture coordinates of the UV sampling shadow map are used to determine whether a vertex is a shadow and its level by comparing the depth of the vertex in the standard device coordinates with the depth of the sampling shadow map.
Claims
1. A local Blit cascaded shadow mapping method based on a Tile-Based block algorithm, characterized in that, Includes the following steps: S1: Mark static and dynamic objects in the scene, and segment the camera view frust according to different strategies; S2: Render the scene based on the position and direction of the light source, and obtain cascaded shadow maps of static and dynamic objects according to different update frequencies; S3: Tile the cascaded shadow map of dynamic objects; S4: Traverse all tiles and merge the shadows of dynamic objects with the shadows of static objects using a local Blit operation on tiles that meet the pixel requirements; S5: Obtain the standard device coordinate system vertex coordinates from the deferred rendering geometry buffer and restore the world space coordinates; S6: Render the scene from the camera position and orientation, transform the vertices to the light space, and compare the depth of the vertex with the shadow map to determine whether it is a shadow and the level of the shadow. In step S2, the cascaded shadow maps of static and dynamic objects are obtained according to different update frequencies as follows: For static objects, the distant parts of the view frustum should be updated once every few frames, while static and dynamic objects closer to the camera should be updated every frame. The obtained shadow maps of static and dynamic objects are merged into a single shadow map. When using the map, the offset texture coordinates are calculated based on the shadow level, as shown below: ; in, , These represent the texture coordinates transformed from screen space coordinates. , These represent the left side of the texture mapped onto the shadow map. , These represent the number of rows and columns that the cascading shadow divides on a single image. , These represent the offsets of the texture coordinates on the horizontal and vertical axes, respectively. In step S4, all tiles are traversed. If any pixel in a tile is a shadow pixel, the shadow of the dynamic object is merged with the shadow of the static object through a local Blit operation. In step S4, the method for merging the shadows of dynamic and static objects is as follows: depending on the standard device coordinate system specification of the graphics application interface, the minimum and maximum depths are taken as the merging result. The specific operation is as follows: ; in , , These represent the pixels written by the fragment shader at the corresponding texture coordinates, the pixels of the dynamic object shadow map, and the pixels of the static object shadow map, respectively. This is represented as the depth value of the sampled texture.
2. The local Blit cascaded shadow mapping method based on the Tile-Based block algorithm according to claim 1, characterized in that, The strategy for segmenting the camera's view frustum in step S1 is as follows: static objects are divided into multiple view frustum levels, while dynamic objects directly use the view frustum level of the static object, which is the 0th or more layers.
3. The local Blit cascaded shadow mapping method based on the Tile-Based block algorithm according to claim 1, characterized in that, The method for rendering the scene based on the light source position and direction in step S2 is as follows: The scene is rendered using orthographic projection based on the light source position and direction. After perspective division, the vertex coordinates in the standard device coordinate system are obtained, specifically as follows: (1); in, , , , These represent the rightmost, leftmost, topmost, and bottommost coordinates of the viewport, respectively. , These represent the far-plane coordinates and near-plane coordinates of the view cone, respectively.
4. The local Blit cascaded shadow mapping method based on the Tile-Based block algorithm according to claim 3, characterized in that, The tile-based processing in step S3 involves dividing the shadow map into several tiles.
5. A local Blit cascaded shadow mapping method based on a Tile-Based block algorithm according to claim 4, characterized in that, Step S5 specifically involves: reading the depth buffer from the deferred rendering geometry buffer, converting the depth to linear depth, and reconstructing the world space coordinates from the vertex coordinates in the standard device coordinate system based on the screen space coordinates. The specific operations are as follows: (4); in , These are the depth values of the sampling depth buffer, the inverse of the observation matrix, and the inverse of the projection matrix, respectively. , These are the vertex coordinates of the standard equipment coordinate system and the world space coordinates, respectively.
6. A local Blit cascaded shadow mapping method based on a Tile-Based block algorithm according to claim 5, characterized in that, Step S6 specifically involves: rendering the scene based on the camera position and orientation, transforming the vertices of the world space coordinate system to the light source space, and then converting them to the screen space to obtain the texture coordinates of the sampled shadow map. The specific operations are as follows: ; in , These are the standard device coordinates in the light source space, the light source space view transformation matrix, and the projection transformation matrix, respectively. The texture coordinates of the sampled shadow map are used to determine whether a vertex is a shadow and its level by comparing the depth of the vertex in the standard device coordinate system with the depth of the sampled shadow map.
Citation Information
Patent Citations
Image rendering method and device, computer equipment and storage medium
CN112884875A
Shadow rendering method and device based on Monte Carlo method
CN114998506A