A rendering method based on node tree

Through the node tree-based rendering method, the node tree model is constructed and updated, and the data and rendering are separated, which solves the problems of low rendering performance and high data coupling in the existing technology, and efficient rendering and simplified maintenance are achieved.

CN118657870BActive Publication Date: 2024-11-19CHANGSHA KELIANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411143900.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-11-19
Estimated Expiration
2044-08-20

Smart Images

  • Figure CN118657870B_ABST
    Figure CN118657870B_ABST
Patent Text Reader

Abstract

The present invention provides a rendering method based on a node tree, by defining each common object as a data structure of a node to be rendered according to the characteristics of the common objects of each scene, and determining the connection relationship between each node to be rendered according to the positional relationship of each common object, constructing an initial node tree model, then obtaining the current scene to be rendered of the scene to be rendered, and determining the object to be rendered in the current scene to be rendered, and then determining the relevant parameters of the object to be rendered according to the initial node tree model, and filling the relevant parameters into the node to be rendered corresponding to the initial node tree model, obtaining the current node tree model of the scene to be rendered, and finally obtaining the texture model of the scene to be rendered according to the current node tree model, and rendering the texture model to obtain the current rendering result. The problem of high data coupling degree, low rendering efficiency, and high resource consumption during rendering in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of simulation technology, and in particular to a rendering method based on a node tree. Background Art

[0002] Existing rendering technology is crucial to many fields such as game development, film and television production, engineering design and architecture, virtual reality and enhanced display technology. It is of great significance for improving visual experience, assisting design and decision-making, simulation and experimentation. Taking water simulation technology as an example, the algorithms in existing rendering technology are generally the following:

[0003] Particle system: A huge number of particles are needed to simulate water. When the simulated water area is large, such as several hundred meters, the rendering performance problem will be difficult to solve.

[0004] Wave Particles: This method combines the characteristics of wave models and particle systems, decomposing water waves into a series of particles, each of which represents a small part of the wave energy, and then converts all waves into the current scene to be rendered. The rendering performance of this method is controllable, but it is difficult to simulate changes in water capacity.

[0005] Grid method: This is the most basic rendering method. It can simulate most water characteristics and has good interactivity and scalability, but it requires higher grid resolution. High-resolution grids will inevitably consume more computing resources while improving simulation accuracy, which will come at the expense of increased computing costs.

[0006] At the same time, when rendering scenes, the existing routine operation is to render directly on the GPU based on the scene data, without separating the data from the rendering independently. The degree of data coupling is too high, and performance bottlenecks are very likely to occur when complex scenes appear, and maintenance and expansion will also become difficult.

[0007] Therefore, how to improve it is a technical problem that needs to be solved urgently in this field. Summary of the invention

[0008] Based on this, the purpose of this application is to provide a node tree-based rendering method to solve at least one technical problem mentioned in the above background technology.

[0009] In a first aspect, the present application provides a node tree-based rendering method, comprising:

[0010] According to the type of the scene to be rendered, determine the common objects of each scene, define each common object as the data structure of the node to be rendered according to the characteristics of the common object, and determine the connection relationship between the nodes to be rendered according to the position relationship of each common object, and build an initial node tree model;

[0011] Get the current scene to be rendered, determine the current object to be rendered and its position relationship;

[0012] According to the data structure of the node to be rendered, relevant parameters of the current object to be rendered are obtained, and according to the position relationship between the current objects to be rendered, a current node tree model of the current scene to be rendered is constructed;

[0013] The texture model of the scene to be rendered is obtained according to the current node tree model, and the texture model is rendered to obtain the current rendering result.

[0014] Furthermore, the initial node tree model includes a scene root node, a model node, and an interface node; the model node and the interface node are first-level child nodes of the scene root node;

[0015] In the model node, each sub-node corresponds to an object to be rendered in the scene to be rendered, and the connection relationship of each subordinate sub-node is determined according to the position relationship between the objects to be rendered;

[0016] In the interface node, each sub-node corresponds to an interactive element in the interface to be rendered, and the connection relationship between each subordinate sub-node is determined according to the type of each sub-node.

[0017] Furthermore, the data structure of the node to be rendered includes: any one or more of a transformation matrix, a rendering state, a visibility flag, and a node type; wherein:

[0018] A transformation matrix, including any one or more of position information, rotation information, and scaling information;

[0019] Rendering state, including any one or more of material model, texture model, and lighting model;

[0020] Visibility flags, including any one or more of visible state, invisible state, hidden state, partially visible state, blocked state, and transparent state;

[0021] Node type, including any one or more of geometry nodes, light source nodes, and camera nodes.

[0022] Furthermore, the step of determining the transformation matrix includes:

[0023] Establish a coordinate system with the geometric center of each node as the origin;

[0024] Get the position information, rotation information and scaling information corresponding to the node to obtain the local transformation matrix of each node;

[0025] Traverse all nodes in the node tree to be rendered to determine whether the current node has a parent node. If so, multiply the local transformation matrix with the world transformation matrix of its parent node to obtain the world transformation matrix of the current node; if not, the local transformation matrix of the current node is the world transformation matrix.

[0026] Furthermore, the step of obtaining the current scene to be rendered and determining the current objects to be rendered and their positional relationships includes:

[0027] Divide the scene to be rendered into several levels, and obtain image data of each level according to the accuracy;

[0028] According to the image data of each level, extract the current object to be rendered in the image data of each level;

[0029] Determine the target position and target area of ​​each current object to be rendered in the image data of the corresponding level;

[0030] According to each target position and target area, the position relationship of the current object to be rendered is determined.

[0031] Furthermore, the step of constructing the current node tree model of the current scene to be rendered includes:

