A high-performance cross-platform 3D rendering engine based on C++ development and physical materials
The high-performance cross-platform 3D rendering engine developed through the C++ language uses OpenGL as the underlying rendering API to solve the problems of cross-platform and high-performance rendering, and realizes efficient 3D rendering and PBR physical material rendering on multiple platforms, satisfying the The rendering demand of large data volume ensures domestic production and independent control.
Patent Information
- Application Number
- CN202311187513.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-14
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2043-09-14
AI Technical Summary
The existing technology is difficult to achieve cross-platform high-performance three-dimensional rendering, especially the loading and rendering needs of large data volumes, and the JavaScript+WebGL solution cannot support the rendering of PBR physical materials.
A high-performance cross-platform three-dimensional rendering engine developed using C++ language, uses OpenGL as the rendering underlying API, combined with the efficient operation ability of C++ and the cross-platform support of OpenGL, to achieve cross-platform, high-performance, physical material rendering.
It realizes efficient three-dimensional rendering on multiple platforms such as Windows, Linux, Android, etc., supports large data volume rendering and the latest graphics rendering technology to achieve high simulation rendering effect, while ensuring domestic production and independent control.
Smart Images

Figure CN117218256B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer network and graphic image processing, and in particular to a high-performance cross-platform three-dimensional rendering engine based on C++ development and physical materials. Background Art
[0002] Usually, there are two ways to implement a cross-platform 3D rendering engine:
[0003] 1. The JavaScript+WebGL technical solution commonly used in the industry: JavaScript is used as the programming language, WebGL is used as the underlying rendering API (Application Programming Interface, which is a set of predefined functions that provide applications and developers with the ability to access a set of routines based on certain software or hardware without accessing the source code or understanding the details of the internal working mechanism), and runs in a web browser environment, such as desktop, mobile and other embedded operating systems. However, this solution has the following technical defects:
[0004] (1) The maximum memory limit for a single page in a browser is 4 GB, which cannot be exceeded;
[0005] (2) JavaScript has low operating efficiency, making it difficult to load and render large amounts of data, and cannot meet the needs of truly high-performance 3D rendering;
[0006] (3) If you want to implement the rendering of PBR physical materials, you must use the latest advanced graphics rendering API (API is usually provided in the form of Http), but WebGL cannot provide and therefore cannot use these latest advanced graphics rendering APIs.
[0007] PBR physical material rendering is based on physical material rendering. Physical material means that the surface is close to the way light behaves in the real world, rather than the way you intuitively think it should be. Compared with shading workflows that rely entirely on the artist's intuition to set parameters, materials rendered in accordance with PBR principles are more accurate and generally look more natural.
[0008] The rendering equation of PBR physical material and the parameter interpretation of the rendering equation parameters are as follows Figure 1 shown.
[0009] The reflection equation corresponding to the rendering of PBR physical material is obtained by removing the self-illumination term from the rendering equation of PBR physical material. The following is the reflectance equation:
[0010]
[0011] In the formula, ω 0 is the solid angle of the current point, ω i is the solid angle of the observation point, L 0 is the optical fiber at the current point, L i is the optical fiber at the observation point, f r BRDF (Bidirectional Reflectance Distribution Function). The limit of the solid angle is "a ray of light", that is, a vector.
[0012] The Cook-Torrance reflectivity equation is shown in equation (2):
[0013]
[0014] The text description of formula (2) is:
[0015]
[0016] like Figure 2 The figure is based on the microfacet surface model. On the left, the normal of the microfacet on the smooth surface changes less, and the direction of the reflected light changes less; on the right, the normal of the microfacet on the rough surface changes more, and the direction of the reflected light changes more.
[0017] The microfacet approximation used in the rendering of PBR physical materials applies the following form of energy conservation: the energy of the outgoing light can never exceed the energy of the incident light (except for the luminous surface). In order to comply with the law of energy conservation, a clear distinction needs to be made between diffuse light and specular light.
[0018] When a beam of light hits the surface of a material, it is usually divided into a reflection part and a refraction part.
[0019] For the reflection part, it is directly regarded as specular reflection. That is to say, if the model is rough enough, the effect is the same as the "diffuse reflection phenomenon" in physics.
[0020] As for the refraction part, the first part of the light is completely absorbed and will not be scattered, while the second part is emitted from the surface after several collisions with the object particles. The diffuse reflection part is entirely composed of the second part. This part of light is also called subsurface-scattered light.
[0021] like Figure 3 The following is a schematic diagram of the subsurface scattering principle. Figure 3 On the left, subsurface scattered light can be emitted from different locations than the point of incidence. If these distance values are smaller than the pixel size that needs to be addressed, then rendering can be done entirely locally ( Figure 3 right); otherwise, you would need to use subsurface scattering rendering techniques.
[0022] Typically, PBR simplifies refracted light, such as Figure 3 As shown on the right, the positions where the second part of the refracted light is emitted are all set to be the same as the position where it is incident, that is, only the situation within one pixel needs to be considered. However, some shader technologies called subsurface scattering technology take into account and handle the problem that subsurface scattered light will be emitted again from the inside of the object from a position different from the incident point, such as Figure 3 As shown on the left, they significantly improve the visual quality of some materials such as skin, marble or wax, but this comes at the cost of performance.
[0023] The rendering engine uses a physically based BRDF.
[0024] BRDF quantitatively describes how a point on the surface of an object interacts with light. In most cases, BRDF can be expressed as f(l,v), where l is the incident direction and v is the viewing direction (bidirectional meaning).
[0025] If the incident direction is rotated around the normal, the relative distribution of reflected and scattered light in all outgoing directions remains unchanged (that is, the value of the BRDF function f remains unchanged), which is called an isotropic BRDF. The corresponding BRDF is anisotropic.
[0026] It can be seen that physical material (PBR) is a rendering process based on physics, a set of shading and rendering techniques that more accurately describes how light interacts with the surface of an object. PBR is "physically based" and is a simulation approximation of reality, so the rendering results are more realistic. To achieve the rendering of physical materials, the rendering engine using the JavaScript programming language can only use WebGL as the underlying rendering API. Since WebGL is a very low OpenGL standard, many advanced APIs are not supported, so it is difficult to achieve standard physical material effects.
[0027] 2. The second implementation method: In Windows environment, use C++ as the programming language and use D3D as the underlying rendering API. This method can meet the requirements of large data loading and rendering, has high operating efficiency, and can fully utilize hardware resources for high-performance rendering. However, since D3D can only run in Windows environment, not in Linux, Android, or web browsers, it cannot achieve true cross-platform high-performance 3D rendering. Summary of the invention
[0028] In order to overcome the deficiencies and shortcomings of the existing technology, a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials is provided. The 3D rendering engine uses the C++ programming language and OpenGL as the rendering system of the underlying rendering API, which has great advantages in cross-platform and physical material implementation. At the same time, due to the high running efficiency of the C++ program, it can meet the needs of high-performance 3D rendering under large amounts of data. The technical solution of using C++ and OpenGL can effectively solve the three problems of cross-platform, high performance, and physical material rendering. The implementation principle of this solution is:
[0029] (1) To achieve high-performance 3D rendering effects across platforms, C++ programming language must be used as the programming language. This is because C++ programming language has compilers on all platforms, including web browsers, and can achieve the feature of "program once, compile on multiple platforms".
[0030] (2) The 3D rendering engine must use OpenGL as the underlying rendering API. OpenGL is the earliest graphics standard and the only global standard in the field of industrial graphics. Other graphics APIs such as WebGL, D3D, Vulkan, Metal, etc. only support specific operating systems and cannot achieve cross-platform features.
[0031] The first aspect of the present invention is to provide a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials, comprising:
[0032] The underlying library and cross-platform SDK interface are developed based on the C++ programming language; the underlying library is provided with a C++ standard library and a C++Boost library; the underlying library and cross-platform SDK interface as the core framework and application modules are all developed using the C++ language;
[0033] Hardware equipment, including operating system and X86 or ARM architecture hardware; and
[0034] A rendering system based on OpenGL that forms the underlying rendering API.
[0035] Preferably, the cross-platform SDK interface includes a native C++ compilation interface, a Wasm compilation interface, a Js hybrid development interface, a native desktop secondary development SDK interface, a native mobile secondary development SDK interface and a Web secondary development SDK interface.
[0036] Preferably, the operating system is arranged at an underlying operating system layer, and at least one operating system selected from Windows, Linux, Android, and iOS is arranged. The underlying operating system layer is also provided with a software interface supporting Windows, Linux, Android, and iOS operating systems, and is applied to desktop computers, tablet computers, and smart phones.
[0037] Preferably, the rendering system based on OpenGL forming a rendering underlying API includes:
[0038] A kernel system, which is used to implement all functions of the cross-platform rendering kernel, including engine initialization, assertion processing, unit testing, memory allocation, decoding and compression library, localization service, data parsing, state collection, engine configuration, character and hash processing, 3D database and object processing, wherein an OpenGL interface is set in the kernel system;
[0039] The main structure of the rendering engine includes a resource management module, a bottom-level rendering module and a visualization effect module; wherein the resource management module is used to manage a variety of resources, including three-dimensional model resources, texture resources, material resources, font resources, skeleton resources, map resources and element resources; the bottom-level rendering module is used to implement bottom-level rendering, including material renderers, various shaders, dynamic and static light sources, cameras and viewpoints, texture and surface renderers, text and font renderers and primitive submitters; the visualization effect module is used to implement the rendering of a variety of visualization effects, including real-time dynamic lighting, keyframe animation rendering, HDR rendering, sky and sunlight rendering at any time, space ambient light occlusion rendering, LBL lighting, a large number of dynamic point light source lighting, TAA, Bloom rendering, height index fog rendering, atmospheric scattering rendering;
[0040] The digital twin scene optimization module is used for real-time scene organization and optimization functions, including full-space index organization of ultra-large scenes, multi-scale detail level organization and scheduling, complex three-dimensional model occlusion culling, and multi-threaded resource access and scheduling.
[0041] Preferably, the high-performance cross-platform three-dimensional rendering engine based on C++ language development and physical materials also includes a basic component layer, a development and debugging tool layer and a client; the basic component layer is provided with an engine, a component library, a control library, an extension module, a communication library and a core library, and the underlying operating system layer is used to call the component library, the control library, the extension module and the core library in the basic component layer for compilation to form an output result, and after communicating with the rendering engine, the rendering result is debugged by the development and debugging tool layer and output to the client; the extension module is provided with at least one of Ext extension, Windows extension DirectX, Linux extension OpenGL, Android extension OpenGLES, and iOS extension Metal; the development and debugging tool layer is provided with at least one of Visual Studio, Android Studio, and XCode; the client is provided with at least one of PC, Linux, iOS, and Android.
[0042] Preferably, the high-performance cross-platform 3D rendering engine based on C++ language development and physical materials also includes a hardware platform detection module, which is used to configure algorithms within the system for OpenGL rendering standards of different platforms. The algorithm configuration standard is to use a simplified algorithm in a low-configuration environment to ensure that the system can run smoothly.
[0043] Preferably, the high-performance cross-platform 3D rendering engine developed based on C++ language and physical materials is based on a multi-threaded running framework to realize the creation, use and management of threads under different platforms, and also includes a thread pool module, wherein the thread pool module includes multiple thread pools for providing multiple task concurrency modes, wherein the task concurrency modes include: the caller passes in a set of parallelizable tasks and grouping strategies, and based on the strategies, several threads of the thread pool are used to concurrently execute tasks; the multiple thread pools are used to realize multiple threads inside the 3D rendering engine, wherein the multiple threads include GUI threads, rendering threads and data loading threads; wherein,
[0044] The GUI thread is the main thread of the 3D rendering engine, and all engine objects are created, updated, and destroyed under the GUI thread. At the same time, the GUI thread has an event loop mechanism inside to manage the operation of the entire rendering system, the initiation of each frame rendering, and the frame rate statistics. The creation and data update of the engine object must be placed after the main thread is updated. The main thread will synchronize the data to the rendering thread, and the synchronization task occurs before each frame rendering to ensure that the rendering results are synchronized in time. The GUI thread is also used for processing work after the data loading task is completed, such as creating rendering vertex data and texture data. The GUI thread is responsible for the initiation of dynamic data request tasks, load balancing of request tasks, and re-request initiation after task failure.
[0045] The rendering thread is responsible for managing the rendering resources related to the rendering device and initiating rendering tasks; the rendering thread cooperates with the main thread, and the objects and data created by the main thread are used as front-end resources; when the front-end resources are synchronized to the rendering thread, the rendering thread will create the corresponding device and back-end resources related to the front-end resources; after receiving the rendering signal from the main thread, the rendering thread performs scene rendering, and the scene rendering includes: camera cutting of the scene, traversal of scene objects, creation of a rendering queue, and creation of a rendering task for each object that needs to be rendered, and adding it to the rendering queue; the rendering resources include: materials, various shaders, three-dimensional models, map resources and feature resources.
[0046] A second aspect of the present invention provides a method for using a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials, comprising:
[0047] Step S1, setting an automated packaging script, compiling the script code, integrating each business function module into a business file through the script, compressing the business file code to obtain a business layer code, and loading the business layer code into the business platform;
[0048] Step S2, compile the script code, integrate the rendering function modules into a rendering library file through the Python script, confuse and compress the rendering library file code to obtain an independent rendering layer file, and load the rendering layer file to the business platform;
[0049] Step S3, formulate an interface protocol for connecting the business layer and the rendering layer, so that the business layer can run with the same business layer code logic on different platforms, and the rendering layer can display the same rendering effect on different platforms, and load the interface protocol to the business platform;
[0050] Step S4, starting the business platform, the business layer calls the initialization screen loading interface, image object acquisition interface and image object addition to screen interface of the protocol layer, and sends the image to be displayed to the rendering layer for image rendering and display.
[0051] A third aspect of the present invention is to provide an electronic device, comprising a processor and a memory, wherein the memory stores a plurality of instructions, and the processor is used to read the instructions and execute the method described in the second aspect.
[0052] A fourth aspect of the present invention is to provide a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, and the plurality of instructions can be read by a processor to execute the method described in the second aspect.
[0053] Beneficial effects of the present invention:
[0054] 1. Compilation on multiple platforms. Use the GCC compiler to compile on desktops such as Windows, Linux, and Xinchuang operating systems. Use the Clang compiler to compile on Android. Use the Webassembly compiler to compile on the Web, which ensures high efficiency, high performance, and consistent rendering effects on all platforms.
[0055] 2. It has achieved localization, 100% domestically produced and independently controllable;
[0056] 3. It realizes cross-platform, different terminals can be adapted as needed, unified development language, one-time programming, and multi-terminal compilation;
[0057] 4. The latest graphics rendering technology can be integrated to achieve high-simulation rendering effects;
[0058] 5. Gather the ecology, the 3D rendering technology is self-controllable and can integrate all open data services.
[0059] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. The objects and features of the present invention will become more apparent in view of the following description in conjunction with the accompanying drawings, in which:
[0061] Figure 1 The following is a rendering equation (Render Equation) of a PBR physical material and parameter definitions of the rendering equation according to an embodiment of the present invention.
[0062] Figure 2Schematic diagram of the principle of a microfacet surface model according to an embodiment of the present invention.
[0063] Figure 3 Schematic diagram of subsurface scattering principle according to an embodiment of the present invention.
[0064] Figure 4 It is a schematic diagram of the structural principle of a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials according to an embodiment of the present invention.
[0065] Figure 5 FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0066] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0067] Embodiment 1
[0068] like Figure 4 As shown, this embodiment provides a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials, including:
[0069] 1. The underlying library and cross-platform SDK interface developed based on the C++ programming language. The SDK interface is Software Development Kit, which means software development kit. It is a collection of development tools for software engineers to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. The underlying library is equipped with C++ standard library and C++Boost library, and all modules are developed in C++ language; the underlying library and cross-platform SDK interface as the core framework and application module are all developed in C++ language. Applications developed in C++ language need to be compiled and executed. The source code is not visible to users, and the compiled binary code is not easy to be tampered with or cracked. The resource file is encrypted and packaged into the execution file, and dynamically read at runtime to ensure the security of the resource file.
[0070] In this embodiment, the cross-platform SDK interface includes a native C++ compilation interface, a Wasm compilation interface, a Js hybrid development interface, a native desktop secondary development SDK interface, a native mobile secondary development SDK interface, and a Web secondary development SDK interface. Of course, those skilled in the art should know that the cross-platform SDK interface is set as an extensible setting, and more development SDKs can be expanded based on the C++ unified development language as needed.
[0071] 2. Hardware equipment, including operating systems (in this embodiment, all operating systems on the market are supported, including Kirin, Tongxin, Loongson, Hongmeng, Windows, Linux and Android) and domestic / non-domestic hardware (in this embodiment, including X86 architecture or ARM architecture);
[0072] In this embodiment, the operating system is set at the underlying operating system layer, and at least one operating system among Windows, Linux, Android, and iOS is set. The underlying operating system layer is also provided with a software interface that supports Windows, Linux, Android, and iOS operating systems, and is applied to desktop computers, tablet computers, and smart phones.
[0073] 3. A rendering system based on OpenGL that forms the underlying rendering API, including:
[0074] (1) a kernel system for implementing all functions of a cross-platform rendering kernel, including but not limited to engine initialization, assertion processing, unit testing, memory allocation, decoding and compression library, localization services, data parsing, state collection, engine configuration, character and hash processing, 3D database, and object processing, wherein an OpenGL interface is provided in the kernel system;
[0075] (2) The main structure of the rendering engine includes a resource management module, a bottom-level rendering module and a visualization effect module; wherein the resource management module is used to manage a variety of resources, including 3D model resources, texture resources, material resources, font resources, skeleton resources, map resources and element resources; the bottom-level rendering module is used to implement bottom-level rendering, including material renderers, various shaders, dynamic and static light sources, cameras and viewpoints, texture and surface renderers, text and font renderers and primitive submitters; the visualization effect module is used to implement the rendering of a variety of visualization effects, including real-time dynamic lighting, keyframe animation rendering, HDR rendering, arbitrary time sky and sunlight rendering, space ambient light occlusion rendering, LBL lighting, a large number of dynamic point light source lighting, TAA, Bloom rendering, height index fog rendering, atmospheric scattering rendering, etc.;
[0076] (3) A digital twin scene optimization module for real-time scene organization and optimization functions, including full-space index organization of ultra-large scenes, multi-scale level of detail organization and scheduling, complex three-dimensional model occlusion culling, and multi-threaded resource access and scheduling.
[0077] As a preferred embodiment, the high-performance cross-platform three-dimensional rendering engine based on C++ language development and physical materials also includes a basic component layer, a development and debugging tool layer and a client; the basic component layer is provided with an engine, a component library, a control library, an extension module, a communication library and a core library, and the underlying operating system layer is used to call the component library, the control library, the extension module and the core library in the basic component layer for compilation to form an output result, and after communicating with the rendering engine, the rendering result is debugged by the development and debugging tool layer and output to the client.
[0078] As a preferred implementation, the extension module is provided with at least one of Ext extension, Windows extension DirectX, Linux extension OpenGL, Android extension OpenGLES, and iOS extension Metal.
[0079] As a preferred implementation, the development and debugging tool layer is provided with at least one of Visual Studio, Android Studio, and XCode.
[0080] As a preferred implementation, the client is configured with at least one of PC, Linux, iOS, and Android.
[0081] As a preferred embodiment, the high-performance cross-platform 3D rendering engine based on C++ language development and physical materials also includes a hardware platform detection module, which is used to configure algorithms within the system for OpenGL rendering standards of different platforms. The algorithm configuration standard is to use a simplified algorithm in a low-configuration environment to ensure that the system can run smoothly.
[0082] As a preferred embodiment, since the high-performance cross-platform 3D rendering engine based on C++ language development and physical materials is based on a multi-threaded operating framework to achieve the creation, use and management of threads under different platforms, it also includes a thread pool module, and the thread pool module includes multiple thread pools for providing multiple task concurrency methods. The task concurrency method includes: the caller passes in a set of parallel tasks and grouping strategies, and based on the strategy, several threads of the thread pool are used to execute tasks concurrently, so that the caller does not need to directly contact the calling and management details of the thread, which reduces the cost of the caller and improves the scheduling efficiency and throughput of the thread. When creating a thread pool, several key design issues will affect the concurrency efficiency, such as: the number of threads that can be used, efficient task allocation methods, and whether it is necessary to wait for a task to complete.
[0083] As a preferred implementation, the multiple thread pools are used to implement multiple threads inside the three-dimensional rendering engine, and the multiple threads include a GUI thread, a rendering thread, and a data loading thread; wherein,
[0084] The GUI thread is the main thread of the 3D rendering engine, and all engine objects are created, updated, and destroyed under the GUI thread. At the same time, the GUI thread has an event loop mechanism inside to manage the operation of the entire rendering system, the initiation of each frame rendering, and the frame rate statistics. The creation and data update of the engine object must be placed after the main thread is updated. The main thread will synchronize the data to the rendering thread, and the synchronization task occurs before each frame rendering to ensure that the rendering results are synchronized in time. The GUI thread is also used for processing work after the data loading task is completed, such as creating rendering vertex data and texture data. The GUI thread is responsible for the initiation of dynamic data request tasks, load balancing of request tasks, and re-request initiation after task failure.
[0085] The rendering thread is responsible for managing the rendering resources related to the rendering device and initiating rendering tasks; the rendering thread cooperates with the main thread, and the objects and data created by the main thread are used as front-end resources; when the front-end resources are synchronized to the rendering thread, the rendering thread will create the corresponding device and back-end resources related to the front-end resources; after receiving the rendering signal from the main thread, the rendering thread performs scene rendering, and the scene rendering includes: camera cutting of the scene, traversal of scene objects, creation of a rendering queue, and creation of a rendering task for each object that needs to be rendered, and adding it to the rendering queue; the rendering resources include: materials, various shaders, three-dimensional models, map resources and feature resources.
[0086] Embodiment 2
[0087] Embodiment 2 of the present invention provides a method for using a high-performance cross-platform 3D rendering engine based on C++ language development and physical materials, including:
[0088] Step S1, setting an automated packaging script, compiling the script code, integrating each business function module into a business file through the script, compressing the business file code to obtain a business layer code, and loading the business layer code into the business platform;
[0089] In addition to the main engine framework, the business platform provided by the embodiment of the present application also provides developers with some python-based automatic packaging and obfuscation scripts. The business layer code consists of various functional modules. For security and code loading and running efficiency, an automatic packaging script running under Windows is written. The script uses babel (compiler) to compile and uniformly format the codes of various business functions, and then uses python (computer programming language) scripts to integrate the codes of multiple modules into one file, and finally uses uglifyjs (JS code optimization tool) to compress the code.
[0090] Step S2, compile the script code, integrate the rendering function modules into a rendering library file through the Python script, confuse and compress the rendering library file code to obtain an independent rendering layer file, and load the rendering layer file to the business platform;
[0091] The web engine is a 2D rendering engine based on HTML5 canvas, using OpenGL rendering technology and JavaScript language. It is a completely independently developed 2D rendering engine. It is an independent rendering engine library that cooperates with the web protocol layer to achieve the normal operation and display of the business layer on the PC web page.
[0092] The engine provides developers with general basic graphics and image rendering functions. The rendering layer is based on OpenGL technology and is natively rendered on multiple platforms (Open GLES on mobile terminals and web GL on PC web terminals), so that the business layer code scripts can run across platforms. The rendering layer provides basic image and graphics rendering, audio and video operations, network operations, and file processing. The rendering layer of each platform can be used as a separate 2D rendering engine for the corresponding platform for developers to use.
[0093] In addition, the rendering layer can also display basic display objects such as pictures and buttons through encapsulated display objects, including support for sequence frame animation and live2d animation models.
[0094] This application completely separates the business layer and rendering layer codes in the engine of the business platform. There is no coupling between each layer structure, which ensures that the business layer code can run across platforms without worrying about the implementation methods of the specific basic functions of each platform.
[0095] Step S3, formulate an interface protocol for connecting the business layer and the rendering layer, so that the business layer can run with the same business layer code logic on different platforms, and the rendering layer can display the same rendering effect on different platforms, and load the interface protocol to the business platform;
[0096] In the embodiment of the present application, the protocol layer has formulated a set of interaction rules to ensure that the business layer and the rendering layer only interact with data without affecting each other. In the set of interface protocols formulated by the protocol layer, each interface provides basic functions, so that the business layer can run with the same code logic on different platforms. In addition, for different operating platforms, it is necessary to connect and implement the specific functions of each interface according to their respective platform characteristics and development modes, which are not limited here.
[0097] Step S4, starting the business platform, the business layer calls the initialization screen loading interface, image object acquisition interface and image object addition to screen interface of the protocol layer, and sends the image to be displayed to the rendering layer for image rendering and display.
[0098] Specifically, after starting the business platform, the business layer needs to use the protocol layer SAL_getCanvas interface to initialize the screen information, then obtain the image object through the SALSprite interface, and then use the SAL_addElement interface to add the image object to the screen, so that an image can be displayed. And this script can run across platforms and display the same effect on different platforms.
[0099] like Figure 5 As shown, the present invention also provides an electronic device, including a processor 301 and a memory 302 connected to the processor 301, wherein the memory 302 stores a plurality of instructions, which can be loaded and executed by the processor so that the processor can execute the method described in Example 2.
[0100] Corresponding to the above embodiment, an embodiment of the present invention provides a computer storage medium, including: at least one memory and at least one processor;
[0101] The memory is used to store one or more program instructions;
[0102] The processor is used to run one or more program instructions to execute a working method of an interactive reading platform rendering engine.
[0103] Corresponding to the above embodiment, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer storage medium contains one or more program instructions, and the one or more program instructions are used by a processor to execute a working method of a business platform rendering engine.
[0104] The embodiments disclosed in the present invention provide a computer-readable storage medium, in which computer program instructions are stored. When the computer program instructions are executed on a computer, the computer executes the working method of the above-mentioned service platform rendering engine.
[0105] In the embodiment of the present invention, the processor may be an integrated circuit chip having the ability to process signals. The processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0106] The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The processor reads the information in the storage medium and completes the steps of the above method in combination with its hardware.
[0107] The storage medium may be a memory, which may be, for example, a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memory.
[0108] Among them, the non-volatile memory can be a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.
[0109] The volatile memory may be a random access memory (RAM) which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced synchronous DRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus DRAM (DRRAM).
[0110] The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memory.
[0111] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention can be implemented using a combination of hardware and software. When software is used, the corresponding functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of computer programs from one place to another. Storage media can be any available media that can be accessed by general or special-purpose computers.
[0112] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A high-performance cross-platform 3D rendering engine based on C++ development and physical materials, characterized by: include: The underlying library and cross-platform SDK interface developed based on the C++ programming language; The underlying library is provided with a C++ standard library and a C++Boost library; the underlying library and the cross-platform SDK interface as the core framework and application module are all developed using the C++ language; Hardware equipment, including operating system and X86 architecture or ARM architecture hardware; and A rendering system based on OpenGL that forms the underlying rendering API; The cross-platform SDK interface includes native C++ compilation interface, Wasm compilation interface, Js hybrid development interface, native desktop secondary development SDK interface, native mobile secondary development SDK interface and Web secondary development SDK interface; The operating system is arranged at the bottom operating system layer, and at least one operating system among Windows, Linux, Android and iOS is arranged. The bottom operating system layer is also provided with a software interface supporting Windows, Linux, Android and iOS operating systems, and is applied to desktop computers, tablet computers and smart phones; the rendering system forming the bottom rendering API based on OpenGL includes: A kernel system, which is used to implement all functions of the cross-platform rendering kernel, including engine initialization, assertion processing, unit testing, memory allocation, decoding and compression library, localization service, data parsing, state collection, engine configuration, character and hash processing, 3D database and object processing, wherein an OpenGL interface is set in the kernel system; The main structure of the rendering engine includes a resource management module, a bottom-level rendering module and a visualization effect module; wherein the resource management module is used to manage a variety of resources, including three-dimensional model resources, texture resources, material resources, font resources, skeleton resources, map resources and element resources; the bottom-level rendering module is used to implement bottom-level rendering, including material renderers, various shaders, dynamic and static light sources, cameras and viewpoints, texture and surface renderers, text and font renderers and primitive submitters; the visualization effect module is used to implement the rendering of a variety of visualization effects, including real-time dynamic lighting, keyframe animation rendering, HDR rendering, sky and sunlight rendering at any time, space ambient light occlusion rendering, LBL lighting, a large number of dynamic point light source lighting, TAA, Bloom rendering, height index fog rendering, atmospheric scattering rendering; Digital twin scene optimization module, which is used for real-time scene organization and optimization functions, including full-space index organization of ultra-large scenes, multi-scale level of detail organization and scheduling, complex three-dimensional model occlusion culling, and multi-threaded resource access and scheduling; The high-performance cross-platform 3D rendering engine based on C++ development and physical materials also includes a basic component layer, a development and debugging tool layer and a client; the basic component layer is provided with an engine, a component library, a control library, an extension module, a communication library and a core library, and the underlying operating system layer is used to call the component library, the control library, the extension module and the core library in the basic component layer for compilation to form an output result, and after communicating with the rendering engine, the rendering result is debugged by the development and debugging tool layer and output to the client; the extension module is provided with at least one of Ext extension, Windows extension DirectX, Linux extension OpenGL, Android extension OpenGLES, and iOS extension Metal; the development and debugging tool layer is provided with at least one of VisualStudio, Android Studio, and XCode; the client is provided with at least one of PC, Linux, iOS, and Android; The high-performance cross-platform 3D rendering engine based on C++ development and physical materials also includes a hardware platform detection module, which is used to configure algorithms for OpenGL rendering standards of different platforms within the system. The standard of the algorithm configuration is to use a simplified algorithm in a low-configuration environment to ensure that the system can run smoothly; the high-performance cross-platform 3D rendering engine based on C++ development and physical materials is based on a multi-threaded running framework to realize the creation, use and management of threads under different platforms, and also includes a thread pool module, which includes multiple thread pools for providing multiple task concurrency modes, and the task concurrency mode includes: the caller passes in a set of parallel tasks and grouping strategies, and uses several threads of the thread pool to execute tasks concurrently based on the strategies; the multiple thread pools are used to realize multiple threads inside the 3D rendering engine, and the multiple threads include GUI threads, rendering threads and data loading threads; wherein, The GUI thread is the main thread of the 3D rendering engine. All engine objects are created, updated and destroyed under the GUI thread. At the same time, there is an event loop mechanism inside the GUI thread to manage the operation of the entire rendering system, the initiation of each frame rendering and the frame rate statistics. The creation and data update of the engine object must be placed after the main thread is updated. The main thread will synchronize the data to the rendering thread. The synchronization task occurs before each frame rendering to ensure that the rendering results are synchronized in time. The GUI thread is also used for processing work after the data loading task is completed. The GUI thread is responsible for the initiation of dynamic data request tasks, load balancing of request tasks, and re-request initiation after task failure. The rendering thread is responsible for managing the rendering resources related to the rendering device and initiating rendering tasks; the rendering thread cooperates with the main thread, and the objects and data created by the main thread are used as front-end resources; when the front-end resources are synchronized to the rendering thread, the rendering thread will create the corresponding device and back-end resources related to the front-end resources; after receiving the rendering signal from the main thread, the rendering thread performs scene rendering, and the scene rendering includes: camera cutting of the scene, traversal of scene objects, creation of a rendering queue, and creation of a rendering task for each object that needs to be rendered, and adding it to the rendering queue; the rendering resources include: materials, various shaders, three-dimensional models, map resources and feature resources.
2. A method for using the high-performance cross-platform 3D rendering engine based on C++ development and physical materials as claimed in claim 1, characterized in that: include: Step S1, setting an automated packaging script, compiling the script code, integrating each business function module into a business file through the script, compressing the business file code to obtain a business layer code, and loading the business layer code into the business platform; Step S2, compile the script code, integrate the rendering function modules into a rendering library file through the Python script, confuse and compress the rendering library file code to obtain an independent rendering layer file, and load the rendering layer file to the business platform; Step S3, formulate an interface protocol for connecting the business layer and the rendering layer, so that the business layer can run with the same business layer code logic on different platforms, and the rendering layer can display the same rendering effect on different platforms, and load the interface protocol to the business platform; Step S4, starting the business platform, the business layer calls the initialization screen loading interface, image object acquisition interface and image object addition to screen interface of the protocol layer, and sends the image to be displayed to the rendering layer for image rendering and display.
3. An electronic device, comprising a processor and a memory, wherein the memory stores a plurality of instructions, and the processor is configured to read the instructions and execute the method according to claim 2.
4. A computer-readable storage medium storing a plurality of instructions, wherein the plurality of instructions can be read by a processor and execute the method according to claim 2.
