Three-dimensional model processing method and electronic device

CN122906305APending Publication Date: 2026-10-13NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611113972.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-24
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0003]然而,上述基于离散采样的体素化方案在薄壁及尖角区域易出现体素缺失或冗余,导致输出几何精度不足

Benefits of technology

[0009]本公开其中一实施例提供一种三维模型处理方法,包括:获取目标三维模型对应的网格数据,并基于网格数据构建空间索引结构;确定多个栅格节点;对于每个栅格节点,基于空间索引结构查询栅格节点至网格数据对应的原始曲面的最近距离;根据最近距离与预设距离阈值的比较结果,从多个栅格节点中确定有效体素。这样,基于空间索引结构的距离查询判定有效体素,有助于降低薄壁及尖角区域因离散采样导致的误判概率,提升几何捕捉的稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122906305A_ABST
    Figure CN122906305A_ABST
Patent Text Reader

Abstract

The present disclosure provides a three-dimensional model processing method and an electronic device, comprising: obtaining mesh data corresponding to a target three-dimensional model, and constructing a spatial index structure based on the mesh data; determining a plurality of grid nodes; for each grid node, querying the nearest distance from the grid node to the original surface corresponding to the mesh data based on the spatial index structure; determining effective voxels from the plurality of grid nodes according to the comparison result of the nearest distance and a preset distance threshold; and rendering the target model based on the effective voxels. In this way, the distance query based on the spatial index structure determines the effective voxels, which helps to reduce the misjudgment probability caused by discrete sampling in the thin-walled and sharp corner areas, and improves the stability of geometric capture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more particularly to methods for processing three-dimensional models. Background Technology

[0002] In the field of digital content creation, there is a growing demand for technologies that convert smooth 3D meshes into voxel representations. Related technologies typically employ a combination of regular grid partitioning and ray intersection detection: a 3D grid is created in space with a fixed step size, and ray projection or bounding box intersection tests are used to determine whether grid cells intersect with the original surface, thereby determining whether voxels should be generated.

[0003] However, the aforementioned voxelization scheme based on discrete sampling is prone to voxel loss or redundancy in thin-walled and sharp-corner regions, resulting in insufficient output geometric accuracy. Summary of the Invention

[0004] This disclosure provides a three-dimensional model processing method, apparatus, electronic device, and computer program product to at least partially solve the aforementioned problems existing in the related art.

[0005] According to one aspect of this disclosure, a three-dimensional model processing method is provided, the method comprising: acquiring mesh data corresponding to a target three-dimensional model and constructing a spatial index structure based on the mesh data; determining multiple raster nodes; for each raster node, querying the nearest distance from the raster node to the original surface corresponding to the mesh data based on the spatial index structure; determining effective voxels from the multiple raster nodes based on the comparison result of the nearest distance and a preset distance threshold; and rendering the target three-dimensional model based on the effective voxels.

[0006] According to one aspect of this disclosure, an information processing apparatus is provided, comprising: a first processing module configured to acquire mesh data corresponding to a target three-dimensional model and construct a spatial index structure based on the mesh data; a first determining module configured to determine a plurality of raster nodes; a second processing module configured to, for each raster node, query the nearest distance from the raster node to the original surface corresponding to the mesh data based on the spatial index structure; a second determining module configured to determine effective voxels from the plurality of raster nodes based on a comparison result of the nearest distance and a preset distance threshold; and a rendering module configured to render the target three-dimensional model based on the effective voxels.

[0007] According to one aspect of this disclosure, an electronic device is provided, including a processor and a memory, wherein the processor executes instructions in the memory to implement any of the above methods.

[0008] According to one aspect of this disclosure, a computer program product is provided, which stores a computer program that, when executed by a processor, implements any of the above methods.

[0009] One embodiment of this disclosure provides a three-dimensional model processing method, including: acquiring mesh data corresponding to a target three-dimensional model and constructing a spatial index structure based on the mesh data; determining multiple grid nodes; for each grid node, querying the nearest distance from the grid node to the original surface corresponding to the mesh data based on the spatial index structure; and determining valid voxels from the multiple grid nodes based on a comparison result between the nearest distance and a preset distance threshold. In this way, determining valid voxels based on distance queries using the spatial index structure helps reduce the probability of misjudgment caused by discrete sampling in thin-walled and sharp-cornered regions, thus improving the stability of geometric capture. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This diagram illustrates a cloud interaction system architecture according to one exemplary embodiment of the present disclosure; Figure 2 A flowchart illustrating a method in one exemplary embodiment of this disclosure is shown; Figure 3 A schematic diagram of a structural device is shown in one exemplary embodiment of this disclosure; Figure 4 A schematic diagram of the structure of an electronic device is shown in one exemplary embodiment of the present disclosure. Detailed Implementation

[0012] The technical solutions of this disclosure will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of this disclosure, not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0013] It should be noted that the information (including but not limited to user input information, such as information entered by the user into input boxes), data (including but not limited to data used for analysis, stored data, and displayed data, such as context code, all code of the current project, the service pressure corresponding to operations performed on all code of the current project, and the code development status of the current project), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with relevant laws, regulations, and standards. For example, the context code, operations performed on all code of the current project, the corresponding service pressure, and the code development status involved in this application were all obtained with full authorization.

[0014] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of the invention described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0015] It should also be noted that the various trigger events disclosed in this manual can be preset, and different trigger events can trigger the execution of different functions.

[0016] A 3D model processing method in one embodiment of this disclosure can run on a terminal device or a server. The terminal device can be a local terminal device. When the 3D model processing method runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and client devices. Figure 1 The figure shows a cloud interaction system architecture diagram provided in this disclosure. As shown, the cloud interaction system may include: a client device 10 and a server 20, wherein the client device 10 can be connected to the server 20 via a network 30.

[0017] In an optional implementation, cloud gaming can run within the cloud interaction system. Cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the 3D model processing method are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the terminal device for information processing is the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game interface and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game interface.

[0018] In an optional implementation, the terminal device can be a local terminal device that stores the game program and is used to present the game interface. The local terminal device is used to interact with the player through the game interface; that is, it typically downloads, installs, and runs the game program via an electronic device. The local terminal device can provide the game interface to the player in various ways, such as rendering it on a terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen and a processor. The display screen is used to present the game interface, which includes game scene visuals, and the processor is used to run the game, generate the game interface, and control the display of the game interface on the display screen.

[0019] According to one embodiment of the present disclosure, a three-dimensional model processing method is used, such as... Figure 2 As shown, the method may include: Step S210: Obtain the mesh data corresponding to the target 3D model, and construct a spatial index structure based on the mesh data; Step S230: Within the bounding box area corresponding to the grid data, determine multiple grid nodes; Step S250: For each grid node, query the nearest distance from the grid node to the original surface corresponding to the grid data based on the spatial index structure; Step S270: Based on the comparison result between the nearest distance and the preset distance threshold, determine the effective voxels from multiple grid nodes.

[0020] According to one embodiment of this disclosure, the determination of valid voxels based on distance query of spatial index structure helps to reduce the probability of misjudgment caused by discrete sampling in thin-walled and sharp-cornered areas, and improves the stability of geometric capture.

[0021] Step S290: Render the target 3D model based on effective voxels.

[0022] The embodiments of this disclosure will now be further described.

[0023] In step S210, the mesh data corresponding to the target 3D model is obtained, and a spatial index structure is constructed based on the mesh data. This pre-construction of the spatial index structure effectively supports efficient nearest-neighbor queries on grid nodes, significantly improving the computational efficiency and stability of surface fitting. In one implementation, the system starts a 3D engine instance in a user-friendly background mode and loads a specified project file. It extracts the triangulated mesh data of the target 3D model in the world coordinate system from this file, and then performs a hierarchical bounding volume tree construction operation on the mesh data, organizing it into a hierarchical spatial index structure. The leaf nodes of the hierarchical bounding volume tree store the geometric information of the original triangular faces, while the internal nodes record the overall bounding range of the subtree. This allows for quick elimination of irrelevant branches based on the positional relationship between the bounding volume and the query point when performing nearest-neighbor retrieval on any query point in space, avoiding the need to traverse all triangular faces one by one.

[0024] Optionally, the spatial index structure is used to hierarchically organize the mesh data of the target 3D model according to spatial location relationships, so as to support fast nearest distance retrieval and branch removal for query points.

[0025] Optionally, the aforementioned spatial index structure can be a hierarchical bounding volume tree, or other tree structures used to accelerate spatial queries; this disclosure is not limited to this. In one specific implementation, the hierarchical bounding volume tree is constructed by progressively dividing the spatial distribution of each triangular facet in the grid data. Its internal nodes record the bounding box range of the child node set, while the leaf nodes are directly associated with one or more adjacent triangular faces in the original surface. When a subsequent processing stage requires a nearest-distance query for a grid node, the system traverses the tree from top to bottom starting from the root node. By comparing the spatial positional relationship between the grid node and the bounding boxes of each node, sub-branches that are far from the bounding range of the current node are quickly eliminated. In this way, the system does not need to calculate the precise distance between the query point and all triangular faces one by one, and can complete the search within the nearest-distance candidate range, significantly reducing the computational complexity in large-scale grid scenarios. It should be noted that the construction strategy of the hierarchical bounding volume tree can adopt either a top-down spatial bisection method or an optimization partitioning method based on surface area heuristics. Its specific implementation can be flexibly selected according to the grid topology characteristics and real-time requirements.

[0026] Optionally, besides the hierarchical bounding box tree, the aforementioned spatial indexing structure can also employ a regularized spatial raster acceleration structure or an octree-based spatial partitioning structure. The regularized spatial raster structure, by uniformly dividing the bounding box space into several equal-sized cells and recording the triangular facet indices of each intersecting cell, is suitable for grid data with relatively uniform distribution and a moderate number of faces. The octree structure, on the other hand, adaptively octet-divides the space, forming finer-grained nodes in geometrically dense regions and maintaining a coarser hierarchy in sparse regions, thus balancing memory usage and query efficiency. When using an octree structure, the nearest-neighbor query process for raster nodes similarly follows the branch culling principle, prioritizing traversal based on the distance between child nodes and the query point. It should be understood that different spatial indexing structures have different focuses in terms of construction time, memory usage, and query speedup. In actual implementation, a comprehensive selection can be made based on the number of faces in the target 3D model, the uniformity of the triangular facet distribution, and the concurrent query pressure in the subsequent voxelization stage, to achieve a balance between preprocessing overhead and runtime efficiency.

[0027] Optionally, considering the high surface complexity of thin-walled structures and acute-angle features in grid data, a patch clustering mechanism can be introduced during the construction of the spatial index structure to improve query stability. Specifically, before constructing the hierarchical bounding volume tree, the system can first perform clustering processing on the original grid, grouping adjacent triangular faces that are spatially close and whose normal differences are less than a preset angle threshold into the same geometric cluster. Then, bounding volumes are constructed at the cluster level and aggregated upwards to form parent nodes. The advantage of this is that when a grid node happens to be located on both sides of a thin wall or in an acute-angle bifurcation region, the cluster-based bounding volume can retain all relevant patches of these sensitive areas in the same local subtree, avoiding distance estimation errors caused by patches being scattered to different distant branches during the query process. Furthermore, in addition to containing the spatial extent, the metadata of each bounding volume node can also record the maximum curvature or local feature size of the triangular faces within the subtree, so that the search strategy can be dynamically adjusted according to the geometric environment of the grid node during the query, ensuring that stable and reliable nearest-distance results can still be obtained in complex surface transition regions.

