A real-time generation and anti-jitter rendering method of cascaded shadows

By employing an adjustable hybrid cascade segmentation strategy and a stabilized PCF method, the problems of jagged, jagged, and flickering shadow edges in cascaded shadow technology were solved, thereby improving the clarity and stability of shadow edges and meeting the visual consistency and real-time requirements of high-quality graphics rendering.

CN122115687APending Publication Date: 2026-05-29HANGZHOU DETE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU DETE INFORMATION TECH CO LTD
Filing Date
2026-02-06
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing cascaded shadow technology suffers from jagged shadow edges, interlacing, or loss of accuracy when trying to balance near-view accuracy and far-view coverage. Shadow maps also exhibit jaggedness and flickering. Furthermore, the perturbation patterns and transition bandwidth of shadow sampling areas lack unified modeling, resulting in limited rendering efficiency and scalability.

Method used

We employ an adjustable hybrid cascaded segmentation strategy, an axis-aligned bounding box grid alignment mechanism, and a stable PCF method based on rotating Poisson disk sampling to construct a complete processing flow, including view frustum cascaded slicing, stable bounding box construction, light view and orthogonal projection matrix generation, unified light UBO management, fragment shadow index determination, boundary region weight fusion, and final shadow factor generation.

Benefits of technology

It achieves flexible shadow partitioning, strong jitter suppression in projection areas, good anti-aliasing effect of sampling offset, natural and smooth boundary transition, and unified and efficient rendering structure, significantly improving the clarity and stability of shadow edges and meeting the visual consistency and real-time requirements of high-quality graphics rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115687A_ABST
    Figure CN122115687A_ABST
Patent Text Reader

Abstract

The application discloses a kind of real-time generation and anti-jitter rendering method of cascaded shadow, comprising: setting camera parameter and segmentation configuration, construct cascaded segmentation structure;According to light source direction and view cone slice, calculate axisymmetric bounding box and execute texel alignment, generate stabilized projection boundary;Construct the light source view matrix and orthogonal projection matrix of each cascade, output two-dimensional array depth texture and uniform light buffer object;In the fragment stage, according to the depth and normal, calculate main cascade index and offset, use stabilized PCF sampling and rotation distribution mode, improve anti-jitter ability;Using screen space Bayer threshold and normalized distance calculation fusion weight, realize cross-cascade smooth transition;Finally, get stable shadow rendering output.The application has the advantages of high rendering stability, natural boundary transition and significant anti-jitter effect, and is suitable for multi-cascade, multi-light large-scale scene real-time shadow rendering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer graphics and real-time rendering technology, and in particular to a method for real-time generation and anti-jitter rendering of cascading shadows. Background Technology

[0002] In real-time graphics rendering, shadow generation is a key method to enhance the sense of space and realism in images. Among them, cascaded shadows are widely used in games, simulation training, and virtual reality scenarios because they balance near-view accuracy with far-view coverage. However, existing cascaded shadow technology still has several shortcomings in practical applications.

[0003] First, traditional cascaded segmentation methods often employ fixed linear or logarithmic segmentation strategies, making it difficult to simultaneously ensure both near-field shadow accuracy and far-field shadow integrity. This leads to issues such as jagged shadow edges, interlacing, or loss of accuracy, affecting the visual consistency of the scene. Some methods attempt to introduce hybrid segmentation, but they do not provide adjustable parameters, making it difficult to adapt to the dynamic needs of different scenes.

[0004] Secondly, when constructing the light projection matrix, the minimum bounding box is often generated directly using the view frustum slice points without pixel-level alignment of the boundaries. This leads to bounding box jumps caused by minute camera movements, resulting in shadow map jitter and flickering, affecting visual stability and user experience. Furthermore, existing methods lack a fine-grained processing mechanism for axisymmetric raster alignment of the bounding box using texel steps, thus failing to fundamentally solve the jitter problem.

[0005] Furthermore, while the commonly used PCF technique can achieve soft shadow effects during the shadow sampling stage, aliasing and abrupt changes occur in the boundary areas, making it impossible to smoothly blend multi-cascaded shadow results. Most systems do not introduce screen-space anti-jitter mechanisms, and lack unified modeling of the perturbation patterns and transition bandwidth of the shadow sampling area, resulting in rough shadow boundaries and unnatural transitions, especially noticeable in low-resolution rendering. The lack of efficient transmission and calling structures for unified management of view matrices and projection matrices under multi-cascaded and multi-light source conditions in existing graphics APIs makes it difficult to quickly determine and schedule sampling of fragment-level shadow states, limiting rendering efficiency and scalability.

[0006] Therefore, how to provide a real-time generation and anti-jitter rendering method for cascading shadows is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] One objective of this invention is to propose a real-time generation and anti-jitter rendering method for cascaded shadows. This invention fully integrates an adjustable hybrid cascaded segmentation strategy, an axis-aligned bounding box raster alignment mechanism, and a stabilized PCF method based on rotating Poisson disk sampling. It constructs a complete processing flow including view frustum cascaded slicing, stable bounding box construction, light view and orthogonal projection matrix generation, unified light UBO management, fragment shadow index determination, boundary region weight fusion, and final shadow factor generation. This achieves shadow accuracy assurance and enhanced boundary stability in multi-light source and complex scenes. This invention possesses advantages such as flexible shadow partitioning, strong projection region jitter suppression capability, good sampling offset anti-aliasing effect, natural and smooth boundary transitions, and a unified and efficient rendering structure. It can significantly improve the clarity and stability of shadow edges in real-time rendering, overcoming problems such as shadow flickering, jumping, abrupt blending, and insufficient coverage in existing methods, meeting the visual consistency and real-time requirements of high-quality graphics rendering.

[0008] A method for real-time generation and anti-jitter rendering of cascading shadows according to an embodiment of the present invention includes the following steps:

[0009] S1. Set the distance between the near and far planes of the camera, initialize the direction of the main light source and the number of cascades N, and set the cascade splitting parameters. Generate a cascaded split configuration;

[0010] S2. Using the cascaded segmentation configuration and camera frustum parameters, the frustum is divided into N cascaded regions. The orthogonal projection range of each region in the light space is calculated. The slice corner points are transformed to the light view space. An axis-aligned bounding box AABB_L is constructed. The boundary grid is aligned according to the shadow map texel step size. The stable cascaded bounding box is output.

[0011] S3. Generate the corresponding light view matrix and orthographic projection matrix through the stabilized cascaded bounding box, render the depth of scene geometry, output a two-dimensional array depth texture, and output a unified light UBO;

[0012] S4. Input a two-dimensional array of depth texture and light UBO, determine the main concatenation index based on the pixel NDC depth, use the stabilized PCF method to sample the depth texture, select the rotation index by combining the low bits of the fragment screen coordinates, calculate the receiving surface offset and normal offset by combining the fragment normal, the lighting direction and the depth gradient, and output the single concatenation shadow result.

[0013] S5. Input the single cascade shadow result and the fragment world space depth. When the fragment is located at the cascade boundary, calculate the normalized distance and call the screen space Bayer threshold matrix to determine the blending weight. Output the blended shadow result of adjacent cascades.

[0014] S6. Based on the mixed shadow results of adjacent cascades and the single cascade shadow results of non-boundary regions, combined with the runtime adjustable PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and segmentation coefficient. This integrates and generates shadow rendering output.

[0015] Optionally, S1 specifically includes:

[0016] S11. Read the camera configuration file, and input the near plane distance of the camera as the starting depth of the cascaded segmentation and the far plane distance as the ending depth.