[0032] Determine whether each object to be rendered in the current scene to be rendered has a corresponding node to be rendered in the initial node tree model. If so, obtain the relevant parameters of the current object to be rendered and fill in the corresponding node; if not, create the corresponding node to be rendered, obtain the relevant parameters of the current object to be rendered and fill in the corresponding node;

[0033] Or / and, determine whether there is a blank node to be rendered in the initial node tree model, if so, delete the blank node to be rendered, if not, leave it unchanged;

[0034] Or / and, updating the connection relationship between the nodes according to the position relationship between the objects currently to be rendered;

[0035] Or / and, obtain the bounding box of each node in the current node tree model, and determine whether it is located in the viewing cone of the image acquisition device. If not, remove the corresponding node to obtain an updated current node tree model.

[0036] Furthermore, the step of obtaining the bounding box of each node in the current node tree model includes:

[0037] Get the vertex coordinates of the geometric body of each node in the current node tree model, and get the minimum coordinate extreme value and the maximum coordinate extreme value of the geometric body of each node;

[0038] The bounding box is constructed according to the coordinate extreme values ​​of the geometric body of each node to obtain the bounding box of the corresponding node.

[0039] Furthermore, the step of obtaining the texture model of the scene to be rendered according to the current node tree model includes:

[0040] According to the height map of the nodes to be rendered in the current node tree model of each level, the positions of each vertex are determined, and the positions of each vertex are connected to obtain the three-dimensional mesh models of each level;

[0041] According to the data structure of each node to be rendered in the current node tree model at each level, the texture map of each node is obtained;

[0042] The texture maps of the nodes contained in each level are mapped to the surface of the three-dimensional mesh model of the corresponding level to obtain the texture models of each level.

[0043] Furthermore, according to the data structure of each node to be rendered in the current node tree model of each level, the step of obtaining the texture map of each node includes:

[0044] According to the prior texture resolution and the amount of image data and numerical data, several two-dimensional arrays are created, and the image data and numerical data are filled into the corresponding two-dimensional arrays to obtain a texture data array;

[0045] Fill the data of each node in the texture data array into several blank textures to obtain the texture map corresponding to each node.

[0046] Furthermore, the step of rendering the texture model to obtain the current rendering result includes:

[0047] Create a compute shader program on the GPU and upload the texture model data of each level to the GPU;

[0048] Set the parameters of the compute shader program, and call the preset function to start the compute shader to render the data of the texture model at each level, obtain the rendering results of each level, and transfer the edge state of the rendering results of each level to obtain the final rendering result.

[0049] Furthermore, before rendering the texture model and obtaining the current rendering result, the following steps are also included:

[0050] The distance between each transparent object and the data acquisition device is obtained, and the rendering order of the transparent objects is determined, so as to render each transparent object in sequence according to the rendering order of the transparent objects. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 A flowchart of a node tree-based rendering method according to an embodiment of the present invention;

[0052] Figure 2 is a schematic diagram of an initial node tree model of an embodiment of the present invention;

[0053] Figure 3 A schematic diagram of an initial node tree model for water body simulation according to an embodiment of the present invention;

[0054] Figure 4 Schematic diagram of the current objects to be rendered and their positional relationship according to an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] It should be noted that if the embodiments of the present invention involve directional indications, such as up, down, left, right, front, back, etc., then the directional indication is only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly. In addition, if the embodiments of the present invention involve descriptions of "first, second", "S1, S2", "step one, step two", etc., then such descriptions are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of indicated technical features or indicating the execution order of the method, etc. Those skilled in the art can understand that anything that does not violate the gist of the invention under the technical concept of the invention should be included in the protection scope of the present invention.

[0057] like Figure 1 As shown, the present invention provides a node tree-based rendering method, comprising:

[0058] S1: according to the type of the scene to be rendered, determine the common objects of each scene, define each common object as the data structure of the node to be rendered according to the characteristics of the common object, and determine the connection relationship between the nodes to be rendered according to the position relationship of each common object, and construct an initial node tree model;

[0059] Specifically, it is optional but not limited to that technical personnel in this field may determine the common objects, i.e., common objects, of the scene according to the type of scene to be rendered, according to its attributes, basic information, regular patterns, etc., and define each common object as the data structure of the node to be rendered according to its basic characteristics, and then define the connection relationship between each node according to the common positional relationship between each common object in reality, so as to construct an initial node tree model.

[0060] Preferably, Figure 2As shown, the initial node tree model may include, but is not limited to, scene root nodes, model nodes, and interface nodes; the model nodes and interface nodes are first-level child nodes of the scene root node;

[0061] In the model node, each sub-node corresponds to an object to be rendered in the scene to be rendered, and the connection relationship of each subordinate sub-node is determined according to the position relationship between the objects to be rendered;

[0062] In the interface node, each sub-node corresponds to an interactive element in the interface to be rendered, and the connection relationship between each subordinate sub-node is determined according to the type of each sub-node.

