Three-dimensional data rendering method and device and electronic equipment
By acquiring and parsing the target tile of the three-dimensional model, calculating texture coordinate transformation information, and mapping child texture data to the three-dimensional model, solving the loading performance problems caused by redundant storage of texture data in the existing technology, and achieving more efficient rendering and loading effects.
Patent Information
- Application Number
- CN202411386690.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-07
AI Technical Summary
The existing three-dimensional data rendering technology is poor in loading city-level manual modeling data due to redundant storage of texture data, and the rendering effect cannot be guaranteed.
By obtaining the target tiles of the three-dimensional model, parsing the texture file to obtain texture stitching information, determining the child texture data, and calculating the texture coordinate transformation information based on the texture stitching information and geometric vertices, mapping the child texture data to the three-dimensional model, reducing the tile Slice file size, improve rendering efficiency and loading efficiency.
Effectively reduces the size of tile files, improves rendering efficiency and data loading efficiency, avoids redundant texture storage, and improves the overall performance of three-dimensional data rendering.
Smart Images

Figure CN119273825A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a three-dimensional data rendering method, device and electronic device. Background Art
[0002] In real-life 3D data, city-level hand-modeled data usually contains a large amount of repetitive and large-size texture data, which has poor loading performance in 3D scenes. In order to solve the loading performance of this column of data, various tile generation processing technologies have been developed. The original data can be improved by constructing pyramid tiles, LOD (Level of Detail), etc., which can improve the loading performance of this type of data. However, tile generation will cause a large amount of redundant storage of textures between different tiles, resulting in poor loading performance of data in 3D scenes and the inability to guarantee the rendering effect of the data. Summary of the invention
[0003] In order to solve the above problems, this application provides the following technical solutions:
[0004] A three-dimensional data rendering method, the method comprising:
[0005] Acquire a target tile corresponding to a three-dimensional model to be rendered, wherein the three-dimensional model corresponds to a plurality of tiles, each tile representing at least part of the data of the three-dimensional model;
[0006] Parsing the target tile to obtain a target texture file, wherein the target texture file includes texture splicing information of sub-level texture data corresponding to the texture image;
[0007] Based on the texture splicing information, determining sub-level texture data corresponding to the target tile;
[0008] Based on the texture splicing information and the geometric vertices of the three-dimensional model, calculating the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data;
[0009] Based on the texture coordinate transformation information, the sub-level texture data is mapped to the three-dimensional model to obtain a rendering result of the three-dimensional model.
[0010] Optionally, the method further comprises:
[0011] Determine the texture image of each material corresponding to each tile of the to-be-rendered three-dimensional model;
[0012] Generate sub-level texture data of a texture image corresponding to each material, wherein the sub-level texture data represents a multi-level progressively distant texture image corresponding to the texture image, wherein the multi-level progressively distant texture image includes a plurality of texture images at different pixel levels having a corresponding relationship;
[0013] The sub-level texture data of each material corresponding to each tile is texture spliced to obtain a texture file corresponding to each tile, wherein the texture file stores texture description information and texture splicing information of each sub-level texture data.
[0014] Optionally, the texture description information includes storage path information of the sub-level texture data, and the method further includes:
[0015] Based on the application characteristics of the sub-level texture data, the types of each sub-level texture data are divided to obtain at least one target type;
[0016] A storage method corresponding to each target type is determined, and storage path information corresponding to each storage method is obtained.
[0017] Optionally, the method further comprises:
[0018] Based on the texture splicing information of each sub-level texture data, multiple materials of the sub-level texture data spliced on the same texture image are merged into the same material, and the material index data is stored in the texture file;
[0019] The data corresponding to the merged multiple materials are stored in the tiles corresponding to the materials.
[0020] Optionally, it also includes:
[0021] Traversing the geometric objects of the three-dimensional model in each of the tiles to obtain a merged material corresponding to the original material of the geometric object;
[0022] Merge the geometric objects with the same merged material to obtain the target geometric object;
[0023] Obtaining position information of a geometric vertex for sampling the sub-level texture data in the skeleton of the target geometric object, and recording the position information as geometric vertex offset information;
[0024] The geometric vertex offset information is stored in the texture splicing information of each sub-level texture data.
[0025] Optionally, the method further comprises:
[0026] Constructing a blank texture of a graphics processor corresponding to the size of the texture image;
[0027] Fill the blank texture with the child texture data.
[0028] Optionally, the calculating, based on the texture splicing information and the geometric vertices of the three-dimensional model, texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data includes:
[0029] Determining geometric vertex offset information according to the texture splicing information and geometric vertices of the three-dimensional model;
[0030] Determining texture coordinates of the sub-level texture data based on the size of the texture image and texture splicing information of the sub-level texture data;
[0031] Based on the texture coordinates of the sub-level texture data and the geometric vertex offset information, texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data is determined.
[0032] A three-dimensional data rendering device, the device comprising:
[0033] An acquisition unit, configured to acquire a target tile corresponding to a three-dimensional model to be rendered, wherein the three-dimensional model corresponds to a plurality of tiles, each tile representing at least part of the data of the three-dimensional model;
[0034] A parsing unit, used for parsing the target tile to obtain a target texture file, wherein the target texture file includes texture splicing information of sub-level texture data corresponding to the texture image;
[0035] A determining unit, configured to determine sub-level texture data corresponding to the target tile based on the texture splicing information;
[0036] A calculation unit, configured to calculate texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture splicing information and the geometric vertices of the three-dimensional model;
[0037] A mapping unit is used to map the sub-level texture data to the three-dimensional model based on the texture coordinate transformation information to obtain a rendering result of the three-dimensional model.
[0038] A storage medium stores a computer program, wherein when the computer program is executed by a processor, the three-dimensional data rendering method as described in any one of the above is implemented.
[0039] An electronic device, comprising:
[0040] Memory, used to store programs;
[0041] The processor is used to execute the program, and the program is specifically used to implement the three-dimensional data rendering method as described in any one of the above.
[0042] Compared with the prior art, the present application provides a three-dimensional data rendering method, device and electronic device, which obtains a target tile corresponding to a three-dimensional model to be rendered; parses the target tile to obtain a target texture file, the target texture file includes texture splicing information of sub-level texture data corresponding to a texture image; based on the texture splicing information, determines the sub-level texture data corresponding to the target tile; based on the texture splicing information and the geometric vertices of the three-dimensional model, calculates the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data; based on the texture coordinate transformation information, maps the sub-level texture data to the three-dimensional model to obtain the rendering result of the three-dimensional model. In the present application, the texture splicing information is stored in the tile, the texture image has a separate storage path, and the texture splicing information is converted into texture coordinate transformation information only when rendering, which reduces the size of the tile file and improves the rendering efficiency and data loading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0044] Figure 1 A schematic diagram of a flow chart of a three-dimensional data rendering method provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of a texture of a material provided in an embodiment of the present application;
[0046] Figure 3 A schematic diagram of the texture of another material provided in an embodiment of the present application;
[0047] Figure 4 A schematic diagram of the effect of a sub-level texture data provided in an embodiment of the present application;
[0048] Figure 5 A schematic diagram of another effect of sub-level texture data provided in an embodiment of the present application;
[0049] Figure 6 A schematic diagram of texture splicing and typesetting effect in a texture image provided by an embodiment of the present application;
[0050] Figure 7 A schematic diagram of a stream structure storage method provided in an embodiment of the present application;
[0051] Figure 8 A schematic diagram of geometric vertex offset information of sub-level texture data provided in an embodiment of the present application;
[0052] Fig. 9 A schematic diagram of sub-level texture data filling information provided in an embodiment of the present application;
[0053] Fig.10 A schematic diagram of the structure of a three-dimensional data rendering device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0055] The terms "first" and "second" in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0056] In the embodiment of the present application, a three-dimensional data rendering method is provided, which is applied to the scene of rendering a three-dimensional model. In order to ensure the rendering efficiency, the embodiment of the present application also includes the storage mode of the relevant tiles and the corresponding texture data to ensure that the shared texture is not redundantly stored, and the entire data rendering batch is minimized, thereby ensuring the rendering efficiency. At the same time, the texture image belonging to a certain tile is pre-stitched, the splicing information is stored in the tile, and the texture image is stored separately in the target path to improve the rendering efficiency and loading efficiency.
[0057] See also Figure 1 , is a three-dimensional data rendering method provided in an embodiment of the present application, and the method may include the following steps:
[0058] S101: Obtain a target tile corresponding to a 3D model to be rendered.
[0059] The three-dimensional model to be rendered is a three-dimensional model that needs to be rendered to improve the display effect in the current application scenario. In order to facilitate the transmission, loading and rendering of data, the data of the three-dimensional model is usually cut according to a quadtree or other hierarchical structure to generate tiles of different levels. These tiles can be stored on a server, and each tile contains detailed data of a part of the three-dimensional model, and the spatial ranges between spatially adjacent tiles can overlap. That is, the three-dimensional model can include multiple tiles, each tile representing at least part of the data of the three-dimensional model. Get the area to be rendered of the current three-dimensional model to be rendered, and then call the target tile corresponding to the area to be rendered to complete the data rendering of the area to be rendered based on the data corresponding to the target tile.
[0060] S102: Analyze the target tile to obtain a target texture file.
[0061] The target texture file includes texture splicing information of the sub-level texture data corresponding to the texture image. When rendering a three-dimensional model, the tiles are loaded and parsed according to the tile scheduling principle based on the area to be rendered. Each tile may contain texture information. When parsing the tiles, these texture splicing information will be obtained. The texture splicing information represents the information of splicing multiple sub-level texture data into the same texture image, wherein the sub-level texture data represents the multi-level progressively distant texture image (MipMap) corresponding to the texture image, and the multi-level progressively distant texture image includes multiple texture images of different pixel levels with corresponding relationships, that is, the multi-level progressively distant texture image is composed of a series of gradually smaller images, and each image is a downsampled version of the original image. The position of the sub-level texture data to be used in the texture image, as well as the storage path information of the corresponding image, etc. can be obtained through the texture splicing information.
[0062] S103: Determine sub-level texture data corresponding to the target tile based on the texture splicing information.
[0063] Based on the texture splicing information, the storage path of the corresponding sub-level texture data can be determined, and the corresponding sub-level texture data can be downloaded according to the storage path, and then the initialization rendering of the texture is completed. In one implementation of the embodiment of the present application, the texture initialization processing process includes: constructing a blank texture of the graphics processor corresponding to the size of the texture image; filling the sub-level texture data into the blank texture. Specifically, all the sub-level texture data (also referred to as "small texture") corresponding to the texture image (also referred to as "large texture") in the target tile are downloaded and parsed, and then the texture images are traversed one by one, and the blank textures of the graphics processor (i.e., GPU) corresponding to the size of the texture image are constructed respectively, and then the corresponding sub-level texture data are filled into the graphics card by uploading the GPU sub-texture. After all the sub-level texture data fills the graphics card, the initialization of the texture is completed.
[0064] S104: Calculate texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture splicing information and the geometric vertices of the three-dimensional model.
[0065] In the embodiment of the present application, the texture splicing information is not directly converted into texture coordinate transformation information and stored in the geometric skeleton of the three-dimensional model, but is filled in during rendering, thereby reducing the size of the tile file. Because if the texture splicing information is stored on the geometric vertices when the data is stored, the splicing information content will be stored in the file in multiples of the number of vertices. On the contrary, if the splicing information is only recorded on the texture when the data is stored, and is not placed on the vertices until it is loaded, the size of the tile file will be greatly reduced.
[0066] In one implementation of the present application, the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data is calculated based on the texture splicing information and the geometric vertices of the three-dimensional model, including: determining the geometric vertex offset information according to the texture splicing information and the geometric vertices of the three-dimensional model; determining the texture coordinates of the sub-level texture data based on the size of the texture image and the texture splicing information of the sub-level texture data; determining the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture coordinates of the sub-level texture data and the geometric vertex offset information. Specifically, the sub-level texture data splicing information of the texture image is assigned to the geometric skeleton in the form of vertex extension attributes according to the geometric vertex offset information, and the vertex extension attribute can be named as texture coordinate transformation information (also referred to as texture coordinate transformation attribute). If the size of the texture image is 4096*4096, the splicing information of texture 0 is (0,0,64,64), and the splicing information of texture 1 is (128,128,512,512). Then the texture coordinate transformation parameters corresponding to the stitching information should be (0 / 4096, 0 / 4096, 64 / 4096, 64 / 4096) for texture 0, that is, (0, 0, 0.015625, 0.015625), where the first two digits are the offset information of the texture coordinates and the last two digits are the scaling information of the texture coordinates. Similarly, the texture coordinate transformation parameters corresponding to texture 1 are (0.03125, 0.03125, 0.125, 0.125). Therefore, the geometric skeleton texture coordinate transformation attributes can be filled into the geometric object.
[0067] S105 . Map the sub-level texture data to the three-dimensional model based on the texture coordinate transformation information to obtain a rendering result of the three-dimensional model.
[0068] After obtaining the texture coordinate transformation information, the rendering of the sub-level texture data can be completed to obtain the rendering result of the three-dimensional model. Take an example. In the GPU fragment shader code, before sampling the texture, the texture coordinates in the sub-level texture data need to be transformed according to the above texture coordinate transformation information, such as defining the texture coordinate transformation information variable as uvTransform (type is float4, 4 float type values), the original texture coordinates are uv (type is float3, 3 float type values), and the transformed texture coordinates are uvAtlas (type is float3). Then the transformation formula 1-1 is as follows, where the function fract represents taking the decimal part of the texture coordinates:
[0069] uvAtlas.xy=fract(uv.xy)*uvTransform.zw+uvTransform.xy (1-1)
[0070] The present application provides a three-dimensional data rendering method, which obtains a target tile corresponding to a three-dimensional model to be rendered; parses the target tile to obtain a target texture file, the target texture file includes texture splicing information of sub-level texture data corresponding to a texture image; based on the texture splicing information, determines the sub-level texture data corresponding to the target tile; based on the texture splicing information and the geometric vertices of the three-dimensional model, calculates the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data; based on the texture coordinate transformation information, maps the sub-level texture data to the three-dimensional model to obtain the rendering result of the three-dimensional model. In the present application, the texture splicing information is stored in the tile, the texture image has a separate storage path, and the texture splicing information is converted into texture coordinate transformation information only when rendering, which reduces the size of the tile file and improves the rendering efficiency and data loading efficiency.
[0071] The following describes the relevant tile data, texture files, etc. used in the embodiments of the present application.
[0072] In one implementation of the embodiment of the present application, the method further includes:
[0073] Determine the texture image of each material corresponding to each tile of the three-dimensional model to be rendered;
[0074] Generate sub-level texture data of the texture image corresponding to each material, the sub-level texture data represents a multi-level gradually-distant texture image corresponding to the texture image, the multi-level gradually-distant texture image includes a plurality of texture images at different pixel levels having a corresponding relationship;
[0075] The sub-level texture data of each material corresponding to each tile is texture spliced to obtain a texture file corresponding to each tile. The texture file stores texture description information and texture splicing information of each sub-level texture data.
[0076] Take the pyramid tiles of the three-dimensional model as an example. In this process, a single tile will contain multiple three-dimensional models. There will be multiple materials between different three-dimensional models, and the textures corresponding to different materials are also different. Figure 2 and Figure 3 As shown in the figure, the two materials correspond to two different texture images. Among them, material description is one of the key factors to achieve realistic rendering of the object surface. Material is a collection of various visual attributes of the model surface. It can include ordinary materials, PBR materials, etc. Ordinary material objects can define visual attributes such as color, texture, transparency, reflectivity, refractive index, and luminosity; PBR (Physically-based rendering) is a rendering method that accurately simulates the real world by calculating the interaction between light and the reflection, refraction, etc. of the surface of the object. PBR materials can define visual attributes such as base color, metalness, roughness, normal, occlusion, and self-luminescence through corresponding texture objects.
[0077] When rendering a 3D model, in order to improve rendering efficiency and quality and reduce the jagged effect of image rendering, it is usually necessary to perform a multi-level mipmap operation on the texture image to construct sub-level texture data. That is, sub-texture data (MipMap) is constructed for each texture image corresponding to the material. The sub-level texture data represents the multi-level mipmap corresponding to the texture image, and the multi-level mipmap includes multiple texture images with different pixel levels that have corresponding relationships. Figure 4 and Figure 5 , for the above Figure 2 and Figure 3 MipMap is constructed for these two texture images, and the texture MipMap pyramid data is arranged on the right side of the original texture to obtain the sub-level texture data of the texture image.
[0078] After obtaining the above sub-level texture data (i.e. texture images with MipMap), the texture pre-stitching operation is performed inside each tile. The maximum size of the stitched texture can be predetermined, such as 4096*4096. If the layout size of the stitched texture exceeds the specified size, the excess texture will be re-layouted on the new large texture (i.e. texture image). If it is less than the specified size, the actual layout size will be used as the main factor. Figure 6 The layout effect of multiple textures corresponding to the texture image.
[0079] In order to facilitate the storage of information, after texture splicing processing is performed on the sub-level texture data of each material, a texture file is generated, and the texture file stores texture description information and texture splicing information of each sub-level texture data.
[0080] See Table 1 for the meaning of each attribute of the texture object, that is, the information of the relevant texture object in Table 1 can be recorded in the texture description information.
[0081] Table 1
[0082]
[0083] Table 2 Meaning of each enumeration value of texture compression type
[0084]
[0085]
[0086] Table 3 Meaning of each pixel format enumeration value
[0087]
[0088] Table 4 Structure of texture stitching information object
[0089]
[0090] Table 5VertexOffsetInfo object structure
[0091] Parameter name Data Types describe geometryName string The name of the geometry skeleton in the tile vertexOffset int32 The starting position of the vertex in the geometry vertexCount int32 Number of vertices
[0092] It should be noted that, in the relevant data in Tables 1 to 5 above, for the convenience of description, the sub-level texture data is expressed as a small texture, and the texture image composed of the sub-level texture data is expressed as a large texture.
[0093] Among them, the process of texture splicing of sub-level texture data is a pre-splicing operation, and the spliced texture data is not stored in the result data, that is, the specific sub-level texture data is not stored in the texture file, but the texture description information and the texture splicing information of each sub-level texture data are stored in the texture file. The description information is shown in Table 1, and the texture image is spliced by multiple small texture images corresponding to the sub-level texture data. The content of the texture splicing information that needs to be stored is shown in Table 4.
[0094] Each texture image (also called a large texture) does not store the specific content of the spliced image. It is necessary to store the splicing information (SubTextureInfo) of all the sub-level texture data (i.e., small textures) in the description structure, and record the storage path information corresponding to each small texture. The geometric vertex offset information in Table 5 is described in the subsequent embodiments.
[0095] Furthermore, the texture description information includes storage path information of the sub-level texture data, and the method also includes: based on application characteristics of the sub-level texture data, dividing the types of each sub-level texture data to obtain at least one target type; determining a storage method corresponding to each target type, and obtaining storage path information corresponding to each storage method.
[0096] Each sub-level texture data can be divided into three types according to its application characteristics. That is, the target type includes three categories. The first category is reused textures, that is, textures shared by multiple models; the second category is non-reusable textures, that is, textures used by only one model; the third category is textures used by instantiated models. Different types have different storage methods and storage path information. For example, for reused textures, the entire data is stored at a global level, and the file naming method is: "Tex_" + block texture index + ".texblock", such as: Tex_0.texblock. The specific stream structure storage method is as follows: Figure 7 As shown. The number of textures N indicates how many small textures are stored in the file, Offset and Count indicate the byte offset position and total byte size of each small texture stored in the data stream, and the texture's ZipBuffer indicates the binary stream after each small texture data is Zip compressed. Before Zip compression, certain texture compression can be performed. For details, refer to the compression types shown in Table 2.
[0097] For non-repeated textures, each tile will use its own non-repeating small textures according to Figure 7 The stream structure is stored in the result data, and the file name is: tile name + ".texblock", such as: Tile_0.texblock. For textures used in instances, since batches cannot be merged between different instanced models, textures cannot be spliced. Small textures are directly grouped according to Figure 7 It can be stored in the form of a stream structure, and the naming method is: texture HashCode name + ".texblock", such as: -1310421451.texblock
[0098] During the tile storage process, the implementation of the present application also includes: based on the texture stitching information of the each sub-level texture data, merging multiple materials of the sub-level texture data stitched on the same texture image into the same material, and storing the material index data in the texture file; storing the data corresponding to the merged multiple materials in the tile corresponding to the material.
[0099] Furthermore, the geometric objects of the three-dimensional model are traversed in each of the tiles to obtain the merged material corresponding to the original material of the geometric objects; the geometric objects having the same merged material are merged to obtain the target geometric object; the position information of the geometric vertices of the sampled sub-level texture data in the skeleton of the target geometric object is obtained, and the position information is recorded as geometric vertex offset information; the geometric vertex offset information is stored in the texture stitching information of each sub-level texture data.
[0100] After obtaining the storage information after texture splicing, multiple materials belonging to the image (also called small texture) corresponding to the subset texture data spliced on the same texture image (also called large texture) can be merged into one material. The merged material only needs to be indexed to the texture image after the splicing is stored, and then the merged multiple materials are stored in their respective tiles. In each tile, the three-dimensional model geometric objects are traversed to find the merged material corresponding to the original material used, and multiple geometric objects mapped to the same merged material are merged into one geometric object, and the vertex and index information are appended together. At the same time, the geometric vertex offset information is recorded in the texture splicing information, that is, the position information of the geometric vertices that need to sample the sub-level texture data (small texture) in the merged geometric skeleton is recorded. Because there are multiple geometric objects sampling the same small texture, there should be multiple geometric vertex offset information recorded here. For example Figure 8 As shown, in the merged geometric skeleton (geometryName is: geo1), there are two geometric vertex parts of the sampled small texture 0, located at 0~m-1 and m+n~m+n+k-1 respectively. Therefore, the geometric vertex offset information of the small texture can be recorded as: [(geo1,0,m), (geo1,m+n,k)].
[0101] Specifically, in the subsequent loading and rendering process of texture data in the 3D scene, the tile can be loaded and parsed according to the pyramid tile scheduling principle, and the sub-level texture data (i.e., small texture data) corresponding to the texture image (large texture) can be requested to be downloaded based on the parsed texture splicing information. If the small texture data comes from a file starting with "Tex_", it means that it is a shared texture, and a memory cache pool with a specified threshold size (such as 100MB) is constructed, and the part of the texture resides in the cache pool so that other tiles can share it multiple times, avoiding repeated parsing requests.
[0102] Wait until all the small textures corresponding to the large textures in the tile are downloaded and parsed, traverse the large textures one by one, build GPU blank textures corresponding to the large texture size, and then fill the corresponding small textures into the graphics card by uploading GPU sub-textures. After all the small textures fill the graphics card, the texture initialization work is completed. The small texture splicing information of the large texture is based on the geometric vertex offset information ( Figure 8As shown in Figure 1, it is assigned to the geometric skeleton in the form of vertex extension attributes, and the vertex extension attributes are named texture coordinate transformation attributes. Fig. 9 As shown, if the size of the large texture is 4096*4096, the stitching information of texture 0 is (0,0,64,64), and the stitching information of texture 1 is (128,128,512,512). Then the texture coordinate transformation parameters corresponding to the stitching information should be (0 / 4096,0 / 4096,64 / 4096,64 / 4096) corresponding to texture 0, that is, (0,0,0.015625,0.015625), where the first two digits are the offset information of the texture coordinates, and the last two digits are the scaling information of the texture coordinates. Similarly, the texture coordinate transformation parameters corresponding to texture 1 are (0.03125,0.03125,0.125,0.125). Therefore, Figure 8 The geometry skeleton texture coordinate transformation attributes should be as shown Fig. 9 Fill the geometric object as shown.
[0103] In the GPU fragment shader code, before sampling the texture, the texture coordinates need to be transformed according to the above texture coordinate transformation attributes. Define the texture coordinate transformation attribute variable as uvTransform (type is float4, 4 float type values), the original texture coordinates are uv (type is float3, 3 float type values), and the transformed texture coordinates are uvAtlas (type is float3). Then the transformation formula 1-1 is as follows, where the function fract represents taking the decimal part of the texture coordinates:
[0104] uvAtlas.xy=fract(uv.xy)*uvTransform.zw+uvTransform.xy (1-1)
[0105] In the embodiment of the present application, not only can the shared texture be stored without redundant storage, but the entire data rendering batch can also be minimized, thereby ensuring the rendering process experience; the texture splicing information is not directly converted into texture coordinate transformation attributes and stored in the geometric skeleton, but is filled during rendering, which greatly reduces the size of the tile file; when loading, the texture cache pool stores the shared sub-level texture data. The amount of shared texture data for massive manual modeling data is large, so the repeated downloading and parsing of a large amount of sub-level texture data between tiles is avoided, which improves the efficiency of data update and display;
[0106] In the embodiment of the present application, a three-dimensional data rendering device is also provided. Fig.10 , the device comprises:
[0107] An acquisition unit 201 is used to acquire a target tile corresponding to a three-dimensional model to be rendered, wherein the three-dimensional model corresponds to a plurality of tiles, and each tile represents at least part of the data of the three-dimensional model;
[0108] A parsing unit 202, configured to parse the target tile to obtain a target texture file, wherein the target texture file includes texture splicing information of sub-level texture data corresponding to the texture image;
[0109] A determination unit 203, configured to determine sub-level texture data corresponding to the target tile based on the texture splicing information;
[0110] A calculation unit 204, configured to calculate texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture splicing information and the geometric vertices of the three-dimensional model;
[0111] The mapping unit 205 is used to map the sub-level texture data to the three-dimensional model based on the texture coordinate transformation information to obtain a rendering result of the three-dimensional model.
[0112] Optionally, the device further comprises:
[0113] An image determination unit, used to determine the texture image of each material corresponding to each tile of the three-dimensional model to be rendered;
[0114] A generating unit, configured to generate sub-level texture data of a texture image corresponding to each material, wherein the sub-level texture data represents a multi-level gradually receding texture image corresponding to the texture image, wherein the multi-level gradually receding texture image includes a plurality of texture images at different pixel levels having a corresponding relationship;
[0115] The processing unit is used to perform texture splicing processing on the sub-level texture data of each material corresponding to each tile to obtain a texture file corresponding to each tile, wherein the texture file stores texture description information and texture splicing information of each sub-level texture data.
[0116] Optionally, the texture description information includes storage path information of the sub-level texture data, and the device further includes:
[0117] a dividing unit, configured to divide the types of each sub-level texture data based on application characteristics of the sub-level texture data to obtain at least one target type;
[0118] The path acquisition unit is used to determine the storage mode corresponding to each target type and obtain storage path information corresponding to each storage mode.
[0119] Optionally, the device further comprises:
[0120] A merging unit, configured to merge a plurality of materials of the sub-level texture data spliced on the same texture image into a same material based on texture splicing information of each sub-level texture data, and store the material index data in the texture file;
[0121] The storage unit is used to store the data corresponding to the merged multiple materials into the tiles corresponding to the materials.
[0122] Optionally, it also includes:
[0123] A material acquisition unit, configured to traverse the geometric objects of the three-dimensional model in each tile to obtain a merged material corresponding to an original material of the geometric object;
[0124] An object merging unit, used for merging geometric objects with the same merged material to obtain a target geometric object;
[0125] A position acquisition unit, used for obtaining position information of a geometric vertex for sampling the sub-level texture data in the skeleton of the target geometric object, and recording the position information as geometric vertex offset information;
[0126] The information storage unit is used to store the geometric vertex offset information in the texture splicing information of each sub-level texture data.
[0127] Optionally, the device further comprises:
[0128] A construction unit, used for constructing a blank texture of a graphics processor corresponding to the size of the texture image;
[0129] A filling unit is used to fill the blank texture with the sub-level texture data.
[0130] Optionally, the computing unit includes:
[0131] A first determining subunit, configured to determine geometric vertex offset information according to the texture splicing information and geometric vertices of the three-dimensional model;
[0132] A second determining subunit, configured to determine texture coordinates of the sub-level texture data based on a size of the texture image and texture splicing information of the sub-level texture data;
[0133] The third determining subunit is used to determine the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture coordinates of the sub-level texture data and the geometric vertex offset information.
[0134] In an embodiment of the present application, a storage medium is further provided, which stores a computer program. When the computer program is executed by a processor, the three-dimensional data rendering method as described in any one of the above is implemented.
[0135] In an embodiment of the present application, an electronic device is also provided, the electronic device comprising:
[0136] Memory, used to store programs;
[0137] The processor is used to execute the program, and the program is specifically used to implement the three-dimensional data rendering method as described in any one of the above.
[0138] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0139] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A three-dimensional data rendering method, characterized in that: The method comprises: Acquire a target tile corresponding to a three-dimensional model to be rendered, wherein the three-dimensional model corresponds to a plurality of tiles, each tile representing at least part of the data of the three-dimensional model; Parsing the target tile to obtain a target texture file, wherein the target texture file includes texture splicing information of sub-level texture data corresponding to the texture image; Based on the texture splicing information, determining sub-level texture data corresponding to the target tile; Based on the texture splicing information and the geometric vertices of the three-dimensional model, calculating the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data; Based on the texture coordinate transformation information, the sub-level texture data is mapped to the three-dimensional model to obtain a rendering result of the three-dimensional model.
2. The method according to claim 1, characterized in that The method further comprises: Determine the texture image of each material corresponding to each tile of the to-be-rendered three-dimensional model; Generate sub-level texture data of a texture image corresponding to each material, wherein the sub-level texture data represents a multi-level progressively distant texture image corresponding to the texture image, wherein the multi-level progressively distant texture image includes a plurality of texture images at different pixel levels having a corresponding relationship; The sub-level texture data of each material corresponding to each tile is texture spliced to obtain a texture file corresponding to each tile, wherein the texture file stores texture description information and texture splicing information of each sub-level texture data.
3. The method according to claim 2, characterized in that The texture description information includes storage path information of the sub-level texture data, and the method further includes: Based on the application characteristics of the sub-level texture data, the types of each sub-level texture data are divided to obtain at least one target type; A storage method corresponding to each target type is determined, and storage path information corresponding to each storage method is obtained.
4. The method according to claim 2, characterized in that: The method further comprises: Based on the texture splicing information of each sub-level texture data, multiple materials of the sub-level texture data spliced on the same texture image are merged into the same material, and the material index data is stored in the texture file; The data corresponding to the merged multiple materials are stored in the tiles corresponding to the materials.
5. The method according to claim 4, characterized in that Also includes: Traversing the geometric objects of the three-dimensional model in each of the tiles to obtain a merged material corresponding to the original material of the geometric object; Merge the geometric objects with the same merged material to obtain the target geometric object; Obtaining position information of a geometric vertex for sampling the sub-level texture data in the skeleton of the target geometric object, and recording the position information as geometric vertex offset information; The geometric vertex offset information is stored in the texture splicing information of each sub-level texture data.
6. The method according to claim 1, characterized in that The method further comprises: Constructing a blank texture of a graphics processor corresponding to the size of the texture image; Fill the blank texture with the child texture data.
7. The method according to claim 6, characterized in that The step of calculating the texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture splicing information and the geometric vertices of the three-dimensional model includes: Determining geometric vertex offset information according to the texture splicing information and geometric vertices of the three-dimensional model; Determining texture coordinates of the sub-level texture data based on the size of the texture image and texture splicing information of the sub-level texture data; Based on the texture coordinates of the sub-level texture data and the geometric vertex offset information, texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data is determined.
8. A three-dimensional data rendering device, characterized in that: The device comprises: An acquisition unit, configured to acquire a target tile corresponding to a three-dimensional model to be rendered, wherein the three-dimensional model corresponds to a plurality of tiles, each tile representing at least part of the data of the three-dimensional model; A parsing unit, used for parsing the target tile to obtain a target texture file, wherein the target texture file includes texture splicing information of sub-level texture data corresponding to the texture image; A determining unit, configured to determine sub-level texture data corresponding to the target tile based on the texture splicing information; A calculation unit, configured to calculate texture coordinate transformation information corresponding to each geometric vertex in the sub-level texture data based on the texture splicing information and the geometric vertices of the three-dimensional model; A mapping unit is used to map the sub-level texture data to the three-dimensional model based on the texture coordinate transformation information to obtain a rendering result of the three-dimensional model.
9. A storage medium, characterized in that: The storage contains a computer program, and when the computer program is executed by a processor, the three-dimensional data rendering method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: Memory, used to store programs; A processor is used to execute the program, wherein the program is specifically used to implement the three-dimensional data rendering method as described in any one of claims 1 to 7.