Method and device for rendering stylized cloth, storage medium and computer device
By constructing mirror and diffuse lighting models in a 3D game scene and combining them with the color and material information of the cloth, the problem of poor cloth rendering effect was solved, and delicate color expression was achieved.
Patent Information
- Application Number
- CN202211511376.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-11-29
AI Technical Summary
Existing technologies struggle to render subtle color variations in cloth within 3D game scenes, impacting the overall color presentation of the image.
By determining the color and material information of the cloth to be rendered, the reflected color is calculated, and the Fresnel factor is determined in combination with the light source information. A specular reflection lighting model is constructed using the Fresnel factor, normal distribution factor, and micro-surface distribution factor, and the specular and diffuse reflection lighting models are combined for rendering.
It improves the color representation of cloth in 3D models, showing a delicate mirror reflection effect and enhancing the realism of cloth colors after rendering.
Smart Images

Figure CN118114420B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method, apparatus, storage medium, and computer device for rendering stylized cloth. Background Technology
[0002] In the real world, when light shines on the surface of an object, phenomena such as reflection, refraction, transmission, and absorption occur, giving the object a certain color and luster. In some virtual scenes, such as 3D game scenes, to simulate real-world lighting, a lighting model can be created and used to render objects in the virtual scene to present the effect of lighting.
[0003] In related technologies, most applications in conventional 3D games or other 3D scenes use PBR (Physically Based Rendering) technology to render 3D models. For example, Unreal Engine also uses this technology. The shading model provided by Unreal Engine covers most of the materials in the real world and can render some materials very well.
[0004] However, for other materials, such as cloth, it is difficult to achieve the desired rendering effect using the same rendering method, such as... Figure 1 As shown, Figure 1 This is a schematic diagram illustrating the effect of rendering cloth using the Unreal Engine, a current technology. Rendering cloth using Unreal Engine's primitive lighting model results in a plastic-like appearance, failing to capture the delicate color details of cloth. Since game development demands specific color representation, it's crucial to achieve a harmonious balance between light and shadow. Most characters and humanoid monsters in 3D game scenes wear clothing; poor cloth color rendering negatively impacts the overall color presentation of the image. Summary of the Invention
[0005] This application provides a method, apparatus, storage medium, and computer device for rendering stylized fabric, which can improve the color performance of fabric in the rendered 3D model.
[0006] In a first aspect, embodiments of this application provide a method for rendering stylized cloth, comprising:
[0007] Determine the color and material information of the fabric to be rendered;
[0008] The reflective color of the fabric to be rendered is determined based on the color information and the material information.
[0009] Acquire light source information, and determine the Fresnel factor based on the light source information and the reflected color;
[0010] The specular reflection illumination model is determined based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor.
[0011] A lighting model is obtained based on the specular reflection lighting model and the diffuse reflection lighting model, and the cloth to be rendered is rendered according to the lighting model.
[0012] Secondly, embodiments of this application also provide a rendering apparatus for stylized fabric, comprising:
[0013] The acquisition module is used to determine the color and material information of the cloth to be rendered;
[0014] The first determining module is used to determine the reflected color of the fabric to be rendered based on the color information and the material information;
[0015] The second determining module is used to acquire light source information and determine the Fresnel factor based on the light source information and the reflected color;
[0016] The third determining module is used to determine the specular reflection illumination model based on the Fresnel factor, normal distribution factor and micro-surface distribution factor.
[0017] The rendering module is used to obtain a lighting model based on the specular reflection lighting model and the diffuse reflection lighting model, and to perform rendering processing on the cloth to be rendered according to the lighting model.
[0018] Thirdly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to execute a rendering method for stylized cloth as provided in any embodiment of this application.
[0019] Fourthly, embodiments of this application also provide a computer device, including a processor and a memory, the memory having a computer program, and the processor executing a stylized cloth rendering method as provided in any embodiment of this application by calling the computer program.
[0020] The technical solution provided in this application, when rendering a 3D model, determines the color and material information of the cloth to be rendered, determines the reflected color of the cloth based on the color and material information, determines the Fresnel factor based on the light source information and the reflected color, then determines the specular reflection lighting model based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor, and finally obtains a lighting model by combining the specular reflection lighting model and the diffuse reflection lighting model, and then renders the cloth to be rendered based on this lighting model. In this solution, based on the construction principle of the Unreal Engine's lighting model, the reflected color is determined based on the color and material information of the cloth to be rendered, and this reflected color is incorporated into the calculation process of the Fresnel factor. This allows the specular reflection effect of the cloth rendered using the specular lighting model calculated based on the Fresnel factor to reflect subtle color changes, thereby improving the color performance of the cloth in the rendered 3D model. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram illustrating the effect of rendering cloth using the Unreal Engine, a current technology.
[0023] Figure 2 This is a flowchart illustrating a method for rendering stylized cloth provided in an embodiment of this application.
[0024] Figure 3 This is a schematic diagram illustrating the effect of rendering using the lighting model provided in the embodiment of this application.
[0025] Figure 4 This is a schematic diagram showing the rendering effects of the D component before and after optimization using the embodiments of this application.
[0026] Figure 5 This is a schematic diagram of a texture map in the stylized cloth rendering method provided in the embodiments of this application.
[0027] Figure 6 This describes the display effect of texture maps under different light and shadow transition parameters.
[0028] Figure 7 This is a schematic diagram showing the backlighting effect of a backlit surface under different shadow values.
[0029] Figure 8This is a schematic diagram of a stylized fabric rendering apparatus provided in an embodiment of this application.
[0030] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the protection scope of this application.
[0032] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0033] This application provides a method for rendering stylized cloth. Based on the construction principle of the lighting model of Unreal Engine, the method determines the reflection color according to the color and material information of the cloth to be rendered, and incorporates the reflection color into the calculation process of the Fresnel factor. This allows the specular reflection effect of the cloth to be rendered after rendering using the specular lighting model calculated based on the Fresnel factor to show subtle color changes, thereby improving the color performance of the cloth in the rendered 3D model.
[0034] The entity executing the stylized cloth rendering method can be the stylized cloth rendering device provided in this application embodiment, or a computer device integrating the stylized cloth rendering device. The stylized cloth rendering device can be implemented in hardware or software. The computer device can be a smartphone, tablet, PDA, laptop, or desktop computer, etc.
[0035] Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for rendering stylized cloth according to an embodiment of this application. The specific flow of the method for rendering stylized cloth according to an embodiment of this application can be as follows:
[0036] Step 101: Determine the color and material information of the fabric to be rendered.
[0037] The cloth to be rendered can be a target object selected by the user from the current 3D scene, and it must be a 3D model. For example, if the 3D scene is a game scene, the cloth to be rendered can be the clothing of a virtual character in that game scene. After determining the cloth to be rendered, its color and material information are then determined.
[0038] The color information can be pre-configured by the user, and specific color information can be represented using RGB three-channel color values. Material information can also be pre-configured by the user; for example, material information could be silk, cotton, velvet, etc. Both color and material information can be pre-configured in the attribute information of the 3D model to be rendered. When rendering of the cloth is required, it is retrieved from the attribute information of the cloth to be rendered.
[0039] Alternatively, in one embodiment, when rendering of the cloth to be rendered is required, the user can configure color and material information for the cloth through the Unreal Engine's material editor.
[0040] Step 102: Determine the reflection color of the fabric to be rendered based on the color and material information.
[0041] After obtaining the color and material information of the fabric to be rendered, the reflected color that the fabric can present when illuminated is determined based on the color and material information.
[0042] In some embodiments, the step of determining the reflective color of the fabric to be rendered based on color information and material information includes: obtaining a reflective color lookup table, which includes a correspondence between preset colors, preset materials and reflective colors; and determining a reflective color that matches the color information and material information from the reflective color lookup table as the reflective color of the fabric to be rendered.
[0043] In this embodiment, a pre-configured correspondence between preset colors, preset materials, and reflection colors is established, for example, by storing this correspondence in a table. In this table, for each preset material, the reflection color corresponding to that preset color is stored. That is, for the same material of fabric to be rendered, the reflection color will differ depending on the fabric's inherent color. Based on this, after obtaining the color and material information of the fabric to be rendered, the computer device retrieves the corresponding reflection color from the aforementioned table according to the color and material information.
[0044] Step 103: Obtain the light source information and determine the Fresnel factor based on the light source information and the reflected color.
[0045] After obtaining the reflected color, the Fresnel factor is calculated based on the reflected color.
[0046] Next, we will introduce the phenomenon of specular reflection based on the micro-plane theory. The micro-plane theory analyzes this from a microscopic perspective. It posits that the surface of any object, at the microscopic scale, is composed of many smaller mirrors. When the normals of these tiny mirrors are relatively concentrated, the specular reflection of the object is more pronounced from a macroscopic perspective. Conversely, when the normals of these tiny mirrors are more irregular and uniformly distributed, the object's surface will be relatively rough. Diffuse reflection at the microscopic scale can be explained as follows: When light shines on the surface of an object, some light rays undergo specular reflection with the numerous tiny mirrors on the surface, while others are refracted into the object's interior. As the light rays refract into the interior, they continuously collide with the object's tiny particles and are scattered in random directions. During these collisions, some of the light's energy is absorbed and converted into heat. Some light rays, after multiple collisions, have their energy completely dissipated, indicating that the light has been completely absorbed by the object. The remaining light rays refracted into the object's interior will leave the surface again due to the randomness of their scattering direction; this portion of light constitutes diffuse reflection. The solution in this embodiment mainly optimizes the calculation of the specular reflection lighting model. Therefore, the specular reflection lighting model will be explained first, and the diffuse reflection lighting model will be explained in detail later.
[0047] The specular reflection illumination model mainly consists of three components: the normal distribution factor (D component), the Fresnel factor (F component), and the micro-surface distribution factor (G component).
[0048] The normal distribution factor, calculated from the normal distribution function, describes the probability of the plane's normal distribution, i.e., the concentration of the normals on a micro-surface with the correct orientation. Specifically, it represents the concentration of the normals relative to the surface area at a surface point with the correct orientation that can reflect light from ray l to the line of sight v. The normal distribution function can be understood as the statistical distribution of the normals on a micro-plane surface region.
[0049] The Fresnel factor is calculated based on the Fresnel equation and describes the proportion of light reflected from the surface at different surface angles.
[0050] The microsurface distribution factor, calculated using a geometry function, describes the self-shadowing property of microfacets. When a plane is relatively rough, microfacets on the surface may block other microfacets, thus reducing the amount of light reflected from the surface.
[0051] The specular reflection lighting model can be represented as follows:
[0052]
[0053] Where l represents the incident light, v represents the outgoing light, F() represents the Fresnel equation, D() represents the normal distribution function, G() represents the microsurface distribution function, diffuse represents the diffuse reflection constant, and θ d θ represents the diffuse reflection angle, θh represents the angle between the half-length vector and the normal, and θ l θ represents the angle between the surface normal and the incident light. v This represents the angle between the surface normal and the emitted light. 4θ l cosθ v It is a correction factor used to correct microplanar quantities for transformations between the local space of micro-geometry and the local space of the entire macroscopic surface.
[0054] Unreal Engine's existing material interface does not provide editing for reflection colors; instead, the reflection color is set as a scalar in the material editor. However, the specular reflection of an object actually has some color variation. Furthermore, the conventional F-component is calculated using the Schlick algorithm, which is only defined for dielectric (insulator) surfaces. However, the basic reflectivity of dielectrics differs from that of metallic materials. Therefore, Unreal Engine pre-calculates the surface reflectivity at a normal viewing angle (i.e., viewing the surface directly at 0 degrees), and then, like the Schlick algorithm, interpolates based on the viewing angle to obtain the final reflectivity. However, this approach by Unreal Engine only considers the reflection color of conductors or metallic surfaces. It does not implement reflection color rendering for insulators. But it's not just conductors or metallic surfaces that have colored basic reflectivity; many plastics, materials with colored ceramic reflective coatings, and fabrics also have colored reflectivity. Therefore, for rendering objects made of these materials, the specular reflection lighting model can be calculated according to the embodiments of this application.
[0055] To optimize the F component, and considering the need for color control of incident specular reflection, grazing specular reflection requires color variation. In this embodiment, the RGB variable of reflection color (SpecularColor) is added to the F component of the specular reflection lighting model, thereby enriching the reflection color of some insulating materials such as cloth to be rendered.
[0056] Among them, the SpecularColor value of a certain generation of rendering object, as mentioned above, can be obtained by looking up a table based on the color information and material information of the cloth to be rendered.
[0057] In some embodiments, the step of acquiring light source information and determining the Fresnel factor based on the light source information and the reflected color includes: determining the viewing angle vector based on the viewing angle of the cloth to be rendered; acquiring light source information, determining reflected light information based on the light source information, and determining the half-range vector between the incident light and the outgoing light based on the reflected light information; and determining the Fresnel factor based on the half-range vector, the viewing direction, and the reflected color.
[0058] After obtaining the color object, the Fresnel factor F can be calculated as follows.
[0059] F = saturate(a*SpecularColor)*Fc + (1-Fc)*SpecularColor, where Fc = Pow5(1-E·H), F is the Fresnel factor, Pow5() represents the power of 5 operation, E represents the line-of-sight vector, H represents the half-length vector, and E·H represents the dot product of E and H. a is a constant greater than 1, for example, a = 50, and saturate() performs the normalization operation.
[0060] In a 3D scene, light sources are placed within the scene containing the target object. These light sources illuminate the scene, giving the target object a three-dimensional appearance. For example, when light from a light source in a game scene shines on the clothing of a virtual character, diffuse and / or specular reflections need to be produced on the clothing. The solution in this application calculates a lighting model based on the light source information and the material information of the fabric, and then renders the clothing based on this model, allowing the rendered clothing to exhibit lighting effects. Designers configure light source information when designing a 3D scene, and the computer device can determine the light source information from the configuration parameters of the scene where the rendering object is currently located when calculating the lighting model.
[0061] Among them, the light source information includes the light source direction. The reflected light information can be determined based on the light source direction. The half-range vector between the incident light and the reflected light can be determined based on the reflected light information. Then, the Fresnel factor can be calculated according to the above formula.
[0062] Step 104: Determine the specular reflection illumination model based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor.
[0063] After calculating the Fresnel factor, f(l,v) can be calculated using the formula for the reflected light model described above. The normal distribution factor and micro-surface distribution factor in this embodiment can be calculated using conventional methods, which will not be elaborated here.
[0064] Step 105: Obtain the lighting model based on the specular reflection lighting model and the diffuse reflection lighting model, and then perform rendering processing on the cloth to be rendered according to the lighting model.
[0065] After obtaining the specular reflection lighting model, combining the specular reflection lighting model and the diffuse reflection lighting model yields a complete lighting model for the object's surface. This lighting model is then used to render the cloth to be rendered, ensuring that the cloth displays a reflective color consistent with its material and color. For example... Figure 3 As shown, Figure 3 This is a schematic diagram illustrating the effect of rendering a lighting model provided by the solution of this application embodiment. The object in the diagram is a peach-colored velvet. As can be seen from the diagram, the rendered fabric does not only have its inherent color, but also exhibits a certain reflective color under lighting, with delicate color changes, which enhances the color performance of the rendered 3D model.
[0066] In practice, this application is not limited by the execution order of the described steps. Without causing conflicts, some steps may be performed in other orders or simultaneously.
[0067] As can be seen from the above, the stylized cloth rendering method provided in this application, when rendering a 3D model, determines the color and material information of the cloth to be rendered, determines the reflected color of the cloth based on the color and material information, determines the Fresnel factor based on the light source information and the reflected color, then determines the specular reflection lighting model based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor, and finally obtains the lighting model by combining the specular reflection lighting model and the diffuse reflection lighting model, and then renders the cloth to be rendered based on the lighting model. In this scheme, based on the construction principle of the lighting model of Unreal Engine, the reflected color is determined according to the color and material information of the cloth to be rendered, and the reflected color is combined into the calculation process of the Fresnel factor. This allows the specular reflection effect of the cloth to be rendered after rendering using the specular lighting model calculated based on the Fresnel factor to reflect subtle color changes, thereby improving the color performance of the cloth in the rendered 3D model.
[0068] In Unreal Engine's PBR (Presentation-Based Rendering) architecture, roughness is used by default to control the D-component in the specular reflection lighting model. However, for some special materials, such as silk fabric, the roughness is generally low. If the original D-component calculation method is used, the rendering effect of the fabric will be poor.
[0069] Based on this, in some embodiments, before determining the specular reflection lighting model according to the Fresnel factor, normal distribution factor, and micro-surface distribution factor, the method further includes: determining the surface roughness of the fabric to be rendered based on material information; when the surface roughness is less than a preset threshold, determining the normal distribution factor according to a first preset algorithm, the surface roughness, the normal vector of the surface of the rendered object, and the half-range vector between the incident light and the outgoing light; when the surface roughness is greater than or equal to the preset threshold, obtaining the glossiness of the fabric to be rendered, and determining the normal distribution factor according to a second preset algorithm, the glossiness, the normal vector, and the half-range vector.
[0070] For some types of fabric to be rendered, such as cloth, the difference in roughness between different materials is relatively large. For example, cotton has a relatively large roughness, while silk has a relatively small roughness. In this embodiment, a preset threshold for roughness is set. Based on this preset threshold, the algorithm for calculating the D component of fabric with smaller roughness is distinguished from that of fabric with larger roughness.
[0071] In addition to pre-configuring roughness parameters, glossiness parameters can also be configured in the material information of the cloth to be rendered. First, the material information of the cloth to be rendered is determined. The roughness is obtained from the material information, and it is determined whether the roughness is less than a preset threshold. If the roughness is less than the preset threshold, it indicates that the cloth to be rendered is relatively smooth. Then, the D component of the specular reflection model is calculated according to the first preset algorithm. In other words, for relatively smooth cloth, the specular reflection of the cloth is controlled by the glossiness parameter. Specifically, the normal distribution factor is determined based on the first preset algorithm, surface roughness, the surface normal vector of the rendered object, and the half-range vector between the incident and outgoing light. The calculation formula of the first preset algorithm is expressed as follows:
[0072]
[0073] Wherein, sin2h=max(1.0-cos2h,0.0078125),cos2h=(·H)*(N·H).
[0074] Where sh represents glossiness, N represents the normal vector, H represents the half-range vector between the incident and outgoing light, and N·H represents the dot product operation between N and H.
[0075] Conversely, if the roughness is greater than or equal to a preset threshold, it indicates that the cloth to be rendered is relatively rough. In this case, the D component of the specular reflection model is calculated according to the second preset algorithm. That is, for relatively rough cloth, the specular reflection is controlled based on the roughness parameter. Specifically, the normal distribution factor is determined based on the second preset algorithm, glossiness, normal vector, and half-length vector. The calculation formula for the second preset algorithm is as follows:
[0076]
[0077] d=(N·H-rough*(N·H))*(N·H)+oughness
[0078] Where roughness represents the surface roughness, N represents the normal vector, H represents the half-length vector between the incident and outgoing light, and N·H represents the dot product operation between N and H. A and B are constants greater than 1, for example, A = B = 4.0.
[0079] like Figure 4 As shown, Figure 4 The illustrations show the rendering effects of the D component before and after optimization using the embodiments of this application. The left side shows the rendering before optimization, and the right side shows the rendering after optimization. The fabric in the illustrations is white velvet with a high roughness. The D component is calculated using the second preset algorithm, and the optimized rendering effect can reflect the delicate color variations of the velvet.
[0080] The solution in this embodiment calculates the normal distribution factor by using the surface roughness and gloss of the fabric to be rendered, thereby optimizing the D component in the specular reflection lighting model and improving the specular reflection effect.
[0081] In some embodiments, the steps of obtaining a lighting model based on a specular lighting model and a diffuse lighting model, and rendering the cloth to be rendered according to the lighting model, include: determining an initial diffuse lighting model; generating a stylized texture of the light-dark boundary region of the cloth to be rendered based on light source information, texture map, and stylization parameters corresponding to the texture map; overlaying the stylized texture with the initial diffuse lighting model to obtain a diffuse lighting model; obtaining a lighting model based on a specular lighting model and a diffuse lighting model, and rendering the cloth to be rendered according to the lighting model.
[0082] This embodiment provides a method for stylizing the rendering of cloth. The method determines the light-dark boundary region of the cloth to be rendered based on light source information, generates a stylized texture of the light-dark boundary region of the cloth using a user-defined texture map and its corresponding stylization parameters, and then overlays this stylized texture with the initial diffuse lighting model to obtain the final diffuse lighting model.
[0083] In some embodiments, the light source information includes the light source direction; the step of generating a stylized texture of the light-dark boundary region of the cloth to be rendered based on the light source information, the texture map, and the stylization parameters corresponding to the texture map includes: determining the light-dark boundary region of the cloth to be rendered based on the light source direction; obtaining the texture map and the stylization parameters corresponding to the texture map; and generating a stylized texture of the light-dark boundary region based on the texture map and the stylization parameters.
[0084] In this embodiment, the light-dark boundary region of the cloth to be rendered is determined according to the direction of the light source. The part facing the light source is the light area, and the part facing away from the light source is the dark area. The area where the light area and the dark area intersect forms the light-dark boundary region. The texture map can be selected by the user according to the desired effect; for example, it can be a continuous four-sided texture map.
[0085] like Figure 5 As shown, Figure 5 This is a schematic diagram of a texture map in the stylized cloth rendering method provided in this application embodiment. When setting the texture map, the user also needs to set stylization parameters for the rendering effect of the texture map.
[0086] For example, in some embodiments, the step of obtaining a texture map and the stylization parameters corresponding to the texture map includes: obtaining a pre-configured texture map and the stylization parameters corresponding to the texture map, wherein the stylization parameters include one or more of the following: light and dark boundary position parameters, light and dark boundary transition parameters, and brush stroke parameters of the texture map.
[0087] In this application's embodiments, "stylization" is used in contrast to realism. Realism refers to representing an object as realistically as possible in the real world, making the model appear lifelike and "realistic." Stylization, on the other hand, is a visual representation that can depict the appearance of an object without sufficient experimentation and accurate representation. Stylization does not pursue "realism" but can exaggerate or omit details of an object. In this application's embodiments, setting texture maps at the light and shadow transitions of the cloth is a stylized rendering method. The stylization parameters are parameters configured for the rendering effect of the texture maps.
[0088] For example, a texture configuration node can be provided through the material editor, where users can input texture maps and their corresponding stylization parameters. Stylization parameters include one or more of the following: kibbles, kibbles transition parameters, and texture map stroke parameters.
[0089] The light-dark boundary position parameter is used to adjust the proportion of the bright and dark parts of the texture map in the light-dark boundary area. For example, the proportion of the bright and dark parts can be set to 4:6 or 3:7.
[0090] The light-dark boundary transition parameter can be used to set the degree of influence of the texture map on the light-dark boundary. This value can range from (-1, 1), such as... Figure 6 As shown, Figure 6 This describes the display effect of a texture map under different light and shadow transition parameters. The closer this parameter is to -1, the better. Figure 6As shown by the sphere on the left, the closer the brush stroke color in the texture map is to the color of the dark area of the cloth to be rendered; the closer this parameter is to 1, the better. Figure 6 As shown by the sphere on the right, the closer the brush stroke color in the texture map is to the color of the bright area of the cloth to be rendered; when this parameter is equal to 0, as... Figure 6 As shown in the sphere located in the middle, the effect of this texture map is zero, which is equivalent to not having this texture map.
[0091] Among them, the brush stroke parameters of the texture map include the brush stroke size, which users can set according to the effect they want to achieve.
[0092] After obtaining the above stylization parameters through the texture configuration node, the computer device can generate a stylized texture of the light and dark boundary region based on one or more of the brush stroke parameters, light and dark boundary position parameters, and light and dark boundary transition parameters.
[0093] For example, in one embodiment, the computer device can first set the brushstroke display effect of the texture map according to the brushstroke parameters, then multiply the light and dark boundary position parameters with the texture map after setting the brushstroke parameters to obtain an intermediate stylized texture, and then multiply the light and dark boundary transition parameters with the intermediate texture display to obtain the final stylized texture.
[0094] After obtaining the stylized texture, the initial diffuse lighting model can be processed based on the stylized texture. For example, in some embodiments, the step of overlaying the stylized texture with the initial diffuse lighting model to obtain the diffuse lighting model includes: processing the stylized texture and the initial diffuse lighting model according to a first algebraic operation logic to obtain a first diffuse lighting model; obtaining the shadow value of the backlit side of the cloth to be rendered, and processing the shadow value with the first diffuse lighting model according to a second algebraic operation logic to obtain a second diffuse lighting model; and normalizing the value of the second diffuse lighting model to obtain the diffuse lighting model.
[0095] The initial diffuse lighting model can be a conventional diffuse lighting model, such as the Burley diffuse model or the Lambert model. The stylized texture and the initial diffuse lighting model are processed according to first-algebraic operation logic to obtain the first diffuse lighting model. The first-algebraic operation logic can be multiplication or addition.
[0096] In this embodiment, the user can also set the shadow value of the backlit side of the fabric to be rendered as needed. This shadow value is used to set the brightness of the backlit side, such as... Figure 7 As shown, Figure 7This diagram illustrates the backlighting effect of a backlit surface under different shadow values. The smaller the shadow value, the darker the backlit surface of the object. In one embodiment, a shadow value configuration node can be provided through the material editor, allowing the user to set specific shadow values. The range of these shadow values can be set to (0,1).
[0097] After obtaining the first diffuse lighting model, the shadow values set by the user for the backlit side of the cloth to be rendered can be acquired. These shadow values are then processed with the first diffuse lighting model using second algebraic operation logic to further stylize the cloth. The shadow values and the first diffuse lighting model are processed using second algebraic operation logic to obtain the second diffuse lighting model. After obtaining the second diffuse lighting model, its values are normalized to obtain the final diffuse lighting model. The second algebraic operation logic can be either multiplication or addition.
[0098] The solution in this embodiment achieves stylized rendering of cloth in a 3D virtual scene.
[0099] In one embodiment, a rendering apparatus for stylized fabric is also provided. See also... Figure 8 , Figure 8 This is a schematic diagram of a stylized fabric rendering apparatus 300 provided in an embodiment of this application. The stylized fabric rendering apparatus 300 is applied to a computer device and includes:
[0100] The acquisition module 301 is used to determine the color and material information of the cloth to be rendered;
[0101] The first determining module 302 is used to determine the reflective color of the fabric to be rendered based on the color information and the material information;
[0102] The second determining module 303 is used to acquire light source information and determine the Fresnel factor based on the light source information and the reflected color;
[0103] The third determining module 304 is used to determine the specular reflection illumination model based on the Fresnel factor, normal distribution factor and micro-surface distribution factor.
[0104] The rendering module 305 is used to obtain a lighting model based on the specular reflection lighting model and the diffuse reflection lighting model, and to perform rendering processing on the cloth to be rendered according to the lighting model.
[0105] In some embodiments, the first determining module 302 is configured to obtain a reflection color lookup table, the reflection color lookup table including a preset color, a preset material and a correspondence between the reflection color and the preset material; and to determine a reflection color that matches the color information and the material information from the reflection color lookup table as the reflection color of the fabric to be rendered.
[0106] In some embodiments, the first determining module 302 is configured to determine a line-of-sight vector based on the viewing angle of the fabric to be rendered; acquire light source information, determine reflected light information based on the light source information, and determine a half-range vector between the incident light and the outgoing light based on the reflected light information; and determine a Fresnel factor based on the half-range vector, the line-of-sight direction, and the reflected color.
[0107] In some embodiments, the third determining module 304 is configured to determine the surface roughness of the fabric to be rendered based on the material information; when the surface roughness is less than a preset threshold, determine the normal distribution factor based on a first preset algorithm, the surface roughness, the normal vector of the surface of the rendered object, and the half-range vector between the incident light and the outgoing light; and when the surface roughness is greater than or equal to the preset threshold, obtain the glossiness of the fabric to be rendered, and determine the normal distribution factor based on a second preset algorithm, the glossiness, the normal vector, and the half-range vector.
[0108] In some embodiments, the rendering module 305 is configured to: determine an initial diffuse lighting model; generate a stylized texture of the light-dark boundary region of the cloth to be rendered based on the light source information, texture map, and stylization parameters corresponding to the texture map; overlay the stylized texture with the initial diffuse lighting model to obtain a diffuse lighting model; and obtain a lighting model based on the specular lighting model and the diffuse lighting model, and perform rendering processing on the cloth to be rendered based on the lighting model.
[0109] In some embodiments, the rendering module 305 is configured to determine the light-dark boundary region of the cloth to be rendered according to the direction of the light source; obtain a texture map and stylization parameters corresponding to the texture map; and generate a stylized texture of the light-dark boundary region according to the texture map and the stylization parameters.
[0110] In some embodiments, the rendering module 305 is configured to obtain a pre-configured texture map and stylization parameters corresponding to the texture map, wherein the stylization parameters include one or more of the following: light-dark boundary position parameters, light-dark boundary transition parameters, and brush stroke parameters of the texture map; and to generate a stylized texture of the light-dark boundary region based on one or more of the following: brush stroke parameters, light-dark boundary position parameters, and light-dark boundary transition parameters.
[0111] In some embodiments, the rendering module 305 is used to process the stylized texture and the initial diffuse lighting model according to a first algebraic operation logic to obtain a first diffuse lighting model; obtain the shadow value of the backlit side of the cloth to be rendered, process the shadow value and the first diffuse lighting model according to a second algebraic operation logic to obtain a second diffuse lighting model; and normalize the value of the second diffuse lighting model to obtain a diffuse lighting model.
[0112] It should be noted that the stylized cloth rendering device provided in this application embodiment belongs to the same concept as the stylized cloth rendering method in the above embodiment. The stylized cloth rendering device can implement any of the methods provided in the stylized cloth rendering method embodiment. For details of its implementation process, please refer to the stylized cloth rendering method embodiment, which will not be repeated here.
[0113] As can be seen from the above, the stylized cloth rendering apparatus proposed in this application determines the color and material information of the cloth to be rendered when rendering a 3D model. Based on this color and material information, the reflected color of the cloth is determined. A Fresnel factor is determined based on the light source information and the reflected color. Then, a specular reflection lighting model is determined based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor. Finally, the specular reflection lighting model and the diffuse reflection lighting model are combined to obtain a lighting model. The cloth to be rendered is then rendered based on this lighting model. In this scheme, based on the construction principle of the Unreal Engine's lighting model, the reflected color is determined based on the color and material information of the cloth to be rendered, and this reflected color is incorporated into the calculation process of the Fresnel factor. This allows the specular reflection effect of the cloth rendered using the specular lighting model calculated based on the Fresnel factor to reflect subtle color changes, thereby improving the color performance of the cloth in the rendered 3D model.
[0114] This application also provides a computer device, which can be a terminal, such as a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Figure 9 As shown, Figure 9This is a schematic diagram of a computer device provided in an embodiment of this application. The computer device 400 includes a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 and the memory 402 are electrically connected. Those skilled in the art will understand that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0115] The processor 401 is the control center of the computer device 400. It connects various parts of the computer device 400 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, it performs various functions of the computer device 400 and processes data, thereby monitoring the computer device 400 as a whole.
[0116] In this embodiment, the processor 401 in the computer device 400 loads the instructions corresponding to the processes of one or more applications into the memory 402 according to the following steps, and the processor 401 runs the applications stored in the memory 402 to achieve various functions:
[0117] Determine the color and material information of the fabric to be rendered;
[0118] The reflective color of the fabric to be rendered is determined based on the color information and the material information.
[0119] Acquire light source information, and determine the Fresnel factor based on the light source information and the reflected color;
[0120] The specular reflection illumination model is determined based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor.
[0121] A lighting model is obtained based on the specular reflection lighting model and the diffuse reflection lighting model, and the cloth to be rendered is rendered according to the lighting model.
[0122] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0123] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0124] As can be seen from the above, the computer device provided in this embodiment, when rendering a 3D model, determines the color and material information of the cloth to be rendered, determines the reflected color of the cloth based on the color and material information, determines the Fresnel factor based on the light source information and the reflected color, then determines the specular reflection lighting model based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor, and finally obtains the lighting model by combining the specular reflection lighting model and the diffuse reflection lighting model, and performs rendering processing on the cloth to be rendered based on the lighting model. In this scheme, based on the construction principle of the lighting model of Unreal Engine, the reflected color is determined according to the color and material information of the cloth to be rendered, and the reflected color is combined into the calculation process of the Fresnel factor. This allows the specular reflection effect of the cloth to be rendered after rendering using the specular lighting model calculated based on the Fresnel factor to reflect subtle color changes, thereby improving the color performance of the cloth in the rendered 3D model.
[0125] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0126] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute steps in any of the stylized cloth rendering methods provided in embodiments of this application. For example, the computer program can execute the following steps:
[0127] Determine the color and material information of the fabric to be rendered;
[0128] The reflective color of the fabric to be rendered is determined based on the color information and the material information.
[0129] Acquire light source information, and determine the Fresnel factor based on the light source information and the reflected color;
[0130] The specular reflection illumination model is determined based on the Fresnel factor, normal distribution factor, and micro-surface distribution factor.
[0131] A lighting model is obtained based on the specular reflection lighting model and the diffuse reflection lighting model, and the cloth to be rendered is rendered according to the lighting model.
[0132] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0133] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk, or optical disk, etc. Since the computer program stored in the storage medium can execute the steps of any of the stylized cloth rendering methods provided in the embodiments of this application, it can achieve the beneficial effects achievable by any of the stylized cloth rendering methods provided in the embodiments of this application, as detailed in the preceding embodiments, and will not be repeated here.
[0134] The above provides a detailed description of a stylized fabric rendering method, apparatus, medium, and computer equipment provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method of rendering a stylized cloth, the method comprising: receiving a cloth model; receiving a style; and applying the style to the cloth model to generate a stylized cloth model. The method comprises the following steps: determining color information and material information of a cloth to be rendered; determining a reflection color of the cloth to be rendered according to the color information and the material information; obtaining light source information and determining a Fresnel factor according to the light source information and the reflection color; determining a specular reflection lighting model according to the Fresnel factor, a normal distribution factor and a micro-surface distribution factor; obtaining a lighting model based on the specular reflection lighting model and a diffuse reflection lighting model, and performing rendering processing on the cloth to be rendered according to the lighting model; wherein the step of obtaining light source information and determining a Fresnel factor according to the light source information and the reflection color comprises: determining a line-of-sight vector according to an observation angle of the cloth to be rendered; obtaining light source information, determining reflection light information according to the light source information, and determining a half-way vector between incident light and outgoing light according to the reflection light information; and determining a Fresnel factor according to the half-way vector, the line-of-sight vector and the reflection color; The Fresnel factor is calculated in the following manner: ; wherein Fc=Pow5(1-E·H), F is the Fresnel factor, Pow5() represents 5th power operation, E represents the line-of-sight vector, H represents the half-way vector, E·H represents the dot product operation between E and H, a is a constant greater than 1, saturate() is a normalization operation, and SpecularColor represents the reflection color.
2. The method of rendering a stylized cloth of claim 1, wherein, The step of determining a reflection color of the cloth to be rendered according to the color information and the material information comprises: obtaining a reflection color lookup table, wherein the reflection color lookup table comprises a corresponding relationship between a preset color, a preset material and a reflection color; determining a reflection color matching the color information and the material information from the reflection color lookup table as the reflection color of the cloth to be rendered.
3. The method of rendering a stylized cloth of any of claims 1 to 2, wherein, Before the step of determining a specular reflection lighting model according to the Fresnel factor, the normal distribution factor and the micro-surface distribution factor, the method further comprises: determining a surface roughness of the cloth to be rendered according to the material information; when the surface roughness is less than a preset threshold, determining a normal distribution factor according to a first preset algorithm, the surface roughness, a normal vector of a surface of a rendering object, a half-way vector between incident light and outgoing light; when the surface roughness is greater than or equal to the preset threshold, obtaining a glossiness of the cloth to be rendered, and determining a normal distribution factor according to a second preset algorithm, the glossiness, the normal vector and the half-way vector.
4. The method of rendering a stylized cloth of claim 1, wherein, The step of obtaining a lighting model based on the specular reflection lighting model and the diffuse reflection lighting model, and performing rendering processing on the cloth to be rendered according to the lighting model comprises: determining an initial diffuse reflection lighting model; generating a stylized texture of a highlight area of the cloth to be rendered according to the light source information, a texture map and a stylization parameter corresponding to the texture map; superimposing the stylized texture and the initial diffuse reflection lighting model to obtain a diffuse reflection lighting model; obtaining a lighting model based on the specular reflection lighting model and the diffuse reflection lighting model, and performing rendering processing on the cloth to be rendered according to the lighting model.
5. The method of rendering a stylized cloth of claim 4, wherein, The light source information includes a light source direction; the step of generating the stylized texture of the highlight and dark intersection area of the cloth to be rendered according to the light source information, a texture map and the stylized parameters corresponding to the texture map comprises: determining the highlight and dark intersection area of the cloth to be rendered according to the light source direction; obtaining a texture map and the stylized parameters corresponding to the texture map; generating the stylized texture of the highlight and dark intersection area according to the texture map and the stylized parameters.
6. The method of rendering a stylized cloth of claim 5, wherein, The step of obtaining the texture map and the stylized parameters corresponding to the texture map comprises: obtaining a pre-configured texture map and the stylized parameters corresponding to the texture map, wherein the stylized parameters comprise one or more of highlight and dark intersection position parameters, highlight and dark intersection transition parameters and stroke parameters of the texture map; The step of generating the stylized texture of the highlight and dark intersection area according to the texture map and the stylized parameters comprises: generating the stylized texture of the highlight and dark intersection area according to one or more of the stroke parameters, the highlight and dark intersection position parameters and the highlight and dark intersection transition parameters.
7. A method of rendering a stylized cloth as claimed in any one of claims 4 to 6, wherein, The step of superimposing the stylized texture and the initial diffuse reflection light model to obtain the diffuse reflection light model comprises: processing the stylized texture and the initial diffuse reflection light model according to a first algebraic operation logic to obtain a first diffuse reflection light model; obtaining a shadow value of a back light surface of the cloth to be rendered, processing the shadow value and the first diffuse reflection light model according to a second algebraic operation logic to obtain a second diffuse reflection light model; and normalizing the value of the second diffuse reflection light model to obtain the diffuse reflection light model.
8. A rendering apparatus for stylized fabric, characterized in that, comprises: an obtaining module configured to determine color information and material information of cloth to be rendered; a first determining module configured to determine a reflection color of the cloth to be rendered according to the color information and the material information; a second determining module configured to obtain light source information and determine a Fresnel factor according to the light source information and the reflection color; a third determining module configured to determine a specular reflection light model according to the Fresnel factor, a normal distribution factor and a micro-surface distribution factor; a rendering module configured to obtain a light model based on the specular reflection light model and a diffuse reflection light model, and perform rendering processing on the cloth to be rendered according to the light model; The second determining module is further configured to: determine a view line vector according to an observation viewing angle of the cloth to be rendered; obtain light source information, determine reflection light information according to the light source information, and determine a half-way vector between incident light and outgoing light according to the reflection light information; and determine a Fresnel factor according to the half-way vector, the view line vector and the reflection color. The Fresnel factor F is calculated in the following manner: ; wherein Fc=Pow5(1-E·H), F is the Fresnel factor, Pow5() represents 5th power operation, E represents the view line vector, H represents the half-way vector, E·H represents the dot product operation between E and H, a is a constant greater than 1, saturate() is a normalization operation, and SpecularColor represents the reflection color.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when run on a computer, causes the computer to perform the method of rendering a stylized cloth according to any one of claims 1 to 7.
10. A computer device comprising a processor and a memory, the memory storing a computer program, characterized in that, The processor, by invoking the computer program, is configured to perform the method of rendering a stylized cloth according to any one of claims 1 to 7.
Citation Information
Patent Citations
Model rendering method, device and equipment and storage medium
CN112316420A
Stylized rendering method and device for target object, electronic equipment and storage medium
CN114419220A