Hair highlight rendering method and device
By adjusting the texture coordinates of the hair model and using highlight maps, dynamically adjusting the highlight position on the hair model, the problem of the problem of the inability to dynamically adjust the highlights and poor rendering quality when the curvature is too large in the existing technology is solved, and the hair rendering effect and user experience are improved .
Patent Information
- Application Number
- CN202410939819.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-15
AI Technical Summary
In the existing hair rendering technology, the highlighted parts based on the map cannot be adjusted dynamically. The tangent-based solution has poor rendering quality on hair patches with large curvature, resulting in a decrease in hair rendering quality and affecting user's visual perception.
By obtaining the texture coordinates of the hair model and the target vector in the vertical direction of the head, determine the target angle based on the standard line of sight vector and target vector, adjust the texture coordinates to obtain the sampling coordinates, and render the hair model with pre-configured highlight maps. Adjust the highlight position.
It has achieved improvements in hair rendering effects and improvements in user visual experience. Especially when scenes and viewing angles change, dynamic adjustment of highlight positions alleviates the problem of surface distortion and improves rendering quality.
Smart Images

Figure CN118967889A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of three-dimensional model technology, and in particular, to a hair highlight rendering method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] In cartoon rendering, hair rendering involves base color, highlights and shadows, among which the rendering effects of highlights and shadows directly affect the final rendering quality of hair.
[0003] However, among the existing rendering solutions, the highlight part of the map-based solution cannot be dynamically adjusted according to the needs, and the highlight part of the tangent-based solution has poor rendering quality on the hair patch with large curvature and is prone to irregular disturbances, which leads to a decrease in the rendering quality of the hair, thus affecting the user's viewing experience.
[0004] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the invention
[0005] Embodiments of the present application provide a hair highlight rendering method, apparatus, computer equipment, computer-readable storage medium, and computer program product to solve or alleviate one or more of the technical problems raised above.
[0006] One aspect of an embodiment of the present application provides a hair highlight rendering method, the method comprising:
[0007] Obtaining texture coordinates of a hair model and a target vector of a head vertical direction corresponding to the hair model in a world space;
[0008] Determining a target angle according to a standard sight line vector in the world space and the target vector;
[0009] Adjust the texture coordinates according to the target angle to obtain sampling coordinates;
[0010] The hair model is rendered according to the sampling coordinates and the pre-configured highlight map to obtain a hair model containing highlights.
[0011] Optionally, the hair model includes a plurality of contour lines, each contour line including a plurality of three-dimensional vertices;
[0012] Correspondingly, the obtaining of the texture coordinates of the hair model includes:
[0013] Mapping each three-dimensional vertex of the hair model to a texture coordinate system to obtain a two-dimensional coordinate of each three-dimensional vertex;
[0014] Performing a coordinate correction operation according to the plurality of contour lines and the two-dimensional coordinates of each three-dimensional vertex;
[0015] After performing the coordinate correction operation, the two-dimensional coordinates of each three-dimensional vertex are determined as the texture coordinates of each three-dimensional vertex.
[0016] Optionally, the coordinate correction operation includes: adjusting the difference in longitudinal coordinate values of two-dimensional coordinates corresponding to a plurality of three-dimensional vertices located on the same contour line to within a preset range.
[0017] Optionally, the method further comprises:
[0018] monitoring the target vector and the standard sight line vector;
[0019] When the target vector and / or the standard sight line vector change, obtaining the latest target vector and the latest standard sight line vector; and
[0020] The target angle is updated according to the latest target vector and the latest standard sight line vector.
[0021] Optionally, the highlight map includes a highlight area, and the highlight area includes a plurality of pixel points;
[0022] Among them, the pixel value of the middle pixel point of the highlight area is higher than the pixel value of the edge pixel point; in the highlight area, the pixel value of the pixel point gradually decreases from the middle to the edge; the pixel value is used to indicate the highlight intensity and / or highlight color.
[0023] Optionally, adjusting the texture coordinates according to the target angle to obtain sampling coordinates includes:
[0024] Determining a first intermediate coordinate according to the texture coordinate and the cosine value of the target angle;
[0025] Determining a second intermediate coordinate according to the first intermediate coordinate and a preset correction coefficient;
[0026] The sampling coordinates are determined according to the second intermediate coordinates and a preset offset value.
[0027] Optionally, rendering the hair model according to the sampling coordinates and a preconfigured highlight map includes:
[0028] According to the sampling coordinates, searching for corresponding pixel points in the highlight map;
[0029] Determine the highlight intensity and / or highlight color corresponding to the sampling coordinates according to the pixel value corresponding to the found pixel point;
[0030] Rendering each three-dimensional vertex of the hair model according to the highlight color and / or highlight intensity corresponding to the sampling coordinates.
[0031] Optionally, rendering the hair model according to the sampling coordinates and a pre-configured highlight map further includes:
[0032] Adjusting the longitudinal coordinate value of the sampling coordinate by using the pre-configured noise map and the sampling coordinate;
[0033] The hair model is rendered according to the sampling coordinates after the longitudinal coordinate values are adjusted and the highlight map.
[0034] Another aspect of an embodiment of the present application provides a hair highlight rendering device, the device comprising:
[0035] An acquisition module, used to acquire the texture coordinates of the hair model and a target vector of the head vertical direction corresponding to the hair model in the world space;
[0036] A determination module, used for determining a target angle according to a standard sight line vector of the world space and the target vector;
[0037] An adjustment module, used for adjusting the texture coordinates according to the target angle to obtain sampling coordinates;
[0038] The rendering module is used to render the hair model according to the sampling coordinates and a pre-configured highlight map to obtain a hair model containing highlights.
[0039] Another aspect of an embodiment of the present application provides a computer device, including:
[0040] at least one processor; and
[0041] a memory communicatively coupled to the at least one processor;
[0042] Wherein: the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0043] Another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described above is implemented.
[0044] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the method described above when executed by a processor.
[0045] The above technical solution adopted in the embodiment of the present application may have the following advantages:
[0046] The embodiment of the present application performs highlight rendering on the hair model through sampling coordinates and a pre-configured highlight map: for each three-dimensional vertex of the hair model, its sampling coordinates are obtained by adjusting its texture coordinates according to the vertical direction of the head of the hair model and the standard line of sight vector. That is, the sampling coordinates (the sampling position of the highlight map) can be adjusted in real time as the head moves or the line of sight changes, thereby dynamically controlling the position of the highlight on the hair model. It can be seen that the highlight rendering of the embodiment of the present application can be dynamically adjusted as the scene and / or viewing angle changes, effectively improving the rendering effect of the hair and the user's viewing experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0048] Figure 1 The flowchart of the hair highlight rendering method according to the first embodiment of the present application is schematically shown;
[0049] Figure 2 A hair model according to the first embodiment of the present application is schematically shown;
[0050] Figure 3 Schematically shows Figure 1 Flow chart of sub-steps of step S100;
[0051] Figure 4 A newly added flow chart of the hair highlight rendering method according to the first embodiment of the present application is schematically shown;
[0052] Figure 5 Schematically shows Figure 1 Flow chart of sub-steps of step S104;
[0053] Figure 6 The highlight map according to the first embodiment of the present application is schematically shown;
[0054] Figure 7 The highlight map according to the first embodiment of the present application is schematically shown;
[0055] Figure 8 Schematically shows Figure 1 Flow chart of sub-steps of step S106;
[0056] Fig. 9 Schematically shows Figure 1Flow chart of sub-steps of step S106;
[0057] Fig.10 The noise map according to the first embodiment of the present application is schematically shown;
[0058] Fig.11 A block diagram schematically shows a device for rendering hair highlights according to the second embodiment of the present application; and
[0059] Fig.12 The hardware architecture diagram of the computer device according to the third embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0061] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0062] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.
[0063] First, the following terms are explained:
[0064] World space: also known as the world coordinate system, is a reference coordinate system in three-dimensional space. It can provide a common reference frame for each object in the scene and can be used to accurately describe the position, direction and size of each object.
[0065] Secondly, in order to facilitate those skilled in the art to understand the technical solutions provided by the embodiments of the present application, the relevant technologies are described below. The applicant understands that the relevant rendering solutions are implemented based on maps or tangents. Among them, the rendering solution based on maps directly draws the highlights and shadows of the hair in the maps, and the highlights cannot change dynamically. The rendering solution based on tangents has high requirements on the hair production process, and requires manual adjustment and repeated iteration of the hair tangents in the three-dimensional modeling software. The production process is complicated and time-consuming. In addition, the tangent-based rendering solution is not suitable for hair models (hair patches) with too large surfaces, and the problem of hair highlight distortion will occur.
[0066] To this end, the embodiment of the present application provides a technical solution for hair highlight rendering. In this technical solution: (1) Highlight rendering is performed based on sampling coordinates and pre-configured highlight maps to alleviate the problem of shape distortion of highlights when the surface / curvature of the hair model (hair patch) is too large; (2) The position of the highlight on the hair model can be dynamically adjusted as the scene and / or line of sight changes, effectively improving the rendering quality of the hair and the user's viewing experience. See below for details.
[0067] The technical solutions of the present application are described below through multiple embodiments. It should be noted that these embodiments can be implemented in a variety of different forms and should not be construed as being limited to the embodiments described here.
[0068] Embodiment 1
[0069] Figure 1 The flowchart of the hair highlight rendering method according to the first embodiment of the present application is schematically shown.
[0070] like Figure 1 As shown, the hair highlight rendering method may include steps S100 to S106, wherein:
[0071] Step S100, obtaining texture coordinates of a hair model and a target vector of a head in a vertical direction corresponding to the hair model in a world space.
[0072] Step S102, determining a target angle according to the standard sight line vector of the world space and the target vector.
[0073] Step S104: adjusting the texture coordinates according to the target angle to obtain sampling coordinates.
[0074] Step S106, rendering the hair model according to the sampling coordinates and the pre-configured highlight map to obtain a hair model with highlights.
[0075] The hair highlight rendering method provided in this embodiment performs highlight rendering on the hair model through sampling coordinates and a pre-configured highlight map: for each three-dimensional vertex of the hair model, its sampling coordinates are obtained by adjusting its texture coordinates according to the vertical direction of the head of the hair model and the standard sight line vector. That is, the sampling coordinates (the sampling position of the highlight map) can be adjusted in real time as the head moves or the sight line changes, thereby dynamically controlling the position of the highlight on the hair model. It can be seen that this embodiment can dynamically adjust the position of the highlight on the hair model as the scene and / or viewing angle changes, effectively improving the rendering effect of the hair and the user's viewing experience.
[0076] The following combination Figure 1 , each step in steps S100 to S106 and other optional steps are described in detail.
[0077] Step S100 , obtain the texture coordinates of the hair model and the target vector of the vertical direction of the head corresponding to the hair model in the world space.
[0078] A hair model can be a three-dimensional model used to describe the hair on a person's or animal's head. It can be composed of a series of lines or patches, or composed of complex geometric bodies. The hair model is embedded in the character model and is closely integrated with the head model to achieve realistic animation effects. The hair model can include multiple three-dimensional vertices, each of which corresponds to a texture coordinate. Texture coordinates can be used to instruct the rendering engine to select pixels at specific locations in the texture image and apply them to the corresponding three-dimensional vertices (i.e., rendering). Among them, the texture image can include various texture information of each three-dimensional vertex, such as color, normal, transparency, etc. It can be seen that texture images include but are not limited to highlight maps, shadow maps, normal maps, transparency maps, displacement maps, etc. These maps can be used alone or combined to achieve more complex rendering effects and improve rendering quality.
[0079] There are many ways to obtain the texture coordinates of the hair model, such as: UV Projections, which projects the three-dimensional vertices of the hair model onto an imaginary plane (such as a sphere) through the projection method and converts them into two-dimensional texture coordinates; UVUnwrap, which uses the cutting line of the hair model as the reference line for UV unfolding and unfolds the surface of the hair model onto a two-dimensional plane; UV Flatten; UV Straighten, etc.
[0080] In order to further improve the hair highlight rendering effect, the texture coordinates can also be optimized. An exemplary solution is provided below.
[0081] In an optional embodiment, if Figure 2As shown, the hair model may be configured with a series of contour lines, each of which is located at a different height position of the hair model, such as the forehead, the top of the head, etc. Each contour line may include a plurality of three-dimensional vertices, and the three-dimensional vertices located on the same contour line have the same height.
[0082] Correspondingly, if Figure 3 As shown, step S100 may include:
[0083] Step S300, mapping each three-dimensional vertex of the hair model to a texture coordinate system to obtain a two-dimensional coordinate of each three-dimensional vertex.
[0084] Step S302: performing a coordinate correction operation according to the plurality of contour lines and the two-dimensional coordinates of each three-dimensional vertex.
[0085] Step S304: after performing the coordinate correction operation, determining the two-dimensional coordinates of each three-dimensional vertex as the texture coordinates of each three-dimensional vertex.
[0086] In practical applications, each three-dimensional vertex of the hair model can be mapped from the local coordinate system (model space) to the texture coordinate system (two-dimensional plane) to obtain the two-dimensional coordinates of each three-dimensional vertex, and each three-dimensional vertex corresponds to a two-dimensional coordinate. A coordinate correction operation can be performed according to the multiple contour lines and the two-dimensional coordinates of each three-dimensional vertex. In an optional embodiment, the coordinate correction operation may include: adjusting the longitudinal coordinate value difference of the two-dimensional coordinates corresponding to multiple three-dimensional vertices located on the same contour line to within a preset range. Exemplarily, the average value of the longitudinal coordinate values of the two-dimensional coordinates corresponding to each three-dimensional vertex of the same contour line can be obtained, and then the longitudinal coordinate values of the two-dimensional coordinates corresponding to each three-dimensional vertex of the same contour line are all adjusted to the average value, and then the longitudinal coordinate value difference is zero. Or a preset value range is configured according to the average value, and then the longitudinal coordinate values of the two-dimensional coordinates corresponding to each three-dimensional vertex of the same contour line are all adjusted to the preset value range, and then the longitudinal coordinate value difference can be controlled within the preset range. After performing the coordinate correction operation, the two-dimensional coordinates of each three-dimensional vertex can be determined as the texture coordinates of each three-dimensional vertex.
[0087] In this embodiment, the UV shape is optimized by aligning the hair UV coordinates (texture coordinates) to present a smoother line, thereby effectively controlling the shape and position of the hair highlight.
[0088] In actual applications, the animation scene may change in real time, such as character movement or adding head animation. In order to enhance the viewing experience, the highlight effect needs to be dynamically adjusted accordingly. Character movement, etc. will directly affect the vertical direction of the head corresponding to the hair model. Therefore, consider obtaining the vertical direction of the head to achieve more accurate and realistic highlight rendering. Exemplarily, the direction vector of the vertical direction of the head in the local coordinate system (model space) of the hair model can be obtained, and then the direction vector can be converted into the world space to obtain the target vector. In some embodiments, the target vector can be a normalized vector to improve rendering efficiency.
[0089] Step S102 , determine the target angle according to the standard sight line vector of the world space and the target vector.
[0090] The standard sight line vector can be obtained by normalizing the sight line vector. The sight line vector can be a vector pointing from the camera to the hair model. The camera is used to represent the perspective / sight line of the observer. According to the standard sight line vector and the target vector in the world space, the target angle can be determined. The target angle can be used to determine the direction or posture of the hair model relative to the observer. In some embodiments, the standard sight line vector and the target vector can be dot-producted, which can be expressed as Dot(up, V)=cosA. Wherein up is the target vector, V is the standard sight line vector, and A is the target angle. The target angle can be obtained by processing the dot product result with the inverse cosine function.
[0091] In this embodiment, the target angle is calculated according to the standard sight line vector and the target vector, so that the current posture of the hair model can be determined, so as to accurately render highlights later.
[0092] In practical applications, if the viewer's perspective / sight changes, the highlight position also needs to change dynamically with the sight to achieve a more realistic animation effect. An exemplary solution is provided below.
[0093] In an optional embodiment, if Figure 4 As shown, the hair highlight rendering method may further include:
[0094] Step S400, monitoring the target vector and the standard sight line vector.
[0095] Step S402, when the target vector and / or the standard sight line vector change, obtain the latest target vector and the latest standard sight line vector.
[0096] Step S404: updating the target angle according to the latest target vector and the latest standard sight line vector.
[0097] For example, the hair model can be monitored in real time. When character movement, head animation addition, line of sight change, etc. are detected, it is determined whether the target vector has changed according to the current vertical direction of the head, and whether the standard line of sight vector has changed according to the current viewing angle. When the target vector and / or the standard line of sight vector change, the latest target vector and the latest standard vector are obtained to update the target angle for re-rendering highlights.
[0098] In this embodiment, the target angle is monitored and updated in real time, so that the highlight can be re-rendered in time and the position of the highlight on the hair model can be dynamically adjusted following the changes in the scene and / or the sight line.
[0099] Step S104 , adjust the texture coordinates according to the target angle to obtain sampling coordinates.
[0100] In practical applications, there may be a variety of adjustment schemes. For example, the adjustment ratio may be determined according to the target angle to flexibly transform the texture coordinates. Alternatively, an appropriate transformation matrix may be constructed according to the target angle to perform transformations such as scaling, translation, and rotation on the texture coordinates. The texture transformation amount may also be determined according to the target angle, and the horizontal coordinate value and / or the vertical coordinate value of the texture coordinate may be adjusted according to the texture transformation amount. An exemplary scheme is provided below.
[0101] In an optional embodiment, if Figure 5 As shown, step S104 may include:
[0102] Step S500: determining a first intermediate coordinate according to the texture coordinate and the cosine value of the target angle.
[0103] Step S502: determining a second intermediate coordinate according to the first intermediate coordinate and a preset correction coefficient.
[0104] Step S504: determining the sampling coordinates according to the second intermediate coordinates and a preset offset value.
[0105] Exemplarily, the longitudinal coordinate value of the texture coordinate and the cosine value of the target angle can be used to longitudinally distort the texture coordinate to obtain the first intermediate coordinate. According to the preset correction coefficient, the first intermediate coordinate is adjusted to obtain the second intermediate coordinate. Among them, the correction coefficient is used to control the speed of change of the highlight as the target angle changes. For example, the target angle of the previous frame is 60 degrees, and the target angle of the current frame is 15 degrees. The change in the target angle is 45 degrees. The correction coefficient can be set to 0-1. The larger the correction coefficient, the faster the highlight changes as the target angle changes, and the smaller the correction coefficient, the slower the highlight changes as the target angle changes. Adding a preset offset value on the basis of the second intermediate coordinate can obtain the sampling coordinate. Among them, the offset value can be used to control the initial position of the highlight to ensure the accuracy of the highlight rendering.
[0106] Texture coordinates can be expressed as (X, Y1), sampling coordinates can be expressed as (X, Y2), and the calculation formula of sampling coordinates can be expressed as follows:
[0107] Y2=Y1*cosA*m+offset;
[0108] Where A is the target angle, m is the correction coefficient, and offset is the offset value.
[0109] In this embodiment, the longitudinal coordinate value of the texture coordinate is adjusted by the target viewing angle to obtain the sampling coordinate, and the sampling coordinate is used for the pixels to be applied to the three-dimensional vertices in the highlight map, so that when the scene and / or viewing angle changes, the hair highlight can move up and down as a whole to achieve a dynamic change effect.
[0110] Step S106 , rendering the hair model according to the sampling coordinates and the pre-configured highlight map to obtain a hair model containing highlights.
[0111] The highlight map may include at least highlight information, which is used to specify the highlight position, highlight intensity, etc. of the hair model surface. In some embodiments, the highlight map may be merged with the shadow map to indicate whether each three-dimensional vertex in the hair model is visible, thereby improving the hair rendering effect. The highlight map may be set according to actual needs (shape and position of the highlight).
[0112] In an optional embodiment, if Figure 6 As shown, the highlight map includes multiple pixels. The highlight map can be divided into a highlight area and a non-highlight area. The highlight area represents the initial position of the hair highlight and can be located above the highlight map to simulate the hair highlight that appears in the hair area in front of the forehead in a natural form. The highlight map can be a grayscale image, and the pixel values of its pixels can represent the highlight intensity and / or highlight color at different positions on the surface of the hair model. Figure 6 and Figure 7 As shown in the figure, the white solid line can represent the highlight area, and the black area corresponds to the non-highlight area. It can be seen that the white solid line is aligned with the hair texture coordinates in the forehead area. According to the actual situation, the pixel value of the middle pixel point in the highlight area can be set higher than the pixel value of the edge pixel point. In the highlight area, the pixel value of the pixel point gradually decreases from the middle to the edge.
[0113] In this embodiment, the pixel values of the pixels are configured to decay along the highlight area on both sides longitudinally, so as to optimize the transition effect between the highlight area and the non-highlight area, and further improve the hair rendering quality and user perception.
[0114] The above embodiment introduces the features of the highlight map. The following will exemplarily introduce how to perform highlight rendering.
[0115] In an optional embodiment, if Figure 8 As shown, step S106 may include:
[0116] Step S800: searching for corresponding pixel points in the highlight map according to the sampling coordinates.
[0117] Step S802: Determine the highlight intensity and / or highlight color corresponding to the sampling coordinates according to the pixel value corresponding to the found pixel point.
[0118] Step S804: Render each three-dimensional vertex of the hair model according to the highlight color and / or highlight intensity corresponding to the sampling coordinates.
[0119] Exemplarily, the horizontal / vertical coordinate value range of the sampling coordinate can be from 0 to 1, corresponding to the entire highlight map. For example, (0, 0) represents the lower left corner of the highlight map, and (1, 1) represents the upper right corner of the highlight map. For any sampling coordinate, the corresponding pixel point can be quickly found in the highlight map according to the horizontal / vertical coordinate value of the sampling coordinate. By obtaining the pixel value of the found pixel point, the highlight intensity and / or highlight color corresponding to the sampling coordinate can be determined. The rendering engine can perform corresponding highlight rendering on the three-dimensional vertex corresponding to the sampling coordinate according to the corresponding highlight intensity and / or highlight color. After rendering each three-dimensional vertex, a hair model containing highlights can be obtained.
[0120] In this embodiment, highlight rendering is performed based on sampling coordinates and a pre-configured highlight map, which alleviates the problem of highlight shape distortion when the surface / curvature of the hair model (hair patch) is too large. The position of the highlight on the hair model can also be dynamically adjusted as the scene and / or line of sight changes.
[0121] In an optional embodiment, if Fig. 9 As shown, the hair highlight rendering method may further include:
[0122] Step S900: adjusting the longitudinal coordinate value of the sampling coordinates by using the pre-configured noise map and the sampling coordinates.
[0123] Step S902, rendering the hair model according to the sampling coordinates after the longitudinal coordinate values are adjusted and the highlight map.
[0124] The noise map may include randomly generated data to simulate natural textures and increase visual detail, providing realism to hair highlight rendering. Fig.10As shown, the noise map can be a grayscale image, and the brightness value (pixel value) of its pixel represents the adjustment amplitude of the longitudinal coordinate value of the sampling coordinate, which can be generated randomly or pseudo-randomly. For example, the adjustment amount of the white pixel can be +0.5, and the adjustment amount of the black pixel can be -0.5. According to the noise map and the sampling coordinates, the longitudinal coordinate value of the sampling coordinates is adjusted, and the sampling coordinates can be distorted longitudinally, changing the sampling position of the three-dimensional vertex in the highlight map. According to the sampling coordinates after the longitudinal coordinate value is adjusted and the highlight map, the hair model is rendered.
[0125] In this embodiment, the sampling coordinates are distorted longitudinally by using a noise map, so as to achieve the effect of simulating the natural up and down changes of highlight hair.
[0126] In order to make the present application easier to understand, an exemplary application is provided below.
[0127] S11: Preprocess the hair model, obtain UV coordinates (texture coordinates), and correct the UV coordinates according to the contour lines.
[0128] S12: creating a highlight map, the highlight map including a highlight area, and the pixel values of the pixels in the highlight area gradually decrease from the middle to the edge.
[0129] S13, making a noise map for longitudinally distorting coordinates.
[0130] S14, converting the upward direction of the hair model (vertical direction of the head) from the model space to the world space to obtain the upward direction of the hair model in the world space (target vector).
[0131] S15: Determine a target angle according to the target vector and the world space standard sight vector.
[0132] S16: According to the cosine value of the target angle, the correction coefficient, and the offset value, the longitudinal coordinate value of the texture coordinate is adjusted to obtain the sampling coordinate.
[0133] S17, performing highlight rendering on the hair model according to the sampling coordinates, the highlight map, and the noise map to obtain a highlight model containing highlights.
[0134] In this exemplary application: (1) highlight rendering is performed based on sampling coordinates and a pre-configured highlight map, alleviating the problem of highlight shape distortion when the surface / curvature of the hair model (hair patch) is too large; (2) the position of the highlight on the hair model can be dynamically adjusted as the scene and / or line of sight changes, effectively improving the rendering quality of the hair and the user's viewing experience.
[0135] Embodiment 2
[0136] Fig.11The block diagram of the hair highlight rendering device according to the second embodiment of the present application is schematically shown. The device can be divided into one or more program modules, one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. Fig.11 As shown, the device 1000 may include: an acquisition module 1100, a determination module 1200, an adjustment module 1300 and a rendering module 1400, wherein:
[0137] An acquisition module 1100 is used to acquire the texture coordinates of the hair model and a target vector of the head vertical direction corresponding to the hair model in the world space;
[0138] A determination module 1200, configured to determine a target angle according to a standard sight line vector in the world space and the target vector;
[0139] An adjustment module 1300, configured to adjust the texture coordinates according to the target angle to obtain sampling coordinates;
[0140] The rendering module 1400 is used to render the hair model according to the sampling coordinates and a pre-configured highlight map to obtain a hair model with highlights.
[0141] As an optional embodiment, the hair model includes a plurality of contour lines, each contour line includes a plurality of three-dimensional vertices;
[0142] Correspondingly, the obtaining of the texture coordinates of the hair model includes:
[0143] Mapping each three-dimensional vertex of the hair model to a texture coordinate system to obtain a two-dimensional coordinate of each three-dimensional vertex;
[0144] Performing a coordinate correction operation according to the plurality of contour lines and the two-dimensional coordinates of each three-dimensional vertex;
[0145] After performing the coordinate correction operation, the two-dimensional coordinates of each three-dimensional vertex are determined as the texture coordinates of each three-dimensional vertex.
[0146] As an optional embodiment, the coordinate correction operation includes: adjusting the difference in longitudinal coordinate values of two-dimensional coordinates corresponding to a plurality of three-dimensional vertices located on the same contour line to within a preset range.
[0147] As an optional embodiment, the hair highlight rendering device 1000 is further used for:
[0148] monitoring the target vector and the standard sight line vector;
[0149] When the target vector and / or the standard sight line vector change, obtaining the latest target vector and the latest standard sight line vector; and
[0150] The target angle is updated according to the latest target vector and the latest standard sight line vector.
[0151] As an optional embodiment, the highlight map includes a highlight area, and the highlight area includes a plurality of pixel points;
[0152] Among them, the pixel value of the middle pixel point of the highlight area is higher than the pixel value of the edge pixel point; in the highlight area, the pixel value of the pixel point gradually decreases from the middle to the edge; the pixel value is used to indicate the highlight intensity and / or highlight color.
[0153] As an optional embodiment, adjusting the texture coordinates according to the target angle to obtain sampling coordinates includes:
[0154] Determining a first intermediate coordinate according to the texture coordinate and the cosine value of the target angle;
[0155] Determining a second intermediate coordinate according to the first intermediate coordinate and a preset correction coefficient;
[0156] The sampling coordinates are determined according to the second intermediate coordinates and a preset offset value.
[0157] As an optional embodiment, rendering the hair model according to the sampling coordinates and the preconfigured highlight map includes:
[0158] According to the sampling coordinates, searching for corresponding pixel points in the highlight map;
[0159] Determine the highlight intensity and / or highlight color corresponding to the sampling coordinates according to the pixel value corresponding to the found pixel point;
[0160] Rendering each three-dimensional vertex of the hair model according to the highlight color and / or highlight intensity corresponding to the sampling coordinates.
[0161] As an optional embodiment, rendering the hair model according to the sampling coordinates and the pre-configured highlight map further includes:
[0162] Adjusting the longitudinal coordinate value of the sampling coordinate by using the pre-configured noise map and the sampling coordinate;
[0163] The hair model is rendered according to the sampling coordinates after the longitudinal coordinate values are adjusted and the highlight map.
[0164] Embodiment 3
[0165] Fig.12 The schematic diagram of the hardware architecture of a computer device 10000 suitable for implementing the hair highlight rendering method according to the third embodiment of the present application is shown schematically. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Fig.12 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them:
[0166] The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (such as an SD or DX memory), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 10010 may be an internal storage module of the computer device 10000, such as a hard disk or a memory of the computer device 10000. In other embodiments, the memory 10010 may also be an external storage device of the computer device 10000, such as a plug-in hard disk equipped on the computer device 10000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 10010 may also include both the internal storage module of the computer device 10000 and its external storage device. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed in the computer device 10000, such as the program code of the hair highlight rendering method, etc. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.
[0167] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.
[0168] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0169] It should be pointed out that Fig.12 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0170] In this embodiment, the hair highlight rendering method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.
[0171] Embodiment 4
[0172] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the hair highlight rendering method in the embodiment are implemented.
[0173] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEP ROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Of course, the computer-readable storage medium may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on the computer device, such as the program code of the hair highlight rendering method in the embodiment. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.
[0174] Embodiment 5
[0175] An embodiment of the present application also provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.
[0176] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by general-purpose computer devices, they can be concentrated on a single computer device, or distributed on a network composed of multiple computer devices, optionally, they can be implemented by executable program codes of computer devices, so that they can be stored in a storage device and executed by the computer device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0177] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A hair highlight rendering method, characterized in that: The method comprises: Obtaining texture coordinates of a hair model and a target vector of a head vertical direction corresponding to the hair model in a world space; Determining a target angle according to a standard sight line vector in the world space and the target vector; Adjust the texture coordinates according to the target angle to obtain sampling coordinates; The hair model is rendered according to the sampling coordinates and the pre-configured highlight map to obtain a hair model containing highlights.
2. The method according to claim 1, characterized in that The hair model includes a plurality of contour lines, each contour line includes a plurality of three-dimensional vertices; Correspondingly, the obtaining of the texture coordinates of the hair model includes: Mapping each three-dimensional vertex of the hair model to a texture coordinate system to obtain a two-dimensional coordinate of each three-dimensional vertex; Performing a coordinate correction operation according to the plurality of contour lines and the two-dimensional coordinates of each three-dimensional vertex; After performing the coordinate correction operation, the two-dimensional coordinates of each three-dimensional vertex are determined as the texture coordinates of each three-dimensional vertex.
3. The method according to claim 2, characterized in that The coordinate correction operation includes: adjusting the longitudinal coordinate value difference of the two-dimensional coordinates corresponding to a plurality of three-dimensional vertices located on the same contour line to within a preset range.
4. The method according to claim 1, characterized in that: The method further comprises: monitoring the target vector and the standard sight line vector; When the target vector and / or the standard sight line vector change, obtaining the latest target vector and the latest standard sight line vector; and The target angle is updated according to the latest target vector and the latest standard sight line vector.
5. The method according to any one of claims 1 to 4, characterized in that: The highlight map includes a highlight area, and the highlight area includes a plurality of pixel points; Among them, the pixel value of the middle pixel point of the highlight area is higher than the pixel value of the edge pixel point; in the highlight area, the pixel value of the pixel point gradually decreases from the middle to the edge; the pixel value is used to indicate the highlight intensity and / or highlight color.
6. The method according to any one of claims 1 to 4, characterized in that: Adjusting the texture coordinates according to the target angle to obtain sampling coordinates includes: Determining a first intermediate coordinate according to the texture coordinate and the cosine value of the target angle; Determining a second intermediate coordinate according to the first intermediate coordinate and a preset correction coefficient; The sampling coordinates are determined according to the second intermediate coordinates and a preset offset value.
7. The method according to any one of claims 1 to 4, characterized in that: Rendering the hair model according to the sampling coordinates and the pre-configured highlight map includes: According to the sampling coordinates, searching for corresponding pixel points in the highlight map; Determine the highlight intensity and / or highlight color corresponding to the sampling coordinates according to the pixel value corresponding to the found pixel point; Rendering each three-dimensional vertex of the hair model according to the highlight color and / or highlight intensity corresponding to the sampling coordinates.
8. The method according to any one of claims 1 to 4, characterized in that: Rendering the hair model according to the sampling coordinates and the pre-configured highlight map also includes: Adjusting the longitudinal coordinate value of the sampling coordinate by using the pre-configured noise map and the sampling coordinate; The hair model is rendered according to the sampling coordinates after the longitudinal coordinate values are adjusted and the highlight map.
9. A hair highlight rendering device, characterized in that: The device comprises: An acquisition module, used to acquire the texture coordinates of the hair model and a target vector of the head vertical direction corresponding to the hair model in the world space; A determination module, used for determining a target angle according to a standard sight line vector of the world space and the target vector; An adjustment module, used for adjusting the texture coordinates according to the target angle to obtain sampling coordinates; The rendering module is used to render the hair model according to the sampling coordinates and a pre-configured highlight map to obtain a hair model containing highlights.
10. A computer device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claims 1 to 8 are implemented.
