Hair rendering method and apparatus, electronic device, and storage medium
By rendering semi-transparent hair sections in the hair model in both opaque and semi-transparent ways, depth information is obtained and the rendered image is fused, thus solving the problem of incorrect rendering order of semi-transparent models and improving the rendering effect and realism.
Patent Information
- Application Number
- CN202210663477.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-06-13
AI Technical Summary
During the image rendering process, the wrong rendering order of multiple translucent models leads to incorrect rendering results, especially in the hair model of hyper-realistic characters, where the positional relationship between multiple translucent models cannot be determined.
By rendering each semi-transparent hair section model opaquely to obtain depth information, and then rendering it semi-transparently, the rendered images of multiple semi-transparent hair sections are finally merged to ensure the accuracy of the rendering order.
It improved the accuracy of rendering order for multiple semi-transparent objects, enhanced rendering effects, and improved the realism and naturalness of hair models.
Smart Images

Figure CN115063330B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a hair rendering method, a hair rendering device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of image processing technology, image rendering technology has also become increasingly mature, and the image presentation effects obtained through image rendering are becoming increasingly close to real images. However, in related technologies, during the image rendering process, for multiple translucent models in a virtual scene (for example, the hair model of a hyper-realistic character), it is usually necessary to blend the colors of multiple translucent models. Therefore, depth values cannot be written during the rendering process. This results in the multiple translucent models having no positional relationship in the virtual scene, which easily leads to the problem of incorrect rendering order, and thus incorrect rendering results. Summary of the Invention
[0003] The embodiments of the present disclosure at least provide a hair rendering method, a hair rendering device, an electronic device, and a computer-readable storage medium.
[0004] The present disclosure provides a hair rendering method, including:
[0005] Obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair piece models, each translucent hair piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel;
[0006] For each of the translucent hair piece models, perform opaque rendering on the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model, wherein the first rendering result includes depth information of the translucent hair piece model relative to the virtual camera;
[0007] Performing semi-transparent rendering on the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model;
[0008] Obtaining a rendered image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result;
[0009] The rendered images corresponding to the multiple translucent hair piece models are fused to obtain a rendered image corresponding to the hair model.
[0010] In the embodiment of the present disclosure, when the hair model includes multiple stacked translucent hair piece models, each translucent hair piece model is firstly opaquely rendered, and then each translucent hair piece is semi-transparently rendered to obtain a rendered image corresponding to each translucent hair piece model. Then, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain a rendered image corresponding to the hair model. In this way, the depth information of each translucent hair piece model relative to the virtual camera can be obtained through opaque rendering, thereby reducing the occurrence of rendering order errors of different translucent hair piece models during the semi-transparent rendering process, improving the accuracy of the rendering order of multiple translucent objects, and thus improving the rendering effect of multiple translucent objects.
[0011] In a possible implementation, when the hair model is a hair model representing the roots of hair, the hair model further includes an opaque hair piece model, the opaque hair piece model is stacked with the multiple translucent hair piece models, and the opaque hair piece model is close to the scalp.
[0012] In the disclosed embodiment, the hair piece model near the scalp is an opaque hair piece model. This can avoid the problem of rendering the scalp due to the transparency information of the color map, thereby increasing the realism of the hair rendering.
[0013] In one possible implementation, the translucent hair blade model includes a front face close to the virtual camera and a back face far from the virtual camera, and performing opaque rendering on the translucent hair blade model using the color map to obtain a first rendering result of the translucent hair blade model includes:
[0014] Performing opaque rendering on the back side of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model;
[0015] The step of performing semi-transparent rendering on the semi-transparent hair piece model by using the color map to obtain a second rendering result of the semi-transparent hair piece model includes:
[0016] The front side of the translucent hair piece model is semi-transparently rendered using the color map to obtain a second rendering result of the translucent hair piece model.
[0017] In the disclosed embodiment, a color map is used to first perform opaque rendering on the back of a translucent hair piece model, and then a translucent rendering is performed on the front of the translucent hair piece model. In this way, the position of the translucent hair piece model can be determined without affecting the rendering effect, thereby reducing the occurrence of rendering order errors.
[0018] In a possible implementation, performing opaque rendering on the back surface of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model includes:
[0019] The back side of the translucent hair piece model is rendered with color using the color map to obtain the first rendering result.
[0020] In this disclosed embodiment, a color map is used to render the back of a semi-transparent hair piece model. This allows the first rendering result to also include color information, enhancing the rendering effect of the back of the model. Furthermore, since the first rendering only performs color rendering, it can reduce the waste of resources caused by excessive and unnecessary rendering.
[0021] In a possible implementation, using the color map to perform semi-transparent rendering on the front side of the semi-transparent hair piece model to obtain a second rendering result of the semi-transparent hair piece model includes:
[0022] Obtaining position information and light direction information of the translucent hair piece model;
[0023] The front side of the translucent hair piece model is rendered in color using the color map, and the front side of the translucent hair piece model is rendered in shadow based on the light direction information and the position information of the translucent hair piece model to obtain the second rendering result.
[0024] In the disclosed embodiment, by using a color map to perform color rendering and shadow rendering on the front side of the translucent hair piece model respectively, the second rendering result includes the color information and light and shadow information of the translucent hair piece model, so that the rendering effect of the hair can be made more realistic and natural.
[0025] In a possible implementation, fusing the rendered images corresponding to the multiple translucent hair piece models to obtain the rendered image corresponding to the hair model includes:
[0026] Based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0027] In the disclosed embodiment, multiple rendered images are fused based on the depth information of each translucent hair piece model relative to the virtual camera to obtain a rendered image corresponding to the hair model. In this way, errors in the ordering of multiple translucent hair piece models can be reduced, making the image generated after rendering closer to the real effect.
[0028] In a possible implementation, fusing the rendered images corresponding to the multiple translucent hair models based on the depth information of each translucent hair model relative to the virtual camera to obtain the rendered image corresponding to the hair model includes:
[0029] determining, based on depth information of each translucent hair piece model relative to the virtual camera, a fusion order of the rendered images corresponding to the multiple translucent hair piece models;
[0030] Based on the fusion order, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0031] In the disclosed embodiment, the fusion order of multiple rendered images is determined based on the depth information of each translucent hair piece model relative to the virtual camera, and then the multiple rendered images are fused according to the fusion order. In this way, the fusion order of multiple rendered images can be determined based on the positional relationship between the multiple translucent hair piece models, so that the image generated after rendering is closer to the real effect.
[0032] The present disclosure also provides a hair rendering device, comprising:
[0033] A model acquisition module is configured to acquire a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair piece models, each translucent hair piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel;
[0034] a first rendering module, configured to perform opaque rendering on each translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model, wherein the first rendering result includes depth information of the translucent hair piece model relative to the virtual camera;
[0035] a second rendering module, configured to perform semi-transparent rendering on the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model;
[0036] An image generation module, configured to obtain a rendering image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result;
[0037] The image fusion module is used to fuse the rendering images corresponding to the multiple translucent hair piece models to obtain the rendering image corresponding to the hair model.
[0038] In a possible implementation, when the hair model is a hair model representing the roots of hair, the hair model further includes an opaque hair piece model, the opaque hair piece model is stacked with the multiple translucent hair piece models, and the opaque hair piece model is close to the scalp.
[0039] In a possible implementation, the translucent hair piece model includes a front face close to the virtual camera and a back face away from the virtual camera, and the first rendering module is specifically configured to:
[0040] Performing opaque rendering on the back side of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model;
[0041] The second rendering module is specifically configured to:
[0042] The front side of the translucent hair piece model is semi-transparently rendered using the color map to obtain a second rendering result of the translucent hair piece model.
[0043] In a possible implementation, the first rendering module is specifically configured to:
[0044] The back side of the translucent hair piece model is rendered with color using the color map to obtain the first rendering result.
[0045] In a possible implementation, the second rendering module is specifically configured to:
[0046] Obtaining position information and light direction information of the translucent hair piece model;
[0047] The front side of the translucent hair piece model is rendered in color using the color map, and the front side of the translucent hair piece model is rendered in shadow based on the light direction information and the position information of the translucent hair piece model to obtain the second rendering result.
[0048] In a possible implementation, the image fusion module is specifically configured to:
[0049] Based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0050] In a possible implementation, the image fusion module is specifically configured to:
[0051] determining, based on depth information of each translucent hair piece model relative to the virtual camera, a fusion order of the rendered images corresponding to the multiple translucent hair piece models;
[0052] Based on the fusion order, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0053] An embodiment of the present disclosure further provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus. When the machine-readable instructions are executed by the processor, the hair rendering method in any one of the possible implementations described above is performed.
[0054] The embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the hair rendering method in any one of the possible implementation modes described above is executed.
[0055] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.
[0057] Figure 1 A schematic diagram showing a first rendering effect of multiple translucent objects provided by an embodiment of the present disclosure is shown;
[0058] Figure 2 A schematic diagram showing a second rendering effect of multiple translucent objects provided by an embodiment of the present disclosure;
[0059] Figure 3 A schematic diagram showing a third rendering effect of multiple translucent objects provided by an embodiment of the present disclosure;
[0060] Figure 4 A flowchart of a hair rendering method provided by an embodiment of the present disclosure is shown;
[0061] Figure 5 A schematic diagram of a hair model provided by an embodiment of the present disclosure is shown;
[0062] Figure 6 A side view of a plurality of hairpiece models located at the same position provided by an embodiment of the present disclosure is shown;
[0063] Figure 7 A schematic diagram showing the result of performing opaque rendering on a translucent hair piece model provided by an embodiment of the present disclosure is shown;
[0064] Figure 8 A schematic diagram showing the result of semi-transparent rendering of a semi-transparent hair piece model provided by an embodiment of the present disclosure is shown;
[0065] Figure 9 A flowchart of another hair rendering method provided by an embodiment of the present disclosure is shown;
[0066] Figure 10 A flow chart of a method for semi-transparently rendering the front side of a semi-transparent hair piece model provided by an embodiment of the present disclosure is shown;
[0067] Figure 11 A structural schematic diagram of a hair rendering device provided by an embodiment of the present disclosure is shown;
[0068] Figure 12 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the disclosure for which protection is sought, but merely represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present disclosure.
[0070] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0071] The term "and / or" herein simply describes an association relationship, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, and the existence of B alone. In addition, the term "at least one" herein refers to any combination of at least two of any one or more of a plurality of items. For example, "at least one of A, B, and C" can represent any one or more elements selected from the set consisting of A, B, and C.
[0072] Because the hair model of a hyper-realistic character (hereafter referred to as a digital human) consists of multiple translucent models, the colors of these models need to be blended during rendering, and depth values cannot be written. However, without depth values, the positional relationships between the multiple translucent models cannot be determined, which can easily lead to incorrect rendering order and erroneous rendering results.
[0073] The following is a detailed introduction to the situation in related technologies where rendering errors occur for multiple translucent objects due to an error in the rendering order.
[0074] See Figure 1 The diagram includes a translucent model 1, a translucent model 2, and a translucent model 3. Translucent model 2 and translucent model 3 are placed inside translucent model 1. That is, under normal circumstances, no matter from which angle the model is viewed, the translucent model 1 should be shown in front of the translucent model 2 and the translucent model 3.
[0075] However, in the related art, when rendering multiple translucent models, the positional relationship between translucent model 1, translucent model 2, and translucent model 3 is not determined. Therefore, if the shooting angle of the virtual camera is adjusted, the translucent model 2 may be located in front of the translucent model 1 (e.g., Figure 2 Alternatively, the translucent model 3 is located in front of the translucent model 1 (as shown in FIG. Figure 3 However, the spatial positions of translucent model 2 and translucent model 3 have not changed. Instead, the rendering order is wrong, which leads to the error in the final rendered image.
[0076] To address the above-mentioned problem, an embodiment of the present disclosure provides a hair rendering method, comprising: obtaining a hair model and a color map corresponding to the hair model; the hair model comprises a plurality of stacked translucent hair plate models, each translucent hair plate model is modeled and generated based on a hair plate formed by a plurality of hairs, the color map comprises a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel; for each translucent hair plate model, performing opaque rendering on the translucent hair plate model using the color map to obtain a first rendering result of the translucent hair plate model, the first rendering result including depth information of the translucent hair plate model relative to a virtual camera; performing translucent rendering on the translucent hair plate model using the color map to obtain a second rendering result of the translucent hair plate model; obtaining a rendered image corresponding to the translucent hair plate model based on the first rendering result and the second rendering result; and fusing the rendered images corresponding to the plurality of translucent hair plate models to obtain a rendered image corresponding to the hair model.
[0077] In the embodiment of the present disclosure, when the hair model includes multiple stacked translucent hair piece models, each translucent hair piece model is firstly opaquely rendered, and then each translucent hair piece is semi-transparently rendered to obtain a rendered image corresponding to each translucent hair piece model. Then, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain a rendered image corresponding to the hair model. In this way, the depth information of each translucent hair piece model relative to the virtual camera can be obtained through opaque rendering, thereby reducing the occurrence of rendering order errors of different translucent hair piece models during the semi-transparent rendering process, improving the accuracy of the rendering order of multiple translucent objects, and thus improving the rendering effect of multiple translucent objects.
[0078] The hair rendering method provided in the embodiments of the present disclosure is generally executed by an electronic device with certain computing capabilities, such as a terminal device, a server, or other processing device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a handheld device, a computing device, or an in-vehicle device. The server may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms.
[0079] In some possible implementations, the hair rendering method may be implemented by a processor calling computer-readable instructions stored in a memory.
[0080] Furthermore, this disclosure aims to provide a rendering method, and therefore does not limit the rendering software used in the specific implementation process. The method described in this disclosure can also be applied to different scenarios, such as offline rendering of digital human hair and real-time rendering of digital human hair on mobile devices.
[0081] See also Figure 4 FIG. 1 is a flowchart of a hair rendering method provided by an embodiment of the present disclosure, wherein the method includes steps S101 to S105, wherein:
[0082] S101, obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair-piece models, each translucent hair-piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel.
[0083] Optionally, the hair model can run on a computer's CPU (Central Processing Unit), GPU (Graphics Processing Unit), and memory, and include meshed model information and texture information. Accordingly, as an example, the translucent hair piece model and the opaque hair piece model include, but are not limited to, meshed model data and texture data, or a combination thereof. Meshes include, but are not limited to, triangular meshes, quadrilateral meshes, other polygonal meshes, or a combination thereof. In the disclosed embodiment, the mesh is a triangular mesh.
[0084] Exemplarily, the hair model includes multiple stacked, translucent hair piece models, each modeled based on a hair piece formed by multiple hairs. Specifically, the multiple hairs can be grouped together, each group forming a hair piece. Modeling is then performed for each hair piece, resulting in a corresponding translucent hair piece model. This eliminates the need to construct a separate model for each hair piece, reducing the number of models required during rendering. Accordingly, each translucent hair piece model includes multiple vertices, and multiple vertices at different positions are interconnected to form a patch, thereby forming the surface of the hair model.
[0085] For example, see Figure 5 As shown, a schematic diagram of a hair model provided by an embodiment of the present disclosure includes multiple hair piece models, and there are multiple hair piece models at position A, position B, and position C respectively. The multiple hair piece models at the same position are stacked, so as to represent the hairstyle of the entire hair, making the rendered hair more realistic.
[0086] The color map corresponding to the hair model is generated based on the translucent hair lamella model. The color map includes multiple color channels and a transparency channel. The transparency channel value of each pixel in the color map represents the transparency information of that pixel. The transparency value corresponding to the translucent hair lamella model can range from [0, 255] or [0, 1]. The transparency value of the translucent hair lamella model determines the degree of transparency of the translucent hair lamella model. The larger the transparency value, the more opaque the translucent hair lamella model appears.
[0087] Specifically, the multiple color channels in the color map are R, G, and B channels. The R channel represents the red channel value of the pixel, the G channel represents the green channel value of the pixel, and the B channel represents the blue channel value of the pixel. The color values corresponding to the color channels can range from [0, 255] or [0, 1]. The color values corresponding to the color channels determine the color rendering effect of the translucent hair piece model. The larger the color value corresponding to the color channel, the darker the color rendering effect of the translucent hair piece model.
[0088] In a possible embodiment, when the hair model is a hair model representing the hair root, the hair model further includes an opaque hair piece model, the opaque hair piece model is stacked with the multiple translucent hair piece models, and the opaque hair piece model is close to the scalp. For example, see again Figure 5 As shown, the innermost hair models at positions A and B are opaque hair models. This avoids the problem of scalp rendering due to the transparency information of the color map, and increases the realism of hair rendering.
[0089] For example, see Figure 6 FIG2 is a side view of a plurality of hairpiece models located in the same position according to an embodiment of the present disclosure, including hairpiece model 1, hairpiece model 2, hairpiece model 3, and hairpiece model 4 located in the same position. Hairpiece model 4 is an opaque hairpiece model located close to the scalp, while hairpiece model 1, hairpiece model 2, and hairpiece model 3 are translucent hairpiece models.
[0090] It should be noted that the hair model and the color map corresponding to the hair model can be pre-made and stored in a preset storage space. When the rendering task of the hair model needs to be performed, the hair model and the corresponding color map are read from the preset storage space.
[0091] S102: For each of the translucent hair sheet models, perform opaque rendering on the translucent hair sheet model using the color map to obtain a first rendering result of the translucent hair sheet model, where the first rendering result includes depth information of the translucent hair sheet model relative to the virtual camera.
[0092] Specifically, a semi-transparent hair piece model can be rendered using a shader. The shader is used to render the model during the 3D image rendering process to produce a rendered image. The shader includes a vertex shader and a pixel shader. The vertex shader calculates the geometric relationships between the model's vertices, while the pixel shader calculates the model's color.
[0093] For example, see Figure 7 The figure shows a schematic diagram of the result of opaque rendering of a translucent hair lamella model according to an embodiment of the present disclosure. The translucent hair lamella model is rendered based on its z-axis coordinates in the visual coordinate system to obtain depth information of the translucent hair lamella model relative to the virtual camera. The depth information represents the position of the translucent hair lamella model. The smaller the depth value corresponding to the translucent hair lamella model, the closer the translucent hair lamella model is to the virtual camera.
[0094] A virtual camera is a method of presenting a three-dimensional virtual world by controlling one or more lenses. The lens systems used in video games are designed to display the action at the optimal angle; generally speaking, these lenses are used in three-dimensional virtual worlds that require a third-person perspective. After finding a suitable lens, the virtual camera's lens position and rotation angle are obtained, and this data is used by the graphics engine renderer to generate the view.
[0095] S103: Performing translucent rendering on the translucent hair piece model using the color map to obtain a second rendering result of the translucent hair piece model.
[0096] Translucent rendering refers to applying transparency to the model based on the intensity of the transparency information expressed in the color map. The intensity of the map determines the degree of transparency in the final rendering. In this embodiment, semi-transparent rendering is used to render hair tips and broken hair, making the rendered hair model more realistically resemble human hair.
[0097] Optionally, in the process of semi-transparently rendering the semi-transparent hair piece model using a color map, there is a correspondence between the vertices of the semi-transparent hair piece model and the pixels of the color map. Based on this correspondence, in addition to determining the corresponding color, texture, and other information for each vertex of the semi-transparent hair piece model, the transparency value corresponding to each vertex in the first model is determined using the value of each pixel in the color map in the transparency channel. The transparency value is used to indicate whether the position corresponding to the pixel is transparent. Therefore, the hair corresponding to the semi-transparent hair piece model in the inner layer can be rendered through the semi-transparent hair piece model in the outer layer by using the transparency value corresponding to each pixel in the color map, thereby achieving the following effect: Figure 8 The rendering effect shown.
[0098] S104: Obtain a rendering image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result.
[0099] For example, after obtaining the first rendering result and the second rendering result, a rendered image corresponding to the translucent hair piece model can be obtained based on the first rendering result and the second rendering result. The rendered image can be obtained by taking a picture from any angle with a virtual camera, and the rendered image includes multiple hairs drawn in the color map.
[0100] It should be noted that since the first rendering uses an opaque rendering method and the second rendering uses a single-layer translucent rendering method, the rendered image obtained by the first rendering result and the second rendering result will not have the problem of incorrect sorting between multiple translucent models, further improving the accuracy of the rendering results.
[0101] S105 , fusing the rendered images corresponding to the multiple translucent hair piece models to obtain a rendered image corresponding to the hair model.
[0102] After obtaining the rendered image corresponding to each translucent hair piece model in the hair model, it is necessary to fuse the rendered images corresponding to the multiple translucent hair piece models to obtain the rendered image corresponding to the hair model.
[0103] Optionally, based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the multiple translucent hair piece models may be fused to obtain the rendered image corresponding to the hair model.
[0104] In this embodiment, since the depth information of the translucent hair piece model relative to the virtual camera is used to determine the position of the translucent hair piece model relative to the virtual camera, by fusing multiple rendered images through the depth information, the error in the sorting between multiple translucent hair piece models can be reduced, making the image generated after rendering closer to the real effect.
[0105] Specifically, based on the depth information of each translucent hair piece model relative to the virtual camera, the fusion order of the rendered images corresponding to the multiple translucent hair piece models is determined; based on the fusion order, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0106] Among them, the rendered image corresponding to each translucent hair piece model is composed of many pixel points. When multiple rendered images are fused, the translucent hair piece model with a smaller depth value is closer to the virtual camera, that is, the translucent hair piece model with a smaller depth value is located at the front end of the hair piece model, and the translucent hair piece model with a larger depth value is farther away from the virtual camera, that is, the translucent hair piece model with a larger depth value is located at the back end of the hair piece model.
[0107] It should be noted that the order in which the rendered images corresponding to the multiple translucent hair models are fused can be sorted from smallest to largest depth value, or from largest to smallest depth value, without specific limitation. For example, if the fusion order is obtained by sorting from smallest to largest depth value, the fusion can be started from the translucent hair model with the smallest depth value, that is, starting from the outermost layer of the hair model; if the fusion order is obtained by sorting from largest to smallest depth value, the fusion can be started from the translucent hair model with the largest depth value, that is, starting from the innermost layer of the hair model.
[0108] In the embodiment of the present disclosure, when the hair model includes multiple stacked translucent hair piece models, each translucent hair piece model is firstly opaquely rendered, and then each translucent hair piece is semi-transparently rendered to obtain a rendered image corresponding to each translucent hair piece model. Then, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain a rendered image corresponding to the hair model. In this way, the depth information of each translucent hair piece model relative to the virtual camera can be obtained through opaque rendering, thereby reducing the occurrence of rendering order errors of different translucent hair piece models during the semi-transparent rendering process, improving the accuracy of the rendering order of multiple translucent objects, and thus improving the rendering effect of multiple translucent objects.
[0109] In a possible implementation, the translucent hair piece model includes a front side close to the virtual camera and a back side far away from the virtual camera. Figure 9 FIG. 2 is a flowchart of another hair rendering method provided by an embodiment of the present disclosure, including S201 to S205:
[0110] S201, obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair-piece models, each translucent hair-piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel.
[0111] This step is the same as Figure 4 The process is similar to step S101 in , and will not be described again here.
[0112] S202 : For each of the translucent hair piece models, perform opaque rendering on the back surface of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model.
[0113] In this embodiment, the back side of the translucent hair piece model is rendered using an opaque rendering method. This can obtain the depth information of the translucent hair piece model relative to the virtual camera without affecting the final rendering effect, thereby reducing the possibility of errors in the arrangement order between multiple models.
[0114] Specifically, the color map is used to render the back of the translucent hair piece model, and the following is obtained: Figure 7 This allows the first rendering result to also include color information, enhancing the rendering effect of the back of the model. In addition, since the first rendering only performs color rendering, it can reduce the waste of resources caused by excessive and unnecessary rendering.
[0115] S203 , performing semi-transparent rendering on the front side of the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model.
[0116] In this embodiment, the back of the translucent hair piece model is first rendered opaquely using a color map, and then the front of the translucent hair piece model is rendered using a translucent rendering method. In this way, the position of the translucent hair piece model can be determined without affecting the rendering effect, thereby reducing the occurrence of rendering order errors.
[0117] Specifically, see Figure 10 FIG. 2 is a flow chart of a method for semi-transparently rendering the front side of a semi-transparent hair piece model provided by an embodiment of the present disclosure, including S2031 to S2032:
[0118] S2031: Acquire position information and light direction information of the translucent hair piece model.
[0119] The position information of the translucent hair piece model refers to the position information of the translucent hair piece model relative to the simulated light source, and the light direction information refers to the direction in which the simulated light source illuminates the translucent hair piece model.
[0120] S2032: Perform color rendering on the front side of the translucent hair piece model using the color map, and perform shadow rendering on the front side of the translucent hair piece model based on the light direction information and the position information of the translucent hair piece model to obtain a second rendering result.
[0121] Among them, shadow rendering is to simulate the brightness and darkness produced by the light source illuminating the model, and use grayscale or color output to obtain a tone that changes approximately continuously with the light intensity, so as to achieve sensitive contrast at different positions of the model, give the model a certain three-dimensional sense, and intuitively express the changes at different positions of the model.
[0122] In this embodiment, by performing color rendering on the front side of the translucent hair piece model, the color information of the translucent hair piece model can be obtained, and by performing shadow rendering on the front side of the translucent hair piece model, the light and shadow information of the translucent hair piece model can be obtained. Based on the color information and light and shadow information of the translucent hair piece model, the rendering effect of the hair can be made more realistic and natural.
[0123] S204: Obtain a rendering image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result.
[0124] This step is the same as Figure 4 The process is similar to step S104 in , and will not be described again here.
[0125] S205 , fusing the rendered images corresponding to the multiple translucent hair piece models to obtain a rendered image corresponding to the hair model.
[0126] This step is the same as Figure 4 The process is similar to step S105 in , and will not be described again here.
[0127] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0128] Based on the same inventive concept, the embodiments of the present disclosure also provide a hair rendering device corresponding to the hair rendering method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to that of the above-mentioned hair rendering method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0129] Reference Figure 11 FIG. 1 is a schematic diagram of a hair rendering device according to an embodiment of the present disclosure. The device 1100 includes:
[0130] Model acquisition module 1101 is configured to acquire a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair piece models, each translucent hair piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel;
[0131] A first rendering module 1102 is configured to perform opaque rendering on each translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model, wherein the first rendering result includes depth information of the translucent hair piece model relative to the virtual camera;
[0132] A second rendering module 1103 is configured to perform semi-transparent rendering on the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model;
[0133] An image generation module 1104 is configured to obtain a rendering image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result;
[0134] The image fusion module 1105 is configured to fuse the rendered images corresponding to the multiple translucent hair piece models to obtain a rendered image corresponding to the hair model.
[0135] In a possible implementation, when the hair model is a hair model representing the roots of hair, the hair model further includes an opaque hair piece model, the opaque hair piece model is stacked with the multiple translucent hair piece models, and the opaque hair piece model is close to the scalp.
[0136] In a possible implementation, the translucent hair piece model includes a front face close to the virtual camera and a back face away from the virtual camera, and the first rendering module 1102 is specifically configured to:
[0137] Performing opaque rendering on the back side of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model;
[0138] The second rendering module 1103 is specifically configured to:
[0139] The front side of the translucent hair piece model is semi-transparently rendered using the color map to obtain a second rendering result of the translucent hair piece model.
[0140] In a possible implementation, the first rendering module 1102 is specifically configured to:
[0141] The back side of the translucent hair piece model is rendered with color using the color map to obtain the first rendering result.
[0142] In a possible implementation, the second rendering module 1103 is specifically configured to:
[0143] Obtaining position information and light direction information of the translucent hair piece model;
[0144] The front side of the translucent hair piece model is rendered in color using the color map, and the front side of the translucent hair piece model is rendered in shadow based on the light direction information and the position information of the translucent hair piece model to obtain the second rendering result.
[0145] In a possible implementation, the image fusion module 1105 is specifically configured to:
[0146] Based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0147] In a possible implementation, the image fusion module 1105 is specifically configured to:
[0148] determining, based on depth information of each translucent hair piece model relative to the virtual camera, a fusion order of the rendered images corresponding to the multiple translucent hair piece models;
[0149] Based on the fusion order, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
[0150] Based on the same technical concept, the embodiment of the present application also provides an electronic device. Figure 121 is a schematic diagram of the structure of an electronic device 1200 provided in an embodiment of the present application, including a processor 1201, a memory 1202, and a bus 1203. The memory 1202 is used to store execution instructions and includes a memory 12021 and an external memory 12022. The memory 12021 is also referred to as internal memory and is used to temporarily store calculation data in the processor 1201 and data exchanged with an external memory 12022 such as a hard disk. The processor 1201 exchanges data with the external memory 12022 through the memory 2021.
[0151] In the embodiment of the present application, the memory 1202 is specifically used to store application code for executing the solution of the present application, and the execution is controlled by the processor 1201. That is, when the electronic device 1200 is running, the processor 1201 communicates with the memory 1202 via the bus 1203, so that the processor 1201 executes the application code stored in the memory 1202, thereby performing the method disclosed in any of the aforementioned embodiments.
[0152] Among them, the memory 1202 can be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0153] The processor 1201 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor.
[0154] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 1200. In other embodiments of the present application, the electronic device 1200 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0155] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program executes the steps of the hair rendering method described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0156] A computer program product provided in an embodiment of the present disclosure includes a computer-readable storage medium storing program code. The program code includes instructions that can be used to execute the steps of a hair rendering method in the above-mentioned method embodiment. For details, please refer to the above-mentioned method embodiment and will not be repeated here.
[0157] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0158] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0160] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0161] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0162] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.
Claims
1. A hair rendering method, characterized in that: include: Obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair piece models, each translucent hair piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel; For each of the translucent hair piece models, perform opaque rendering on the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model, wherein the first rendering result includes depth information of the translucent hair piece model relative to the virtual camera; Performing semi-transparent rendering on the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model; Obtaining a rendered image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result; determining, based on depth information of each translucent hair piece model relative to the virtual camera, a fusion order of the rendered images corresponding to the multiple translucent hair piece models; Based on the fusion order, the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model.
2. The method according to claim 1, characterized in that In the case that the hair model is a hair model representing the root of the hair, the hair model further includes an opaque hair piece model, the opaque hair piece model is stacked with the multiple translucent hair piece models, and the opaque hair piece model is close to the scalp.
3. The method according to claim 1 or 2, characterized in that The translucent hair piece model includes a front side close to the virtual camera and a back side far from the virtual camera, and the opaque rendering of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model includes: Performing opaque rendering on the back side of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model; The step of performing semi-transparent rendering on the semi-transparent hair piece model by using the color map to obtain a second rendering result of the semi-transparent hair piece model includes: The front side of the translucent hair piece model is semi-transparently rendered using the color map to obtain a second rendering result of the translucent hair piece model.
4. The method according to claim 3, characterized in that The step of performing opaque rendering on the back surface of the translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model includes: The back side of the translucent hair piece model is rendered with color using the color map to obtain the first rendering result.
5. The method according to claim 3, characterized in that The method of performing semi-transparent rendering on the front side of the semi-transparent hair piece model by using the color map to obtain a second rendering result of the semi-transparent hair piece model includes: Obtaining position information and light direction information of the translucent hair piece model; The front side of the translucent hair piece model is rendered in color using the color map, and the front side of the translucent hair piece model is rendered in shadow based on the light direction information and the position information of the translucent hair piece model to obtain the second rendering result.
6. A hair rendering device, characterized in that: include: A model acquisition module is configured to acquire a hair model and a color map corresponding to the hair model; the hair model includes a plurality of stacked translucent hair piece models, each translucent hair piece model being modeled based on a hair piece formed by a plurality of hairs; the color map includes a plurality of color channels and a transparency channel, and the value of each pixel in the color map in the transparency channel is used to represent the transparency information of the pixel; a first rendering module, configured to perform opaque rendering on each translucent hair piece model using the color map to obtain a first rendering result of the translucent hair piece model, wherein the first rendering result includes depth information of the translucent hair piece model relative to the virtual camera; a second rendering module, configured to perform semi-transparent rendering on the semi-transparent hair piece model using the color map to obtain a second rendering result of the semi-transparent hair piece model; An image generation module, configured to obtain a rendering image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result; An image fusion module is configured to determine a fusion order of the rendered images corresponding to the multiple translucent hair piece models based on depth information of each translucent hair piece model relative to the virtual camera, and fuse the rendered images corresponding to the multiple translucent hair piece models based on the fusion order to obtain a rendered image corresponding to the hair model.
7. An electronic device, characterized in that: include: A processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus. When the machine-readable instructions are executed by the processor, the hair rendering method according to any one of claims 1 to 5 is performed.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the hair rendering method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Model rendering method and device, electronic equipment and computer readable medium
CN111508053A
Scene rendering method and device, electronic equipment and readable storage medium
CN113205583A