[0017] S12. Initialize the main light source direction, set the light source to illuminate from a predefined direction, and obtain the three-dimensional direction vector of the light source in world space by converting the elevation angle and tilt angle through trigonometric functions. Calculate the horizontal, vertical and height components of the vector, and after normalizing the vector, store the direction vector in the system parameters.

[0018] S13. Set the number of cascades N, and determine the number of segmentation layers based on the scene's requirements for shadow accuracy and coverage.

[0019] S14, Input segmentation parameters , The value of is between 0 and 1, representing the mixing ratio of linear and logarithmic partitioning;

[0020] S15. For cascaded partitions, calculate the corresponding logarithmic depth position, which is obtained by scaling logarithmically between the near and far planes. Calculate the linear depth position of the partition, which is obtained by dividing the near and far planes at equal intervals. The values ​​of are weighted proportionally between the logarithmic and linear results to obtain the actual depth boundary values ​​of the cascade.

[0021] S16. Repeat the calculation process to obtain the depth boundary values ​​of all cascaded partitions in turn;

[0022] S17. Calculate the camera's near-plane distance, far-plane distance, main light source direction, number of cascaded units N, and segmentation parameters. All cascaded depth boundary values ​​are output together to form a cascaded split configuration.

[0023] Optionally, S2 specifically includes:

[0024] S21. Extract the sequence of depth boundary values ​​contained in the cascaded segmentation configuration, and read the two boundary depth values ​​numbered i and i+1 in sequence as the starting depth and ending depth of the current cascaded region.

[0025] S22. For the starting and ending depths of the cascaded region, read the camera's vertical field of view and aspect ratio. At the starting and ending depths, calculate half the height as the depth multiplied by half the field of view tangent, and half the width as the height divided by the aspect ratio. Take the positive and negative values ​​and translate them to combine them into four corner points of the front and rear planes, generating eight three-dimensional coordinate points as the complete view frustum section boundary of the current cascaded region.

[0026] S23. Read the direction vector of the light source and set a fixed upward direction. Use the observation matrix function provided in the graphics library to make the light source look towards the center of the scene and generate a transformation matrix that observes the world from the perspective of the light source. Input the calculated eight three-dimensional coordinate points into this transformation matrix one by one, calculate the new position coordinates under the perspective of the light source, and obtain the transformed point coordinate array.

[0027] S24. Read all the values ​​of the eight coordinate points after transformation in the horizontal, vertical and depth directions respectively. In each direction, find the minimum and maximum values ​​respectively to obtain three minimum values ​​and three maximum values, which represent the boundary range of the cascade along each axis in the light source space. Combine these six values ​​into a set of six tuples as the axis-aligned bounding box boundary AABB_L of the current cascade.

[0028] S25. Read the horizontal and vertical resolutions of the current shadow map as integers, subtract the minimum value from the maximum horizontal value of AABB_L to obtain the projection width, divide the projection width by the number of horizontal pixels of the map to obtain the actual projection length of the horizontal texel, and calculate the vertical value in the same way. The texel is the smallest pixel unit used to represent shadows in the texture map.

[0029] S26. Divide the minimum horizontal value of AABB_L by the texel width, round down, and multiply back by the texel width. Divide the maximum value by the texel width, round up, and multiply back by the texel width. This will align the boundaries of AABB_L with the pixel grid in both the horizontal and vertical directions, resulting in a stable cascaded bounding box.

[0030] S27. Output the AABB_L boundary after texel alignment obtained from each cascade calculation as a six-dimensional vector, corresponding to the horizontal minimum, vertical minimum, depth minimum, horizontal maximum, vertical maximum, and depth maximum values ​​respectively, and store them in an array in cascade order as a set of stable shadow regions.

[0031] Optionally, S3 specifically includes:

[0032] S31. Read the minimum and maximum values ​​of AABB_L in the horizontal, vertical and depth directions of the cascaded region. Set the light source direction vector and the fixed upward direction as parameters and input them into the camera observation matrix function. Read the average of the six boundaries of AABB_L to obtain the center point. Set the light source direction vector and the fixed upward direction. Subtract the light source direction from the center point and multiply it by a fixed distance to obtain the light source position. Input the light source position, center point and upward direction into the observation matrix function to generate the light view matrix.

[0033] S32. Fill the six boundary values ​​in AABB_L into the parameters of the orthogonal projection matrix respectively. The minimum and maximum values ​​in the horizontal direction are used as the left and right boundaries, the minimum and maximum values ​​in the vertical direction are used as the top and bottom boundaries, and the minimum and maximum values ​​in the depth direction are used as the near and far planes. Call the orthogonal projection function in the graphics library to generate the cascaded corresponding orthogonal projection matrix.

[0034] S33. Multiply the light view matrix generated in the first two steps with the orthogonal projection matrix by matrix multiplication to obtain the complete transformation matrix;

[0035] S34. Prepare the target layer for rendering in the current cascade and bind it to the corresponding layer of the two-dimensional array depth texture. Using the graphics interface, set the current transformation matrix as the input of the vertex shader, traverse all visible geometry, perform projection on the triangles, output only the depth value, and write the result into the depth map generated by the current layer to form a shadow map. Output the two-dimensional array depth texture after writing is completed.

[0036] S35. Take the current light number and the current cascade number as two integers, multiply the light number by the total number of cascade layers, add the current cascade number to get a unique layer index value, and write the layer index to the position of the two-dimensional array depth texture.

[0037] S36. Fill the light view matrix, orthographic projection matrix and depth boundary value into the structure in order. Generate a structure instance for each cascade layer. Arrange all structures in ascending order of cascade index to form a structure array. Call the graphics API interface to create a unified buffer object (UBO). Write the structure array as a contiguous memory block into the UBO and bind it to a fixed buffer slot. Output the unified light UBO.

[0038] Optionally, S4 specifically includes:

[0039] S41. Based on the stabilized PCF method, during the fragment coloring stage, the normalized device coordinate depth value (NDC) of the current pixel is read, and the NDC depth value is compared with the segmentation depth interval of each cascade one by one. The first cascade index that satisfies "depth value is less than the upper boundary of segmentation" is found and used as the main cascade index of the current pixel.

[0040] S42. Read the two-dimensional array depth texture, determine the layer number of pixel sampling according to the main concatenation index and the light number, multiply the world space position of the fragment by the light view matrix and the orthogonal projection matrix in turn to obtain the homogeneous clip space coordinates, perform homogeneous division to obtain the standard device coordinates in the range of -1 to 1, and linearly map the standard device coordinates to 0 to 1 according to the components to obtain the normalized sampling coordinates of the corresponding texture.

[0041] S43. In the two-dimensional array depth texture sampling, the sampling pattern is loaded from the preset rotating Poisson disk sequence or blue noise distribution. According to the low bit value of the screen coordinate of the fragment, the rotation index is selected as the sampling direction. The corresponding sampling point coordinates are rotated to obtain the anti-jitter sampling position set. The rotated coordinates are used as the sampling offset position. The sampling is performed in the two-dimensional array depth texture to generate the shadow judgment value set.

[0042] S44. Read the depth texture value for each offset sampling point and compare it with the depth value after the current fragment transformation. Calculate the sampling ratio that is less than the fragment depth and use it as the shadow factor.

[0043] S45. Read the fragment normal vector and the illumination direction vector, calculate the dot product and take the inverse cosine to get the angle, determine the tilt of the receiving surface based on the angle, calculate the depth gradient around the pixel in the light space along the illumination direction to get the depth change rate, multiply the tilt by a preset coefficient to get the depth offset of the receiving surface, multiply the depth change rate by the normal alignment to get the normal offset, convert them into light space length units, add them to the fragment depth and sampling depth and then compare them.

