CN115239863A - Three-dimensional scene rendering method and engine system - Google Patents

Three-dimensional scene rendering method and engine system Download PDF

Info

Publication number
CN115239863A
CN115239863A CN202210962559.7A CN202210962559A CN115239863A CN 115239863 A CN115239863 A CN 115239863A CN 202210962559 A CN202210962559 A CN 202210962559A CN 115239863 A CN115239863 A CN 115239863A
Authority
CN
China
Prior art keywords
rendering
scene
node
texture
bounding box
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.)
Pending
Application number
CN202210962559.7A
Other languages
Chinese (zh)
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.)
Xi'an Kongtian Simulation Technology Co ltd
Original Assignee
Xi'an Kongtian Simulation 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 Xi'an Kongtian Simulation Technology Co ltd filed Critical Xi'an Kongtian Simulation Technology Co ltd
Priority to CN202210962559.7A priority Critical patent/CN115239863A/en
Publication of CN115239863A publication Critical patent/CN115239863A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a three-dimensional scene rendering method, which belongs to the technical field of three-dimensional graphic rendering and comprises the following steps: acquiring scene elements required by scene rendering, organizing the scene elements by adopting a self-adaptive binary tree algorithm, constructing a self-adaptive binary tree, judging node visibility under nodes and node branches according to the position relation between a bounding ball and a bounding box contained in the nodes of the self-adaptive binary tree and a visual cone, completing a specific rendering process by adopting rendering sequences, forming a rendering mode of a rendering group by a plurality of rendering sequences, and sending visible nodes and node branches into a rendering pipeline to render complex primitives. The method is divided into a core function module and an extended function module according to different functions and tasks, the advantages of the modern graphics processor are fully exerted, and the rendering efficiency and quality are further improved.

Description

