Hair model generation method and device, computer device, and storage medium
By calculating the offset based on the position information and offset slope of the patch model during the hair rendering process, and controlling the offset of the patch model, the problems of low hair rendering efficiency and insufficient realism are solved, and a highly efficient hair rendering effect is achieved.
Patent Information
- Application Number
- CN202210488524.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-06
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2042-05-06
AI Technical Summary
In existing technologies, hair rendering techniques struggle to achieve efficient and realistic hair effects with a minimal number of model layers, resulting in low rendering efficiency and insufficient realism.
By obtaining the position information of the patch model, the hair segment to which it belongs is determined, and the offset of the patch model is calculated based on the offset slope of different hair segments. Different offset slopes are set to control the offset of the patch model, so that more patch models are offset closer to the outer layer of hair, reducing the phenomenon of layer breaks and improving rendering efficiency.
With fewer layers of surface models, a more realistic hair rendering effect is achieved, rendering gaps are avoided, and hair rendering efficiency is improved.
Smart Images

Figure CN114842119B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to a hair model generation method, apparatus, computer device, and computer-readable storage medium (hereinafter referred to as storage medium). Background Technology
[0002] With the development of computer graphics technology, video games, animated films, and other applications using 3D graphics technology are becoming increasingly common. Among these, hair rendering typically employs MultiPass rendering technology. This involves replicating the model along its normals to create multiple layers, rendering one layer per pass, and then rendering multiple layers to make the hair appear to grow from the model's surface. More layers result in more realistic hair, but this increases rendering overhead and reduces efficiency. Conversely, fewer layers result in lower rendering overhead and higher efficiency, but can lead to noticeable gaps in the rendered hair, reducing realism. Finding a balance between realistic hair and rendering efficiency is challenging; achieving good hair effects with as few layers as possible is a crucial problem that needs to be solved. Summary of the Invention
[0003] Therefore, it is necessary to provide a hair model generation method, apparatus, computer device, and storage medium to address the aforementioned technical problems, so as to achieve better hair effects using as few model layers as possible.
[0004] In a first aspect, this application provides a method for generating a hair model, the method comprising:
[0005] Obtain the surface model of the hair effect to be rendered;
[0006] Based on the positional information of the patch model, determine the hair segment to which the patch model belongs;
[0007] The offset of the patch model is calculated based on the hair segment to which the patch model belongs and the offset slope of different hair segments.
[0008] Hair models are generated based on patch models and their offsets.
[0009] In some embodiments of this application, determining the hair segment to which the patch model belongs based on the position information of the patch model includes:
[0010] Obtain the number of channels in different hair segments;
[0011] Based on the location information of the patch model and the number of channels in different hair segments, the patch model is classified to obtain the hair segment to which the patch model belongs.
[0012] In some embodiments of this application, the offset of the patch model is calculated based on the hair segment to which the patch model belongs and the offset slope of different hair segments, including:
[0013] The first offset slope is determined from the offset slopes of different hair segments;
[0014] The index value of the patch model is determined based on its position information;
[0015] The offset of the patch model is obtained by multiplying the index value and the first offset slope.
[0016] In some embodiments of this application, the offset of the patch model is calculated based on the hair segment to which the patch model belongs and the offset slope of different hair segments, including:
[0017] The second offset slope is determined from the offset slopes of different hair segments;
[0018] The index value of the patch model is determined based on its position information;
[0019] Calculate the product of the index value and the second offset slope to obtain the offset distance of the patch model;
[0020] The offset of the patch model is obtained based on the starting position and offset distance of the hair segment to which the patch model belongs.
[0021] In some embodiments of this application, before calculating the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments, the method further includes:
[0022] Obtain the number of channels and segmentation parameters for different hair segments;
[0023] Obtain the hair length of the hair effect to be rendered, and obtain the total offset of each hair segment based on the division parameters of different hair segments and the hair length.
[0024] The offset slope of each hair segment is calculated based on the total offset of each hair segment and the number of channels in each hair segment.
[0025] In some embodiments of this application, the hair segment includes the hair root segment, the hair middle segment, and the hair tip segment;
[0026] The number of channels increases sequentially from the root segment of the hair to the middle segment and the tip segment of the hair.
[0027] In some embodiments of this application, a hair model is generated based on a patch model and the offset of the patch model, including:
[0028] Based on the position information and offset of the patch model, the patch model is offset along the normal direction of the bottom patch model to obtain the initial patch model.
[0029] Obtain hair rendering data, and render each initial patch model based on the hair rendering data to obtain the hair model.
[0030] In some embodiments of this application, the hair rendering data includes noise maps and color maps;
[0031] Render each initial patch model based on the hair rendering data to obtain the hair model, including:
[0032] Based on the position information of the initial patch model, set the pixel attenuation amount of the initial patch model;
[0033] Based on the noise map and the pixel attenuation of the initial patch model, the initial patch model is cropped to obtain the target patch model;
[0034] By combining color mapping with color rendering of the target surface model, the hair model is obtained.
[0035] In some embodiments of this application, after color rendering of the target patch model using color mapping to obtain the hair model, the process includes:
[0036] Based on the position information of the target patch model, set the grayscale parameters of the target patch model;
[0037] Determine the color parameters of the target patch model based on the color map and the grayscale parameters of the target patch model;
[0038] The target patch model is rendered using color parameters to generate a hair model.
[0039] Secondly, this application provides a hair model generation apparatus, the apparatus comprising:
[0040] The patch model acquisition module is used to acquire the patch model of the hair effect to be rendered;
[0041] The hair segment determination module is used to determine the hair segment to which the patch model belongs based on the position information of the patch model;
[0042] The offset determination module is used to calculate the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments.
[0043] The hair model rendering module is used to generate hair models based on the patch model and the offset of the patch model.
[0044] Thirdly, this application also provides a computer device, which includes:
[0045] One or more processors; memory; and one or more applications, wherein one or more applications are stored in memory and configured to be executed by the processor to implement the hair model generation method.
[0046] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute the steps in the hair model generation method.
[0047] Fifthly, embodiments of this application provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned hair model generation method.
[0048] The aforementioned hair model generation method, apparatus, computer equipment, and storage medium acquire a patch model of the hair effect to be rendered; determine the hair segment to which the patch model belongs based on the position information of the patch model; calculate the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments; and generate a hair model based on the patch model and its offset. By setting different offset slopes for different hair segments, the offset of the patch model can be controlled in multiple segments. With a certain number of patch models, controlling the offset of patch models belonging to different hair segments allows more patch models to be offset to hair segments closer to the outer layer of hair. This results in more patch models with smaller spacing in hair segments closer to the outer layer of hair, avoiding layering in the rendered hair model and achieving a more realistic hair rendering effect with fewer patch model layers, thus improving hair rendering efficiency. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is a flowchart illustrating the hair model generation method in an embodiment of this application;
[0051] Figure 2 This is a schematic diagram of the hair segment in an embodiment of this application;
[0052] Figure 3This is a schematic diagram of another hair segment in an embodiment of this application;
[0053] Figure 4 This is a schematic diagram of the offset of the patch model in the embodiments of this application;
[0054] Figure 5 This is a flowchart illustrating the hair model acquisition steps in an embodiment of this application;
[0055] Figure 6 This is a flowchart illustrating another hair model acquisition step in an embodiment of this application;
[0056] Figure 7 This is a schematic diagram of the noise map in an embodiment of this application;
[0057] Figure 8A This is a schematic diagram of the patch model in the embodiments of this application;
[0058] Figure 8B This is a schematic diagram of another patch model in an embodiment of this application;
[0059] Figure 9 This is a flowchart illustrating another hair model acquisition step in an embodiment of this application;
[0060] Figure 10 This is a schematic diagram of the hair model generation device in the embodiments of this application;
[0061] Figure 11 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0063] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0064] In the description of this application, the word "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0065] The hair model generation method provided in this application can run on a terminal device or a server. The terminal device can be a local terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Taking the application of this hair model generation method in a video game scene as an example, the video game server can generate hair models of virtual characters in the video game scene based on this hair model generation method, realizing the rendering of hair effects.
[0066] See Figure 1 This application provides a hair model generation method, mainly illustrated by its application to a server. The method includes steps S110 to S140, as follows:
[0067] S110, obtain the surface model of the hair effect to be rendered.
[0068] Among them, the patch model refers to the model corresponding to the area on the target object where hair is to be generated. The server can render the hair corresponding to the target object based on the patch model.
[0069] Understandably, the target object refers to the object to be rendered in the 3D drawing. Taking a game scene as an example, the target object can be a virtual character to be generated through 3D drawing rendering in the game scene, such as an animal virtual character in the game scene. The patch model can be used to render the fur covering the animal virtual character. Or, for example, a human virtual character in the game scene, the patch model can be used to render the human virtual character's hair or the furry clothing on the human virtual character.
[0070] Furthermore, to achieve a more realistic hair effect, multiple patch models are used, each serving as a layer in the hair model. By controlling the offset of each patch model by different distances, a hair model with a certain hair thickness is constructed; that is, the hair model comprises multiple patch models. Specifically, the initial model of the target object can be copied to obtain a preset number of patch models, and each patch model is identical to the initial model of the target object. Hair rendering is then performed based on the patch models to obtain a display effect where the target object is covered with hair.
[0071] S120, based on the position information of the patch model, determine the hair segment to which the patch model belongs.
[0072] The positional information of the patch model can be its index value, hierarchical order information, or other information reflecting the distance between the patch model and the initial model. In other words, the positional information of the patch model can reflect its order, such as copy order or offset order. For example, the closer the patch model is to the initial model of the target object, the earlier the patch model will be in the copy order or offset order; conversely, the farther the patch model is from the initial model of the target object, the later the patch model will be in the copy order or offset order. Specifically, in the process of obtaining the patch model for rendering the hair effect, the obtained patch models can be sorted to determine their index values and obtain their positional information.
[0073] Here, a hair segment refers to the location marker after dividing the hair according to its length; specifically, there can be multiple hair segments. For example, such as... Figure 2 As shown, dividing hair into three segments can result in a hair segment comprising the root segment, the middle segment, and the tip segment; for example, as... Figure 3 As shown, if hair is divided into 4 segments, then the hair segments can include the first segment, the second segment, the third segment, and the fourth segment.
[0074] When the server-determined location information indicates that the patch model is closer to the initial model of the target object (smaller index value), the hair segment to which the patch model belongs is the segment near the hair root; that is, the patch model is used to render and display pixels near the inner root of the hair. Conversely, when the location information indicates a greater distance from the initial model of the target object (larger index value), the hair segment to which the patch model belongs is the segment farthest from the hair root; that is, the patch model is used to render and display pixels near the outer tip of the hair. Specifically, hair segment division location information can be pre-set. After determining the location information of the patch model, the hair segment to which the patch model belongs is determined based on the location information and the hair segment division location information.
[0075] Furthermore, in one embodiment, step S120 specifically includes: obtaining the number of channels in different hair segments; classifying the face model according to the position information of the face model and the number of channels in different hair segments to obtain the hair segment to which the face model belongs.
[0076] In the process of rendering hair effects, one pass renders one layer of the face model. Therefore, the number of passes for different hair segments can be preset. The total number of passes for all hair segments is equal to the total number of face models. Specifically, the number of passes for different hair segments is different.
[0077] Furthermore, to avoid discontinuities in the final hair effect, the hair segments closer to the outer layer have more channels, allowing more facet models to be used for rendering and displaying pixels near the tips of the outer hair layer. For example, with Figure 2 For example, the tip segment has the most channels, the middle segment has the second most channels, and the root segment has the fewest channels.
[0078] Specifically, after obtaining the number of channels in the hair segment, the hierarchical order of the patch model can be determined based on its positional information. Then, the patch model can be classified according to the hierarchical order to determine the hair segment to which the patch model belongs.
[0079] Still with Figure 2 For example, there are 3 hair segments. Assume the root segment has 5 channels, the middle segment has 15 channels, and the tip segment has 20 channels. The total number of facet models is 40. The index values of each facet model are labeled from 1 to 40. When the index value of a facet model is 1, the hair segment to which the facet model belongs is determined to be the root segment. When the index value of a facet model is 15, the hair segment to which the facet model belongs is determined to be the middle segment. When the index value of a facet model is 30, the hair segment to which the facet model belongs is determined to be the tip segment.
[0080] S130, calculate the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments.
[0081] The offset can refer to the offset distance between the patch model and the initial model of the target object.
[0082] The offset slope controls the offset of the patch model and reflects the degree of change in the offset of the patch model in different hair segments. Specifically, the offset slope is used to calculate the distance from the starting position. The larger the offset slope, the greater the distance between the patch model and the starting position, and the greater the degree of change in the offset between the patch models. The smaller the offset slope, the smaller the distance between the patch model and the starting position, and the smaller the degree of change in the offset between the patch models.
[0083] Specifically, different offset slopes are set for different hair segments. After obtaining the hair segment to which the patch model belongs, the offset of each patch model under different hair segments is calculated according to the offset slope corresponding to the hair segment to which the patch model belongs, so as to control the offset of the patch model in different hair segments.
[0084] Understandably, hair models are created by stacking layers of surface models. By setting different offset slopes for different hair segments, the stacking effect of surface models in different hair segments can be controlled, improving the flexibility of surface model offset adjustment. This results in more surface models being stacked near the outer layer of hair with smaller gaps, avoiding the rendering of hair with discontinuities and improving the realism of the hair effect. This allows for rendering more realistic hair effects using fewer surface models.
[0085] Furthermore, the offset slope is used to calculate the distance from the starting position, which can refer to the starting position of the hair model composed of patch models, such as the position of the initial model of the target object. In one embodiment, the offset of the patch model is calculated based on the hair segment to which the patch model belongs and the offset slope of different hair segments, including: determining a first offset slope from the offset slopes of different hair segments; determining the index value of the patch model based on the position information of the patch model; and obtaining the offset of the patch model by multiplying the index value and the first offset slope.
[0086] The index value of the patch model refers to the identification information of the patch model, used to identify the hierarchical information of the patch model. For example, from the innermost patch model to the outermost patch model, the index values are "1", "2", "3", etc. Specifically, different hair segments are set with different offset slopes. After obtaining the hair segment to which a certain patch model belongs, the first offset slope of the hair segment to which the patch model belongs can be determined. Then, the product of the index value and the first offset slope is determined as the offset of the patch model. It can be understood that the offset here refers to the offset relative to the initial model of the target object.
[0087] like Figure 4 As shown, Figure 4The diagram shows the initial model of the target object and the multi-layered patch model obtained by copying the initial model. Patch models with index values 1 to 3 represent the root segment, patch models with index values 4 to 7 represent the root segment, and patch models with index values 8 to 13 represent the tip segment. Taking the patch model with index value 1 as an example, the first offset slope corresponding to the root segment is determined from the offset slopes of different hair segments. Then, the offset of the patch model with index value 1 from the initial model is obtained by multiplying the index value 1 and the first offset slope. Taking the patch model with index value 6 as an example, the first offset slope corresponding to the middle segment is determined from the offset slopes of different hair segments. Then, the offset of the patch model with index value 6 from the initial model is obtained by multiplying the index value 6 and the first offset slope.
[0088] Furthermore, the offset slope is used to calculate the distance from the starting position. The starting position here can also refer to the starting position of the hair segment to which the patch model belongs. For example, it could be the position of the outermost patch model in the previous hair segment of the hair segment to which the patch model belongs. In one embodiment, the offset of the patch model is calculated based on the hair segment to which the patch model belongs and the offset slopes of different hair segments, including: determining a second offset slope from the offset slopes of different hair segments; determining the index value of the patch model based on the position information of the patch model; calculating the product of the index value and the second offset slope to obtain the offset distance of the patch model; and obtaining the offset of the patch model based on the starting position of the hair segment to which the patch model belongs and the offset distance.
[0089] Specifically, after obtaining the hair segment to which a certain patch model belongs, the second offset slope of the hair segment to which the patch model belongs can be determined. Then, the product of the index value and the second offset slope is determined as the offset distance of the patch model in the hair segment. Finally, the sum of the starting position and the offset distance of the hair segment to which the patch model belongs is obtained, and the sum is determined as the offset relative to the initial model of the target object.
[0090] Still with Figure 4 For example, Figure 4The diagram shows the initial model of the target object and the multi-layered patch model obtained by copying the initial model. The starting position of the middle segment can be set to the position of the patch model with index value 3, and the starting position of the tip segment can be set to the position of the patch model with index value 7. If the hair segment to which the patch model belongs has no preceding hair segment, such as the root segment, then the position of the initial model of the target object is determined as the starting position; that is, the starting position of the root segment is set to the position of the initial model. Taking the patch model with index value 1 as an example, the second offset slope corresponding to the root segment is determined from the offset slopes of different hair segments. Then, based on the product of index value 1 and the second offset slope, the offset distance of the patch model with index value 1 from the initial model is obtained. This offset distance can be determined as the offset amount of the patch model with index value 1. Taking the patch model with index value 6 as an example, the second offset slope corresponding to the middle segment is determined from the offset slopes of different hair segments. Then, based on the product of index value 6 and the second offset slope, the offset distance of the patch model with index value 6 relative to the patch model with index value 3 is obtained. Then, based on the position of the patch model with index value 3 (i.e. the starting position of the middle segment) and the offset distance relative to the patch model with index value 3, the offset of the patch model with index value 6 from the initial model is determined.
[0091] In one embodiment, before calculating the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments, the method further includes: obtaining the number of channels and partitioning parameters of different hair segments; obtaining the hair length of the hair effect to be rendered, and obtaining the total offset of each hair segment based on the partitioning parameters and hair length of different hair segments; and calculating the offset slope of each hair segment based on the total offset of each hair segment and the number of channels of each hair segment.
[0092] The segmentation parameters refer to the location information for dividing hair segments. For example, using... Figure 2 For example, one end of a hair can be set to 0 and the other end can be set to 1. In this case, the division parameter of the root segment is set to 0.2, the division parameter of the middle segment is set to 0.5, and the division parameter of the tip segment is set to 1. That is, the position from 0 to 0.2 is the root segment (the root segment accounts for 20% of the whole hair), the position from 0.2 to 0.5 is the middle segment (the middle segment accounts for 30% of the whole hair), and the position from 0.5 to 1 is the tip segment (the tip segment accounts for 50% of the whole hair).
[0093] The total offset of different hair segments refers to the length corresponding to different hair segments. After obtaining the division parameters of different hair segments, the hair length of each hair segment is determined according to the hair length of the hair to be generated, i.e., the total offset. Then, based on the total offset of each hair segment and the number of channels, the offset slope of each hair segment is calculated.
[0094] For example, with Figure 2 For example, the number of channels in the root segment is y1, and the total offset is x1; the number of channels in the middle segment is y2, and the total offset is x2; the number of channels in the tip segment is y3, and the total offset is x3. By combining the slope formula with the two known points on the line, we can obtain the offset slope of the root segment as: k1 = y1 / x1, the offset slope of the middle segment as: k2 = (y2-y1) / (x2-x1), and the offset slope of the tip segment as: k3 = (y3-y2) / (x3-x2).
[0095] In one embodiment, the hair segment includes a hair root segment, a hair middle segment, and a hair tip segment; the number of channels in the hair root segment, the hair middle segment, and the hair tip segment increases sequentially.
[0096] S140, generates a hair model based on a patch model and the offset of the patch model.
[0097] After obtaining the offset of the patch model, each patch model is offset outward by the corresponding offset, and then the patch models are merged to obtain a hair model, which serves as the basis for subsequent hair rendering effects.
[0098] Specifically, such as Figure 5 As shown, in one embodiment, step S140 may specifically include:
[0099] S510, according to the position information and offset of the patch model, offset the patch model along the normal direction of the patch model located at the bottom layer to obtain the initial patch model.
[0100] S520: Obtain hair rendering data, and render each initial patch model based on the hair rendering data to obtain the hair model.
[0101] The location information can include the index value of the patch model, which reflects the order of the patch models; the bottom-level patch model can be the initial model of the target object, or the patch model whose location information indicates it is closest to the initial model; for example... Figure 4 As shown, the bottom-level patch model can be either the initial model or a patch model with an index value of 1. As mentioned above, the hair model can be obtained by controlling the offset of different patch models. Taking the bottom-level patch model as the initial model of the target object as an example, after obtaining the patch models and their offsets, the layer order of the patch models can be determined based on their position information. Then, according to the layer order of the patch models, along the normal direction of the initial model of the target object, each patch model is extruded with its corresponding offset to obtain the initial patch model.
[0102] The hair rendering data includes noise maps, color maps, and ambient light maps. The noise map controls the thickness and density of the rendered hair, the color map controls the color of the rendered hair, and the ambient light map controls the parameters of how the current ambient light affects the hair color.
[0103] After obtaining the hair rendering parameters, the server renders the initial patch model according to the hair rendering parameters to obtain the hair model.
[0104] Furthermore, such as Figure 6 As shown, in one embodiment, the hair rendering data includes noise maps and color maps; the hair model is obtained by rendering each initial patch model based on the hair rendering data, including:
[0105] S610, based on the position information of the initial patch model, sets the pixel attenuation amount of the initial patch model;
[0106] S620: Based on the noise map and the pixel attenuation of the initial patch model, the initial patch model is cropped to obtain the target patch model.
[0107] The S630 combines color mapping to render the target surface model, resulting in a hair model.
[0108] The noise map can include multiple noise points, which can be used to represent the distribution area of hair; for example, a reference... Figure 7 Each noise point (white area) represents a single hair.
[0109] The pixel attenuation amount is used to control the size of the rendered pixels on the initial patch model. Specifically, the server can determine the layer order of the initial patch model based on its position information, and then set the pixel attenuation amount of each initial patch model based on the layer order to control the size of the rendered pixels of the initial patch model. It can be understood that the pixel attenuation amount of the initial patch model increases as the layer order increases.
[0110] When cropping the initial patch model based on the noise map, the size of the white area in the noise map of the initial patch model decreases as the pixel attenuation of the patch model increases. This results in the white area in the corresponding noise map decreasing in size as the layer order of the initial patch model increases, and the target patch model obtained after cropping exhibits a hair effect.
[0111] like Figure 8AThe diagram shows an initial patch model. A "slice" of a layer can be regarded as a patch model. The patch model is offset according to its corresponding offset (the offset of different patch models in the figure is only an example) to obtain a multi-layered initial patch model with parallel distribution. The initial patch model is cropped using a noise map. Since the pixel attenuation of the initial patch model increases with the increase of the layer order, the opaque area in the noise map on the obtained target patch model becomes smaller and smaller. Finally, the multi-layered target patch model presents the shape of hair.
[0112] After obtaining the target surface model that resembles hair, color mapping can be used to render the target surface model to obtain a hair model with a specific color.
[0113] Taking a sphere as the target object, we obtain the corresponding facet model and the offset of each facet model. After offsetting the facet model according to its corresponding offset, we use a noise map to trim the initial facet model, resulting in... Figure 8B The target surface model shown is in the shape of hair. Color maps can be used to render the target surface model to make it display different colors.
[0114] Furthermore, since there are fewer facet models in the hair segments near the inner side of the hair, to avoid discontinuities in the hair area near the inner side, the color intensity of the target facet models can be adjusted, so that the target facet models that are further out are rendered with lighter colors, and the target facet models that are closer to the root are rendered with darker colors. In one embodiment, such as Figure 9 As shown, color rendering is performed on the target patch model using color mapping to obtain the hair model, including:
[0115] S910, set the grayscale parameters of the target patch model according to the position information of the target patch model;
[0116] S920 determines the color parameters of the target patch model based on the color map and the grayscale parameters of the target patch model;
[0117] S930 performs color rendering on the target patch model based on color parameters to generate a hair model.
[0118] The grayscale parameter controls the color depth of the target patch model. Specifically, the server can determine the layer order of the target patch model based on its position information, and then adjust the grayscale parameters of each layer of the target patch model based on the layer order. This results in the target patch model with a smaller layer order (i.e., closer to the hair tip) being rendered with a lighter color, closer to white, while the target patch model with a larger layer order (i.e., closer to the hair root) is rendered with a darker color, closer to black. This controls the color depth of the target patch model and avoids the layering phenomenon caused by the fewer layers in the hair segment near the hair root, thus optimizing the hair rendering effect.
[0119] Furthermore, the index value of the target patch model can be obtained based on its position information. The closer the target patch model is to the hair tip, the larger its index value; the closer it is to the hair root, the smaller its index value. Then, the grayscale parameters of the target patch model are set according to the index value; for example, the smaller the index value, the closer its grayscale parameter is to 1, and the larger the index value, the closer its grayscale parameter is to 0. Finally, when rendering colors based on the color map, the color of the target patch model is adjusted in conjunction with the grayscale parameters.
[0120] In the aforementioned hair model generation method, the following steps are taken: First, a patch model of the hair to be rendered is obtained. Then, based on the positional information of the patch model, the hair segment to which the patch model belongs is determined. Next, the offset of the patch model is calculated based on the hair segment to which it belongs and the offset slopes of different hair segments. Finally, the hair model is generated based on the patch model and its offset. By setting different offset slopes for different hair segments, the offset of the patch model can be controlled in multiple segments, resulting in different offset distances for patch models in different hair segments, thus improving the controllability of the patch model offset. Furthermore, with a certain number of patch models, by controlling the offset of patch models belonging to different hair segments, more patch models are offset closer to the outer layer of the hair. This results in more layers and smaller spacing in the patch models near the outer layer of the hair, avoiding layering in the rendered hair model. This achieves a more realistic hair rendering effect with fewer patch model layers, improving hair rendering efficiency.
[0121] To better implement the hair model generation method provided in the embodiments of this application, based on the hair model generation method proposed in the embodiments of this application, this application also provides a hair model generation device, such as... Figure 10 As shown, the hair model generation device 1000 includes:
[0122] The patch model acquisition module 1010 is used to acquire the patch model of the hair effect to be rendered;
[0123] The hair segment determination module 1020 is used to determine the hair segment to which the patch model belongs based on the position information of the patch model;
[0124] The offset determination module 1030 is used to calculate the offset of the patch model based on the hair segment to which the patch model belongs and the offset slope of different hair segments.
[0125] The hair model rendering module 1040 is used to generate hair models based on the patch model and the offset of the patch model.
[0126] In some embodiments of this application, the hair segment determination module is specifically used to obtain the number of channels in different hair segments; based on the position information of the patch model and the number of channels in different hair segments, the patch model is classified to obtain the hair segment to which the patch model belongs.
[0127] In some embodiments of this application, the offset determination module is specifically used to determine a first offset slope from the offset slopes of different hair segments; determine the index value of the patch model based on the position information of the patch model; and obtain the offset of the patch model based on the product of the index value and the first offset slope.
[0128] In some embodiments of this application, the offset determination module is specifically used to determine a second offset slope from the offset slopes of different hair segments; determine the index value of the patch model according to the position information of the patch model; calculate the product of the index value and the second offset slope to obtain the offset distance of the patch model; and obtain the offset of the patch model according to the starting position of the hair segment to which the patch model belongs and the offset distance.
[0129] In some embodiments of this application, the offset determination module is specifically used to obtain the number of channels and division parameters of different hair segments; obtain the hair length of the hair effect to be rendered, and obtain the total offset of each hair segment according to the division parameters and hair length of different hair segments; and calculate the offset slope of each hair segment according to the total offset of each hair segment and the number of channels of each hair segment.
[0130] In some embodiments of this application, the hair segment includes the hair root segment, the hair middle segment, and the hair tip segment; the number of channels in the hair root segment, the hair middle segment, and the hair tip segment increases sequentially.
[0131] In some embodiments of this application, the hair model rendering module is specifically used to offset the face model along the normal direction of the face model located at the bottom layer according to the position information and offset of the face model to obtain an initial face model; obtain hair rendering data, and render each initial face model according to the hair rendering data to obtain a hair model.
[0132] In some embodiments of this application, the hair rendering data includes a noise map and a color map; the hair model rendering module is specifically used to set the pixel attenuation amount of the initial patch model according to the position information of the initial patch model; to crop the initial patch model according to the noise map and the pixel attenuation amount of the initial patch model to obtain a target patch model; and to perform color rendering on the target patch model in combination with the color map to obtain a hair model.
[0133] In some embodiments of this application, the hair model rendering module is specifically used to set the grayscale parameters of the target patch model according to the position information of the target patch model; determine the color parameters of the target patch model according to the color map and the grayscale parameters of the target patch model; and perform color rendering on the target patch model based on the color parameters to generate a hair model.
[0134] In some embodiments of this application, the hair model generation device 1000 can be implemented as a computer program, which can be implemented in, for example... Figure 11 The computer device shown operates on this device. The computer device's memory can store the various program modules that make up the hair model generation apparatus 1000, for example, Figure 10 The diagram shows a patch model acquisition module 1010, a hair segment determination module 1020, an offset determination module 1030, and a hair model rendering module 1040. The computer program comprised of these modules causes the processor to execute the steps in the hair model generation methods of the various embodiments of this application described in this specification.
[0135] For example, Figure 11 The computer device shown can be used as follows Figure 10 The patch model acquisition module 1010 in the hair model generation apparatus 1000 shown executes step S110. The computer device can execute step S120 via the hair segment determination module 1020. The computer device can execute step S130 via the offset determination module 1030. The computer device can execute step S140 via the hair model rendering module 1040. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with external computer devices via a network connection. When the computer program is executed by the processor, it implements a hair model generation method.
[0136] Those skilled in the art will understand that Figure 11The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0137] In some embodiments of this application, a computer device is provided, including one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processors as described in the hair model generation method. The steps of the hair model generation method here may be steps from the hair model generation methods of the various embodiments described above.
[0138] In some embodiments of this application, a computer-readable storage medium is provided, storing a computer program that is loaded by a processor, causing the processor to execute the steps of the hair model generation method described above. The steps of the hair model generation method here can be the steps in the hair model generation methods of the various embodiments described above.
[0139] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0140] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0141] The foregoing has provided a detailed description of a hair model generation method, apparatus, computer device, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method of generating a hair model, characterized by, The method comprises the following steps: acquiring a patch model of a hair effect to be rendered; acquiring the number of channels of different hair sections, which are different; classifying the patch model according to the position information of the patch model and the number of channels of the different hair sections to obtain a hair section to which the patch model belongs, and the more the number of channels of the hair section is, the more the patch model belonging to the hair section is; calculating the offset of the patch model according to the hair section to which the patch model belongs and the offset slopes of the different hair sections; generating a hair model based on the patch model and the offset of the patch model.
2. The method of claim 1, wherein, The method of calculating the offset of the patch model according to the hair section to which the patch model belongs and the offset slopes of the different hair sections comprises the following steps: determining a first offset slope from the offset slopes of the different hair sections; determining an index value of the patch model according to the position information of the patch model; calculating the product of the index value and the first offset slope to obtain the offset of the patch model.
3. The method of claim 1, wherein, The method of calculating the offset of the patch model according to the hair section to which the patch model belongs and the offset slopes of the different hair sections comprises the following steps: determining a second offset slope from the offset slopes of the different hair sections; determining an index value of the patch model according to the position information of the patch model; calculating the product of the index value and the second offset slope to obtain the offset distance of the patch model; acquiring the offset of the patch model according to the starting position of the hair section to which the patch model belongs and the offset distance.
4. The method according to any one of claims 1 to 3, characterized in that, Before the method of calculating the offset of the patch model according to the hair section to which the patch model belongs and the offset slopes of the different hair sections, the method further comprises the following steps: acquiring the number of channels of different hair sections and division parameters; acquiring the length of hair to be rendered and acquiring the total offset of each hair section according to the division parameters of the different hair sections and the length of hair; calculating the offset slope of each hair section according to the total offset of each hair section and the number of channels of each hair section.
5. The method of claim 4, wherein, The hair section comprises a hair root section, a hair middle section and a hair tip section; The number of channels of the hair root section, the hair middle section and the hair tip section increases in turn.
6. The method of claim 1, wherein, The method of generating a hair model based on the patch model and the offset of the patch model comprises the following steps: offsetting the patch model along the normal direction of the patch model located at the bottom layer according to the position information and the offset of the patch model to obtain an initial patch model; acquiring hair rendering data and rendering each initial patch model according to the hair rendering data to obtain a hair model.
7. The method of claim 6, wherein, The hair rendering data comprises a noise map and a color map; The method of rendering each initial patch model according to the hair rendering data to obtain a hair model comprises the following steps: setting the pixel attenuation of the initial patch model according to the position information of the initial patch model; According to the noise map and pixel attenuation of the initial patch model, the initial patch model is cut to obtain a target patch model; The target patch model is color rendered in combination with a color map to obtain a hair model.
8. The method of claim 7, wherein, After the target patch model is color rendered in combination with the color map to obtain the hair model, the method comprises: According to position information of the target patch model, a gray parameter of the target patch model is set; According to the color map and the gray parameter of the target patch model, a color parameter of the target patch model is determined; The target patch model is color rendered based on the color parameter to generate a hair model.
9. A hair model generation apparatus characterized by comprising: The apparatus comprises: A patch model acquisition module is configured to acquire a patch model of a hair effect to be rendered; A hair section determination module is configured to acquire a number of channels of different hair sections, the number of channels of the different hair sections being different; and to classify the patch model according to position information of the patch model and the number of channels of the different hair sections to obtain a hair section to which the patch model belongs, the more the number of channels of the hair section, the more the patch model belonging to the hair section; An offset determination module is configured to calculate an offset of the patch model according to the hair section to which the patch model belongs and offset slopes of different hair sections; A hair model rendering module is configured to generate a hair model based on the patch model and the offset of the patch model.
10. A computer device, comprising: The computer device comprises: one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the hair model generation method in any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is loaded by a processor to execute steps in the hair model generation method in any one of claims 1 to 8.
Citation Information
Patent Citations
Hair model generation method and device, storage medium and electronic equipment
CN113409465A
Hair rendering method, device and storage medium
CN113888688A