Three-dimensional model texture editing method and device, electronic equipment and storage medium

By rendering and updating the 3D model, identifying visible films, and pixel modifications to the texture image to be processed, the problem of the existing technology that cannot be quickly and intuitively adjusted the three-dimensional model texture is solved, and efficient texture editing is achieved.

CN119600244APending Publication Date: 2025-03-11THE QUARTERMASTER RES INST OF THE GENERAL LOGISTICS DEPT OF THE CPLA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411676363.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The prior art cannot quickly and intuitively adjust the texture of a certain area on a three-dimensional model, resulting in the editing process being time-consuming and unintuitive.

Method used

By rendering the three-dimensional model, a two-dimensional image is obtained, and the two-dimensional image is updated according to the texture patch to be processed, the visible patch is determined, and then pixel modifications are made to the texture image to be processed, realizing texture editing of the three-dimensional model.

Benefits of technology

It realizes rapid and intuitive adjustment of the texture of a certain area on the three-dimensional model, avoids time-consuming operation of the pixels of the original texture image and improves editing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600244A_ABST
    Figure CN119600244A_ABST
Patent Text Reader

Abstract

The invention provides a three-dimensional model texture editing method and device, electronic equipment and a storage medium, and the method comprises the steps: rendering a three-dimensional model to obtain a two-dimensional diagram, and updating the two-dimensional diagram according to a to-be-processed texture patch in the three-dimensional model to obtain a to-be-processed texture image; calculating a preset number of pixel points in the triangular region on the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point; determining at least one visible patch in the preset number of patches according to the distance value and the depth value; and performing pixel modification on the to-be-processed texture image to obtain a target to-be-processed texture image, and modifying at least one visible patch in the three-dimensional model according to the target to-be-processed texture image to obtain a target three-dimensional model. According to the method, the two-dimensional diagram of the three-dimensional model is modified, so that the visible surface patch in the three-dimensional model is modified, and the purpose of adjusting the texture of a certain area on the three-dimensional model is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of three-dimensional model editing, and in particular to a three-dimensional model texture editing method, device, electronic equipment and storage medium. Background Art

[0002] With the development of science and technology, 3D models have broad application prospects in various fields. In the field of computer graphics, the texture display of 3D models is usually completed by reading the original texture image of the model, the 3D vertices and their texture coordinates, and then mapping the pixels in the texture image to each face of the model according to the texture coordinates. Since the polygons formed by the vertex coordinates of the face and the polygons of the texture coordinates are not necessarily consistent in shape, texture stretching will occur during the mapping process.

[0003] In the prior art, in order to reduce the texture stretching phenomenon caused by shape inconsistency, the original texture map of the 3D model is generally generated according to the following steps: first, all the facets of the model are segmented and clustered according to the geometric relationship, and then small textures are generated for the sets of multiple facets after clustering, and many fragmented textures are merged into a large texture map. However, for the 3D model texture generated by the above technology, if you want to adjust the texture of a certain area on the 3D model, it is very time-consuming and unintuitive for practitioners to only perform pixel operations on the original texture image to complete the editing.

[0004] Therefore, there is an urgent need to propose a three-dimensional model texture editing method, device, electronic device and storage medium to solve the technical problem in the prior art that the texture of a certain area on the three-dimensional model cannot be adjusted quickly and intuitively. Summary of the invention

[0005] In view of this, it is necessary to provide a 3D model texture editing method, device, electronic device and storage medium to solve the technical problem in the prior art that the texture of a certain area on a 3D model cannot be adjusted quickly and intuitively.

[0006] In one aspect, the present invention provides a 3D model texture editing method, comprising:

[0007] Rendering the three-dimensional model to obtain a two-dimensional image, and updating the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain a texture image to be processed; the three-dimensional model includes a preset number of patches;

[0008] Calculate a preset number of pixel points in the triangular area on the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point;

[0009] Determine at least one visible face among the preset number of faces according to the distance value and the depth value;

[0010] Pixel modification is performed on the texture image to be processed to obtain a target texture image to be processed, and the at least one visible face in the three-dimensional model is modified according to the target texture image to be processed to obtain a target three-dimensional model.