[0044] S46. After completing all depth texture sampling and offset calculations for the current pixel in the determined main cascade based on the stabilized PCF method, calculate the ratio between the number of sampling points falling into the shadow area and the total number of sampling points, generate the shadow factor of the pixel, and output the shadow factor as the single cascade shadow result of the current fragment.

[0045] Optionally, S5 specifically includes:

[0046] S51. Read the single cascade shadow result of the current fragment under the main cascade, and read the depth value of the fragment in world space. Take out all cascade segmentation depth thresholds from the uniform light UBO in sequence, determine which two adjacent cascades the segmentation depth value is located between, and subtract the smaller segmentation depth from the segmentation depth value, divide by the difference between the two segmentation depths to obtain the normalized distance.

[0047] S52. Round down the horizontal and vertical coordinates of the fragment on the screen, extract the two least significant bits of the integer, and concatenate the two least significant bits of the horizontal coordinate with the two least significant bits of the vertical coordinate to form a 4-bit binary index value. Use the index value to look up the floating-point value at the corresponding position in the pre-set screen space Bayer threshold matrix, and use it as the dither threshold of the current fragment.

[0048] S53. Compare the normalized distance value with the dither threshold. If the distance value is less than the threshold, set the fusion weight to 1, indicating that the current pixel fully adopts the shadow result of the main cascade. If the distance value is greater than or equal to the threshold, construct a linear scaling factor based on the distance value and use it as a weight. Multiply the shadow results of the current main cascade and the next cascade by the corresponding weights and sum them to obtain the fused shadow result.

[0049] S54. Determine whether the generated blending weight value is less than 1. If so, directly use the blending shadow result as the final blending value of the current fragment. If the blending weight is 1, it means that the current fragment is not in the cascade boundary area. Then directly use the shadow factor of the main cascade as the current blending result. Regardless of the source of the blending weight, the final blending result is uniformly output as the shadow value of the current pixel, and the blending shadow result of the adjacent cascade is output.

[0050] Optionally, S6 specifically includes:

[0051] S61. Read the depth value of the current pixel in world space, traverse the start and end depth values ​​of each cascade in the Unified Light UBO, determine whether it falls within the depth range of a certain cascade, if so, determine it as the main cascade, read the start depth value of the next cascade, calculate the difference between the current pixel depth value and the start depth of the next cascade, if the difference is less than the preset transition bandwidth threshold, it is in the boundary area between the main cascade and the next cascade.

[0052] S62. If it is in the boundary area, read the blended shadow result of the adjacent concatenation generated in the previous step; if it is not in the boundary area, read the single concatenation shadow result of the current pixel under the main concatenation.

[0053] S63. Read the six configuration values ​​from the runtime parameters: PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and split coefficient, and store them in the constant buffer of the fragment shader.

[0054] S64. Use the light view matrix and orthogonal projection matrix to transform the world space coordinates into normalized sampling coordinates. Based on the PCF kernel size and the preset sampling offset pattern, generate multiple offset sampling points. Read the sampling depth value one by one and compare it with the light space depth. If the sampling depth is greater than the fragment depth plus the offset, it is recorded as unoccluded. Calculate the proportion of unoccluded samples in all samples and use it as the occlusion ratio factor of the current pixel.

[0055] S65. The occlusion ratio factor calculated for each pixel is written as the gray value of the current pixel in the output shadow image and written to the corresponding position. The gray value range is 0 to 1. After all pixels are processed, a two-dimensional image is generated as the final stabilized shadow rendering output.

[0056] The beneficial effects of this invention are:

[0057] This invention proposes a real-time generation and anti-jitter rendering method for cascaded shadows. Addressing the issues of uneven segmentation leading to accuracy loss, unstable bounding regions causing shadow jitter, and severe sampling aliasing affecting edge transitions in existing real-time shadow rendering, this invention employs an adjustable hybrid segmentation method combining linear and logarithmic depth partitioning strategies to balance near-field accuracy and far-field coverage. By constructing an axisymmetric bounding box aligned with the light direction and introducing a texture resolution-aware texel-level boundary alignment mechanism, the spatial stability of the bounding region is improved. During the fragment sampling stage, a stable PCF method is established by integrating a rotated Poisson disk distribution and a screen coordinate-based perturbation offset strategy, significantly enhancing the smoothness and anti-jitter capability of edge shadows. This invention possesses advantages such as adaptive cascaded segmentation accuracy, anti-jitter bounding region, natural shadow edge transitions, and stable sampling distribution with anti-aliasing, effectively solving problems such as boundary flickering, abrupt layering changes, and rendering artifacts in traditional cascaded shadows in dynamic scenes, significantly improving shadow quality and visual consistency. Attached Figure Description

[0058] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0059] Figure 1 This is a flowchart of a real-time generation and anti-jitter rendering method for cascading shadows proposed in this invention;

[0060] Figure 2 This is a flowchart of the axisymmetric bounding box construction and texel alignment stabilization process based on the light source space proposed in this invention.

[0061] Figure 3 This is a flowchart of the fragment-level shadow determination process based on the fusion weight adjustment of stabilized PCF and dither proposed in this invention. Detailed Implementation

[0062] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0063] refer to Figure 1-3 A real-time generation and anti-jitter rendering method for cascading shadows includes the following steps:

[0064] S1. Set the distance between the near and far planes of the camera, initialize the direction of the main light source and the number of cascades N, and set the cascade splitting parameters. It is used to control the ratio of linear and logarithmic mixed segmentation, thereby balancing near-field accuracy and far-field coverage, and generating cascaded segmentation configurations;

[0065] S2. Using the cascaded segmentation configuration and camera frustum parameters, the frustum is divided into N cascaded regions. The orthogonal projection range of each region in the light space is calculated. The slice corner points are transformed to the light view space. An axis-aligned bounding box AABB_L is constructed. The boundary grid is aligned according to the shadow map texel step size. The stable cascaded bounding box is output to improve shadow stability and reduce jitter caused by small changes in viewing angle.

[0066] S3. Through the stable cascaded bounding box, generate the corresponding light view matrix and orthogonal projection matrix, render the scene geometry depth, output a two-dimensional array depth texture, the layer index is jointly encoded by the light number and the cascade index, and output a unified light UBO, which contains all projection matrices and segmentation depth, for use in the fragment stage.

[0067] S4. Input a two-dimensional array of depth texture and light UBO. In the fragment shading stage, determine the main concatenation index based on the pixel NDC depth. Use the stabilized PCF method to sample the depth texture. The sampling points are based on the rotating Poisson disk or blue noise distribution. Combine the low-bit bits of the fragment screen coordinates to select the rotation index. Combine the fragment normal, the lighting direction and the depth gradient to calculate the receiving surface offset and normal offset. Output the single concatenation shadow result.

[0068] S5. Input the single cascade shadow result and the fragment world space depth. When the fragment is located at the cascade boundary, calculate the normalized distance and call the screen space Bayer threshold matrix to determine the blending weight. Output the blended shadow result of adjacent cascades for smooth boundary transition.

[0069] S6. Based on the mixed shadow results of adjacent cascades and the single cascade shadow results of non-boundary regions, combined with the runtime adjustable PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and segmentation coefficient. This process integrates and generates the final, stable shadow rendering output.