[0063] Take the construction of the initial node tree model for water body simulation as an example. Figure 3As shown, it is usually necessary to include a model node and an interface node, and the scene to be rendered can be optionally used as the root node, and the model node and interface node required in the scene are first-level child nodes. For the model node, since in the example of the water body simulation initial node tree model, the water body, the ship and the sun can usually be directly observed, the child nodes of the model node in the initial model, i.e., the second-level child nodes, can be optionally but not limited to including water body nodes, ship nodes and sun nodes, etc., as third-level nodes. The water body usually includes objects such as stones, fish, and grass, so the child nodes of the water body node in the initial model, i.e., the third-level child nodes, can be optionally but not limited to including stone nodes, fish nodes, grass nodes, etc., as fourth-level nodes. Of course, this example is only an example of the adaptability of the water body scene, and is not limited to this. For further refinement, the fish node can also be optionally but not limited to including various types of fish or fish of various sizes, etc., as the child nodes of the fish node, i.e., the fifth-level node. For the interface node, since it is necessary to adjust the numerical data such as environmental parameters in the model, such as wind direction, wind speed, etc., the child nodes of the interface node in the initial model, i.e., the second-level child nodes, can optionally include, but are not limited to, elf nodes, button nodes, etc., as third-level nodes. The interface node and its child nodes can respond to user input, such as touch, click, or change the numerical parameters of the model according to the numerical parameters of the current scene, and perform corresponding actions according to these inputs. Of course, this example is only an example of the adaptability of the water scene, and is not limited to this. For further refinement, the elf node can also optionally include, but is not limited to, background child nodes, label child nodes, etc., as child nodes of the elf node, i.e., fourth-level nodes. Among them, the background node can be selected as a static image, such as a solid color rectangle, texture, gradient color or pattern, which is used to fill the background area of ​​the sprite node and provide a visual basis for the sprite node, and help other elements (such as label subnodes) to stand out better; the label node can be selected as a text element, which is used to display text information and has attributes such as font, size, color and alignment to provide information or instructions on the user interface; the button node can be selected as an interactive element, such as a rectangular area containing a text label, icon or other decorative graphics to indicate its function, such as changing environmental factors such as wind speed and wind direction, which is used to receive user click or touch events and trigger certain operations or functions.

[0064] It is worth noting that Figure 3 As shown, the adaptability of the water simulation node tree model is exemplified, but it is not limited to this. The specific number and content of its sub-nodes at all levels can be arbitrarily set according to the actual situation of the scene type to be rendered. For example, if the root node is a city scene, the sub-nodes of the model node can be selected but not limited to buildings, roads, suns, etc., and the sub-nodes at all levels can be arbitrarily set according to the actual scene. For example, the sub-nodes of the road node can be selected but not limited to cars, people, etc.

[0065] More preferably, the data structure of the node to be rendered may optionally include but is not limited to: any one or more of: a transformation matrix, a rendering state, a visibility flag, and a node type;

[0066] More preferably,

[0067] A transformation matrix, which may optionally include any one or more of position information, rotation information, and scaling information;

[0068] Rendering state, which may include any one or more of material model, texture model, and lighting model;

[0069] Visibility flag, optional including any one or more of visible state, invisible state, hidden state, partially visible state, blocked state, and transparent state;

[0070] Node type, which can be any one or more of geometry node, light source node, and camera node.

[0071] Specifically, each node to be rendered may include attributes such as a transformation matrix, a rendering state, a visibility flag and a node type, wherein the transformation matrix includes position information, rotation information and scaling information; the rendering state includes a material model, a texture model and a lighting model; the visibility flag includes a visible state, an invisible state, a hidden state, a partially visible state, an occluded state and a transparent state; the node type includes a geometric node, a light source node and a camera node, thereby forming a basic data structure of a node to be rendered, so as to facilitate subsequent determination of basic information of each object according to the object to be rendered of the current scene to be rendered, and obtain the nodes to be rendered corresponding to each object of the current scene to be rendered, so as to construct a current node tree model corresponding to the current scene to be rendered of the current scene, so as to preferentially merge the nodes to be rendered having the same data structure and improve rendering efficiency.

[0072] S2: Obtain the current scene to be rendered, determine the current object to be rendered and its position relationship;

[0073] Specifically, it is optional but not limited to obtaining image data such as terrain or scene of the current scene to be rendered based on satellite remote sensing to further determine which objects to be rendered are included in the current scene to be rendered and the positional relationship between the objects.

[0074] Preferably, the specific steps of obtaining the current scene to be rendered and determining the current object to be rendered and its position relationship may optionally include but are not limited to:

[0075] S21: Divide the scene to be rendered into several levels, and obtain image data of each level according to the accuracy;

[0076] Specifically, taking the water body scene as an example, it is optional but not limited to that the technical personnel in this field divide the water body into several levels according to the distance between the image acquisition device and the water body, set the acquisition accuracy of each level of water body respectively, and obtain the image data of each level of water body according to the acquisition accuracy; specifically, the acquisition accuracy is set arbitrarily by the technical personnel in this field according to the distance between each level of water body and the image acquisition device; the image acquisition device may optionally include common equipment such as underwater cameras, shipborne camera systems, and fixed underwater cameras to acquire image data.

[0077] Preferably, when the distance between each level of scenes and the image acquisition device is closer, the acquisition accuracy is higher, and vice versa.

[0078] S22: extracting the current object to be rendered in the image data of each level according to the image data of each level;

[0079] Specifically, an image segmentation algorithm may be optionally used to determine the objects to be rendered contained in each level of image.

[0080] S23: Determine the target position and target area of ​​each current object to be rendered in the image data of the corresponding level;

[0081] Specifically, according to the position of the object to be rendered in the image, a corner point or midpoint of the image can be selected as the coordinate origin, and the position coordinates of the midpoint or corner point of the object to be rendered are determined as the target position; according to its size, shape, etc., the area it occupies is determined as the target area.

[0082] S24: Determine the position relationship of the current object to be rendered according to each target position and target area.

[0083] Specifically, the relative positions of the objects to be rendered contained in the scenes at each level can be determined according to the target positions of the current objects to be rendered in the image data of the corresponding level obtained in step S23, and then the subordinate relationships of the objects to be rendered can be determined according to the target areas of the objects to be rendered in the image. By combining the relative positions and subordinate relationships of the objects to be rendered, the positional relationships of all the current objects to be rendered in the scenes to be rendered can be obtained.