[0028] In an optional implementation, the step of constructing a spatial index structure based on grid data includes: constructing a hierarchical bounding volume tree based on the grid data as the spatial index structure; the method further includes: calculating and determining a preset distance threshold based on the product of the voxel side length and a preset coefficient, wherein the preset coefficient is used to characterize the distance tolerance between the effective voxel and the original surface. Thus, by using a hierarchical bounding volume tree to accelerate spatial queries and adaptively determining the distance threshold based on the product of the voxel side length and the preset coefficient, not only is the fitting stability for thin-walled and acute-angled structures significantly improved, but the probability of false positives and false negatives is also reduced while maintaining computational efficiency.

[0029] In one implementation, after reading the triangulated mesh of the target 3D model, the system performs bottom-up aggregation using triangular faces as basic primitives to construct a hierarchical bounding volume tree, with each leaf node storing the geometric index of the corresponding triangular face. Based on this, the system determines the voxel side length according to the physical scale and fineness parameters of the reference object, and then multiplies it by a preset coefficient (such as 0.8) to calculate a preset distance threshold, thereby obtaining the continuous distance boundary used to determine the effective voxels.

[0030] Optionally, a hierarchical bounding volume tree is used to recursively divide the triangular facet space into several levels of bounding boxes to accelerate the query of the nearest distance from the grid node to the original surface. Optionally, the construction process of the hierarchical bounding volume tree can be completed using the triangular faces of the target 3D model as basic primitives, employing a bottom-up aggregation strategy or a top-down partitioning strategy. In one specific implementation, the system first calculates the axis-aligned bounding box of each triangular facet as a leaf node, and then iteratively selects two spatially adjacent nodes to aggregate and generate the parent node bounding box based on surface area heuristics or volume heuristics, until a single root node is finally formed, thereby constructing a binary tree structure that can be efficiently traversed. It should be noted that the above aggregation strategy is not the only way; a mid-axis partitioning, equal-number partitioning, or a binary partitioning strategy optimized by surface area heuristics can also be used, and this disclosure does not limit this approach. This tree structure allows for the rapid location of candidate regions by hierarchical elimination when querying the shortest distance from the center point of any grid to the original surface, without traversing all triangular faces. This significantly reduces the amount of distance calculation and ensures that the geometric information of thin-walled, acute-angled, and high-curvature regions is completely preserved in the leaf node index, thus providing an accurate data foundation for subsequent continuous distance determination.

[0031] Optionally, a preset coefficient is multiplied by the voxel edge length to obtain a preset distance threshold. This preset distance threshold determines that when the nearest distance from the grid center to the original surface does not exceed this product, the corresponding grid is marked as a valid voxel, thus characterizing the distance tolerance between the valid voxel and the original surface. Optionally, the value range and setting method of the preset coefficient can be flexibly adjusted according to the geometric features of the original model and the desired degree of voxelization fit. In one embodiment, for cartoon-style characters containing a large number of sharp edges and high curvature details, in order to ensure that these subtle features are fully contained by the voxels without being lost, the preset coefficient can be set to a value slightly greater than 0.5, such as 0.6 or 0.7, so that the distance threshold is moderately relaxed, thereby allowing grid nodes located near the tangent direction of the surface to still be included in the set of valid voxels; on the other hand, for mechanical or architectural models that are mainly composed of large surfaces, if the user wants the voxel boundaries to be as close as possible to the original surface to reduce redundant voxels, the preset coefficient can be reduced to 0.3 or 0.4, so that the distance tolerance is correspondingly narrowed. It should be noted that the above values ​​are only examples. In actual implementation, adaptive interpolation calculations can be performed based on the size of the voxel side length itself, the rate of change of the normal of the original mesh, or the art style label specified by the user, so as to dynamically allocate differentiated preset coefficients in different regions. This disclosure does not limit the specific determination method.

[0032] In an optional implementation, the method further includes calculating and determining the voxel side length based on the physical scale and refinement parameters of a reference object in the scene. This allows the voxelization result to stably adapt to 3D assets of different sizes by anchoring the actual physical scale of the scene to the reference object and dynamically adjusting the voxel density in conjunction with the refinement parameters, effectively improving the size consistency and automation of cross-scene batch processing. For example, in one implementation, the system identifies a 240 cm high pillar in the scene as the reference object. If the user sets the refinement parameter to 60 in the interactive interface, the calculated voxel side length is 4 cm. If the refinement parameter is adjusted to 30 for the same pillar, the voxel side length becomes 8 cm, thus obtaining a coarser voxel granularity at the same physical scale. It should be noted that the aforementioned reference object can also be replaced by any static object in the scene with a known principal axis scale, such as a fence with a horizontal length of 120 cm. When the refinement parameter is set to 40, the voxel side length is calculated to be 3 cm, thus ensuring that the absolute size of the voxel always remains consistent with the actual proportion of the scene.

[0033] Optionally, the reference object can be any 3D static object in the scene with a clearly defined physical scale along its principal axis, such as a vertical column, a horizontal beam, or a regular base. Before calculation, the system applies all spatial transformations of the object to the world coordinate system, and then reads its axis-aligned bounding box dimensions along the principal axis as the physical scale reference value. It should be noted that the selection of the reference object is not limited to the main model in the scene; it can also be an explicitly marked auxiliary measurement mesh. Considering the differences in local units and scaling factors between assets from different sources, the above physical scale anchoring mechanism bypasses the model normalized dimensions and directly uses real-world lengths as the measurement basis, thereby avoiding voxel side length drift due to coordinate system differences. As a result, when processing in batches across scenes, whether it is an indoor miniature ornament or a large outdoor building, a uniform absolute voxel size and visual proportion standard can be maintained.

[0034] Optionally, besides directly resolving the principal axis length of the axis-aligned bounding box, the physical scale of the reference object can be obtained by having the user manually input the dimension annotation when importing assets, or by automatically reading the standard dimension field embedded in the model metadata. When objects are not strictly axis-aligned in the world coordinate system, the system can first apply the object's local spatial transformation to the world coordinate system before calculating the bounding box to eliminate scale inflation caused by rotational deviations. Furthermore, when there is no single suitable reference object in the scene, the layout spacing of multiple objects with known dimensions can be used as the equivalent physical scale. In other words, regardless of whether the physical scale is obtained through automatic resolution, manual annotation, or indirect calculation, the core is to provide a stable and reproducible real-world anchor point for voxel side lengths, ensuring that pixel style transfer still has a unified dimensional measurement benchmark when collaborating across projects.

[0035] Optionally, the fineness parameter is used to control the voxelization output density, which can be flexibly set according to the user's requirements for pixel style granularity.

[0036] Optionally, the refinement parameter can be a unitless value, used to define the number of voxels to be uniformly subdivided within the physical scale of the reference object. The system divides this physical scale by the refinement parameter, and the quotient is the calculated voxel edge length. For example, when the physical scale of the reference object along the principal axis is 200 cm and the refinement parameter is set to 40, the voxel edge length is calculated to be 5 cm; if the refinement parameter is adjusted to 80, the voxel edge length is correspondingly reduced to 2.5 cm, thus generating denser raster nodes per unit length. It should be noted that the value of the refinement parameter can be flexibly configured according to the rendering performance budget of the target platform and the visual requirements of the pixel style. It can be directly specified by the user through the slider or numerical input box in the interactive interface, or it can read the default setting pre-stored in the project configuration file. In this way, users can intuitively control the density and level of detail of the voxelization output under a unified physical scale anchor, taking into account both visual performance and performance under different styles.

[0037] In step S230, multiple grid nodes are determined. By determining multiple grid nodes for the target 3D model, subsequent distance queries can be limited to the effective spatial range to reduce traversal overhead. This also provides a uniform reference array for point-by-point sampling of continuous distance fields, thereby improving voxelization efficiency and geometric fit stability.

[0038] In one implementation, after the system acquires the mesh data corresponding to the target 3D model, it calculates the bounding box of the mesh data in 3D space to define the approximate spatial range occupied by the model; thereby determining multiple grid nodes within the bounding box range corresponding to the mesh data.

[0039] Optionally, grid nodes are used to represent the sampling positions of regular 3D grids in the model space, serving as reference points for subsequent distance queries.

[0040] Optionally, the aforementioned grid nodes can be determined by establishing a regular 3D grid within the bounding box and recording the geometric center point position of each grid cell. Specifically, the system can divide the expanded bounding box area into equal-interval sections along the three orthogonal directions (horizontal, vertical, and horizontal axes) with a uniform step size for the voxel side length, thereby obtaining a cubic grid array arranged according to row and column layers. Each grid cell has a side length equal to the voxel side length in 3D space, and the 3D world coordinates of its center point can be calculated by multiplying the 3D index of the grid cell by the voxel side length and adding the offset of the bounding box origin. As a possible implementation, the spatial arrangement density of the grid nodes can also be adaptively adjusted according to the local geometric complexity of the model. For example, the step size can be appropriately increased in areas with gentle surface curvature changes to save computation, while the step size can be reduced in thin-walled or acute-angled dense areas to improve sampling accuracy. It should be noted that the above description of the regular cubic grid is only one example. In actual implementation, other space-filling methods such as hexahedral close packing or body-centered cubic packing can also be used to generate grid nodes. This disclosure is not limited to this.

[0041] Optionally, after the grid nodes are determined, the system can write the 3D index and spatial coordinates of each grid node as basic data into structured storage for fast access during subsequent distance queries and voxel marking stages. Once a grid node is marked as a valid voxel, its 3D index can be directly used to determine the relative position of its corresponding voxel in the output space, while its spatial coordinates can be used as vertex data to generate the vertex position attributes of the cube. Furthermore, to avoid geometric discontinuities caused by truncation of grid node distribution at model edges, the expansion of the bounding box in all three axes can be guaranteed to be an integer multiple of the voxel side length during grid node determination, ensuring strict alignment between the bounding box boundary and the grid cell boundary and reducing half-grid distortion. It should be understood that the grid node indexing method can be zero-based continuous integer indexing or sparse coding based on spatial hashing. If sparse coding is used, only grid nodes close to the model surface are stored to further reduce memory usage and improve traversal efficiency.

[0042] In an optional implementation, the step of determining multiple grid nodes includes: calculating the axis-aligned bounding box of the mesh data, and extending it outward along the three coordinate axes of the axis-aligned bounding box by a preset distance threshold to obtain an extended bounding box; within the extended bounding box, establishing a regular three-dimensional grid with the voxel side length as the step size, and determining the center point of the regular three-dimensional grid as a grid node. In this way, by constructing an extended bounding box by extending it outward along the three axes by a preset distance threshold, it ensures that the grid in the vicinity of the curved surface is completely included in the traversal range, avoiding the omission of thin-walled or boundary voxels due to initial bounding box clipping, and improving the integrity of geometric coverage.