[0070] This implementation achieves real-time shadow effects with clear edges, natural layer transitions, and stable overall performance in complex scenes by constructing a stable cascaded shadow generation and anti-jitter rendering process. The system sets the distance between the camera's near and far planes, initializes the main light source direction and the number of cascades N, and configures segmentation parameters to generate a cascaded segmentation configuration, achieving a dynamic balance between high-precision shadows in near-field areas and large-scale coverage in far-field areas. An AABB_L bounding box aligned with the texture pixel grid is constructed using the view frustum and segmentation configuration to improve projection stability and reduce shadow jumps caused by viewpoint movement. A light view and projection matrix are generated based on the stable bounding box, a scene geometry depth map is rendered, and a two-dimensional array depth texture and a unified light UBO are output, enabling efficient fragment access to multi-cascaded information. At the fragment stage, a stable PCF method is used for rotating Poisson disk or blue noise pattern sampling, and the rotation direction is selected based on the fragment screen coordinates. The shadow offset is calculated by fusing fragment normals, lighting direction, and depth gradients to generate an anti-jitter single-cascaded shadow result. For cascaded boundary fragments, a fusion weight is constructed using a Bayer matrix, and this weighted fusion is performed with the adjacent cascaded results to avoid stitching artifacts. Finally, the cascaded shadow results are integrated, and combined with runtime adjustable parameters, to output a high-quality, stable, and continuous shadow image.

[0071] In this embodiment, S1 specifically includes:

[0072] S11. Read the camera configuration file, and input the near plane distance of the camera as the starting depth of the cascaded segmentation and the far plane distance as the ending depth.

[0073] S12. Initialize the main light source direction, set the light source to illuminate from a predefined direction, and obtain the three-dimensional direction vector of the light source in world space by converting the elevation angle and tilt angle through trigonometric functions. Calculate the horizontal, vertical and height components of the vector, and after normalizing the vector, store the direction vector in the system parameters as the input for the subsequent light view matrix.

[0074] S13. Set the number of cascades N. Determine the number of segmentation layers based on the scene's requirements for shadow accuracy and coverage. Calculate the distance range from the near plane to the far plane. If the range is less than 50 meters and there are a large number of close-range fine models in the scene, set N to 4 or more to improve the sampling accuracy of the near shadow edges. If the range is greater than 50 meters and includes distant large buildings or terrain projections, set N to 3 or more to expand the shadow coverage.

[0075] S14, Input segmentation parameters , The value of λ is between 0 and 1, representing the mixing ratio of linear segmentation and logarithmic segmentation. The closer λ is to 0, the more it is biased towards logarithmic segmentation, which enhances the accuracy of near depth. The closer λ is to 1, the more it is biased towards linear segmentation, which enhances the overall coverage uniformity.

[0076] S15. For cascaded partitions, calculate the corresponding logarithmic depth position, which is obtained by scaling logarithmically between the near and far planes. Calculate the linear depth position of the partition, which is obtained by dividing the near and far planes at equal intervals. The values ​​of are weighted proportionally between the logarithmic and linear results to obtain the actual depth boundary values ​​for the cascade:

[0077] ;

[0078] in Indicates the first The depth segmentation boundary values ​​corresponding to each cascaded slice Indicates the near-plane distance of the camera. Indicates the distance of the camera to the far plane. This represents the currently processed cascading index, where N represents the total number of cascading levels. For the segmentation mixing coefficient, This indicates that the values ​​a and b are weighted together. Perform linear interpolation;

[0079] S16. Repeat the calculation process to obtain the depth boundary values ​​of all cascaded partitions in turn, so that the near-distance area has high depth accuracy and the far-distance area has complete coverage.

[0080] S17. Calculate the camera's near-plane distance, far-plane distance, main light source direction, number of cascaded units N, and segmentation parameters. All cascaded depth boundary values ​​are output together to form a cascaded segmentation configuration, which can be called by subsequent frustum slicing and bounding box construction steps.

[0081] This implementation generates cascaded segmentation configurations that meet the needs of different scenes by setting camera parameters and light source direction, thereby achieving a dynamic balance between shadow accuracy and coverage. The camera configuration file is read, and the distances between the near and far planes are input as the cascaded segmentation depth range. The main light source direction is initialized, and a three-dimensional direction vector is calculated based on the elevation and tilt angles, normalized, and stored in the system parameters. The number of cascades, N, is set, and the number of layers is adaptively selected based on the scene's detail and depth range. The segmentation blending parameter λ is input to control the ratio of linear to logarithmic division, achieving higher accuracy in the near field and complete coverage in the far field. The actual depth boundary values ​​for each cascade are calculated by proportionally weighting the logarithmic and linear depth results. The camera distance, light source direction, number of cascade layers, and depth boundary values ​​are uniformly encapsulated into a cascaded segmentation configuration for use in subsequent steps.

[0082] In this embodiment, S2 specifically includes:

[0083] S21. Extract the sequence of depth boundary values ​​contained in the cascaded segmentation configuration, and read the two boundary depth values ​​numbered i and i+1 in sequence as the starting depth and ending depth of the current cascaded region, which are used to construct the clipping depth range of the cascaded region.

[0084] S22. For the starting and ending depths of the cascaded region, read the camera's vertical field of view and aspect ratio. At the starting and ending depths, calculate half the height as the depth multiplied by half the field of view tangent, and half the width as the height divided by the aspect ratio. Take the positive and negative values ​​and translate them to combine them into four corner points of the front and rear planes, generating eight three-dimensional coordinate points as the complete view frustum section boundary of the current cascaded region.

[0085] S23. Read the direction vector of the light source and set a fixed upward direction. Use the observation matrix function provided in the graphics library to make the light source look towards the center of the scene and generate a transformation matrix that observes the world from the perspective of the light source. Input the calculated eight three-dimensional coordinate points into this transformation matrix one by one, calculate the new position coordinates under the perspective of the light source, and obtain the transformed point coordinate array.

[0086] S24. Read all the values ​​of the eight coordinate points after transformation in the horizontal, vertical and depth directions respectively. In each direction, find the minimum and maximum values ​​respectively to obtain three minimum values ​​and three maximum values, which represent the boundary range of the cascade along each axis in the light source space. Combine these six values ​​into a set of six tuples as the axis-aligned bounding box boundary AABB_L of the current cascade.

[0087] S25. Read the horizontal and vertical resolutions of the current shadow map as integers, subtract the minimum value from the maximum horizontal value of AABB_L to obtain the projection width, divide the projection width by the number of horizontal pixels of the map to obtain the actual projection length of the horizontal texel, and calculate the vertical value in the same way. The texel is the smallest pixel unit used to represent shadows in the texture map.

[0088] S26. Divide the minimum horizontal value of AABB_L by the texel width, round down, and multiply back by the texel width. Divide the maximum value by the texel width, round up, and multiply back by the texel width. This will align the boundaries of AABB_L with the pixel grid in both the horizontal and vertical directions, resulting in a stable cascaded bounding box.

[0089] S27. Output the AABB_L boundary after texel alignment obtained from each cascade calculation as a six-dimensional vector, corresponding to the minimum horizontal value, minimum vertical value, minimum depth value, maximum horizontal value, maximum vertical value, and maximum depth value, respectively. Store them in an array in cascade order as a stable set of shadow regions for subsequent orthogonal projection matrix construction, ensuring that the bounding range does not jump when the camera moves slightly, thus improving the stability of shadow rendering.

