Scene rendering method, computing device, storage medium and computer program product
By splitting the virtual scene into multiple scene data blocks, loading and eliminating unnecessary data, the problems of high memory footprint and long loading time in virtual scene rendering are solved, and faster loading speed and better user experience are achieved.
Patent Information
- Application Number
- CN202411872827.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-28
AI Technical Summary
During the virtual scene rendering process, the object data is huge, resulting in excessive memory usage and long loading time, affecting the user's virtual experience.
By splitting the target scene into multiple scene data blocks, loading and determining the target object information in each data block, removing unnecessary scene data, and performing culling processing before rendering, to reduce memory usage and loading time.
By splitting the scene into multiple data blocks, the size of a single file is reduced, the loading speed is improved, the memory footprint is reduced, and the user's virtual experience is improved.
Smart Images

Figure CN119722894A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a scene rendering method, a computing device, a storage medium, and a computer program product. Background Art
[0002] In actual applications, in order to ensure the authenticity and richness of virtual scenes, a large number of objects are usually rendered in the virtual scenes, such as vegetation, snow, land, etc. However, in virtual scenes, the amount of object data to be rendered is huge, which will cause excessive memory usage and long loading time when loading and rendering, affecting the user's virtual experience. Summary of the invention
[0003] In view of this, an embodiment of the present specification provides a scene rendering method. One or more embodiments of the present specification also relate to a scene rendering device, a computing device, a computer-readable storage medium and a computer program product to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of this specification, a scene rendering method is provided, including: In response to an operation instruction for a target scene, determining a plurality of scene data blocks of the target scene; Loading the multiple scene data blocks, and determining target object information of target objects in the multiple scene data blocks, to obtain a scene data set of the target scene; Determine and remove the scene data to be removed from the scene data set to obtain target scene data; The target scene data is rendered to obtain the target scene.
[0005] According to a second aspect of an embodiment of this specification, a scene rendering device is provided, including: A determination module, configured to determine a plurality of scene data blocks of the target scene in response to an operation instruction for the target scene; A loading module is configured to load the multiple scene data blocks, determine target object information of target objects in the multiple scene data blocks, and obtain a scene data set of the target scene; A removal module is configured to determine and remove the scene data to be removed from the scene data set to obtain target scene data; The rendering module is configured to render the target scene data to obtain the target scene.
[0006] According to a third aspect of an embodiment of this specification, a computing device is provided, including: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above-mentioned scene rendering method are implemented.
[0007] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned scene rendering method are implemented.
[0008] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which implements the steps of the above-mentioned scene rendering method when executed by a processor.
[0009] An embodiment of the present specification provides a scene rendering method, comprising: in response to an operating instruction for a target scene, determining multiple scene data blocks of the target scene; loading the multiple scene data blocks, and determining target object information of target objects in the multiple scene data blocks, to obtain a scene data set of the target scene; determining and eliminating scene data to be eliminated from the scene data set, to obtain target scene data; rendering the target scene data, to obtain the target scene.
[0010] In the above method, after responding to the running instruction for the target scene, multiple scene data blocks of the target scene are determined, and the multiple scene data blocks are loaded, and the target object information of the target objects contained in the multiple scene data blocks is determined, so as to obtain the scene data set of the target scene, determine and eliminate the scene data to be eliminated from the scene data set, obtain the target scene data, and render the target scene according to the target scene data. By splitting the target scene into multiple scene data, the size of a single file is reduced, the loading speed is increased, thereby reducing the loading time, and the scene data set is eliminated before rendering to reduce memory usage, thereby further ensuring the user's virtual experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 is a flow chart of a scene rendering method provided by an embodiment of this specification; Figure 2 It is a schematic diagram of dividing a target scene in a scene rendering method provided by an embodiment of this specification; Figure 3 It is a schematic diagram of data restoration in a scene rendering method provided by an embodiment of this specification; FIG4( a ) is a schematic diagram of a scene data set before being shuffled in a scene rendering method provided by an embodiment of the present specification; FIG4( b ) is a schematic diagram of a shuffled scene data set in a scene rendering method provided by an embodiment of this specification; Figure 5 It is a schematic diagram of data elimination in a scene rendering method provided by an embodiment of this specification; FIG6 (a) is a schematic diagram of first rendering data in a scene rendering method provided by an embodiment of this specification; FIG6( b ) is a schematic diagram of second rendering data in a scene rendering method provided by an embodiment of this specification; FIG6 (c) is a schematic diagram of third rendering data in a scene rendering method provided by an embodiment of this specification; FIG6( d ) is a schematic diagram of fourth rendering data in a scene rendering method provided by an embodiment of this specification; FIG. 7 (a) and FIG. 7 (b) are schematic diagrams of a rendering process in a scene rendering method provided in an embodiment of the present specification; Figure 8 is a structural schematic diagram of a scene rendering device provided by an embodiment of this specification; Fig. 9 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0012] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0013] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0014] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0015] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0016] In actual applications, in the game field, when rendering virtual game scenes, in order to ensure the authenticity of the virtual game scenes, a large number of different types of vegetation can be rendered in the virtual game scenes, which requires data optimization, streaming loading, culling optimization and batch processing. The data organization of a large number of instances and the culling of each instance object will bring about large memory usage and performance issues. Therefore, an effective technical solution is urgently needed to solve the above problems.
[0017] In this specification, a scene rendering method is provided. This specification also relates to a scene rendering device, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.
[0018] See also Figure 1 , Figure 1 A flow chart of a scene rendering method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0019] Step 102: In response to an operation instruction for a target scene, a plurality of scene data blocks of the target scene are determined.
[0020] Specifically, the scene rendering method provided in this specification can be applied to the field of virtual scene generation. For example, it can be virtual scene generation in the field of games, that is, rendering and generating game scenes in games. It can also be applied to virtual scene generation in other fields, such as film and television fields, architectural design fields, virtual reality fields, etc. Specifically, in the field of film and television, movie special effects, animated films, and TV programs can use virtual scene rendering to create visual effects. In the field of architectural design, virtual scene rendering can be used to display unbuilt buildings or interior designs, and a preview of the final effect of the architectural design can be achieved. This specification embodiment does not limit this. For ease of understanding, this specification embodiment takes the application of the scene rendering method to vegetation rendering in a game scene as an example for explanation.
[0021] The target scene can be understood as a virtual scene that needs to be rendered, such as a game scene or a virtual reality scene. Taking the target scene as a game scene of a target game as an example, the running instruction for the target scene can be understood as the game running instruction for the target game by the user on the client. The multiple scene data blocks of the target scene can be understood as scene data for rendering the target scene.
[0022] In actual applications, the client receives a game running instruction for the target game from a game player of the target game, and can obtain multiple scene data blocks of the target scene of the target game from the memory of the client.
[0023] Furthermore, before determining the plurality of scene data blocks of the target scene in response to the running instruction for the target scene, the method further includes: Dividing the target scene to obtain a plurality of scene data blocks of the target scene; The multiple scene data blocks are stored according to a preset storage structure.
[0024] The preset storage structure may be understood as a storage structure for scene data of a target scene. In practical applications, the preset storage structure may be a quadtree structure.
[0025] Specifically, the target scene may be divided into a plurality of scene data blocks, and the plurality of scene data blocks may be stored according to a preset storage structure.
[0026] In summary, by dividing and storing the target scenes, the size of a single file is reduced and the loading speed is improved.
[0027] In a specific implementation, dividing the target scene to obtain a plurality of scene data blocks of the target scene includes: Dividing the target scene to obtain a plurality of sub-scenes corresponding to the target scene, and determining a terrain height map and an object density map corresponding to each of the plurality of sub-scenes; Dividing each of the multiple sub-scenes to obtain multiple sub-scene areas corresponding to the target scene; Divide each of the multiple sub-scene areas to obtain multiple scene data blocks of the target scene; The storing of the plurality of scene data blocks according to the preset storage structure includes: According to a preset storage structure, the multiple sub-scenes, the terrain height map and the object density map corresponding to each sub-scene, the multiple sub-scene areas and the multiple scene data blocks are stored.
[0028] The target scene contains multiple target objects. When the target scene is a game scene, the target object can be understood as the vegetation in the game scene. The terrain height map can be used to record the height of the terrain, and to restore the coordinate height of the target object during subsequent scene rendering. The object density map can be understood as the distribution density map of the target object, such as the distribution density map of vegetation.
[0029] Specifically, the process of obtaining multiple scene data blocks includes the following steps: step 1, dividing the target scene to obtain multiple sub-scenes corresponding to the target scene; step 2, dividing the multiple sub-scene areas and each sub-scene area to obtain multiple scene data blocks of the target scene; step 3, storing the multiple sub-scenes, the terrain height map and object density map corresponding to each sub-scene, the multiple sub-scene areas and the multiple scene data blocks according to a preset storage structure.
[0030] In specific implementation, the target scene is divided to obtain multiple sub-scenes corresponding to the target scene, and after determining the terrain height map and object density map corresponding to each sub-scene in the multiple sub-scenes, the scene data block (i.e., cluster data) corresponding to the target scene can also be obtained.
[0031] In practical applications, see Figure 2 , Figure 2 A schematic diagram of the division of a target scene in a scene rendering method provided according to an embodiment of the present specification is shown. Specifically, the entire target scene is divided into multiple sub-scenes (i.e., SubScene, which can be a data management unit of 1024 meters * 1024 meters, and subsequently recorded as 1K * 1K), and each sub-scene exports a terrain height map and multiple vegetation data density maps (i.e., object density maps).
[0032] Terrain height map, used to restore the vegetation coordinate height at runtime, recorded as Terrain1K_X_Y_HeighMap, where X and Y are the block index values of the sub-scene in the target scene.
[0033] The vegetation data density map can be recorded as the number of vegetation in the 2*2 meter area according to a pixel point of 2*2 meters. There are multiple different types of vegetation on each sub-scene. Each type of vegetation has its own density map data. Each density map is exported and recorded as Terrain1K_X_Y_GrassA_DensityMap (i.e. multiple vegetation data density maps), where X, Y are the block index values of the sub-scene in the target scene, and A is the specific vegetation type.
[0034] The vegetation data density map can be recorded as 8 bits per pixel, supporting a maximum of 255 plants in a 2*2 meter area. Two density maps of different types can be combined into one density map, each recording requires 4 bits (a maximum of 16 plants in a 2*2 meter area). Optionally, the density map can be compressed and stored to further reduce the amount of data storage.
[0035] Each sub-scene is further divided into multiple sub-scene areas (i.e., Blocks). The size of a sub-scene area is 256 meters * 256 meters. A sub-scene area is the minimum data loading and restoration unit for vegetation.
[0036] Each sub-scene area is further divided into 4m*4m areas, called scene data blocks (i.e. Clusters). A scene data block is used as a culling unit, and the number of vegetation in a scene data block is not fixed based on the density map.
[0037] Each sub-scene area has different vegetation, each type of vegetation is called a data slice, and different data slices are combined and recorded as a sub-scene area data file (i.e., BlocakData file). The number of the same type of vegetation (data slices) in the sub-scene area is numbered and indexed (from 0 to N), and the numbering order is from left to right and from bottom to top according to the order of the scene data block as the traversal unit. The data recorded in each scene data block includes: StartIndex: the starting index of the vegetation tree in the scene data block; Count: the number of vegetation in the scene data block; Bound: the overall bounding box of the vegetation in the scene data block.
[0038] The data of scene data blocks of different types of vegetation in the same sub-scene area are recorded in the sub-scene area data file, recorded as Block_X_Y_Z_W, where X and Y are the block index values of the sub-scene where the target scene data block is located in the target scene, and Z and W are the block index values of the target sub-scene area inside the target sub-scene.
[0039] Based on the data file data generated above, a quadtree structure is pre-built and stored as a quadtree structure file, where the quadtree node records the following data: the bounding box size of the target data file block to be loaded in the scene, and the path of the target data file to be loaded. In the quadtree file, the bounding boxes of all sub-scene area data files (i.e., BlocakData) can be expanded in space, and the expanded spatial node data only records the path of the target file to be loaded.
[0040] In summary, by dividing the target scene multiple times, data loading is made more refined and loaded on demand, reducing unnecessary data loading. By pre-building a quadtree structure, the necessary sub-scene area data files are dynamically loaded according to the camera position and viewing distance, reducing memory usage. The height map and density map corresponding to the target block are loaded through the sub-scene area data file association. Different types of vegetation density maps can be stored together, and each pixel uses 4 bits to record the information of two types of vegetation, further reducing the amount of data storage.
[0041] Step 104: Load the multiple scene data blocks, determine the target object information of the target objects in the multiple scene data blocks, and obtain a scene data set of the target scene.
[0042] The target object can be understood as vegetation data in the target scene, and the target object information includes but is not limited to coordinate position information, height information, scaling and rotation information, etc. of the target object in the target scene.
[0043] Specifically, a pre-built preset storage structure may be run and loaded, a load query may be performed, multiple scene data blocks may be loaded, and target object information of target objects in multiple scene data blocks may be restored to obtain a scene data set of a target scene.
[0044] In a specific implementation, the loading of the multiple scene data blocks includes: The target objects in the multiple scene data blocks are loaded into the memory according to the loading distances corresponding to the object types of the target objects in the multiple scene data blocks.
[0045] The object type of the target object may be understood as a vegetation type of vegetation, and the loading distance corresponding to the vegetation type may be preconfigured.
[0046] Specifically, the relevant data of the target objects in the multiple scene data blocks may be loaded into the memory according to the loading distances corresponding to the vegetation types of the vegetation contained in the multiple scene data blocks.
[0047] In one embodiment of this specification, it also includes: The terrain height map and the object density map corresponding to the object type of the target object in the multiple scene data blocks are loaded in an associated manner.
[0048] In actual applications, you can load a pre-built quadtree structure and perform a loading query. According to the configured loading distances of different vegetation types, load the sub-scene area data file and the corresponding vegetation slice type data in the sub-scene area data file into memory, and at the same time find the sub-scene where the sub-scene area data file is located, and load the terrain height map corresponding to the sub-scene where the sub-scene area is located: Terrain1K_X_Y_HeighMap.
[0049] If you decide to load the data slice of vegetation type A in the restored sub-scene area data file, you also need to load the vegetation data density map of this type of vegetation exported from the corresponding sub-scene: Terrain1K_X_Y_GrassA_DensityMap. Among them, you only need to load the height map once within a 1k*1K range, and you need to load the density map once for the same type of vegetation within a 1k*1K range (the sub-scene area data files of different blocks of the same vegetation type share this density map).
[0050] In a specific implementation, the step of determining target object information of the target object in the plurality of scene data blocks to obtain a scene data set of the target scene includes: According to the restoration algorithm, using multiple restoration threads, data restoration is performed on the multiple scene data blocks to obtain target object information of the target objects in the multiple scene data blocks; The target object information of the target objects in the multiple scene data blocks is merged to obtain a scene data set of the target scene.
[0051] The restoration algorithm may be, for example, a pseudo-random algorithm of Perlin noise in a local area that is parallelized to generate specific vegetation instance data according to the terrain height map and the vegetation density map at runtime. This algorithm is usually executed in a multi-threaded environment to improve processing efficiency. It can generate detailed data of each vegetation instance according to the terrain height map and the vegetation density map, including position, rotation, scaling, etc.
[0052] In practical applications, we can build a runtime restoration algorithm DoScateringJobs to perform multi-threaded task parallel computing. Each thread task is responsible for processing the restoration of the data of a scene data block. For details, see Figure 3 , Figure 3 A schematic diagram of data restoration in a scene rendering method provided according to an embodiment of this specification is shown, and the specific steps are as follows: Step 302: Data input, the input includes two main parts: TerrainHeightMap data (i.e. terrain height map): indicates the height information of the terrain, the size is 1K*1K SubScene corresponding area. DensityMap data (i.e. vegetation density map): indicates the density information of the vegetation, the size is also 1K*1K SubScene corresponding area. The input also includes: 256×256 subscene area data, the subscene area data includes vegetation type slice data A, including scene data block 0, scene data block 1 and multiple scene data blocks.
[0053] Step 304: Convert the input terrain height map and vegetation density map data into forms suitable for subsequent processing.
[0054] Step 306: Execute the DotScatteringJob algorithm to generate instance data of multiple scene data blocks based on the input terrain and vegetation data through a certain algorithm (possibly the Perlin noise pseudo-random algorithm or other pseudo-random correlation algorithms).
[0055] Step 308: When it is determined that restoration of all scene data blocks has not been completed, thread tasks are allocated (16 threads in parallel).
[0056] Specifically, in this step, in order to speed up the processing, multi-threading technology is used. Specifically, there are 16 threads working at the same time, and each thread is responsible for processing the instance data restoration of a scene data block.
[0057] Step 310: Execute data restoration of a single scene data block instance.
[0058] Specifically, each thread independently completes the instance data restoration work of the scene data block it is responsible for. In this process, each scene data block will be processed separately and the corresponding instance data will be generated.
[0059] Step 312: Merge the data to form a scene data set (ie, a MatrixDatas array).
[0060] Specifically, when the instance data of all scene data blocks are processed, they will be merged into a larger data structure: scene data set. This array contains the instance data of all scene data blocks in the target sub-scene area, which is convenient for subsequent rendering operations.
[0061] Step 314: When it is determined that all scene data blocks have been restored, the process ends, and the output result is a scene data set that is ready for rendering.
[0062] In actual applications, the scene data set output by the above step 314 is a matrix array, the number of which is the sum of the number of corresponding slice vegetation types in the sub-scene area, and the storage records include: the length is the sum of the number of corresponding slice types of vegetation in the sub-scene area, and the restoration data of a single vegetation (i.e., target object information), the restoration data includes the matrix of the single instance of vegetation, which is used for subsequent culling and rendering, the radius of the single instance of vegetation, which is used for subsequent culling, and the index of the scene data block where the single instance of vegetation is located, which is used for subsequent culling.
[0063] Furthermore, the step of merging the target object information of the target objects in the plurality of scene data blocks to obtain the scene data set of the target scene includes: Merging target object information of target objects in the multiple scene data blocks to obtain scene merged data; According to a random shuffling algorithm, the scene merged data is randomly shuffled to obtain a scene data set of the target scene.
[0064] Specifically, the target object information of the target objects contained in multiple scene data blocks can be merged to obtain scene merged data, and according to the random shuffling algorithm, the order of each vegetation type in each sub-scene area (i.e., Block) in the scene merged data is shuffled to obtain the scene data set of the target scene (i.e., the shuffled MatrixDatas array) for vegetation density control.
[0065] Furthermore, when the scene merged data is randomly shuffled, the shuffle may be performed based on the internal structure of the scene data block, thereby controlling the density of vegetation rendering in each scene data block.
[0066] In actual applications, refer to Figures 4 (a) and 4 (b), Figure 4 (a) shows a schematic diagram of a scene data set before scrambling in a scene rendering method provided according to an embodiment of the present specification, and Figure 4 (b) shows a schematic diagram of a scene data set after scrambling in a scene rendering method provided according to an embodiment of the present specification. As shown in Figure 4 (a), in the scene data set of vegetation type A in the sub-scene area, in scene data block 0, each vegetation is arranged in order, and as shown in Figure 4 (b), in the scene data set of vegetation type A in the same sub-scene area, in scene data block 0, the order of each vegetation is scrambled, and similarly, the order of vegetation in each scene data block is scrambled.
[0067] In summary, by randomly disrupting the scene merge data, the vegetation in the subsequent target scene can be evenly and randomly distributed.
[0068] Step 106: Determine and remove the scene data to be removed from the scene data set to obtain target scene data.
[0069] The scene data to be eliminated can be understood as scene data that needs to be eliminated.
[0070] Specifically, determining and removing the scene data to be removed from the scene data set to obtain the target scene data includes: Determining the scene data to be eliminated from the scene data set according to a preset determination rule; The scene data to be eliminated is eliminated to obtain target scene data.
[0071] The preset determination rule may be understood as being used to determine which scene data needs to be eliminated.
[0072] Specifically, according to a preset determination rule, scene data that needs to be eliminated can be determined from the scene data set, and these scene data can be eliminated to obtain target scene data.
[0073] In addition, in one embodiment of the present specification, the scene data to be eliminated can be directly constructed, and the scene data set can be merged and processed and a single elimination calculation can be performed.
[0074] In a specific implementation, determining the scene data to be eliminated from the scene data set according to a preset determination rule includes: According to the preset determination rule, scene data in the scene data set that does not fall within the range of the target visual frustum is determined as scene data to be eliminated; and / or According to the preset determination rule, the occluded scene data in the scene data set is determined as the scene data to be eliminated.
[0075] The preset determination rule may be understood as a rule for determining scene data to be eliminated.
[0076] Specifically, the preset determination rule may be to determine the scene data in the scene data set that is not within the target visual frustum as the scene data to be eliminated. And / or, the preset determination rule may also be to determine the occluded scene data in the scene data set as the scene data to be eliminated.
[0077] In practical applications, see Figure 5 , Figure 5 A schematic diagram of data culling in a scene rendering method provided according to an embodiment of the present specification is shown, comprising the following steps.
[0078] Step 502: Start.
[0079] Step 504: The client's CPU performs a quadtree query.
[0080] Step 506: Obtain a batch to be rendered, where the bounding box is usually equal to or smaller than a 256*256 range (Block).
[0081] Step 508: Execute a GPU scene data block culling operation.
[0082] Specifically, the system implements the GPU cluster culling function and builds culling logic on the GPU, such as a quadtree structure or other space partitioning methods, to effectively cull invisible objects.
[0083] Step 510: Obtain elimination results.
[0084] Specifically, the system obtains a culling result, which can be understood as which objects can be culled, that is, they do not need to participate in subsequent rendering calculations.
[0085] Step 512: CPU visual frustum large-scale culling.
[0086] Step 514: When the vegetation data is within the CPU viewing frustum (ie, the target viewing frustum range), perform conventional GPU occlusion culling based on the sub-scene area size.
[0087] Step 516: Read back the conventional GPU occlusion culling result of the previous frame based on the sub-scene area.
[0088] Step 518: Determine whether the vegetation data is occluded according to the GPU occlusion culling result.
[0089] Step 520: If the vegetation data is blocked or is not in the CPU visual frustum, the process ends.
[0090] Step 522: In the case of no occlusion, roughly calculate the LOD Range to be rendered according to the distance between the sub-scene area and the camera.
[0091] Among them, LOD Range is the Level of Detail. LOD allows the complexity of the model to be dynamically adjusted according to the observer's perspective and distance to balance performance and visual quality.
[0092] Step 524: Execute the indirect drawing Draw Call.
[0093] Specifically, the system executes indirect drawing commands (Indirect Draw Call), allowing the GPU to directly control the rendering pipeline, thereby improving rendering efficiency.
[0094] Specifically, when a GPU scene data block culling operation is performed in step 508, based on the 1K*1K sub-scene, through the above steps, scene data sets of different vegetation types in different sub-scene areas can be restored, and multiple different scene data sets of these different sub-scene areas and different vegetation types can be merged for data processing, and LOD and shadows are processed at the same time, and then computeshader is executed for culling once, and one scene data set corresponds to an indirect drawing DrawCall that may eventually participate in rendering. According to the preset loading distance configuration of different vegetation, multiple independent data can be obtained, for example, it can include: scene data set of vegetation type A in Block_0_0, scene data set of vegetation type B in Block_0_0, scene data set of vegetation type C in Block_0_0, scene data set of vegetation type A in Block_0_1... scene data set of vegetation type K in Block_X_Y.
[0095] The data of different sub-scene areas can be merged according to the scene data set and the corresponding scene data block records. The rendering data (i.e. computebuffer) required for culling and rendering is constructed, and the culling data is generated according to the LOD level and shadow distance of the model.
[0096] In practical applications, the rendering data includes first rendering data computebuffer1, second rendering data computebuffer2, third rendering data computebuffer3 and fourth rendering data computebuffer4, see Figures 6(a), 6(b), 6(c) and 6(d), Figure 6(a) shows a schematic diagram of the first rendering data in a scene rendering method provided according to an embodiment of the present specification, Figure 6(b) shows a schematic diagram of the second rendering data in a scene rendering method provided according to an embodiment of the present specification, Figure 6(c) shows a schematic diagram of the third rendering data in a scene rendering method provided according to an embodiment of the present specification, Figure 6(d) shows a schematic diagram of the fourth rendering data in a scene rendering method provided according to an embodiment of the present specification, the first rendering data includes a first parameter _argBuffer, which is used to record the parameters of the rendering batch, the second rendering data includes a second parameter _clusterDataBuffer, which is used to record the data of each scene data block, the third rendering data includes a third parameter _lodParambuffer, which is used to record the LOD parameters, and the fourth rendering data includes a fourth parameter _cullResultIndexBuffer, which is used to record the index of the culling result.
[0097] Specifically, after constructing the four rendering data, the culling execution step can be entered: based on the number of scene data blocks of the second parameter in the second rendering data, the calculation function DispatchCompute in the GPU is called, and based on the calculation function, a culling algorithm is executed for each scene data block separately.
[0098] The specific steps of the culling algorithm are as follows: Step 1: Get the scene data block for this culling calculation; Step 2: Perform visual cone culling based on the bounding box of the scene data block; Step 3: Perform hi-z depth occlusion culling based on the bounding box of the scene data block; Step 4: Traverse the starting index and quantity through the culled scene data block, that is, the scene data block participating in the final rendering, record the index in the fourth parameter of the culling result data, and increment the data for controlling the rendering quantity in the first parameter used for rendering parameter drawing. Step 5: According to the above steps, in one culling algorithm, perform culling calculations on all scene data blocks and obtain the final culling result data.
[0099] Step 108: Render the target scene data to obtain the target scene.
[0100] In practical applications, a rendering channel may be constructed, and specifically, rendering may be performed based on the first rendering data, the fourth rendering data, and the target scene data (ie, the matrixdatas array).
[0101] Referring to FIG. 7 (a) and FIG. 7 (b), FIG. 7 (a) and FIG. 7 (b) show schematic diagrams of a rendering process in a scene rendering method provided according to an embodiment of the present specification. In specific implementation, the LOD Range required for rendering of the batch can be roughly calculated based on the sub-scene area where the scene data set of the batch to be rendered is located and the distance from the camera, and the call of invalid indirect drawing call parameters (i.e., indirectdrawcall) is reduced. When a certain LOD level of the batch needs to be rendered is determined, the offset start offset of the LOD of the batch in the first parameter is located and recorded as argBufferOffset, as shown in FIG. 7 (a). Afterwards, the offset start offset of the instance index required to be rendered by the scene data set in the fourth parameter is located and recorded as resultBufferOffset, as shown in FIG. 7 (b). Through the above-mentioned first parameter, argBufferOffset parameter, fourth parameter, resultBufferOffset parameter and instance data scene data set, the parameters required for the indirect drawing call parameters and the bound rendering data can be constructed, and the final drawcall call is initiated to complete a rendering process.
[0102] In practical applications, the scene rendering method provided in the embodiments of this specification is applied to the rendering of vegetation in a game world as an example for explanation.
[0103] Specifically, in the data preparation stage, the game world can be divided into multiple sub-scenes, each of which is 1024 meters * 1024 meters in size. Each sub-scene contains a terrain height map and multiple vegetation density maps. The height map is used to restore the exact location of vegetation, and the density map records the number of vegetation in a specific area. Each sub-scene exports a terrain height map (Terrain1K_X_Y_HeighMap). For each type of vegetation, the corresponding density map (Terrain1K_X_Y_GrassA_DensityMap) is exported. The density map is represented by 8 bits and supports up to 255 plants per 2*2 meter area; different types of vegetation can be combined with density maps by compressed storage, and each pixel uses 4 bits to record the information of two types of vegetation. Each sub-scene is subdivided into 4 256m * 256m sub-scene areas as the basic unit for loading and restoring vegetation data. Each sub-scene area is further divided into multiple 4m * 4m scene data blocks as culling units, and the number of vegetation inside it changes dynamically according to the density map. Different types of vegetation in each sub-scene area are considered as separate data slices, which are eventually merged into a sub-scene area data file. For the same type of vegetation in a block, they are numbered and indexed according to the traversal order of the scene data block (from left to right, from bottom to top), and each scene data block records the starting index, quantity, and bounding box of the vegetation.
[0104] In order to manage sub-scene area data files more efficiently, a quadtree structure is pre-built, which can quickly determine which sub-scene area data files need to be loaded into memory. Each quadtree node records the bounding box size of the target data file block in the scene and its file path. The bounding box information of all sub-scene area data files is integrated and stored as a quadtree file, which is convenient for quickly finding and loading the required data.
[0105] In response to the user's running instructions for the game world, the runtime first loads the pre-built quadtree structure and performs a loading query. According to the configured loading distances of different vegetation types, the sub-scene area data file and the corresponding vegetation slice type data in the sub-scene area data file are loaded into the memory. Find the sub-scene where the sub-scene area data file is located, and load the height map (Terrain1K_X_Y_HeighMap) of the sub-scene where the sub-scene area is located in the 1K*1K sub-scene. If it is determined that the data slice of vegetation type A in the sub-scene area data file is to be loaded and restored, load the density map (Terrain1K_X_Y_GrassA_DensityMap) of this type of vegetation exported from the corresponding 1k*1K sub-scene. Only one height map needs to be loaded within a 1k*1K range, and one density map needs to be loaded for the same type of vegetation within a 1k*1K range (different sub-scene area data files share this density map). Construct the runtime restoration algorithm DoScateringJobs to perform multi-threaded task parallel calculations, and each thread task is responsible for processing the restoration of a scene data block. The result is a matrix array, the number of which is the sum of the number of vegetation types in the corresponding slices in the sub-scene area. A random shuffling algorithm is performed on the generated result scene data set for uniform random distribution in the subsequent density control algorithm. The order is interrupted separately within each scene data block to ensure a more natural distribution of vegetation within the scene data block.
[0106] In the culling and rendering phase, multiple different scene data sets (i.e., target scene data) of different sub-scene areas and different vegetation types are merged for data processing, and LOD and shadows are processed at the same time. Construct four rendering data: The first rendering data: _argBuffer, which is used to record the parameters of the rendering batch. The second rendering data: _clusterDataBuffer, which is used to record the data of each scene data block. The third rendering data: lodParambuffer, which is used to record the LOD parameters. The fourth rendering data: _cullResultIndexBuffer [total number of instances * number of rendering LODs + total number of instances * number of shadow LODs], which is used to record the index of the culling result. Based on the number of scene data blocks in _clusterDataBuffer, call GPUDispatchCompute, and execute the culling algorithm once for each scene data block. Calculate the LOD level of each scene data block, perform frustum culling and occlusion culling, and update _argBuffer and _cullResultIndexBuffer. According to the sub-scene area where the scene data set of the batch to be rendered is located and the distance from the camera, roughly calculate the LODRange that needs to be rendered for this batch. When determining a certain LOD level of the batch that needs to be rendered, locate the offset start offset of the batch LOD in _argBuffer and the offset start offset in _cullResultIndexBuffer. Through the above _argBuffer, _cullResultIndexBuffer and instance data matrixDatas, construct the parameters and bound buffers required for indirect draw, and initiate the final draw call to complete a rendering process and obtain the rendered target scene.
[0107] To summarize, in the above method, after responding to the running instruction for the target scene, multiple scene data blocks of the target scene are determined, and the multiple scene data blocks are loaded, and the target object information of the target objects contained in the multiple scene data blocks is determined, so as to obtain the scene data set of the target scene, determine and eliminate the scene data to be eliminated from the scene data set, obtain the target scene data, and render the target scene according to the target scene data. By splitting the target scene into multiple scene data, the size of a single file is reduced, the loading speed is increased, thereby reducing the loading time, and the scene data set is eliminated before rendering to reduce memory usage, thereby further ensuring the user's virtual experience.
[0108] Corresponding to the above method embodiment, this specification also provides a scene rendering device embodiment, Figure 8FIG. 1 shows a schematic diagram of the structure of a scene rendering device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises: The determination module 802 is configured to determine a plurality of scene data blocks of the target scene in response to an operation instruction for the target scene; The loading module 804 is configured to load the multiple scene data blocks, determine the target object information of the target object in the multiple scene data blocks, and obtain the scene data set of the target scene; A removal module 806 is configured to determine and remove scene data to be removed from the scene data set to obtain target scene data; The rendering module 808 is configured to render the target scene data to obtain the target scene.
[0109] In an optional embodiment, the loading module 804 is further configured to: According to the restoration algorithm, using multiple restoration threads, data restoration is performed on the multiple scene data blocks to obtain target object information of the target objects in the multiple scene data blocks; The target object information of the target objects in the multiple scene data blocks is merged to obtain a scene data set of the target scene.
[0110] In an optional embodiment, the loading module 804 is further configured to: Merging target object information of target objects in the multiple scene data blocks to obtain scene merged data; According to a random shuffling algorithm, the scene merged data is randomly shuffled to obtain a scene data set of the target scene.
[0111] In an optional embodiment, the loading module 804 is further configured to: The target objects in the multiple scene data blocks are loaded into the memory according to the loading distances corresponding to the object types of the target objects in the multiple scene data blocks.
[0112] In an optional embodiment, the loading module 804 is further configured to: The terrain height map and the object density map corresponding to the object type of the target object in the multiple scene data blocks are loaded in an associated manner.
[0113] In an optional embodiment, the elimination module 806 is further configured to: Determining the scene data to be eliminated from the scene data set according to a preset determination rule; The scene data to be eliminated is eliminated to obtain target scene data.
[0114] In an optional embodiment, the elimination module 806 is further configured to: According to the preset determination rule, scene data in the scene data set that does not fall within the range of the target visual frustum is determined as scene data to be eliminated; and / or According to the preset determination rule, the occluded scene data in the scene data set is determined as the scene data to be eliminated.
[0115] In an optional embodiment, the determining module 802 is further configured to: Dividing the target scene to obtain a plurality of scene data blocks of the target scene; The multiple scene data blocks are stored according to a preset storage structure.
[0116] In an optional embodiment, the determining module 802 is further configured to: Dividing the target scene to obtain a plurality of sub-scenes corresponding to the target scene, and determining a terrain height map and an object density map corresponding to each of the plurality of sub-scenes; Dividing each of the multiple sub-scenes to obtain multiple sub-scene areas corresponding to the target scene; Divide each of the multiple sub-scene areas to obtain multiple scene data blocks of the target scene; According to a preset storage structure, the multiple sub-scenes, the terrain height map and the object density map corresponding to each sub-scene, the multiple sub-scene areas and the multiple scene data blocks are stored.
[0117] To summarize, in the above-mentioned device, after responding to the running instruction for the target scene, multiple scene data blocks of the target scene are determined, and the multiple scene data blocks are loaded, and the target object information of the target objects contained in the multiple scene data blocks is determined, so as to obtain the scene data set of the target scene, determine and eliminate the scene data to be eliminated from the scene data set, obtain the target scene data, and render the target scene according to the target scene data. By splitting the target scene into multiple scene data, the size of a single file is reduced, the loading speed is increased, thereby reducing the loading time, and the scene data set is eliminated before rendering to reduce memory usage, thereby further ensuring the user's virtual experience.
[0118] The above is a schematic scheme of a scene rendering device of this embodiment. It should be noted that the technical scheme of the scene rendering device and the technical scheme of the scene rendering method described above are of the same concept, and the details not described in detail in the technical scheme of the scene rendering device can be referred to the description of the technical scheme of the scene rendering method described above.
[0119] Fig. 9 The structure block diagram of a computing device 900 provided according to an embodiment of the present specification is shown. The components of the computing device 900 include but are not limited to a memory 910 and a processor 920. The processor 920 is connected to the memory 910 via a bus 930, and a database 950 is used to store data.
[0120] The computing device 900 also includes an access device 940 that enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 940 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0121] In one embodiment of the present application, the above components of the computing device 900 and Fig. 9 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig. 9 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0122] The computing device 900 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 900 may also be a mobile or stationary server.
[0123] The processor 920 is used to execute the following computer program / instruction, which implements the steps of the above-mentioned scene rendering method when executed by the processor.
[0124] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the scene rendering method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the scene rendering method embodiment.
[0125] An embodiment of the present specification further provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned scene rendering method when executed by a processor.
[0126] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the scene rendering method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the scene rendering method embodiment.
[0127] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned scene rendering method when executed by a processor.
[0128] The above is a schematic solution of a computer program product of this embodiment. It should be noted that the technical solution of the computer program product and the technical solution of the above-mentioned scene rendering method belong to the same concept, and the details not described in detail in the technical solution of the computer program product can be referred to the description of the technical solution of the above-mentioned scene rendering method.
[0129] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0130] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0131] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0132] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0133] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A scene rendering method, characterized in that: include: In response to an operation instruction for a target scene, determining a plurality of scene data blocks of the target scene; Loading the multiple scene data blocks, and determining target object information of target objects in the multiple scene data blocks, to obtain a scene data set of the target scene; Determine and remove the scene data to be removed from the scene data set to obtain target scene data; The target scene data is rendered to obtain the target scene.
2. The method according to claim 1, characterized in that The step of determining target object information of the target object in the plurality of scene data blocks to obtain a scene data set of the target scene includes: According to the restoration algorithm, using multiple restoration threads, data restoration is performed on the multiple scene data blocks to obtain target object information of the target objects in the multiple scene data blocks; The target object information of the target objects in the multiple scene data blocks is merged to obtain a scene data set of the target scene.
3. The method according to claim 2, characterized in that The step of merging the target object information of the target objects in the plurality of scene data blocks to obtain the scene data set of the target scene includes: Merging target object information of target objects in the multiple scene data blocks to obtain scene merged data; According to a random shuffling algorithm, the scene merged data is randomly shuffled to obtain a scene data set of the target scene.
4. The method according to any one of claims 1 to 3, characterized in that: The loading of the plurality of scene data blocks comprises: The target objects in the multiple scene data blocks are loaded into the memory according to the loading distances corresponding to the object types of the target objects in the multiple scene data blocks.
5. The method according to claim 4, characterized in that Also includes: The terrain height map and the object density map corresponding to the object type of the target object in the multiple scene data blocks are loaded in an associated manner.
6. The method according to claim 1, characterized in that The step of determining and removing the scene data to be removed from the scene data set to obtain target scene data includes: Determining the scene data to be eliminated from the scene data set according to a preset determination rule; The scene data to be eliminated is eliminated to obtain target scene data.
7. The method according to claim 6, characterized in that The step of determining the scene data to be eliminated from the scene data set according to a preset determination rule includes: According to the preset determination rule, scene data in the scene data set that does not fall within the range of the target visual frustum is determined as scene data to be eliminated; and / or According to the preset determination rule, the occluded scene data in the scene data set is determined as the scene data to be eliminated.
8. The method according to claim 1, characterized in that Before determining a plurality of scene data blocks of the target scene in response to the running instruction for the target scene, the method further includes: Dividing the target scene to obtain a plurality of scene data blocks of the target scene; The multiple scene data blocks are stored according to a preset storage structure.
9. The method according to claim 8, characterized in that The step of dividing the target scene to obtain a plurality of scene data blocks of the target scene includes: Dividing the target scene to obtain a plurality of sub-scenes corresponding to the target scene, and determining a terrain height map and an object density map corresponding to each of the plurality of sub-scenes; Dividing each of the multiple sub-scenes to obtain multiple sub-scene areas corresponding to the target scene; Divide each of the multiple sub-scene areas to obtain multiple scene data blocks of the target scene; The storing of the plurality of scene data blocks according to the preset storage structure includes: According to a preset storage structure, the multiple sub-scenes, the terrain height map and the object density map corresponding to each sub-scene, the multiple sub-scene areas and the multiple scene data blocks are stored.
10. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 9 are implemented.
11. A computer-readable storage medium, characterized in that: It stores a computer program / instruction, which implements the steps of the method described in any one of claims 1 to 9 when executed by a processor.
12. A computer program product, characterized in that The method comprises a computer program / instruction which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.