[0043] In one implementation, the system first aligns the bounding box of the triangulated mesh of the target character model in the world coordinate system with the computational axes, obtaining its minimum and maximum boundary values ​​in the three orthogonal coordinate axis directions. Assuming the voxel side length is 0.1 meters and the preset coefficient is 1.5, the system expands the bounding box outward by 0.15 meters along each of the three axes to obtain an expanded bounding box. Within this expanded spatial range, the system establishes a regular 3D grid with a step size of 0.1 meters, and determines the geometric center point of each grid cell as the grid node for subsequent distance queries. The outward expansion process ensures that adjacent areas of thin walls or protruding structures near the original bounding box, such as the character's fingertips and leaf edges, are still fully covered by the grid, reducing the probability of missing effective voxels due to boundary clipping.

[0044] Optionally, the aforementioned axis-aligned bounding box is used to enclose all triangulated geometric elements of the target 3D model, providing a boundary reference for the subsequent generation of regular 3D grids. Optionally, the construction process of the aforementioned axis-aligned bounding box may include: traversing the vertex coordinates of all triangular faces in the target 3D model, and calculating the minimum and maximum values ​​of each vertex on the three coordinate axes to determine the spatial occupancy of the mesh data in the world coordinate system. It should be noted that the six faces of the axis-aligned bounding box are parallel to the corresponding reference planes of the coordinate system. This alignment characteristic simplifies subsequent outward numerical calculations and integer index mapping of the regular 3D grid. In one possible implementation, if the target 3D model undergoes rotation or non-uniform scaling spatial transformations, the construction of the aforementioned axis-aligned bounding box should be performed after applying all spatial transformations to ensure that the bounding box accurately encloses the transformed actual geometry. In other words, the axis-aligned bounding box not only defines the initial traversal range but also provides a unified spatial reference for aligning the expansion calculations with the grid step size.

[0045] Optionally, besides using tightly aligned bounding boxes built directly based on the extreme values ​​of all vertices, a slightly looser bounding box strategy can be adopted depending on the application requirements. For example, in one approach, a local aligned bounding box can be built independently for each skeletal submesh, and then the global aligned bounding box can be obtained by merging the local bounding boxes, thereby reducing the computational overhead of traversing a large set of vertices in a single pass. Furthermore, in addition to recording the boundary values ​​in six directions, the data structure of the bounding box can also record the instance identifier or material grouping information of the model in the scene, facilitating rapid reuse during batch processing of multiple instances. Considering the geometric characteristics of the aligned bounding box and its natural alignment with the regular 3D grid, the quotient obtained by dividing its boundary value by the voxel side length can be directly used as the upper limit of the integer dimension of the grid, thus saving complex floating-point boundary clipping calculations during the traversal phase.

[0046] Optionally, the above-described method of generating bounding boxes that expand uniformly along three axes is merely an example. In another implementation, considering that some target 3D models have significant extension along one axis while being relatively flat along others, different expansion ratios can be applied to the three axes to generate non-uniformly expanded bounding boxes. For example, for a cloth model that is approximately sheet-like, a larger expansion threshold can be applied only in the sheet-like normal direction, while maintaining a smaller expansion amount in the tangential direction, thereby reducing the number of redundant grids while ensuring coverage of key areas. It should be understood that regardless of whether a uniform or non-uniform expansion strategy is used, the expanded bounding box range should at least cover the effective distance field influence area around the original surface, so that the spatial index structure upon which the subsequent nearest distance query is based can return meaningful distance values, avoiding meaningless empty queries on grid nodes located outside the effective query range.

[0047] Optionally, the above-mentioned regular three-dimensional grid is uniformly divided within the extended bounding box with the voxel side length as the step size, and the position and size of its grid unit directly determine the voxel coverage granularity.

[0048] Optionally, the aforementioned regular 3D grid can be viewed as a 3D array structure obtained by uniformly subdividing the cuboid space defined by the extended bounding box according to the voxel side length as the basic scale unit. Specifically, the system can calculate the number of grid cells in each axis according to the ratio of the length information of the extended bounding box in the three coordinate axes to the voxel side length, and identify the position of each grid cell with an integer index triplet. In one possible implementation, the geometric center point of each grid cell is determined as the spatial coordinates of the grid node. The center point coordinates can be obtained by adding the minimum corner coordinates of the extended bounding box to the product of the index values ​​of each axis and the voxel side length, and then adding an offset of half the voxel side length. By fixing the sampling point at the grid center, a clear and one-to-one mapping relationship can be ensured between the distance query position and the final generated voxel spatial position, so that the subsequent voxel determination result based on the nearest distance can be directly mapped to the spatial occupancy of the entity voxel, avoiding voxel misalignment or overlap caused by sampling position deviation.

[0049] Optionally, in addition to uniformly dividing the entire extended bounding box with a globally uniform step size, the regular 3D raster can also be in the form of a layered raster or a multi-resolution raster. For example, in areas near the model surface or in regions with drastic curvature changes, the raster step size can be locally reduced to improve voxelization accuracy; while in open areas far from the surface, a larger step size is maintained to reduce the number of invalid rasters. It should be noted that regardless of the step size strategy used, as long as the spatial location of the raster unit can be addressed using a regular index, it can be considered a lower-level implementation of the aforementioned regular 3D raster. Furthermore, in addition to a one-to-one correspondence between raster units and voxels, multiple adjacent raster units can be merged into a composite voxel according to compression requirements, or the occupancy status of valid raster nodes can be stored in memory in the form of a 3D bitmap or a sparse hash table; this disclosure does not limit this approach.

[0050] In step S250, for each grid node, the system queries the nearest distance from the grid node to the original surface corresponding to the mesh data based on the spatial index structure. This method, by replacing discrete ray detection with continuous distance measurement, not only can thin-walled and acute-angled structures be accurately captured, but also stable surface fitting can be achieved based on a preset threshold, thereby effectively improving the accuracy of voxelized geometry and reducing manual repair work. In one embodiment, after establishing a regular 3D grid, for each grid node, the system queries the nearest distance between the center point of the grid node and the original triangular mesh surface using a pre-constructed hierarchical bounding volume tree. For example, when the target 3D model contains a thin-walled structure with a thickness close to one voxel in a local area, traditional ray detection is prone to missing voxels because the rays directly penetrate both sides of the thin wall; however, in this embodiment, the system uses a hierarchical bounding volume tree to calculate the minimum distance between the grid center and each bounding volume layer by layer from the root node and prunes the branches, quickly locating the triangular facet closest to the center, thereby accurately obtaining the nearest distance from the grid node to the original surface. This distance value (i.e., the closest distance) is then recorded in the attribute data of the corresponding raster so that it can be compared with a preset distance threshold to determine whether the raster should be marked as a valid voxel.

[0051] Optionally, the aforementioned process of obtaining the nearest distance can be implemented based on various spatial index structures. In this embodiment, considering the balance between query efficiency and storage overhead for complex geometries, the aforementioned spatial index structure can specifically be a pre-constructed hierarchical bounding volume tree. It should be noted that there are multiple possibilities for constructing this hierarchical bounding volume tree; it can be an axis-aligned bounding volume hierarchy or an oriented bounding volume hierarchy, and this disclosure does not limit it in this way. When the system traverses each grid node in the regular 3D grid, for each grid node, taking the center point of the node as the query source point, it traverses from top to bottom along the hierarchical bounding volume tree, calculates the minimum distance between the query source point and each bounding volume at each level, and prunes the subtree according to the distance value, thereby quickly converging to the triangular facet on the original surface that is closest to the source point, and then obtaining the nearest Euclidean distance from the center of the grid node to the original surface. In this way, by replacing discrete Boolean decisions with continuous distance metrics, we can avoid the problem of missed detection in thin-walled structures by ray detection, and obtain a stable voxel-fitting effect in the entire scene based on a preset threshold, which significantly enhances the geometric consistency of subsequent effective voxel determination.

[0052] Optionally, besides using a hierarchical bounding volume tree to perform nearest-neighbor queries, in other implementations, a spatial hash grid or a sparse voxel octree can also be used to implement the above distance query process. For example, when using a spatial hash grid, the system can first discretize the original surface into a directed distance field and store it in a three-dimensional hash table. Then, for each grid node, the distance value of its local region is directly read through hash addressing, without needing to perform a tree-level traversal node by node. When using a sparse voxel octree, the system can adaptively allocate voxel resolution at different depth levels, using finer child nodes for distance sampling in local regions close to the original surface, and using coarse-grained nodes for fast stepping in open areas far from the surface, thereby reducing space storage while maintaining distance query accuracy. It should be noted that the selection of the above different index structures can be dynamically configured according to the patch size of the original model, the fineness of the target voxels, and real-time requirements. This disclosure is not intended to exhaustively limit the specific type of the spatial index structure.

[0053] In step S270, effective voxels are determined from multiple grid nodes based on the comparison result between the nearest distance and a preset distance threshold. This method of determining effective voxels through continuous distance threshold comparison not only avoids the omission of thin-walled and acute-angled structures by discrete ray detection, but also significantly improves the fitting accuracy and generation stability of the voxel set and the original surface. In one embodiment, the system first performs world coordinate system transformation and triangulation on the target 3D model, then constructs a hierarchical bounding volume tree using its mesh data and calculates the axis-aligned bounding box. Subsequently, the system expands the bounding box outward along the three coordinate axes by a preset distance threshold (this threshold is determined by the product of the voxel side length and a preset coefficient), and establishes a regular 3D grid within this expanded spatial range with the voxel side length as the step size. For each grid center node, the system uses the hierarchical bounding volume tree to query its nearest distance to the original surface. When the nearest distance is not greater than the aforementioned threshold, the grid node is determined to meet the distance field fitting condition, marked as an effective voxel, and its 3D index and spatial coordinates are recorded simultaneously, thus completing the distance field voxelization determination process.

[0054] Optionally, effective voxels are generated by marking the center nodes in a regular 3D raster that meet the distance field fitting conditions. Their 3D indexes and spatial coordinates are recorded and used for subsequent mesh reconstruction and color assignment.

[0055] Optionally, the determination of valid voxels relies on a numerical comparison between the nearest distance from the grid center node to the original surface and a preset distance threshold. The system traverses all regular 3D grids within the expanded bounding box. For each grid center node, a hierarchical bounding volume tree is used to accelerate the query for its nearest distance to the original surface of the target 3D model. When the nearest distance does not exceed the preset distance threshold, the grid node is considered a valid voxel and marked; conversely, if the nearest distance exceeds the preset distance threshold, the node's spatial location is considered outside the acceptable fitting range of the original surface, and no voxel is generated. The preset distance threshold is calculated by multiplying the voxel's side length by a preset coefficient. The preset coefficient characterizes the distance tolerance between the valid voxel and the original surface, and its value directly affects the surface fit of the final voxelization result. This decision mechanism based on continuous distance fields quantifies the spatial relationship between grid nodes and the original surface into continuous nearest distances, enabling the system to stably control the distance relationship between voxels and the original surface globally with a single numerical threshold. This effectively reduces the risk of voxel loss or morphological distortion caused by fixed sampling step size in thin-walled structures, sharp-angled edges, and high-curvature transition areas, thereby ensuring that geometric details are stably restored in voxel space.