[0090] This implementation constructs stable cascaded bounding boxes to achieve stable projection of shadow regions under minute changes in camera viewpoint, significantly improving the anti-jitter capability of shadow rendering. Each cascaded depth boundary value is sequentially read, and the eight corner points of the corresponding view frustum section are calculated. After transformation to the light source viewpoint coordinate system, an axis-aligned bounding box AABB_L is generated. Furthermore, the actual texel length is calculated based on the shadow map resolution, and the AABB_L boundary is aligned at the texel granularity to avoid projection boundary jumps caused by pixel jitter. A stable, aligned bounding box set is output, providing a precise range for constructing the orthogonal projection matrix and ensuring the consistency and rendering quality of cascaded shadows in dynamic scenes.

[0091] In this embodiment, S3 specifically includes:

[0092] S31. Read the minimum and maximum values ​​of AABB_L in the horizontal, vertical and depth directions of the cascaded region. Set the light source direction vector and the fixed upward direction as parameters and input them into the camera observation matrix function. Read the average of the six boundaries of AABB_L to obtain the center point. Set the light source direction vector and the fixed upward direction. Subtract the light source direction from the center point and multiply it by a fixed distance to obtain the light source position. Input the light source position, center point and upward direction into the observation matrix function to generate the light view matrix. Convert the world coordinates into the light source view coordinates.

[0093] S32. Fill the six boundary values ​​in AABB_L into the parameters of the orthogonal projection matrix respectively. The minimum and maximum values ​​in the horizontal direction are used as the left and right boundaries, the minimum and maximum values ​​in the vertical direction are used as the top and bottom boundaries, and the minimum and maximum values ​​in the depth direction are used as the near and far planes. Call the orthogonal projection function in the graphics library to generate the cascaded corresponding orthogonal projection matrix.

[0094] S33. Multiply the light view matrix generated in the first two steps with the orthogonal projection matrix by matrix multiplication to obtain a complete transformation matrix that directly maps objects in the scene from world coordinates to the light source projection space. The complete transformation matrix will be used to project the three-dimensional points in the scene onto the two-dimensional depth texture during the depth map rendering process.

[0095] S34. Prepare the target layer for rendering in the current cascade and bind it to the corresponding layer of the two-dimensional array depth texture. Use a graphics interface, such as OpenGL's FrameBuffer binding, set the current transformation matrix as the input of the vertex shader, traverse all visible geometry, perform projection on the triangles, output only the depth value, and write the result into the depth map generated by the current layer to form a shadow map. Output the two-dimensional array depth texture after writing is completed.

[0096] S35. Take the current light number and the current cascade number as two integers, multiply the light number by the total number of cascade layers, add the current cascade number to get a unique layer index value, which is used to identify which light and which layer the current depth map belongs to. Write the layer index into the position of the two-dimensional array depth texture to achieve accurate differentiation under multiple lights and multiple cascades.

[0097] S36. Fill the light view matrix, orthographic projection matrix, and depth boundary values ​​into the structure in sequence. Generate a structure instance for each cascade. Arrange all structures in ascending order of cascade index to form a structure array. Call the graphics API interface to create a unified buffer object (UBO). Write the structure array as a contiguous memory block into the UBO and bind it to a fixed buffer slot. Output the unified light UBO for subsequent fragment shaders to perform cascade selection and matrix calls during the shadow determination stage.

[0098] This implementation constructs a complete transformation link from world space to light source projection space by generating a light view matrix and an orthogonal projection matrix, achieving a high-precision shadow mapping foundation. A stable AABB_L is used to precisely set the illumination range, ensuring that shadows are unaffected by camera micro-motion. A two-dimensional array depth texture and a unique layer indexing mechanism are employed to support accurate depth writing and fast indexing under multiple light cascades. Finally, each cascade matrix and boundary are encapsulated in the form of a structure and written to a unified light UBO, enabling fast access to all cascade configurations at the fragment stage, improving shadow judgment efficiency and rendering coherence.

[0099] In this embodiment, S4 specifically includes:

[0100] S41. Based on the stabilized PCF method, in the fragment coloring stage, the normalized device coordinate depth value of the current pixel, i.e., the NDC depth value, is read, and the NDC depth value is compared with the segmentation depth interval of each cascade one by one. The first cascade index that satisfies "depth value is less than the upper boundary of segmentation" is found and used as the main cascade index of the current pixel, which is used to select the depth map and projection matrix of the corresponding layer.

[0101] S42. Read the two-dimensional array depth texture, determine the layer number of pixel sampling according to the main concatenation index and the light number, multiply the world space position of the fragment by the light view matrix and the orthogonal projection matrix in turn to obtain the homogeneous clip space coordinates, transform the coordinates into homogeneous clip space coordinates, perform homogeneous division to obtain the standard device coordinates in the range of -1 to 1, and linearly map the standard device coordinates to 0 to 1 according to the components to obtain the normalized sampling coordinates of the corresponding texture.

[0102] S43. In the two-dimensional array depth texture sampling, the sampling pattern is loaded from the preset rotating Poisson disk sequence or blue noise distribution. According to the low bit value of the screen coordinate of the fragment, the rotation index is selected as the sampling direction. The corresponding sampling point coordinates are rotated so that all sampling points are offset around the current pixel position in the selected direction to obtain the anti-jitter sampling position set. The rotated coordinates are used as the sampling offset position. Sampling is performed in the two-dimensional array depth texture to generate a set of shadow judgment values ​​for the current pixel.

[0103] S44. Read the depth texture value for each offset sampling point and compare it with the depth value after the current fragment transformation. Calculate the sampling ratio that is less than the fragment depth and use it as the shadow factor.

[0104] S45. Read the fragment normal vector and the illumination direction vector, calculate the dot product and take the inverse cosine to get the angle, determine the tilt of the receiving surface based on the angle, calculate the depth gradient around the pixel in the light space along the illumination direction to get the depth change rate, multiply the tilt by a preset coefficient to get the depth offset of the receiving surface, multiply the depth change rate by the normal alignment to get the normal offset, convert them into light space length units, add them to the fragment depth and sampling depth and then compare them.

[0105] S46. After completing all depth texture sampling and offset calculations for the current pixel in the determined main cascade based on the stabilized PCF method, calculate the ratio between the number of sampling points falling into the shadow area and the total number of sampling points, generate the shadow factor of the pixel, and output the shadow factor as the single cascade shadow result of the current fragment.

[0106] The implementation method rapidly determines the main concatenation index using NDC depth, achieving precise correspondence between pixels and concatenated layers and avoiding unnecessary sampling overhead. Rotational anti-jitter sampling is performed using standardized coordinates and the main concatenation depth map, with the rotation direction dynamically selected by combining low-order bits of the screen coordinates, significantly reducing shadow flicker caused by pixel jitter. Furthermore, the offset between the receiving surface and the normal is calculated by combining fragment normals and illumination directions, enhancing shadow edge accuracy and reducing floating and light leakage phenomena. The occlusion ratio is statistically analyzed under the stabilized PCF method to generate high-quality single-concatenation shadow results, laying a stable and jitter-resistant shadow foundation for subsequent concatenation fusion and final rendering output.

[0107] In this embodiment, S5 specifically includes:

[0108] S51. Read the single cascade shadow result of the current fragment under the main cascade, and read the depth value of the fragment in world space. Take out all cascade segmentation depth thresholds from the uniform light UBO in sequence, determine which two adjacent cascades the segmentation depth value is located between, and subtract the smaller segmentation depth from the segmentation depth value, divide by the difference between the two segmentation depths to obtain the normalized distance.