Three-dimensional scene rendering method and engine system
Technical Field
The invention relates to the technical field of three-dimensional graphic rendering, in particular to a three-dimensional scene rendering method and an engine system.
Background
With the rapid development of computer software and hardware, computer graphics has gained much attention and rapid development in recent years, and has been widely used in various industries. Three-dimensional graphics technologies include many graphics image processing algorithms, increasing the difficulty of development. Although supported by the underlying graphic development library, in actual project development, the graphic application program is developed by directly calling the interfaces provided by the underlying graphic library, so that certain limitations still exist, the development progress of the three-dimensional graphic application is limited, and the development efficiency is influenced.
Disclosure of Invention
The embodiment of the invention provides a three-dimensional scene rendering method, which comprises the following steps:
acquiring scene elements required by scene rendering;
organizing scene elements by adopting a self-adaptive binary tree algorithm to construct a self-adaptive binary tree;
according to the position relation between the bounding sphere and bounding box contained in the adaptive binary tree node and the view frustum, node visibility judgment under the node and the node branch is carried out;
rendering after packaging the visible nodes and node branches;
in the rendering process, a rendering sequence which represents a specific rendering process and contains rendering elements is formed into a rendering group to complete a rendering task.
Preferably, the acquiring of scene elements required for scene rendering includes:
mesh, texture, shader program, animation, physical parameters.
Preferably, the process of constructing an adaptive binary tree includes:
taking a bounding box which is aligned with a coordinate axis and covers the whole scene as a root node;
executing a recursive subdivision function, and dividing the current bounding box by using an optimal division plane perpendicular to one of the three main coordinate axes as two child nodes of the current node;
and respectively continuing to subdivide the two sub-nodes by adopting the optimal segmentation surfaces until the number of the surfaces in the nodes reaches a preset threshold value or the upper depth limit of the tree.
Preferably, the optimal spatial splitting plane includes:
determining a candidate surface data set for segmentation by adopting a random sampling method;
and (4) scoring each candidate face in the candidate face data set by adopting a scoring function, wherein the face with the highest score is the optimal segmentation face.
Preferably, the determining the visibility of the nodes and nodes under node branches according to the position relationship between the view cone and the bounding sphere and the bounding box included in the adaptive binary tree node includes:
judging the position relation between the enclosing sphere of the node and the view cone;
if the surrounding ball is positioned in the viewing cone, the surrounding ball is directly sent into a rendering pipeline for drawing;
if the bounding sphere is outside the view frustum, stopping the visibility judgment of the node on the branch;
when the bounding sphere is intersected with the view frustum, judging the position relation between the bounding box of the node and the view frustum;
if the bounding box is positioned in the view frustum, directly sending the node and the branch nodes thereof into a rendering pipeline for manufacturing;
if the bounding box is positioned outside the view frustum, stopping the visibility judgment of the node and the branch child nodes thereof;
if the bounding box intersects the view frustum, the child nodes are traversed, and the child nodes are likewise subjected to visibility determination based on the bounding sphere and the bounding box.
Preferably, the determining the position relationship between the bounding sphere of the node and the view frustum includes:
calculating the distance from the center of the sphere to 6 planes of the viewing cone;
if the absolute value of the distance is less than the radius of the bounding sphere, then the bounding sphere intersects the plane of the viewing frustum;
if the distance is greater than 0, the bounding sphere is located on the front side of the viewing cone plane;
if the distance is less than 0, then the sphere is located at the back of the viewing frustum, absolutely outside the viewing frustum.
Preferably, the determining the position relationship between the bounding box of the node and the view frustum includes:
defining a bounding box with three minima and three maxima;
then 8 vertices of the bounding box are compared to the view frustum;
if all points are within the cone, then this bounding box is said to be within the cone;
if at least one vertex of the bounding box is not in the view frustum, the bounding box is intersected with the view frustum;
if all points of the bounding box are on the back of a particular frustum plane, the bounding box is outside the frustum.
The invention also provides a three-dimensional scene rendering engine system, comprising:
the resource management submodule is used for providing scene elements required by scene rendering;
the scene management submodule organizes scene elements by adopting a self-adaptive binary tree algorithm and constructs a self-adaptive binary tree; according to the position relation between the bounding sphere and bounding box contained in the adaptive binary tree node and the view frustum, node visibility judgment under the node and the node branch is carried out;
and the rendering management sub-module adopts a rendering sequence to complete a specific rendering process, forms a rendering mode of a rendering group by the rendering sequences, and sends visible nodes and node branches into a rendering pipeline to render the complex primitives.
Preferably, the system further comprises a basic primitive management sub-module, configured to encapsulate the basic primitive into a more complex primitive, which is called by the three-dimensional graphics image processing program to draw a complex three-dimensional model.
Preferably, the resource management submodule includes:
the Resource access interface sub-module is used for storing information of all resources and controlling the authority of Resource access through a Resource class Resource and a Resource management class resourcemanager, wherein the Resource class Resource is used for abstract packaging of the attribute and the operation method of the Resource, and the Resource management class resourcemanager is used for searching the Resource;
the file system submodule is used for managing files through a Directory, a FileOperator and a DirectoryManager, wherein the Directory is used for managing Directory information of the files, the DirectoryManager is used for completing operations such as creating, searching and deleting of specific specified files, and the FileOperator is used for completing reading of the specified files;
the Material management submodule is used for passing through a Material manager type Material manager and a Material type Material, wherein the Material type Material packages the attribute information of the Material and provides a method for loading and unloading a Material file; the MaterialManager inherits the ResourceManager and rewrites the abstract method of the processing resource provided by the ResourceManager;
the Model management submodule is used for reading and analyzing the Model file and loading and unloading the Model file through the Model class Model and the Model manager class Model manager;
the Texture management submodule is used for packaging the bottom layer graph development library OpenGL through Texture type Texture and Texture management type Texture manager, wherein the Texture type Texture encapsulates Texture operation, the Texture operation comprises methods such as Texture creation, texture binding and Texture storage, and the Texture management type Texture manager realizes Texture creation, destruction and the like through Texture object management;
and the font management submodule is used for managing the characters through the font class and the font management class, wherein the font class packages attributes related to the fonts and is responsible for initializing and drawing the fonts, the font management class is responsible for setting various attributes of the font object, and the characters are drawn by calling a font drawing interface provided by the font object.
The embodiment of the invention provides a three-dimensional scene rendering method and an engine system, and compared with the prior art, the three-dimensional scene rendering method has the following beneficial effects:
1. the three-dimensional rendering engine is divided into a core functional module and an extended functional module according to different functions and tasks. In order to fully exploit the advantages of modern graphics processors, the efficiency and quality of rendering is further improved.
2. And the scene management module adopts an advanced self-adaptive binary tree scene organization algorithm to be responsible for dividing objects in the scene. On the basis of the self-adaptive binary tree scene organization structure, a viewing cone cropping algorithm based on the bounding sphere and the bounding box is adopted, so that the number of nodes participating in visibility calculation is reduced, and the cropping accuracy and the subsequent rendering efficiency are improved. Aiming at the problems of the traditional binary tree (BSP), the self-adaptive binary tree Algorithm (ABT) is adopted to organize and manage scenes, and the method has strong self-adaptability and is suitable for subdividing any type of scenes. Adaptive Binary Trees (ABT) offer the advantage of "polymorphism" compared to traditional octrees, in the sense that it is an abstraction of geometric models and spatial partitioning, and is not limited to fixed shapes. The method is mainly used for visual cone clipping in complex 3D scenes. Octree increases the overhead of visibility calculation due to its strict spatial structure. This can be alleviated by using a loose octree, but there are still many limitations, especially octrees do not guarantee uniqueness of the mesh data (which is very important on modern 3D hardware), and moreover octrees do not adapt smoothly to the segmentation of the geometry as an adaptive binary tree. For general rendering of medium or complex scenes, adaptive Binary Trees (ABT) are more efficient than octrees. An Adaptive Binary Tree (Adaptive Binary Tree) partitions a space based on a scene's geometry. The split bodies can be dynamically changed in size and can also be partially overlapped so as to reduce the number of split surfaces. The division plane is determined by a scoring system considering various different parameters (the number and the positions of the division planes, and the like), and due to the scoring mechanism, when the space division is performed on different scenes, the scoring mechanism can select a proper division plane to perform the scene division according to the actual parameter condition. Therefore, the ABT is suitable for complex indoor and outdoor scenes due to the self-adaptive characteristic.
Drawings
Fig. 1 is a structural diagram of a three-dimensional scene rendering method and an engine system according to an embodiment of the present invention;
fig. 2 is an execution flow of building an adaptive binary tree of a three-dimensional scene rendering method and an engine system according to an embodiment of the present invention;
fig. 3 is an algorithm flow of a three-dimensional scene rendering method and an engine system for searching a partition plane according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a three-dimensional scene rendering method and resource management contents of an engine system according to an embodiment of the present invention;
fig. 5 is a schematic diagram illustrating that the implementation subclass of the FileOperator class completes reading and parsing of the configuration file in the three-dimensional scene rendering method and the engine system according to the embodiment of the present invention;
fig. 6 is a usage diagram of a three-dimensional scene rendering method and an engine system directory manager for searching and reading files according to an embodiment of the present invention;
FIG. 7 is an illustration of a three-dimensional scene rendering method and an example of an engine system material management sub-module according to an embodiment of the present invention;
FIG. 8 is a sequence diagram of a three-dimensional scene rendering method and a material manager loading material file of an engine system according to an embodiment of the present invention;
fig. 9 is an illustration of processing a model by a three-dimensional scene rendering method and an engine system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Referring to fig. 1 to 9, an embodiment of the present invention provides a three-dimensional scene rendering engine system, including:
1 architecture of three-dimensional rendering engine
In order to provide services for applications in different fields, the three-dimensional rendering engine is designed in consideration of the need for a comprehensive consideration. And (4) specific analysis is carried out on specific functional modules, and the relation among the functional modules is designed. Because the three-dimensional graphic application program can run on different platforms, the three-dimensional graphic application program needs to be transplanted according to the characteristics of the engine, so that the three-dimensional graphic application program can provide service for each graphic application program across platforms without being limited by the platforms. The overall architecture of the three-dimensional rendering engine is designed by referring to the existing technical achievements at home and abroad. The engine mainly comprises a core function module and an extended function module. As shown in fig. 1:
the three-dimensional rendering engine is positioned in the middle layer, and provides called service for the application program of the upper layer through the opened functional interface between the application program and the bottom layer graphic library. The core part of the three-dimensional rendering engine mainly comprises a scene management submodule, a rendering management submodule, a resource management submodule and other functional modules. And the expansion module part mainly comprises sub-modules such as a GUI (graphical user interface), a script system and the like.
2. Functional submodules of three-dimensional rendering engine
2.1 scene management submodule
The module is one of important modules in a three-dimensional rendering engine and is responsible for organizing and managing elements in a scene. A good scene management technology has important influences on the division of scenes, the elimination of visibility, the collision detection and the acceleration of scene rendering. The current complex scene has the characteristics of high interchangeability, large quantity of scene models, more dynamic scenes and the like, so that the scene is effectively organized, and the improvement on the rendering efficiency and quality of the scene has important research significance.
The scene management module of the three-dimensional rendering engine not only provides scene management strategies of binary trees, octrees and scene graphs, but also provides a new scene management method based on self-adaptive binary trees and scene graphs. The self-adaptive binary tree space subdivision algorithm quotes the scoring standard of the division plane to form self-adaptive behavior, so that the efficiency of scene division is improved, and the subsequent rendering is facilitated. The method adopts a self-adaptive binary tree space subdivision algorithm and is also integrated with a management mode of the scene graph, different ABT weights are applied according to different scene types, a scene management strategy is formed, and a scene management model is constructed, so that the space organization and the real-time rendering efficiency of the scene are effectively improved.
Specifically, the establishment of the adaptive binary tree:
an Adaptive Binary Tree (ABT) algorithm partitions the space based on the geometry of the scene. The segmentation plane is determined by a scoring system that takes into account a number of different parameters (number and position of segmentation planes, etc.), making the resulting segmentation plane more suitable for model partitioning of a particular type of scene. The execution flow of the specific algorithm for adaptive binary tree establishment is shown in fig. 2:
in the creation process, first, bounding boxes which are aligned with the coordinate axes and cover the whole scene are used as root nodes (in the process of creating nodes, one bounding box and one bounding ball containing the bounding box are stored in each node and are used for subsequent clipping and collision detection). Then, a recursive partitioning function is started, which functions to divide the current bounding box into two sub-nodes of the current node by a partition plane perpendicular to one of the three main coordinate axes. The subdivision of the two child nodes then continues until the number of faces in the node reaches a predetermined threshold or the upper depth limit of the tree.
Algorithm for obtaining optimal space division surface
The most difficult part in the adaptive binary tree creation process is how to select the appropriate splitting plane. The better a good splitting plane can split the current geometry set, the more perfect the split plane can be, the higher the structural balance of the constructed binary tree can be, and the better the subsequent clipping and rendering can be. Aiming at the division of the space geometry in the scene, the selection of the division surface is divided into three steps:
step 1: and determining a candidate surface data set for segmentation by adopting a random sampling method.
Step 2: and (4) scoring each candidate face in the candidate face data set by adopting a scoring function, wherein the face with the highest score is the optimal segmentation face.
And 3, step 3: and partitioning the nodes by adopting the optimal partitioning surface.
The algorithm flow for realizing the search of the segmentation plane is shown in FIG. 3:
and the current geometric body set is effectively segmented through the optimal space segmentation surface, so that subsequent visibility judgment and collision detection are facilitated.
2.2 rendering management submodule
The rendering management module in the three-dimensional rendering engine obviously improves the rendering efficiency by packaging a large amount of repeated rendering operations. The rendering management module provides a concept of a rendering sequence and a rendering group, wherein the rendering sequence represents a specific rendering process, and the rendering sequence comprises rendering elements required in the rendering process, such as a data source, a rendering state, a rendering object, an output result and the like. Multiple rendering sequences form a rendering group to accomplish more complex rendering tasks. The rendering management submodule of the engine greatly improves the rendering efficiency through packaging relevant operations in the rendering process and processing various rendering mechanisms.
2.3 resource management submodule
In any complete software project, the resource management part is indispensable and mainly takes charge of managing information such as resource files, configuration files and the like required in the running process of the system. In the three-dimensional rendering engine, the rendering management submodule is mainly used for managing the management of a graphic file and a resource configuration file used when a scene is rendered.
2.4 message management submodule
Message management is one of more important functional modules in a three-dimensional rendering engine, the three-dimensional rendering engine is divided into a plurality of modules, and in order to achieve a good rendering effect, the modules need to be matched with each other to achieve the rendering of complex scenes. The coordination of the work of messages among the various modules plays an important role. The three-dimensional rendering engine mainly comprises two types of messages, wherein one type of messages is user operation messages generated by an operating system, and the other type of messages is self-defined by the rendering engine. The message of the operating system mainly reflects the event of the operation of the user on the keyboard or the mouse, the message in the message buffer queue of the operating system is acquired in the engine through the message processing module, a corresponding message processing function is constructed, and the received system message is processed. Custom messages are then adapted to coordinate work between modules.
2.5 clock management submodule
Various kinds of currently popular graphic image processing software have the clock management function. The clock management module is essential in the three-dimensional rendering engine. The clock management module in the three-dimensional rendering engine realizes the statistics and control of the frame rate mainly by setting the clock
2.6 basic primitive management submodule
The basic primitive is a basic unit for drawing the graph, and although a complex scene can be outlined by using the basic primitive, a large amount of workload is required, and the development progress is influenced. Although the bottom layer graphics development kit provides drawing of basic primitives, the problems of complicated setting and inconvenient use exist. Therefore, the three-dimensional rendering engine should have a basic primitive management tool of the three-dimensional rendering engine, and encapsulate a part of basic primitives into more complex primitives, thereby reducing the workload of drawing the primitives and improving the reusability of the encapsulated primitives. The three-dimensional graphic image processing program can directly call the basic primitive management submodule to realize the drawing of the complex model.
3. And carrying out class structural design and realization on main sub-modules in the three-dimensional rendering engine framework.
3.1 resource management submodule
3.1.1 content of resource management
The management of rendering resources is handled by a resource management submodule, which needs to manage a variety of resource files. The schematic diagram of the resource management content is shown in fig. 4:
3.1.2 resource management submodule
When scene rendering is performed, some more complicated work needs to be performed besides analyzing, establishing and destroying some model configuration files. Thus, we encapsulate the relevant classes and interfaces for the management of graphics resources, as will be explained in turn below.
(1) File system management policy
Each resource manager will contain a large number of file systems. In a personal computer, a programmer calls a graphic file library provided by an operating system to realize the access to files. However, the three-dimensional rendering engine may need to further package the API of the native file system and convert the API into its own proprietary file system API. The following two aspects are mainly considered in this way: firstly, a three-dimensional rendering engine needs to be cross-platform, and under the requirement, the file system API of the engine can generate an isolation effect on other parts of a system, so that the difference between different target platforms is hidden. Second, the file system API provided by the operating system may not meet the requirements of the three-dimensional rendering engine.
There are at least three benefits to wrapping the native file I/OAPI provided by the operating system. First, the engine programmer can ensure that these custom packaged files I/OAPI have the same behavior on all target platforms. Second, engine programmers can streamline native file I/O, reserving only the functions actually needed by the rendering engine, and thus reducing maintenance costs. Third, the functionality of the file system may be expanded, for example, by wrapping native file I/O to handle files on different media.
In the file system designed by the patent, in the aspects of searching and reading files and file directories, different file operation classes are defined for different file types, and the processing of specific resource files is completed through the specific file operation classes. The file system provides several types of functions: one is to be able to operate the file name and path, but open, close, read, write the file, and the third is to scan the contents under the directory.
(2) Resource management policy
For a complex three-dimensional scene, a lot of resources are contained, such as grids, materials, textures, shader programs, animations, physical parameters, etc. The resources used in these rendered scenes must be properly managed. Functionally, the resource management module needs to have two functions, one is to build the resources as an offline tool and to convert them into a form usable by the rendering engine. Another aspect is to implement loading, unloading, etc. of resources during execution. To the management of particular resources.
3.1.3 implementation of resource management submodule
The resources managed in the three-dimensional rendering engine mainly comprise various resources, in order to manage the resources more clearly and reasonably, the resource management module can be further subdivided, a corresponding module is constructed for each resource, and the management of the respective resources is realized through the corresponding modules.
(1) Resource management master module
The module stores the information of all engine resources, and is used as a resource access interface for controlling the authority of resource access.
Resource class Resource abstractly encapsulates the attributes and operation methods of resources in the engine. A particular resource class must inherit the class and implement the virtual methods provided by the class. The model class, texture class, material class, etc. are all subclasses of the Resource class Resource.
The resource management class, the resource manager, is responsible for searching resources, and maintains a resource routing table inside the class, so that a user can conveniently and quickly find needed resources.
(2) Sub-module of file system
The main classes involved in the sub-modules of the file system are Directory, fileOperator and DirectoryManager. Directory is mainly used for managing Directory information of files, directory manager is mainly used for completing operations such as creating, searching and deleting specific appointed files, fileOperator is used for completing reading of appointed files, and as a three-dimensional rendering engine comprises various files of different types, each file is subjected to different types
The same method is used for analyzing the content of one type of file, so that the FileOperator encapsulates various supported file analyzing methods, and the FileOperator can read and analyze the file.
The Directory is an abstract class, which is used as a base class of a derived class FileFolderDir, and the FileFolderDir realizes a method of the base class. The Directory serves as a unified interface of the file system and provides file Directory and file retrieval functions.
The FileOperator class is used as an abstract class for reading files, provides a virtual method for processing different files, and realizes the specific processing process of different files by the subclass of the file operator class. For configuration files in a three-dimensional rendering engine, the work of analysis is needed, when a file system searches configuration information, firstly, a directory manager DirectoryMananger finds the configuration files, and then, the implementation subclass of a FileOperator class finishes the reading and analysis of the configuration files. As shown in fig. 5:
the use case diagram for the directory manager to find and read the file is shown in fig. 6:
(3) And a material management submodule
The module is responsible for managing material resources. Mainly comprises a Material manager class and a Material class Material. The use case diagram is shown in FIG. 7:
the Material class Material encapsulates the attribute information of the Material and provides a method for loading and unloading the Material file. The MaterialManager inherits the ResourceManager and rewrites the abstract method of processing resources provided by the ResourceManager. And the initialization work of material resources is realized by the Material manager. The sequence diagram of the resource manager MaterialManager loading material file is shown in FIG. 8:
(4) Model management submodule
The model management submodule is mainly responsible for reading and analyzing the model files and loading and unloading the model files. The module mainly comprises a Model class Model and a Model manager class Model manager. The Model class Model is a subclass of the resource class, and has functions of loading and unloading Model files and processing other rendering attributes, such as shadow, animation and the like.
The three-dimensional model file is composed of a plurality of information blocks, and the blocks are used as basic units of the three-dimensional model file. Each information block is composed of a block header and a body content. Wherein the block header contains two information fields of block ID and block length. Wherein the ID field of the block is an integer resource used for identifying the information category of the block; the block length is a long integer that indicates the number of bytes of the next block offset from the block. The next block can be found according to the first address and the length offset of the current block. In the three-dimensional model file, the content is organized like a tree structure, so that the concept of parent blocks and child blocks is realized, wherein the parent blocks contain the child blocks. The block with ID number 0x4D is the tree root, and the 3D editor chunk with ID 0x3D (descriptive object information) and EDITKEYFRAME (key frame information) are the secondary child nodes of the tree root, and the rest of the child nodes are organized in the form of this tree structure.
The use case diagram for processing the model is shown in fig. 9:
(5) Texture management submodule
In OpenGL, a texture is a container object that contains one or more images. Texture has three attributes; texture type, texture size, and image format. The texture type defines how the images within the texture are arranged. The size of the texture defines the size of each image in the texture, each image being a one-, two-or three-dimensional array of pixels, and the image format defines the format of each pixel. The rendering engine designs and realizes the texture management submodule through packaging a bottom layer graphics development library OpenGL, and the main core classes of the texture management submodule comprise: texture class, texture management class.
The Texture class Texture encapsulates a series of operations of the Texture, including methods of creating the Texture, binding the Texture, storing the Texture and the like.
The texture management class TextureManager manages texture objects to create and destroy textures.
(6) And font management submodule
The module is responsible for managing characters, and because the bottom layer graphic development library OpenGL does not directly provide a character display function, and OpenGL does not have a special character library. Therefore, the drawing of the characters needs to depend on the functions provided by the operating system, and the currently popular operating systems such as the Windows system and the Linux system provide related functions to support OpenGL to display the characters in the programs. The most common method for displaying characters is to give the characters to be displayed, initialize a display list, and install the OpenGL command for drawing the characters into the display list by the operating system. The font management submodule mainly comprises a font class and a font management class.
The font class encapsulates attributes associated with the font and is responsible for initializing and rendering the font.
The font management class is responsible for setting various attributes (including font size, position and color) of the font object, and realizes the drawing of characters by calling a font drawing interface provided by the font object.
(5) Design of scene management submodule
The purpose of scene management is to optimize scene organization, facilitate subsequent visibility judgment and collision detection, and improve rendering efficiency. In the implementation process of visibility judgment and collision detection, node objects in a scene need to be judged, and a good scene organization structure has extremely important influence on the subsequent rendering step. In view of the fact that the current scene system is generally huge, if a linked list structure is adopted to organize scene elements, when visibility judgment is performed, each node needs to be traversed in sequence, a large amount of time is consumed, and the overall rendering efficiency is affected. Based on the advantages of the tree structure, the invention adopts the self-adaptive binary tree which can process various scenes to organize the scenes.
The generation of the scene tree is a recursive process. Firstly, a proper space segmentation plane is selected to divide a scene model into two parts, then the divided sub-nodes are continuously segmented in the same way, and the scene tree is successfully constructed until the number of the surfaces in the nodes reaches a preset threshold value or the depth upper limit of the tree. To facilitate visibility determination, the view is located within the root node. The entities in the scene contain the necessary elements such as cameras and lights required for rendering, and also contain the three-dimensional models which are made by the users according to specific requirements. The method comprises the steps of realizing scene division through a corresponding space division algorithm, constructing a scene tree, and mounting an entity in the scene into the scene tree as a part of nodes in the scene tree.
(2) Architecture for scene management submodule
The architecture shows the work for which the scene management module is responsible and how it interacts with other modules. Within the dashed box is a scene management module and outside the dashed box are other modules in the engine.
In the structure, a scene manager is responsible for constructing a scene tree and managing scene nodes, the part needing rendering is sent to a rendering management submodule, and the rendering management submodule is responsible for drawing model data provided by the scene manager.
(6) Implementation of scene management submodule
In the sub-module, three functional classes are mainly included, which are a scene tree node class, a movable object class and a scene manager class. For the scene tree node classes, as the partitioning of the scene has a plurality of algorithms, such as scene organization algorithms like binary tree, quadtree, octree, adaptive binary tree, etc., different scene partitioning algorithms have different data structures, each algorithm corresponds to a respective scene node encapsulation class when the scene node classes are encapsulated, and the three-dimensional rendering engine of the invention not only provides the node encapsulation classes of the traditional scene partitioning algorithm, but also designs the scene node encapsulation classes aiming at the adaptive binary tree algorithm. The scene node class (SceneNode) mainly manages entities in a scene, and controls various attributes of the entities, such as positions, sizes of rotation and scaling, whether the entities are leaf nodes, and the like. The movable object in the scene is defined and packaged by using a movable object class (MovableObj). The scene manager class (SceneManager) is a core class in scene management, and is used to control all objects in a scene, including functions of building objects, removing objects, setting attributes of objects, and the like. In the three-dimensional rendering engine, a scene manager class is responsible for managing a scene node class, a model entity class and a movable object class.
6.1 implementation of adaptive binary tree-based viewing cone cropping algorithm
The scale of the three-dimensional scene is larger and larger, the drawing objects can be effectively reduced, the model complexity is reduced, and the method is the key point for realizing the rapid drawing of the complex scene in the three-dimensional rendering engine. Visibility judgment is a very effective method, and visibility clipping algorithms are often divided into three categories: view cone cutting, back cutting and shielding cutting. The method mainly researches visual field elimination by adopting a hierarchical clipping mode based on a bounding sphere and a bounding box on the basis of scene organization of a self-adaptive binary tree. In a given scene, the scene elements are organized by adopting a self-adaptive binary tree algorithm, patches are distributed more uniformly in leaf nodes, the depth of the tree is optimal, and an efficient and balanced binary tree is formed.
6.2 Cone Algorithm description based on bounding sphere and bounding Box
The principle of the algorithm is that firstly, objects in a scene are organized by using an ABT algorithm, an adaptive binary tree is built, each node in the adaptive binary tree comprises a bounding sphere and a bounding box (axis-aligned bounding box), then, in the aspect of viewing cone clipping, clipping processing is carried out on the nodes in the tree in a recursive mode, firstly, whether the bounding sphere of the node is in the viewing cone is judged, if the bounding sphere is positioned in the viewing cone, all child nodes under the node branch are visible, and therefore the child nodes can be directly sent to a rendering pipeline for drawing. If the bounding sphere is located outside the view cone, the node and the subnodes under the branch are not visible, and the visibility judgment of the node on the branch can be directly stopped, so that the cycle overhead of the CPU is saved. When the bounding volume intersects with the view cone, the position relation between the view cone and the axis in the bounding volume is judged, if the bounding volume is positioned in the view cone, the node and the branch node are directly sent to a rendering pipeline for processing. If the bounding box is outside the view frustum, the visibility determination for that node and its branch sub-nodes is stopped. If the bounding box intersects the view frustum, its children nodes continue to be traversed, and visibility determinations based on the bounding sphere and the bounding box are performed on its children nodes as well.
6.3, determining the position relation of the bounding sphere, the bounding box and the view cone
Determining whether the bounding sphere is located inside, outside, or intersecting the cone is in fact a very simple process, all that needs to be done is to calculate the distance from the center of the sphere to the 6 planes of the cone. If the absolute value of the distance is less than the radius of the sphere, the sphere intersects the plane. In case the intersection is not established, the sphere is located in front of the plane (possibly also within the viewing cone) if the distance is larger than 0. If less than 0, then the sphere is located at the back of the viewing cone, absolutely outside the viewing cone.
The positional state of the view frustum and bounding box is determined, and this is done by first defining the bounding box with three minimum and three maximum values, and then comparing the 8 vertices of the bounding box with the view frustum. If all points are within the cone, then the bounding box is said to be within the cone, and if at least one (but not all) of the vertices of the bounding box are not within the cone, then the bounding box is said to intersect the cone. If all points of the bounding box are on the back of a particular viewing frustum plane. This bounding box is located outside the view frustum and is not visible. Consider the case where the viewing frustum is completely contained within the bounding box. In this case, none of the points are within the viewing cone, but the bounding box is still considered visible.
Although the present invention has been described in detail with reference to the specific embodiments, it should be understood that various changes and modifications can be made by those skilled in the art without departing from the spirit and scope of the invention.