[0056] Optionally, in addition to using the aforementioned single global threshold (i.e., the preset distance threshold) for determination, the determination of effective voxels can also be performed based on a more refined layering or object-by-object adaptive strategy. For example, for composite models with significant thickness differences, the system can assign differentiated distance tolerance coefficients to different parts of the model or regions with different materials, thereby using relatively lenient coefficients in thinner regions to avoid voxel loss, and using relatively strict coefficients in thicker or flatter regions to suppress the generation of redundant voxels.

[0057] Optionally, grid nodes marked as valid voxels can record their 3D index and spatial coordinates, and further associate and store attribute data such as the hit triangle information, texture sampling coordinates, and initial transparency channel. The 3D index uses integer coordinates to identify the voxel's array position in the regular 3D grid, while the spatial coordinates reflect the voxel's absolute position in the world coordinate system. Together, they form the spatial addressing basis for the subsequent block mesh reconstruction stage. When entering the color assignment stage, the system can directly sample the initial color of the voxel from the material texture image of the target 3D model based on the pre-recorded hit triangles and their texture coordinates. If the user specifies a target color palette, the sampled color is further converted to a perceptually uniform color space to complete nearest neighbor matching, and the matching result, along with the original transparency, is written into the color attribute of the valid voxel.

[0058] In an optional implementation, after determining the effective voxels from multiple grid nodes, the method further includes: obtaining the sampled color corresponding to the effective voxel, and obtaining at least one palette color value, wherein the palette color value is included in the target palette; converting the sampled color and the at least one palette color value to a perceptually uniform color space; calculating the distance between the sampled color and each palette color value in the perceptually uniform color space, and determining the target color of the effective voxel based on the nearest neighbor matching result. This allows color matching to be performed in a perceptually uniform color space, eliminating the nonlinear deviation between the standard color space and human visual perception, effectively suppressing hue drift and brightness jumps, and making the overall color scheme of the voxelized model closer to the artistic design.

[0059] In one implementation, the target 3D model is assumed to be a character wearing armor, with its surface covered by a base color texture. After determining the effective voxel, the system samples an initial sampled color (e.g., a warm brown with red 180, green 140, and blue 110 components) from the material texture associated with the original surface for that voxel. Simultaneously, the system reads several hexadecimal color values ​​stored in the target color palette as palette color values. The system performs color space conversion on the warm brown and each palette color value, mapping them to a perceptually uniform color space and calculating the Euclidean distance between them. The converted warm brown is closest to the ochre color in the palette within this space; therefore, the system determines the ochre color as the target color for that effective voxel, thus completing accurate color mapping within a finite color gamut.

[0060] Optionally, the sampled color is used to characterize the initial color information of the effective voxel on the original surface, and it is obtained by sampling based on texture coordinates. Optionally, the above-mentioned sampled color can be the initial color value directly sampled from the texture image associated with the target 3D model based on the texture coordinates of the voxel hitting the triangle face. In a specific implementation, the system backtracks along the basic color input port of the standard shader from the material node graph of the target object to find the texture image node and extract the corresponding 2D texture data. Further, the system performs sampling at the corresponding pixel position of the texture image based on the hit triangle face and its texture coordinates recorded in the distance query stage, thereby obtaining the initial color of the voxel position. Before participating in the subsequent perceptual uniform color space conversion, the numerical representation of this sampled color usually exists in the form of a standard three-channel nonlinear color space, and its transparency channel can be completely preserved to ensure that the voxel still has the correct transparency attribute after the subsequent nearest neighbor matching is completed. In this way, through accurate texture backtracking and coordinate mapping, an input basis that is highly consistent with the visual information of the original model surface can be provided for the subsequent color space conversion.

[0061] Optionally, considering that 3D models in actual production environments may not have complete texture coordinates or texture images, the above-mentioned method for obtaining sampled colors may not rely entirely on texture images. As one possible implementation, the system can directly read the vertex color attributes of the triangle face corresponding to the voxel's hit location and interpolate the color values ​​of the three vertices based on the centroid coordinates to obtain the sampled color of the voxel. As another implementation, the system can also perform lighting calculations based on the angle between the normal direction of the hit triangle face and the preset light source direction, combined with the material's basic color parameters, to generate simulated light and dark sampled colors. In other words, the methods for obtaining sampled colors can be diverse; they can originate from pre-baked texture data, procedural lighting calculations, or vertex shading data. Those skilled in the art can flexibly choose based on the data integrity of the source model and the target visual style. Thus, even with low-precision models lacking texture coordinates, usable color input can be provided for subsequent perceptual uniform color space mapping.

[0062] Optionally, a perceptually uniform color space is used to provide a measurement benchmark based on human eye perception for color comparison. It is constructed through gamma linearization and reference white point normalization. Alternatively, the perceptually uniform color space can be a color representation system that, after a specific nonlinear transformation, allows the Euclidean distance in the color space to approximately represent the magnitude of color difference perceived by the human eye. In one specific implementation, the system performs gamma linearization on the sampled color and palette color values ​​respectively to eliminate the nonlinear compression of channel values ​​by the display gamma. Then, it maps the red, green, and blue channel representations to a device-independent color representation through tristimulus value transformation, and further performs reference white point normalization, thereby placing all color values ​​in a unified perceptually uniform color space. For example, the above tristimulus value transformation can be implemented with reference to a standard color transformation matrix, while the reference white point can be dynamically selected according to the lighting conditions of the scene or display environment. After the conversion, the system calculates the Euclidean distance between the sampled color and each palette color value in the perceived uniform color space. Since the distance measurement in this space has a higher linear correlation with differences in human visual perception, it effectively avoids the hue drift and brightness jump problems caused by relying solely on numerical distance in the standard color space. It should be noted that the above method of determining the target color based on nearest neighbor matching results can include various implementation logics. As one possible implementation, after calculating the Euclidean distance between the sampled color and each palette color value in the perceived uniform color space, the system directly selects the palette color value with the smallest distance as the target color, thus ensuring a strictly numerical nearest neighbor. As another implementation, the system can first divide all palette color values ​​into several priority levels according to their distance from the sampled color. When multiple candidate color values ​​with the same or approximately equal minimum distance appear, one is selected based on a preset hue continuity rule or random perturbation strategy to avoid large-area continuous voxels producing checkerboard-like color jumps due to sampling noise.

[0063] Optionally, the color values ​​in the target color palette are included and used to compare with the sampled colors to constrain the color output range of the voxelization result. Optionally, the aforementioned color values ​​in the color palette can be a set of hexadecimal color values ​​picked up by the user from a reference image through an interactive interface or manually input, and this set of color values ​​can be encoded into a color patchwork image during persistent storage. In one specific implementation, in response to pointer movement operations on the canvas area, the system reads the red, green, and blue channel values ​​of the pixel where the pointer is located in real time and synthesizes hexadecimal color values. After user confirmation, these values ​​are added to the color value set of the target color palette. After construction, the system horizontally splices each color value into color patches of fixed side lengths to generate a color patchwork image, which is stored in the same path as the project file with the same name but a fixed suffix. During loading, the system reads the image and samples pixel values ​​one by one according to the center position of each color patch, restoring it to a list of hexadecimal color values. This image format not only facilitates reuse across sessions but also allows users to directly visually verify the composition of the color palette using common image preview tools, thereby improving the convenience of asset management. In this way, through a persistent image storage mechanism, palette color values ​​can be stably reused across different projects and sessions.

[0064] Optionally, the construction method and color value source of the target color palette are not limited to the reference image picking method; they can be dynamically determined in various ways according to project needs. As one possible implementation, the system can directly call verified color palette configurations from a preset art style library, such as a limited color palette for a retro hardware style or a harmonious color scheme for a specific art theme, and load it as the initial color value set of the target color palette into the interactive interface. As another implementation, the system can also receive arbitrary color values ​​manually entered by the user through a color picker control, and automatically perform deduplication processing before adding them to the color value set to avoid redundant interference from duplicate color values ​​in subsequent nearest neighbor matching calculations. In other words, the target color palette can be a completely customized manual color scheme result or a standardized color palette resource based on historical projects. Its scale can range from several basic color values ​​to dozens of extended color values. This disclosure does not intend to limit the specific scale or generation method of the color palette.

[0065] In an optional implementation, the step of obtaining the sampled color corresponding to the effective voxel includes: extracting a texture image from the material node map of the target 3D model; and sampling in the texture image according to the triangle facets and texture coordinates corresponding to the effective voxel to obtain the sampled color. In this way, by backtracking to extract the original texture from the material node map and accurately sampling according to the texture coordinates of the hit triangle facets, it can ensure that the voxel color accurately corresponds to the surface texture of the model, avoiding visual deviations caused by single-color mapping. In one implementation, after voxelizing the target 3D model, the system extracts a base color texture image from the material node map of the model for one effective voxel; then, based on the triangle facets corresponding to the obtained effective voxel, it reads the vertex texture coordinates of the triangle facets and interpolates them according to the relative position of the voxel center on the triangle facet to obtain the sampling coordinates in the texture space, and then samples the initial color corresponding to the voxel from the texture image.

[0066] Optionally, the material node graph is used to carry the texture reference relationships and shading logic of the target 3D model. The system can backtrack from it and extract the texture image to be sampled. Optionally, the material node graph is a directed graph structure in the 3D rendering pipeline used to organize and manage material properties. Each node can include, but is not limited to, texture image nodes, color adjustment nodes, vector operation nodes, and blending nodes. In this embodiment, the system does not directly read external image files from fixed paths. Instead, it parses the material node graph of the target 3D model and backtracks along the base color input port of the standard shader to automatically locate and extract the texture image directly related to the shading of the model surface. This texture image can be of various types, such as a 2D bitmap, normal map, or lightmap, but the base color texture information is mainly used for color sampling. It should be noted that the above backtracking extraction path is not limited to a single level. If the base color input port is connected to an intermediate blending node, the system can continue to trace upstream until a valid texture image node is encountered, thereby ensuring that the original texture data source can still be accurately captured in complex node-based material workflows.

[0067] Optionally, the triangular face corresponding to the effective voxel refers to the triangular facet closest to the grid center, obtained through a spatial index structure query during the distance field voxelization stage. This triangular facet typically belongs to the original mesh data of the target 3D model. After determining this triangular facet, the system further obtains the texture coordinates associated with the three vertices of the triangular facet, i.e., the horizontal and vertical coordinates of the corresponding vertices in the 2D texture space, and interpolates based on the centroid coordinates of the voxel center on the triangular facet to calculate the precise texture coordinates corresponding to the voxel center. These texture coordinates are then used to perform sampling in the texture image to obtain color. As a possible implementation, if the voxel center happens to fall on an edge or vertex of the triangular facet, the texture coordinates corresponding to that edge or vertex can be directly used; if the distance query hits an edge shared by multiple triangular faces, the texture coordinates of any adjacent triangular facets can be selected or the average value can be taken. It should be noted that the above texture coordinates can not only be 2D floating-point coordinates, but also, in scenarios involving 3D textures or volumetric textures, can be further extended to 3D texture coordinates, which is not limited in this disclosure.

[0068] In an optional implementation, the step of converting the sampled color and at least one palette color value to a perceptually uniform color space includes: performing gamma linearization, tristimulus value conversion, and reference white point normalization on the sampled color and at least one palette color value respectively to obtain a color representation, wherein the color representation is a representation in the perceptually uniform color space. Thus, by performing gamma linearization, tristimulus value conversion, and reference white point normalization in stages, the color values ​​are uniformly mapped to the perceptually uniform color space, making the distance measurement consistent with human visual perception, suppressing systematic biases in color difference matching, and improving the visual accuracy of palette mapping.