[0084] Taking the water scene as an example, Figure 4As shown, suppose the current scene to be rendered includes a person, a flag, a boat, a fish, a water body and the sun, and the sun is in the sky, the water body is below the sun, the fish swims in the water body, the boat is above the water body, and the person and the flag are both in the cabin. The black box in the figure is the target area corresponding to the object to be rendered. In this scene, since the target areas of the water body, the boat and the sun do not contain each other, the water body, the boat and the sun are in a parallel relationship, and the target area of ​​the fish is included in the target area of ​​the water body. Therefore, the fish object is subordinate to the water body object, and its corresponding fish node is a child node of the water body node. Similarly, since the target area of ​​the person and the target area of ​​the flag are both included in the target area of ​​the boat, the person object and the flag object are subordinate to the boat object, and their corresponding person node and flag node are child nodes of the boat node.

[0085] S3: according to the data structure of the node to be rendered, obtain the relevant parameters of the current object to be rendered, and according to the position relationship between the current objects to be rendered, construct the current node tree model of the current scene to be rendered;

[0086] Specifically, it is optional to determine relevant parameters such as transformation matrix, rendering state, visibility flag, node type and other relevant parameters according to all objects actually existing in the current scene to be rendered obtained in step S2, that is, the objects to be rendered, and according to the specific definition mode of the initial node tree model, and fill them into the data structure of the corresponding node to be rendered in the initial node tree model respectively, and then determine the connection relationship between the rendering nodes according to the positional relationship between the current objects to be rendered in the current scene to be rendered, such as the example shown in step S2 that the fish node is a child node of the water node, the human node and the flag node are children of the cabin node, etc., so as to obtain the current node tree model suitable for the current scene to be rendered.

[0087] Similarly, taking the water body simulation node tree model as an example, the transformation matrix, rendering state, visibility flag and node type and other related parameters of the water body, ship, sun and other objects in the current scene to be rendered obtained in step S2 are obtained, and the corresponding water body node, ship node, sun node and other sub-nodes in the initial model are respectively filled in, and each node to be rendered in the current node tree model of the current water body scene can be obtained. It is worth noting that, according to the different objects to be rendered corresponding to each node to be rendered, its data structure is slightly different, such as the water body node, ship node, sun node and other sub-nodes have transformation matrix, rendering state, visibility flag and node type and other related parameters, but the water body node also includes the height map obtained according to the image data of the current scene to be rendered, while the ship node and the sun node do not include.

[0088] Preferably, taking step S21 of dividing the scene to be rendered into several levels as an example, each level of the scene to be rendered has a corresponding initial node tree model, and the initial node tree is updated according to steps S1-S3 to obtain the current node tree of each level of the scene to be rendered.

[0089] Preferably, according to the data structure of the node to be rendered, the relevant parameters of the current object to be rendered are obtained, which can be determined according to the actual situation of the node. Taking the determination of the transformation matrix as an example, it can optionally include:

[0090] S31: Establish a coordinate system with the geometric center of each node as the origin;

[0091] S32: Obtaining position information, rotation information, and scaling information corresponding to each node to obtain a local transformation matrix of each node;

[0092] S33: traverse all nodes in the node tree to be rendered, determine whether the current node has a parent node, if so, multiply the local transformation matrix by the world transformation matrix of its parent node to obtain the world transformation matrix of the current node; if not, the local transformation matrix of the current node is the world transformation matrix.

[0093] Specifically, you can choose to traverse all nodes in the initial node tree model from the root node to the leaf node, establish a coordinate system with the geometric center of each node as the origin, obtain the position information, rotation information and scaling information of the corresponding node according to the object corresponding to each node in the current scene to be rendered, and obtain the local transformation matrix of each node, and multiply the local transformation matrix of each node with the world transformation matrix of the corresponding parent node to obtain the world transformation matrix of each node, thereby determining the parameters of the transformation matrix of each node to be rendered; it is worth noting that if it is a root node, its world transformation matrix is ​​the local transformation matrix.

[0094] For example, assuming that the world transformation matrix of node A is W_A, its local transformation matrix is ​​L_A, and the world transformation matrix of its parent node B is W_B, then the world transformation matrix of node A is: W_A = L_A × W_B. Preferably, the relevant parameters of the current object to be rendered are obtained according to the data structure of the node to be rendered, which can be determined according to the actual situation of the node.

[0095] Preferably, obtaining the relevant parameters of the current object to be rendered further includes obtaining a height map and numerical data. Taking step S21 of obtaining the image data of the scene to be rendered hierarchically as an example, the step of obtaining the height map and numerical data includes:

[0096] S34: obtaining a height map of each level according to the image data of the scene to be rendered at each level;

[0097] Specifically, it is optional but not limited to obtaining a corresponding grayscale image based on the image data of each level, and mapping the grayscale value of each pixel in the grayscale image to the corresponding height value according to the range of the grayscale value and the height value, so as to obtain the height map of each level; it is worth noting that the height map of each type of scene to be rendered is stored in different nodes to be rendered, such as the height map in the water scene can be optionally stored in the water node, and the height map in the urban scene can be optionally stored in the building node. Various data storage methods are arbitrarily set by technical personnel in this field according to the type of scene to be rendered and the method of constructing the node tree.

[0098] For example, assuming that the grayscale value range in the grayscale image is 0 to 255, and the height value range in the height map is 0 to 100, it is optional but not limited to obtaining the height value corresponding to each pixel in the grayscale image in the height map through a linear mapping formula:

[0099]