[0011] In some possible implementations, rendering the three-dimensional model to obtain a two-dimensional image includes:

[0012] Obtaining the preset number of patches in the three-dimensional model, vertex coordinates of a preset number of three-dimensional vertices corresponding to each patch, texture coordinates corresponding to each three-dimensional vertex, and a preset number of original texture maps;

[0013] The three-dimensional model is rendered according to the preset number of facets, the vertex coordinates, the texture coordinates and the preset number of original texture maps to obtain a two-dimensional image.

[0014] In some possible implementations, updating the two-dimensional image according to the texture patch to be processed in the three-dimensional model to obtain the texture image to be processed includes:

[0015] Determining a texture patch to be processed in the three-dimensional model according to the vertex coordinates and the texture coordinates;

[0016] According to the position of the texture patch to be processed in the three-dimensional model, the viewing angle of the camera in the rendering scene is changed to obtain an image of the texture patch to be processed in a frontal viewing angle;

[0017] The two-dimensional image is updated according to the image to obtain a texture image to be processed.

[0018] In some possible implementations, calculating a preset number of pixel points in a triangular area on the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point includes:

[0019] Determining a first change relationship according to the three-dimensional coordinates of the three-dimensional model and the pixel coordinates of the texture image to be processed;

[0020] Determining a second change relationship according to the pixel coordinates of the original texture image and the three-dimensional coordinates of the three-dimensional model;

[0021] Determine a triangular area according to vertex coordinates of three-dimensional vertices of the texture image to be processed in the three-dimensional model;

[0022] Performing a two-dimensional transformation on a preset number of pixel points in the triangular area of ​​the texture image to be processed according to the first change relationship to obtain pixel point coordinates corresponding to each pixel point;

[0023] Performing a three-dimensional transformation on the preset number of pixel points according to the second change relationship to obtain three-dimensional pixel point coordinates corresponding to each pixel point;

[0024] The distance to the center of the camera in the rendering scene is calculated according to the coordinates of all pixel points of the preset number of pixel points and the coordinates of all three-dimensional pixel points to obtain the depth value and distance value corresponding to each pixel point.

[0025] In some possible implementations, calculating the distance to the center of the camera in the rendered scene according to the coordinates of all pixel points and all three-dimensional pixel points of the preset number of pixel points to obtain the depth value and distance value corresponding to each pixel point includes:

[0026] Calculate the distance from the pixel coordinates corresponding to each pixel to the center of the camera in the rendering scene to obtain a depth value corresponding to each pixel;

[0027] The distance from the three-dimensional pixel point coordinates corresponding to each pixel point to the center of the camera in the rendering scene is calculated to obtain the distance value corresponding to each pixel point.

[0028] In some possible implementations, the at least one visible face includes a completely visible face and a partial region visible face;

[0029] The step of determining at least one visible face among the preset number of faces according to the distance value and the depth value includes:

[0030] Determine a pixel whose depth value is less than a preset threshold as a visible pixel; the depth value of the visible pixel is equal to the distance value;

[0031] Each of the face patches is judged respectively, and when all the pixels in the face patch are the visible pixels, the face patch is determined to be a completely visible face patch;

[0032] When some of the pixels of all the pixels of the patch are the visible pixels, the patch is determined as a partial-area visible patch.

[0033] In some possible implementations, the modifying the at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain the target three-dimensional model includes:

[0034] Performing a three-dimensional transformation on the preset number of pixel points in the triangular area of ​​the preset number of original texture images according to the second change relationship to obtain target three-dimensional pixel point coordinates corresponding to each pixel point in the three-dimensional model;

[0035] Performing a two-dimensional transformation on the target three-dimensional pixel point coordinates of each pixel point in the triangular area in the three-dimensional model according to the first change relationship to obtain target texture coordinates corresponding to each pixel point in the target texture image to be processed;

[0036] Determine the pixel points corresponding to each target texture coordinate to obtain the preset number of visible target texture coordinates where the pixel points are visible pixels;

[0037] According to the pixel values ​​of the preset number of visible target texture coordinates, the corresponding pixel points in the corresponding original texture map are modified to obtain a target three-dimensional model.

[0038] On the other hand, the present invention also provides a 3D model texture editing device, comprising:

[0039] A model rendering module, used to render the three-dimensional model to obtain a two-dimensional image, and update the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain the texture image to be processed; the three-dimensional model includes a preset number of patches;

[0040] A pixel point calculation module, used to calculate a preset number of pixel points in the triangular area on the texture image to be processed, and obtain a depth value and a distance value corresponding to each pixel point;

[0041] A patch determination module, configured to determine at least one visible patch among the preset number of patches according to the distance value and the depth value;

[0042] The model modification module is used to modify the pixels of the texture image to be processed to obtain a target texture image to be processed, and to modify the at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain a target three-dimensional model.

[0043] On the other hand, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the various steps of the above-mentioned three-dimensional model texture editing method embodiment.

[0044] On the other hand, an embodiment of the present invention discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various steps of the above-mentioned three-dimensional model texture editing method embodiment are implemented.

[0045] The beneficial effect of adopting the above-mentioned embodiment is that the 3D model texture editing method provided by the present invention can obtain a 2D image by rendering the 3D model, so that the texture patch to be processed can be determined in the 2D image, and then the visible patches among all patches can be determined for the texture patch to be processed, so as to prevent the textures of other patches from being modified by mistake when the patches are modified. Furthermore, by modifying the pixels of the texture image to be processed, a target texture image to be processed can be obtained, and then the visible patches in the 3D model can be modified by the target texture image to be processed, so as to obtain the edited target 3D model, and the purpose of adjusting the texture of a certain area on the 3D model is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 A schematic flow chart of an embodiment of a 3D model texture editing method provided by the present invention;

[0048] Figure 2 For the present invention Figure 1 A schematic flow chart of an embodiment of step S102;

[0049] Figure 3 For the present invention Figure 1 A schematic flow chart of an embodiment of step S104;

[0050] Figure 4 A schematic diagram of the structure of an embodiment of a 3D model texture editing device provided by the present invention;

[0051] Figure 5 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0052] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0053] Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor systems and / or microcontroller systems.

[0054] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0055] The embodiments of the present invention provide a 3D model texture editing method, device, electronic device and storage medium, which are described below respectively.

[0056] Figure 1 A schematic flow chart of an embodiment of a 3D model texture editing method provided by the present invention is shown in FIG. Figure 1 As shown, the 3D model texture editing method includes:

[0057] S101, rendering the three-dimensional model to obtain a two-dimensional image, and updating the two-dimensional image according to the texture facets to be processed in the three-dimensional model to obtain the texture image to be processed; the three-dimensional model includes a preset number of facets;

[0058] S102, calculating a preset number of pixel points in the triangular area of ​​the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point;

[0059] S103, determining at least one visible face among a preset number of faces according to the distance value and the depth value;

[0060] S104: modify pixels of the texture image to be processed to obtain a target texture image to be processed, and modify at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain a target three-dimensional model.

[0061] Compared with the prior art, the 3D model texture editing method provided by the embodiment of the present invention renders the 3D model to obtain a 2D image, thereby determining the texture patch to be processed in the 2D image, and then determining the visible patches among all patches for the texture patch to be processed, thereby preventing the textures of other patches from being modified by mistake when the patches are modified. Furthermore, by modifying the pixels of the texture image to be processed, a target texture image to be processed can be obtained, and then the visible patches in the 3D model can be modified by the target texture image to be processed, thereby obtaining the edited target 3D model, thereby achieving the purpose of adjusting the texture of a certain area on the 3D model.

[0062] In a specific embodiment of the present invention, it can be applied to a computer, which may include a human-computer interaction input device, a display terminal, a memory, a processor, a computer program P1 stored in the memory and executable on the processor, and an image editing program P2 executable on the processor. The computer program P1 can read the data of each facet in the three-dimensional model and render the three-dimensional model. The image editing program P2 can edit the texture image to be processed to obtain a modified target texture image to be processed.

[0063] In some embodiments of the present invention, step S101 includes:

[0064] Obtain a preset number of patches in the three-dimensional model, vertex coordinates of a preset number of three-dimensional vertices corresponding to each patch, texture coordinates corresponding to each three-dimensional vertex, and a preset number of original texture maps;

[0065] The three-dimensional model is rendered according to a preset number of facets, vertex coordinates, texture coordinates and a preset number of original texture maps to obtain a two-dimensional image.

[0066] In a specific embodiment of the present invention, a three-dimensional model can be input into a computer program P1, and the computer program P1 can read a preset number of facets in the three-dimensional model, a preset number of three-dimensional vertices of each facet, the vertex coordinates of each three-dimensional vertex, the texture coordinates corresponding to each three-dimensional vertex, and a preset number of original texture maps of the three-dimensional model. The computer program P1 can render the preset number of facets, the preset number of three-dimensional vertices, the vertex coordinates of each three-dimensional vertex, the texture coordinates corresponding to each three-dimensional vertex, and the preset number of original texture maps of the three-dimensional model through GPU rendering technology, load the three-dimensional model into a rendering scene, and display it on a display terminal, and the display result is a two-dimensional image.

[0067] In some embodiments of the present invention, step S101 includes:

[0068] Determine the texture patch to be processed in the three-dimensional model according to the vertex coordinates and the texture coordinates;

[0069] According to the position of the texture patch to be processed in the three-dimensional model, the viewing angle of the camera in the rendering scene is changed to obtain an image of the texture patch to be processed in a normal viewing angle;

[0070] The two-dimensional image is updated according to the image to obtain a texture image to be processed.

[0071] In a specific embodiment of the present invention, the original texture map to be processed can be determined according to actual needs, and then the three-dimensional vertices of the original texture map in the three-dimensional model can be determined, which can be multiple three-dimensional vertices, so that the texture coordinates corresponding to each three-dimensional vertex can be determined, and then the texture facets to be processed that need to be processed can be determined from a preset number of facets according to the texture coordinates. Then, according to the position of the texture facets to be processed in the three-dimensional model, the position of the texture facets to be processed in the rendering scene can be determined, and the camera operator can be used to translate or rotate the camera in the rendering scene, and the camera is set to the perspective of facing the texture facets to be processed, so that the image of the texture facets to be processed in the camera's perspective can be obtained, and then the two-dimensional map can be updated according to the image to obtain the texture image to be processed.

[0072] In some embodiments of the present invention, Figure 2 As shown, step S102 includes:

[0073] S201, determining a first change relationship according to the three-dimensional coordinates of the three-dimensional model and the pixel coordinates of the texture image to be processed;

[0074] S202, determining a second change relationship according to the pixel coordinates of the original texture image and the three-dimensional coordinates of the three-dimensional model;

[0075] S203, determining a triangular area according to vertex coordinates of three-dimensional vertices of the texture image to be processed in the three-dimensional model;

[0076] S204, performing a two-dimensional transformation on a preset number of pixel points in the triangular area of ​​the texture image to be processed according to the first change relationship to obtain pixel point coordinates corresponding to each pixel point;

[0077] S205, performing a three-dimensional transformation on a preset number of pixel points according to the second change relationship to obtain the three-dimensional pixel point coordinates corresponding to each pixel point;

[0078] S206 , calculating the distance to the center of the camera in the rendering scene according to the coordinates of all pixel points of a preset number of pixel points and the coordinates of all three-dimensional pixel points, to obtain a depth value and a distance value corresponding to each pixel point.

[0079] In a specific embodiment of the present invention, the first change relationship can be determined according to the three-dimensional coordinates of the three-dimensional model and the pixel coordinates of the texture image to be processed. For example, if the vertex coordinates of the three-dimensional vertices of any visible face in the scene are At (x t ,y t ,z t ), the vertex coordinates correspond to the pixel coordinates of a point on the texture image to be processed as T t (u t ,v t ), then the first change relationship between the vertex coordinates of the patch and the pixel coordinates on the two-dimensional texture image to be processed is shown in formula (1):

[0080] T t =M3*M2*M1*A t (1)

[0081] Where M1 is the model view matrix, M2 is the projection matrix, and M3 is the viewport transformation matrix.

[0082] The second change relationship is determined based on the pixel coordinates of the original texture map and the three-dimensional coordinates of the three-dimensional model. For example, the three three-dimensional vertices in the patch are A(x0, y0, z0), B(x1, y1, z1), and C(x2, y2, z2). The texture coordinates corresponding to the original texture map are l(u0, v0), m(u1, v1), and n(u2, v2). The rendering process will use the triangular area determined by the three texture coordinates for texture mapping. The coordinates of a pixel point k(u0, v0) in the triangular area are k(u1, v1), and n(u2, v2). k, v k ), based on the three 3D vertices, a point K(x k ,y k ,z k ), the second change relationship is shown in formula (2):

[0083]

[0084] Where M t is the calculated rotation and scaling parameter matrix, N t is the translation parameter matrix.

[0085] During the rendering of the 3D model, the obstructed patches that are far from the camera will be cut out according to the depth values ​​corresponding to the pixels on the texture image to be processed. The specific process includes: the triangular area can be determined according to the three 3D vertices in the rendering process, and then all the pixels of the triangular area of ​​the texture image to be processed can be transformed in two dimensions according to formula (1), and then the pixel coordinates corresponding to each pixel can be obtained. The pixel coordinates corresponding to each pixel can also be transformed in three dimensions according to formula (2) to obtain the three-dimensional pixel coordinates corresponding to each pixel, so that the distance to the camera center in the rendering scene can be calculated according to the pixel coordinates corresponding to each pixel and all the three-dimensional pixel coordinates, so as to calculate the depth value and distance value corresponding to each pixel.

[0086] In some embodiments of the present invention, the distance to the center of the camera in the rendered scene is calculated according to the coordinates of all pixel points of a preset number of pixel points and the coordinates of all three-dimensional pixel points to obtain the depth value and distance value corresponding to each pixel point, including:

[0087] The distance from the pixel coordinates of each pixel to the center of the camera in the rendered scene is calculated to obtain the depth value corresponding to each pixel.

[0088] The distance from the three-dimensional pixel coordinates corresponding to each pixel to the center of the camera in the rendered scene is calculated to obtain the distance value corresponding to each pixel.

[0089] In a specific embodiment of the present invention, during rendering, a pixel point on the texture image to be processed is a three-dimensional point T p (x p ,y p ,z p ) is obtained through viewport transformation, the point T p The distance L1 from the center point of the camera is the depth value corresponding to the pixel point. That is, after obtaining the pixel coordinates corresponding to each pixel point, the pixel coordinate point T can be calculated. p The distance L1 from the center of the camera in the rendered scene is the depth value of the corresponding pixel point; the three-dimensional pixel coordinates T corresponding to the three-dimensional vertex in any facet in the triangle area can also be obtained. c After that, calculate the coordinates of the three-dimensional pixel point T c The distance L2 from the center of the camera in the rendered scene is a distance value, so that the distance value corresponding to each pixel point can be obtained.

[0090] In some embodiments of the present invention, the at least one visible face includes a completely visible face and a partially visible face; step S103 includes:

[0091] Determine pixels whose depth values ​​are less than a preset threshold as visible pixels; the depth value of the visible pixel is equal to the distance value;

[0092] Each patch is judged separately, and when all pixels in the patch are visible pixels, the patch is determined to be a completely visible patch;

[0093] When some of the pixels in all the pixels of the patch are visible pixels, the patch is determined as a partially visible patch.

[0094] In a specific embodiment of the present invention, the visible face may include a completely visible face and a partially visible face; the completely visible face is represented by all pixels in the face being in the triangular region, which can be viewed on the texture image to be processed, and the partially visible face is represented by a part of the pixels in the face being in the triangular region, and a part being different, which can be viewed on the texture image to be processed. For example, when taking a photo of a house, a photo of the house can be obtained according to the shooting angle, then the face of the house displayed in the photo is a visible face, and the face of the house not in the photo is an invisible face. If a wall is half in the photo and half on the back and not displayed in the photo, then the face of the wall is a partially visible face. The visible face can be determined according to the calculated depth value of each pixel in the triangular region to cut out the blocked face that is far from the camera. Among them, the depth value of each pixel can be judged, and the pixel with a depth value less than a preset threshold is determined as a visible pixel, and because the distance from each pixel to the camera is constant, when the pixel is a visible pixel, the depth value of the pixel is equal to the distance value, and when the pixel is an invisible pixel, the depth value is zero. After all the pixels in the triangular area are judged, the patch where all the pixels are visible pixels can be determined as a completely visible patch, and the patch where some of the pixels in the patch are visible pixels can be determined as a partially visible patch.

[0095] Furthermore, after the calculation of the pixel points on the texture image to be processed is completed, the texture in the texture image to be processed can be edited and modified through the image editing program P2 according to actual needs, so as to obtain the target texture image to be processed. The specific editing process and content are not limited in this embodiment of the present invention.

[0096] In some embodiments of the present invention, Figure 3 As shown, step S104 includes:

[0097] S301, performing three-dimensional transformation on a preset number of pixel points in a triangular area of ​​a preset number of original texture images according to a second change relationship to obtain target three-dimensional pixel point coordinates corresponding to each pixel point in the three-dimensional model;

[0098] S302, performing a two-dimensional transformation on the target three-dimensional pixel point coordinates of each pixel point in the triangular area of ​​the three-dimensional model according to the first change relationship to obtain the target texture coordinates corresponding to each pixel point in the target texture image to be processed;

[0099] S303, judging the pixel points corresponding to each target texture coordinate, and obtaining the pixel points as the preset number of visible pixel points and visible target texture coordinates;

[0100] S304 , modify corresponding pixel points in the corresponding original texture map according to the pixel values ​​of a preset number of visible target texture coordinates to obtain a target three-dimensional model.

[0101] In a specific embodiment of the present invention, after the texture image to be processed is edited, the three-dimensional model can be modified according to the obtained target texture image to be processed to obtain the target three-dimensional model. The specific process includes: performing a three-dimensional transformation on a preset number of pixel points of the original texture image of the three-dimensional model in the triangle area according to formula (2) to obtain the target three-dimensional pixel point coordinates corresponding to each pixel point, so that the target three-dimensional pixel point coordinates corresponding to each pixel point can be converted into two dimensions according to formula (1) to obtain the target texture coordinates corresponding to each pixel point, thereby realizing the three-dimensional transformation from the original texture image to the three-dimensional model and the two-dimensional transformation from the three-dimensional model to the target texture image to be processed, and all the target texture coordinates can be converted into two dimensions. All pixel points of the target are judged to determine whether there are visible pixel points. If so, all pixel points that are visible pixel points can be obtained, that is, a preset number of visible target texture coordinates. The pixel values ​​of corresponding pixel points in the corresponding original texture map of the three-dimensional model can be modified according to the pixel values ​​of the preset number of visible target texture coordinates. When the pixel values ​​of the preset number of visible target texture coordinates in the original texture map of the three-dimensional model are all modified, the texture modification task of a face patch is completed. All affected faces can be processed in turn through the above process, and the modified values ​​of the pixels in the target texture image to be processed can be fully mapped to the original texture map of the three-dimensional model, so as to obtain the modified target three-dimensional model.

[0102] Since the value of the texture coordinates is not an integer, the pixel value needs to be calculated by interpolation. The non-integer image interpolation method can be explained as follows: when the pixel coordinates are not integers, it is necessary to round down and round down from the row and column dimensions respectively, and take the pixel points with these four integer coordinate values ​​to perform certain interpolation operations to obtain the pixel value of the non-integer position.

[0103] In order to better implement the 3D model texture editing method in the embodiment of the present invention, based on the 3D model texture editing method, the embodiment of the present invention also provides a 3D model texture editing device, such as Figure 4 As shown, the 3D model texture editing device comprises:

[0104] The model rendering module 401 is used to render the three-dimensional model to obtain a two-dimensional image, and to update the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain the texture image to be processed; the three-dimensional model includes a preset number of patches;

[0105] A pixel calculation module 402 is used to calculate a preset number of pixel points in a triangular area on the texture image to be processed, and obtain a depth value and a distance value corresponding to each pixel point;

[0106] A patch determination module 403 is used to determine at least one visible patch among a preset number of patches according to the distance value and the depth value;

[0107] The model modification module 404 is used to modify pixels of the texture image to be processed to obtain a target texture image to be processed, and to modify at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain a target three-dimensional model.

[0108] The three-dimensional model texture editing device provided in the above embodiment can implement the technical solution described in the above three-dimensional model texture editing method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above three-dimensional model texture editing method embodiment, which will not be repeated here.

[0109] like Figure 5 As shown, the present invention also provides an electronic device 500. The electronic device 500 includes a processor 501, a memory 502 and a display 503. Figure 5 Only some components of the electronic device 500 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0110] In some embodiments, the memory 502 may be an internal storage unit of the electronic device 500, such as a hard disk or memory of the electronic device 500. In other embodiments, the memory 502 may also be an external storage device of the electronic device 500, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 500.

[0111] Furthermore, the memory 502 may include both an internal storage unit of the electronic device 500 and an external storage device. The memory 502 is used to store application software installed in the electronic device 500 and various data.

[0112] In some embodiments, the processor 501 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 502, such as the three-dimensional model texture editing method of the present invention.

[0113] In some embodiments, the display 503 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 503 is used to display information on the electronic device 500 and to display a visual user interface. The components 501-503 of the electronic device 500 communicate with each other via a system bus.

[0114] In some embodiments of the present invention, when the processor 501 executes the 3D model texture editing program in the memory 502, the following steps may be implemented:

[0115] Rendering the three-dimensional model to obtain a two-dimensional image, and updating the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain the texture image to be processed; the three-dimensional model includes a preset number of patches;

[0116] Calculate a preset number of pixel points in the triangular area of ​​the texture image to be processed to obtain the depth value and distance value corresponding to each pixel point;

[0117] Determine at least one visible face among a preset number of faces according to the distance value and the depth value;

[0118] Pixel modification is performed on the texture image to be processed to obtain a target texture image to be processed, and at least one visible face in the three-dimensional model is modified according to the target texture image to be processed to obtain a target three-dimensional model.

[0119] It should be understood that: when the processor 501 executes the three-dimensional model texture editing program in the memory 502, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0120] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 500 mentioned, and the electronic device 500 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 500 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0121] Accordingly, an embodiment of the present application also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, the three-dimensional model texture editing method steps or functions provided in the above-mentioned method embodiments can be implemented.

[0122] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0123] The three-dimensional model texture editing method, device, electronic device and storage medium provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A 3D model texture editing method, characterized in that: include: Rendering the three-dimensional model to obtain a two-dimensional image, and updating the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain a texture image to be processed; the three-dimensional model includes a preset number of patches; Calculate a preset number of pixel points in the triangular area on the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point; Determine at least one visible face among the preset number of faces according to the distance value and the depth value; Pixel modification is performed on the texture image to be processed to obtain a target texture image to be processed, and the at least one visible face in the three-dimensional model is modified according to the target texture image to be processed to obtain a target three-dimensional model.

2. The 3D model texture editing method according to claim 1, characterized in that: The three-dimensional model is rendered to obtain a two-dimensional image, including: Obtaining the preset number of patches in the three-dimensional model, vertex coordinates of a preset number of three-dimensional vertices corresponding to each patch, texture coordinates corresponding to each three-dimensional vertex, and a preset number of original texture maps; The three-dimensional model is rendered according to the preset number of facets, the vertex coordinates, the texture coordinates and the preset number of original texture maps to obtain a two-dimensional image.

3. The 3D model texture editing method according to claim 2, characterized in that: The updating of the two-dimensional image according to the texture patch to be processed in the three-dimensional model to obtain the texture image to be processed includes: Determining a texture patch to be processed in the three-dimensional model according to the vertex coordinates and the texture coordinates; According to the position of the texture patch to be processed in the three-dimensional model, the viewing angle of the camera in the rendering scene is changed to obtain an image of the texture patch to be processed in a frontal viewing angle; The two-dimensional image is updated according to the image to obtain a texture image to be processed.

4. The 3D model texture editing method according to claim 2, characterized in that: The step of calculating a preset number of pixel points in a triangular area on the texture image to be processed to obtain a depth value and a distance value corresponding to each pixel point includes: Determining a first change relationship according to the three-dimensional coordinates of the three-dimensional model and the pixel coordinates of the texture image to be processed; Determining a second change relationship according to the pixel coordinates of the original texture image and the three-dimensional coordinates of the three-dimensional model; Determine a triangular area according to vertex coordinates of three-dimensional vertices of the texture image to be processed in the three-dimensional model; Performing a two-dimensional transformation on a preset number of pixel points in the triangular area of ​​the texture image to be processed according to the first change relationship to obtain pixel point coordinates corresponding to each pixel point; Performing a three-dimensional transformation on the preset number of pixel points according to the second change relationship to obtain three-dimensional pixel point coordinates corresponding to each pixel point; The distance to the center of the camera in the rendering scene is calculated according to the coordinates of all pixel points of the preset number of pixel points and the coordinates of all three-dimensional pixel points to obtain the depth value and distance value corresponding to each pixel point.

5. The 3D model texture editing method according to claim 4, characterized in that: The calculating the distance to the center of the camera in the rendered scene according to the coordinates of all pixel points and all three-dimensional pixel points of the preset number of pixel points to obtain the depth value and distance value corresponding to each pixel point includes: Calculate the distance from the pixel coordinates corresponding to each pixel to the center of the camera in the rendering scene to obtain a depth value corresponding to each pixel; The distance from the three-dimensional pixel point coordinates corresponding to each pixel point to the center of the camera in the rendering scene is calculated to obtain the distance value corresponding to each pixel point.

6. The 3D model texture editing method according to claim 4, characterized in that: The at least one visible face comprises a completely visible face and a partial area visible face; The step of determining at least one visible face among the preset number of faces according to the distance value and the depth value includes: Determine a pixel whose depth value is less than a preset threshold as a visible pixel; the depth value of the visible pixel is equal to the distance value; Each of the face patches is judged respectively, and when all the pixels in the face patch are the visible pixels, the face patch is determined to be a completely visible face patch; When some of the pixels of all the pixels of the patch are the visible pixels, the patch is determined as a partial-area visible patch.

7. The 3D model texture editing method according to claim 6, characterized in that: The step of modifying the at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain a target three-dimensional model includes: Performing a three-dimensional transformation on the preset number of pixel points in the triangular area of ​​the preset number of original texture images according to the second change relationship to obtain target three-dimensional pixel point coordinates corresponding to each pixel point in the three-dimensional model; Performing a two-dimensional transformation on the target three-dimensional pixel point coordinates of each pixel point in the triangular area in the three-dimensional model according to the first change relationship to obtain target texture coordinates corresponding to each pixel point in the target texture image to be processed; Determine the pixel points corresponding to each target texture coordinate to obtain the preset number of visible target texture coordinates where the pixel points are visible pixels; According to the pixel values ​​of the preset number of visible target texture coordinates, the corresponding pixel points in the corresponding original texture map are modified to obtain a target three-dimensional model.

8. A 3D model texture editing device, characterized in that: include: A model rendering module, used to render the three-dimensional model to obtain a two-dimensional image, and update the two-dimensional image according to the texture patches to be processed in the three-dimensional model to obtain the texture image to be processed; the three-dimensional model includes a preset number of patches; A pixel point calculation module, used to calculate a preset number of pixel points in the triangular area on the texture image to be processed, and obtain a depth value and a distance value corresponding to each pixel point; A patch determination module, configured to determine at least one visible patch among the preset number of patches according to the distance value and the depth value; The model modification module is used to modify the pixels of the texture image to be processed to obtain a target texture image to be processed, and to modify the at least one visible face in the three-dimensional model according to the target texture image to be processed to obtain a target three-dimensional model.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the three-dimensional model texture editing method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the three-dimensional model texture editing method according to any one of claims 1 to 7 are implemented.