Claims (10)

1. A method of rendering a three-dimensional scene, comprising:
acquiring scene elements required by scene rendering;
organizing scene elements by adopting a self-adaptive binary tree algorithm to construct a self-adaptive binary tree;
according to the position relation between the bounding sphere and bounding box contained in the adaptive binary tree node and the view frustum, node visibility judgment under the node and the node branch is carried out;
rendering after packaging the visible nodes and node branches;
in the rendering process, a rendering sequence which represents a specific rendering process and contains rendering elements is formed into a rendering group to complete a rendering task.
2. The method as claimed in claim 1, wherein the obtaining the scene elements required for scene rendering comprises:
mesh, material, texture, animation.
3. A method for rendering a three-dimensional scene as claimed in claim 1, wherein said process of constructing an adaptive binary tree comprises:
taking a bounding box which is aligned with a coordinate axis and covers the whole scene as a root node;
executing a recursion subdivision function, and separating the current bounding box by using an optimal division plane perpendicular to one of the three main coordinate axes as two child nodes of the current node;
and respectively continuing to subdivide the two sub-nodes by adopting the optimal division surfaces until the number of the surfaces in the nodes reaches a preset threshold value or the upper depth limit of the tree.
4. A method for rendering a three-dimensional scene as claimed in claim 3, wherein said optimal spatial partition plane comprises:
determining a candidate surface data set for segmentation by adopting a random sampling method;
and (4) scoring each candidate face in the candidate face data set by adopting a scoring function, wherein the face with the highest score is the optimal segmentation face.
5. The method for rendering a three-dimensional scene according to claim 1, wherein the determining of node visibility under nodes and node branches according to the position relationship between the bounding sphere and bounding box contained in the adaptive binary tree node and the viewing pyramid comprises:
judging the position relation between the enclosing sphere of the node and the view frustum;
if the surrounding ball is positioned in the viewing cone, the surrounding ball is directly sent into a rendering pipeline for drawing;
if the bounding sphere is outside the view frustum, stopping the visibility judgment of the nodes on the branch;
when the bounding sphere is intersected with the view frustum, judging the position relation between the bounding box of the node and the view frustum;
if the bounding box is positioned in the view frustum, directly sending the node and the branch nodes thereof into a rendering pipeline for manufacturing;
if the bounding box is positioned outside the view frustum, stopping the visibility judgment of the node and the branch child nodes thereof;
if the bounding box intersects the view frustum, the child nodes are traversed, and the child nodes are subjected to visibility judgment based on the bounding sphere and the bounding box.
6. The method of claim 5, wherein the determining the position relationship between the bounding sphere of the node and the view frustum comprises:
calculating the distance from the center of the sphere to 6 planes of the viewing cone;
if the absolute value of the distance is less than the radius of the bounding sphere, then the bounding sphere intersects the plane of the viewing frustum;
if the distance is greater than 0, the bounding sphere is located on the front side of the viewing cone plane;
if the distance is less than 0, then the sphere is located at the back of the viewing frustum, absolutely outside the viewing frustum.
7. The method as claimed in claim 5, wherein the determining the position relationship between the bounding box of the node and the view frustum comprises:
defining a bounding box with three minima and three maxima;
then 8 vertices of the bounding box are compared to the view frustum;
if all points are within the cone, then this bounding box is said to be within the cone;
if at least one vertex of the bounding box is not in the view frustum, the bounding box is intersected with the view frustum;
if all points of the bounding box are on the back of a particular frustum plane, the bounding box is outside the frustum.
8. A three-dimensional scene rendering engine system, comprising:
the resource management submodule is used for providing scene elements required by scene rendering;
the scene management submodule organizes scene elements by adopting a self-adaptive binary tree algorithm and constructs a self-adaptive binary tree; according to the position relation between the bounding sphere and bounding box contained in the adaptive binary tree node and the view frustum, node visibility judgment under the node and the node branch is carried out;
the rendering management submodule is used for rendering after packaging the visible nodes and node branches; in the rendering process, a rendering sequence which represents a specific rendering process and contains rendering elements is formed into a rendering group to complete a rendering task.
9. The system of claim 8, further comprising a base primitive management sub-module configured to encapsulate base primitives into more complex primitives for invocation by a three-dimensional graphics image processing routine to render complex three-dimensional models.
10. The system of claim 8, wherein the resource management submodule comprises:
the Resource access interface sub-module is used for storing information of all resources and controlling the authority of Resource access through a Resource class Resource and a Resource management class Resource manager, wherein the Resource class Resource is used for abstract packaging of the attribute and the operation method of the Resource, and the Resource management class Resource manager is used for searching the Resource;
the file system submodule is used for managing files through a Directory, a FileOperator and a DirectoryManager, wherein the Directory is used for managing Directory information of the files, the DirectoryManager is used for completing operations such as creating, searching and deleting specific appointed files, and the FileOperator is used for completing reading of the appointed files;
the Material management submodule is used for passing through a Material manager type Material manager and a Material type Material, wherein the Material type Material packages the attribute information of the Material and provides a method for loading and unloading a Material file; the MaterialManager inherits the ResourceManager and rewrites the abstract method of the processing resource provided by the ResourceManager;
the Model management submodule is used for reading and analyzing the Model file and loading and unloading the Model file through the Model class Model and the Model manager class Model manager;
the Texture management submodule is used for packaging an OpenGL (open graphics library) of a bottom layer graphic development library through Texture type Texture and Texture management type Texture manager, wherein the Texture type Texture encapsulates Texture operation, the Texture operation comprises methods such as Texture creation, texture binding and Texture storage, and the Texture management type Texture manager manages Texture objects to realize Texture creation, texture destruction and the like;
and the font management submodule is used for managing the characters through the font class and the font management class, wherein the font class packages attributes related to the fonts and is responsible for initializing and drawing the fonts, the font management class is responsible for setting various attributes of the font object, and the characters are drawn by calling a font drawing interface provided by the font object.
CN202210962559.7A 2022-08-11 2022-08-11 Three-dimensional scene rendering method and engine system Pending CN115239863A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210962559.7A CN115239863A (en) 2022-08-11 2022-08-11 Three-dimensional scene rendering method and engine system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210962559.7A CN115239863A (en) 2022-08-11 2022-08-11 Three-dimensional scene rendering method and engine system