[0109] S52. Round down the horizontal and vertical coordinates of the fragment on the screen, extract the two least significant bits of the integer, and concatenate the two least significant bits of the horizontal coordinate with the two least significant bits of the vertical coordinate to form a 4-bit binary index value. Use the index value to look up the floating-point value at the corresponding position in the pre-set screen space Bayer threshold matrix, and use it as the dither threshold of the current fragment.

[0110] S53. Compare the normalized distance value with the dither threshold. If the distance value is less than the threshold, set the fusion weight to 1, indicating that the current pixel fully adopts the shadow result of the main cascade. If the distance value is greater than or equal to the threshold, construct a linear scaling factor based on the distance value and use it as a weight. Multiply the shadow results of the current main cascade and the next cascade by the corresponding weights and sum them to obtain the fused shadow result.

[0111] S54. Determine whether the generated blending weight value is less than 1. If so, directly use the blending shadow result as the final blending value of the current fragment. If the blending weight is 1, it means that the current fragment is not in the cascade boundary area. Then directly use the shadow factor of the main cascade as the current blending result. Regardless of the source of the blending weight, the final blending result is uniformly output as the shadow value of the current pixel, and the blending shadow result of the adjacent cascade is output.

[0112] This implementation method accurately determines whether a fragment is located in the cascade boundary region by dynamically comparing the world space depth value with the cascade segmentation depth in the Unified Lighting Object (UBO). Combined with the Bayer matrix, a pixel-level jitter threshold is generated to avoid obvious edge breaks and stripe artifacts in the blending band. The blending process employs a linear weighted transition strategy to achieve a smooth transition between adjacent cascades. This preserves the high-quality shadows of the main cascade while effectively blending the coverage information of subsequent cascades, significantly improving the naturalness and continuity of shadow boundaries. This ensures stable, jitter-free shadow rendering even in complex scenes or with large-scale changes in field of view.

[0113] In this embodiment, S6 specifically includes:

[0114] S61. Read the depth value of the current pixel in world space, traverse the start and end depth values ​​of each cascade in the Unified Light UBO, determine whether it falls within the depth range of a certain cascade, if so, determine it as the main cascade, read the start depth value of the next cascade, calculate the difference between the current pixel depth value and the start depth of the next cascade, if the difference is less than the preset transition bandwidth threshold, it is in the boundary area between the main cascade and the next cascade.

[0115] S62. If it is in the boundary area, read the blended shadow result of the adjacent concatenation generated in the previous step; if it is not in the boundary area, read the single concatenation shadow result of the current pixel under the main concatenation.

[0116] S63. Read the six configuration values ​​from the runtime parameters: PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and split coefficient, and store them in the constant buffer of the fragment shader.

[0117] S64. Use the light view matrix and orthogonal projection matrix to transform the world space coordinates into normalized sampling coordinates. Based on the PCF kernel size and the preset sampling offset pattern, generate multiple offset sampling points. Read the sampling depth value one by one and compare it with the light space depth. If the sampling depth is greater than the fragment depth plus the offset, it is recorded as unoccluded. Calculate the proportion of unoccluded samples in all samples and use it as the occlusion ratio factor of the current pixel.

[0118] S65. The occlusion ratio factor calculated for each pixel is written as the gray value of the current pixel in the output shadow image and written to the corresponding position. The gray value ranges from 0 to 1, representing the shadow intensity. After all pixels are processed, a two-dimensional image is generated as the final stabilized shadow rendering output.

[0119] This implementation dynamically determines the pixel's position within each cascade depth range, intelligently selecting between single-cascaded or blended shadow results. Combined with runtime adjustable PCF core configuration and transition bandwidth, it achieves flexible shadow sampling control. At the fragment stage, it utilizes the matrix and depth boundary provided by the Unified Light Object (UBO) to efficiently transform coordinates, accurately locating the sampling area. Combined with sampling offset patterns and occlusion ratio calculations, it outputs pixel-by-pixel shadow grayscale values. The resulting 2D shadow image possesses high spatial consistency and anti-jitter capabilities, effectively avoiding shadow edge flickering, jagged artifacts, or jagged edges, ensuring rendering stability and visual continuity of shadows in dynamic scenes.

[0120] Example 1:

[0121] To verify the feasibility and application value of this invention in a real-world engineering system, it was deployed on a "digital twin platform for intelligent loading and unloading operations" under a coastal port group. This platform is used to present the real-time operational status of equipment such as gantry cranes, rail-mounted cranes, and AGV transport vehicles within the yard around the clock. Combined with free-viewpoint switching and day / night lighting simulation, it places extremely high demands on the realism and stability of dynamic shadows. However, under the original CSM cascaded shadow scheme, under conditions of rapid movement of near-field equipment, frequent viewpoint switching, and low-angle lighting, shadow edges frequently jitter, there are obvious discontinuities at cascade boundaries, and shadows in distant areas are easily missing. This seriously affects the dispatcher's judgment of shading status and operational anomalies, and even leads to multiple misjudgments of gantry crane interference and shading positions. Especially in multi-light source high frame rate mode, the system's GPU load increases sharply, and the frame rate fluctuates drastically, limiting the visualization and interactive capabilities of the digital twin platform.

[0122] To address the aforementioned issues, this invention proposes a cascaded shadow generation method based on segmentation, axisymmetric bounding boxes, and stable PCF fusion anti-jitter, which is then introduced into the existing graphics rendering pipeline. In the cascaded depth segmentation stage, a logarithmic equalization strategy is employed to optimize the distribution ratio, significantly enhancing the edge details of the shadows of the near-viewing bridge crane foundation and track. An axisymmetric bounding box is introduced to construct an orthogonal projection matrix of the light source, reducing the disturbance of the shadow projection boundary caused by dynamic changes in the view frustum, maintaining consistency between the ground and building shadow areas even with frequent changes in viewing angle. In the cascaded fusion stage, a fusion weight based on screen coordinates is used to avoid the sideband flickering problem caused by hard switching between traditional multi-cascaded methods, improving visual continuity. Finally, combined with a stable PCF structure, shadow jaggedness and high-frequency jumps are greatly suppressed, resulting in more natural shadow transitions and more realistic textures throughout the scene.

[0123] To compare and verify the actual effect of the present invention, comparative tests were conducted on the platform under various scenarios, including continuous operation for 7 days, coverage of low light conditions at dawn and dusk, high-frequency camera switching, and multi-device collaborative motion. The comparison was between the original CSM solution and the optimized fusion solution of the present invention. During the test, typical areas such as the bridge crane base, the track area vehicle body, and the shadows of the port tower crane were selected. Key indicators such as shadow edge jumping frequency, cascade boundary error, distant view occlusion loss rate, system frame rate fluctuation, and shadow retention rate under complex lighting conditions were recorded. The results are shown in Table 1.

[0124] Table 1. Detailed performance comparison between the shadow optimization method of the present invention and the traditional CSM scheme.

[0125] Test Project Original CSM Plan Optimization scheme of the present invention Foreground shadow edge jumping frequency 7.8 0.6 Shadow boundary flash rate 12.3% 1.1% Integrity of distant shadows 90.6% 99.6% Mid-range transition continuous scoring 5.4 9.2 Average number of stable samples per frame 8.0 8.0 Number of misjudgments due to sharp-angle highlight occlusion 6.3 0.8 GPU core utilization 74.2% 78.9% Average frame rate in multi-source mode 48.1 54.6 Frame rate fluctuation range ±11.3 ±4.7 Average response delay 0.78 0.46 Shading retention rate at oblique light angle (<20°) 84.6% 98.2% Edge discrimination error rate under rain and fog conditions 9.8% 2.3% Number of false alarms triggered in highlight aliasing areas 42 7 Number of operator misjudgments of interference events 15 3

