Hair map generation method and device, electronic equipment and readable storage medium
Patent Information
- Application Number
- CN202311235210.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-09-22
AI Technical Summary
[0004]可见,一方面头发贴图扮演着头发着色器中重要的角色,是头发效果最直接的提供者之一,制作流程相对复杂;另一方面目前市场上缺乏完整的解决方案来处理所有贴图,且所采用的二维贴图方式存在层次感弱等缺陷
[0044]本申请提供一种头发贴图生成方法、装置、电子设备和可读存储介质,首先制作发片规划图,发片规划图中包括目标发丝信息,然后制作背景板和多个发片分区,其中,多个发片分区按照发片规划图中目标发丝信息进行划分得到。在背景板上,按照目标发丝信息对各发片分区进行发丝设置,得到发丝高模,基于发丝高模生成目标发丝对应的多项贴图数据。本方案中,基于发丝规划图为发丝设置提供依据,并且,基于发丝高模生成匹配的贴图数据,一方面可以保障发丝设置按照需求生成对应的发丝高模,另一方面,基于发丝高模生成的贴图,满足头发模型高层次感的要求,进而提升头发模型的质量。
Smart Images

Figure CN117218265B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and readable storage medium for generating hair textures. Background Technology
[0002] As Unreal Engine (UE) gains increasing market share, its rendering standard has become mainstream. This means that hair shaders in UE have become crucial. Hair shaders require a set of textures, including ID maps, depth maps, root maps, alpha maps, tangent maps, and normal maps, and the creation of these textures is a complex and difficult process.
[0003] Currently, there is a lack of readily available solutions on the market to meet all texture creation needs. Furthermore, many software programs can only generate textures based on two-dimensional information, resulting in hair textures with weak layering.
[0004] It is evident that, on the one hand, hair textures play a crucial role in hair shaders, being one of the most direct providers of hair effects, and their production process is relatively complex; on the other hand, the current market lacks a complete solution to handle all textures, and the 2D texture methods employed suffer from drawbacks such as weak layering. Therefore, how to create high-quality hair textures is a pressing problem that needs to be solved. Summary of the Invention
[0005] The present invention aims to provide, for example, a hair texture generation method, apparatus, electronic device, and readable storage medium capable of generating high-quality hair textures that meet requirements.
[0006] The embodiments of the present invention can be implemented as follows:
[0007] In a first aspect, the present invention provides a method for generating hair textures, the method comprising:
[0008] Create a hair section planning diagram, which includes target hair strand information;
[0009] Create a background panel and multiple hair section sections, wherein the multiple hair section sections are divided according to the target hair strand information in the hair section planning diagram;
[0010] On the background board, hair strands are set for each hair section according to the target hair strand information to obtain a high-resolution hair strand model;
[0011] Based on the high-poly model of the hair strand, generate multiple texture data corresponding to the target hair strand.
[0012] In an optional implementation, the method further includes:
[0013] The hair model of the target virtual character is rendered using the aforementioned multiple texture data to obtain the corresponding hair rendering result.
[0014] In an optional implementation, the texture data includes a tangent texture for storing hair cutting information;
[0015] The method further includes:
[0016] For each hair section in the low-mold of the hair section, obtain the unnormalized tangent component and sub-tangent component of any poly on the hair section, and calculate the elongation parameter of any poly of the low-mold of the hair section based on the tangent component and sub-tangent component.
[0017] The stretching parameters are stored in the vertex properties of any poly of the low-poly model of the hair piece, so as to correct the deviation of the tangent direction in the tangent map caused by the stretching of the hair piece when rendering the hair.
[0018] In an optional implementation, the step of rendering the hair model of the target virtual character using the multiple texture data to obtain the corresponding hair rendering result includes:
[0019] For any pixel in the low-poly model of the hair section, obtain the hair tangent information included in the tangent texture in the multiple texture data, and store the hair tangent information in the tangent texture in a linear color format;
[0020] The hair tangent information is converted into tangent vectors in tangent space, and then the tangent vectors in tangent space are converted into tangent vectors in world space through coordinate transformation.
[0021] Extract the stretching parameter stored in the vertex attributes of any pixel, and multiply the stretching parameter by the secondary tangent component of the tangent vector to obtain the corrected tangent vector;
[0022] The hair model of the target virtual character is rendered using the corrected tangent vectors to obtain the corresponding hair rendering result.
[0023] In an optional implementation, the step of obtaining the unnormalized tangential and secondary tangential components of any poly on the hairpiece, and calculating the elongation parameters of any poly of the low-modulus hairpiece based on the tangential and secondary tangential components, includes:
[0024] Determine the triangular model to which any poly on the hairpiece belongs, wherein the triangular model includes three vertices;
[0025] Based on the position information of the three vertices, the texture horizontal coordinate information, and the texture vertical coordinate information, the unnormalized tangent component and the secondary tangent component of the arbitrary poly are calculated.
[0026] The elongation parameter of any poly of the low-mold hairpiece is obtained by dividing the length of the tangent component by the length of the sub-tangent component.
[0027] In an optional implementation, the plurality of texture data includes density textures used to characterize hair density and thickness information;
[0028] The step of generating multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand includes:
[0029] For each hair bundle in the high-resolution model of the hair strand, determine the number of overlapping hair strands on each pixel of the hair bundle;
[0030] Determine the range of the number of overlapping hair strands on each pixel, and obtain the transparency parameter corresponding to the range of the number of hair strands.
[0031] A density map corresponding to the target hair strand is generated based on the transparency parameter corresponding to each pixel.
[0032] In an optional implementation, the step of setting the hair strands in each hair section according to the target hair strand information includes:
[0033] A transparent surface is made on the background plate to support each of the hair section sections, and the transparent surface has basic surface properties that affect the setting of hair strands;
[0034] For the hair strand attributes present in the basic surface attributes, the corresponding hair strand attributes in the basic surface attributes are set according to the target hair strand information to achieve hair strand setting;
[0035] For hair strand attributes that are not present in the basic surface attributes, obtain the hair strand attributes that are pre-stored in the Detail function and correspond to the transparent surface in the attribute array, and set the hair strand attributes in the attribute array according to the target hair strand information to achieve hair strand setting.
[0036] In a second aspect, the present invention provides a hair texture generation apparatus, the apparatus comprising:
[0037] The first production module is used to create a hair section planning diagram, which includes target hair strand information;
[0038] The second production module is used to create a background board and multiple hair section partitions, wherein the multiple hair section partitions are obtained by dividing the target hair strands according to the hair section planning diagram;
[0039] The setting module is used to set the hair strands in each hair section on the background board according to the target hair strand information to obtain a high-resolution hair strand model.
[0040] The generation module is used to generate multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand.
[0041] Thirdly, the present invention provides an electronic device including one or more storage media and one or more processors communicating with the storage media, wherein the one or more storage media store machine-executable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-executable instructions to perform the method described in any of the foregoing embodiments.
[0042] Fourthly, the present invention provides a computer-readable storage medium storing machine-executable instructions that, when executed by a processor, implement the method described in any one of the foregoing embodiments.
[0043] The beneficial effects of the embodiments of the present invention include, for example:
[0044] This application provides a method, apparatus, electronic device, and readable storage medium for generating hair textures. First, a hair section planning map is created, including target hair strand information. Then, a background plate and multiple hair section partitions are created, where the partitions are divided according to the target hair strand information in the hair section planning map. On the background plate, hair strands are set for each hair section partition according to the target hair strand information, resulting in a high-poly model of the hair strands. Based on the high-poly model, multiple texture data corresponding to the target hair strands are generated. In this solution, the hair section planning map provides a basis for hair strand settings, and matching texture data is generated based on the high-poly model. This ensures that the hair strand settings generate corresponding high-poly models as required, and the textures generated based on the high-poly model meet the requirements for high-level detail in the hair model, thereby improving the quality of the hair model. Attached Figure Description
[0045] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A flowchart of a hair texture generation method provided in an embodiment of this application;
[0047] Figure 2 for Figure 1A flowchart of the sub-steps included in step S13;
[0048] Figure 3 for Figure 1 A flowchart of the sub-steps included in step S14;
[0049] Figure 4 A flowchart of the method for obtaining the stretching parameter in the hair texture generation method provided in this application embodiment;
[0050] Figure 5 for Figure 1 A flowchart of the sub-steps included in step S15;
[0051] Figure 6 for Figure 4 A flowchart of the sub-steps included in step S21;
[0052] Figure 7 This is one of the interface diagrams in the embodiments of this application;
[0053] Figure 8 This is the second schematic diagram of the interface in the embodiments of this application;
[0054] Figure 9 This is the third schematic diagram of the interface in the embodiments of this application;
[0055] Figure 10 This is a functional block diagram of the hair texture generation device provided in the embodiments of this application;
[0056] Figure 11 A structural block diagram of an electronic device provided in an embodiment of this application.
[0057] Icons: 110-Hair texture generation device; 111-First production module; 112-Second production module; 113-Setting module; 114-Generation module; 120-Processor; 130-Memory; 140-Communication module. Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0059] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0060] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0061] In the description of this invention, it should be noted that the terms "first" and "second" are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance.
[0062] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0063] Figure 1 This is a flowchart of a hair texture generation method provided in an embodiment of this application. This embodiment is applicable to scenarios where hair textures are needed to generate hair models of virtual objects in a certain game scene. This method can be executed by a hair texture generation device, which can be implemented in software and / or hardware, and can be configured in a terminal. Figure 1 As shown, the method includes:
[0064] S11, Create a hair section planning diagram, which includes target hair strand information.
[0065] S12, create a background panel and multiple hair section partitions, wherein the multiple hair section partitions are obtained by dividing the target hair strand information according to the hair section planning diagram.
[0066] S13, on the background plate, hair strands are set for each hair section according to the target hair strand information to obtain a high-resolution hair strand model.
[0067] S14, Generate multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand.
[0068] In this embodiment, a hair section planning diagram can be created using drawing software, such as Photoshop. The hair section planning diagram can be understood as a sketch of the hair strands to be generated later. Therefore, the hair section planning diagram includes target hair strand information, which refers to the hair strands contained in the hair to be generated later. In other words, the hair strands will be set according to the target hair strand information later.
[0069] Based on this, a background panel is created in the software. In this embodiment, Houdini can be used. By further developing Houdini, the functions of each step in this embodiment can be realized. The background panel provides a solid foundation for the subsequent generation of hair strands and can be understood as the backing plate that supports the hair strands. The background panel can be understood as a rectangular poly with an aspect ratio of 1:2 or 1:1. The UV coordinates of the four corner points of this poly are (0,0), (1,0), (1,1), and (0,1), respectively. Its function is to act as the background for the texture during texture baking. When partitioning according to the planning diagram, it will be divided into several horizontally parallel rectangular polys. The smaller polys will generate an invisible poly under the action of parameters and become the base model for the subsequent generation of the high-poly hair strands. The high-poly hair strands are built on this invisible poly.
[0070] In addition, multiple hair sections are created, each of which can be divided according to the target hair strand information in the hair section planning diagram. This can be understood as a hairstyle being composed of multiple hair sections, with one or more hair strands generated on each section, thus creating a hairstyle composed of a large number of hair strands.
[0071] The target hair strand information in the hair section planning diagram reflects the hair strand layout and partitioning. Therefore, hair section partitioning can be set based on the hair section planning diagram. The hair section width can be set on the interface. Multiple different alpha channels that can affect the hair strand layout (the amount of hair) can be set, allowing you to select and configure any one of these alpha channels for each hair section low-poly model. The hair section low-poly model is a model created by the production staff that corresponds to the hair section partitioning. Thus, the hair strand arrangement in each hair section can be consistent with the hair strand layout in the hair section planning diagram.
[0072] Specifically, the hair section low-poly model is a sheet-like or strip-shaped poly model used to render the hair of a real-time game character. It is generally composed of a series of quadrilateral polys. The background is used for baking textures, and the hair section low-poly model is used for sampling textures. At the same time, the range of the sampling texture of each hair section low-poly model is basically consistent with the segmented area of the background.
[0073] In addition to the hair layout, several other settings are required for hair strand configuration. In this embodiment, the hair strands are configured for each hair section on the background panel according to the target hair strand information in the hair section planning diagram. These settings include hair strand density, root shape of the hair bundle, hair strand length, hair strand thickness, hair bundle silhouette (bundling effect and bending effect), random noise of the hair strands, and wave effect of the hair strands.
[0074] By setting the hair strands as described above, a high-poly model of the hair strands can be obtained. Based on this high-poly model, corresponding multi-texture data can be generated. The high-poly model of the hair strands is generated on the background by adjusting parameters. Several separate hair bundle models are generated according to the partitions of the background. The hair bundle model is composed of solid models of hair strands, forming the resource model for baking hair textures.
[0075] In this embodiment, the multiple texture data include ID maps, depth maps, root maps, alpha maps, tangent maps, and normal maps. The ID map assigns a unique ID color to each hair strand to facilitate differentiation in the shader. The depth map records the distance information between each pixel in the hair section and the camera, used to change the mutual occlusion relationship of the hair sections during rendering. The root map identifies the position information of the hair's starting point, used to generate the position and direction of vertices. The alpha map records the hair's transparency to determine the visibility of pixels, making the hair appear realistic and visible. The tangent map stores hair tangent information for anisotropic lighting effects on the hair sections. The normal map stores hair normal information, ensuring that the hair correctly reflects and blocks light during rendering.
[0076] In addition, this embodiment can also generate a density map, which is used to record hair density and thickness information to achieve softer occlusion and shadow effects. The difference between a density map and a transparency map is that a transparency map shows the visibility based on the transparency of individual hair strands at the hair strand level, while a density map shows the density and thickness information based on the overall appearance of the hair strands. The former can be understood as a visual effect with the texture of individual hair strands at close range, while the latter can be understood as a visual effect at a distance, i.e., a visual effect without the texture of individual hair strands.
[0077] In the hair texture generation method provided in this embodiment, the hair strand planning map is used as a basis for hair strand settings, and matching texture data is generated based on the high-poly model of the hair strands. On the one hand, this ensures that the hair strand settings generate the corresponding high-poly model of the hair strands as required. On the other hand, the texture generated based on the high-poly model of the hair strands meets the requirements of high-level sense of the hair model, thereby improving the quality of the hair model.
[0078] Furthermore, in this embodiment, matching ID maps, depth maps, root maps, transparency maps, tangent maps, normal maps, and density maps can be generated based on the high-poly model of the hair strands, which can meet the comprehensive texture creation requirements. The existing texture creation process is as follows:
[0079] Existing techniques use software such as Xgen to create the curves of the hair strands in the corresponding areas of the planned hair texture, and then create a high-poly model of the hair strands with the front facing up, or create a high-poly model of the hair strands with the front facing up in Maya.
[0080] In existing technologies, for transparency map creation, a color map is baked using Maya, and then processed using tools such as desaturation and curves in Photoshop. For ID map creation, ZBrush automatically assigns a random group based on hair strands, then manually converts the random group into vertex colors, and then bakes the ID map using other software. Because IDs need to be created manually, the number of groups cannot be too large. For root map creation, ZBrush automatically assigns a UV based on hair strands, then converts the UVs into vertex colors, and then bakes the G-channel of the vertex colors (i.e., the root map, the selection of which is determined by the UV orientation of the hair model) using other software. For depth map creation, texture mapping software (such as XNormal, ZBrush, etc.) is used to bake the depth values of pixels. For normal map creation, it is necessary to return to Xgen to generate a cylindrical high-poly model of the hair strands, and then bake it using software such as Maya or 3ds Max. This process, using Xgen twice, can cause the boundaries of the normal map to mismatch with the outline of the transparency map. If the hair strands in the normal map are thinner than those in the transparency map, the overflow noise at the boundary of the normal map will be sampled.
[0081] The existing technology for texture creation is relatively complex and difficult. Furthermore, the existing technology lacks universal baking tools for tangent maps and density maps, making it difficult to meet the comprehensive texture creation needs.
[0082] As can be seen, compared with the existing texture creation process, the hair texture generation method in this embodiment can directly generate matching textures based on the high-poly model of hair strands created according to the hair section planning diagram, solving the hair texture creation problem in one stop. Furthermore, it allows for free selection of the required texture combinations. The hair textures generated based on the high-poly model meet the requirements for high-level detail in hair models. Multiple textures can be generated, including normal maps and density maps, satisfying comprehensive texture generation needs.
[0083] The hair texture generation method provided in this embodiment is based on Houdini's Groom tool and is a secondary development on top of it. It integrates multiple Houdini tool systems, such as Groom, SOP, COP, material, and volume, and utilizes Houdini's built-in VEX language. However, all nodes edited based on the brush are irreversible; irreversible means that once the saved file is closed and reopened, previous operations cannot be undone. To avoid the drawback of irreversible nodes, please refer to [link to relevant documentation]. Figure 2 In this embodiment, the step of setting the hair strands of each hair section according to the target hair strand information can be implemented in the following way:
[0084] S131, a transparent surface is made on the background plate to support each of the hair section sections, the transparent surface having basic surface properties that affect the setting of hair strands.
[0085] S132, for the hair strand attributes in the basic surface attributes, set the corresponding hair strand attributes in the basic surface attributes according to the target hair strand information to realize hair strand setting.
[0086] S133, for hair strand attributes that are not present in the basic surface attributes, obtain the hair strand attributes in the attribute array that are pre-stored in the Detail function and correspond to the transparent surface, and set the hair strand attributes in the attribute array according to the target hair strand information to realize the hair strand setting.
[0087] It should be noted that, in actual implementation, steps S132 and S133 can be selected to be executed according to the actual situation.
[0088] In this embodiment, a transparent surface can be provided above the background plate, which serves as the surface directly supporting the hair section. As the name suggests, this transparent surface is transparent and invisible. It can have relevant basic surface properties, and by adjusting these properties, the properties of the hair strands within the hair section can be adjusted. While some hair strand properties can be adjusted by modifying the basic surface properties, others may not have corresponding items in the basic surface properties and therefore cannot be adjusted by modifying them.
[0089] Based on this, for hair attributes that have corresponding items in the basic surface properties, the hair attributes can be adjusted in the basic surface properties according to the target hair information, thereby realizing hair settings.
[0090] In this embodiment, Groom also includes a Detail function, which contains an attribute array. This attribute array can be used to store hair attributes related to hair settings. For hair attributes that are not present in the basic surface attributes, these attributes can be pre-stored in the attribute array. Later, when hair settings are needed, the attributes can be retrieved from the attribute array and set accordingly.
[0091] The Detail function can contain multiple attribute arrays, each corresponding to a different transparent surface in the software. Therefore, when setting hair strands on a specific transparent surface, the corresponding attribute array can be located using the surface number, allowing control over the hair strand curves by setting the hair strand properties within that array.
[0092] Neither of the above two methods directly edits individual hair strands; therefore, the editing process is reversible. The editing process can be executed in any order based on requirements, avoiding the irreversible nature of traditional methods that use irreversible nodes in Groom or require manipulating model nodes on the display interface. This solution allows the editing process to be executed in any order, and the shape and style of the hair strands can be changed through simple operations to gradually generate a large number of different hair strand sets.
[0093] In addition to the two methods mentioned above, in this embodiment, functions not available in Groom can be created by directly using the VEX language in Houdini to directly and indirectly control the hair curve.
[0094] As can be seen from the above, in addition to the more conventional hair texture, this embodiment also proposes a density texture, that is, the generated multiple texture data includes a density texture, which is used to characterize hair density information and thickness information.
[0095] Please see Figure 3 As one possible implementation, the steps for generating multiple texture data corresponding to the target hair strands based on the high-poly model of the hair strands include the following sub-steps:
[0096] S141, for each hair bundle in the hair high-resolution model, determine the number of hair strands overlapping each pixel point on the hair bundle.
[0097] S142, determine the range of the number of overlapping hair strands on each pixel, and obtain the transparency parameter corresponding to the range of the number of hair strands.
[0098] S143, Generate a density map corresponding to the target hair strand based on the transparency parameter corresponding to each pixel.
[0099] For each hair bundle, among the pixels in the hair bundle, some pixels may have passed through 200 hair strands, that is, the number of overlapping hair strands on the pixel is 200; some pixels may have passed through 100 hair strands, that is, the number of overlapping hair strands on the pixel is 100; and some pixels may not have passed through any hair strands.
[0100] After rendering the hair, in some scenarios, the hair may need to have a strand-like texture to show the hair details, while in other scenarios, the hair may not need to have a strand-like texture, and it may only need to show the density and thickness of the hair, such as in a distant view.
[0101] When there are many overlapping hair strands on a pixel, the hair density and thickness of that pixel are greater; conversely, when there are fewer overlapping hair strands, the hair density and thickness of that pixel are smaller. For pixels with more than a certain threshold of overlapping hair strands, the hair at that pixel can be considered completely dense and opaque.
[0102] Based on the above research, in this embodiment, after determining the number of overlapping hair strands on each pixel, the range to which the number of hair strands belongs can be determined. For example, a first range can be defined as 1 to 100 hair strands, a second range as 101 to 200 hair strands, and a third range as 201 to 300 hair strands, etc.
[0103] Each quantity range can correspond to a transparency parameter, which can affect the hair density and thickness information represented by the pixel.
[0104] Thus, after determining the range of hair strand counts for each pixel, the corresponding transparency parameter can be obtained. A density map is then generated based on this transparency parameter for each pixel. Consequently, in the hair rendered using this density map, areas with a high number of overlapping hair strands appear densely packed, for example, as dark gray-black. Conversely, areas with fewer overlapping hair strands appear sparsely packed, for example, as light gray-black.
[0105] It should be noted that the above is only an example. The specific effect of the hair rendered based on density mapping needs to be adaptively adjusted in combination with information such as the color of the virtual character's hair. This embodiment does not impose any specific limitations.
[0106] In this embodiment, density maps are generated in the above manner to meet the diverse needs for hair rendering effects in different scenarios.
[0107] It should be noted that the above description only introduces the generation of texture data from the perspective of density mapping. The actual generated texture data includes not only density mapping but also the other textures mentioned above, which will not be described one by one in this embodiment.
[0108] Please refer to it again. Figure 1 Based on the above, the hair texture generation method provided in this embodiment may further include the following steps:
[0109] S15, the hair model of the target virtual character is rendered using the multiple texture data to obtain the corresponding hair rendering result.
[0110] The target virtual character can be any character that requires hair rendering, such as a cartoon character or a 3D character.
[0111] In this embodiment, the generated multiple texture data includes a tangent texture for storing hair tangent information. Tangent texture and normal texture... Figure 1 Similarly, both are textures based on linear color storage vectors. Each pixel in the hair texture will be restored to a vector in the UE engine. If a world-space vector (representing the tangent direction and orientation of the high-poly hair model) is transformed to tangent space as (0.7071, 0.7071, 0), it will be stored as a linear color (0.85355, 0.85355, 0.5) on the tangent texture, roughly grayish-green. This color will be restored in the UE engine to a tangent vector in tangent space (0.7071, 0.7071, 0), and then transformed into a world-space tangent vector, which is 45 degrees to both the tangent and secondary tangent directions of its primary and coplanar planes.
[0112] The tangent space, also known as the texture space, provides three mutually perpendicular directions as spatial axes: the tangent direction (pointing to the horizontal direction of the texture), the secondary tangent direction (pointing to the vertical direction of the texture), and the normal direction (perpendicular to the surface of the model and pointing outwards).
[0113] World space is the absolute space within the game scene, defined by three mutually perpendicular directions: X, Y, and Z. The various spaces in the game are not independent of each other, but rather defined as vectors or coordinates. For example, a pixel on a quadrilateral plane facing the X direction has a vector pointing to the X direction that is (1, 0, 0) in Unreal Engine's world space, but (0, 0, 1) in tangent space.
[0114] The tangent vector is a vector provided by the tangent map. The tangent vector is a three-dimensional vector consisting of components projected onto three spatial axes. The tangent space provides three mutually perpendicular spatial axes to provide the basis for the projection of the vector.
[0115] If the hairpiece model is not stretched in the UE engine, the direction of the hair strands on the hairpiece model will be exactly this direction. However, in actual scenarios, the creation of the hairpiece model will definitely involve stretching the hairpiece for use. At this time, the hair strands will become straighter and straighter (for example, the angle between the hair strands and the secondary tangent direction changes from 45 degrees to 5 degrees). However, the hair tangent information stored in the tangent map is the tangent information before the hair strands are stretched. Therefore, the UE engine will have errors when rendering hair based on the tangent map.
[0116] Therefore, it is necessary to inform the UE engine of the specific information regarding the lengthening of the hair clip. Currently, the UE engine obtains this information separately and dynamically. This method increases resource consumption during game execution.
[0117] Based on the above research, this embodiment provides a method that eliminates the need for the UE engine to separately obtain specific information about the elongation of the hair extension, thereby avoiding the problem of increased game resource consumption. Please refer to... Figure 4 Specifically, after generating the tangent map as described above, and before rendering the hair, the following steps may also be included:
[0118] S21, for each hair section in the produced hair low mold, obtain the unnormalized tangent component and sub-tangent component of any poly on the hair section, and calculate the elongation parameter of any poly of the hair section low mold based on the tangent component and sub-tangent component.
[0119] S22, the stretching parameters are stored in the vertex properties of any poly of the low-poly model of the hair piece, so as to correct the deviation of the tangent direction in the tangent map caused by the stretching of the hair piece when rendering the hair.
[0120] In this embodiment, in the low-profile hairpiece, the hair strands on each hairpiece undergo a stretching process, during which the angle between the hair strand and the secondary tangent changes. Based on the tangent component and secondary tangent component in the tangent information of the hair strand, the stretching parameter of the stretched hair strand can be calculated. For example, for shoulder-length hair, the stretching parameter is generally between 5 and 15 times.
[0121] In the low-poly model of the hair section, the hair section can be understood as a piece composed of individual triangular models, each with three vertices. Each poly on the hair section has its own associated triangular model. Since the UE engine needs to render the hair section in conjunction with the overall hair texture, in this embodiment, the stretching parameters of any poly can be directly stored in the alpha attribute of its vertex. This allows the UE engine to obtain the stretching parameters simultaneously without needing to extract them separately.
[0122] In this embodiment, a MAX tool, such as FTD_UV_Warp_Alpha_v0.0.16.MCG, can be used to complete the above operation of storing the stretching parameters into the vertex attributes.
[0123] Based on this, the steps described above for rendering the hair model of the target virtual character using multiple texture data to obtain the corresponding hair rendering result can be achieved in the following ways, please refer to the following: Figure 5 :
[0124] S151, for any pixel in the low-poly model of the hair piece, obtain the hair tangent information included in the tangent texture in the multiple texture data, and the hair tangent information is stored in the tangent texture in a linear color format.
[0125] S152, the hair tangent information is converted into a tangent vector in tangent space, and the tangent vector in tangent space is converted into a tangent vector in world space through coordinate transformation.
[0126] S153, extract the stretching parameter stored in the vertex attributes of the arbitrary pixel, and multiply the stretching parameter by the secondary tangent component of the tangent vector to obtain the corrected tangent vector.
[0127] S154 uses the corrected tangent vector to render the hair model of the target virtual character, and obtains the corresponding hair rendering result.
[0128] As mentioned above, tangent vectors are stored as linear colors in the tangent map. Therefore, in the UE engine, the hair tangent information in the linear color format of the tangent map needs to be converted into tangent vectors in tangent space. For example, if the linear color in the tangent map is (0.85355, 0.85355, 0.5), it becomes (0.7071, 0.7071, 0) after being converted into a tangent vector in tangent space. Then, coordinate transformation is used to convert the tangent vector in tangent space into a tangent vector in world space.
[0129] The tangent vector in the transformed world space includes a tangent component and a secondary tangent component. Multiplying the elongation parameter calculated above by the secondary tangent component allows for normalization of the product, resulting in a corrected tangent vector. Thus, rendering the hair of the target virtual character based on the corrected tangent vector can correct the tangent direction deviation caused by hair stretching during the rendering process.
[0130] It should be noted that the above description is only the rendering process from the perspective of tangent mapping. Hair rendering also requires the combination of depth mapping, ID mapping, root mapping, transparency mapping, normal mapping and density mapping to achieve comprehensive hair rendering.
[0131] In this embodiment, the stretching parameters of the poly lines on the hair section are calculated and stored in the vertex attributes. This allows the stretching parameters to be extracted during rendering to account for deviations in the tangent direction caused by stretching. This achieves the goal of ensuring the correctness of the hair tangent effect while avoiding excessive consumption of game resources.
[0132] Please see Figure 6 As one possible implementation, in this embodiment, the elongation parameter can be calculated in the following way:
[0133] S211, determine the triangular model to which any poly on the hairpiece belongs, the triangular model including three vertices.
[0134] S212, based on the position information of the three vertices, the texture horizontal coordinate information, and the texture vertical coordinate information, calculate the unnormalized tangent component and the secondary tangent component of the arbitrary poly.
[0135] S213, by dividing the length of the tangent component by the length of the sub-tangent component, the elongation parameter of any poly of the low-mold of the hairpiece is obtained.
[0136] In this embodiment, the triangular model to which any poly belongs includes three vertices, such as vertex 0, vertex 1, and vertex 2. Each vertex has position information on the texture and coordinate information in UV space, wherein the coordinate information in UV space includes texture horizontal coordinate information and texture vertical coordinate information.
[0137] Based on the position information of the three vertices of the triangular model, the texture horizontal coordinate information, and the texture vertical coordinate information, the tangent component T and the secondary tangent component B of any poly can be calculated.
[0138] As one possible implementation, the tangent component T and the secondary tangent component B can be calculated using the following formula:
[0139] T=(DV1*E2-DV2*E1) / (DV1*DU2-DV2*DU1)
[0140] B=(DU2*E1-DU1*E2) / (DV1*DU2-DV2*DU1)
[0141] Where E1 represents the position information of vertex 1 minus the position information of vertex 0 in the triangulation model; E2 represents the position information of vertex 2 minus the position information of vertex 0. DU1 represents the texture x-coordinate UV.u of vertex 1 minus the texture x-coordinate UV.u of vertex 0; DU2 represents the texture x-coordinate UV.u of vertex 2 minus the texture x-coordinate UV.u of vertex 0. DV1 represents the texture y-coordinate UV.v of vertex 1 minus the texture y-coordinate UV.v of vertex 0; DV2 represents the texture y-coordinate UV.v of vertex 2 minus the texture y-coordinate UV.v of vertex 0.
[0142] Based on the calculation of the tangential component T and the secondary tangential component B, the elongation parameter of the hair strand is equal to the ratio of their lengths, T / B.
[0143] The hair texture generation method provided in this embodiment involves baking all hair textures based on the same high-poly model within a single software, resulting in good matching between them.
[0144] Hair settings are achieved by adjusting basic surface properties or setting hair properties in the attribute array of the Detail function. This avoids using irreversible nodes in Groom and nodes that require manipulation of the model on the display interface, allowing the editing process to proceed in any order. The shape and style of the hair can be changed with very simple operations, and a large number of hair sets with different styles can be generated gradually.
[0145] Using Houdini without the need for complex node operations greatly lowers the barrier to entry and significantly improves its friendliness to artists.
[0146] The secondary development based on Houdini's Groom integrates all operations into a single interface, for example... Figures 7 to 9 As shown, this significantly improves the efficiency of texture creation. Furthermore, it provides a one-stop solution for hair texture creation, avoiding the cumbersome process of importing and exporting hair models and textures between multiple software programs.
[0147] Furthermore, a density map generation method is proposed to meet the needs of hair effects in different scenarios. It also solves the problem of mismatch between tangent maps and hair section models caused by stretching.
[0148] Based on the same application concept, please refer to Figure 10 This illustration shows a functional module diagram of the hair texture generation device 110 provided in this embodiment. This embodiment can divide the hair texture generation device 110 into functional modules according to the above method embodiment. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware or as software functional modules. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0149] For example, when dividing functional modules according to their respective functions, Figure 10 The hair texture generation device 110 shown is only a schematic diagram of the device. The hair texture generation device 110 may include a first production module 111, a second production module 112, a setting module 113, and a generation module 114. The functions of each functional module of the hair texture generation device 110 will be described in detail below.
[0150] The first production module 111 is used to create a hair section planning diagram, which includes target hair strand information;
[0151] It is understood that the first production module 111 can be used to perform the above step S11. For details on the implementation of the first production module 111, please refer to the relevant content of the above step S11.
[0152] The second production module 112 is used to produce a background board and multiple hair section partitions, wherein the multiple hair section partitions are obtained by dividing the target hair strand information according to the hair section planning diagram;
[0153] It is understood that the second production module 112 can be used to perform the above step S12. For details on the implementation of the second production module 112, please refer to the relevant content of the above step S12.
[0154] Setting module 113 is used to set hair strands in each hair section on the background plate according to the target hair strand information to obtain a high-resolution hair strand model.
[0155] It is understood that the setting module 113 can be used to perform the above step S13. For details on the implementation of the setting module 113, please refer to the relevant content of the above step S13.
[0156] The generation module 114 is used to generate multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand.
[0157] It is understood that the generation module 114 can be used to perform the above step S14. For details on the implementation of the generation module 114, please refer to the relevant content of the above step S14.
[0158] In one possible implementation, the hair texture generation device 110 further includes a rendering module, which is used for:
[0159] The hair model of the target virtual character is rendered using the aforementioned multiple texture data to obtain the corresponding hair rendering result.
[0160] In one possible implementation, the texture data includes a tangent texture for storing hair tangent information, and the hair texture generation device 110 further includes a storage module for:
[0161] For each hair section in the low-mold of the hair section, obtain the unnormalized tangent component and sub-tangent component of any poly on the hair section, and calculate the elongation parameter of any poly of the low-mold of the hair section based on the tangent component and sub-tangent component.
[0162] The stretching parameters are stored in the vertex properties of any poly of the low-poly model of the hair piece, so as to correct the deviation of the tangent direction in the tangent map caused by the stretching of the hair piece when rendering the hair.
[0163] In one possible implementation, the rendering module described above is used for:
[0164] For any pixel in the low-poly model of the hair section, obtain the hair tangent information included in the tangent texture in the multiple texture data, and store the hair tangent information in the tangent texture in a linear color format;
[0165] The hair tangent information is converted into tangent vectors in tangent space, and then the tangent vectors in tangent space are converted into tangent vectors in world space through coordinate transformation.
[0166] Extract the stretching parameter stored in the vertex attributes of any pixel, and multiply the stretching parameter by the secondary tangent component of the tangent vector to obtain the corrected tangent vector;
[0167] The hair model of the target virtual character is rendered using the corrected tangent vectors to obtain the corresponding hair rendering result.
[0168] In one possible implementation, the above storage module is used for:
[0169] Determine the triangular model to which any poly on the hairpiece belongs, wherein the triangular model includes three vertices;
[0170] Based on the position information of the three vertices, the texture horizontal coordinate information, and the texture vertical coordinate information, the unnormalized tangent component and the secondary tangent component of the arbitrary poly are calculated.
[0171] The elongation parameter of any poly of the low-mold hairpiece is obtained by dividing the length of the tangent component by the length of the sub-tangent component.
[0172] In one possible implementation, the setting module 113 described above is used for:
[0173] A transparent surface is made on the background plate to support each of the hair section sections, and the transparent surface has basic surface properties that affect the setting of hair strands;
[0174] For the hair strand attributes present in the basic surface attributes, the corresponding hair strand attributes in the basic surface attributes are set according to the target hair strand information to achieve hair strand setting;
[0175] For hair strand attributes that are not present in the basic surface attributes, obtain the hair strand attributes that are pre-stored in the Detail function and correspond to the transparent surface in the attribute array, and set the hair strand attributes in the attribute array according to the target hair strand information to achieve hair strand setting.
[0176] In one possible implementation, the plurality of texture data includes a density texture for characterizing hair density and thickness information, and the generation module 114 is used for:
[0177] For each hair bundle in the high-resolution model of the hair strand, determine the number of overlapping hair strands on each pixel of the hair bundle;
[0178] Determine the range of the number of overlapping hair strands on each pixel, and obtain the transparency parameter corresponding to the range of the number of hair strands.
[0179] A density map corresponding to the target hair strand is generated based on the transparency parameter corresponding to each pixel.
[0180] Please see Figure 11 This is a structural block diagram of an electronic device provided in an embodiment of this application. The electronic device includes a memory 130, a processor 120, and a communication module 140. The memory 130, processor 120, and communication module 140 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0181] The memory 130 is used to store programs or data. The memory 130 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0182] The processor 120 is used to read / write data or programs stored in the memory 130 and execute the hair texture generation method provided in any embodiment of this application.
[0183] The communication module 140 is used to establish a communication connection between the electronic device and other communication terminals via a network, and to send and receive data via the network.
[0184] It should be understood that, Figure 11 The structure shown is only a schematic diagram of an electronic device; the electronic device may also include components that are larger than... Figure 11 The more or fewer components shown, or having the same Figure 11 The different configurations shown.
[0185] Furthermore, embodiments of this application also provide a computer-readable storage medium storing machine-executable instructions, which, when executed, implement the hair texture generation method provided in the above embodiments.
[0186] Specifically, the computer-readable storage medium can be a general-purpose storage medium, such as a removable disk or hard disk. When the computer program on the computer-readable storage medium is run, it can execute the above-described hair texture generation method. The processes involved in the execution of the executable instructions on the computer-readable storage medium can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0187] In summary, the hair texture generation method, apparatus, electronic device, and readable storage medium provided in this application first create a hair section planning map, which includes target hair strand information. Then, a background plate and multiple hair section partitions are created, wherein the multiple hair section partitions are divided according to the target hair strand information in the hair section planning map. On the background plate, hair strands are set for each hair section partition according to the target hair strand information to obtain a high-poly model of the hair strands. Based on the high-poly model, multiple texture data corresponding to the target hair strands are generated. In this solution, the hair section planning map provides a basis for hair strand setting, and matching texture data is generated based on the high-poly model of the hair strands. On the one hand, this ensures that the hair strand settings generate corresponding high-poly models of the hair strands as required; on the other hand, the textures generated based on the high-poly model of the hair strands meet the requirements for high-level textures in the hair model, thereby improving the quality of the hair model.
[0188] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for generating hair textures, characterized in that, The method includes: Create a hair section planning diagram, which includes target hair strand information; Create a background panel and multiple hair section sections, wherein the multiple hair section sections are divided according to the target hair strand information in the hair section planning diagram; On the background board, hair strands are set for each hair section according to the target hair strand information to obtain a high-resolution hair strand model; Based on the high-poly model of the hair strand, generate multiple texture data corresponding to the target hair strand; The texture data includes a tangent texture for storing hair tangent information, and the method further includes: For each hair section in the produced low-poly hair section, the triangular model to which any poly on the hair section belongs is determined. The triangular model includes three vertices. Based on the position information, texture x-coordinate information, and texture y-coordinate information of the three vertices, the unnormalized tangent component and subtangent component of the arbitrary poly are calculated. The length of the tangent component is divided by the length of the subtangent component to obtain the stretching parameter of any poly in the low-poly hair section. The stretching parameter is stored in the vertex attribute of any poly in the low-poly hair section. For any pixel in the low-poly model of the hair section, obtain the hair tangent information included in the tangent map in the multiple texture data, and store the hair tangent information in the tangent map in a linear color format; The hair tangent information is converted into tangent vectors in tangent space, and then the tangent vectors in tangent space are converted into tangent vectors in world space through coordinate transformation. Extract the stretching parameter stored in the vertex attributes of any pixel, and multiply the stretching parameter by the secondary tangent component of the tangent vector to obtain the corrected tangent vector; The corrected tangent vectors are used to render the hair model of the target virtual character, resulting in the corresponding hair rendering result.
2. The hair texture generation method according to claim 1, characterized in that, The multiple texture data include density textures used to characterize hair density and thickness information; The step of generating multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand includes: For each hair bundle in the high-resolution model of the hair strand, determine the number of overlapping hair strands on each pixel of the hair bundle; Determine the range of the number of overlapping hair strands on each pixel, and obtain the transparency parameter corresponding to the range of the number of hair strands. A density map corresponding to the target hair strand is generated based on the transparency parameter corresponding to each pixel.
3. The hair texture generation method according to claim 1, characterized in that, The step of setting the hair strands in each hair section according to the target hair strand information includes: A transparent surface is made on the background plate to support each of the hair section sections, and the transparent surface has basic surface properties that affect the setting of hair strands; For the hair strand attributes present in the basic surface attributes, the corresponding hair strand attributes in the basic surface attributes are set according to the target hair strand information to achieve hair strand setting; For hair strand attributes that are not present in the basic surface attributes, obtain the hair strand attributes that are pre-stored in the Detail function and correspond to the transparent surface in the attribute array, and set the hair strand attributes in the attribute array according to the target hair strand information to achieve hair strand setting.
4. A hair texture generation device, characterized in that, The apparatus for implementing the hair texture generation method according to any one of claims 1-3, the apparatus comprising: The first production module is used to create a hair section planning diagram, which includes target hair strand information; The second production module is used to create a background board and multiple hair section partitions, wherein the multiple hair section partitions are obtained by dividing the target hair strands according to the hair section planning diagram; The setting module is used to set the hair strands in each hair section on the background board according to the target hair strand information to obtain a high-resolution hair strand model. The generation module is used to generate multiple texture data corresponding to the target hair strand based on the high-poly model of the hair strand.
5. An electronic device, characterized in that, The device includes one or more storage media and one or more processors communicating with the storage media. The one or more storage media store machine-executable instructions that are executable by the processor. When the electronic device is running, the processor executes the machine-executable instructions to perform the method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores machine-executable instructions that, when executed by a processor, implement the method described in any one of claims 1-3.
Citation Information
Patent Citations
Rendering method and device, computer equipment and storage medium
CN115082615A
Three-dimensional model generation method and device, electronic equipment and storage medium
CN115761111A