Image generation method, device, electronic device and storage medium
By constructing a three-dimensional body model and determining transmission parameters, combining the direction of sight and lighting environment, hair images are generated, which solves the problem of inconsistent lighting in hair rendering, and improves the realism and real-timeness of hair.
Patent Information
- Application Number
- CN202210100673.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-27
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-01-27
AI Technical Summary
In the prior art, hair image rendering does not consider the real lighting environment, resulting in the lighting information of the hair image being inconsistent with reality and having a poor sense of reality.
By obtaining the three-dimensional hair model, building a three-dimensional body model, determining the transmission parameters of the cell based on the line of sight and geometric data, and generating the target image based on the color data of the cell and the diffuse reflection coefficient, simulating the brightness difference and diffuse reflection effect caused by the transmission of the light source.
Improve the brightness of hair edges, increase the translucency and realism of hair, achieve matching lighting information with the direction of sight, and enhance the real-time and authenticity of hair effects.
Smart Images

Figure CN114445558B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image generation method, device, electronic device, and storage medium. Background Art
[0002] In recent years, model rendering has become increasingly popular in various applications, gaining popularity with its realism and three-dimensionality. Hair effects in model rendering are a key technology in applications such as 3D games, AR special effects, and wig fitting. Highly realistic hair is crucial for depicting the details of people and animals. However, related technologies that use hair models to render hair images fail to consider the actual lighting environment. As a result, the lighting information in the hair images does not match reality, resulting in poor realism. Summary of the Invention
[0003] The present disclosure provides an image generation method, apparatus, device, and storage medium to address the deficiencies in the related art.
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image generation method, comprising:
[0005] Acquire a three-dimensional hair model, and construct a three-dimensional body model based on the three-dimensional hair model, wherein the three-dimensional body model is used to represent the body occluded by the hair represented by the three-dimensional hair model;
[0006] determining a transmission parameter of a fragment in the three-dimensional hair model based on a viewing direction, geometric data of the three-dimensional body model, and geometric data of the fragment in the three-dimensional hair model, wherein the transmission parameter is used to characterize brightness differences at different locations in the three-dimensional hair model caused by light source transmission;
[0007] A target image corresponding to the three-dimensional hair model is generated according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
[0008] In one embodiment, determining the transmission parameter of the fragment based on the line of sight direction, the geometric data of the 3D body model, and the geometric data of the fragment in the 3D hair model includes:
[0009] determining a position parameter based on the geometric data of the three-dimensional body model and the three-dimensional coordinates in the geometric data of the fragment, wherein the position parameter is used to represent the relative position of the fragment and the three-dimensional body model;
[0010] A transmission parameter of the fragment is determined according to the position parameter, the viewing direction, and the geometric data of the fragment.
[0011] In one embodiment, it further includes:
[0012] Determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment;
[0013] Generating a target image corresponding to the three-dimensional hair model according to the geometric data of the fragment, the color data of the fragment, and the transmission parameter includes:
[0014] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the diffuse reflection coefficient.
[0015] In one embodiment, the geometric data of the fragment includes a normal direction of the fragment; and determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment includes:
[0016] Determine a first combination parameter of the direction vector of the light source direction and the direction vector of the normal direction;
[0017] determining a correction combining parameter according to a preset constant value, a first weight of the preset constant value, the first combining parameter, and a second weight of the first combining parameter;
[0018] When the correction combination parameter is greater than a critical threshold, the diffuse reflectance is determined as the correction combination parameter; when the correction combination parameter is less than or equal to the critical threshold, the diffuse reflectance is determined as the critical threshold.
[0019] In one embodiment, generating the target image according to the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the diffuse reflection coefficient includes:
[0020] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0021] Determining the diffuse reflection brightness of the fragment according to the color data of the fragment and the diffuse reflection coefficient;
[0022] According to the geometric data of the fragment, the position of the pixel point corresponding to the fragment in the target image is determined, and the transmitted brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
[0023] In one embodiment, it further includes:
[0024] Obtain the highlight brightness of the fragment;
[0025] Generating a target image corresponding to the three-dimensional hair model according to the geometric data, color data and transmission parameters of the fragment includes:
[0026] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the highlight brightness.
[0027] In one embodiment, obtaining the highlight brightness of the fragment includes:
[0028] The highlight brightness of the fragment is determined according to relevant parameters of the highlight brightness and at least one of the following directions: a light source direction, the line of sight direction, and a tangent direction in the geometric data of the fragment.
[0029] In one embodiment, determining the highlight brightness of the fragment based on the highlight brightness related parameters and at least one of the following directions: a light source direction, a line of sight direction, and a tangent direction in the geometric data of the fragment includes:
[0030] Determining a first highlight brightness of the fragment according to the light source direction, the sight line direction, a first highlight offset parameter, a tangent offset coefficient, and the tangent direction, wherein the first highlight brightness is a basic component of the highlight brightness;
[0031] determining a second highlight brightness according to the light source direction, the sight line direction, a second highlight offset parameter, a tangent offset coefficient, the tangent direction, and the occlusion coefficient, wherein the second highlight brightness is a component of highlight brightness formed by selective occlusion on the basis of the first highlight brightness, and the occlusion coefficient is used to indicate whether a second highlight exists at the fragment;
[0032] Determine the highlight brightness of the fragment according to the first highlight brightness and the second highlight brightness.
[0033] In one embodiment, it further includes:
[0034] Obtaining a tangent offset coefficient map, and obtaining a tangent offset coefficient corresponding to the fragment in the tangent offset coefficient map; and / or,
[0035] Obtain a specular occlusion map, and obtain an occlusion coefficient corresponding to the fragment in the specular occlusion map.
[0036] In one embodiment, generating the target image according to the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the highlight brightness includes:
[0037] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0038] According to the geometric data of the fragment, a position of a pixel point corresponding to the fragment in the target image is determined, and the transmission brightness and the highlight brightness are mapped to the pixel point according to the position.
[0039] According to a second aspect of an embodiment of the present disclosure, there is provided an image generating apparatus, including:
[0040] a first acquisition module, configured to acquire a three-dimensional hair model and construct a three-dimensional body model based on the three-dimensional hair model, wherein the three-dimensional body model is used to represent the body occluded by the hair represented by the three-dimensional hair model;
[0041] a first parameter module, configured to determine a transmission parameter of a fragment in the three-dimensional hair model based on a line of sight, geometric data of the three-dimensional body model, and geometric data of the fragment in the three-dimensional hair model, wherein the transmission parameter is used to characterize brightness differences at different locations in the three-dimensional hair model caused by light source transmission;
[0042] A generation module is used to generate a target image corresponding to the three-dimensional hair model according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
[0043] In one embodiment, the determining module is specifically configured to:
[0044] determining a position parameter based on the geometric data of the three-dimensional body model and the three-dimensional coordinates in the geometric data of the fragment, wherein the position parameter is used to represent the relative position of the fragment and the three-dimensional body model;
[0045] A transmission parameter of the fragment is determined according to the position parameter, the viewing direction, and the geometric data of the fragment.
[0046] In one embodiment, a second parameter module is further included, which is configured to:
[0047] Determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment;
[0048] The generation module is specifically used for:
[0049] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the diffuse reflection coefficient.
[0050] In one embodiment, the geometric data of the fragment includes the normal direction of the fragment; and the second parameter module is specifically configured to:
[0051] Determine a first combination parameter of the direction vector of the light source direction and the direction vector of the normal direction;
[0052] determining a correction combining parameter according to a preset constant value, a first weight of the preset constant value, the first combining parameter, and a second weight of the first combining parameter;
[0053] When the correction combination parameter is greater than a critical threshold, the diffuse reflectance is determined as the correction combination parameter; when the correction combination parameter is less than or equal to the critical threshold, the diffuse reflectance is determined as the critical threshold.
[0054] In one embodiment, the generation module is configured to generate the target image based on the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the diffuse reflection coefficient, specifically for:
[0055] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0056] Determining the diffuse reflection brightness of the fragment according to the color data of the fragment and the diffuse reflection coefficient;
[0057] According to the geometric data of the fragment, the position of the pixel point corresponding to the fragment in the target image is determined, and the transmitted brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
[0058] In one embodiment, a high-light module is further included, which is used to:
[0059] Obtain the highlight brightness of the fragment;
[0060] The generation module is specifically used for:
[0061] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the highlight brightness.
[0062] In one embodiment, the highlight module is specifically used for:
[0063] The highlight brightness of the fragment is determined according to relevant parameters of the highlight brightness and at least one of the following directions: a light source direction, the line of sight direction, and a tangent direction in the geometric data of the fragment.
[0064] In one embodiment, the highlight module is configured to determine the highlight brightness of the fragment based on the relevant parameters of the highlight brightness and at least one of the following directions: the light source direction, the line of sight direction, and the tangent direction in the geometric data of the fragment, and is specifically configured to:
[0065] Determining a first highlight brightness of the fragment according to the light source direction, the sight line direction, a first highlight offset parameter, a tangent offset coefficient, and the tangent direction, wherein the first highlight brightness is a basic component of the highlight brightness;
[0066] determining a second highlight brightness according to the light source direction, the sight line direction, a second highlight offset parameter, a tangent offset coefficient, the tangent direction, and the occlusion coefficient, wherein the second highlight brightness is a component of highlight brightness formed by selective occlusion on the basis of the first highlight brightness, and the occlusion coefficient is used to indicate whether a second highlight exists at the fragment;
[0067] Determine the highlight brightness of the fragment according to the first highlight brightness and the second highlight brightness.
[0068] In one embodiment, it further includes:
[0069] A second acquisition module is configured to acquire a tangent offset coefficient map and acquire a tangent offset coefficient corresponding to the fragment in the tangent offset coefficient map; and / or
[0070] The third acquisition module is used to obtain a highlight occlusion map and obtain an occlusion coefficient corresponding to the fragment in the highlight occlusion map.
[0071] In one embodiment, when the generation module is used to generate the target image based on the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the highlight brightness, it is specifically used to:
[0072] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0073] According to the geometric data of the fragment, a position of a pixel point corresponding to the fragment in the target image is determined, and the transmission brightness and the highlight brightness are mapped to the pixel point according to the position.
[0074] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store computer instructions that can be executed on the processor, and the processor is used to implement the method described in the first aspect when executing the computer instructions.
[0075] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.
[0076] According to the above embodiment, a three-dimensional hair model is obtained and a three-dimensional body model is constructed based on the three-dimensional hair model. Transmission parameters of fragments in the three-dimensional hair model are then determined based on the line of sight, geometric data of the three-dimensional body model, and geometric data of the fragments. Finally, a target image corresponding to the three-dimensional hair model is generated based on the geometric data of the fragments, the color data of the fragments, and the transmission parameters. Because the transmission parameters can characterize the brightness differences caused by light transmission at different locations in the three-dimensional hair model (for example, light transmission at the edges but not at the center), the brightness of the hair edges can be increased, enhancing the transparency and realism of the hair. Furthermore, because the transmission parameters are determined based on parameters such as the line of sight direction, the resulting target image's lighting information matches that line of sight, approximating a realistic lighting environment. This also enables real-time updating of the lighting information based on the line of sight direction, further improving the real-time nature of the hair effect.
[0077] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0079] Figure 1 is a flowchart of an image generation method according to an embodiment of the present disclosure;
[0080] Figure 2 is a schematic diagram of a two-dimensional hair image generated by a related technology according to an embodiment of the present disclosure;
[0081] Figure 3 is a schematic diagram of a two-dimensional hair image generated by an embodiment of the present application, shown in one embodiment of the present disclosure;
[0082] Figure 4 is a schematic diagram illustrating a method for determining highlight brightness according to an embodiment of the present disclosure;
[0083] Figure 5 is a structural diagram of an image generating device shown in an embodiment of the present disclosure;
[0084] Figure 6 It is a structural diagram of an electronic device shown in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0085] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
[0086] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0087] It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining."
[0088] In the scene of hair image rendering, related technologies often pre-draw lighting information directly in the map. The lighting information does not change according to the direction of sight, etc., and therefore differs greatly from the real hair effect.
[0089] Based on this, in the first aspect, at least one embodiment of the present disclosure provides an image generation method, please refer to the attached Figure 1 , which shows the process of the method, including steps S101 to S103.
[0090] This method can be used to generate a two-dimensional hair image in real time based on a three-dimensional hair model. For example, this method can be used to generate a two-dimensional hair image in real time based on a three-dimensional hair model of a person, or based on a three-dimensional hair model of an animal. The two-dimensional hair image can be generated independently, or it can be combined with other parts of the human body or face to generate a human image, or it can be combined with other parts of the animal body to generate an animal image.
[0091] The three-dimensional hair model can be generated in advance based on hair lines or hair patches. The three-dimensional hair model has multiple vertices, which are interconnected according to a preset topological structure to generate a grid. The grid has multiple cells, and each cell is formed by at least three vertices. The three-dimensional hair model also has geometric data and color data for each vertex. The geometric data may include the three-dimensional coordinates of the vertex, the tangent direction of the vertex, the normal direction of the vertex, etc. The color data may include the brightness values of each channel of R (red), G (green), and B (blue), etc.
[0092] When generating a two-dimensional hair image in real time, the light source direction, the current sight line direction (ie, the relative direction between the camera and the model), etc. may also be combined, because the light source direction and the sight line direction will affect the lighting information of the hair surface.
[0093] In addition, the method can be executed by an electronic device such as a terminal device or a server. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA) handheld device, a computing device, an in-vehicle device, a wearable device, etc. The method can be implemented by a processor calling computer-readable instructions stored in a memory. Alternatively, the method can be executed by a server, which can be a local server, a cloud server, etc.
[0094] In step S101, a three-dimensional hair model is obtained, and a three-dimensional body model is constructed based on the three-dimensional hair model.
[0095] The three-dimensional hair model may be a human hair model, an animal hair model, etc. The three-dimensional hair model is preset in advance, and in this step, the three-dimensional hair model may be directly imported for use in the method.
[0096] Whether it's a human hair model or an animal hair model, the hair represented by the 3D hair model is attached to the person or animal's body. In other words, the hair represented by the 3D hair model will obscure the person or animal's body. Of course, not all of the hair represented by the 3D hair model obscures the person or animal's body; some hair at the edges does not obscure the body. The hair that obscures and does not obscure the body exhibits different light transmittances: the hair that obscures the body has poor light transmittance, or even no light at all, while the hair that does not obscure the body has better light transmittance. Therefore, a 3D body model can be constructed within the 3D hair model, enhancing the realism of the 3D hair model and making its brightness more realistic and natural. The 3D body model is used to represent the body obscured by the hair represented by the 3D hair model, namely, the body of the person or animal. Due to the softness and adhesion of hair, the three-dimensional body model can be an inscribed model of a three-dimensional hair model. The specific shape can be determined according to the type of the three-dimensional hair model. For example, the three-dimensional body model of a human hair model can be the shape of a human head, that is, an ellipsoid. In other words, the three-dimensional body model of a hair model can be a three-dimensional inscribed ellipsoid. For another example, the three-dimensional body model of an animal's hair model can be the shape of the animal's body.
[0097] The geometric data of the three-dimensional hair model can be data in the world coordinate system or data in the dedicated coordinate system of the three-dimensional hair model. In the dedicated coordinate system, the center of the three-dimensional hair model can be used as the origin, and the three coordinate axes that are perpendicular to each other can be used as the X, Y and Z axes respectively. Taking the construction of a three-dimensional inscribed ellipsoid of a human hair model as an example, the lengths of the three-dimensional hair model along the X, Y, and Z axes (of a world coordinate system or a dedicated coordinate system) can be determined respectively, and the coordinate axis with the maximum length can be selected as the major axis direction of the three-dimensional inscribed ellipsoid. The central coordinates of the three-dimensional hair model can then be used as the center of the three-dimensional inscribed ellipsoid. Then, based on the major axis direction and the center, a maximum ellipsoid enclosed by the three-dimensional hair model can be constructed as the three-dimensional inscribed ellipsoid. Alternatively, an initial three-dimensional ellipsoid can be randomly determined and placed within the three-dimensional hair model, ensuring that the centers of the two coincide. If the initial three-dimensional ellipsoid does not exceed the range of the three-dimensional hair model and is not inscribed with the three-dimensional hair model, the initial three-dimensional ellipsoid is enlarged. If the initial three-dimensional ellipsoid or the enlarged result of the initial three-dimensional ellipsoid exceeds the range of the three-dimensional hair model, the initial three-dimensional ellipsoid is first rotated. If the rotation results in all directions exceed the three-dimensional hair model, the rotation results of the three-dimensional ellipsoid are reduced. The three-dimensional ellipsoid is continuously adjusted in the above manner until the three-dimensional ellipsoid is inscribed with the three-dimensional hair model, and then it is determined to be the three-dimensional inscribed ellipsoid.
[0098] The geometric data of the three-dimensional body model may include geometric data for describing geometric features of the three-dimensional body model. Taking a three-dimensional inscribed ellipsoid as an example, the geometric data may include at least one of the center coordinates of the ellipsoid, the length of the ellipsoid, and the scaling ratio of the ellipsoid.
[0099] In step S102, the transmission parameters of the fragments are determined based on the line of sight direction, the geometric data of the three-dimensional body model, and the geometric data of the fragments in the three-dimensional hair model, wherein the transmission parameters are used to characterize the brightness differences at different positions in the three-dimensional hair model caused by the transmission of the light source.
[0100] When real hair is illuminated by a light source, the thickness of the hair's edges differs from that of its center. Therefore, light from the light source can penetrate the edges to a certain extent, but not the center. This difference in transmittance causes differences in brightness at different locations on the hair, such as brighter edges and darker centers. The transmittance parameter is used to characterize this brightness difference.
[0101] This step is performed for at least one fragment in the 3D hair model, i.e., the transmission parameters of each fragment are determined separately. A fragment in the 3D hair model is the smallest computational unit, or the smallest mapping unit, for rendering a 2D hair image based on the 3D hair model. Each fragment can be individually mapped to a 2D hair image, for example, each fragment can correspond to each pixel in the 2D hair image. The 3D hair model includes vertices and a mesh composed of vertices. Vertices are key points for constructing the 3D hair model, and the mesh is constructed based on the vertices and the topological structure of the model. Fragments in the 3D hair model include vertices and / or ordinary 3D points of the 3D hair model. Ordinary 3D points are points in the mesh of the 3D hair model. Therefore, the geometric data and color data of each fragment of the 3D hair model can be determined based on the geometric data and color data of the vertices. The geometric data and color data of each fragment in each cell of the mesh can be determined based on the geometric data and color data of the vertices surrounding the cell. For example, the geometric data and color data of each fragment can be obtained by interpolation. When using the vertex shader (VS) and fragment shader (FS) to draw a two-dimensional hair image, the geometric data and color data of the vertex can be obtained in the vertex shader, and then the vertex data can be interpolated to obtain the fragment data in the fragment shader.
[0102] In one possible embodiment, the transmission parameter of a fragment may be determined as follows:
[0103] First, position parameters are determined based on the geometric data of the three-dimensional body model and the three-dimensional coordinates in the geometric data of the fragment, wherein the position parameters are used to characterize the relative position of the fragment and the three-dimensional body model in the camera coordinate system.
[0104] The camera coordinate system may refer to a coordinate system with the position of the camera as the origin, and the position of the camera may be determined according to the sight direction and the depth of the three-dimensional hair model.
[0105] Optionally, calculate the position parameter dirAtten according to the following formula:
[0106] dirAtten=dot(vPos-O,ScaleMat*(vPos-O));
[0107] Among them, the dot is the inner product function, the vPos is the position coordinate of the fragment in the camera coordinate system, which can be obtained through the position coordinate in the geometric data of the fragment, and the conversion matrix between the coordinate system where the position coordinate is located (such as the world coordinate system or the special coordinate system of the three-dimensional hair model) and the camera coordinate system, the O is the position coordinate of the center of the three-dimensional body model in the camera coordinate system, which can be obtained through the center coordinate in the geometric data of the three-dimensional body model, and the conversion matrix between the coordinate system where the center coordinate is located (such as the world coordinate system or the special coordinate system of the three-dimensional hair model) and the camera coordinate system, and the ScaleMat is a scaling matrix composed of the scaling coefficients of each axis in the geometric data of the three-dimensional body model.
[0108] If the position parameter is less than 1, it indicates that the fragment is inside the three-dimensional body model in the camera coordinate system. If the position parameter is equal to 1, it indicates that the fragment is on the surface of the three-dimensional body model in the camera coordinate system. If the position parameter is greater than 1, it indicates that the fragment is outside the three-dimensional body model in the camera coordinate system.
[0109] Next, a transmission parameter of the fragment is determined according to the position parameter, the viewing direction, and the normal direction in the geometric data of the fragment.
[0110] The viewing direction can be determined in real time during the interaction of the application executing the method, which represents the observed direction of the three-dimensional hair model, that is, the direction and angle from which the user views the hair. For example, the viewing direction changes when the user rotates the model.
[0111] Optionally, when the position parameter is within a preset cutoff range, the transmission parameter can be determined based on the first exponential power of the sine value of the angle between the line of sight and the normal direction, and the position parameter within the cutoff range; when the position parameter is not within the preset cutoff range, the transmission parameter can be determined based on the first exponential power of the sine value of the angle between the line of sight and the normal direction, and the boundary value of the cutoff range. For example, the transmission parameter M of the fragment can be calculated according to the following formula:
[0112] M=smoothstep(TTdirAttenMin,TTdirAttenMax,dirAtten)*pow(sinVN,ExpTT);
[0113] Wherein, smoothstep is a truncation function, TTdirAttenMin is a preset minimum attenuation truncation coefficient, TTdirAttenMin is less than 1, TTdirAttenMax is a preset maximum attenuation truncation coefficient, TTdirAttenMax is greater than 1, pow is an exponential function, sinVN is the sine of the angle between the view direction and the normal direction, and ExpTT is a preset first exponent. When using a fragment shader to render a two-dimensional hair image, TTdirAttenMin, TTdirAttenMax, and ExpTT are all preset parameters in the fragment shader.
[0114] When calculating the smoothstep function, if dirAtten is between TTdirAttenMin and TTdirAttenMax, the calculation result is the value of dirAtten; if dirAtten is less than or equal to TTdirAttenMin, the calculation result is the value of TTdirAttenMin; if dirAtten is greater than or equal to TTdirAttenMax, the calculation result is the value of TTdirAttenMax.
[0115] In step S103, a target image corresponding to the three-dimensional hair model is generated according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
[0116] The target image corresponding to the 3D hair model is a 2D hair image. Because the transmission parameters are determined based on parameters such as the viewing direction, the resulting target image's illumination information matches that viewing direction. This means the target image is real-time. If the viewing direction of the 3D hair model changes, the target image also changes.
[0117] Optionally, the transmission brightness of the fragment is first determined based on the color data of the fragment and the transmission parameter, and then the position of the pixel point corresponding to the fragment in the target image is determined based on the geometric data of the fragment, and the transmission brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
[0118] For example, the color data has brightness values of three channels, R, G, and B. The color brightness value can be obtained according to the color data, and then the color brightness value is multiplied by the transmission parameter to obtain the transmission brightness.
[0119] This step is performed for each fragment in the three-dimensional hair model, that is, the brightness value of each fragment is mapped to the target image.
[0120] According to the above embodiment, a 3D hair model is obtained and a 3D body model is constructed based on the 3D hair model. Transmission parameters of fragments in the 3D hair model are then determined based on the line of sight, geometric data of the 3D body model, and geometric data of the fragments. Finally, a target image corresponding to the 3D hair model is generated based on the geometric data, color data, and transmission parameters of the fragments. Because the transmission parameters can characterize the brightness differences caused by light source transmission at different locations in the 3D hair model (e.g., light source transmission at the edges but not at the center), the brightness of the hair edges can be increased, resulting in a smooth edge transmission effect across visual angles and enhancing the transparency and realism of the hair. Furthermore, because the transmission parameters are determined based on parameters such as the line of sight, the resulting target image's illumination information matches that line of sight, approximating a realistic lighting environment. Furthermore, the illumination information is updated in real time based on the line of sight, further improving the real-time nature of the hair effect.
[0121] Please refer to the attached Figure 2 , which shows a two-dimensional hair image generated without considering the transmission parameter in the related art. It can be seen that there is no difference in brightness between the center and the edge, the transition is unnatural, and the sense of reality is poor; please refer to the attached Figure 3 , which shows a two-dimensional hair image generated by the image generation method provided in an embodiment of the present application. It can be seen that there is a difference in brightness between the center and the edge, the edge brightness is higher, the transition is more natural, and the sense of reality is stronger.
[0122] In some embodiments of the present disclosure, the albedo of the fragment may be determined based on the light source direction and the geometric data of the fragment. This step is performed for each fragment in the three-dimensional hair model, that is, the albedo of each fragment is determined.
[0123] The geometric data of the fragment includes the normal direction of the fragment. The position of the light source is pre-set, so the light source direction can be determined based on the relative position of the light source and the fragment. Optionally, the position coordinates of the light source and the fragment in the same coordinate system are first obtained, and then a vector from the light source position coordinates to the fragment position coordinates is determined. Finally, the determined vector can be used as the direction vector of the light source direction.
[0124] In one possible embodiment, first, a first combination parameter of the direction vector of the light source direction and the direction vector of the normal direction is determined; next, a correction combination parameter is determined based on a preset constant value, a first weight of the preset constant value, the first combination parameter and a second weight of the first combination parameter; finally, when the correction combination parameter is greater than a critical threshold, the diffuse reflection coefficient is determined to be the correction combination parameter; when the correction combination parameter is less than or equal to the critical threshold, the diffuse reflection coefficient is determined to be the critical threshold.
[0125] Exemplarily, the first combination parameter may be the inner product of the direction vector of the light source direction and the direction vector of the normal direction, and the correction combination parameter may be the inner product of the preset constant value and the first weight, and the sum of the inner product of the first combination parameter and the second weight.
[0126] For example, the diffuse reflectance is calculated according to the following formula:
[0127] diffuse=max(0.0,k1*c1+k2*dot(N,L));
[0128] Wherein, the dot is the inner product function, the N is the normal direction, the L is the light source direction, k1 is the first weight, c1 is a preset constant value, and k2 is the second weight.
[0129] In this embodiment, by setting the second weight for the first combination parameter and setting the preset constant value and the first weight accordingly, the brightness of the dark areas in the three-dimensional hair model and the target image can be increased, making the details of the dark areas clearer.
[0130] Based on the calculated albedo coefficient, when generating a target image, the target image may be generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the albedo coefficient.
[0131] The target image is a projection of the three-dimensional hair model on a two-dimensional plane, and each pixel of the target image is a projection of a fragment of the three-dimensional hair model. Therefore, when generating the target image, the position and brightness of the projection of each fragment on the target image can be determined, and then a pixel of corresponding brightness is generated at the corresponding position of the target image. After each fragment of the three-dimensional hair model generates a corresponding pixel, the target image is generated. Optionally, first, the transmission brightness of the fragment is determined based on the color data of the fragment and the transmission parameter; next, the diffuse reflection brightness of the fragment is determined based on the color data of the fragment and the diffuse reflection coefficient; finally, the position of the pixel point corresponding to the fragment in the target image is determined based on the geometric data of the fragment, and the transmission brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
[0132] For example, if the color data has brightness values of three channels, R, G, and B, the color brightness value can be obtained according to the color data, and then the color brightness value can be multiplied by the transmission parameter to obtain the transmission brightness, and the color brightness value can be multiplied by the diffuse reflection coefficient to obtain the diffuse reflection brightness.
[0133] This step is performed for each fragment in the three-dimensional hair model, that is, the transmission brightness and diffuse reflection brightness of each fragment are mapped to the target image respectively.
[0134] In this embodiment, the brightness of the dark parts of the three-dimensional hair model and the target image is increased by diffuse reflection brightness, and the brightness of the hair edges is brightened by edge transmission brightness, thereby increasing the transparency and realism of the hair.
[0135] In some embodiments of the present disclosure, the highlight brightness of a fragment can also be obtained in the following manner: the highlight brightness of the fragment is determined based on relevant parameters of the highlight brightness and at least one of the following directions: the light source direction, the line of sight direction, and the tangent direction in the geometric data of the fragment. This step is performed for each fragment in the three-dimensional hair model, i.e., the highlight brightness of each fragment is determined.
[0136] The position of the light source is pre-set, so the direction of the light source can be determined based on the relative position of the light source and the fragment. The line of sight direction can be determined in real time during the interaction process of the application executing the method, which represents the position and angle at which the user views the hair. For example, the line of sight direction changes when the user rotates the model. Parameters related to highlight brightness may include a highlight offset parameter, a tangent offset coefficient, and an occlusion coefficient. The tangent offset coefficient can be obtained from a preset tangent offset coefficient map, which has the tangent offset coefficient of each fragment in the three-dimensional hair model. Therefore, the tangent offset coefficient map can be obtained, and the tangent offset coefficient corresponding to the fragment in the tangent offset coefficient map can be obtained.
[0137] In one possible embodiment, as follows Figure 4 The method shown in FIG. 4 is to determine the highlight brightness of a fragment, including steps S401 to S403 .
[0138] In step S401, the first highlight brightness of the fragment is determined according to the light source direction, the line of sight direction, the first highlight offset parameter, the tangent offset coefficient and the tangent direction, wherein the first highlight brightness is the basic component of the highlight brightness.
[0139] The first highlight offset parameter is preset. When a fragment shader is used to draw a two-dimensional hair image, the first highlight offset parameter is a preset parameter in the fragment shader.
[0140] You can first use the first specular shift parameter (PrimarySpecularShift) and the tangent offset coefficient (ShiftTex) to offset the tangent direction, and then calculate the first specular brightness spec1 according to the following formula:
[0141] spec1=smoothstep(-1.0,0.0,dot(H,T)*pow(sinHT,Exp)
[0142] Where smoothstep is a truncation function, dot is an inner product function, H is the half-angle vector between the light direction and the view direction, T is the direction vector of the offset tangent direction, pow is an exponential function, sinHT is the sine of the angle between the half-angle vector and the offset tangent direction, and Exp is a preset second exponent. When using a fragment shader to render a 2D hair image, Exp is a preset parameter in the fragment shader.
[0143] In step S402, the second highlight brightness is determined based on the light source direction, the line of sight direction, the second highlight offset parameter, the tangent offset coefficient, the tangent direction and the occlusion coefficient, wherein the second highlight brightness is a component of the highlight brightness formed by selective occlusion on the basis of the first highlight brightness, and the occlusion coefficient is used to characterize whether a second highlight exists at the fragment.
[0144] The second highlight offset parameter is pre-set. When a fragment shader is used to render a two-dimensional hair image, the second highlight offset parameter is a preset parameter in the fragment shader. When the occlusion coefficient is 1, it indicates that the fragment has a second highlight, and when the occlusion coefficient is 0, it indicates that the fragment does not have a second highlight. The occlusion coefficient can be obtained from a preset highlight occlusion map. The highlight occlusion map contains the occlusion coefficient of each fragment in the three-dimensional hair model. Therefore, the highlight occlusion map can be obtained, and the occlusion coefficient corresponding to the fragment in the highlight occlusion map can be obtained.
[0145] You can first use the second specular shift parameter (SecondarySpecularShift) and the tangent offset coefficient (ShiftTex) to offset the tangent direction, and then calculate the second specular brightness spec2 according to the following formula:
[0146] Spec2=SpecMask*smoothstep(-1.0,0.0,dot(H,T)*pow(sinHT,Exp)
[0147] Wherein, SpecMask is the occlusion coefficient, smoothstep is the truncation function, dot is the inner product function, H is the half-angle vector between the light direction and the view direction, T is the direction vector of the offset tangent direction, pow is the exponential function, sinHT is the sine of the angle between the half-angle vector and the offset tangent direction, and Exp is the preset second exponent. When using a fragment shader to render a 2D hair image, Exp is a preset parameter in the fragment shader.
[0148] In step S403, the highlight brightness of the fragment is determined based on the first highlight brightness and the second highlight brightness. The highlight brightness of the fragment can be obtained by adding the first highlight brightness and the second highlight brightness.
[0149] According to the method provided in step S401 to step S403, the highlight brightness of each fragment of the three-dimensional hair model is determined in sequence.
[0150] Based on the above-calculated highlight brightness, when generating a target image, the target image may be generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the highlight brightness.
[0151] Optionally, first, the transmission brightness of the fragment is determined based on the color data of the fragment and the transmission parameter; next, the position of the pixel point corresponding to the fragment in the target image is determined based on the geometric data of the fragment, and the transmission brightness and the highlight brightness are mapped to the pixel point according to the position.
[0152] This step is performed for each fragment in the three-dimensional hair model, that is, the transmission brightness and highlight brightness of each fragment are mapped to the target image respectively.
[0153] In this embodiment, the anisotropic highlight composed of the first highlight brightness and the second highlight brightness can increase the highlight details of the three-dimensional hair model and the target image, and the edge brightness of the hair can be brightened by the edge transmission brightness, thereby increasing the transparency and realism of the hair.
[0154] In some embodiments of the present disclosure, the diffuse reflection coefficient and highlight brightness of the fragment can also be calculated respectively in the manner provided in the above embodiments, and then when generating the target image, the target image can be generated based on the geometric data of the fragment, the color data of the fragment, the transmission parameters, the diffuse reflection coefficient and the highlight brightness.
[0155] Optionally, first, the transmission brightness of the fragment is determined based on the color data of the fragment and the transmission parameter; next, the diffuse reflection brightness of the fragment is determined based on the color data of the fragment and the diffuse reflection coefficient; finally, the position of the pixel point corresponding to the fragment in the target image is determined based on the geometric data of the fragment, and the transmission brightness, the diffuse reflection brightness and the highlight brightness are mapped to the pixel point according to the position.
[0156] In this embodiment, the brightness of the dark parts of the three-dimensional hair model and the target image is increased by diffuse reflection brightness, and the highlight details of the three-dimensional hair model and the target image can be increased by anisotropic highlights composed of the first highlight brightness and the second highlight brightness. The brightness of the hair edge is brightened by edge transmission brightness, thereby increasing the transparency and realism of the hair.
[0157] An embodiment of the present disclosure exemplarily illustrates a complete process of generating two-dimensional hair using the image generation method provided in the application, and the process includes steps 1 to 6.
[0158] First, perform step 1: Import the 3D hair model and, based on the model's tangent texture or model tangents, obtain vertex coordinates, tangents, normals, and color data in the vertex shader. Using the vertex tangents obtained in the vertex shader, interpolate the coordinates, tangents, normals, and color data for each fragment in the fragment shader.
[0159] Then execute step 2: calculate the diffuse reflection coefficient of each fragment according to the following formula: diffuse = max(0.0,k1*c1+k2*dot(N,L)), where dot is the inner product function, N is the direction vector of the normal direction of the fragment, L is the direction vector of the light source direction, k1 is the first weight, c1 is the preset constant value, and k2 is the second weight.
[0160] Then execute step 3: offset the tangent of each fragment accordingly according to the first highlight offset parameter (PrimarySpecularShift) in the fragment shader and the tangent offset coefficient of each fragment obtained from the tangent offset coefficient map; then calculate the first highlight brightness of each fragment according to the following formula: spec1 = smoothstep(-1.0,0.0,dot(H,T)*pow(sinHT,Exp), where smoothstep is the truncation function, dot is the inner product function, H is the half-angle vector of the light direction and the line of sight direction, T is the direction vector of the tangent direction, pow is the exponential function, sinHT is the sine of the angle between the above half-angle vector and the tangent direction, and Exp is the second exponential power preset in the fragment shader.
[0161] Then execute step 4: offset the tangent of each fragment accordingly according to the second specular shift parameter (SecondarySpecularShift) in the fragment shader and the tangent offset coefficient of each fragment obtained from the tangent offset coefficient map; then calculate the second specular brightness of each fragment according to the following formula: spec2 = SpecMask*smoothstep(-1.0,0.0,dot(H,T)*pow(sinHT,Exp), where SpecMask is the occlusion coefficient of the fragment obtained from the specular occlusion map, smoothstep is the truncation function, dot is the inner product function, H is the half-angle vector of the light direction and the line of sight direction, T is the direction vector of the tangent direction, pow is the exponential function, sinHT is the sine of the angle between the above half-angle vector and the tangent direction, and Exp is the second exponential power preset in the fragment shader.
[0162] Then execute step 5: construct a 3D body model within the 3D hair model, and calculate the position parameters of each fragment and the 3D body model according to the following formula: dirAtten = dot(vPos-O, (vPos-O)*ScaleMat), dot is the inner product function, vPos is the position coordinate of the fragment in the camera coordinate system, O is the position coordinate of the center of the 3D body model in the camera coordinate system, and ScaleMat is the scaling matrix composed of the scaling coefficients of each axis of the 3D body model. Then the transmission parameters of each fragment are calculated according to the following formula: M = smoothstep(TTdirAttenMin,TTdirAttenMax,dirAtten)*pow(sinVN,ExpTT), where smoothstep is the truncation function, TTdirAttenMin is the preset minimum attenuation truncation coefficient, TTdirAttenMin is less than 1, TTdirAttenMax is the preset maximum attenuation truncation coefficient, TTdirAttenMax is greater than 1, pow is the exponential function, sinVN is the sine value of the angle between the line of sight and the normal direction, and ExpTT is the first exponential power preset in the fragment shader.
[0163] Then execute step 6: multiply the diffuse reflection coefficient of each fragment with its color data to determine the diffuse reflection brightness of each fragment, and multiply the transmission parameter of each fragment with its color data to determine the transmission brightness of each fragment. Finally, determine the position of the corresponding pixel point in the target image according to the position coordinates of each fragment, and map the diffuse reflection brightness, transmission brightness, first highlight brightness and second highlight brightness to the corresponding pixel points respectively to generate the target image, that is, the real-time two-dimensional hair image corresponding to the three-dimensional hair model.
[0164] This embodiment provides a hair rendering solution that meets the needs of real-time interaction. Compared with general pre-rendered highlight solutions, it can provide more realistic anisotropic highlights, while adding a natural transition edge transmission light effect and diffuse reflection effect, significantly improving the sense of realism and naturalness.
[0165] According to a second aspect of the present disclosure, an image generating device is provided. Figure 5 , the device comprises:
[0166] A first acquisition module 501 is configured to acquire a three-dimensional hair model and construct a three-dimensional body model based on the three-dimensional hair model, wherein the three-dimensional body model is configured to represent the body occluded by the hair represented by the three-dimensional hair model;
[0167] a first parameter module 502 for determining a transmission parameter of a fragment in the 3D hair model based on a line of sight, geometric data of the 3D body model, and geometric data of the fragment in the 3D hair model, wherein the transmission parameter is used to characterize brightness differences at different locations in the 3D hair model caused by light transmission;
[0168] The generating module 503 is configured to generate a target image corresponding to the three-dimensional hair model according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
[0169] In some embodiments of the present disclosure, the determining module is specifically configured to:
[0170] determining a position parameter based on the geometric data of the three-dimensional body model and the three-dimensional coordinates in the geometric data of the fragment, wherein the position parameter is used to represent the relative position of the fragment and the three-dimensional body model;
[0171] A transmission parameter of the fragment is determined according to the position parameter, the viewing direction, and the geometric data of the fragment.
[0172] In some embodiments of the present disclosure, a second parameter module is further included, configured to:
[0173] Determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment;
[0174] The generation module is specifically used for:
[0175] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the diffuse reflection coefficient.
[0176] In some embodiments of the present disclosure, the geometric data of the fragment includes the normal direction of the fragment; and the second parameter module is specifically configured to:
[0177] Determine a first combination parameter of the direction vector of the light source direction and the direction vector of the normal direction;
[0178] determining a correction combining parameter according to a preset constant value, a first weight of the preset constant value, the first combining parameter, and a second weight of the first combining parameter;
[0179] When the correction combination parameter is greater than a critical threshold, the diffuse reflectance is determined as the correction combination parameter; when the correction combination parameter is less than or equal to the critical threshold, the diffuse reflectance is determined as the critical threshold.
[0180] In some embodiments of the present disclosure, when the generation module is used to generate the target image based on the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the diffuse reflection coefficient, it is specifically used to:
[0181] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0182] Determining the diffuse reflection brightness of the fragment according to the color data of the fragment and the diffuse reflection coefficient;
[0183] According to the geometric data of the fragment, the position of the pixel point corresponding to the fragment in the target image is determined, and the transmitted brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
[0184] In some embodiments of the present disclosure, a high-light module is further included, which is used to:
[0185] Obtain the highlight brightness of the fragment;
[0186] The generation module is specifically used for:
[0187] The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the highlight brightness.
[0188] In some embodiments of the present disclosure, the highlight module is specifically used to:
[0189] The highlight brightness of the fragment is determined according to relevant parameters of the highlight brightness and at least one of the following directions: a light source direction, the line of sight direction, and a tangent direction in the geometric data of the fragment.
[0190] In some embodiments of the present disclosure, the highlight module is configured to determine the highlight brightness of the fragment based on relevant parameters of the highlight brightness and at least one of the following directions: the light source direction, the line of sight direction, and the tangent direction in the geometric data of the fragment, and is specifically configured to:
[0191] Determining a first highlight brightness of the fragment according to the light source direction, the sight line direction, a first highlight offset parameter, a tangent offset coefficient, and the tangent direction, wherein the first highlight brightness is a basic component of the highlight brightness;
[0192] determining a second highlight brightness according to the light source direction, the sight line direction, a second highlight offset parameter, a tangent offset coefficient, the tangent direction, and the occlusion coefficient, wherein the second highlight brightness is a component of highlight brightness formed by selective occlusion on the basis of the first highlight brightness, and the occlusion coefficient is used to indicate whether a second highlight exists at the fragment;
[0193] Determine the highlight brightness of the fragment according to the first highlight brightness and the second highlight brightness.
[0194] In some embodiments of the present disclosure, further comprising:
[0195] A second acquisition module is configured to acquire a tangent offset coefficient map and acquire a tangent offset coefficient corresponding to the fragment in the tangent offset coefficient map; and / or
[0196] The third acquisition module is used to obtain a highlight occlusion map and obtain an occlusion coefficient corresponding to the fragment in the highlight occlusion map.
[0197] In some embodiments of the present disclosure, when the generation module is used to generate the target image based on the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the highlight brightness, it is specifically used to:
[0198] Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter;
[0199] According to the geometric data of the fragment, a position of a pixel point corresponding to the fragment in the target image is determined, and the transmission brightness and the highlight brightness are mapped to the pixel point according to the position.
[0200] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method in the third aspect, and will not be elaborated here.
[0201] In the third aspect, at least one embodiment of the present disclosure provides a device, please refer to the attached Figure 6 , which shows the structure of the device, the device includes a memory and a processor, the memory is used to store computer instructions that can be run on the processor, and the processor is used to generate an image based on the method described in any one of the first aspects when executing the computer instructions.
[0202] In a fourth aspect, at least one embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements any of the methods described in the first aspect when the program is executed by a processor.
[0203] The present disclosure relates to the field of augmented reality. By acquiring image information of a target object in a real-world environment, the relevant features, states, and attributes of the target object are detected or identified using various vision-related algorithms, thereby achieving an AR effect that combines virtual and real life and matches the specific application. For example, the target object may be a face, limbs, gestures, movements, etc. related to the human body, or an identifier or marker related to an object, or a sandbox, display area, or display items related to a venue or location. Vision-related algorithms may involve visual positioning, SLAM, 3D reconstruction, image registration, background segmentation, key point extraction and tracking of objects, and object pose or depth detection. Specific applications can involve not only interactive scenarios such as guided tours, navigation, explanations, reconstruction, and virtual effect overlay displays related to real scenes or objects, but also special effects processing related to people, such as makeup beautification, body beautification, special effects display, and virtual model display. Detection or identification of the relevant features, states, and attributes of the target object can be achieved using a convolutional neural network. The above-mentioned convolutional neural network is a network model obtained by model training based on a deep learning framework.
[0204] In the present disclosure, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The term "plurality" refers to two or more than two, unless otherwise clearly defined.
[0205] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0206] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image generation method, characterized in that: include: Acquire a three-dimensional hair model, and construct a three-dimensional body model based on the three-dimensional hair model, wherein the three-dimensional body model is used to represent the body occluded by the hair represented by the three-dimensional hair model; According to the line of sight direction, the geometric data of the 3D body model, and the geometric data of the fragment in the 3D hair model, the transmission parameter of the fragment is determined according to the following formula: M=smoothstep(TTdirAttenMin,TTdirAttenMax,dirAtten)*pow(sinVN,ExpT T); dirAtten=dot(vPos-O,ScaleMat*(vPos-O)); Among them, the smoothstep is a truncation function, the TTdirAttenMin is a preset minimum attenuation truncation coefficient, the TTdirAttenMin is less than 1, the TTdirAttenMax is a preset maximum attenuation truncation coefficient, the TTdirAttenMax is greater than 1, the pow is an exponential function, the sinVN is the sine value of the angle between the line of sight direction and the normal direction, and the ExpTT is a preset first exponential power; dirAtten is a position parameter used to characterize the relative position of the fragment and the three-dimensional body model in the camera coordinate system, the dot is an inner product function, the vPos is the position coordinate of the fragment in the camera coordinate system, the O is the position coordinate of the center of the three-dimensional body model in the camera coordinate system, and the ScaleMat is a scaling matrix composed of scaling coefficients of each axis in the geometric data of the three-dimensional body model; the transmission parameter is used to characterize the brightness difference caused by light source transmission at different positions in the three-dimensional hair model; A target image corresponding to the three-dimensional hair model is generated according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
2. The image generation method according to claim 1, wherein: The determining of the transmission parameters of the fragments according to the sight direction, the geometric data of the three-dimensional body model, and the geometric data of the fragments in the three-dimensional hair model includes: determining position parameters based on the geometric data of the three-dimensional body model and the three-dimensional coordinates in the geometric data of the fragment, wherein the position parameters are used to represent the relative position of the fragment and the three-dimensional body model in a camera coordinate system; A transmission parameter of the fragment is determined according to the position parameter, the viewing direction, and the geometric data of the fragment.
3. The image generation method according to claim 1 or 2, characterized in that: Also includes: Determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment; Generating a target image corresponding to the three-dimensional hair model according to the geometric data of the fragment, the color data of the fragment, and the transmission parameter includes: The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the diffuse reflection coefficient.
4. The image generation method according to claim 3, wherein: The geometric data of the fragment includes a normal direction of the fragment; and determining the diffuse reflection coefficient of the fragment according to the light source direction and the geometric data of the fragment includes: Determine a first combination parameter of the direction vector of the light source direction and the direction vector of the normal direction; determining a correction combining parameter according to a preset constant value, a first weight of the preset constant value, the first combining parameter, and a second weight of the first combining parameter; When the correction combination parameter is greater than a critical threshold, the diffuse reflectance is determined as the correction combination parameter; when the correction combination parameter is less than or equal to the critical threshold, the diffuse reflectance is determined as the critical threshold.
5. The image generation method according to claim 3, wherein: Generating the target image according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the diffuse reflection coefficient includes: Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter; Determining the diffuse reflection brightness of the fragment according to the color data of the fragment and the diffuse reflection coefficient; According to the geometric data of the fragment, the position of the pixel point corresponding to the fragment in the target image is determined, and the transmitted brightness and the diffuse reflection brightness are mapped to the pixel point according to the position.
6. The image generation method according to claim 1 or 2, characterized in that: Also includes: Obtain the highlight brightness of the fragment; Generating a target image corresponding to the three-dimensional hair model according to the geometric data, color data and transmission parameters of the fragment includes: The target image is generated according to the geometric data of the fragment, the color data of the fragment, the transmission parameter and the highlight brightness.
7. The image generation method according to claim 6, wherein: The obtaining of the highlight brightness of the fragment includes: The highlight brightness of the fragment is determined according to relevant parameters of the highlight brightness and at least one of the following directions: a light source direction, the line of sight direction, and a tangent direction in the geometric data of the fragment.
8. The image generation method according to claim 7, wherein: The determining of the highlight brightness of the fragment based on the relevant parameters of the highlight brightness and at least one of the following directions: a light source direction, a sight line direction, and a tangent direction in the geometric data of the fragment, includes: Determining a first highlight brightness of the fragment according to the light source direction, the sight line direction, a first highlight offset parameter, a tangent offset coefficient, and the tangent direction, wherein the first highlight brightness is a basic component of the highlight brightness; determining a second highlight brightness according to the light source direction, the sight line direction, a second highlight offset parameter, a tangent offset coefficient, the tangent direction, and an occlusion coefficient, wherein the second highlight brightness is a component of highlight brightness formed by selective occlusion on the basis of the first highlight brightness, and the occlusion coefficient is used to indicate whether a second highlight exists at the fragment; Determine the highlight brightness of the fragment according to the first highlight brightness and the second highlight brightness.
9. The image generation method according to claim 8, characterized in that: Also includes: Obtain a tangent offset coefficient map, and obtain a tangent offset coefficient corresponding to the fragment in the tangent offset coefficient map; and / or, Obtain a specular occlusion map, and obtain an occlusion coefficient corresponding to the fragment in the specular occlusion map.
10. The image generation method according to claim 6, wherein: Generating the target image according to the geometric data of the fragment, the color data of the fragment, the transmission parameter, and the highlight brightness includes: Determining the transmission brightness of the fragment according to the color data of the fragment and the transmission parameter; According to the geometric data of the fragment, a position of a pixel point corresponding to the fragment in the target image is determined, and the transmission brightness and the highlight brightness are mapped to the pixel point according to the position.
11. An image generating device, characterized in that: include: a first acquisition module, configured to acquire a three-dimensional hair model and construct a three-dimensional body model based on the three-dimensional hair model, wherein the three-dimensional body model is used to represent the body occluded by the hair represented by the three-dimensional hair model; The first parameter module is configured to determine the transmission parameter of a fragment according to the following formula based on the line of sight direction, the geometric data of the 3D body model, and the geometric data of the fragment in the 3D hair model: M=smoothstep(TTdirAttenMin,TTdirAttenMax,dirAtten)*pow(sinVN,ExpT T); dirAtten=dot(vPos-O,ScaleMat*(vPos-O)); Among them, the smoothstep is a truncation function, the TTdirAttenMin is a preset minimum attenuation truncation coefficient, the TTdirAttenMin is less than 1, the TTdirAttenMax is a preset maximum attenuation truncation coefficient, the TTdirAttenMax is greater than 1, the pow is an exponential function, the sinVN is the sine value of the angle between the line of sight direction and the normal direction, and the ExpTT is a preset first exponential power; dirAtten is a position parameter used to characterize the relative position of the fragment and the three-dimensional body model in the camera coordinate system, the dot is an inner product function, the vPos is the position coordinate of the fragment in the camera coordinate system, the O is the position coordinate of the center of the three-dimensional body model in the camera coordinate system, and the ScaleMat is a scaling matrix composed of scaling coefficients of each axis in the geometric data of the three-dimensional body model; the transmission parameter is used to characterize the brightness difference caused by light source transmission at different positions in the three-dimensional hair model; A generation module is used to generate a target image corresponding to the three-dimensional hair model according to the geometric data of the fragment, the color data of the fragment and the transmission parameter.
12. An electronic device, characterized in that: The device includes a memory and a processor, wherein the memory is used to store computer instructions that can be executed on the processor, and the processor is used to implement the method according to any one of claims 1 to 10 when executing the computer instructions.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
3-d texture super resolution image generation device and image generation method
CN102077243A
Image processing device, image processing method, and imaging device
CN103152582A