[0126] As shown in Table 1, the cascaded shadow optimization method proposed in this invention exhibits significant advantages over the original CSM scheme in several key performance indicators. Regarding visual stability, the near-field shadow edge jitter frequency significantly decreased from 7.8 in the original scheme to 0.6, and the shadow boundary flicker rate also decreased from 12.3% to 1.1%, indicating that the stabilized PCF algorithm effectively reduced jitter and fragmentation at hierarchical boundaries. In terms of distant scene rendering, shadow integrity improved from 90.6% to 99.6%, ensuring the continuity of shadows for distant objects and enhancing overall spatial perception.

[0127] In mid-range performance, the continuous layer transition score improved from 5.4 to 9.2, indicating that the segmentation method optimized by axisymmetric bounding boxes improved the smooth transition effect between mid-range layers. Although the average number of stable samples per frame remained at 8.0, this invention achieved quality without degradation, that is, the structural sampling strategy was optimized without reducing quality. In terms of misjudgment in high-reflection areas, the number of misjudgments of sharp-corner highlight occlusion decreased from 6.3 to 0.8, the edge discrimination error rate in rain and fog environments decreased from 9.8% to 2.3%, and the number of false alarms triggered in highlight aliasing areas also decreased significantly from 42 to 7, fully verifying the effectiveness of the dither stable fusion and anti-shake mechanism under illumination disturbances.

[0128] Regarding hardware utilization and frame rate performance, although the average GPU core utilization slightly increased to 78.9%, the average frame rate in multi-light source mode improved from 48.1 to 54.6, and the frame rate fluctuation range was compressed from ±11.3 to ±4.7, indicating that the system maintains good real-time performance and stability while maintaining high-quality rendering. In addition, the average response latency decreased from 0.78 seconds to 0.46 seconds, and the occlusion retention rate in scenes with oblique light angles of less than 20° improved to 98.2%, further demonstrating the occlusion accuracy of this invention in complex lighting environments.

[0129] At the operational level, the number of operator error intervention events was reduced from 15 to 3, verifying the actual improvement of the invention in terms of user-friendliness and error suppression. In summary, the invention achieves comprehensive optimization in visual consistency, anti-interference capability, rendering stability, and real-time system feedback, and has broad application value in high-precision graphics rendering scenarios.

[0130] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for real-time generation and anti-jitter rendering of cascading shadows, characterized in that, Includes the following steps: S1. Set the distance between the near and far planes of the camera, initialize the direction of the main light source and the number of cascades N, and set the cascade splitting parameters. Generate a cascaded split configuration; S2. Using the cascaded segmentation configuration and camera frustum parameters, the frustum is divided into N cascaded regions. The orthogonal projection range of each region in the light space is calculated. The slice corner points are transformed to the light view space. An axis-aligned bounding box AABB_L is constructed. The boundary grid is aligned according to the shadow map texel step size. The stable cascaded bounding box is output. S3. Generate the corresponding light view matrix and orthographic projection matrix through the stabilized cascaded bounding box, render the depth of scene geometry, output a two-dimensional array depth texture, and output a unified light UBO; S4. Input a two-dimensional array of depth texture and light UBO, determine the main concatenation index based on the pixel NDC depth, use the stabilized PCF method to sample the depth texture, select the rotation index by combining the low bits of the fragment screen coordinates, calculate the receiving surface offset and normal offset by combining the fragment normal, the lighting direction and the depth gradient, and output the single concatenation shadow result. S5. Input the single cascade shadow result and the fragment world space depth. When the fragment is located at the cascade boundary, calculate the normalized distance and call the screen space Bayer threshold matrix to determine the blending weight. Output the blended shadow result of adjacent cascades. S6. Based on the mixed shadow results of adjacent cascades and the single cascade shadow results of non-boundary regions, combined with the runtime adjustable PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and segmentation coefficient. This integrates and generates shadow rendering output.

2. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S1 specifically includes: S11. Read the camera configuration file, and input the near plane distance of the camera as the starting depth of the cascaded segmentation and the far plane distance as the ending depth. S12. Initialize the main light source direction, set the light source to illuminate from a predefined direction, and obtain the three-dimensional direction vector of the light source in world space by converting the elevation angle and tilt angle through trigonometric functions. Calculate the horizontal, vertical and height components of the vector, and after normalizing the vector, store the direction vector in the system parameters. S13. Set the number of cascades N, and determine the number of segmentation layers based on the scene's requirements for shadow accuracy and coverage. S14, Input segmentation parameters , The value of is between 0 and 1, representing the mixing ratio of linear and logarithmic partitioning; S15. For cascaded partitions, calculate the corresponding logarithmic depth position, which is obtained by scaling logarithmically between the near and far planes. Calculate the linear depth position of the partition, which is obtained by dividing the near and far planes at equal intervals. The values ​​of are weighted proportionally between the logarithmic and linear results to obtain the actual depth boundary values ​​of the cascade. S16. Repeat the calculation process to obtain the depth boundary values ​​of all cascaded partitions in turn; S17. Calculate the camera's near-plane distance, far-plane distance, main light source direction, number of cascaded units N, and segmentation parameters. All cascaded depth boundary values ​​are output together to form a cascaded split configuration.

3. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S2 specifically includes: S21. Extract the sequence of depth boundary values ​​contained in the cascaded segmentation configuration, and read the two boundary depth values ​​numbered i and i+1 in sequence as the starting depth and ending depth of the current cascaded region. S22. For the starting and ending depths of the cascaded region, read the camera's vertical field of view and aspect ratio. At the starting and ending depths, calculate half the height as the depth multiplied by half the field of view tangent, and half the width as the height divided by the aspect ratio. Take the positive and negative values ​​and translate them to combine them into four corner points of the front and rear planes, generating eight three-dimensional coordinate points as the complete view frustum section boundary of the current cascaded region. S23. Read the direction vector of the light source and set a fixed upward direction. Use the observation matrix function provided in the graphics library to make the light source look towards the center of the scene and generate a transformation matrix that observes the world from the perspective of the light source. Input the calculated eight three-dimensional coordinate points into this transformation matrix one by one, calculate the new position coordinates under the perspective of the light source, and obtain the transformed point coordinate array. S24. Read all the values ​​of the eight coordinate points after transformation in the horizontal, vertical and depth directions respectively. In each direction, find the minimum and maximum values ​​respectively to obtain three minimum values ​​and three maximum values, which represent the boundary range of the cascade along each axis in the light source space. Combine these six values ​​into a set of six tuples as the axis-aligned bounding box boundary AABB_L of the current cascade. S25. Read the horizontal and vertical resolutions of the current shadow map as integers, subtract the minimum value from the maximum horizontal value of AABB_L to obtain the projection width, divide the projection width by the number of horizontal pixels of the map to obtain the actual projection length of the horizontal texel, and calculate the vertical value in the same way. The texel is the smallest pixel unit used to represent shadows in the texture map. S26. Divide the minimum horizontal value of AABB_L by the texel width, round down, and multiply back by the texel width. Divide the maximum value by the texel width, round up, and multiply back by the texel width. This will align the boundaries of AABB_L with the pixel grid in both the horizontal and vertical directions, resulting in a stable cascaded bounding box. S27. Output the AABB_L boundary after texel alignment obtained from each cascade calculation as a six-dimensional vector, corresponding to the horizontal minimum, vertical minimum, depth minimum, horizontal maximum, vertical maximum, and depth maximum values ​​respectively, and store them in an array in cascade order as a set of stable shadow regions.

4. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S3 specifically includes: S31. Read the minimum and maximum values ​​of AABB_L in the horizontal, vertical and depth directions of the cascaded region. Set the light source direction vector and the fixed upward direction as parameters and input them into the camera observation matrix function. Read the average of the six boundaries of AABB_L to obtain the center point. Set the light source direction vector and the fixed upward direction. Subtract the light source direction from the center point and multiply it by a fixed distance to obtain the light source position. Input the light source position, center point and upward direction into the observation matrix function to generate the light view matrix. S32. Fill the six boundary values ​​in AABB_L into the parameters of the orthogonal projection matrix respectively. The minimum and maximum values ​​in the horizontal direction are used as the left and right boundaries, the minimum and maximum values ​​in the vertical direction are used as the top and bottom boundaries, and the minimum and maximum values ​​in the depth direction are used as the near and far planes. Call the orthogonal projection function in the graphics library to generate the cascaded corresponding orthogonal projection matrix. S33. Multiply the light view matrix generated in the first two steps with the orthogonal projection matrix by matrix multiplication to obtain the complete transformation matrix; S34. Prepare the target layer for rendering in the current cascade and bind it to the corresponding layer of the two-dimensional array depth texture. Using the graphics interface, set the current transformation matrix as the input of the vertex shader, traverse all visible geometry, perform projection on the triangles, output only the depth value, and write the result into the depth map generated by the current layer to form a shadow map. Output the two-dimensional array depth texture after writing is completed. S35. Take the current light number and the current cascade number as two integers, multiply the light number by the total number of cascade layers, add the current cascade number to get a unique layer index value, and write the layer index to the position of the two-dimensional array depth texture. S36. Fill the light view matrix, orthographic projection matrix and depth boundary value into the structure in order. Generate a structure instance for each cascade layer. Arrange all structures in ascending order of cascade index to form a structure array. Call the graphics API interface to create a unified buffer object (UBO). Write the structure array as a contiguous memory block into the UBO and bind it to a fixed buffer slot. Output the unified light UBO.

5. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S4 specifically includes: S41. Based on the stabilized PCF method, during the fragment coloring stage, the normalized device coordinate depth value (NDC) of the current pixel is read, and the NDC depth value is compared with the segmentation depth interval of each cascade one by one. The first cascade index that satisfies "depth value is less than the upper limit of segmentation" is found and used as the main cascade index of the current pixel. S42. Read the two-dimensional array depth texture, determine the layer number of pixel sampling according to the main concatenation index and the light number, multiply the world space position of the fragment by the light view matrix and the orthogonal projection matrix in turn to obtain the homogeneous clip space coordinates, perform homogeneous division to obtain the standard device coordinates in the range of -1 to 1, and linearly map the standard device coordinates to 0 to 1 according to the components to obtain the normalized sampling coordinates of the corresponding texture. S43. In the two-dimensional array depth texture sampling, the sampling pattern is loaded from the preset rotating Poisson disk sequence or blue noise distribution. According to the low bit value of the screen coordinate of the fragment, the rotation index is selected as the sampling direction. The corresponding sampling point coordinates are rotated to obtain the anti-jitter sampling position set. The rotated coordinates are used as the sampling offset position. The sampling is performed in the two-dimensional array depth texture to generate the shadow judgment value set. S44. Read the depth texture value for each offset sampling point and compare it with the depth value after the current fragment transformation. Calculate the sampling ratio that is less than the fragment depth and use it as the shadow factor. S45. Read the fragment normal vector and the illumination direction vector, calculate the dot product and take the inverse cosine to get the angle, determine the tilt of the receiving surface based on the angle, calculate the depth gradient around the pixel in the light space along the illumination direction to get the depth change rate, multiply the tilt by a preset coefficient to get the depth offset of the receiving surface, multiply the depth change rate by the normal alignment to get the normal offset, convert them into light space length units, add them to the fragment depth and sampling depth and then compare them. S46. After completing all depth texture sampling and offset calculations for the current pixel in the determined main cascade based on the stabilized PCF method, calculate the ratio between the number of sampling points falling into the shadow area and the total number of sampling points, generate the shadow factor of the pixel, and output the shadow factor as the single cascade shadow result of the current fragment.

6. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S5 specifically includes: S51. Read the single cascade shadow result of the current fragment under the main cascade, and read the depth value of the fragment in world space. Take out all cascade segmentation depth thresholds from the uniform light UBO in sequence, determine which two adjacent cascades the segmentation depth value is located between, and subtract the smaller segmentation depth from the segmentation depth value, divide by the difference between the two segmentation depths to obtain the normalized distance. S52. Round down the horizontal and vertical coordinates of the fragment on the screen, extract the two least significant bits of the integer, and concatenate the two least significant bits of the horizontal coordinate with the two least significant bits of the vertical coordinate to form a 4-bit binary index value. Use the index value to look up the floating-point value at the corresponding position in the pre-set screen space Bayer threshold matrix, and use it as the dither threshold of the current fragment. S53. Compare the normalized distance value with the dither threshold. If the distance value is less than the threshold, set the fusion weight to 1, indicating that the current pixel fully adopts the shadow result of the main cascade. If the distance value is greater than or equal to the threshold, construct a linear scaling factor based on the distance value and use it as a weight. Multiply the shadow results of the current main cascade and the next cascade by the corresponding weights and sum them to obtain the fused shadow result. S54. Determine whether the generated blending weight value is less than 1. If so, directly use the blending shadow result as the final blending value of the current fragment. If the blending weight is 1, it means that the current fragment is not in the cascade boundary area. Then directly use the shadow factor of the main cascade as the current blending result. Regardless of the source of the blending weight, the final blending result is uniformly output as the shadow value of the current pixel, and the blending shadow result of the adjacent cascade is output.

7. The method for real-time generation and anti-jitter rendering of cascading shadows according to claim 1, characterized in that, S6 specifically includes: S61. Read the depth value of the current pixel in world space, traverse the start and end depth values ​​of each cascade in the Unified Light UBO, determine whether it falls within the depth range of a certain cascade, if so, determine it as the main cascade, read the start depth value of the next cascade, calculate the difference between the current pixel depth value and the start depth of the next cascade, if the difference is less than the preset transition bandwidth threshold, it is in the boundary area between the main cascade and the next cascade. S62. If it is in the boundary area, read the blended shadow result of the adjacent concatenation generated in the previous step; if it is not in the boundary area, read the single concatenation shadow result of the current pixel under the main concatenation. S63. Read the six configuration values ​​from the runtime parameters: PCF radius, number of samples, dither matrix size, number of cascades N, transition bandwidth and split coefficient, and store them in the constant buffer of the fragment shader. S64. Use the light view matrix and orthogonal projection matrix to transform the world space coordinates into normalized sampling coordinates. Based on the PCF kernel size and the preset sampling offset pattern, generate multiple offset sampling points. Read the sampling depth value one by one and compare it with the light space depth. If the sampling depth is greater than the fragment depth plus the offset, it is recorded as unoccluded. Calculate the proportion of unoccluded samples in all samples and use it as the occlusion ratio factor of the current pixel. S65. The occlusion ratio factor calculated for each pixel is written as the gray value of the current pixel in the output shadow image and written to the corresponding position. The gray value range is 0 to 1. After all pixels are processed, a two-dimensional image is generated as the final stabilized shadow rendering output.