[0100] Among them, y is the height value of each pixel in the height map, and x is the pixel value of the corresponding pixel in the grayscale image.

[0101] S35: Acquire numerical data of each level of the scene to be rendered, and obtain numerical data of each node to be rendered.

[0102] Specifically, taking the water body scene as an example, it is optional but not limited to that technical personnel in this field use the image acquisition device as the center to collect the numerical data of water bodies at each level through the data acquisition device, preferably to obtain more detailed numerical data based on the specific position of each node in each level; specifically, the data acquisition equipment may be selected from commonly used data acquisition equipment such as water level meter, current meter, satellite remote sensing, anemometer, wind vane, etc. The wind speed above the current water body is obtained according to the anemometer, the wind direction above the current water body is obtained according to the wind vane, the water depth of the current water body is obtained according to the water level meter, and the flow velocity of the current water body is obtained according to the current velocity meter, so as to collect commonly used numerical data such as water flow velocity, water depth, wind speed and wind direction of the scene or terrain where the water body is located.

[0103] Preferably, since the objects to be rendered included in the scene to be rendered may be slightly different from the initial node tree model constructed previously, step S3 further includes:

[0104] S31': Determine whether each object to be rendered in the current scene to be rendered has a corresponding node to be rendered in the initial node tree model; if so, obtain relevant parameters of the current object to be rendered and fill in the corresponding node; if not, create a corresponding node to be rendered, obtain relevant parameters of the current object to be rendered and fill in the corresponding node;

[0105] S32': Determine whether there is a blank node to be rendered in the initial node tree model, if so, delete the blank node to be rendered, if not, leave it unchanged;

[0106] In this embodiment, steps S31 ′ and S32 ′ are added to check for omissions and redundant nodes in the initial node tree model to obtain a complete current node tree model. Specifically, it is optional to sequentially obtain the parameters of each object to be rendered in the current scene to be rendered, and fill in the corresponding node to be rendered in the initial node tree model. If the current object to be rendered is not fully filled in the initial node tree model, that is, the corresponding node to be rendered definition is not found in the initial node tree model, that is, when the initial node tree model was originally created, this type of node was not considered, and its data structure and connection relationship were not defined. Then, according to the creation method of step S1, an unfilled object, that is, a node to be rendered corresponding to the current object, can be created, and then the parameters of the current object to be rendered are filled in the corresponding node to be rendered. Then, the iteration is continued until all relevant parameters of the objects to be rendered have been filled in the initial node tree model. It is also possible that redundant nodes are created in the initial node tree model relative to the actual scene. Therefore, it is necessary to determine whether there are blank nodes to be rendered in the initial node tree model, that is, there is no corresponding object to be rendered in the current scene to be rendered. If so, delete it. When all blank nodes to be rendered are deleted, the subsequent steps can be executed.

[0107] Taking the water scene as an example, suppose that the initial node tree model includes fish nodes, stone nodes, grass nodes and snake nodes, and the current scene to be rendered actually includes fish objects, stone objects, grass objects and crab objects, then the relevant parameters of the fish object, stone object and grass object are filled into the fish node, stone node and grass node respectively. Since there is no to-be-rendered node corresponding to the crab object in the initial node tree model, it is necessary to create a crab node in the initial node tree model and fill the relevant parameters of the crab object in the current scene to be rendered into the crab node; at the same time, since there is a snake node in the initial node tree model, but there is actually no snake object in the current scene to be rendered, it is necessary to delete the snake node in the initial node tree to ensure that there is no blank node in the current node tree model.

[0108] S33': updating the connection relationship between the nodes according to the position relationship between the current objects to be rendered.

[0109] Specifically, it is optional but not limited to obtaining the subordinate relationship between the current objects to be rendered according to the position relationship between the current objects to be rendered obtained in step S2, and changing the connection relationship between the nodes to obtain the final current node tree model.

[0110] Taking the water scene as an example, in the initial node tree model, the scene to be rendered is the root node, the model node and interface node required in the scene are the second-level nodes, the water node, the ship node and the sun node are the child nodes of the model node, that is, the third-level nodes, and the person node and the flag node are the child nodes of the ship node, that is, the fourth-level nodes. Since the scene is constantly changing, the person in the example is a child node of the ship node in the previous node tree model, but if the person jumps into the water from the boat, the person in the current scene to be rendered swims in the water. Therefore, the person node is no longer subordinate to the ship node, but should be modified to be subordinate to the water node. The parent-child relationship between the person node and the ship node in the initial node tree should be changed according to the position relationship between the current objects to be rendered in the current scene to be rendered. The connection relationship between the rendering nodes corresponding to each object should be changed, that is, the person node is changed to a child node of the water node to update the specific structure of the initial node tree.

[0111] More preferably, step S3 preferably further comprises:

[0112] S34': Obtain the bounding box of each node in the current node tree model, and determine whether it is located within the viewing cone of the image acquisition device. If not, remove the corresponding node to obtain an updated current node tree model;

[0113] For example, the specific steps of obtaining the bounding box of each node in the current node tree model may include but are not limited to:

[0114] S341': Obtain the vertex coordinates of the geometric body of each node in the current node tree model, and obtain the minimum coordinate extreme value and the maximum coordinate extreme value of the geometric body of each node;

[0115] S342': construct a bounding box according to the coordinate extreme value of the geometric body of each node to obtain the bounding box of the corresponding node. Then determine whether the bounding box of each node is within the viewing cone of the image acquisition device. If not, remove the corresponding node to obtain the updated current node tree model.