[0069] In one implementation, for the sampled color of a specific effective voxel, the system performs color space conversion preprocessing according to a fixed procedure: First, the channel values ​​of the sampled color are gamma linearized to remove the influence of the non-linear encoding of the display device and restore them to basic values ​​that are linearly related to light intensity. Then, the system performs tristimulus value conversion on these linearized channel values, mapping them from a device-dependent three-channel representation to a device-independent color representation based on the photosensitive characteristics of the human eye. On this basis, the system further performs reference white point normalization, correcting the color representation according to the white point coordinates under a standard light source to eliminate color shifts caused by different observation conditions. Finally, the system obtains the color representation of the sampled color in a perceptually uniform color space. For each color value in the target color palette, the system repeats the same preprocessing procedure to complete subsequent nearest neighbor distance matching based on a unified perceptual metric.

[0070] Optionally, the gamma linearization process can include all channel components of the sampled color and each color value in the color palette, and its implementation can be diverse. Considering that display devices typically use gamma encoding to optimize human visual perception within a finite numerical range, directly performing numerical calculations in this non-linear encoding space would lead to significant deviations in subsequent brightness mixing and color difference calculations. As one implementation, the aforementioned gamma linearization can include: applying a preset inverse power function transformation to the normalized value of each channel, where the power exponent typically corresponds to the gamma value of the target device or a composite gamma curve in the standard red-green-blue color space for display. Furthermore, this step can also include reverse lookup processing of non-standard color profiles to support broader color management needs. It should be noted that the above description of the inverse power function transformation is only one example, and this disclosure is not intended to limit the specific algorithm of gamma linearization. In actual implementation, any processing method that can map the value from the non-linear encoding domain to the linear light intensity domain is applicable to this scheme, thereby ensuring that subsequent tristimulus value conversions obtain a physically correct input basis.

[0071] Optionally, the main function of the tristimulus value conversion is to transform device-dependent color representations into standardized color representations that are independent of any specific device characteristics. Considering that the three types of cone cells in the human retina have differentiated spectral responses to different wavelengths of light, as one implementation, the above tristimulus value conversion can, according to the definition of a preset standard device-independent color metric space, linearly weight and combine the linearized values ​​of the three channels through a 3x3 conversion matrix to obtain three stimulus value components. Among these, the component most closely related to luminance is mainly used to describe lightness information, while the other two components jointly describe the chromaticity characteristics of the color. It should be noted that the coefficients of the above conversion matrix can be pre-calibrated according to different standard light sources or target color gamut requirements; this disclosure does not intend to limit the specific values ​​of the matrix. Through this conversion, the sampled color and the palette color value are unified under the same device-independent mathematical framework, establishing an objective and physically interpretable intermediate transition for subsequent entry into a perceptually uniform color space.

[0072] Optionally, the reference white point normalization can be performed by comparing the color representation obtained after converting the tristimulus values ​​with the reference white point coordinates under a standard light source and performing a scaling operation. Considering that different observation environments or rendering light source settings can cause significant color shifts in the human eye perception of the same set of stimulus values, as one implementation method, the above normalization can include: obtaining the white point tristimulus values ​​corresponding to a preset standard light source, dividing each component of the color representation by the corresponding component of the white point, thereby obtaining a normalization ratio relative to the standard observation conditions. If the target application scenario requires visual presentation under other specific light sources, the divisor reference can be dynamically adjusted based on the white point calibration data of that scenario. It should be noted that reference white point normalization applies not only to sampled colors but also to every color value in the color palette, aiming to ensure that the two types of color data being compared are under consistent observation condition references. If this step is skipped, the difference in light source will directly translate into a constant deviation in distance calculation, causing an overall hue shift in the nearest neighbor matching results, thereby reducing the visual fidelity after pixel style conversion.

[0073] Optionally, the color representation is a numerical description of the sampled color or palette color value within a perceptually uniform color space, used to support subsequent Euclidean distance calculations consistent with human visual perception. Optionally, the color representation is the final output of the aforementioned three-step preprocessing steps: gamma linearization, tristimulus value conversion, and reference white point normalization. Its data structure can include, but is not limited to, floating-point three-dimensional vectors or fixed-point compressed values. The perceptually uniform color space in which this color representation resides has perceptual uniformity characteristics, meaning that the Euclidean distance between any two points in the space is approximately proportional to the perceptual intensity of the corresponding color difference by the human eye. As one implementation, the color representation in the perceptually uniform color space can include one luminance-related component and two chromaticity-related components, where the luminance component changes independently of the chromaticity components, thereby avoiding the coupling of lightness differences and hue differences during measurement. It should be noted that the above specific structural description of the perceptually uniform color space is only one example, and this disclosure is not intended to limit the type of this space. In practical implementation, a suitable perceptually uniform color space implementation method can be selected based on the system's different requirements for color gamut coverage, computational overhead, and visual accuracy. This ensures both approximately uniform perceptual scale and the real-time requirements of batch voxel processing. In other words, the generation quality of this color representation directly determines the accuracy of nearest neighbor matching.

[0074] In step S290, the target 3D model is rendered based on effective voxels. In one embodiment, after the front-end interactive interface initiates a voxelization task, the designer can directly observe the target 3D model reconstructed based on effective voxels in the engine preview window. For example, the system organizes effective voxels into several spatial blocks (such as rectangular blocks) according to planar orientation indexes. The rendering engine dynamically clips each block region according to the camera's view frustum and only performs drawing calls on blocks that fall within the visible range. In an optional embodiment, after determining effective voxels from multiple grid nodes, the method further includes: dividing the effective voxels into at least one rectangular block according to a preset block step size based on planar orientation indexes; generating a cube for each effective voxel within each rectangular block, and performing coplanar face merging processing on the cube to generate an independent mesh object corresponding to the rectangular block. In this way, by reducing the number of redundant faces through spatial block division and coplanar merging, the output model directly meets the performance constraints of the real-time rendering engine for view frustum clipping and batch management, effectively shortening the delivery latency of production-grade assets.

[0075] Optionally, rendering is used to convert the preprocessed valid voxel data into graphical output and dynamically schedule the visibility of each block object according to spatial indexing and batch management strategies. Optionally, considering that the aforementioned block mesh reconstruction stage has divided all valid voxels into several rectangular blocks according to planar orientation indexing, as a possible implementation, the above rendering process can specifically include: when the 3D engine loads the output set, it allocates each independent mesh object to the corresponding rendering batch according to the spatial coordinates and bounding volume parameters. It should be noted that when the camera frustum is translated or rotated, the engine quickly determines whether each block is within the visible area through spatial indexing, submitting only the blocks falling within the frustum to the rendering pipeline, while blocks completely outside the frustum are temporarily discarded. That is to say, this block rendering mechanism is not only related to the spatial position of individual blocks, but also dynamically associated with the camera orientation and field of view parameters. Furthermore, since each block has been assigned vertex color attributes and retains the original transparency channel during the reconstruction stage, the rendering pipeline can directly complete the color rendering through vertex interpolation without additionally querying complex material node graphs, thereby significantly reducing the computational overhead of the pixel shading stage. This approach avoids wasting bandwidth and computational resources by indiscriminately sending all voxel data into the rendering pipeline. Furthermore, it leverages the engine's native frustum clipping capability, ensuring stable performance for large-scale voxel scenes in both real-time preview and final output. In one implementation, for a building model containing hundreds of thousands of effective voxels, after voxelization, the system calculates a preset block step size of 512 units based on the physical scale of the reference object. It then divides all effective voxels into six rectangular blocks, indexed along the horizontal plane of the world coordinate system. Within each block, the system generates cubes to represent the spatial area occupied by each voxel. It then identifies and merges coplanar faces between adjacent voxels to remove redundant inner surfaces, and triangulates the exposed outer surfaces. Finally, each block generates an independent mesh object, which is included in the output set and processed by the rendering engine for frustum clipping and batch scheduling according to spatial regions.

[0076] Optionally, the preset block step size directly determines the spatial range and voxel capacity covered by a single rectangular block. Its calculation is typically based on the numerical relationship between the physical scale of the reference object along the principal axis and the determined voxel side length. In a specific design, the step size can be determined by dividing the physical scale of the reference object by an empirical coefficient, ensuring that the number of triangles within a single block remains within the performance budget of the rendering engine's single render call. It should be noted that this block step size is not fixed and can be dynamically adjusted based on the distribution density of objects in the scene, the hardware capabilities of the rendering platform, or the target frame rate requirements. For example, when dealing with background objects at a distance, the block step size can be appropriately increased to reduce the batch size; while when processing fine objects with frequent close-range interaction, the block step size can be shortened to improve the granularity of the view frustum clipping. This embodiment does not limit this. The purpose of setting the step size on demand is to balance the scale of each independent mesh object, on the one hand, to avoid a sudden increase in rendering pressure due to excessively high face count in a single batch, and on the other hand, to prevent the blocks from being too fragmented, thus avoiding a burden on batch management.

[0077] Optionally, the preset block step size can also be determined through user-defined input or adaptive subdivision based on a spatial octree. Considering the differences in rendering call limits across different hardware platforms, as a possible implementation, the system can initially generate candidate step sizes using a fixed ratio of the physical scale of the reference object to the voxel side length, and then adaptively adjust them based on the performance profile of the current target platform. To ensure the alignment of block boundaries, the aforementioned step size is usually set to an integer multiple of the voxel side length, thereby avoiding discontinuities caused by voxel truncation when crossing blocks. Furthermore, in target scenes with multiple objects of different sizes, differentiated block step sizes can be set for large-scale background objects and small-scale foreground props, and the results of each block can be uniformly merged into the same output set. This layered setting strategy not only takes into account the management accuracy requirements of both foreground and background scenes, but also maintains the consistency of spatial organization while considering the rendering sequence and loading priority of different objects.

[0078] Optionally, the planar orientation index is essentially a two-dimensional mesh coordinate identifier obtained by projecting a three-dimensional voxel grid along a specified axis. Its orientation is usually consistent with the horizontal plane or longitudinal section in the world coordinate system. In a specific implementation, the system can traverse the voxel grid layer by layer along the vertical axis, grouping voxels with the same height level into the same planar index set, and then further dividing it into several rectangular blocks along the horizontal axis according to a preset block step size. It should be noted that the above-mentioned planar orientation is not uniquely limited to the horizontal plane; it can also be adjusted to an inclined plane according to the main geometric orientation or main surface normal distribution of the source model surface. For example, for roofs or slopes, the planar orientation can be adjusted to be approximately parallel to the slope normal. For example, for terrain or building roof structures with obvious slope direction, using an inclined plane approximately parallel to the main surface normal for indexing can further reduce orientation jumps in the subsequent cube generation stage, making the boundaries of the rectangular blocks more consistent with the geometric trend of the original model. This disclosure is not intended to limit the specific selection of the planar orientation.