Publications (1)

Publication Number Publication Date
CN115239863A true CN115239863A (en) 2022-10-25

Family

ID=83678801

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210962559.7A Pending CN115239863A (en) 2022-08-11 2022-08-11 Three-dimensional scene rendering method and engine system

Country Status (1)

Country Link
CN (1) CN115239863A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116664789A (en) * 2023-07-24 2023-08-29 齐鲁空天信息研究院 Global ionosphere grid data rapid visualization method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116664789A (en) * 2023-07-24 2023-08-29 齐鲁空天信息研究院 Global ionosphere grid data rapid visualization method and system
CN116664789B (en) * 2023-07-24 2023-10-24 齐鲁空天信息研究院 Global ionosphere grid data rapid visualization method and system

Similar Documents

Publication Publication Date Title
US20220245111A1 (en) Hierarchy Merging in Computer Graphics
US20210174572A1 (en) Hybrid hierarchy of bounding and grid structures for ray tracing
CA2501516C (en) Visual and scene graph interfaces
US7126606B2 (en) Visual and scene graph interfaces
EP0713594B1 (en) Object-oriented rendering system
Naylor Interactive solid geometry via partitioning trees
Brodlie et al. Recent advances in volume visualization
CN112347546A (en) BIM rendering method, device and computer-readable storage medium based on lightweight device
Christen Ray tracing on GPU
WO2022121525A1 (en) Method and device for rendering three-dimensional scene data, storage medium, and electronic device
Ernst et al. Early split clipping for bounding volume hierarchies
HRP20030389A2 (en) Markup language and object model for vector graphics
CN115239863A (en) Three-dimensional scene rendering method and engine system
Guérin et al. Efficient modeling of entangled details for natural scenes
WO1998043208A2 (en) Method and apparatus for graphics processing
CN118648028A (en) Generation of tight world space bounding regions
Garanzha The use of precomputed triangle clusters for accelerated ray tracing in dynamic scenes
Jiang et al. View frustum culling algorithm for scene based on adaptive binary tree
CN114708140B (en) Real-time interactive sectioning visualization method for numerical calculation model based on unit
CN115268366A (en) Five-axis milling machine simulation method based on GPU parallel operation
Karaffová Efficient ray tracing of CSG models
AU2004279179B2 (en) Visual and scene graph interfaces
Cottingham A Method of Rendering CSG-Type Solids Using a Hybrid of Conventional Rendering Methods and Ray Tracing Techniques
Hasselbalch Progressive Meshes
Rademakers First impressions of the new Appolo DN580

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