[0116] Specifically, it is optional but not limited to obtaining the vertex coordinates of each node geometry, traversing all vertices, finding the minimum and maximum coordinate extremes, constructing a bounding box based on the coordinate extremes, obtaining the bounding box of the corresponding node, and determining whether the bounding box of each node is within the viewing cone of the image acquisition device. If not, it is an invisible node, and the invisible nodes are removed to obtain the final node tree for subsequent rendering operations; it is worth noting that if the current node has child nodes, the bounding box of the current node includes the bounding boxes of all descendant nodes. If the bounding boxes of the current node and all its descendant nodes are within the viewing cone of the image acquisition device, it is a visible node, otherwise it is an invisible node, and the invisible nodes in its child nodes need to be removed until the bounding boxes of the current node and all its descendant nodes are within the viewing cone of the image acquisition device to obtain the final current node tree model.

[0117] Further preferably, it is optional but not limited to obtaining the occlusion relationship between the nodes through a deep occlusion method, and when performing subsequent rendering steps, stopping rendering of the occluded nodes to improve rendering efficiency and save rendering resources.

[0118] S4: Obtaining a texture model of the scene to be rendered according to the current node tree model, and rendering the texture model to obtain a current rendering result.

[0119] Specifically, taking the water body simulation node tree model as an example, it is optional but not limited to obtaining and connecting the vertices in the height map according to the height map of the water body nodes in the current node tree model to obtain the three-dimensional mesh model of the current scene to be rendered, and at the same time, according to the data structure of each node in the current node tree model, to obtain the texture map of each node, and map the texture map to the three-dimensional mesh model to obtain the texture model of the scene to be rendered.

[0120] Taking step S21 of dividing the scene to be rendered into several levels as an example, the step of obtaining the texture model of the scene to be rendered according to the current node tree model may optionally include:

[0121] S41: determining the positions of each vertex according to the height map of the nodes to be rendered in the current node tree model of each level, and connecting the positions of each vertex to obtain the three-dimensional mesh models of each level;

[0122] Specifically, it is optional but not limited to the height map of the water body node in the current node tree model corresponding to the current scene to be rendered at each level obtained in step S34, dividing the height map of each level into several parts, obtaining the point with the highest pixel value in each height map, and treating it as a vertex. Since the pixel value of each vertex represents its altitude in reality, each vertex is mapped to a three-dimensional space according to the pixel value of each vertex, and then all the vertices of each height map are connected to obtain a three-dimensional mesh model corresponding to each level; preferably, the number of vertices in the height map is arbitrarily set by a technician in this field according to conditions such as rendering accuracy.

[0123] S42: Obtaining a texture map of each node according to the data structure of each node to be rendered in the current node tree model of each level;

[0124] Specifically, it is optional but not limited to binding the image data and numerical data of each node to be rendered obtained in step S3 to a number of blank textures to obtain a texture map corresponding to each node.

[0125] Preferably, the step of obtaining the texture map of each node according to the data structure of each node to be rendered in the current node tree model of each level may optionally include but is not limited to:

[0126] S421: creating a number of two-dimensional arrays according to the amount of image data and numerical data, and filling the image data and numerical data into the corresponding two-dimensional arrays to obtain a texture data array;

[0127] Specifically, since the data needs to be converted into the form of a two-dimensional array when binding it to a blank texture in order to meet the conditions for binding the texture and improve the subsequent rendering quality and efficiency, it is optional but not limited to determining the size of the two-dimensional array based on the prior texture resolution, and determining the number of the two-dimensional array based on the amount of image data and numerical data, and determining the position of each data point in the image data and numerical data in the two-dimensional array so as to fill the data into the two-dimensional array and obtain the final texture data array; the prior texture resolution can be optionally obtained by technical personnel in this field based on parameters such as the size and repeatability of the blank texture, compression technology, etc.

[0128] Preferably, taking the water scene as an example, assuming that the prior texture resolution is 255×255, six 256x256 two-dimensional arrays can be optionally created, corresponding to image data, flow velocity in the x-direction, flow velocity in the y-direction, water depth, wind speed and wind direction, and each array element stores all levels of attribute information of a pixel.

[0129] Further preferably, before filling the image data and the numerical data into the two-dimensional array, the following steps may be performed, but are not limited to:

[0130] S4211: normalizing the image data and numerical data of each level;

[0131] Specifically, taking the water scene as an example, it is optional but not limited to substituting linear data such as image data, flow velocity data, water depth data, wind speed data into linear normalization formula 2-1, and substituting angle value data such as wind direction data into angle normalization formula 2-2 to obtain the corresponding normalized data:

[0132] x_normalized1 = (x1 - x_min) / (x_max - x_min) = x1 / x_max 2-1

[0133] Among them, x_normalized1 is the linear data before normalization, x1 is the linear data after normalization, x_min is the minimum value of the linear data before normalization, and x_max is the maximum value of the linear data before normalization.

[0134] x_normalized 2= 2×(x2 - min_angle) / (max_angle - min_angle) - 1 2-2

[0135] Among them, x_normalized2 is the angle value data before normalization, x2 is the angle value data after normalization, min_angle is the minimum value of the angle value data before normalization, and max_angle is the maximum value of the angle value data before normalization.

[0136] Taking the image data with a minimum value of 0 meters and a maximum value of 100 meters as an example, substitute the image data into the linear normalization formula 2-1 to obtain the normalized image data:

[0137] x_normalized1 = (x1 - 0) / (100 - 0) = x 1 / 100

[0138] Among them, x_normalized1 is the normalized image data, and x1 is the normalized image data.

[0139] Taking the wind direction data ranging from 0 to 360 degrees as an example, substitute the wind direction data into the angle normalization formula 2-2 to obtain the normalized wind direction data:

[0140] x_normalized 2= 2× (x 2- 0) / (360 - 0) - 1

