A lightweight real-time rendering method for generating super-large forest landscapes
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-30
- Publication Date
- 2026-08-11
AI Technical Summary
[0004](1)模型制作成本高,团队需要在前期花费大量时间进行采样与建模;
[0057]本发明的有益效果:本发明的一种生成式超大规模森林景观的轻量级实时渲染方法,本发明主要包含三大特点:一、森林景观中的树木模型与分布位置均是通过随机化参数自动生成的,无需用户建模与编辑;二、实现了对于超大规模树木模型的轻量级网络传输、在线解析、实时渲染、缓存管理的一体化流程;三、森林规模庞大,可在Web端实时渲染出百万级别树木所构成的森林景观。本发明着眼于面向Web3D的超大规模景观的实时渲染技术瓶颈,能够对影视、游戏以及Web3D可视化智慧应用的发展提供推动力。
Smart Images

Figure CN117576290B_ABST
Abstract
Description
Technical Field
[0001] This invention is a lightweight real-time rendering method for generative ultra-large-scale forest landscapes, belonging to the technical field of real-time rendering of large-scale landscapes. Background Technology
[0002] Web3D real-time rendering technology is a web-based, browser-based real-time rendering technology. With the improvement of web browser performance and network bandwidth, Web3D real-time rendering technology has received increasing attention, and WebGL-based development tools and frameworks have been further improved and developed. The open-source engine three.js on GitHub is based on JavaScript, can run GPU drivers directly in the browser, and has rich documentation and a mature community. Babylon.js is based on TypeScript and can render 3D scenes in the browser while providing an advanced set of debugging tools to improve development efficiency. However, the rendering methods provided by current mainstream engines cannot well support online real-time rendering of large-scale scenes; in most cases, they can only guarantee high frame rates and resolutions when rendering single or a few models.
[0003] In the era of digital twins, improving the real-time rendering effect of large-scale landscapes for web-based applications has become a key issue in the development of Web3D online visualization applications. Currently, the main problems with real-time rendering of large-scale landscapes in Web3D are as follows:
[0004] (1) The model production cost is high, and the team needs to spend a lot of time on sampling and modeling in the early stage;
[0005] (2) A single model contains a large amount of data, which causes network transmission time to be prolonged and the scene scale to be small.
[0006] (3) The scene contains too many vertices and triangles, resulting in low real-time rendering frame rate and lack of lighting effects, causing poor user experience such as stuttering and lack of immersion. There is an urgent need for a lightweight real-time rendering method for generative ultra-large-scale forest landscapes to solve the above problems. Summary of the Invention
[0007] To address the shortcomings of existing technologies, the present invention aims to provide a lightweight real-time rendering method for generative ultra-large-scale forest landscapes. First, a lightweight, parameterized, fine-grained tree model is automatically generated online using a parametric tree skeleton construction algorithm and a tree skeleton-based model building algorithm. Next, coarse-grained tree cross-facets are generated online using coarse-grained, consistent tree cross-facets. Then, through four steps—generating randomized terrain and tree coordinate points, octree-based tree coordinate point frustum culling, layered instantiation of the tree model according to viewpoint distance, and adding lighting and cascading shadows—the lightweight, real-time rendering effect of ultra-large-scale forest landscapes is achieved, thus solving the problems mentioned in the background technology.
[0008] To achieve the above objectives, the present invention provides a lightweight real-time rendering method for generative ultra-large-scale forest landscapes, comprising the following steps:
[0009] S1, online generation of lightweight parametric fine-grained tree models;
[0010] S2, online generation of coarse-grained, uniform tree cross-shaped patches;
[0011] S3, layered instantiation rendering for multi-level detailed tree models;
[0012] S4 manages the cache by calculating the tree retention rate and performing three-state transitions;
[0013] S5 adds lighting and cascading shadow effects that utilize WebGPU.
[0014] Furthermore, step S1 specifically includes:
[0015] S1.1 Lightweight transmission of tree feature objects: By observing and learning from real-world trees, the features of tree branches and leaves are abstracted into a set of parameterized data. This set of parameters constitutes the tree feature object corresponding to this type of tree. The parameters contained in the tree feature object can be divided into skeleton parameters and mesh parameters. Skeleton parameters are used to specify the posture of the tree skeleton, and mesh parameters are used to specify the shape of the branch mesh and leaf mesh.
[0016] By integrating tree feature objects corresponding to various trees to form a tree feature object library (Tree FeatureDatabase) and deploying it in the cloud, when a client wants to obtain a tree feature, it only needs to request a string containing the tree species from the tree feature object library. When the tree feature object library returns the corresponding tree feature object, it only needs to transmit a lightweight tree feature string. Because a tree feature string is very small, the response time required for the above request is very short, achieving lightweight and low-latency network data transmission.
[0017] S1.2, Online construction of tree skeleton based on tree feature object: Read the skeleton parameters contained in the Tree Feature, and construct the tree skeleton online through the Parametric Tree Skeleton Construction Algorithm (PTSCA);
[0018] PTSCA is essentially a recursive function that accepts four input data: the current branch start position (cur_start), the end position (cur_end), the parent tree skeleton (superior_tree_skeleton), and the current depth (cur_depth). The output data is a Tree Skeleton, which is a data structure with fractal characteristics, containing both the skeleton key points and the next level Tree Skeleton. The PTSCA function performs the following steps in each recursive call:
[0019] (1) Determine whether the current depth exceeds the maximum recursion depth. If yes, end the process; otherwise, continue with step (2).
[0020] (2) Generate the skeleton key points of the current level based on the start, end, disturbance, and gravity in the Tree Feature, and then use these skeleton key points to create the current tree skeleton (cur_tree_skeleton) and use it as the lower-level skeleton of superior_tree_skeleton.
[0021] (3) Obtain the total number of lower branches based on Tree Feature and assign it to an integer N. Execute the following operation N times in a loop: Based on the CatmullRom curve generated from the current level skeleton keypoints, obtain the start position (next_start) and end position (next_end) of the lower branches. Increment cur_depth by 1. Use next_start, next_end, cur_tree_skeleton and cur_depth as the new round of inputs to the PTSCA function and recursively execute the PTSCA function.
[0022] (4) The loop ends, and the current recursion also ends;
[0023] S1.3, Online construction of fine-grained tree models based on tree skeleton: Read the key points of each branch skeleton of the Tree Skeleton layer by layer, and construct fine-grained tree models online through the Model Construction Algorithm Based on Tree Skeleton (MCABTS).
[0024] MCABTS accepts two input data: the current tree skeleton (cur_tree_skeleton) and the current depth (cur_depth). The output data is the complete tree model. MCABTS is also a recursive function, and the following steps are executed in each recursive call:
[0025] (1) Determine whether the current depth exceeds the maximum recursion depth. If yes, end the process; otherwise, continue with step (2).
[0026] (2) Generate a CatmullRom curve based on the skeleton keypoints contained in cur_tree_skeleton, and generate the branch pillars of the current level along this curve. If the current branch is a terminal branch, add leaf meshes and materials;
[0027] (3) Traverse each lower-level skeleton (next_tree_skeleton) of cur_tree_skeleton, and use the value of next_tree_skeleton and cur_depth incremented by 1 as the new round of input for MCABTS, and recursively execute the MCABTS function;
[0028] (4) This recursion ends.
[0029] Furthermore, step S2 specifically includes:
[0030] S2.1, Render the fine-grained tree model as a render target: Place the fine-grained tree model at the origin of the world coordinate system, adaptively calculate the position and orientation of the camera according to the size of the tree model, and render the fine-grained tree model to the render target from the front and side respectively;
[0031] S2.2, store the Render Target as a material map and attach it to the cross-shaped facet: Read the Render Targets of the front and side faces respectively, and store them as square material maps with a lower resolution (e.g., 256*256 pixels). Next, generate a cross-shaped facet geometry of size 1, and scale the cross-shaped facet geometry to a consistent tree cross-shaped facet of the same size according to the size of the tree model's OBB bounding box. Finally, attach the above material map to the consistent tree cross-shaped facet to obtain a coarse-grained consistent tree cross-shaped facet.
[0032] Furthermore, step S3 specifically includes:
[0033] S3.1, Generation of undulating terrain and non-re-randomized tree coordinate points based on Berlin noise: First, a terrain plane with numerous grid points is initialized. Then, a series of continuously changing random numbers are generated using Berlin noise. These random numbers are used as the heights of the terrain plane grid points, resulting in a terrain grid with random height undulations. Tree coordinate points are randomly and uniformly selected from the terrain grid points. To avoid repeatedly selecting the same terrain grid point, a flag (Boolean variable) indicating whether it has been selected is added to the vertex array of the terrain grid. For each randomly generated vertex array index, it is checked whether the flag corresponding to the index has been set to True. If so, a new vertex array index is randomly generated, and the check is repeated until the flag corresponding to the index is False. If not, a non-re-randomized tree coordinate point has been successfully generated, and the flag corresponding to the index is changed to True.
[0034] S3.2, Instantiated Tree Frustum Cultivation Based on Octree Index Structure: First, an octree index structure is established for all tree coordinates. The octree is partitioned using the classic octet method. Each node of the octree can hold 10 tree coordinates. If new tree coordinates are added, the node is divided into eight equal parts. Next, the six planes of the camera frustum are expanded outward to obtain the expanded frustum. The reason for not directly using the camera frustum is that frustum culling based on the camera frustum faces two problems.
[0035] First, some trees within the field of view are not rendered. That is, some trees that should be within the field of view are not rendered on the screen because their coordinates are outside the view frustum.
[0036] Second, rotating the view causes "edge blanking," meaning that when rotating the view, the trees at the edge of the screen are not rendered in time, and users will briefly see that the trees are missing from the edge.
[0037] To address the two issues mentioned above, the six planes of the camera's view frustum are extended outwards to obtain an extended view frustum. The view frustum generated by the camera's perspective projection matrix consists of six planes, each defined using the Hessian Normal Form (also known as the Hessian Normal Form). The Hessian Normal Form defines a plane in three-dimensional space using the plane normal *n* and the distance *p* from the plane to the origin. The sign of *p* determines which side of the plane the origin lies on; if *p* is positive, the origin is in the half-space along the plane normal direction; otherwise, the origin is in the other half-space. The vector definition of the Hessian Normal Form is:
[0038] r·np=0
[0039] Where r is the vector from the origin to any point on the plane, n is the plane normal (unit vector), and p is the distance from the origin to the plane. The normals of the six planes contained in the view frustum generated by the camera all point inwards from the view frustum. Based on this property, to simultaneously expand the range of the view frustum in six directions, it is only necessary to add a positive expansion amount to the p value of each plane;
[0040] The extended view frustum pre-calculates the trees that will be seen in six directions: front, back, left, right, up, and down. This effectively includes trees that are locally located within the camera's view frustum, solving the problem of unrendered trees within the view frustum. It also pre-renders the trees that will be seen after rotating the viewpoint, solving the problem of "edge blanking" caused by rotating the viewpoint.
[0041] S3.3, Layered Instantiation Based on Viewpoint Distance: First, for the tree coordinates within the view frustum in this frame, calculate their respective viewpoint distances and classify them into different distance intervals. Next, integrate the transformation matrices (including translation, rotation, and size transformation matrices) of the trees corresponding to the tree coordinates in each interval to obtain an array of transformation matrices for instantiation. Then, match the array of transformation matrices for instantiation to the models of each granularity. Finally, instantiate and render the models of each granularity separately. From the viewpoint's perspective, models of different granularities are distributed layer by layer from near to far, hence the name layered instantiation rendering. After rendering this frame to the screen, a three-state transition cache management is performed by calculating the tree retention rate (see S4 for details), and the above steps are repeated for the next frame.
[0042] Furthermore, step S4 specifically includes:
[0043] S4.1, Calculate tree retention around the viewpoint: Define a circular region centered at the viewpoint with the furthest visible distance as its radius, and calculate the retention of all trees within this region. Let the viewpoint distance of a certain tree be D. tree The camera's closest and furthest visible distances are D and D, respectively. min and D max Define the normalized viewpoint distance d of the tree:
[0044]
[0045] Define the shading coefficient o of trees:
[0046]
[0047] Then define the tree retention rate R:
[0048] R = 1 - d × o
[0049] From the above definition, it can be seen that, Furthermore, the larger the value of R, the higher the tree preservation rate. The relationship between R and d, o is shown in the table below:
[0050]
[0051] S4.2, Three-state transitions are performed based on tree retention and visibility: To manage the cache in an orderly manner, three states are defined for each instantiated object: "Currently Visible", "Potentially Visible", and "Cleaned". The "Currently Visible" state indicates that the instantiated object is located within the view frustum and needs to be rendered to the screen; the "Potentially Visible" state indicates that although the instantiated object is located outside the view frustum, its current retention is high and it may be seen in the future; the "Cleaned" state indicates that the cache space corresponding to the instantiated object has been released and there is no longer any space for it in the cache.
[0052] Figure 6 The upper section shows the transition diagram for these three states. The transition between the "potentially visible" state and the "cleaned" state involves judging the retention level. The method to measure the retention level is to define a retention threshold T. If the current retention level is higher than T, it is considered high; otherwise, it is considered low. The value of T depends on the specific situation. Similarly, the method to measure whether the retention level is low for a long period of time is to define a time threshold and compare the duration of low retention with this threshold.
[0053] In the cache, cache blocks corresponding to all instantiated objects in the same state are organized together in a linked structure. If cache block A3 in the state A linked list needs to transition to state B, the subsequent pointer of the previous cache block A2 will skip A3 and directly point to A4. At the same time, the subsequent pointer of the last cache block B6 in the state B linked list will point to A3. The above process achieves the purpose of moving cache block A3 from the state A linked list to the state B linked list. In particular, when state B is the "cleaned up" state, the state B linked list is actually a large block of free cache space. Moving cache blocks from other states to state B (the "cleaned up" state) at this time is essentially releasing this cache block space directly.
[0054] Furthermore, step S5 specifically includes:
[0055] S5.1, Add ambient light and directional light: Ambient light is used to illuminate trees in the scene from various angles, and directional light is used to simulate sunlight in the real world;
[0056] S5.2 adds cascading shadows utilizing WebGPU: Cascading shadows dynamically adjust the resolution of shadow maps by calculating the distance from the camera's viewpoint. The closer an object is to the viewpoint, the higher the resolution of the cast shadow. Relying on the more efficient parallel computing provided by WebGPU, cascading shadows are added to ultra-large-scale forest scenes, allowing trees, branches, and the ground to all cast and receive shadow effects, achieving more realistic real-time rendering.
[0057] The beneficial effects of this invention are as follows: This invention provides a lightweight real-time rendering method for generative ultra-large-scale forest landscapes. The invention mainly includes three features: First, the tree models and distribution locations in the forest landscape are automatically generated through randomized parameters, eliminating the need for user modeling and editing; second, it achieves an integrated process for lightweight network transmission, online parsing, real-time rendering, and cache management of ultra-large-scale tree models; third, it can render forest landscapes composed of millions of trees in real-time on the Web platform, addressing the technical bottlenecks of real-time rendering of ultra-large-scale landscapes for Web3D, and can promote the development of film, games, and Web3D visualization intelligent applications. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1This is a flowchart of the lightweight real-time rendering process for generative ultra-large-scale forest landscapes in this invention.
[0060] Figure 2 This is a schematic diagram illustrating the lightweight transmission, parsing, and construction of tree feature objects into a fine-grained tree model in this invention.
[0061] Figure 3 This is a schematic diagram illustrating the two aspects of problems that the extended view frustum algorithm needs to solve in this invention;
[0062] Figure 4 This is a schematic diagram of the extended view frustum algorithm in this invention;
[0063] Figure 5 This is a schematic diagram illustrating the layered instantiation and rendering of coarse- and fine-grained tree models in this invention.
[0064] Figure 6 This is a schematic diagram of cache management in this invention, which performs three-state transitions by calculating tree retention rate;
[0065] Figure 7 These are real-time rendering images of the distant and close-up views of the generative ultra-large-scale forest landscape in this invention. Detailed Implementation
[0066] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0067] The purpose of this invention is to provide a lightweight real-time rendering method for generative ultra-large-scale forest landscapes. To make the above-mentioned objectives, features and advantages of this invention more apparent and understandable, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0068] like Figure 1 As shown, this invention provides a lightweight real-time rendering method for generative ultra-large-scale forest landscapes, comprising the following steps:
[0069] S1, online generation of lightweight parametric fine-grained tree models;
[0070] S2, online generation of coarse-grained, uniform tree cross-shaped patches;
[0071] S3, layered instantiation rendering for multi-level detailed tree models;
[0072] S4 manages the cache by calculating the tree retention rate and performing three-state transitions;
[0073] S5 adds lighting and cascading shadow effects that utilize WebGPU.
[0074] Step S1 specifically includes:
[0075] S1.1 Lightweight Transfer of Tree Feature Objects: By observing and learning from real-world trees, the features of tree branches and leaves are abstracted into a set of parameterized data. This set of parameters constitutes the tree feature object corresponding to that tree type. The parameters contained in the tree feature object can be divided into skeleton parameters and mesh parameters. Skeleton parameters define the orientation of the tree skeleton, while mesh parameters define the shape of the branch and leaf meshes. All parameters contained in the tree feature object are shown in the table below:
[0076]
[0077]
[0078] The tree feature objects corresponding to various types of trees are integrated to form a tree feature object library (Tree FeatureDatabase) and deployed in the cloud. Figure 2 The upper section illustrates the lightweight transmission process of tree feature objects: when a client wants to obtain a tree feature, it only needs to request a string containing the tree species from the tree feature object library. When the tree feature object library returns the corresponding tree feature object, it only needs to transmit a lightweight Tree Feature string. Because a Tree Feature string is very small, the response time required for the above request is very short, achieving lightweight and low-latency network data transmission.
[0079] S1.2, Online construction of tree skeleton based on tree feature object: Read the skeleton parameters contained in the Tree Feature, and construct the tree skeleton online through the Parametric Tree Skeleton Construction Algorithm (PTSCA).
[0080] Figure 2The middle section illustrates the recursive structure of parametric tree skeleton construction. PTSCA is essentially a recursive function that accepts four inputs: the current branch start position (cur_start), the end position (cur_end), the parent tree skeleton (superior_tree_skeleton), and the current depth (cur_depth). The output is a Tree Skeleton. A Tree Skeleton is a data structure with fractal characteristics, containing both the skeleton's key points and its next-level Tree Skeletons. The PTSCA function performs the following steps during each recursive call:
[0081] (1) Determine whether the current depth exceeds the maximum recursion depth. If yes, end the process; otherwise, continue with step (2).
[0082] (2) Generate the skeleton key points of the current level based on the start, end, disturbance, and gravity in the Tree Feature, and then use these skeleton key points to create the current tree skeleton (cur_tree_skeleton) and use it as the lower-level skeleton of superior_tree_skeleton.
[0083] (3) Obtain the total number of lower branches based on Tree Feature and assign it to an integer N. Execute the following operation N times in a loop: Based on the CatmullRom curve generated from the current level skeleton keypoints, obtain the start position (next_start) and end position (next_end) of the lower branches. Increment cur_depth by 1. Use next_start, next_end, cur_tree_skeleton and cur_depth as the new round of inputs to the PTSCA function and recursively execute the PTSCA function.
[0084] (4) The loop ends, and the current recursion also ends.
[0085] S1.3, Online construction of fine-grained tree models based on tree skeleton: Read the key points of each branch skeleton of the Tree Skeleton layer by layer, and construct fine-grained tree models online through the Model Construction Algorithm Based on Tree Skeleton (MCABTS).
[0086] Figure 2The lower section illustrates the skeleton-based model building process. MCABTS accepts two input data: the current tree skeleton (cur_tree_skeleton) and the current depth (cur_depth), and the output data is the complete tree model. MCABTS is also a recursive function, performing the following steps in each recursive call:
[0087] (1) Determine whether the current depth exceeds the maximum recursion depth. If yes, end the process; otherwise, continue with step (2).
[0088] (2) Generate a CatmullRom curve based on the skeleton keypoints contained in cur_tree_skeleton, and generate the branch pillars of the current level along this curve. If the current branch is a terminal branch, add leaf meshes and materials;
[0089] (3) Traverse each lower-level skeleton (next_tree_skeleton) of cur_tree_skeleton, and use the value of next_tree_skeleton and cur_depth incremented by 1 as the new round of input for MCABTS, and recursively execute the MCABTS function;
[0090] (4) This recursion ends.
[0091] Step S2 specifically includes:
[0092] S2.1, Render the fine-grained tree model as a render target: Place the fine-grained tree model at the origin of the world coordinate system, adaptively calculate the camera position and orientation based on the size of the tree model, and render the fine-grained tree model to the render target from the front and side respectively.
[0093] The adaptive camera position is calculated as follows: First, calculate the OBB bounding box of the fine-grained tree model, obtaining the center point C of the bounding box and the length s of the volume diagonal. Given the camera pitch angle f (in radians), the distance between the camera and the tree is:
[0094]
[0095] Fit is an adjustable scalar value ranging from 0 to 1. The purpose of introducing this parameter is to more flexibly adapt to screens of different sizes.
[0096] For a camera with an arbitrary initial position, let its initial position be P, then the direction vector from the center point of the tree to the adaptive camera position should be:
[0097] α = (PC)·(1,0,1)
[0098] From D and α, the adaptive camera position can be obtained as:
[0099] Q = C + α * D
[0100] The adaptive camera orientation is calculated as follows: simply have the camera look at the center point of the bounding box, i.e., C. Input C as a parameter into the lookAt method provided by the WebGL API to calculate the adaptive camera orientation.
[0101] S2.2, store the Render Target as a material map and attach it to the cross-shaped facet: Read the Render Targets of the front and side faces respectively, and store them as square material maps with a lower resolution (e.g., 256*256 pixels). Next, generate a cross-shaped facet geometry of size 1, and scale the cross-shaped facet geometry to a consistent tree cross-shaped facet of the same size according to the size of the tree model's OBB bounding box. Finally, attach the above material map to the consistent tree cross-shaped facet to obtain a coarse-grained consistent tree cross-shaped facet.
[0102] Step S3 specifically includes:
[0103] S3.1, Generation of undulating terrain and non-re-randomized tree coordinate points based on Berlin noise: First, a terrain plane with numerous grid points is initialized. Then, a series of continuously changing random numbers are generated using Berlin noise. These random numbers are used as the heights of the terrain plane grid points, resulting in a terrain grid with random height undulations. Tree coordinate points are randomly and uniformly selected from the terrain grid points. To avoid repeatedly selecting the same terrain grid point, a flag (Boolean variable) indicating whether it has been selected is added to the vertex array of the terrain grid. For each randomly generated vertex array index, it is checked whether the flag corresponding to the index has been set to True. If so, a new randomly generated vertex array index is generated, and the check is repeated until the flag corresponding to the index is False. If not, a non-re-randomized tree coordinate point has been successfully generated, and the flag corresponding to the index is changed to True.
[0104] S3.2, Instantiated Tree Frustum Cultivation Based on Octree Index Structure: First, an octree index structure is established for all tree coordinates. The octree is partitioned using the classic octet method. Each node of the octree can hold 10 tree coordinates. If new tree coordinates are added, the node is divided into eight equal parts. Next, the six planes of the camera frustum are expanded outward to obtain the expanded frustum. The reason for not directly using the camera frustum is that frustum culling based on the camera frustum would face challenges such as... Figure 3 The two issues shown.
[0105] First, some trees within the field of view were not rendered. Figure 3 The upper left corner shows the intersection of two trees in different positions with the view frustum. The top branches of tree 1 should be visible, but because its coordinates are outside the view frustum, it is not rendered to the screen. Only trees like tree 2, whose coordinates are inside the view frustum, can be rendered to the screen. Figure 3 The upper right corner shows a rendering of "trees within the view frustum not rendered". The area surrounded by white dotted lines should have trees, but they are empty.
[0106] Second, rotating the viewing angle causes "marginal blanks". Figure 3 The lower left corner shows the transformation of visible trees after the view frustum transitions from the previous frame (dashed line) to the current frame (solid line). The trees seen in this frame include those only visible in this frame (light green) and those visible in both the previous and current frames (yellow). Because the coordinates of the trees within the view frustum need to be recalculated and rendered to the screen every frame, trees only visible in this frame are rendered to the screen more slowly than trees visible in both the previous and current frames. This results in… Figure 3 The "blank edge" issue shown in the lower right corner means that when the view is rotated, the trees at the edge of the screen are not rendered in time, and the user will briefly see that the trees are missing from the edge.
[0107] To address the two issues mentioned above, the six planes of the camera's view frustum are extended outwards to obtain an extended view frustum. The view frustum generated by the camera's perspective projection matrix consists of six planes, each defined using the Hessian Normal Form (also known as the Hessian Normal Form). The Hessian Normal Form defines a plane in three-dimensional space using the plane normal *n* and the distance *p* from the plane to the origin. The sign of *p* determines which side of the plane the origin lies on; if *p* is positive, the origin is in the half-space along the plane normal direction; otherwise, the origin is in the other half-space. The vector definition of the Hessian Normal Form is:
[0108] r·np=0
[0109] Where r is the vector from the origin to any point on the plane, n is the plane normal (unit vector), and p is the distance from the origin to the plane. The normals of the six planes contained in the view frustum generated by the camera all point inwards from the view frustum. Based on this property, to simultaneously expand the range of the view frustum in six directions, simply add a positive expansion amount to the p value of each plane.
[0110] The correctness of this method is demonstrated as follows: Figure 4 As shown, suppose there is a point A within the view frustum. According to the definition of a plane, the distances L from the six planes to point A are... i(L1, L2, ..., L6) are all positive numbers. To increase the range of the visual cone, that is, to make L... i Increase. When p is less than 0, i.e., the origin O is on the back side of the plane, A and O are on opposite sides. Adding a positive increment to p causes the plane to move closer to the origin O and further away from point A. i Increase; when p is greater than 0, that is, when the origin O is on the front of the plane, A and O are on the same side. The positive increase in p causes the plane to move away from the origin O and away from point A. i It also increases. In summary, by simply adding a positive expansion amount to the p-value of each plane, the range of the view frustum can be expanded simultaneously in six directions.
[0111] The extended view frustum pre-calculates the trees that will be seen in six directions: front, back, left, right, up, and down. This effectively includes trees that are locally located within the camera's view frustum, solving the problem of unrendered trees within the view frustum. It also pre-renders the trees that will be seen after rotating the viewpoint, solving the "edge blanking" problem caused by rotating the viewpoint.
[0112] S3.3, Instantiate in layers based on viewpoint distance: Figure 5 The iterative process of this step is illustrated. First, for the tree coordinates within the view frustum in this frame, their respective viewpoint distances are calculated and classified into different distance intervals. For example, the viewpoint distance interval for the fine-grained model is defined as 0 to 300, and the viewpoint distance interval for the coarse-grained model is 300 to the far plane of the view frustum. The coordinates classified into the distance interval of 0 to 300 are shown as the yellow coordinates in the figure, and the coordinates classified into the distance interval of 300 to the far plane of the view frustum are shown as the red coordinates in the figure. Next, the transformation matrices (including translation, rotation, and size transformation matrices) corresponding to the tree coordinates in each interval are integrated to obtain an array of transformation matrices for instantiation. Then, the array of transformation matrices for instantiation is matched to the model of each granularity. In this example, there are only two granularity models; therefore, the transformation matrix corresponding to the yellow coordinates is matched to the fine-grained model, and the transformation matrix corresponding to the red coordinates is matched to the coarse-grained model (crossface). Finally, the models at each granularity are instantiated and rendered separately. From the viewpoint, the models of different granularities are distributed layer by layer from near to far, hence the name layered instantiation rendering. After rendering this frame to the screen, the cache management of three-state transitions is performed by calculating the tree retention rate (see S4 for details), and the above steps are repeated for the next frame.
[0113] Step S4 specifically includes:
[0114] S4.1, Calculate tree retention around the viewpoint: Define a circular region centered at the viewpoint with the furthest visible distance as its radius, and calculate the retention of all trees within this region. Let the viewpoint distance of a certain tree be D. treeThe camera's closest and furthest visible distances are D and D, respectively. min and D max Define the normalized viewpoint distance d of the tree:
[0115]
[0116] Define the shading coefficient o of trees:
[0117]
[0118] Then define the tree retention rate R:
[0119] R = 1 - d × o
[0120] From the above definition, it can be seen that, Furthermore, the larger the value of R, the higher the tree preservation rate. The relationship between R and d, o is shown in the table below:
[0121]
[0122] S4.2, a three-state transition is performed based on tree retention and visibility: To manage the cache in an orderly manner, three states are defined for each instantiated object: "Currently Visible", "Potentially Visible", and "Cleaned". The "Currently Visible" state indicates that the instantiated object is within the view frustum and needs to be rendered to the screen; the "Potentially Visible" state indicates that although the instantiated object is outside the view frustum, its current retention is high and it may be seen in the future; the "Cleaned" state indicates that the cache space corresponding to the instantiated object has been released, and there is no longer any space for it in the cache.
[0123] Figure 6 The upper section shows the transition diagram for these three states. The transition between the "potentially visible" state and the "cleaned" state involves judging the retention level. The method for measuring the retention level is to define a retention threshold T. If the current retention level is higher than T, it is considered high; otherwise, it is considered low. The value of T depends on the specific situation. Similarly, the method for measuring whether the retention level is low for a long period of time is to define a time threshold and compare the duration of low retention with this threshold.
[0124] Figure 6The section below illustrates the cache management process corresponding to state transitions. In the cache, cache blocks corresponding to all instantiated objects in the same state are organized together in a linked structure. If cache block A3 in the linked list of state A ("currently visible" in the example) needs to transition to state B, the subsequent pointer of the previous cache block A2 will skip A3 and directly point to A4. At the same time, the subsequent pointer of the last cache block B6 in the linked list of state B ("potentially visible" in the example) will point to A3. The above process achieves the purpose of moving cache block A3 from the linked list of state A to the linked list of state B, that is, the cache block A3 transitions from state A to state B. In particular, when state B is the "cleaned up" state, the linked list of state B is actually a large block of free cache space. Moving cache blocks from other states to state B ("cleaned up" state) at this time is essentially releasing this cache block space directly.
[0125] Step S5 specifically includes:
[0126] S5.1, Add ambient light and directional light: Ambient light is used to illuminate trees in the scene from various angles, and directional light is used to simulate sunlight in the real world;
[0127] S5.2 adds cascading shadows utilizing WebGPU: Cascading shadows dynamically adjust the resolution of shadow maps by calculating the distance from the camera's viewpoint. The closer an object is to the viewpoint, the higher the resolution of the cast shadow. Relying on the more efficient parallel computing provided by WebGPU, cascading shadows are added to ultra-large-scale forest scenes, allowing trees, branches, and the ground to all cast and receive shadow effects, achieving more realistic real-time rendering. Figure 7 The real-time rendering effect of the ultra-large-scale forest landscape is shown from both near and far viewpoints.
[0128] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or basic characteristics. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, it is intended that all variations falling within the meaning and scope of equivalents of the claims be included within the present invention.
[0129] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A lightweight real-time rendering method for generative ultra-large-scale forest landscapes, characterized in that, Includes the following steps: S1, online generation of lightweight parametric fine-grained tree models, specifically includes the following steps: S1.1, Lightweight transfer of tree feature objects; S1.2, Construct tree skeletons online based on tree feature objects; S1.3, online construction of fine-grained tree models based on tree skeletons; S2, online generation of coarse-grained, uniform tree cross-shaped patches, specifically includes: S2.1, render the fine-grained tree model as the rendering target; S2.2, save the rendering target as a material map and attach it to the cross facet; S3, layered instantiation rendering for multi-level detailed tree models, specifically includes: S3.1, Generating undulating terrain and non-repeated randomized tree coordinates based on Berlin noise: First, initialize a terrain plane with many grid points. Then, generate a series of continuously changing random numbers using Berlin noise. Use these random numbers as the heights of the terrain plane grid points to obtain a terrain grid with random height undulations. Tree coordinates are randomly and uniformly selected from the terrain grid points. To avoid repeatedly selecting the same terrain grid point, add a boolean variable indicating whether it has been selected to the vertex array of the terrain grid. For each randomly generated vertex array index, check whether the corresponding flag has been set to True. If so, regenerate a vertex array index and check again until the corresponding flag is False. If not, a non-repeated tree coordinate point has been successfully generated, and the flag corresponding to the index is changed to True. S3.2, Instantiated Tree Frustum Cultivation Based on Octree Index Structure: First, an octree index structure is established for all tree coordinates. The octree is partitioned using the classic octet method. Each node of the octree can hold 10 tree coordinates. If new tree coordinates are added, the node is divided into eight equal parts. Next, the six planes of the camera frustum are expanded outward to obtain the expanded frustum. The frustum generated by the camera's perspective projection matrix consists of six planes. Each plane is defined using the Hessian Normal Form (also known as the Hessian Normal Form). The Hessian Normal Form defines a plane in three-dimensional space using the plane normal n and the distance p from the plane to the origin. The sign of p determines which side of the plane the origin is on. If p is positive, the origin is in the half-space of the plane normal direction; otherwise, the origin is in the other half-space. The vector definition of the Hessian Normal Form is r. ·np=0, where r is the vector from the origin to any point on the plane, n is the plane normal (i.e., the unit vector), and p is the distance from the origin to the plane. The normals of the six planes contained in the view frustum generated by the camera all point towards the interior of the view frustum. S3.3, Layered instantiation based on viewpoint distance: First, for the tree coordinates within the view frustum in this frame, calculate their respective viewpoint distances and classify them into different distance intervals. Next, integrate the transformation matrices of the trees corresponding to the tree coordinates in each interval, including translation, rotation, and size transformation matrices, to obtain an array of transformation matrices for instantiation. Then, match the array of transformation matrices for instantiation to the models of each granularity. Finally, instantiate and render the models of each granularity separately. From the viewpoint, the models of different granularities are distributed layer by layer from near to far, hence the name layered instantiation rendering. After rendering this frame to the screen, the three-state transition cache is managed by calculating the tree retention rate, and the above steps are repeated for the next frame. S4, cache management for three-state transitions by calculating tree retention rate, specifically includes: S4.1 Calculate the tree retention around the viewpoint. Delineate a circular area with the viewpoint as the center and the farthest visible distance as the radius. Calculate the retention of all trees within this area. Let the viewpoint distance of a certain tree be D. tree The camera's closest and furthest visible distances are D and D, respectively. min and D max Define the normalized viewpoint distance d for trees: Define the shading coefficient o for trees: ; Define tree retention rate R: R = 1 - d × o; S4.2, a three-state transition is performed based on tree retention and visibility. To manage the cache in an orderly manner, three states are defined for each instantiated object: "Currently Visible," "Potentially Visible," and "Cleaned." The "Currently Visible" state indicates that the instantiated object is within the view frustum and needs to be rendered to the screen. The "Potentially Visible" state indicates that although the instantiated object is outside the view frustum, its current retention is high and it may be seen in the future. The "Cleaned" state indicates that the cache space corresponding to the instantiated object has been released, and there is no space for it in the cache. The transition between the "Potentially Visible" and "Cleaned" states involves judging the retention level. The method to measure the retention level is to define a retention threshold T. If the current retention level is higher than T, it is considered high; otherwise, it is considered low. The value of T depends on the specific situation. Similarly, the method to measure whether the retention level is low for a long time is to define a time threshold and compare the duration of low retention with the threshold. S5 adds lighting and cascading shadow effects that utilize WebGPU.
2. The lightweight real-time rendering method for generative ultra-large-scale forest landscapes according to claim 1, characterized in that, Step S5 specifically includes: S5.1, Add ambient light and directional light; S5.2 adds cascading shadows that utilize WebGPU.
Citation Information
Patent Citations
Tree three-dimensional visualization model realization method based on Sphere-Board
CN105205861A
Accelerated rendering method of scene model
CN110910505A