CN-116797486-B - Smoothing method and device for voxel model and electronic equipment
Abstract
The embodiment of the application discloses a smoothing method, a smoothing device and electronic equipment for a voxel model, wherein the method is used for determining coordinate parameters of a first voxel vertex to be subjected to smoothing treatment in the voxel model, calculating coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm, calculating normal parameters of the second voxel vertex according to the coordinate parameters of the second voxel vertex, and replacing the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex without modifying the original framework of the voxel model, and meanwhile enabling the voxel model to have a smoothing and graceful effect.
Inventors
- XIE CHENGHONG
- WANG YAWEI
- GUO ZHAOKUI
- HU GAO
- LI RONG
- MA YUKAI
Assignees
- 北京蓝亚盒子科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20200427
Claims (10)
- 1. A smoothing method for a voxel model, the voxel model constructed by 3D voxels, the method comprising: determining coordinate parameters of a first voxel vertex to be subjected to smoothing treatment in the voxel model; calculating coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm; calculating normal parameters of the second voxel vertex according to the coordinate parameters of the second voxel vertex; Replacing the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex, wherein the coordinate parameters of the first voxel vertex are not modified; smoothing is achieved with the illumination effect by means of the replaced normal parameters, the normal being dependent on the type of voxel object illuminated and the illumination direction corresponding to the normal direction.
- 2. The smoothing method for voxel model as claimed in claim 1, wherein determining coordinate parameters of a first voxel vertex to be smoothed in the voxel model specifically comprises: Identifying edges and corners of the voxel model appearance; and determining the coordinate parameters of the voxel vertexes corresponding to the identified edge and corner as the coordinate parameters of the first voxel vertex to be subjected to smoothing.
- 3. The smoothing method for voxel model as claimed in claim 1, wherein the surface reduction processing is performed on a plurality of voxel surfaces on the voxel model surface before the rendering operation is completed, or the surface reduction processing is performed on a plurality of voxel surfaces on the voxel model surface after the smoothing operation is performed before the rendering operation is completed.
- 4. A smoothing method for voxel model as defined in claim 3, wherein the surface subtraction processing is performed on a plurality of voxel surfaces of the voxel model surface, specifically comprising: Judging whether the included angle between the normals of the adjacent first voxel vertex and the third voxel vertex on the appearance of the voxel model is smaller than an included angle threshold value or not; when the normal angle is smaller than the angle threshold, assuming that one of the first voxel vertex and the third voxel vertex is subtracted, and judging whether the distances between the non-subtracted voxel vertex and each voxel surface with the assumed subtracted voxel vertex are smaller than a distance threshold; and when the distance values are smaller than the distance threshold value, determining to perform subtraction operation on the voxel vertex which is supposed to be subtracted.
- 5. A smoothing method for a voxel model as defined in claim 4, wherein each of the voxel vertices has a calibration weight for the angle threshold and/or the distance threshold, the method further comprising, after replacing a normal parameter of the first voxel vertex with a normal parameter of the second voxel vertex: And reducing the calibration weight of the first voxel vertex and the third voxel vertex relative to the included angle threshold and/or the distance threshold.
- 6. A smoothing method for a voxel model as claimed in claim 3 or 4, wherein the subtracting face processing is performed for a plurality of voxel faces of the voxel model exterior, specifically comprising: Identifying whether a color intersection exists between adjacent voxel surfaces of the appearance of the voxel model; And setting auxiliary voxel surfaces at the color intersection, wherein the included angle between the auxiliary voxel surfaces and each intersected voxel surface is larger than the included angle threshold value.
- 7. The smoothing method for a voxel model of claim 6, wherein after performing a face-down process on a plurality of voxel faces of the voxel model exterior, the method further comprises eliminating the auxiliary voxel face.
- 8. A smoothing apparatus for a voxel model, the voxel model constructed from 3D voxels, the apparatus comprising: A target vertex coordinate determining unit configured to determine coordinate parameters of a first voxel vertex to be subjected to smoothing processing in the voxel model; A smooth vertex coordinate calculation unit configured to calculate coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm; A normal parameter calculation unit configured to calculate a normal parameter of the second voxel vertex from a coordinate parameter of the second voxel vertex; A normal parameter replacement unit configured to replace a normal parameter of the first voxel vertex with a normal parameter of the second voxel vertex, the coordinate parameter of the first voxel vertex not being modified; smoothing is achieved with the illumination effect by means of the replaced normal parameters, the normal being dependent on the type of voxel object illuminated and the illumination direction corresponding to the normal direction.
- 9. An electronic device, comprising: at least one processor, and A memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the method of any of claims 1 to 7.
- 10. A machine-readable storage medium storing executable instructions that, when executed, cause the machine to perform the method of any one of claims 1 to 7.
Description
Smoothing method and device for voxel model and electronic equipment The patent application is a divisional application with the application number 202010347774.7, the application date is 2020, 4 and 27, and the invention name is 'smoothing method, device and electronic equipment for voxel model'. Technical Field The embodiment of the application relates to the technical field of computers, in particular to a smoothing method and device for a voxel model and electronic equipment. Background "Voxels" are the basic units of digital data in three-dimensional space division, voxels are used in the fields of 3D imaging, game design, scientific data, medical imaging, etc., which can be conceptually similar to the basic units of two-dimensional space-pixels, which are used on the image data of two-dimensional computer images. Through 3D voxel editing, 3D voxels can be spliced to construct corresponding scene models, such as various electronic buildings, figures, plants and the like. For example, a game development user can construct various voxel models or scenes in a designed game by editing 3D voxels, and the user only needs to assemble with a simple cube box (i.e. a representation of the 3D voxels), and like placing building blocks, does not need to understand what is the points, lines and faces forming the cube box, does not need to program codes by the user, can reduce the game development threshold, and is oriented to popular creators. Currently, voxel models built with 3D voxels may result in "pixelated" or "mosaic" like visual effects (as shown in fig. 1), and some specialized software built models may not be smooth in visual impression. Therefore, after the voxel model is manufactured by using the voxel editing operation mode, how to make the voxel model smoother without showing mosaic effect without using extra special professional software is a difficult problem to be solved in the industry. Disclosure of Invention In view of this, the embodiments of the present application provide a smoothing method, a device and an electronic apparatus for a voxel model, which are used for at least solving the problem that the smoothing effect of the voxel model achieved by voxel editing in the related art is poor. The embodiment of the application adopts the following technical scheme: the embodiment of the application provides a smoothing method for a voxel model, which comprises the steps of determining coordinate parameters of a first voxel vertex to be subjected to smoothing treatment in the voxel model, calculating coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm, calculating normal parameters of the second voxel vertex according to the coordinate parameters of the second voxel vertex, and replacing the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex. The embodiment of the application also provides a smoothing device for the voxel model, which comprises a target vertex coordinate determining unit, a smoothing vertex coordinate calculating unit, a normal parameter calculating unit and a normal parameter replacing unit, wherein the target vertex coordinate determining unit is configured to determine coordinate parameters of a first voxel vertex to be subjected to smoothing processing in the voxel model, the smoothing vertex coordinate calculating unit is configured to calculate coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm, the normal parameter calculating unit is configured to calculate normal parameters of the second voxel vertex according to the coordinate parameters of the second voxel vertex, and the normal parameter replacing unit is configured to replace the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex. The embodiment of the application also provides electronic equipment, which comprises at least one processor and a memory, wherein the memory stores instructions which, when executed by the at least one processor, cause the at least one processor to execute the method. Embodiments of the present application also provide a machine-readable storage medium storing executable instructions that, when executed, cause the machine to perform a method as described above The above at least one technical scheme adopted by the embodiment of the application can achieve the following beneficial effects: the smoothing effect is skillfully realized by changing the normal and illumination, the original architecture of the voxel model is not changed, and the follow-up operation of the voxel model is facilitated. Drawings The accompanying drawings, which are included to provide a further understanding of embodiments of the application and are incorporated in and constitute a part of this specificati