[0141] S4212: quantizing the normalized image data and numerical data to a specific precision to obtain optimized image data and numerical data.

[0142] Specifically, it is preferred to quantize all normalized image data and numerical data into 8-bit integers for subsequent storage and processing; it is worth noting that when the image data and numerical data are quantized into 8-bit integers, that is, the image data and numerical data are mapped into an 8-bit integer range, i.e., 0 to 255, but it does not mean that the final result will definitely be an 8-bit binary number (i.e., 00000000 to 11111111), but it represents a discrete representation of the value within this range. Therefore, even if the result is a three-digit number, it can still represent a value within the 8-bit integer range.

[0143] Preferably, the normalized image data and numerical data are substituted into the quantization formula to obtain the corresponding optimized image data and optimized numerical data:

[0144] x_quantized = round(x_normalized × (2^8 - 1)) 2-3

[0145] Among them, x_quantized is the quantized image data and numerical data, x_normalized is the normalized data, and round() is a preset function used to round the function in brackets to ensure that the calculation result is an eight-bit integer.

[0146] For example, when the normalized value of the image data is 0.5, substitute it into the quantization formula to get the quantized value:

[0147] round(0.5× (2^8 - 1)) = 128

[0148] S422: Fill the data of each node in the texture data array into a number of blank textures respectively to obtain the texture map corresponding to each node.

[0149] Specifically, it is optional but not limited to create a number of blank textures equal to the number of nodes, and fill the image data and numerical data of each node in the texture data array into the same blank texture, so as to obtain the texture map corresponding to each node.

[0150] S43: mapping the texture maps of the nodes included in each level to the surface of the three-dimensional mesh model of the corresponding level to obtain the texture model of each level;

[0151] Specifically, the texture map of each node obtained in step S42 may be optionally mapped to the surface of the three-dimensional mesh model of the level where each node is located, so as to obtain the texture model of each level.

[0152] S44: Rendering the texture model to obtain a current rendering result.

[0153] Specifically, it is optional but not limited to uploading the texture model data to the GPU, and then creating and starting a compute shader in the GPU to render the texture model, so as to obtain the current rendering result after rendering the current node tree model corresponding to the rendered scene.

[0154] Preferably, taking steps S41-S43 of dividing the scene to be rendered into several levels to obtain texture models of each level as an example, the steps of rendering the texture model to obtain the current rendering result may optionally include but are not limited to:

[0155] S441: creating a compute shader program on the GPU and uploading texture model data of each level to the GPU;

[0156] Specifically, optionally but not limited to, compiling and linking the compute shader code on the GPU to create an executable compute shader program, and then uploading the texture model data to be processed to the GPU through buffer objects such as vertex buffers.

[0157] S442: Set the parameters of the compute shader program, and call a preset function to start the compute shader to render the data of the texture model at each level, obtain the rendering results of each level, and transfer the edge state of the rendering results of each level to obtain the final rendering result.

[0158] Specifically, it is optional but not limited to setting working parameters of the compute shader, such as the number and size of work groups, and finally calling the function provided by the API in the existing image rendering engine to start the execution of the compute shader to obtain the final rendering result.

[0159] More specifically, taking the water scene as an example, it is optional but not limited to using the GPU's compute shader to simulate and calculate the height maps of each level of water in turn, and using sub-stepping technology to avoid the water moving too fast, resulting in the CFL condition (Courant-Friedrichs-Lewy condition) not being met, and by introducing multiple sub-steps in each main time step to improve the accuracy and stability of the simulation, the rendering results of the texture model of each level of water are obtained, and the edge state of the rendering result is transferred, and the edge area included in the rendering result of the previous level but not included in the rendering result of the next level is filled into the edge area of ​​the next level until the rendering operation of the texture model of the last level is completed. At this time, the rendering result contains image data and numerical data of all levels, that is, the final rendering result is obtained.

[0160] For example, in the image rendering engine OpenGL, the glDispatchCompute function is called to start the compute shader in the GPU, and then the GPU will automatically allocate threads to execute the compute shader code in parallel according to the size and number of work groups to render the texture model.

[0161] Preferably, if each node also includes a transparent object, the texture model is rendered, and before the step of obtaining the current rendering result, the step further includes:

[0162] S44': obtaining the distance between each transparent object and the data acquisition device, determining the rendering order of the transparent objects, and rendering each transparent object in turn according to the rendering order of the transparent objects.

[0163] Specifically, it is optional but not limited to sorting each transparent object from near to far according to the distance between each transparent object and the data acquisition device to determine the rendering order of the transparent objects, and then preferably turning on the blending mode in the opengl image rendering engine through glEnable (GL_BLEND), by allowing the rendered pixels to be combined with the pixels in the frame buffer to form a new color value, thereby producing a correct visual effect, so as to better render the transparent objects and obtain the final rendering result.

[0164] In this embodiment, a rendering method based on a node tree of the present invention is provided. By determining the common objects of each scene according to the type of the scene to be rendered, defining each common object as the data structure of the node to be rendered according to the characteristics of the common object, and determining the connection relationship between each node to be rendered according to the positional relationship of each common object, an initial node tree model is constructed to reduce the degree of data coupling, so that the number of nodes can be expanded later and the maintainability of data can be improved. Then, the current scene to be rendered is obtained, and the current object to be rendered and its positional relationship are determined. Then, the relevant parameters of the current object to be rendered can be obtained according to the data structure of the node to be rendered, and the current node tree model of the current scene to be rendered can be constructed according to the positional relationship between each current object to be rendered, so that the data can be rendered according to the relevant parameters of each node later, the rendering efficiency can be improved, and the rendering cost can be reduced. Finally, the texture model of the scene to be rendered is obtained according to the current node tree model, and the texture model is rendered to obtain the current rendering result. In the whole process, data and rendering are separated, which solves the problems of high data coupling, low rendering efficiency, and high resource consumption during rendering in the prior art.