[0079] Optionally, each rectangular block logically corresponds to a local spatial region, containing voxels that are continuously distributed along the planar direction index. This ensures that the coplanar face merging operation has clear spatial boundaries and avoids accidental deletion of adjacent faces across blocks. When determining block boundaries, the system can use a preset block step size as a reference, starting from the origin of the expanded bounding box and successively increasing the step size along the planar direction index until the index range of all valid voxels is covered. It should be understood that since the spatial distribution of valid voxels is usually uneven, there may be local gaps in the blocks at the boundaries. To optimize output efficiency, the system can first remove empty regions within the rectangular block before generating the cube, and only perform subsequent face construction and triangulation processing on compact sub-regions containing valid voxels. This strategy not only saves the invalid vertex overhead caused by empty voxels, but also ensures that the face size of each independent mesh object matches its actual geometric complexity.

[0080] Optionally, the cube corresponds to the position and size of a single occupied cell in a regular 3D grid. Its side length is equal to the calculated and determined voxel side length, and the vertex coordinates are typically obtained by offsetting half a side length in each of the six orthogonal directions with the grid center as the origin. While generating the cube, the system can attach color and normal attributes to its vertices so that after subsequent triangulation, it can output directly renderable assets with vertex rendering information. Considering that generating each cube independently in a large-scale voxelization scene would result in a massive number of duplicate vertices, as an optimization implementation, the system can also pre-allocate vertex buffers at the block level and share vertices of faces with the same spatial location through index mapping, thereby reducing memory usage and improving throughput in the geometry generation stage. This embodiment is not limited to this; in actual implementation, it can be adaptively adjusted according to the memory budget and vertex processing pipeline characteristics of the target platform.

[0081] Optionally, the core of coplanar patch merging lies in detecting spatially overlapping or completely fitted patches among the cubes within a block and removing these patches from the output geometry. In one specific processing method, the system can traverse all patches of all cubes within a rectangular block and establish a spatial hash mapping table with the patch center coordinates and normal direction as the joint key. When two or more patches fall into the same hash bucket and their normal directions are opposite and the center distance is less than a preset tolerance, they can be determined as coplanar inner surfaces between adjacent voxels and marked for deletion. Considering that floating-point precision errors may cause slight offsets in the patch center coordinates, the above tolerance is usually set to the order of one-thousandth of the voxel side length, thereby ensuring the accuracy of removal while avoiding misjudging non-coplanar adjacent patches. One objective of this embodiment is that, through this patch merging mechanism, on the one hand, the six-fold redundancy generated by the original independent voxel-by-voxel face can be significantly reduced, and on the other hand, the retained outer surfaces can form continuous polygons with larger areas, providing a better geometric topological basis for subsequent triangulation processing.

[0082] Optionally, the timing and granularity of coplanar patch merging can be flexibly adjusted according to the output purpose. In a lightweight implementation for real-time interactive scenarios, the system can perform merging only within the same rectangular block to maximize task parallelism between blocks. In a heavyweight implementation for offline high-definition rendering, the system can add a global deduplication stage after merging within a block to uniformly remove duplicate patches remaining on the boundaries of adjacent blocks due to independent processing. It should be understood that differentiated processing for different pipelines helps to achieve a dynamic balance between resource consumption and face reduction. If the voxel distribution within a block is extremely sparse or consists entirely of isolated points, the benefits of coplanar merging will rapidly decrease. In this case, the system can choose to skip the merging step and directly triangulate all cubes for output, thereby avoiding additional preprocessing overhead. This disclosure is not intended to limit the merging level and execution strategy uniquely; in practical applications, it can be determined according to hardware load and image quality requirements.

[0083] Optionally, after merging coplanar faces, the remaining outer surface is typically composed of non-planar polygonal faces or polygons with more than four vertices. However, mainstream graphics interfaces generally only support triangles as the most basic drawing primitives. Therefore, the system needs to decompose the faces retained in each block into several non-overlapping triangles using methods such as ear-cutting, sector partitioning, or center-point segmentation. During this process, the system can synchronously inherit the color, normal, and tangent attributes of each face vertex to ensure that the output mesh after triangulation maintains visual consistency with the original voxel sampling results. It should be noted that, in order to minimize the generation of elongated triangles, the above partitioning algorithm can be adaptively selected based on the specific number of vertices and convexity / concavity characteristics of the face. For example, diagonal partitioning can be used for convex quadrilaterals, while ear-cutting can be used for concave polygons. By maintaining a reasonable distribution of triangle shapes, problems such as texture mapping distortion or abnormal lighting calculations can be avoided in subsequent real-time rendering.

[0084] Optionally, each independent mesh object contains triangulated vertex buffers, index buffers, and material property references in its data structure. Its spatial transformation matrix is ​​usually inherited from the world coordinate system state of the original target object, thus ensuring that its position and orientation in the scene are consistent with the source model. At the level of output set organization, each independent mesh object can remain as a separate scene node, or it can be dynamically merged into a single output parent node during the import stage for unified management in the content production pipeline. One objective of this embodiment is that by splitting a large number of voxels into multiple independent mesh objects, the rendering engine can perform frustum clipping based on the world space bounding box of each object, initiating drawing calls only for visible blocks, thereby completely eliminating the vertex processing and pixel filling overhead of invisible areas, effectively improving the frame rate and rendering throughput of large-scale pixel-style scenes.

[0085] In an optional implementation, before dividing the effective voxels into at least one rectangular block according to the planar index based on the preset block step size, the method further includes: calculating and determining the preset block step size based on the physical scale of the reference object in the scene and the voxel side length. Thus, by jointly constraining the block step size with the physical scale of the reference object in the scene and the voxel side length, the spatial block size adaptively matches the scene scale and voxel precision, ensuring a balance between the number of blocks and the number of faces per block, while also considering the batch scheduling efficiency of the rendering engine and the granularity of view frustum clipping. In practical applications, the system can perform a quantized comparison between the physical scale of the reference object along each principal axis direction in the scene and the determined voxel side length, using the obtained value as the benchmark for the preset block step size. For example, when the physical span of the reference object in the X-axis direction is 1024 cm and the voxel side length is 16 cm, the system can calculate and set the block step size in the X-axis direction as 64 voxels. If the physical span of the reference object in the Y-axis direction is 256 cm, the block step size in the corresponding direction can be determined as 16 voxels. Thus, the block step size in each axis is numerically mapped to the inherent proportions of the scene, ensuring that the rectangular blocks subsequently divided accordingly are compatible with the single-time scheduling capability of the rendering engine in terms of the number of faces.

[0086] Optionally, the preset block step size can be calculated and determined based on the scale of the reference object and the voxel side length to control the granularity of the rectangular blocks. Optionally, the specific calculation process of the above-mentioned preset block step size can be directly related to the principal axis physical scale of the reference object in the scene. Considering that if the block step size is fixed to a certain empirical constant, a single block may contain too many voxels when processing large-scale scenes, resulting in the number of faces after merging still exceeding the capacity limit of the rendering engine's single draw call; conversely, when processing small and detailed props, a fixed block step size may generate a large number of scattered blocks, increasing the additional overhead of batch scheduling. Based on this, the system can read the physical span of the reference object along the three coordinate axes of the world coordinate system, quantize and compare this span with the determined voxel side length by dimension, and thus obtain a block step size that matches the number of voxels in each axis. For example, when the physical span of the reference object in the X-axis direction is 512 units and the voxel side length is 8 units, the system can calculate that this direction contains a total of 64 voxels. The block step size is then set to 32 or 16, resulting in 2 or 4 rectangular blocks generated along this axis. This strategy establishes a mapping relationship between the block size and the inherent proportions of the scene, ensuring that projects of different sizes achieve a balanced number of facets and a reasonable total number of blocks after voxelization, effectively reducing rendering performance fluctuations caused by block size mismatch.

[0087] In an optional implementation, the method further includes: obtaining the color value set of the constructed target color palette; stitching the color values ​​together into color blocks of preset side lengths to generate a color block stitched image, wherein each color value is a color value in the color value set; and storing the color block stitched image to a specified path. In this way, by storing the color palette data in image format at the same level as the project file, it supports direct reuse across sessions and allows users to quickly verify color values ​​visually, reducing the overhead of repetitive configuration.

[0088] In practical applications, once the user confirms the color palette configuration, the system first reads the complete set of color values ​​from the target color palette. Then, it renders each color value as an independent color block according to a preset side length, and seamlessly stitches all the color blocks together horizontally to form a stitched image. Finally, the image file is written to a specified path for persistent storage. For example, the preset side length can be set to sixteen pixels, and each color block is a rectangular area filled with a solid color. The stitched image accurately reflects all color values ​​in the color value set and their arrangement order, allowing for direct reading and reuse later.

[0089] Optionally, the color patch image, as the physical carrier of palette data, can be generated as follows: each independent color value in the target palette's color value set is rendered into a rectangular or square color patch with a uniform preset side length. These color patches are then seamlessly stitched together along a single direction or multi-row array to ultimately synthesize a complete image file. A direct mapping relationship is maintained between each pixel region and the color value in this image, allowing any system with image reading capabilities to reverse-engineer the original color value sequence and arrangement order by sampling the center pixel of the color patch or parsing the pixel array at a fixed step size. It should be noted that the file format used for the aforementioned color patch image can be a bitmap format, vector format, or other data format that can be parsed by a general image reading interface; this disclosure does not specifically limit this. In practical implementation, the purpose of generating this image is to leverage the advantage of general image formats being widely supported by operating systems and graphics pipelines, allowing palette data to exist independently of a specific project context. This facilitates sharing and transmission between multiple projects or work sessions, reducing redundant configuration costs.

[0090] Optionally, besides stitching the color blocks sequentially along the horizontal direction, the stitched image can also be constructed using a multi-row, multi-column grid layout. Specifically, the system can calculate a near-square combination of row and column parameters based on the total number of color values ​​in the color value set; first, the first N color blocks are arranged in the first row, then subsequent color blocks are arranged sequentially in the second row, until all color values ​​are mapped to the corresponding color blocks. In this grid layout, adjacent color blocks can remain seamlessly aligned, and a specified width of transparent or background color pixel spacing can be inserted between rows and columns to facilitate visual differentiation. It is important to emphasize that regardless of whether linear sequential stitching or matrix grid stitching is used, the core purpose is to assign a unique and fixed image space coordinate to each color value, thereby ensuring that the color value set can be accurately restored through a unified sampling algorithm during the subsequent loading stage. The advantages and disadvantages of different stitching methods mainly lie in the image file size ratio and the convenience of manual verification; the choice can be made flexibly according to the actual application scenario.

[0091] Optionally, the preset side length controls the pixel area size occupied by a single color block in the color block stitched image. Its value can be flexibly set according to the comprehensive requirements of display accuracy, sampling stability, and final image file size in the actual application scenario. For example, if the color palette is mainly used for screen preview or manual visual verification, the preset side length can be set to a smaller value, such as four or eight pixels, to present more color values ​​within a limited display area; if the color palette needs to serve the subsequent automatic sampling and reading process, the preset side length can be set to a larger value, such as sixteen or thirty-two pixels, thereby reducing color reading errors caused by sampling position deviations. Furthermore, the aforementioned preset side length can be specified directly by the user through an interface input box or slider during the color palette construction stage, or it can be automatically deduced by the system based on the total number of color values ​​in the color value set to generate a color block stitched image with a balanced aspect ratio. It should be noted that once the preset side length is determined during the generation stage, each color block should be filled with a solid color within the rectangular area defined by that side length to ensure clear and consistent boundaries between adjacent color blocks.

[0092] Optionally, the path can be specified as the storage location of the stitched image in the file system, designed to support fast reading and engineered reuse across sessions.

[0093] In an optional implementation, the step of obtaining at least one palette color value includes: reading a patchwork image; sampling the patchwork image at preset sampling positions to obtain at least one palette color value. This standardized sampling of the patchwork image based on preset sampling positions not only enables accurate cross-session reuse of palette data but also effectively avoids color value distortion caused by sampling coordinate deviations, improving the consistency and reliability of subsequent color mapping.

[0094] For example, when it is necessary to obtain palette color values, the system can read the generated color patch image and perform pixel sampling on the image according to each preset sampling position. For instance, each color area in the color patch image has a fixed side length. The system can read the pixels located at specified sampling coordinates in each area block by block, collect their color channel values, and synthesize the corresponding color values ​​to obtain at least one palette color value. It should be noted that the preset sampling positions mentioned above can be the center point of each patch, or they can be determined according to other rules based on the correspondence between the side length of the patch and the image resolution. Optionally, this reading operation can load the persistent color patch image to restore the palette color samples that can be used for color mapping.

[0095] Optionally, the above-described operation of reading the color patch image aims to reload the persistent color palette data into system memory for use in subsequent color mapping processes. This color patch image can be a raster image previously generated by color value stitching, where each color patch retains complete color channel information. During reading, the system can parse the file through an image decoding interface to obtain its pixel matrix data; this pixel matrix data exists in memory as a two-dimensional array or a continuous byte stream, with each pixel unit corresponding to a color value in the original color palette. Thus, by encoding the color palette data into a universal image format for storage and reverse reading, not only is cross-project and cross-session data reuse achieved, but users can also directly view and verify the color palette content using the operating system's native image browsing function, without relying on a dedicated project parsing environment. It should be noted that the color patch image targeted by the reading operation can be an uncompressed bitmap format or a lossless compressed portable network graphics format; this disclosure does not limit its specific file encoding method.

[0096] Optionally, the preset sampling position aims to provide standardized sampling coordinates for each stitched color area in the color patch image to ensure consistent color value reproduction. Optionally, considering that the color patch image has already arranged the color values ​​of each palette into regular rectangular color blocks with fixed side lengths during generation, the above-mentioned preset sampling position can be configured as the geometric center region of each stitched color block. In specific implementation, if the pixel side length of a single color block and the initial offset of the image are known, the center sampling point of each color block can be determined one by one through formulaic coordinate calculation. For example, taking the upper left corner of the image as the origin, the horizontal coordinate increment of each center point is calculated sequentially according to the horizontal stitching order. In this way, since the sampling position is fixed in the center region of each color block, even if the edges of the color blocks experience slight pixel smudging or jagged interference due to image compression or format conversion, the pixels in the center region can still maintain high color purity, thereby effectively reducing sampling deviation. It should be noted that the number of preset sampling positions is usually consistent with the number of color values ​​required by the target color palette, with each sampling position corresponding to one target color value. Of course, in cases where color gamuts are similar and need to be merged and categorized, multiple sampling positions can be mapped to the same output color value, and this disclosure does not limit this. In addition, the aforementioned preset sampling positions can be represented using integer pixel coordinates or floating-point normalized coordinates, and their implementation granularity can be flexibly adjusted according to the image resolution.

[0097] Optionally, in addition to the above-mentioned scheme of using the geometric center as the preset sampling position, as a possible implementation method, the preset sampling position can also be set as the upper left vertex, lower right vertex or other feature points with clear spatial definition of each spliced ​​color block. As long as the position follows a consistent mapping rule in both the generation and sampling stages, accurate sampling can be completed.

[0098] In an optional implementation, the step of obtaining the color value set of the constructed target color palette includes: loading a reference image in response to an image loading instruction and drawing the reference image onto the canvas area; reading the color channel value of the pixel where the pointer is located and synthesizing the color value in response to a pointer movement operation on the canvas area; and adding the color value to the color value set of the target color palette in response to a confirmation operation on the canvas area. In this way, by drawing the reference image onto the canvas area and synthesizing the color value in real time in response to pointer movement, a color palette can be quickly and intuitively constructed using existing image resources, significantly reducing the workload of manually configuring color values ​​and improving the intuitiveness of color matching.

[0099] In one implementation, the user clicks a loading control in the front-end interface to issue an image loading command. The system reads a locally stored reference image containing multiple theme colors and draws it completely in the center of the canvas area. The canvas area supports continuous movement of the mouse pointer or stylus. When the pointer slides across the canvas surface, the system captures the values ​​of the red, green, and blue color channels of the pixel where the pointer is currently located at fixed time intervals, merges them into a hexadecimal color value according to high-bit padding rules, and displays the color block corresponding to the current composite color value in real time in the preview area next to the canvas. When the user finds that the pointer is on the desired color, they click the left mouse button to perform a confirmation operation, and the hexadecimal color value is then deduplicated and added to the color value set of the target color palette.

[0100] Optionally, the canvas area is used to display the reference image, responding to pointer movement to show a real-time color picking preview, and receiving confirmation to complete the color value addition. Optionally, the canvas area can be a rectangular planar control in the interactive interface, a semi-transparent layer floating at the top of the interface, or a full-screen image preview window arranged alongside the object selection panel. Its display size dynamically and adaptively scales according to the resolution of the reference image to maintain the image's aspect ratio. When the pixel size of the reference image exceeds the preset display boundary of the canvas area, the system can provide scrollbars or drag-and-drop panning functions within the canvas area, allowing users to fully browse the entire image area. Furthermore, when drawing the reference image, the canvas area can be pixel-by-pixel enlarged according to the user-defined scaling ratio to accurately select the color of a single pixel in a low-resolution image; simultaneously, the background layer of the canvas area can be filled with neutral gray or a checkerboard pattern to reduce the impact of ambient light interference on the user's color judgment. It should be noted that the coordinate mapping mechanism of the canvas area is responsible for accurately converting the pointer's position in the screen coordinate system to the corresponding position in the reference image's texture coordinate system, thereby ensuring the spatial accuracy of subsequent color channel value readings.

[0101] Optionally, in addition to loading external reference images, the canvas area can directly capture and display the real-time rendering frame of the current viewport of the 3D engine, or display the unfolded texture of the currently selected material sphere in the material system, allowing users to directly extract colors from the final rendering effect. In this arrangement, a linked refresh mechanism is established between the canvas area and the 3D preview view; when the user rotates or zooms the model in the 3D preview view, the image in the canvas area updates synchronously. Considering that the rendering frame may contain complex lighting and shadows, as another implementation, the system can extract the basic color channel information and mask the specular and shadow layers before drawing the rendering frame to the canvas area, ensuring that the picked colors are close to the inherent colors of the materials. Similarly, the canvas area can also load color patch images, allowing users to add or remove elements from the saved color palette. In this case, the boundary of each color patch in the canvas area can be overlaid with a dashed grid to help users accurately locate the center sampling point of the color patch to be operated on.

[0102] Optionally, a reference image is used to provide a visual source for extracting color values ​​from the palette. After being loaded, it is drawn and displayed in the canvas area, and color sampling is completed in response to interactive operations.

[0103] Optionally, the reference image can be a digital image file stored in the local working directory, a remote image resource obtained through a network data interface, or a rendered frame image directly extracted from the current 3D project file. Its file format supports various standard encodings, including lossless and lossy compression. During the loading phase, the system parses the file header metadata of the reference image to identify its color space description information. If the image uses a non-linear encoding curve, decoding and conversion are performed first to ensure that the color channel values ​​read subsequently are in a unified linear color space. To ensure consistency between the picked color values ​​and the final voxelization effect, the content theme of the reference image usually matches the artistic style of the target 3D model. For example, when the target 3D model needs to present a natural vegetation scene, the reference image can be an outdoor photograph containing grass, trees, and soil tones; when the target 3D model presents a metallic mechanical style, the reference image can be a scanned image of industrial materials containing rust, paint, and specular highlights. Through the above diverse image sources and content adaptation methods, the color palette construction process can quickly respond to the art setting requirements of different projects, reducing rework and adjustments caused by color deviations in later stages.

[0104] Optionally, color value synthesis is used to extract pixel colors in real time and convert them into codes as the pointer moves, generating color values ​​that can be previewed and stored. Optionally, when the user moves the pointer in the canvas area, the system triggers screen sampling at a fixed period synchronized with the display refresh rate, or at a preset time interval or pointer displacement threshold. The sampling process first maps the pointer's position in the current interface coordinate system to the local texture coordinates corresponding to the reference image, and then reads the values ​​of multiple color channels of the pixel at that coordinate, typically including three components: red, green, and blue. Based on this, the system can extract only the original value of the center pixel directly below the pointer to retain the highest sharpness, or it can take the weighted average of several pixels in the surrounding neighborhood to smooth out random errors caused by single-point noise. After reading, the values ​​of each color channel can be combined into hexadecimal color values ​​through high-bit padding and bitwise operations, or they can be normalized to floating-point values ​​and then saved as a triplet structure. For example, the red, green, and blue channel values ​​of the pixel where the pointer is located are 238, 130, and 98 respectively. The system combines these values ​​to obtain the hexadecimal color value EE8262 and renders the color block in the preview area. This linkage mechanism between instant synthesis and real-time rendering provides users with a fast and intuitive color selection experience.

[0105] Optionally, to avoid unstable color channel value readings or frequent jumps in preview color values ​​caused by high-speed pointer movement, the system can introduce a hysteresis detection mechanism. Specifically, when the pointer's current dwell time exceeds a preset duration threshold (e.g., 200 milliseconds), or the pointer displacement between adjacent sampling frames is less than a preset pixel threshold, the system triggers formal color channel value reading and synthesis. During the high-speed pointer movement, the preview area displays the synthesized color value that last met the stability conditions. Furthermore, the synthesized color value can be simultaneously displayed next to the preview area with its nearest neighbor matching result in the current target color palette, allowing the user to predict the degree of coordination between the color and the existing color palette gamut before confirming its addition. It should be understood that the reading accuracy of color channel values ​​is directly related to the storage bit depth of the reference image. For high bit depth image sources, the system can also perform adaptive quantization truncation on the channel values ​​before synthesis, thereby ensuring compatibility with the storage and rendering pipeline requirements of subsequent low color depth palettes.

[0106] In an optional implementation, the step of obtaining the color value set of the constructed target color palette includes: adding the input color value to the color value set of the target color palette in response to the color value addition operation input through the color picker control. In one implementation, the user triggers the color picker control in the color palette management area of ​​the interactive interface, specifies the target color value in the pop-up color selection window, and clicks confirm. The system appends the input hexadecimal color value to the end of the color value set of the target color palette, and then iterates through the set, comparing the newly added color value with the existing records one by one. If a duplicate color value with the same value is detected, the first record is automatically retained and subsequent duplicates are removed to ensure that the color values ​​in the color palette are not repeated, thereby maintaining the independence and accuracy of each color block in the color patchwork image.

