Dynamic model processing method, device and electronic equipment in game
By using model bounding boxes in the game engine for frustum culling and detail level switching, the problem of low efficiency in dynamic model processing was solved, thus improving the game's running efficiency.
Patent Information
- Application Number
- CN202310313885.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-22
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2043-03-22
AI Technical Summary
In existing technologies, the dynamic model processing efficiency in game engines is low, resulting in low game performance. This is mainly due to the increased computational load caused by frustum culling and detail switching for each object, the heavy matrix calculation pressure, and the increased computational burden caused by frequent changes in attachment relationships.
By determining whether the logic layer data has been fully loaded, frustum culling and detail level switching are performed based on the model bounding box. This avoids separate calculations for each sub-model and uses the overall bounding box for culling and switching, reducing computational load and the number of graphics rendering operations.
It improves the processing efficiency of dynamic models in the game screen, reduces the amount of culling operations and the number of times graphics are drawn, and improves the game's running efficiency.
Smart Images

Figure CN116510294B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of game design, and in particular to a dynamic model processing method and device in a game and an electronic device. BACKGROUND
[0002] In related technologies, each object in a game engine is represented by a separate object, for example, a character model is divided into a head, a body, clothes, decorations and other objects. In order to reduce the rendering pressure of the model, view frustum culling and detail switching need to be performed on each object respectively. However, performing view frustum culling and detail switching on each object respectively increases the amount of calculation and reduces the model processing efficiency. At the same time, the deformation matrix of the dynamic model in the game will change a lot in each frame of game picture, and various hanging relationships often appear in the game, for example, the accessories, backpacks and the like of a character, and the matrix corresponding to the hanging articles will also change with each change of the character. Since the matrix of each object changes each time needs to be calculated with the corresponding bounding box, the pressure of matrix calculation is increased, resulting in low efficiency of game running. SUMMARY
[0003] The present application aims to provide a dynamic model processing method and device in a game and an electronic device to improve the dynamic model processing efficiency and thus improve the game running efficiency.
[0004] In a first aspect, the present application provides a dynamic model processing method in a game, the method comprising: judging whether the logical layer data required by a current game picture is loaded; wherein the logical layer data comprises resource data of a dynamic model in the current game picture and change data of the dynamic model; wherein the dynamic model is composed of a plurality of sub-models; if the loading is completed, determining rendering related data based on the logical layer data; wherein the rendering related data comprises change data and model bounding box of the dynamic model and resource data related to rendering; the model bounding box is a bounding box corresponding to the whole dynamic model; performing view frustum culling and detail level switching processing on the dynamic model based on the model bounding box to obtain a processing result; extracting rendering data to be rendered from the rendering related data according to the processing result, and sending the rendering data to be rendered to a game engine, so that the game engine renders the current game picture based on the rendering data to be rendered.
[0005] In a second aspect, the present application provides a dynamic model processing device in a game, comprising: a judging module configured to judge whether logical layer data required by a current game screen is loaded; wherein the logical layer data comprises resource data of a dynamic model in the current game screen and change data of the dynamic model; wherein the dynamic model is composed of a plurality of sub-models; a data determining module configured to, if the logical layer data is loaded, determine rendering related data based on the logical layer data; wherein the rendering related data comprises the change data of the dynamic model and a model bounding box, and resource data related to rendering; the model bounding box is a bounding box corresponding to the dynamic model as a whole; a model processing module configured to perform view frustum culling and level of detail switching processing on the dynamic model based on the model bounding box to obtain a processing result; and a data extracting module configured to extract to-be-rendered data from the rendering related data according to the processing result, and send the to-be-rendered data to a game engine, so that the game engine renders the current game screen based on the to-be-rendered data.
[0006] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the dynamic model processing method in a game.
[0007] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer executable instructions, and when the computer executable instructions are called and executed by a processor, the computer executable instructions cause the processor to implement the dynamic model processing method in a game.
[0008] The embodiments of the present application bring the following beneficial effects:
[0009] The application provides a game dynamic model processing method, device and electronic equipment. First, it is judged whether the logical layer data required by a current game picture is loaded; the logical layer data comprises resource data of a dynamic model in the current game picture and change data of the dynamic model; wherein the dynamic model is composed of multiple sub-models; if the loading is completed, rendering related data is determined based on the logical layer data; the rendering related data comprises the change data of the dynamic model, a model bounding box and resource data related to rendering; the model bounding box is a bounding box corresponding to the whole dynamic model; then, the dynamic model is subjected to frustum culling and level of detail switching processing based on the model bounding box, and the to-be-rendered data is extracted from the rendering related data according to the processing result, and the to-be-rendered data is sent to a game engine, so that the game engine renders the current game picture based on the to-be-rendered data. In this way, the model bounding box is calculated in the rendering preparation stage, so that the range box is not calculated based on the change data for each sub-model; and the frustum culling and level of detail switching are performed on the bounding box of the whole model, so that the operation amount of culling and the number of times of graphic drawing are reduced, and the processing efficiency of the dynamic model in the game picture is improved.
[0010] Other features and advantages of the present application will be illustrated in the following description, or can be learned or determined from the description, or can be known by implementing the above-mentioned technologies of the present application.
[0011] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the following preferred embodiments are specifically described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without any creative labor.
[0013] Figure 1 A flowchart of a game dynamic model processing method provided by an embodiment of the present application is shown in the figure.
[0014] Figure 2 A flowchart of another game dynamic model processing method provided by an embodiment of the present application is shown in the figure.
[0015] Figure 3 A structure relationship diagram of LogicEntity and ResourceData provided by an embodiment of the present application is shown in the figure.
[0016] Figure 4A RenderEntity, a RenderData and a RenderPart structure diagram provided for an embodiment of the present application;
[0017] Figure 5 A flow chart of another game dynamic model processing method provided for an embodiment of the present application;
[0018] Figure 6 A structure diagram of a game dynamic model processing device provided for an embodiment of the present application;
[0019] Figure 7 A structure diagram of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION
[0020] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the following will be combined with the accompanying drawings for the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations.
[0021] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative labor are within the scope of protection of the present application.
[0022] With the continuous improvement of hardware level and the continuous update of technology, people's requirements for the quality of games are also getting higher and higher. In current games, there is often a demand for rendering thousands of people on the same screen, and a large number of dynamic objects are moving and interacting. Therefore, how to efficiently process these dynamic objects is very important for improving the running efficiency of the game.
[0023] In the related art, each object in the game engine is represented by a separate object, for example, a character model is divided into hair, eyeball, head, body, clothes, trousers, shoes, decoration and other objects. Before being submitted to the graphics API, some optimization methods are usually used to reduce the rendering pressure of the model, for example, Frustum Culling and Levels of Detail (LOD) switching are performed for each object respectively. However, the scheme in the related art has the following problems:
[0024] 1. For each object, because of the universality of the game engine, a large number of useless fields are brought, and each object is not processed for the storage manner of memory when created, is dispersed everywhere in the memory, and is accessed in the form of a pointer, which causes a large number of CPU (Central Processing Unit) cache miss in the operation process, and is low in efficiency.
[0025] 2. In view of the fact that many objects have logical relevance (for example, the parts of a character model are almost together), and in the case of a large number of dynamic models in the same screen, there are few cases of needing to remove a part alone, the object needs to calculate whether the bounding box is in the view volume in view of the fact that each object, and this way brings a lot of redundant operations.
[0026] 3. When the object performs LOD switching, only the object is replaced by a lower-precision object model, the highest-precision LOD can have 10 models, and the low-precision LOD can be represented by only 1 to 2 models, which limits the production of artists, increases the number of times of drawing graphics, and reduces the production efficiency.
[0027] 4. The transform of the dynamic model in the game changes a lot every frame, including the movement, scaling, animation, and skeleton of different gameplays, which can cause the change of the matrix, and various hanging relationships often appear in the game, such as the accessories, backpacks, and the like of the character. The matrix corresponding to the hanging object also changes with each change of the character, and since the matrix of each object needs to be calculated with the corresponding bounding box every time, the pressure of matrix calculation is increased, which leads to low efficiency of game running.
[0028] Based on the above problems, the embodiment of the application provides a dynamic model processing method, device and electronic equipment in a game, which can be applied to the processing scene of dynamic objects in the game, especially the management of object resources, the management of material parameters, the processing of view volume culling of each frame of game picture in running time, and the LOD switching of objects.
[0029] In order to facilitate the understanding of the embodiment of the application, first, a dynamic model processing method in a game disclosed by the embodiment of the application is introduced in detail, as shown in the following Figure 1 The method comprises the following specific steps:
[0030] Step S102, judging whether the logical layer data required by the current game picture is loaded; wherein the logical layer data comprises resource data of a dynamic model in the current game picture, and change data of the dynamic model; wherein the dynamic model is composed of a plurality of sub-models.
[0031] In a specific implementation, each frame of game picture in the game can have a dynamic model that changes, which is a model that can move or be controlled by the player in the game. The dynamic model is usually composed of multiple sub-models, that is, each sub-model is part of the dynamic model. Specifically, the sub-model can be a component or a pendant of the dynamic model, etc. For example, if the dynamic model is a character model, the sub-models can be hair, eyeballs, head, body, clothes, pants, shoes, decorations, etc.
[0032] In the refreshing process of each frame of game picture, it is first needed to determine whether the logical layer data required by the current game picture is loaded. If the logical layer data is loaded, data preparation in the rendering stage is performed on the loaded logical layer data. If the logical layer data is not loaded, data preparation in the rendering stage is performed on the original logical layer data. Specifically, this method is usually used in the case where the dynamic model of the current game picture is modified. For example, the dynamic model in the current game picture is modified by the player to a first model, but the logical layer data corresponding to the first model is not loaded when the current game picture is refreshed. At this time, data preparation in the rendering stage is performed on the logical layer data of the original dynamic model, and the original dynamic model continues to be displayed in the current game picture. If the logical layer data corresponding to the first model is loaded, data preparation in the rendering stage is performed on the logical layer data of the first model, and the first model is displayed in the current game picture. Such a design can avoid the problem of lag or flicker caused by replacing new resources.
[0033] In step S104, if the loading is completed, rendering-related data is determined based on the logical layer data. The rendering-related data includes change data of the dynamic model and a model bounding box, and resource data related to rendering. The model bounding box is a bounding box corresponding to the whole dynamic model.
[0034] In a specific implementation, the rendering-related data is extracted from the logical layer data and constructed. In view of the feature that the dynamic model can have data changed in each frame of game picture, the present application divides the data into logical layer data and rendering-related data. The logical layer data is mainly used for storing resources and interacting with scripts, and the rendering-related data is the minimum data unit required for constructing view frustum culling, LOD switching (equivalent to detail level switching), and rendering, and these data are stored in a compact and flat manner. Specifically, the model bounding box in the rendering-related data is data related to view frustum culling and LOD switching. The model bounding box is a bounding box corresponding to the whole dynamic model, rather than a separate bounding box corresponding to each sub-model.
[0035] In step S106, view frustum culling and detail level switching processing are performed on the dynamic model based on the model bounding box, to obtain a processing result.
[0036] In the preparation stage of rendering, the frustum culling and LOD switching are performed according to a model entity instead of each single sub-model, for example, for all parts of a character model, whether the whole character is outside the camera to be culled and the LOD switching of the whole character is calculated, so that a large number of culling operations can be reduced. Moreover, when the LOD switching is performed, the same number of models in each LOD is no longer required, so that only a few models can be displayed in the low-precision LOD, thereby reducing the number of graphic drawing and improving the drawing efficiency.
[0037] In step S108, the to-be-rendered data is extracted from the rendering-related data according to the processing result, and the to-be-rendered data is sent to the game engine, so that the game engine renders the current game picture based on the to-be-rendered data.
[0038] Through the processing result of the frustum culling and the LOD switching, the corresponding to-be-rendered data in the rendering-related data is transmitted to the game engine for rendering, instead of sending all the rendering-related data to the game engine, thereby reducing the rendering pressure of the game engine.
[0039] The game dynamic model processing method provided by the embodiment of the application first judges whether the logical layer data required by the current game picture is loaded, the logical layer data includes resource data of a dynamic model in the current game picture and change data of the dynamic model, the dynamic model is composed of a plurality of sub-models, if the logical layer data is loaded, rendering-related data is determined based on the logical layer data, the rendering-related data includes the change data of the dynamic model, a model bounding box and resource data related to rendering, the model bounding box is a bounding box corresponding to the whole dynamic model, then the frustum culling and the LOD switching of the dynamic model are performed based on the model bounding box, the to-be-rendered data is extracted from the rendering-related data according to the processing result, and the to-be-rendered data is sent to the game engine, so that the game engine renders the current game picture based on the to-be-rendered data. The model bounding box is calculated in the preparation stage of rendering, so that the range box is not calculated based on the change data for each sub-model; the frustum culling and the LOD switching are performed for the bounding box of the whole model, so that the culling operation amount and the number of graphic drawing can be reduced, and the processing efficiency of the dynamic model in the game picture can be improved.
[0040] The embodiment of the application further provides another game dynamic model processing method, which is implemented based on the above-mentioned embodiment, and mainly describes the specific process of determining the rendering-related data based on the logical layer data if the logical layer data is loaded (implemented through steps S206-S210), as shown in the following. Figure 2 The method comprises the following steps.
[0041] Step S202, judging whether the logical layer data required by the current game picture is loaded or not; if yes, executing step S206, otherwise, executing step S204.
[0042] In the specific implementation, the application splits the data into two stages, one is the logical layer data corresponding to the logical stage, and the other is the rendering related data corresponding to the rendering stage. The logical layer data includes the logical entity LogicEntiy and the logical data resource ResourceData; the rendering related data includes the rendering entity RenderEntity, the rendering data RenderData and the rendering sub-module RenderPart.
[0043] The ResourceData is a sub-model, which stores the resource data of the sub-model, and the resource data includes a series of objects related to resources such as model resources, material resources, material parameters, bone resources and map resources. The LogicEntity is a logical entity of script operation, which has a collection of ResourceData of multiple layers of LOD, and has some data related to bounding box, LOD switching, hanging and rendering. The structural relationship between the LogicEntity and the ResourceData is shown in Figure 3 As shown in the figure, one LogicEntity has multiple layers of LOD, and each layer of LOD has multiple ResourceData. Here, the ResourceData is not tiled, mainly because the user may frequently modify the dynamic model through the script. If the data is directly tiled every time, the efficiency will be very low.
[0044] In the specific implementation, the user can use the script to create the model through the preset interface, establish the mapping between the model and the entity, and the preset interface will also return the handle of the model to the script. The script uses the handle to perform a series of operations on the model such as replacing the material, modifying the material parameter, setting the rendering parameter and the like, so as to generate the change data, which is the data changed by the current game picture relative to the previous frame of the current game picture, including the deformation matrix and the rendering state. The deformation matrix is used to indicate the position change and / or state change of the dynamic model in the current game picture. Specifically, the user creates the dynamic model based on the script through the preset interface to obtain the resource data of the dynamic model; or adjusts the resource data of the dynamic model through the preset interface to obtain the change data corresponding to the dynamic model; wherein the adjustment of the dynamic model includes at least one of the following: modifying the material parameter of the dynamic model, replacing the material resource of the dynamic model, replacing the map resource of the dynamic model and modifying the bone resource of the dynamic model.
[0045] In practical applications, different game engines have different ways of loading game resources. Generally, the game engine calls the relevant interfaces of other modules to read the relevant data of the resources from the hard disk to the memory, and after initialization, the resources can be used. These resources are the logical layer data that have been loaded. Specifically, determining whether the logical layer data required by the current game screen has been loaded, that is, checking whether the resources on the LogicEntity are ready, which can also be understood as checking whether the model resources in the Lod interval set by the script are complete, including the entity's bone resources, model replacement material resources, replacement map resources, etc., or checking whether the shader Shader has been compiled. After the resources on the LogicEntity are ready, the subsequent steps are performed, which can prevent the game from freezing or flickering when a new resource is replaced.
[0046] Step S204: waiting for the detection of the loading completion of the logical layer data required by the next frame of game screen corresponding to the current game screen.
[0047] If the logical layer data required by the current game screen has not been loaded, that is, the change data has not been loaded, at this time, the current game screen will continue to use the logical layer data of the dynamic model used by the last frame of game screen until the change data is loaded, and then the subsequent step S206 is executed. It can also be understood that when the script needs to modify the model, the logical stage waits for the loading completion of the resource, and the rendering layer renders the original resource in this process. When the resource is ready, the new resource is rendered. This design can avoid the freezing or flickering problem caused by directly replacing the resource.
[0048] Step S206: determining whether the rendering related data needs to be reconstructed based on the logical layer data; if yes, performing step S208, otherwise, performing step S210.
[0049] The rendering-related data includes a render entity (RenderEntity), render data (RenderData), and a render part (RenderPart). The RenderEntity is a LogicEntity in a rendering state, which stores a current deformation matrix, a model bounding box in a world space, a distance from a camera, a current LOD level, a corresponding RenderData offset value, and a plurality of RenderData and a plurality of RenderPart stored in a tile. The RenderData corresponds to a submodel, which includes a LOD level corresponding to the submodel and an index of the RenderPart. The RenderPart corresponds to a group of meshes and shaders of the submodel, that is, resource data related to rendering corresponding to the submodel. In fact, the RenderPart means that each submodel can have different Mesh and shader resources. For example, the pants are cloth material, and the buttons are plastic material. A structure diagram of the RenderEntity, the RenderData, and the RenderPart is shown in FIG. 11. Figure 4 The RenderData and the RenderPart are both POD (Plain Old Data) data and are continuously stored. In this way, the data is organized in a more computer-friendly manner to improve running efficiency.
[0050] In a specific implementation, whether the rendering-related data needs to be reconstructed is determined based on the logic layer data, that is, whether the LogicEntity needs to reconstruct the data on the RenderEntity. Specifically, whether a submodel of a dynamic model in the logic layer data LogicEntity is added or deleted is determined. If the submodel is added or deleted, the rendering-related data needs to be rearranged. In some embodiments, if a script setting of the logic layer data changes the LOD interval, the rendering-related data also needs to be rearranged.
[0051] The specific process of rearranging the rendering related data is: rearranging the RenderData and the RenderPart data on the RenderEntity, and processing the data on the LogicEntity and the ResourceData, and only storing the data required for rendering into the RenderData; if the script modifies the material parameters, the update of the material parameters will also be put after the resource preparation is completed, because it is possible to replace new maps, and it is necessary to wait for the new map resource to be loaded first. Among them, the rendering data and the rendering sub-module corresponding to each sub-model in the rearranged rendering related data are stored in a compact tiling manner. Specifically, the purpose of rearranging the rendering related data is to maintain the compact tiling of the rendering data and the rendering sub-module, and to add the data of the newly added sub-model to the rendering data, or to delete the data of the deleted sub-model from the rendering data, etc.
[0052] In step S208, the rendering data and the rendering sub-module in the rendering related data are rearranged according to the logic layer data to obtain rearranged rendering related data; the change data in the logic layer data is copied into the rearranged rendering related data, the model bounding box in the rearranged rendering related data is multiplied by the deformation matrix in the change data to obtain a new model bounding box, and the model bounding box in the rearranged rendering related data is replaced by the new model bounding box; and step S212 is executed.
[0053] In step S210, the change data in the logic layer data is copied into the rendering related data, the model bounding box in the rendering related data is multiplied by the deformation matrix in the change data to obtain a new model bounding box, and the model bounding box in the rendering related data is replaced by the new model bounding box; and step S212 is executed.
[0054] The change data includes a deformation matrix, a rendering state, etc., and if the model is hidden in the rendering state set by the script, the following steps can be directly skipped. The model bounding box in the world space is obtained by multiplying the bounding box in the model space (equivalent to the bounding box in the above-mentioned rendering related data) by the deformation matrix, and the model bounding box is used for subsequent view frustum culling and LOD switching.
[0055] In step S212, based on the model bounding box, the dynamic model is subjected to view frustum culling and detail level switching processing to obtain a processing result.
[0056] In step S214, according to the processing result, the rendering related data is extracted from the rendering related data, and the rendering related data is sent to the game engine, so that the game engine renders the current game picture based on the rendering related data.
[0057] The application is in the form of a plug-in which puts all the dynamic models of a scene in one place for unified management, and is more convenient for meeting some special requirements of a game engine and debugging. In actual operation, the application can be divided into a logic stage and a rendering-related stage. In the logic stage, a script interacts with the plug-in of the application through a preset interface, including adding or deleting a model, replacing a model material, modifying a material parameter, modifying a model LOD parameter, and modifying a rendering parameter. The application records relevant data during the interaction with the script and processes the data in the refresh stage of each game picture, including obtaining a model resource, a material resource, and a new map resource. After the loading of these resources is completed, the application extracts and constructs rendering-related data from the logic layer data, such as data required by a bottom graphics API, through elimination and LOD switching. In the preparation stage of rendering, the application performs view frustum elimination and LOD switching according to a model as a whole instead of each single sub-model, and finally transmits corresponding rendering-related data to the bottom API of the game engine for rendering.
[0058] The above-mentioned dynamic model processing method in a game stores a large amount of data which needs to be calculated in each game picture in a more compact and tiled manner, so as to be more friendly to a CPU cache mechanism. Meanwhile, the method postpones the calculation of a large amount of model matrix operations (including the calculation of a deformation matrix and a bounding box) of each game picture to the preparation stage of rendering. In this way, only the bounding box of a model participating in rendering is calculated, and the calculation is postponed to the unified stage. In this way, the calculation of the bounding box of a sub-model after each matrix change is not needed, unnecessary calculation is reduced, and the game running efficiency is improved.
[0059] The embodiment of the application further provides another dynamic model processing method in a game. The method is implemented on the basis of the above-mentioned embodiment, and mainly describes the specific process of performing view frustum elimination and detail level switching processing on a dynamic model based on a model bounding box (implemented through steps S506-S510), and the specific process of extracting to-be-rendered data from rendering-related data according to the processing result and sending the to-be-rendered data to a game engine (implemented through steps S512-S514) as shown in the following. Figure 5 The method comprises the following steps.
[0060] In step S502, it is judged whether the logic layer data required by the current game picture is loaded completely. The logic layer data comprises resource data of a plurality of dynamic models contained in the current game picture and change data of each dynamic model. Each dynamic model is composed of a plurality of sub-models.
[0061] Step S504, if the loading is completed, determining rendering related data based on the logical layer data; wherein the rendering related data comprises change data and a model bounding box of each dynamic model, and resource data related to rendering; the model bounding box is a bounding box corresponding to the whole dynamic model.
[0062] Specifically, one dynamic model corresponds to one model bounding box.
[0063] Step S506, determining a view frustum by acquiring six planes of a camera of a current game picture.
[0064] Step S508, in the plurality of dynamic models, removing a dynamic model whose model bounding box is not in the view frustum to obtain remaining dynamic models.
[0065] In actual application, the view frustum culling processing of the present application refers to a visibility operation through the six planes of the camera and the model bounding box in the rendering related data. This mode directly uses the model bounding box of the whole dynamic model instead of using the bounding box of each sub-model, mainly because the bounding box itself is not very accurate, and the sub-models in the dynamic model will be displayed or removed uniformly with the whole dynamic model in most cases. By simplifying to only one model bounding box visibility operation, the operation amount of the culling processing can be reduced.
[0066] Step S510, for each remaining dynamic model, performing a level of detail (LOD) switching processing on the remaining dynamic model according to a distance between the model bounding box corresponding to the remaining dynamic model and the camera, or according to a screen ratio of the model bounding box corresponding to the remaining dynamic model, to obtain a processing result; wherein the processing result is used to indicate a sub-model that needs to be rendered in rendering of the remaining dynamic model.
[0067] In actual application, there are two switching modes for the LOD switching, one is directly switching the LOD according to the distance between the model bounding box corresponding to the remaining dynamic model and the camera, and the other is switching the LOD according to the screen ratio of the model bounding box corresponding to the remaining dynamic model. The switching according to the distance has a smaller operation amount and can be suitable for most cases. The switching according to the screen ratio is mainly suitable for cases where the FOV of the camera will change significantly or the overall size of the dynamic model will change. The threshold value of the LOD switching is also multiplied by a certain rate here to prevent the LOD switching from producing jitter at the threshold boundary.
[0068] Step S512, extracting resource data related to rendering corresponding to the sub-model that needs to be rendered in the rendering of the remaining dynamic model indicated by the processing result from the rendering related data of the remaining dynamic model, and determining the extracted data as to-be-rendered data.
[0069] The to-be-rendered data is the data on the relevant RenderPart. Since the view frustum culling and LOD switching have been completed, only the data of the corresponding LOD level of the RenderPart within the view frustum needs to be submitted to the relevant position of the game engine.
[0070] In step S514, the to-be-rendered data is sent to the game engine, so that the game engine renders the current game picture based on the to-be-rendered data.
[0071] In actual application, if the current game picture contains multiple dynamic models, a thread task group can also be generated based on the multiple dynamic models, and the thread task group is divided into multiple preset sub-threads for processing, so as to process the multiple dynamic models in parallel. Since there is no any dependency between each RenderEntity in the processing of the rendering related stage, a thread task group can be easily formed by multiple RenderEntity, and then the thread task group is distributed to multiple sub-threads for processing. Through the parallel processing mode, the processing efficiency of the dynamic model can be further improved.
[0072] The above-mentioned dynamic model processing method in the game does not perform culling and LOD related operations on each sub-model when performing view frustum culling or LOD switching, but performs operations on the overall model corresponding to multiple sub-models, thereby reducing a large number of culling operations. Moreover, when performing LOD switching, each layer of LOD no longer needs to have the same number of models, so that only a few models can be displayed at a low precision LOD, thereby reducing the number of times of graphic drawing and improving the efficiency. Meanwhile, the method can efficiently process a large number of dynamic objects in a game scene, including management of object resources, management of material parameters, processing of view frustum culling and LOD switching of objects in each frame during running, and the like.
[0073] Corresponding to the above-mentioned method embodiment, the embodiment of the present application also provides a dynamic model processing device in a game, as shown in the figure, the device comprises: Figure 6
[0074] The judging module 60 is configured to judge whether the logical layer data required by the current game picture is loaded or not. The logical layer data includes resource data of a dynamic model in the current game picture and change data of the dynamic model. The dynamic model is composed of multiple sub-models.
[0075] The data determining module 61 is configured to determine rendering related data based on the logical layer data if the logical layer data is loaded. The rendering related data includes change data and model bounding box of the dynamic model and resource data related to rendering. The model bounding box is a bounding box corresponding to the whole dynamic model.
[0076] The model processing module 62 is configured to perform view frustum culling and level of detail switching processing on the dynamic model based on the model bounding box to obtain a processing result.
[0077] The data extraction module 63 is configured to extract to-be-rendered data from the rendering-related data according to the processing result, and send the to-be-rendered data to the game engine, so that the game engine renders the current game picture based on the to-be-rendered data.
[0078] The above-mentioned dynamic model processing device in the game first determines whether the logical layer data required by the current game picture is loaded; the logical layer data includes resource data of a dynamic model in the current game picture and change data of the dynamic model; the dynamic model is composed of a plurality of sub-models; if the loading is completed, rendering-related data is determined based on the logical layer data; the rendering-related data includes change data of the dynamic model and a model bounding box, and resource data related to rendering; the model bounding box is a bounding box corresponding to the whole dynamic model; then, the dynamic model is subjected to view frustum culling and level of detail switching processing based on the model bounding box, to-be-rendered data is extracted from the rendering-related data according to a processing result, and the to-be-rendered data is sent to the game engine, so that the game engine renders the current game picture based on the to-be-rendered data. This way calculates the model bounding box in the rendering preparation stage, avoiding calculating the range box based on the change data for each sub-model; and this way performs frustum culling and level of detail switching on the bounding box of the whole model, which can reduce the amount of culling operation and the number of times of graphic drawing, and helps to improve the processing efficiency of the dynamic model in the game picture.
[0079] Specifically, the above-mentioned resource data includes model resources, material resources, bone resources and map resources; the above-mentioned change data is data changed in the current game picture relative to a previous frame of game picture of the current game picture, including a deformation matrix and a rendering state; the deformation matrix is used to indicate the position change and / or state change of the dynamic model in the current game picture; the above-mentioned device further includes a model adjusting module, configured to: before determining whether the logical layer data required by the current game picture is loaded, create the dynamic model through a preset interface to obtain resource data of the dynamic model; adjust the resource data of the dynamic model through the preset interface to obtain change data corresponding to the dynamic model; wherein the adjustment of the dynamic model includes at least one of the following: modifying material parameters of the dynamic model, replacing material resources of the dynamic model, replacing map resources of the dynamic model, and modifying bone resources of the dynamic model, etc.
[0080] In a specific implementation, the rendering-related data includes a model bounding box, a plurality of rendering data stored in a tile manner, and a plurality of rendering sub-modules; the rendering data includes a level of detail corresponding to a sub-model in a dynamic model and an index of a corresponding rendering sub-module; the rendering sub-module includes resource data corresponding to the sub-model and related to rendering; the data determination module 61 is configured to: if the loading is completed, determine whether the rendering-related data needs to be reconstructed based on the logical layer data; if not, copy change data in the logical layer data to the rendering-related data, multiply the model bounding box in the rendering-related data by a deformation matrix in the change data to obtain a new model bounding box, and replace the model bounding box in the rendering-related data with the new model bounding box; if yes, rearrange the rendering data and the rendering sub-module in the rendering-related data according to the logical layer data to obtain rearranged rendering-related data; copy the change data in the logical layer data to the rearranged rendering-related data, multiply the model bounding box in the rearranged rendering-related data by the deformation matrix in the change data to obtain a new model bounding box, and replace the model bounding box in the rearranged rendering-related data with the new model bounding box.
[0081] Further, the data determination module 61 is further configured to: determine whether a sub-model of a dynamic model in the logical layer data is added or deleted; if yes, the rendering-related data needs to be rearranged; wherein the rendering data and the rendering sub-module corresponding to each sub-model in the rearranged rendering-related data are stored in a compact tile manner.
[0082] In a specific implementation, the current game screen includes a plurality of dynamic models; the model processing module 62 is configured to: determine a view frustum by obtaining six planes of a camera in the current game screen; in the plurality of dynamic models, eliminate a dynamic model whose model bounding box is not in the view frustum to obtain remaining dynamic models; for each remaining dynamic model, perform level of detail switching processing on the remaining dynamic model according to a distance between a model bounding box corresponding to the remaining dynamic model and the camera or according to a screen ratio of the model bounding box corresponding to the remaining dynamic model to obtain a processing result; wherein the processing result is used to indicate a sub-model that needs to be rendered in rendering of the remaining dynamic model.
[0083] Further, the data extraction module 63 is configured to: from rendering-related data corresponding to the remaining dynamic model, extract resource data corresponding to a sub-model that needs to be rendered in rendering of the remaining dynamic model indicated by the processing result, and determine the extracted data as to-be-rendered data; and send the to-be-rendered data to a game engine.
[0084] In actual application, the current game picture contains multiple dynamic models; the device further includes a parallel processing module, configured to: based on the multiple dynamic models, generate a thread task group; and divide the thread task group into multiple preset sub-threads for processing, so as to process the multiple dynamic models in parallel
[0085] The game dynamic model processing device provided by the embodiments of the present application has the same implementation principle and technical effects as the game dynamic model processing method, and for brevity of description, the part of the device embodiments not mentioned can be referred to the corresponding content in the method embodiments.
[0086] The embodiments of the present application further provide an electronic device, as shown in the figure, which includes a processor and a memory, the memory stores machine executable instructions executable by the processor, and the processor executes the machine executable instructions to implement the game dynamic model processing method. Figure 7
[0087] Specifically, the game dynamic model processing method includes: judging whether the logical layer data required by the current game picture is loaded; wherein the logical layer data includes resource data of a dynamic model in the current game picture and change data of the dynamic model; wherein the dynamic model is composed of multiple sub-models; if the loading is completed, determining rendering related data based on the logical layer data; wherein the rendering related data includes change data and model bounding box of the dynamic model, and resource data related to rendering; the model bounding box is a bounding box corresponding to the whole dynamic model; performing frustum culling and level of detail switching processing on the dynamic model based on the model bounding box to obtain a processing result; extracting to-be-rendered data from the rendering related data according to the processing result, and sending the to-be-rendered data to a game engine, so that the game engine renders the current game picture based on the to-be-rendered data.
[0088] The game dynamic model processing method calculates the model bounding box in the rendering preparation stage, avoids calculating the range box based on the change data for each sub-model, and performs frustum culling and level of detail switching on the bounding box of the whole model, which can reduce the culling operation amount and the number of graphic drawing times, and is helpful to improve the processing efficiency of the dynamic model in the game picture.
[0089] In an optional embodiment, the resource data includes a model resource, a material resource, a skeleton resource, and a texture resource; the change data is data of changes of a current game screen relative to a previous frame of game screen of the current game screen, including a deformation matrix and a rendering state; the deformation matrix is used to indicate position changes and / or state changes of a dynamic model in the current game screen; before the step of judging whether the logical layer data required by the current game screen is loaded, the method further includes: creating the dynamic model through a preset interface to obtain resource data of the dynamic model; adjusting the resource data of the dynamic model through the preset interface to obtain change data corresponding to the dynamic model; wherein the adjustment of the dynamic model includes at least one of the following: modifying a material parameter of the dynamic model, replacing a material resource of the dynamic model, replacing a texture resource of the dynamic model, and modifying a skeleton resource of the dynamic model, etc.
[0090] In an optional embodiment, the rendering-related data includes a model bounding box, a plurality of rendering data stored in a tile manner, and a plurality of rendering sub-modules; wherein the rendering data includes a level of detail of a sub-model in the dynamic model and an index of a corresponding rendering sub-module; the rendering sub-module includes resource data related to rendering corresponding to the sub-model; if the loading is completed, the step of determining the rendering-related data based on the logical layer data includes: if the loading is completed, judging whether the rendering-related data needs to be reconstructed based on the logical layer data; if not, copying change data in the logical layer data to the rendering-related data, multiplying the model bounding box in the rendering-related data by the deformation matrix in the change data to obtain a new model bounding box, and replacing the model bounding box in the rendering-related data with the new model bounding box; if yes, rearranging the rendering data and the rendering sub-module in the rendering-related data according to the logical layer data to obtain rearranged rendering-related data; copying the change data in the logical layer data to the rearranged rendering-related data, multiplying the model bounding box in the rearranged rendering-related data by the deformation matrix in the change data to obtain a new model bounding box, and replacing the model bounding box in the rearranged rendering-related data with the new model bounding box.
[0091] In an optional embodiment, the step of judging whether the rendering-related data needs to be reconstructed based on the logical layer data includes: judging whether a sub-model of the dynamic model in the logical layer data is added or deleted; if yes, the rendering-related data needs to be rearranged; wherein the rendering data and the rendering sub-module corresponding to each sub-model in the rearranged rendering-related data are stored in a compact tile manner.
[0092] In an optional embodiment, the current game picture contains a plurality of dynamic models; the step of performing view frustum culling and level of detail switching processing on the dynamic models based on the model bounding boxes to obtain a processing result includes: determining a view frustum by obtaining six planes of a camera of the current game picture; in the plurality of dynamic models, culling a dynamic model whose model bounding box is not in the view frustum to obtain a remaining dynamic model; for each remaining dynamic model, performing level of detail switching processing on the remaining dynamic model according to a distance between the model bounding box corresponding to the remaining dynamic model and the camera or according to a screen ratio of the model bounding box corresponding to the remaining dynamic model to obtain a processing result; wherein the processing result is used to indicate a sub-model that needs to be rendered in rendering of the remaining dynamic model.
[0093] In an optional embodiment, the step of extracting the to-be-rendered data from the rendering-related data according to the processing result and sending the to-be-rendered data to the game engine includes: extracting resource data related to rendering corresponding to a sub-model that needs to be rendered in rendering of a remaining dynamic model indicated by the processing result from rendering-related data corresponding to the remaining dynamic model, and determining the extracted data as the to-be-rendered data; and sending the to-be-rendered data to the game engine.
[0094] In an optional embodiment, the current game picture contains a plurality of dynamic models; the method further includes: generating a thread task group based on the plurality of dynamic models; and dividing the thread task group into a plurality of preset sub-threads for processing to process the plurality of dynamic models in parallel.
[0095] Further, Figure 7 The electronic device shown further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
[0096] The memory 100 can include a high-speed random access memory (RAM) and can also include a non-volatile memory such as at least one disk memory. The communication between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used. The bus 102 can be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the figure to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0097] The processor 101 can be an integrated circuit chip having signal processing capability. In the implementation process, each step of the above method can be completed by the integrated logic circuit of hardware or the instruction in the form of software in the processor 101. The processor 101 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block diagram disclosed in the embodiment of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiment of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in 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 storage medium in the art. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and combines the hardware to complete the steps of the method of the above embodiment.
[0098] The embodiment of the present application also provides a computer readable storage medium, the computer readable storage medium stores computer executable instructions, when the computer executable instructions are called and executed by the processor, the computer executable instructions cause the processor to realize the dynamic model processing method in the game described above, and the specific implementation can be referred to the method embodiment, and will not be repeated here.
[0099] Specifically, the method for processing a dynamic model in a game comprises: determining whether logical layer data required by a current game screen is loaded; wherein the logical layer data comprises resource data of a dynamic model in the current game screen and change data of the dynamic model; wherein the dynamic model is composed of multiple sub-models; if the logical layer data is loaded, determining rendering related data based on the logical layer data; wherein the rendering related data comprises change data of the dynamic model and a model bounding box and resource data related to rendering; the model bounding box is a bounding box corresponding to the dynamic model as a whole; performing frustum culling and level of detail switching processing on the dynamic model based on the model bounding box to obtain a processing result; extracting to-be-rendered data from the rendering related data according to the processing result, and sending the to-be-rendered data to a game engine, so that the game engine renders the current game screen based on the to-be-rendered data.
[0100] The method for processing a dynamic model in a game calculates a model bounding box in a rendering preparation stage, avoids calculating a range box based on change data for each sub-model, performs frustum culling and level of detail switching on the bounding box of the model as a whole, reduces the amount of culling operation and the number of times of graphic drawing, and helps to improve the processing efficiency of the dynamic model in a game screen.
[0101] In an optional embodiment, the resource data comprises model resources, material resources, skeleton resources and map resources; the change data is data that changes relative to a previous game screen of the current game screen, and comprises a deformation matrix and a rendering state; wherein the deformation matrix is used to indicate position change and / or state change of the dynamic model in the current game screen; before the step of determining whether the logical layer data required by the current game screen is loaded, the method further comprises: creating the dynamic model through a preset interface to obtain resource data of the dynamic model; and adjusting the resource data of the dynamic model through the preset interface to obtain change data corresponding to the dynamic model; wherein the adjustment of the dynamic model comprises at least one of the following: modifying material parameters of the dynamic model, replacing material resources of the dynamic model, replacing map resources of the dynamic model and modifying skeleton resources of the dynamic model.
[0102] In an optional embodiment, the rendering-related data includes a model bounding box, a plurality of rendering data stored in a tile manner, and a plurality of rendering sub-modules; the rendering data includes a level of detail corresponding to a sub-model in the dynamic model and an index of the corresponding rendering sub-module; the rendering sub-module includes resource data corresponding to the sub-model and related to rendering; and the step of determining the rendering-related data based on the logical layer data after the loading is completed includes: determining whether the rendering-related data needs to be reconstructed based on the logical layer data after the loading is completed; if not, copying the change data in the logical layer data to the rendering-related data, multiplying the model bounding box in the rendering-related data by the deformation matrix in the change data to obtain a new model bounding box, and replacing the model bounding box in the rendering-related data with the new model bounding box; if yes, rearranging the rendering data and the rendering sub-module in the rendering-related data according to the logical layer data to obtain rearranged rendering-related data; copying the change data in the logical layer data to the rearranged rendering-related data, multiplying the model bounding box in the rearranged rendering-related data by the deformation matrix in the change data to obtain a new model bounding box, and replacing the model bounding box in the rearranged rendering-related data with the new model bounding box.
[0103] In an optional embodiment, the step of determining whether the rendering-related data needs to be reconstructed based on the logical layer data includes: determining whether a sub-model of the dynamic model in the logical layer data is added or deleted; if yes, the rendering-related data needs to be rearranged; and each sub-model in the rearranged rendering-related data corresponds to rendering data and a rendering sub-module stored in a compact tile manner.
[0104] In an optional embodiment, the current game screen includes a plurality of dynamic models; and the step of performing frustum culling and level of detail switching processing on the dynamic models based on the model bounding box to obtain a processing result includes: determining a frustum by obtaining six planes of a camera in the current game screen; culling, from the plurality of dynamic models, a dynamic model whose model bounding box is not in the frustum to obtain remaining dynamic models; performing, for each remaining dynamic model, level of detail switching processing on the remaining dynamic model according to a distance between the model bounding box corresponding to the remaining dynamic model and the camera or according to a screen ratio of the model bounding box corresponding to the remaining dynamic model to obtain a processing result; and the processing result is used to indicate a sub-model that needs to be rendered in rendering of the remaining dynamic model.
[0105] In an optional embodiment, the step of extracting the to-be-rendered data from the rendering-related data according to the processing result and sending the to-be-rendered data to the game engine comprises: extracting, from the rendering-related data of the remaining dynamic model, resource data related to rendering corresponding to the sub-models that need to be rendered in the rendering of the remaining dynamic model indicated by the processing result, and determining the extracted data as the to-be-rendered data; and sending the to-be-rendered data to the game engine.
[0106] In an optional embodiment, the current game picture contains a plurality of dynamic models; the method further comprises: generating a thread task group based on the plurality of dynamic models; and dividing the thread task group into a plurality of preset sub-threads for processing, so as to process the plurality of dynamic models in parallel.
[0107] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the present application that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0108] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application. In addition, the terms "first", "second", "third" are only for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0109] Finally, it should be noted that the above-described embodiments are merely specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the same. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any person skilled in the art can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features, within the technical scope disclosed by the present application. The modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for processing dynamic models in a game, characterized in that, The method includes: Determine whether the logic layer data required for the current game screen has been fully loaded; wherein, the logic layer data includes: resource data of the dynamic model in the current game screen, and change data of the dynamic model; wherein, the dynamic model is composed of multiple sub-models; If loading is complete, based on the logical layer data, rendering-related data is determined; wherein, the rendering-related data includes: change data of the dynamic model, model bounding box, multiple rendering data stored in a tiled manner, multiple rendering sub-modules, and rendering-related resource data; the model bounding box is the bounding box corresponding to the entire dynamic model; the rendering data includes the level of detail level corresponding to a sub-model in the dynamic model and the index of the corresponding rendering sub-module; the rendering sub-module includes the rendering-related resource data corresponding to the sub-model; Based on the model bounding box, the dynamic model is subjected to frustum culling and detail level switching to obtain the processing result; Based on the processing result, the data to be rendered is extracted from the rendering-related data, and the data to be rendered is sent to the game engine so that the game engine can render the current game screen based on the data to be rendered. If loading is complete, the step of determining rendering-related data based on the logical layer data includes: If loading is complete, determine whether the rendering-related data needs to be reconstructed based on the logic layer data; if not, copy the changed data in the logic layer data to the rendering-related data, multiply the model bounding box in the rendering-related data with the deformation matrix in the changed data to obtain a new model bounding box, and replace the model bounding box in the rendering-related data with the new model bounding box. If necessary, the rendering data and rendering sub-modules in the rendering-related data are rearranged according to the logic layer data to obtain rearranged rendering-related data; the changed data in the logic layer data is copied to the rearranged rendering-related data; the model bounding box in the rearranged rendering-related data is multiplied with the deformation matrix in the changed data to obtain a new model bounding box; and the model bounding box in the rearranged rendering-related data is replaced with the new model bounding box.
2. The method according to claim 1, characterized in that, The resource data includes model resources, material resources, bone resources, and texture resources; the change data refers to the changes in the current game screen relative to the previous frame of the game screen, including deformation matrix and rendering state; wherein, the deformation matrix is used to indicate the position change and / or state change of the dynamic model in the current game screen; Before the step of determining whether the logic layer data required for the current game screen has been fully loaded, the method further includes: The dynamic model is created through a preset interface, and the resource data of the dynamic model is obtained. The resource data of the dynamic model is adjusted through the preset interface to obtain the change data corresponding to the dynamic model; wherein, the adjustment of the dynamic model includes at least one of the following: modifying the material parameters of the dynamic model, replacing the material resources of the dynamic model, replacing the texture resources of the dynamic model, and modifying the skeletal resources of the dynamic model.
3. The method according to claim 1, characterized in that, The step of determining whether the rendering-related data needs to be reconstructed based on the logic layer data includes: Determine whether any sub-models of the dynamic model in the logical layer data have been added or deleted; if so, the rendering-related data needs to be rearranged; wherein, the rendering data and rendering sub-modules corresponding to each sub-model in the rearranged rendering-related data are compactly and flatly stored.
4. The method according to claim 1, characterized in that, The current game screen contains multiple dynamic models; The steps of performing frustum culling and detail level switching on the dynamic model based on the model bounding box to obtain the processing result include: The visual frustum is determined by acquiring the six planes of the camera in the current game view; Among the multiple dynamic models, the dynamic models whose bounding boxes are not within the visual cone are removed to obtain the remaining dynamic models; For each remaining dynamic model, the level of detail switching process is performed on the remaining dynamic model according to the distance between the model bounding box corresponding to the remaining dynamic model and the camera, or according to the screen ratio of the model bounding box corresponding to the remaining dynamic model, to obtain the processing result; wherein, the processing result is used to indicate the sub-models that need to be rendered in the rendering of the remaining dynamic model.
5. The method according to claim 4, characterized in that, The step of extracting the data to be rendered from the rendering-related data based on the processing result and sending the data to be rendered to the game engine includes: From the rendering-related data corresponding to the remaining dynamic model, extract the rendering-related resource data corresponding to the sub-model that needs to be rendered in the rendering of the remaining dynamic model as indicated by the processing result, and determine the extracted data as the data to be rendered. The data to be rendered is sent to the game engine.
6. The method according to claim 1, characterized in that, The current game screen contains multiple dynamic models; the method further includes: Based on the aforementioned multiple dynamic models, a thread task group is generated; The thread task group is divided into multiple preset sub-threads for processing, so as to process the multiple dynamic models in parallel.
7. A dynamic model processing device for games, characterized in that, The device includes: The judgment module is used to determine whether the logic layer data required for the current game screen has been loaded completely; wherein, the logic layer data includes: resource data of the dynamic model in the current game screen, and change data of the dynamic model; wherein, the dynamic model is composed of multiple sub-models; A data determination module is used to determine rendering-related data based on the logic layer data once loading is complete. The rendering-related data includes: change data of the dynamic model, model bounding boxes, multiple tiled rendering data sets and multiple rendering sub-modules, and rendering-related resource data. The model bounding box is the bounding box corresponding to the entire dynamic model. The rendering data includes the level of detail level corresponding to a sub-model in the dynamic model and the index of the corresponding rendering sub-module. The rendering sub-module includes rendering-related resource data corresponding to the sub-model. The model processing module is used to perform frustum culling and detail level switching on the dynamic model based on the model bounding box to obtain the processing result; The data extraction module is used to extract data to be rendered from the rendering-related data according to the processing result, and send the data to be rendered to the game engine so that the game engine renders the current game screen based on the data to be rendered. The data determination module is further configured to, if loading is complete, determine whether the rendering-related data needs to be reconstructed based on the logic layer data; if not, copy the changed data in the logic layer data to the rendering-related data, multiply the model bounding box in the rendering-related data with the deformation matrix in the changed data to obtain a new model bounding box, and replace the model bounding box in the rendering-related data with the new model bounding box; if necessary, rearrange the rendering data and rendering sub-modules in the rendering-related data according to the logic layer data to obtain rearranged rendering-related data; copy the changed data in the logic layer data to the rearranged rendering-related data, multiply the model bounding box in the rearranged rendering-related data with the deformation matrix in the changed data to obtain a new model bounding box, and replace the model bounding box in the rearranged rendering-related data with the new model bounding box.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the dynamic model processing method in a game as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the dynamic model processing method in a game as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Large-volume three-dimensional scene three-dimensional model rendering optimization method and system
CN113808247A
Scene rendering method and device, runner and readable storage medium
CN114627221A