CN110580734B - Three-dimensional scene rendering method, device, equipment and readable storage medium - Google Patents

Three-dimensional scene rendering method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN110580734B
CN110580734B CN201910865723.0A CN201910865723A CN110580734B CN 110580734 B CN110580734 B CN 110580734B CN 201910865723 A CN201910865723 A CN 201910865723A CN 110580734 B CN110580734 B CN 110580734B
Authority
CN
China
Prior art keywords
node
state attribute
attribute
tree
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910865723.0A
Other languages
Chinese (zh)
Other versions
CN110580734A (en
Inventor
俞蔚
李斌
刘凤芹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Kelan Information Technology Co ltd
Original Assignee
Zhejiang Kelan Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Kelan Information Technology Co ltd filed Critical Zhejiang Kelan Information Technology Co ltd
Priority to CN201910865723.0A priority Critical patent/CN110580734B/en
Publication of CN110580734A publication Critical patent/CN110580734A/en
Application granted granted Critical
Publication of CN110580734B publication Critical patent/CN110580734B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Geometry (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a three-dimensional scene rendering method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: acquiring a graph structure corresponding to a three-dimensional scene; creating a root node of a state attribute tree, creating state attribute nodes corresponding to a state attribute set in the graph structure, and sequentially inserting the state attribute nodes into the state attribute tree; rendering of the three-dimensional scene is achieved based on the state attribute tree; inserting state attribute nodes into the state attribute tree in turn, including: determining any state attribute node as a target node; judging whether a corresponding state attribute node exists in the state attribute tree, if so, determining the state attribute node as a target father node, and if not, determining the root node of the state attribute tree as a target node; if the target node exists under the target parent node, determining to complete the insertion, and if the target node does not exist under the target parent node, inserting the target node under the target parent node. Thereby improving rendering efficiency.

Description

Three-dimensional scene rendering method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of three-dimensional scene rendering technologies, and in particular, to a three-dimensional scene rendering method, apparatus, device, and readable storage medium.
Background
Three-dimensional scenes are used to simulate the real world, i.e., three-dimensional scenes obtained by organizing a plurality of objects in real world space according to their spatial properties (size, position, shape, etc.) are used to simulate the space. In the prior art, a three-dimensional scene often organizes objects contained in the three-dimensional scene through a graph structure, the graph structure contains graph nodes, the graph nodes comprise grouping nodes, scheduling nodes, drawing nodes and the like, in order to achieve a rich and gorgeous drawing effect, one or more different state attributes are usually set on the graph nodes, the same state attribute can be set on the different graph nodes, and the graph structure in a specific scene can be shown in fig. 1. In the graph structure, the same state attribute may exist in the same level to occupy multiple graph nodes, for example, material_0 in fig. 1 occupies two graph nodes in the second level, and in this case, when three-dimensional scene rendering is implemented based on the graph structure, more logic resources are wasted, which results in lower rendering efficiency of the three-dimensional scene.
In summary, in the prior art, rendering of a three-dimensional scene based on a graph structure has the problem of low rendering efficiency.
Disclosure of Invention
The invention aims to provide a three-dimensional scene rendering method, device and equipment and a readable storage medium, which can solve the problem of lower rendering efficiency in the prior art for rendering a three-dimensional scene based on a graph structure.
In order to achieve the above object, the present invention provides the following technical solutions:
a three-dimensional scene rendering method, comprising:
acquiring a graph structure corresponding to a three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node;
creating a root node of a state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree; rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree;
the state attribute nodes are sequentially inserted into the state attribute tree, and the method comprises the following steps:
determining any state attribute node as a target node;
judging whether a state attribute node corresponding to a parent node of the graph node corresponding to the target node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target node;
if the target node exists under the target father node, determining to complete the insertion, and if the target node does not exist under the target father node, inserting the target node under the target father node.
Preferably, the rendering of the corresponding three-dimensional scene based on the state attribute tree includes:
and acquiring an inheritance type of each tree node in the state attribute tree, determining an attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering a corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
Preferably, obtaining the inheritance type of each tree node in the state attribute tree includes:
acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not affected by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
Preferably, after rendering the corresponding three-dimensional scene based on the state attribute tree, the method further includes:
and outputting the rendered three-dimensional scene to a designated terminal for the corresponding staff to acquire.
A three-dimensional scene rendering device, comprising:
an acquisition module for: acquiring a graph structure corresponding to a three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node;
a creation module for: creating a root node of a state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree;
a rendering module for: rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree;
wherein the creation module comprises:
an insertion unit for: determining any state attribute node as a target node; judging whether a state attribute node corresponding to a parent node of the graph node corresponding to the target node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target node; if the target node exists under the target father node, determining to complete the insertion, and if the target node does not exist under the target father node, inserting the target node under the target father node.
Preferably, the rendering module includes:
a rendering unit configured to: and acquiring an inheritance type of each tree node in the state attribute tree, determining an attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering a corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
Preferably, the rendering unit includes:
an acquisition subunit configured to: acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not affected by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
Preferably, the method further comprises:
an output module for: and after the rendering of the corresponding three-dimensional scene is realized based on the state attribute tree, outputting the rendered three-dimensional scene to a designated terminal for the corresponding staff to acquire.
A three-dimensional scene rendering device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the three-dimensional scene rendering method according to any of the preceding claims when executing the computer program.
A computer readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the three-dimensional scene rendering method as claimed in any of the preceding claims.
According to the three-dimensional scene rendering method, device and equipment and the readable storage medium, the graph structure corresponding to the three-dimensional scene is converted into the state attribute tree, and the condition that the same state attribute set occupies two tree nodes cannot occur under the same parent node of the same level in the conversion process, so that the structure based on the three-dimensional scene rendering is simplified, the waste of logic resources is avoided, and the rendering efficiency of the three-dimensional scene is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a three-dimensional scene map structure in a specific scene of the prior art;
FIG. 2 is a flowchart of a three-dimensional scene rendering method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a state attribute tree corresponding to the structure of FIG. 1 in a three-dimensional scene rendering method according to an embodiment of the present invention;
FIG. 4 is an exemplary diagram of a state attribute tree enumerated during the description of a problem to be solved by a three-dimensional scene rendering method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a three-dimensional scene rendering device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 2, a flowchart of a three-dimensional scene rendering method according to an embodiment of the present invention may include:
s11: and acquiring a graph structure corresponding to the three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node.
It should be noted that, the execution body of the three-dimensional scene rendering method provided by the embodiment of the present invention may be a corresponding three-dimensional scene rendering device. The state attribute, the three-dimensional scene and the graph structure have the same meaning as the corresponding concept in the prior art; the opengl (or referred to as an opengl state machine) is a software interface of graphics hardware, in this embodiment, drawing of an object in a three-dimensional scene is implemented based on the opengl (the drawing of the object in the three-dimensional scene is implemented based on the opengl is the same as the implementation principle of a corresponding technical scheme in the prior art), while the state attribute is defined for the opengl, which can be regarded as a machine capable of recording its own state, where the status of the opengl itself can be referred to as the state attribute, such as an alpha test and a depth test currently used by the opengl, and the state attribute actually corresponds to the attribute such as the alpha test and the depth test of the object in the three-dimensional scene, so the state attribute can be regarded as the status of the opengl itself, which represents the attribute of the object in the three-dimensional scene; corresponding state attributes and attribute values are set on one or more graph nodes of the graph structure according to drawing requirements when the three-dimensional scene is rendered, wherein the graph structure is relative to a tree structure, and for the tree structure, one father node can be provided with a plurality of child nodes, but one child node only is provided with one father node, and the graph structure can be provided with a plurality of child nodes, and the child nodes can be provided with a plurality of father nodes. The map nodes in the map structure have corresponding state attributes and attribute values, in this embodiment, a corresponding state attribute set is set for the map nodes having the state attributes and the attribute values, where the state attribute set includes the state attributes and the attribute values of the corresponding map nodes, that is, each map node having the state attributes and the attribute values has a state attribute set, and each state attribute set includes at least one state attribute and the corresponding attribute value; when rendering a three-dimensional scene based on a graph structure, that is, based on a state attribute set of each graph node in the graph structure, for example, when rendering the three-dimensional scene according to the graph structure shown in fig. 1, the three-dimensional scene needs to be drawn according to the state attribute set on each graph node included in a branch corresponding to an object to be drawn in the graph structure; taking fig. 1 as an example, the root node is LIGHT, the leftmost branches are LIGHT, material _0 and texture_0, and the last graph node (texture_0) of the leftmost branch is marked with 1, that is, the leftmost branch needs to be used for drawing the object 1, when the corresponding object 1 is drawn, the state attribute LIGHT of the object is set to be (LIGHT, 0), the material_0 is (Material, 0), the texture_0 is (text, 0), and the other objects are also similar.
S12: creating a root node of the state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree. The method sequentially inserts the state attribute nodes into the state attribute tree, and comprises the following steps: determining any state attribute node as a target node; judging whether a state attribute node corresponding to a parent node of a target node corresponding graph node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target node; if the target node exists under the target parent node, determining to complete the insertion, and if the target node does not exist under the target parent node, inserting the target node under the target parent node.
In this embodiment, a state attribute tree is created, where tree nodes included in the state attribute tree correspond to different state attribute sets, so that rendering of a three-dimensional scene is implemented based on the state attribute tree. Specifically, a root node of the state attribute tree needs to be created first, a state attribute set corresponding to the root node of the state attribute tree contains all state attributes contained in the graph structure, and the state attributes contained in the state attribute set corresponding to the root node of the default state attribute tree are all invalid states (the state attribute is invalid, that is, the attribute value of the state attribute is a value representing the invalid state), so that when three-dimensional scene rendering is realized based on the opengl state machine, the state attribute corresponding to the root node can be consistent with the states of the state attributes used in the current opengl state machine, the state of the state attribute on the opengl state machine does not need to be modified, state switching is reduced, and time cost is saved.
All state attribute sets contained in the graph structure can be obtained by traversing the graph structure, and after all state attribute sets in the graph structure are obtained, state attribute nodes corresponding to each state attribute set can be created, specifically, each state attribute node represents one state attribute set; when the state attribute nodes are sequentially inserted into the state attribute tree, the state attribute nodes which need to be inserted into the state attribute tree are called target nodes, whether the state attribute nodes corresponding to the parent nodes of the graph nodes corresponding to the target nodes exist in the state attribute tree is judged, if so, the state attribute nodes corresponding to the parent nodes of the graph nodes corresponding to the target nodes in the graph structure are determined to be the parent nodes of the target nodes, namely, the target parent nodes, if not, the root nodes of the state attribute tree are directly determined to be the parent nodes of the target nodes, namely, the target parent nodes, and further, after the parent nodes of the target nodes are determined, the insertion of the target nodes into the state attribute tree is realized, specifically: if the target node exists under the target father node, determining that the insertion is completed, and if the target node does not exist under the target father node, inserting the target node under the target father node; thereby realizing the conversion from the graph structure to the state attribute tree; the state attribute tree obtained by the method only comprises state attribute nodes corresponding to the graph nodes with the state attribute set, and the same two state attribute nodes cannot be contained under the same father node. In addition, for the objects (1 to 6 as shown in fig. 1) marked in the graph structure, the object is also required to be marked in the state attribute tree, specifically, any one of the objects shown in the graph structure may be determined as a target object, a state attribute node corresponding to the state attribute set of the graph node marked with the target object in the state attribute tree is determined, and the target object is marked under the determined state attribute node corresponding to the state attribute set of the graph node marked with the target object (fig. 3 is the state attribute tree corresponding to fig. 2, where 1 to 6 are marked objects), so that when drawing is implemented based on the state attribute tree, the object corresponding to each branch can be determined, and specifically, if two or more branches correspond to one object (such as two branches corresponding to the object 6 in fig. 3), the corresponding object is sequentially drawn according to each branch.
S13: rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree.
The principle of implementing rendering of the corresponding three-dimensional scene based on the state attribute tree is the same as the principle of implementing rendering of the corresponding three-dimensional scene based on the graph structure, and will not be described herein.
In the technical scheme disclosed by the application, the graph structure corresponding to the three-dimensional scene is converted into the state attribute tree, and in the conversion process, the condition that the same state attribute set occupies two tree nodes cannot occur under the same parent node of the same level, so that the structure based on the three-dimensional scene rendering is simplified, the waste of logic resources is avoided, and the rendering efficiency of the three-dimensional scene is improved.
In addition, the process of inserting the state attribute nodes corresponding to each state attribute set in the graph structure into the state attribute tree can be realized based on a stack, namely, the state attribute sets which need to be inserted are pushed into the stack each time, and the state attribute nodes are popped from the stack after the insertion of the corresponding state attribute nodes is completed; specifically, the above steps S12 to S13 (the process of obtaining the state attribute tree based on the graph structure) will be described taking the graph structure of fig. 1 as an example, and the corresponding obtained state attribute tree is shown in fig. 3 (it should be noted that, because the graph structure includes far more graph nodes than the graph structure shown in fig. 1 in the practical application, the graph structure is converted into the corresponding state attribute tree by using the technical solution of the present application, so that the merging of the corresponding tree nodes of the same state attribute set can be achieved, that is, the situation that the same state attribute set occupies two tree nodes under the same parent node of the same level will not occur, so in the practical application, the state attribute tree is simplified relative to the corresponding graph structure, that is, the structure based on which the three-dimensional scene rendering is implemented is simplified), which specifically may include:
creating a root node0 of the state attribute tree, wherein a state attribute set of the root node0 comprises all state attributes contained in the graph structure, and the state attributes in the state attribute set of the root node0 are all invalid states;
cutting from a root node of the graph structure, if the root node of the graph structure contains a state attribute set, pushing the state attribute set of the root node into a stack, pushing the Light into the stack, searching whether a state attribute node corresponding to the pushed Light exists on the root node0, if not, creating a state attribute node1 of the Light, inserting the state attribute node1 into a child node of the root node0 (or inserting the state attribute node into the child node of the root node 0), popping the Light out of the stack, and cutting a next object;
material_0 is pushed, a state attribute node2 is created, inserted into a child node of the node1, and the next object is cut;
building a state attribute node3 by stacking the texture_0, inserting the state attribute node3 into a child node of the node2, marking an object 1, popping the texture_0, and cutting a next object;
building a state attribute node4 by pushing the light_0 stack, inserting the state attribute node4 into a child node of the node2, and cutting out a next object;
the PointSize_1 is pushed, a state attribute node5 is created, inserted into a child node of the node4, and the next object is cut;
stacking Texenv_0, creating a state attribute node6, inserting the state attribute node6 into a child node of the node5, marking an object 2, stacking off the Texenv_0, and cutting out the next object;
the front face_0 pushes a stack, creates a state attribute node7, inserts the state attribute node7 into a child node of the node5, and cuts out the next object;
the Blend_1 is pushed, a state attribute node8 is created, inserted into a child node of the node7, and an object 3 is marked;
the blend_1 is popped;
front face_0 pop;
the PointSize_1 is popped;
light_0 popped;
material_0 is popped off, and the next object is cut;
metal_1 pushes a stack, creates a state attribute node9, inserts the state attribute node9 into a child node of the node1, and cuts out a next object;
the PointSize_1 is pushed, a state attribute node10 is created, inserted into a child node of the node9, and the next object is cut;
building a state attribute node11 by pushing the light_0 stack, inserting the state attribute node11 into a child node of the node10, and cutting out a next object;
a texture_1 push is carried out, a state attribute node12 is created, the state attribute node is inserted into a child node of the node11, and an object 4 is marked;
the texture_1 is popped;
light_0 is popped off, and the next object is cut;
a blend_0 push is carried out, a state attribute node13 is created, the state attribute node is inserted into a child node of the node10, and the next object is cut;
a texture_1 push is carried out, a state attribute node14 is created, the state attribute node is inserted into a child node of the node13, and an object 5 is marked;
the texture_1 is popped;
the blend_0 is popped;
the PointSize_1 is popped;
material_1 is popped off, and the next object is cut;
material_2 is pushed, a state attribute node15 is created, inserted into a child node of node1, and the next object is cut;
the CullFace_1 pushes a stack, creates a state attribute node16, inserts the state attribute node16 into a child node of the node15, and cuts out the next object;
stacking Texgen_1, creating a state attribute node17, inserting the state attribute node17 into a child node of the node16, and marking an object 6;
texgen_pop;
the CullFace_1 is popped;
material_2 is popped off, and the next object is cut;
material_0 pushes a stack, searches the state attribute set from the child node of node1, searches successfully, directly uses the child node2, and cuts out the next object;
stacking Texgen_1, creating a state attribute node18, inserting the state attribute node18 into a child node of the node2, and marking an object 6;
texgen_1 is popped off;
material_0 is popped;
light pop.
It should be noted that before each state attribute node is created or before the state attribute node is inserted into the state attribute tree in the above steps, it is necessary to find whether the state attribute node to be inserted exists under the parent node from the corresponding parent node, if so, the existing state attribute node is directly used, otherwise, the state attribute node is inserted under the corresponding parent node, and in the above steps, the above judging steps are not written for simplifying the description; in addition, the state attribute set may be created at any time before the state attribute node is inserted, and the state attribute set is not specifically limited.
The three-dimensional scene rendering method provided by the embodiment of the invention realizes the rendering of the corresponding three-dimensional scene based on the state attribute tree, and can comprise the following steps:
and acquiring the inheritance type of each tree node in the state attribute tree, determining the attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering the corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
Since Opengl is a software interface to graphics hardware, it works in a state machine that places it into various states (or modes) and then remains active until after changing their state properties, it remains active in the modified state. Therefore, regardless of the fact that a certain state attribute is repeatedly set a plurality of times before drawing an object, it still enables only the state set last time, and the state attribute parameter set last time is used at the time of drawing. Assuming that the color state is exemplified by setting the color to red, then to green, and finally to blue before drawing, the drawing object will appear blue. Specifically, when an object is drawn according to a state attribute tree, the state attribute on each tree node included in a branch corresponding to the object to be drawn in the state attribute tree needs to be drawn; taking fig. 3 as an example, the parent node is LIGHT, the second branch from left is LIGHT, material _0 and texture_1, and when the corresponding object (object 1) is drawn, the state attribute LIGHT of the object is (LIGHT, 0), the material_0 is (Material, 0), and the texture_1 is (text, 0) are sequentially set; if the third node in the branch is LIGHT and the value of the state attribute is (LIGHT, 1), the state attribute of the object is sequentially set to be LIGHT (LIGHT, 0), the material_1 is (Material, 0), and when the object is drawn based on Opengl, the drawing object is caused to present the value of the state attribute set last time, so that the process of switching the state attribute of LIGHT from (LIGHT, 0) to (LIGHT, 1) occurs, the switching overhead is very large, the drawing efficiency of the three-dimensional scene is seriously affected, and the frame clamping and frame dropping phenomena occur for the three-dimensional scene setting of the large scene, so that the display result is not smooth.
It should be noted that, the corresponding inheritance type can be set for each tree node in the state attribute tree according to actual needs, so that only based on the inheritance type, it can be known which attribute value needs to be followed when any state attribute has different attribute values, so that a final drawing object has an effective state attribute for each state attribute, thus not only making the setting of the state attribute more flexible, but also avoiding the huge switching overhead caused by repeatedly setting the state attribute when any state attribute has different attribute values, and also avoiding the problems of reduced rendering efficiency, stuck frames and dropped frames caused by such repeated setting.
Specifically, obtaining the inheritance type of each tree node in the state attribute tree may include:
acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not influenced by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
It should be noted that, setting of the inheritance type may be set according to actual needs, and four inheritance types may be set in this embodiment, which are respectively GENERAL (default type), OVERRIDE (coverage type), protection type, and inheritance type; the inherited type of the state attribute may be considered by default as GENERAL. Specifically, any tree node is called as a target tree node, if the inherited type of the target tree node is GENERAL, the attribute value of the state attribute corresponding to the target tree node is used by default, but at this time, if the inherited type of the father node of the target tree node is OVERDE, the attribute value of the state attribute of the target tree node follows the attribute value of the state attribute of the same type contained in the father node of the target tree node, namely, the meaning of GENERAL is that if the inherited type of other tree nodes does not influence the inherited type of the other tree nodes, the attribute value of the state attribute contained in the inherited type of the tree node of GENERAL is adopted by default, and if the inherited type of the other tree nodes affects the inherited type of the tree node, the attribute value of the state attribute contained in the inherited type of the GENERAL is changed by the influence of the other tree nodes; if the inheritance type of the target tree node is the OVERRIDE, the attribute value of the state attribute of the target tree node covers the attribute values of the state attributes of the same type contained in all the child nodes of the target tree node, namely no matter what the attribute values of the state attributes of the same type contained in the child nodes of the target tree node are, the attribute values of the state attributes of the same type of the target tree node need to be followed; if the inheritance type of the target tree node is PROTECTED, the attribute value of the state attribute of the father node of the target tree node is not affected by the attribute value of the state attribute of the father node of the same type; if the inheritance type of the target tree node is INHERIT, the state attribute of the target tree node enforces attribute values of the state attributes of the same type of the parent node of the target tree node, and the attribute values of the same state attributes contained in the child nodes of the target tree node are all regarded as invalid. Therefore, the determination of the attribute value of the state attribute can be realized through the simple principles, and the method is convenient and quick.
The three-dimensional scene rendering method provided by the embodiment of the invention, after rendering the corresponding three-dimensional scene based on the state attribute tree, can further comprise:
and outputting the rendered three-dimensional scene to a designated terminal for the corresponding staff to acquire.
In order to facilitate the acquisition of the three-dimensional scene by the staff, the embodiment can be provided with the designated terminal corresponding to the staff in advance, and then the rendered three-dimensional scene is directly sent to the designated terminal, so that the staff can remotely acquire the three-dimensional scene.
Taking fig. 4 as an example to illustrate the effective effect of the technical scheme disclosed by the invention, taking the drawing node5 as an example, both the node1 and the node2 are provided with state attributes, if no state attribute inheritance relationship (inheritance type) exists, the state attribute corresponding to the node1 needs to be firstly set on an opengl state machine, then the state attribute corresponding to the node2 is set, and then the drawing of the node5 is carried out, so that the same state attribute is frequently switched, and the time is consumed; in another case, as shown in fig. 4, the state attribute s1 is set in each of the node2, the node3 and the node4, the state attribute of the node2 is invalid, the state attribute of the node3 is valid, and the state attribute of the node4 is invalid, so that when the nodes 5, 6, 7 and 8 are drawn, the state attribute of the s1 is invalid, then the state attribute of the s1 is set to be valid, the nodes 6, 7 and 8 are drawn, then the state attribute of the s1 is set to be invalid, the node8 is drawn, and the nodes are drawn and need to be switched twice, thereby consuming time. And, the principle of realizing node drawing by using the graph structure in the prior art is the same as that of realizing node drawing by using the state attribute tree. Therefore, the method reduces frequent switching of the state attribute by constructing a proper state attribute tree, thereby reducing the switching cost and improving the scene drawing efficiency; meanwhile, repeated submission of the state attribute instructions of the same type to the GPU can be reduced, the time consumption of the GPU is saved, and the resource waste is avoided.
The embodiment of the invention also provides a three-dimensional scene rendering device, as shown in fig. 5, which may include:
an acquisition module 11 for: acquiring a graph structure corresponding to the three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node;
a creation module 12 for: creating a root node of a state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree;
a rendering module 13 for: rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree;
wherein the creation module 11 comprises:
an insertion unit 111 for: determining any state attribute node as a target node; judging whether a state attribute node corresponding to a parent node of a target node corresponding graph node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target node; if the target node exists under the target parent node, determining to complete the insertion, and if the target node does not exist under the target parent node, inserting the target node under the target parent node.
The three-dimensional scene rendering device provided by the embodiment of the invention, the rendering module can comprise:
a rendering unit configured to: and acquiring the inheritance type of each tree node in the state attribute tree, determining the attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering the corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
The three-dimensional scene rendering device provided by the embodiment of the invention, the rendering unit can comprise:
an acquisition subunit configured to: acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not influenced by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
The three-dimensional scene rendering device provided by the embodiment of the invention can further comprise:
an output module for: after the rendering of the corresponding three-dimensional scene is realized based on the state attribute tree, the rendered three-dimensional scene is output to the appointed terminal for the corresponding staff to acquire.
The embodiment of the invention also provides a three-dimensional scene rendering device, which can comprise:
a memory for storing a computer program;
a processor for implementing the steps of any of the three-dimensional scene rendering methods described above when executing a computer program.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the steps of the three-dimensional scene rendering method are realized.
It should be noted that, for the description of the related parts in the three-dimensional scene rendering device, the device and the readable storage medium provided in the embodiments of the present invention, please refer to the detailed description of the corresponding parts in the three-dimensional scene rendering method provided in the embodiments of the present invention, which is not repeated here. In addition, the parts of the above technical solutions provided in the embodiments of the present invention, which are consistent with the implementation principles of the corresponding technical solutions in the prior art, are not described in detail, so that redundant descriptions are avoided.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A three-dimensional scene rendering method, comprising:
acquiring a graph structure corresponding to a three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node;
creating a root node of a state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree; rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree;
the state attribute nodes are sequentially inserted into the state attribute tree, and the method comprises the following steps:
determining any state attribute node as a target node;
judging whether a state attribute node corresponding to a parent node of the graph node corresponding to the target node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target parent node;
if the target node exists under the target father node, determining to complete the insertion, and if the target node does not exist under the target father node, inserting the target node under the target father node.
2. The method of claim 1, wherein rendering the corresponding three-dimensional scene based on the state attribute tree comprises:
and acquiring an inheritance type of each tree node in the state attribute tree, determining an attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering a corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
3. The method of claim 2, wherein obtaining inheritance types for each tree node in the state attribute tree comprises:
acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not affected by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
4. The method of claim 3, further comprising, after rendering the corresponding three-dimensional scene based on the state attribute tree:
and outputting the rendered three-dimensional scene to a designated terminal for the corresponding staff to acquire.
5. A three-dimensional scene rendering device, comprising:
an acquisition module for: acquiring a graph structure corresponding to a three-dimensional scene and provided with state attributes and corresponding attribute values, wherein the state attributes and the corresponding attribute values of the same graph node in the graph structure are contained in a state attribute set of the graph node;
a creation module for: creating a root node of a state attribute tree, traversing the graph structure, acquiring all state attribute sets in the graph structure, creating state attribute nodes corresponding to each state attribute set, and sequentially inserting the state attribute nodes into the state attribute tree;
a rendering module for: rendering of the corresponding three-dimensional scene is achieved based on the state attribute tree;
wherein the creation module comprises:
an insertion unit for: determining any state attribute node as a target node; judging whether a state attribute node corresponding to a parent node of the graph node corresponding to the target node in the graph structure exists in the state attribute tree, if so, determining the state attribute node as the target parent node, and if not, determining a root node of the state attribute tree as the target parent node; if the target node exists under the target father node, determining to complete the insertion, and if the target node does not exist under the target father node, inserting the target node under the target father node.
6. The apparatus of claim 5, wherein the rendering module comprises:
a rendering unit configured to: and acquiring an inheritance type of each tree node in the state attribute tree, determining an attribute value to be followed by the state attribute in each state attribute set based on the inheritance type, and rendering a corresponding three-dimensional scene based on the attribute value to be followed by each state attribute.
7. The apparatus of claim 6, wherein the rendering unit comprises:
an acquisition subunit configured to: acquiring an inheritance type of each tree node in the state attribute tree, wherein the inheritance type comprises a default type, an overlay type, a protection type and an inheritance type; the default type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value to be followed by the state attribute default, the overlay type indicates that the attribute value of the state attribute of the corresponding tree node overlays the attribute value of the state attribute of the same type contained in the child node, the protection type indicates that the attribute value of the state attribute of the corresponding tree node is not affected by the attribute value of the state attribute of the parent node, and the inheritance type indicates that the attribute value of the state attribute of the corresponding tree node is the attribute value of the state attribute of the parent node.
8. The apparatus as recited in claim 7, further comprising:
an output module for: and after the rendering of the corresponding three-dimensional scene is realized based on the state attribute tree, outputting the rendered three-dimensional scene to a designated terminal for the corresponding staff to acquire.
9. A three-dimensional scene rendering device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the three-dimensional scene rendering method according to any of claims 1 to 4 when executing the computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the three-dimensional scene rendering method according to any of claims 1 to 4.
CN201910865723.0A 2019-09-12 2019-09-12 Three-dimensional scene rendering method, device, equipment and readable storage medium Active CN110580734B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910865723.0A CN110580734B (en) 2019-09-12 2019-09-12 Three-dimensional scene rendering method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910865723.0A CN110580734B (en) 2019-09-12 2019-09-12 Three-dimensional scene rendering method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN110580734A CN110580734A (en) 2019-12-17
CN110580734B true CN110580734B (en) 2023-04-25

Family

ID=68811695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910865723.0A Active CN110580734B (en) 2019-09-12 2019-09-12 Three-dimensional scene rendering method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN110580734B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111176772B (en) * 2019-12-24 2022-07-01 安克创新科技股份有限公司 Method and device for state switching and robot
CN111273977B (en) * 2020-01-13 2023-09-12 陕西心像信息科技有限公司 Automatic scene updating method and device for three-dimensional visualization platform
CN114254163B (en) * 2021-12-23 2024-09-06 国泰新点软件股份有限公司 Three-dimensional scene management method, device, equipment and storage medium
CN115439608B (en) * 2022-09-01 2023-06-27 广州南方智能技术有限公司 Model rendering method, device and storage medium based on snapshot and multi-route

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108701366A (en) * 2016-02-25 2018-10-23 高通股份有限公司 The start node of tree traversal for the shadow ray in graphics process determines

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101692230A (en) * 2009-07-28 2010-04-07 武汉大学 Three-dimensional R tree spacial index method considering levels of detail
US9754405B1 (en) * 2015-08-10 2017-09-05 Ngrain (Canada) Corporation System, method and computer-readable medium for organizing and rendering 3D voxel models in a tree structure
KR102651125B1 (en) * 2016-04-06 2024-03-26 삼성전자주식회사 Method and apparatus for performing path rendering
CN106023297B (en) * 2016-05-20 2018-07-20 江苏得得空间信息科技有限公司 A kind of texture dynamic organization method of subtle three-dimensional model
CN106296785B (en) * 2016-08-09 2017-12-15 腾讯科技(深圳)有限公司 A kind of picture rendering intent and picture rendering apparatus
CN107689078A (en) * 2017-08-21 2018-02-13 哈尔滨工程大学 A kind of bounding volume hierarchy (BVH) tree constructing method based on chain list sorting balanced binary tree
CN107564087B (en) * 2017-09-11 2019-08-06 南京大学 A kind of Three-D linear symbol rendering method based on screen

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108701366A (en) * 2016-02-25 2018-10-23 高通股份有限公司 The start node of tree traversal for the shadow ray in graphics process determines

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
张敬斋 ; 张鹏洲 ; 乔向东 ; .改进三维偏序分形树建模方法研究.计算机仿真.2013,(第11期),427-431. *
聂俊岚 ; 张继凯 ; 刘硕 ; 郭栋梁 ; .基于枚举四叉树的多分辨率几何图像绘制方法.计算机辅助设计与图形学学报.2013,(第07期),60-67. *
臧明生 ; 邬正义 ; 谈正 ; .3D场景的树结构管理与实现.常熟理工学院学报.2005,(第06期),66-69. *

Also Published As

Publication number Publication date
CN110580734A (en) 2019-12-17

Similar Documents

Publication Publication Date Title
CN110580734B (en) Three-dimensional scene rendering method, device, equipment and readable storage medium
CN104751507B (en) Graphical content rendering intent and device
CN109949391B (en) Image-text drawing method, image-text drawing device, electronic equipment and storage medium
CN107463692B (en) Super large text data is synchronized to the method and system of search engine
US20150170316A1 (en) Subgraph-based distributed graph processing
CN108509272B (en) Method and device for copying GPU (graphics processing Unit) video memory texture to system memory and electronic equipment
CN112799598B (en) Data processing method, processor and electronic equipment
CN110473292A (en) Model automatization loads layout method in a kind of three-dimensional scenic
CN105407114A (en) Client and method for processing Zookeeper cluster data
CN107770458B (en) A kind of method and terminal device of scene switching
CN111773710B (en) Texture image processing method and device, electronic equipment and storage medium
CN110368693B (en) MMO game element cutting method and device based on multi-quadtree
WO2023173728A1 (en) Graphic rendering method and apparatus, and storage medium
CN111241204B (en) Gradient data synchronization method, device, equipment and storage medium
CN112035656A (en) Method, device, computer equipment and medium for quickly previewing document
CN116938953A (en) Block chain-based data processing method and device, electronic equipment and storage medium
CN114399430A (en) Method and device for realizing dissolving effect based on cocos2dx
CN108280887A (en) A kind of echo determines method and device
CN111524446B (en) Data processing method and device, electronic equipment and readable storage medium
CN104243201B (en) Network equipment detection use-case corresponds to the storage method and system of topological diagram
KR20180138458A (en) Method for processing 3-d data
CN108376101B (en) Method and device for managing resources in Unity3D runtime
CN109509245B (en) Method and device for generating style image
WO2014194758A1 (en) Method and system for simulating real-time processing of virtual scene
CN113535171B (en) Information searching method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant