UV map using weight painting

A method, computer system, and a computer program product for projecting a 3D model defined by x, y, z coordinates onto the surface of a 2D image defined by u, v coordinates is provided. The present invention may include receiving a 3D model having a plurality of polygons, wherein certain edges are marked as seams. The present invention may include receiving input from a user, wherein the input comprises painting one or more parts of the 3D model in different colors, wherein the colors correspond with a weight of the area painted. The present invention may include unwrapping, by a processor, a 2D texture from the 3D model using a projection algorithm. The present invention may include generating a rectangular boundary around each island. The present invention may include scaling each island according to a gradient score.

BACKGROUND

The present invention relates generally to the field of computing, and more particularly to automatic partitioning of UV maps based on weight painting.

UV mapping may be a three-dimensional modeling process of projecting a two-dimensional image onto the surface of a three-dimensional model to give the two-dimensional image color and/or texture. The “U” and the “V” of “UV” may refer to the horizontal and vertical axes, respectively, of the two-dimensional space, as X, Y, and Z may already be used in a three-dimensional space. Three-dimensional modeling and/or texturing software may provide an automated process to unwrap a three-dimensional model.

SUMMARY

Embodiments of the present invention disclose a method, computer system, and a computer program product for projecting a 3D model defined by x, y, z coordinates onto the surface of a 2D image defined by u, v coordinates is provided. The present invention may include receiving a 3D model having a plurality of polygons, wherein certain edges are marked as seams. The present invention may include receiving input from a user, wherein the input comprises painting one or more parts of the 3D model in different colors, wherein the colors correspond with a weight of the area painted. The present invention may include unwrapping, by a processor, a 2D texture from the 3D model using a projection algorithm. The present invention may include generating a rectangular boundary around each island. The present invention may include scaling each island according to a gradient score.

DETAILED DESCRIPTION

The following described exemplary embodiments provide a system, method and program product for projecting a 3D model defined by x, y, z coordinates onto the surface of a 2D image defined by u, v coordinates is provided. As such, the present embodiment has the capacity to improve the technical field of automatic partitioning of UV maps by enabling partitioning to be done based on the use of weight painting in 3D modeling software. More specifically, the present invention may include receiving a 3D model having a plurality of polygons, wherein certain edges are marked as seams. The present invention may include receiving input from a user, wherein the input comprises painting one or more parts of the 3D model in different colors, wherein the colors correspond with a weight of the area painted. The present invention may include unwrapping, by a processor, a 2D texture from the 3D model using a projection algorithm. The present invention may include generating a rectangular boundary around each island. The present invention may include scaling each island according to a gradient score.

As described previously, UV mapping may be a three-dimensional (i.e., 3D) modeling process of projecting a two-dimensional (i.e., 2D) image onto the surface of a three-dimensional model to give the two-dimensional image color and/or texture. The “U” and the “V” of “UV” may refer to the horizontal and vertical axes, respectively, of the two-dimensional space, as X, Y, and Z may already be used in a three-dimensional space. Three-dimensional modeling and/or texturing software may provide an automated process to unwrap a three-dimensional model.

However, existing three-dimensional modeling and/or texturing software may require a three-dimensional (i.e., 3D) artist (i.e., the artist) to manually manipulate a UV coordinate set in order to achieve a desired result. Depending on a capability of the three-dimensional artist (i.e., the artist), this may result in a high number of seams and/or an overlapping set of UV coordinates depicted on a UV map (e.g., a distorted, messy, and/or unrecognizable image). This challenge faced by artists may result in a need for a modification of an artist's workflow.

Furthermore, adjusting a scale of UV coordinates (e.g., included in a polygon mesh, which is the collection of vertices, edges, and faces that make up a three-dimensional object) may be both time consuming and tedious. A small scale of UV coordinates may result in a blocky appearance while a high scale of UV coordinates may include significantly more detail.

Therefore, it may be advantageous to, among other things, utilize a weight map, painted on by the three-dimensional artist (i.e., the artist), corresponding to a level of importance of elements (e.g., components, areas) of an image so that each element of the image may be placed into a UV island (e.g., where the UV island depicts a non-overlapped set of UV coordinates representing the element of the image). A two-dimensional (i.e., 2D) image may have a plurality of UV islands for depiction in a three-dimensional (i.e., 3D) space. By signifying an importance of a particular element on the three-dimensional model, an unwrapping algorithm may be able to further adjust a scale of the UV islands.

According to at least one embodiment, the present invention may enable a user to input a three-dimensional (i.e., 3D) model, unwrap a two-dimensional (i.e., 2D) texture from the three-dimensional model, apply weight paint (e.g., user-selected colors) to the unwrapped two-dimensional texture, and scale elements of the unwrapped two-dimensional texture based on the user's applied weight paint.

According to at least one embodiment, a user may apply weight paint to a mesh within a software application used for three-dimensional (i.e., 3D) modeling (e.g., where a mesh may be a structural build of a three-dimensional model consisting of polygons (e.g., straight-sided shapes defined by three-dimensional points called vertices and the straight lines that connect them called edges). The applied weight paint may result in a portion of the mesh being unwrapped from a 3D model to a two-dimensional (i.e., 2D) texture which takes up a larger or smaller portion of a UV coordinate plane based on a determined importance level of the portion of the mesh. This may be an improvement upon current functionality of software applications used for 3D modeling because current software applications do not scale a size of a portion of an image immediately upon unwrapping based on a received user input.

According to the present embodiment, a user using a client computer102or a server computer112may use the weight painting program110a,110b(respectively) to accurately project a 3D model defined by x, y, z coordinates onto the surface of a 2D image defined by u, v coordinates, giving more weight to important areas of the 3D model, by using weight paint in 3D modeling software. The weight painting method is explained in more detail below with respect toFIGS.2and3.

Referring now toFIG.2, an operational flowchart illustrating the exemplary weight painting process200used by the weight painting program110aand110baccording to at least one embodiment is depicted.

At202, the weight painting program110aand110breceives a three-dimensional (i.e., 3D) model from a user. A computer graphics software toolset used for creating animated films, visual effects, art, 3D printed models, motion graphics, virtual reality, computer games, and/or interactive 3D effects, may be used to receive a 3D model. For example, a cube-shaped 3D model (i.e., a cube) may be received by Blender® (Blender and all Blender-based trademarks are trademarks or registered trademarks of The Blender Foundation in the United States, and/or other countries), or any other software application capable of being used for 3D modeling. The cube may be comprised of six faces, each with four vertices, which together make up a mesh (e.g., a polygon mesh). A mesh may be a collection of vertices, edges, and faces that may define the shape of a three-dimensional object. For example, a single face may have, at a minimum, three vertices (e.g., for a triangular shape).

During an unwrapping of a three-dimensional (i.e., 3D) model, as will be described in more detail with respect to step206below, each face of the mesh may be cut along defined edges. A software application used for the 3D modeling may know, at least for primitive shapes, where the edges are. For more complex shapes, the software application used for 3D modeling may not accurately cut the mesh into faces. A user may, additionally and/or alternatively, mark seams on the 3D model to identify for the software application where the mesh should be cut. In this case, the software application may cut along the lines defined by the user.

At204, the weight painting program110aand110breceives input from the user. Received user input may include a weight map, generated by placing weight paint onto the 3D model by the user (e.g., an artist). Weight painting may, for example, be used for deforming vertices around a bone structure for use in animation, and the present invention may utilize weight painting to distinguish areas of importance of a received three-dimensional (3D) model. Any software application capable of being used for 3D modeling may enable weight painting by a user.

Weight paint may directly correlate to a scaling rate of a component of the 3D model. According to at least one gradient scale, blue may signify no importance while red may signify high importance. The gradient scale may be a primary factor which influences a scaling rate. Calculations may be made for an entire island (as will be described in more detail with respect to step208below) if the weight painting program110aand110bdetermines that a gradient is different in different regions of the island. An average gradient value may be calculated to obtain a single value which represents a gradient value of the entire island.

As described previously, according to at least one embodiment, the color red may represent areas of most significance while blue may represent areas of least significance. The user may paint red on areas of the three-dimensional (3D) model which are most visible (e.g., a human's shoulder or piece of armor, among many other things). The user may likewise paint blue on areas of the three-dimensional (3D) model which may not be seen. This may include, for example, an armpit and/or a neck area on the three-dimensional (3D) model, among many other areas of the 3D model.

A corresponding importance of weight paint colors may be an industry standard for weight painting used in three-dimensional (3D) animations, however the present invention may not prohibit a user from modifying the weight paint colors if doing so may increase productivity and/or enable an additional functionality required by the user.

Resulting gradient information may direct the software application to an area of the mesh which the artist marks as important. An artist's input regarding gradient information may feed into a size of a corresponding portion of the 3D model on a UV map. For example, areas of the 3D model that are deemed to be of higher importance may be given more space on a UV map so that these areas may be viewed with higher resolution. Conversely, areas that are deemed to be of lower importance may be given less space on a UV map since it may not matter whether the corresponding portion of the 3D model is viewed with high resolution on the UV map.

At206, the weight painting program110aand110bunwraps a two-dimensional (i.e., 2D) texture from the received three-dimensional (i.e., 3D) model. The 2D texture may be unwrapped from the 3D model using a projection algorithm. The projection algorithm may include, but is not limited to including, a cube projection, a sphere projection, and/or a camera or view projection.

When the weight painting program110aand110bunwraps the 2D texture from the 3D model, the weight painting program110aand110bmay take into consideration the weight map, as discussed previously with respect to step204above, to prioritize areas of higher significance and to allocate more UV space (e.g., more space in a u,v coordinate plane) for the higher prioritized areas (e.g., UV islands with a determined higher priority). A greater amount of UV space may correlate to more details being seen on the 3D model. Likewise, areas of lower significance may be given less UV space and fewer details may be shown on a final rendering of the lower prioritized areas.

At208, the weight painting program110aand110bgenerates a gradient score for each UV island resulting from the unwrapping. The generated gradient score may correspond to a scaling rate which may influence a space allocation of the three-dimensional (i.e., 3D) model onto a two-dimensional (i.e., 2D) u,v coordinate plane.

As described previously with respect to step206above, once a UV map has been generated and UV islands have been identified, the weight painting program110aand110bmay begin the process of UV space allocation. A gradient on islands may be relatively consistent, however, an average of the weights (e.g., based on input received from a user, as described previously with respect to step204above) on an island may be calculated to generate a gradient score. This may assume that a painted color has a corresponding mathematical value such that a numerical average may be calculated. The corresponding mathematical value may be a value configurable by a user (e.g., not a standard value). For example, according to at least one embodiment, the corresponding mathematical value may be a numerical value on a normalized scale ranging from 0 to 1, where 1 indicates areas of high importance and 0 indicates areas of no importance. The scale may be manipulable by the user to achieve a desired unwrapped result. The numerical average may be determined by dividing a total of all mathematical values a number of mathematical values.

The gradient score may correspond to a scaling rate, which may be configurable by a user and which may default to 1. The scaling rate may determine an initial size of an island (e.g., a portion of 3D model). This may be an estimated size which may be adjusted based on a determined gradient score. Incrementally, an island may grow or shrink depending on a determined scaling rate and the determined scaling rate of other islands which are to be projected onto the two-dimensional (i.e., 2D) u,v coordinate plane. For example, an island may grow until there is no more space to grow in a particular direction of the u,v coordinate plane. As another example, an island may grow according to a bin packing algorithm (e.g., an NP problem in which items of different volumes must be packed into a finite number of bins or containers each of a fixed given volume in a way that minimizes a number of bins used) which may attempt to best fit the shapes on the u,v coordinate plane and to fit the shapes together in a best possible way. The weight painting program110aand110bmay run through enough iterations of the bin packing algorithm until a resulting 2D texture is achieved which achieves an appearance acceptable by a user.

At210, the weight painting program110aand110bgenerates a rectangular boundary (i.e., a bounding box, a boundary box) around each island of the UV model. A rectangular boundary box may be generated by identifying four vertices around each island of the UV model. In order to ensure an island of the UV model is captured within a rectangular boundary, the northernmost, southernmost, easternmost, and westernmost points (e.g., vertices) of the island may be identified. The software application used for 3D modeling may generate a rectangular boundary using a u,v coordinate plane (e.g., by identifying a highest U, a lowest U, a highest V, and a lowest V).

As described previously, a rectangular boundary around each island may be generated by comparing points within a u,v coordinate plane that make up an island to see which of the points are the farthest outliers (e.g., the four farthest outliers in each direction may become the four corners of the rectangular boundary box).

A rectangular boundary around each island may be utilized to generate the gradient score. For each island, a gradient score and bounds (e.g., a boundary box) may be determined. A rectangular boundary box may enable the weight painting program110aand110bto identify a center of mass of each island. From this center, the weight painting program110aand110bmay scale each corner of a boundary box according to a scaling rate (e.g., which may be configurable by a user and which may default to 1, as described previously with respect to step208above).

Once an edge of a boundary box reaches another boundary box and/or an edge of the coordinate plane, the boundary box may stop growing in that direction. This process of scaling each island may be iterated until all boundary boxes (e.g., a boundary box is around an island) may no longer be able to grow.

The generated rectangular boundary boxes may be used, primarily, for packing purposes (e.g., for use with a bin packing algorithm). By calculating a gradient score (as described previously with respect to step208above) before generating the rectangular boundary box, the weight painting program110aand110bmay ensure that the calculations are more tailored (e.g., more closely fit) around an island and that there is little to no blank areas in the calculations.

At212, the weight painting program110aand110bscales the UV islands according to a gradient score using at least one fitting algorithm (e.g., bin packing algorithm). The fitting algorithm may have a goal of fitting as many UV islands as possible into the UV coordinate space, while maintaining a size and/or proportion determined by the applied weight paint, as discussed above, with a requirement that all UV islands generated by the weight painting program110aand110bmust fit into the UV coordinate space. The fitting algorithm (e.g., bin packing algorithm) may enable the weight painting program110aand110bto grow and shrink the UV islands until all UV islands achieve a best fit within the UV coordinate space.

As described previously with respect to step210above, once all boundary boxes have reached a maximum size, the weight painting program110aand110bmay partition the UV model based on the locations of seams of the UV model (e.g., which have been allocated UV coordinate space based on a scaling rate configured by the user). In a resulting UV map, each island may be allocated UV space (e.g., space in a u,v coordinate plane) which does not overlap with another island.

A scaling rate may be a percentage of a total gradient score across an entire UV map. For example, if there are five islands and each of the five islands is colored red with weight paint, then each island may evenly take up one fifth of the UV map (e.g., the u,v coordinate plane).

Partitioning of the UV islands may be done by cutting along marked seams. For example, once a seam is manually marked by an artist, the weight painting program110aand110bmay cut along the marked seams to achieve a resulting 2D texture unwrapped into a u,v coordinate plane.

Referring now toFIG.3, a block diagram of an unwrapping process according to at least one embodiment is depicted. A three-dimensional (i.e., 3D) cube302may be received by a user in a 3D modeling software along with user input regarding location of seams and weight paint to indicate an importance of areas of the received cube. The cube is depicted in an x, y, z coordinate plane. The received 3D model (e.g., the cube here) is then unwrapped into a two-dimensional (i.e., 2D) texture304. The 2D texture is depicted in a u,v coordinate plane. As described above, based on the received user input, a gradient score may then be generated for each UV island resulting from the unwrapping (e.g., each resulting square face of the received cube), a rectangular boundary box may be generated around each island and the islands may be scaled according to the gradient score using fitting algorithms and/or a bin packing algorithm.

It may be appreciated thatFIGS.2and3provide only an illustration of one embodiment and do not imply any limitations with regard to how different embodiments may be implemented. Many modifications to the depicted embodiment(s) may be made based on design and implementation requirements.

Characteristics are as follows:

Service Models are as follows:

Deployment Models are as follows:

Referring now toFIG.6, a set of functional abstraction layers1100provided by cloud computing environment1000is shown. It should be understood in advance that the components, layers, and functions shown inFIG.6are intended to be illustrative only and embodiments of the invention are not limited thereto. As depicted, the following layers and corresponding functions are provided:

Workloads layer1144provides examples of functionality for which the cloud computing environment may be utilized. Examples of workloads and functions which may be provided from this layer include: mapping and navigation1146; software development and lifecycle management1148; virtual classroom education delivery1150; data analytics processing1152; transaction processing1154; and weight painting1156. A weight painting program110a,110bprovides a way to accurately project a 3D model defined by x, y, z coordinates onto the surface of a 2D image defined by u, v coordinates, giving more weight to important areas of the 3D model, by using weight paint in 3D modeling software.