[0107] Optionally, the color picker control is located in the color palette management area of ​​the interactive interface. It receives color value selection instructions to add the input color value to the target color palette's color value set. Optionally, the color picker control can be a floating or fixed embedded independent color picking window in the interactive interface, or a color value input panel integrated into the sidebar. The color picker control can include a hue slider, saturation and brightness selection areas, and a hexadecimal value input box, allowing users to determine the target color value by dragging the slider or manually entering numbers. After the user completes the color value selection and triggers the confirmation action, the color picker control combines the currently selected red, green, and blue channel values ​​into a standard color value string, which is then transmitted to the color palette construction module as the input source for the color value addition operation. It should be noted that the specific visual form of the color picker control is not limited to the above description; it can also be a circular color wheel, a square color gamut selector, or a custom control with an eyedropper tool, as long as it can achieve the function of injecting the user-specified color value into the color value set.

[0108] Optionally, the deduplication process for duplicate color values ​​identifies and removes identical values ​​from the color value set to maintain the uniqueness and cleanliness of color values ​​within the palette. Optionally, the deduplication process for duplicate color values ​​may include iterating through the color value set one by one, matching newly added color values ​​with existing color values, or using a hash table or set data structure to intercept duplicates during the insertion stage. One objective of this embodiment is to avoid redundant records in the palette caused by users unintentionally inputting the same color value multiple times through the color picker via an automated deduplication mechanism. This reduces the computational load during nearest neighbor matching in a perceptually uniform color space and ensures that each color block in the color block mosaic image corresponds to a unique color definition, thereby improving the cleanliness and reliability of palette data during cross-session reuse. It should be noted that the deduplication criterion can not only be strict equality of channel values, but also allow visually nearly identical color values ​​to be considered duplicates and merged within a certain tolerance range. This tolerance threshold can be dynamically adjusted according to specific application scenarios.

[0109] In an optional implementation, the step of determining valid voxels from multiple raster nodes based on the comparison between the nearest distance and a preset distance threshold includes: marking the raster node as a valid voxel when the nearest distance corresponding to the raster node does not exceed the preset distance threshold; and recording the 3D index and spatial coordinates of the valid voxel. This method of filtering voxels by distance threshold and recording the 3D index and spatial coordinates not only ensures fitting accuracy but also facilitates rapid positioning during subsequent block reconstruction and color mapping, effectively improving data organization efficiency and processing consistency.

[0110] In one example, the system traverses the regular 3D grid within the expanded bounding box. For a given grid node, the system queries its nearest distance to the original surface and finds it to be 0.3 times the voxel edge length, which is below a preset threshold (e.g., 1.0 times the voxel edge length). The system then marks this grid node as a valid voxel and records its 3D index (e.g., integer grid indices along the three coordinate axes, 12, 5, and 8) and the spatial coordinates of its center point in the scene's world coordinate system (e.g., 2.4, 1.0, and 1.6 in meters). These records will be used for subsequent precise color sampling from material textures and to support spatial clustering and merging operations of voxels during the tiled mesh reconstruction stage.

[0111] Optionally, the 3D index represents the logical position of a voxel within a regular grid, used for subsequent voxel localization, neighborhood lookup, and block clustering. Optionally, the aforementioned 3D index refers to the integer subscript of a valid voxel along each coordinate axis in the regular 3D grid. It is typically composed of the voxel's sequence number along the horizontal, vertical, and axial axes. For example, a grid node in column 3, row 5, and layer 8 can be denoted as the 3D index (3, 5, 8). This index has a definite mathematical mapping relationship with the voxel's side length and the grid origin. The system can quickly calculate the spatial coordinates of the voxel's center based on the 3D index, and can also directly determine the adjacency relationship or distance level between two voxels in 3D space based on the numerical differences of the 3D index. In the block grid reconstruction stage, the system relies on the 3D index to cluster valid voxels according to their planar direction indices, thereby efficiently identifying adjacent voxel sets in the same planar direction without repeatedly traversing spatial coordinates, significantly reducing the time overhead of block computation. In addition, three-dimensional indexes can also be encoded using linearization methods, such as converting them into one-dimensional integers according to row priority or space-filling curves and storing them in an array structure, so as to achieve compact arrangement in memory and accelerate random access.

[0112] Optionally, spatial coordinates are used to record the position of voxels in the world coordinate system to support subsequent geometric reconstruction, texture sampling, and view frustum clipping.

[0113] Optionally, the aforementioned spatial coordinates refer to the actual position of the effective voxel in the scene's world coordinate system. They are typically taken as the 3D floating-point coordinates of the grid center point or the voxel's geometric center point, with the unit of measurement consistent with the physical scale of the reference object in the scene. These coordinates serve as a bridge between the voxel's abstract representation and the actual geometric reconstruction. During the color assignment stage, the system can back-project the voxel onto the original mesh surface based on the spatial coordinates and obtain color information from the texture image by combining the texture coordinates of the hit triangles. During the block mesh reconstruction stage, the spatial coordinates directly determine the vertex positions of the cube. To ensure coordinate accuracy, the system can use double-precision floating-point numbers to record the spatial coordinates. Especially when the scene's physical scale is large and the voxel's side length is relatively small, double-precision representation can effectively avoid voxel position drift or gap problems caused by floating-point rounding errors. Furthermore, spatial coordinates can be combined with a 3D index to establish a spatial hash table, allowing the system to quickly retrieve the voxel's logical neighborhood using the 3D index and perform precise geometric positioning and view frustum clipping using the spatial coordinates in subsequent processing.

[0114] Optionally, when recording spatial coordinates, the system can also simultaneously save the original nearest distance value corresponding to the voxel and the identification information of the hit triangle, thus forming a composite data structure containing geometric position, distance metric, and topological source. This composite recording method has significant advantages when the voxelization results need to be verified or locally edited. For example, users can quickly trace back to the corresponding area of ​​the original model through the hit triangle identification to perform targeted correction of local voxelization anomalies; while the distance value can be used to generate a voxel field with interior and exterior orientation information, providing signed distance field data for subsequent entity Boolean operations or physical collision detection. It should be noted that the recording of spatial coordinates is not limited to the world coordinate system. In applications involving batch processing of multiple objects or hierarchical scene management, the system can also convert the spatial coordinates to the local object coordinate system for storage, so that when the source model undergoes an overall transformation, the existing voxel data can be directly reused without re-performing voxelization calculations.

[0115] An information processing apparatus according to one embodiment of the present disclosure, such as Figure 3 As shown, the device may include: The first processing module 301 is configured to acquire the mesh data corresponding to the target 3D model and construct a spatial index structure based on the mesh data; The first determining module 302 is configured to determine multiple grid nodes; The second processing module 303 is configured to query the nearest distance from the grid node to the original surface corresponding to the grid data based on the spatial index structure for each grid node; The second determining module 304 is configured to determine effective voxels from multiple grid nodes based on the comparison result between the nearest distance and a preset distance threshold.

[0116] Rendering module 305 is configured to render the target 3D model based on effective voxels.

[0117] In this way, determining valid voxels based on distance queries using a spatial index structure helps reduce the probability of misjudgment in thin-walled and sharp-cornered regions due to discrete sampling, thereby improving the stability of geometric snapping. At the same time, it helps reduce the amount of redundant patch data and lower the rendering load on the graphics processing unit.

[0118] The specific details of each part of the above-mentioned device have been described in detail in the method section of the implementation plan. For any undisclosed details, please refer to the implementation plan of the method section, and therefore will not be repeated here.

[0119] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0120] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.

[0121] The following is a detailed reference. Figure 4 The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present disclosure. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 1201, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1202 or a program loaded from memory 1208 into random access memory (RAM) 1203. The RAM 1203 also stores various programs and data required for the operation of the electronic device. The processor 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0122] Typically, the following devices can be connected to I / O interface 1205: input devices 1206 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1207 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 1208 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1209. Communication device 1209 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.

[0123] In particular, according to one embodiment of this disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, one embodiment of this disclosure includes a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via communication device 1209, or installed from memory 1208, or installed from ROM 1202. When the computer program is executed by processor 1201, it performs the functions defined in the methods described above in various embodiments of this disclosure.

[0124] Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0125] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium after being downloaded over a network. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0126] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0127] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for processing three-dimensional models, characterized in that, The method includes: Obtain the mesh data corresponding to the target 3D model, and construct a spatial index structure based on the mesh data; Define multiple grid nodes; For each of the grid nodes, the nearest distance from the grid node to the original surface corresponding to the grid data is queried based on the spatial index structure; Based on the comparison result between the nearest distance and the preset distance threshold, effective voxels are determined from the plurality of grid nodes; The target 3D model is rendered based on the effective voxels.

2. The method according to claim 1, characterized in that, The step of constructing a spatial index structure based on the grid data includes: A hierarchical bounding volume tree is constructed based on the grid data, serving as the spatial index structure; The method further includes: The preset distance threshold is calculated and determined based on the product of the voxel side length and the preset coefficient, wherein the preset coefficient is used to characterize the distance tolerance between the effective voxel and the original surface.

3. The method according to claim 1, characterized in that, The step of determining multiple grid nodes includes: Calculate the axis-aligned bounding box of the grid data, and extend it outward along the three coordinate axes of the axis-aligned bounding box by a preset distance threshold to obtain the extended bounding box; Within the extended bounding box, a regular three-dimensional grid is established with the voxel side length as the step size, and the center point of the regular three-dimensional grid is determined as the grid node.

4. The method according to claim 2, characterized in that, The method further includes: The voxel side length is calculated and determined based on the physical scale and precision parameters of the reference object in the scene.

5. The method according to claim 1, characterized in that, After determining the effective voxels from the plurality of grid nodes, the method further includes: Obtain the sampled color corresponding to the effective voxel, and obtain at least one color palette value, wherein the color palette value is included in the target color palette; The sampled color and the at least one palette color value are respectively converted to a perceptually uniform color space; In the perceived uniform color space, the distance between the sampled color and the color values ​​of each palette is calculated, and the target color of the effective voxel is determined based on the nearest neighbor matching result of the distance.

6. The method according to claim 1, characterized in that, After determining the effective voxels from the plurality of grid nodes, the method further includes: According to the preset block step size, the effective voxels are divided into at least one rectangular block according to the planar direction index; Within each rectangular block, a cube is generated for the effective voxel, and coplanar face merging is performed on the cube to generate an independent mesh object corresponding to the rectangular block.

7. The method according to claim 6, characterized in that, Before the step of dividing the effective voxels into at least one rectangular block according to a preset block step size by planar indexing, the method further includes: The preset block step size is calculated and determined based on the physical scale and voxel side length of the reference object in the scene.

8. The method according to claim 5, characterized in that, The method further includes: Obtain the set of color values ​​for the constructed target color palette; Each color value is stitched together with color blocks of a preset side length to generate a color block stitched image, wherein each color value is a color value in the color value set; Store the stitched image of the color blocks to the specified path.

9. The method according to claim 8, characterized in that, The step of obtaining the set of color values ​​for the constructed target color palette includes: In response to an image loading command, a reference image is loaded and drawn onto the canvas area; In response to a pointer movement operation on the canvas area, the color channel value of the pixel where the pointer is located is read and the color value is synthesized. In response to a confirmation operation for the canvas area, the color value is added to the color value set of the target palette.

10. An electronic device, characterized in that, It includes a processor and a memory, the processor executing instructions in the memory to implement the method according to any one of claims 1 to 9.