[0165] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A rendering method based on a node tree, characterized in that: include: According to the type of the scene to be rendered, determine the common objects of each scene, define each common object as the data structure of the node to be rendered according to the characteristics of the common object, and determine the connection relationship between the nodes to be rendered according to the position relationship of each common object, and build an initial node tree model; It includes scene root node, model node and interface node; model node and interface node are first-level child nodes of scene root node; In the model node, each sub-node corresponds to an object to be rendered in the scene to be rendered, and the connection relationship of each subordinate sub-node is determined according to the position relationship between the objects to be rendered; In the interface node, each sub-node corresponds to an interactive element in the interface to be rendered, and the connection relationship between each subordinate sub-node is determined according to the type of each sub-node; Obtaining the current scene to be rendered, determining the current object to be rendered and its positional relationship; including: dividing the scene to be rendered into several levels, and obtaining image data of each level with different precision; extracting the current object to be rendered in the image data of each level according to the image data of each level; determining the target position and target area of ​​each current object to be rendered in the image data of the corresponding level; determining the relative position of the objects to be rendered contained in the scene of each level according to each target position and target area, determining the subordinate relationship of each object to be rendered according to the target area of ​​each object to be rendered in the image, and obtaining the positional relationship of the current object to be rendered by combining the relative position and subordinate relationship of each object to be rendered; According to the data structure of the node to be rendered, the relevant parameters of the current object to be rendered are obtained, and according to the positional relationship between the current objects to be rendered, the current node tree model of the current scene to be rendered is constructed; the data structure includes: any one or more of a transformation matrix, a rendering state, a visibility flag and a node type; wherein: the transformation matrix includes any one or more of position information, rotation information and scaling information; the rendering state includes any one or more of a material model, a texture model and a lighting model; the visibility flag includes any one or more of a visible state, an invisible state, a hidden state, a partially visible state, an occluded state and a transparent state; the node type includes any one or more of a geometric node, a light source node and a camera node; The texture model of the scene to be rendered is obtained according to the current node tree model, and the texture model is rendered to obtain the current rendering result.

2. The method according to claim 1, characterized in that: The steps of determining the transformation matrix include: Establish a coordinate system with the geometric center of each node as the origin; Get the position information, rotation information and scaling information corresponding to the node to obtain the local transformation matrix of each node; Traverse all nodes in the node tree to be rendered to determine whether the current node has a parent node. If so, multiply the local transformation matrix with the world transformation matrix of its parent node to obtain the world transformation matrix of the current node; if not, the local transformation matrix of the current node is the world transformation matrix.

3. The method according to claim 1, characterized in that: The steps of constructing the current node tree model of the current scene to be rendered include: Determine whether each object to be rendered in the current scene to be rendered has a corresponding node to be rendered in the initial node tree model. If so, obtain the relevant parameters of the current object to be rendered and fill in the corresponding node; if not, create the corresponding node to be rendered, obtain the relevant parameters of the current object to be rendered and fill in the corresponding node; Or / and, determine whether there is a blank node to be rendered in the initial node tree model, if so, delete the blank node to be rendered, if not, leave it unchanged; Or / and, updating the connection relationship between the nodes according to the position relationship between the objects currently to be rendered; Or / and, obtain the bounding box of each node in the current node tree model, and determine whether it is located in the viewing cone of the image acquisition device. If not, remove the corresponding node to obtain an updated current node tree model.

4. The method according to claim 3, characterized in that The steps of obtaining the bounding box of each node in the current node tree model include: Get the vertex coordinates of the geometric body of each node in the current node tree model, and get the minimum coordinate extreme value and the maximum coordinate extreme value of the geometric body of each node; The bounding box is constructed according to the coordinate extreme values ​​of the geometric body of each node to obtain the bounding box of the corresponding node.

5. The method according to claim 4, characterized in that The step of obtaining the texture model of the scene to be rendered according to the current node tree model includes: According to the height map of the nodes to be rendered in the current node tree model of each level, the positions of each vertex are determined, and the positions of each vertex are connected to obtain the three-dimensional mesh models of each level; According to the data structure of each node to be rendered in the current node tree model at each level, the texture map of each node is obtained; The texture maps of the nodes contained in each level are mapped to the surface of the three-dimensional mesh model of the corresponding level to obtain the texture models of each level.

6. The method according to claim 5, characterized in that The step of obtaining the texture map of each node according to the data structure of each node to be rendered in the current node tree model of each level includes: According to the prior texture resolution and the amount of image data and numerical data, several two-dimensional arrays are created, and the image data and numerical data are filled into the corresponding two-dimensional arrays to obtain a texture data array; Fill the data of each node in the texture data array into several blank textures to obtain the texture map corresponding to each node.

7. The method according to claim 6, characterized in that The steps of rendering the texture model and obtaining the current rendering result include: Create a compute shader program on the GPU and upload the texture model data of each level to the GPU; Set the parameters of the compute shader program, and call the preset function to start the compute shader to render the data of the texture model at each level, obtain the rendering results of each level, and transfer the edge state of the rendering results of each level to obtain the final rendering result.

8. The method according to any one of claims 1 to 7, characterized in that: Rendering the texture model and obtaining the current rendering result also includes: The distance between each transparent object and the data acquisition device is obtained, and the rendering order of the transparent objects is determined, so as to render each transparent object in sequence according to the rendering order of the transparent objects.