+

CN115063330A - Hair rendering method, device, electronic device and storage medium - Google Patents

Hair rendering method, device, electronic device and storage medium Download PDF

Info

Publication number
CN115063330A
CN115063330A CN202210663477.2A CN202210663477A CN115063330A CN 115063330 A CN115063330 A CN 115063330A CN 202210663477 A CN202210663477 A CN 202210663477A CN 115063330 A CN115063330 A CN 115063330A
Authority
CN
China
Prior art keywords
translucent
model
hair
rendering
hair piece
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210663477.2A
Other languages
Chinese (zh)
Inventor
冷晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Datianmian White Sugar Technology Co ltd
Original Assignee
Beijing Datianmian White Sugar Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Datianmian White Sugar Technology Co ltd filed Critical Beijing Datianmian White Sugar Technology Co ltd
Priority to CN202210663477.2A priority Critical patent/CN115063330A/en
Publication of CN115063330A publication Critical patent/CN115063330A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Image Generation (AREA)

Abstract

The present disclosure provides a hair rendering method, apparatus, electronic device and storage medium, wherein the method comprises: acquiring a hair model and a color map corresponding to the hair model; the hair model comprises a plurality of semitransparent hair piece models which are arranged in a stacked mode; performing opaque rendering on each semitransparent hairpin model by using a color map to obtain a first rendering result of the semitransparent hairpin model, wherein the first rendering result comprises depth information of the semitransparent hairpin model relative to the virtual camera; performing semi-transparent rendering on the semi-transparent hairpiece model by using the color mapping to obtain a second rendering result of the semi-transparent hairpiece model; obtaining a rendering image corresponding to the semitransparent hairpiece model based on the first rendering result and the second rendering result; and fusing rendering images corresponding to the plurality of semitransparent hairpiece models respectively to obtain rendering images corresponding to the hair models. According to the embodiment of the disclosure, the accuracy of the rendering sequence of the plurality of semitransparent objects can be improved.

Description

头发渲染方法、装置、电子设备及存储介质Hair rendering method, device, electronic device and storage medium

技术领域technical field

本公开涉及图像处理技术领域,具体而言,涉及一种头发渲染方法、头发渲染装置、电子设备及计算机可读存储介质。The present disclosure relates to the technical field of image processing, and in particular, to a hair rendering method, a hair rendering apparatus, an electronic device, and a computer-readable storage medium.

背景技术Background technique

随着图像处理技术的发展,图像渲染技术也日渐成熟,通过图像渲染得到的画面呈现效果越来越贴近真实画面。然而,相关技术中,在图像渲染的过程中,对于虚拟场景中的多个半透明模型(比如:超写实风格角色人物的头发模型),通常需要对多个半透明模型的颜色进行混合,因此,在渲染的过程中不可以写入深度值,这就导致了多个半透明模型在虚拟场景中不存在位置关系,从而容易出现渲染顺序发生错误的问题,进而造成错误的渲染结果。With the development of image processing technology, the image rendering technology is becoming more and more mature, and the rendering effect of the image obtained through image rendering is getting closer and closer to the real image. However, in the related art, in the process of image rendering, for multiple translucent models in the virtual scene (for example: the hair model of a hyper-realistic character), it is usually necessary to mix the colors of the multiple translucent models. Therefore, , the depth value cannot be written during the rendering process, which results in that there is no positional relationship between multiple translucent models in the virtual scene, which is prone to the problem of wrong rendering order, resulting in wrong rendering results.

发明内容SUMMARY OF THE INVENTION

本公开实施例至少提供一种头发渲染方法、头发渲染装置、电子设备及计算机可读存储介质。Embodiments of the present disclosure provide at least a hair rendering method, a hair rendering apparatus, an electronic device, and a computer-readable storage medium.

本公开实施例提供了一种头发渲染方法,包括:Embodiments of the present disclosure provide a hair rendering method, including:

获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;Obtain a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is modeled and generated according to the hair pieces 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 translucent hair piece model, use the color map to perform opaque rendering on the translucent hair piece model, to obtain a first rendering result of the translucent hair piece model, where the first rendering result includes all The depth information of the translucent hair piece model relative to the virtual camera;

利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果;Perform translucent rendering on the translucent hair piece model by using the color map to obtain a second rendering result of the translucent 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;

将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。The rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair model.

本公开实施例中,在头发模型包括多个层叠设置的半透明发片模型的情况下,先对每个半透明发片模型进行不透明渲染,然后再对每个半透明发片进行半透明渲染得到每个半透明发片模型对应的渲染图像,接着再将多个半透明发片模型分别对应的渲染图像进行融合,得到头发模型对应的渲染图像,如此,可以通过不透明渲染得到每个半透明发片模型相对于虚拟相机的深度信息,进而可以减少不同的半透明发片模型在半透明渲染过程中发生渲染顺序出错的情况,提高了多个半透明物体渲染顺序的准确率,从而提升了多个半透明物体的渲染效果。In the embodiment of the present disclosure, when the hair model includes a plurality of translucent hair piece models arranged in layers, opaque rendering is first performed on each translucent hair piece model, and then translucent rendering is performed on each translucent hair piece The rendered image corresponding to each translucent hair piece model is obtained, and then the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model. In this way, each translucent can be obtained by opaque rendering. The depth information of the hair piece model relative to the virtual camera can reduce the rendering sequence error of different translucent hair piece models during the translucent rendering process, and improve the accuracy of the rendering order of multiple translucent objects, thereby improving the Rendering of multiple translucent objects.

在一种可能的实施方式中,在所述头发模型为表征头发根部的头发模型的情况下,所述头发模型还包括不透明发片模型,所述不透明发片模型与所述多个半透明发片模型层叠设置,且所述不透明发片模型靠近头皮位置。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 and the plurality of translucent hair pieces The patch models are arranged in layers, and the opaque hair patch models are positioned close to the scalp.

本公开实施例中,靠近头皮位置处的发片模型为不透明发片模型,如此,可以避免由于颜色贴图的透明度信息造成将头皮渲染出来的问题,增加头发渲染的真实性。In the embodiment of the present disclosure, the hair piece model near the scalp is an opaque hair piece model. In this way, the problem of rendering the scalp due to the transparency information of the color map can be avoided, and the authenticity of hair rendering can be increased.

在一种可能的实施方式中,所述半透明发片模型包括靠近所述虚拟相机的正面以及远离所述虚拟相机的背面,所述利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,包括: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 translucent hair piece model is made opaque by using the color map Rendering to obtain the first rendering result of the translucent hair piece model, including:

利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果;Opaque rendering is performed on the back of the translucent hair piece model by using the color map to obtain a first rendering result of the translucent hair piece model;

所述利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果,包括:The translucent rendering of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model, including:

利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果。Translucent rendering is performed on the front surface of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model.

本公开实施例中,利用颜色贴图先对半透明发片模型的背面进行不透明渲染,然后再对半透明发片模型的正面进行半透明渲染,如此,可以在不影响渲染效果的同时,确定半透明发片模型所处的位置,减少渲染顺序发生错误的情况。In the embodiment of the present disclosure, the backside of the translucent hair piece model is first rendered opaque by using the color map, and then the front side of the translucent hair piece model is rendered translucently. The position of the transparent hair piece model to reduce the occurrence of wrong rendering order.

在一种可能的实施方式中,所述利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果,包括:In a possible implementation manner, performing opaque rendering on the back of the translucent hair piece model by using the color map to obtain a first rendering result of the translucent hair piece model, including:

利用所述颜色贴图对所述半透明发片模型的背面进行颜色渲染,得到所述第一渲染结果。Color rendering is performed on the back surface of the translucent hair piece model by using the color map to obtain the first rendering result.

本公开实施例中,利用颜色贴图对半透明发片模型的背面进行颜色渲染,如此,可以使得第一渲染结果中还包括颜色信息,增强了模型背面渲染效果。此外,由于第一次渲染只进行颜色渲染,因此,可以减少因进行过多不必要的渲染而造成资源浪费的情况发生。In this embodiment of the present disclosure, the color map is used to render the back of the translucent hair piece model in color, so that the first rendering result can also include color information, which enhances the rendering effect of the back of the model. In addition, because the first rendering only performs color rendering, it can reduce the occurrence of resource waste caused by excessive unnecessary rendering.

在一种可能的实施方式中,所述利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果,包括:In a possible implementation manner, performing translucent rendering on the front surface of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model, including:

获取所述半透明发片模型的位置信息以及光线方向信息;Obtain the position information and light direction information of the translucent hair piece model;

利用所述颜色贴图对所述半透明发片模型的正面进行颜色渲染,以及基于所述光线方向信息、和所述半透明发片模型的位置信息,对所述半透明发片模型的正面进行阴影渲染,得到所述第二渲染结果。Color rendering is performed on the front face of the translucent hair piece model by using the color map, and based on the light direction information and the position information of the translucent hair piece model, the front face of the translucent hair piece model is rendered in color. Shadow rendering to obtain the second rendering result.

本公开实施例中,通过利用颜色贴图对半透明发片模型的正面分别进行颜色渲染以及阴影渲染,使得第二渲染结果中包括半透明发片模型的颜色信息以及光影信息,如此,可以使得头发的渲染效果更加真实、自然。In the embodiment of the present disclosure, by using a color map to perform color rendering and shadow rendering on the front of the translucent hair piece model, the second rendering result includes the color information and light and shadow information of the translucent hair piece model. The rendering effect is more realistic and natural.

在一种可能的实施方式中,所述将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像,包括:In a possible implementation manner, the rendering images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair model, including:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。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 respectively are fused to obtain a rendered image corresponding to the hair model.

本公开实施例中,根据每个半透明发片模型相对于虚拟相机的深度信息,将多张渲染图像进行融合,得到头发模型对应的渲染图像,如此,可以降低多个半透明发片模型之间的排序发生错误的情况,使得渲染后生成的图像更加贴近于真实效果。In the embodiment of the present disclosure, according to the depth information of each translucent hair piece model relative to the virtual camera, a plurality of rendered images are fused to obtain a rendered image corresponding to the hair model. In this way, the difference between the multiple translucent hair piece models can be reduced. If the ordering between them is wrong, the image generated after rendering is closer to the real effect.

在一种可能的实施方式中,所述基于所述每个半透明发片模型相对于虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像,包括:In a possible implementation manner, based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images respectively corresponding to the multiple translucent hair piece models are fused to obtain the Rendered images corresponding to the hair model, including:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,确定所述多个半透明发片模型分别对应的渲染图像的融合顺序;Based on the depth information of each translucent hair piece model relative to the virtual camera, determining the fusion order of the rendered images corresponding to the plurality of translucent hair piece models respectively;

基于所述融合顺序,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Based on the fusion sequence, the respective rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair models.

本公开实施例中,根据每个半透明发片模型相对于虚拟相机的深度信息,确定多张渲染图像的融合顺序,然后根据融合顺序,将多张渲染图像进行融合,如此,可以根据多个半透明发片模型之间的位置关系,确定多张渲染图像的融合顺序,使得渲染后生成的图像更加贴近于真实效果。In the embodiment of the present disclosure, the fusion sequence of the multiple rendered images is determined according to the depth information of each semi-transparent slice-making model relative to the virtual camera, and then the multiple rendered images are fused according to the fusion sequence. The positional relationship between the translucent hair piece models determines the fusion order of multiple rendered images, so that the rendered images are closer to the real effect.

本公开实施例还提供一种头发渲染装置,包括:Embodiments of the present disclosure also provide a hair rendering device, including:

模型获取模块,用于获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;a model obtaining module, used for obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is based on a hair piece formed by a plurality of hairs Perform modeling and generation, 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;

第一渲染模块,用于针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,所述第一渲染结果包括所述半透明发片模型相对于虚拟相机的深度信息;The first rendering module is configured to perform opaque rendering on the translucent hair chip model by using the color map for each of the translucent hair chip models, and obtain a first rendering result of the translucent hair chip model. 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 translucent rendering on the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model;

图像生成模块,用于基于所述第一渲染结果以及所述第二渲染结果,得到所述半透明发片模型对应的渲染图像;an image generation module, configured to obtain a rendered image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result;

图像融合模块,用于将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。The image fusion module is used for fusing the rendered images corresponding to the multiple translucent hair piece models respectively to obtain the rendered images corresponding to the hair model.

在一种可能的实施方式中,在所述头发模型为表征头发根部的头发模型的情况下,所述头发模型还包括不透明发片模型,所述不透明发片模型与所述多个半透明发片模型层叠设置,且所述不透明发片模型靠近头皮位置。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 and the plurality of translucent hair pieces The patch models are arranged in layers, and the opaque hair patch models are positioned close to the scalp.

在一种可能的实施方式中,所述半透明发片模型包括靠近所述虚拟相机的正面以及远离所述虚拟相机的背面,所述第一渲染模块具体用于:In a possible implementation manner, 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 used for:

利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果;Opaque rendering is performed on the back of the translucent hair piece model by using the color map to obtain a first rendering result of the translucent hair piece model;

所述第二渲染模块具体用于:The second rendering module is specifically used for:

利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果。Translucent rendering is performed on the front surface of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model.

在一种可能的实施方式中,所述第一渲染模块具体用于:In a possible implementation manner, the first rendering module is specifically used for:

利用所述颜色贴图对所述半透明发片模型的背面进行颜色渲染,得到所述第一渲染结果。Color rendering is performed on the back surface of the translucent hair piece model by using the color map to obtain the first rendering result.

在一种可能的实施方式中,所述第二渲染模块具体用于:In a possible implementation manner, the second rendering module is specifically used for:

获取所述半透明发片模型的位置信息以及光线方向信息;Obtain the position information and light direction information of the translucent hair piece model;

利用所述颜色贴图对所述半透明发片模型的正面进行颜色渲染,以及基于所述光线方向信息、和所述半透明发片模型的位置信息,对所述半透明发片模型的正面进行阴影渲染,得到所述第二渲染结果。Color rendering is performed on the front face of the translucent hair piece model by using the color map, and based on the light direction information and the position information of the translucent hair piece model, the front face of the translucent hair piece model is rendered in color. Shadow rendering to obtain the second rendering result.

在一种可能的实施方式中,所述图像融合模块具体用于:In a possible implementation manner, the image fusion module is specifically used for:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。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 respectively are fused to obtain a rendered image corresponding to the hair model.

在一种可能的实施方式中,所述图像融合模块具体用于:In a possible implementation manner, the image fusion module is specifically used for:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,确定所述多个半透明发片模型分别对应的渲染图像的融合顺序;Based on the depth information of each translucent hair piece model relative to the virtual camera, determining the fusion order of the rendered images corresponding to the plurality of translucent hair piece models respectively;

基于所述融合顺序,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Based on the fusion sequence, the respective rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair models.

本公开实施例还提供一种电子设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当电子设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行上述任一种可能的实施方式中的头发渲染方法。Embodiments of the present disclosure further provide an electronic device, including: a processor, a memory, and a bus, where the memory stores machine-readable instructions executable by the processor, and when the electronic device runs, the processor and the The memories communicate with each other through a bus, and when the machine-readable instructions are executed by the processor, the hair rendering method in any of the possible implementation manners described above is executed.

本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述任一种可能的实施方式中的头发渲染方法。An embodiment of the present disclosure further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the hair rendering method in any of the foregoing possible embodiments is executed.

为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and easy to understand, the preferred embodiments are exemplified below, and are described in detail as follows in conjunction with the accompanying drawings.

附图说明Description of drawings

为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the following briefly introduces the accompanying drawings required in the embodiments, which are incorporated into the specification and constitute a part of the specification. The drawings illustrate embodiments consistent with the present disclosure, and together with the description serve to explain the technical solutions of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. Other related figures are obtained from these figures.

图1示出了本公开实施例所提供的第一种多个半透明物体渲染效果的示意图;FIG. 1 shows a schematic diagram of a first rendering effect of multiple translucent objects provided by an embodiment of the present disclosure;

图2示出了本公开实施例所提供的第二种多个半透明物体的渲染效果的示意图;FIG. 2 shows a schematic diagram of a second rendering effect of multiple translucent objects provided by an embodiment of the present disclosure;

图3示出了本公开实施例所提供的第三种多个半透明物体的渲染效果的示意图;FIG. 3 shows a schematic diagram of a third rendering effect of multiple translucent objects provided by an embodiment of the present disclosure;

图4示出了本公开实施例所提供的一种头发渲染方法的流程图;FIG. 4 shows a flowchart of a hair rendering method provided by an embodiment of the present disclosure;

图5示出了本公开实施例所提供的一种头发模型的示意图;FIG. 5 shows a schematic diagram of a hair model provided by an embodiment of the present disclosure;

图6示出了本公开实施例所提供的一种位于同一位置多个发片模型的侧面示意图;FIG. 6 shows a schematic side view of a plurality of hair piece models located at the same position provided by an embodiment of the present disclosure;

图7示出了本公开实施例所提供的一种对半透明发片模型进行不透明渲染的结果示意图;FIG. 7 shows a schematic diagram of a result of opaque rendering of a translucent hair piece model provided by an embodiment of the present disclosure;

图8示出了本公开实施例所提供的一种对半透明发片模型进行半透明渲染的结果示意图;FIG. 8 shows a schematic diagram of a result of translucent rendering of a translucent hair piece model provided by an embodiment of the present disclosure;

图9示出了本公开实施例所提供的另一种头发渲染方法的流程图;FIG. 9 shows a flowchart of another hair rendering method provided by an embodiment of the present disclosure;

图10示出了本公开实施例所提供的一种对半透明发片模型的正面进行半透明渲染的方法流程图;FIG. 10 shows a flowchart of a method for translucent rendering of the front surface of a translucent hairpiece model provided by an embodiment of the present disclosure;

图11示出了本公开实施例所提供的一种头发渲染装置的结构示意图;FIG. 11 shows a schematic structural diagram of a hair rendering apparatus provided by an embodiment of the present disclosure;

图12示出了本公开实施例所提供的一种电子设备的结构示意图。FIG. 12 shows a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.

具体实施方式Detailed ways

为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only These are some, but not all, embodiments of the present disclosure. The components of the disclosed embodiments generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure as claimed, but is merely representative of selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present disclosure.

应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that like numerals and letters refer to like items in the following figures, so once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.

本文中术语“和/或”,仅仅是描述一种关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this paper only describes an association relationship, which means that there can be three kinds of relationships, for example, A and/or B, which can mean: the existence of A alone, the existence of A and B at the same time, the existence of B alone. a situation. In addition, the term "at least one" herein refers to any combination of any one of the plurality or at least two of the plurality, for example, including at least one of A, B, and C, and may mean including from A, B, and C. Any one or more elements selected from the set of B and C.

由于超写实风格角色人物(以下简称数字人)的头发模型包括多个半透明模型,因此,在对多个半透明模型进行渲染的过程中,需要对多个半透明模型的颜色进行混合,不可以写入深度值。然而,若不写入深度值,则无法确定多个半透明模型之间的位置关系,从而容易出现渲染顺序发生错误的问题,进而造成错误的渲染结果。Since the hair model of the hyperrealistic character (hereinafter referred to as the digital human) includes multiple translucent models, in the process of rendering the multiple translucent models, the colors of the multiple translucent models need to be mixed. Depth values can be written. However, if the depth value is not written, the positional relationship between the multiple translucent models cannot be determined, so that the rendering sequence is prone to error, resulting in erroneous rendering results.

下面对相关技术中,针对多个半透明物体,因渲染顺序出错而导致渲染效果出错的情况进行详细介绍。In the related art, a situation in which a rendering effect is wrong due to a wrong rendering order for multiple translucent objects is described in detail below.

请参见图1,该示意图中包括半透明模型1、半透明模型2以及半透明模型3。其中,半透明模型1中放置有半透明模型2以及半透明模型3,也即,在正常情况下,无论从任何角度看该模型,都应该展示半透明模型1在半透明模型2以及半透明模型3前方的位置关系。Referring to FIG. 1 , the schematic diagram includes a translucent model 1 , a translucent model 2 and a translucent model 3 . Among them, translucent model 1 is placed with translucent model 2 and translucent model 3, that is, under normal circumstances, no matter from any angle, the translucent model 1 should be displayed in translucent model 2 and translucent model 3. The positional relationship in front of Model 3.

然而,相关技术中在对多个半透明模型进行渲染的过程中,并未确定半透明模型1、半透明模型2以及半透明模型3的位置关系,因此,若调整虚拟相机的拍摄视角,则会发生半透明模型2位于半透明模型1的前方(如图2所示的画面效果),或者,发生半透明模型3位于半透明模型1的前方(如图3所示的画面效果)。但其实半透明模型2以及半透明模型3的空间位置并没有发生变化,而是因为渲染顺序发生错误导致最后呈现的画面效果发生了错误。However, in the process of rendering multiple translucent models in the related art, the positional relationship of the translucent model 1, the translucent model 2 and the translucent model 3 is not determined. Therefore, if the shooting angle of the virtual camera is adjusted, then It happens that the translucent model 2 is located in front of the translucent model 1 (the picture effect shown in Figure 2), or the translucent model 3 is located in front of the translucent model 1 (the picture effect shown in Figure 3). But in fact, the spatial positions of the translucent model 2 and the translucent model 3 have not changed, but the final rendered picture effect is wrong because of the wrong rendering order.

针对上述问题,本公开实施例提供了一种头发渲染方法,包括:获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,所述第一渲染结果包括所述半透明发片模型相对于虚拟相机的深度信息;利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果;基于所述第一渲染结果以及所述第二渲染结果,得到所述半透明发片模型对应的渲染图像;将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。In response to the above problems, an embodiment of the present disclosure provides a hair rendering method, including: acquiring 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 half The transparent hair piece model is modeled and generated according to the hair piece formed by multiple hairs. The color map includes a plurality of color channels and a transparency channel. The value of each pixel in the color map in the transparency channel is used to represent the color map. Transparency information of the pixel point; for each translucent hair piece model, use the color map to perform opaque rendering on the translucent hair piece model to obtain the first rendering result of the translucent hair piece model, the The first rendering result includes depth information of the translucent hair piece model relative to the virtual camera; translucent rendering is performed on the translucent hair piece model by using the color map to obtain a second rendering of the translucent hair piece model result; based on the first rendering result and the second rendering result, a rendered image corresponding to the translucent hair piece model is obtained; the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the The rendered image corresponding to the hair model described above.

本公开实施例中,在头发模型包括多个层叠设置的半透明发片模型的情况下,先对每个半透明发片模型进行不透明渲染,然后再对每个半透明发片进行半透明渲染得到每个半透明发片模型对应的渲染图像,接着再将多个半透明发片模型分别对应的渲染图像进行融合,得到头发模型对应的渲染图像,如此,可以通过不透明渲染得到每个半透明发片模型相对于虚拟相机的深度信息,进而可以减少不同的半透明发片模型在半透明渲染过程中发生渲染顺序出错的情况,提高了多个半透明物体渲染顺序的准确率,从而提升了多个半透明物体的渲染效果。In the embodiment of the present disclosure, when the hair model includes a plurality of translucent hair piece models arranged in layers, opaque rendering is first performed on each translucent hair piece model, and then translucent rendering is performed on each translucent hair piece The rendered image corresponding to each translucent hair piece model is obtained, and then the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model. In this way, each translucent can be obtained by opaque rendering. The depth information of the hair piece model relative to the virtual camera can reduce the rendering sequence error of different translucent hair piece models during the translucent rendering process, and improve the accuracy of the rendering order of multiple translucent objects, thereby improving the Rendering of multiple translucent objects.

本公开实施例所提供的头发渲染方法的执行主体一般为具有一定计算能力的电子设备,该电子设备例如包括:终端设备或服务器或其它处理设备,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、手持设备、计算设备、车载设备等。服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云存储、大数据和人工智能平台等基础云计算服务的云服务器。The executive body of the hair rendering method provided by the embodiments of the present disclosure is generally an electronic device with a certain computing capability. , mobile devices, user terminals, terminals, handheld devices, computing devices, vehicle-mounted devices, etc. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a basic cloud computing that provides cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms. service cloud server.

在一些可能的实现方式中,该头发渲染方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。In some possible implementations, the hair rendering method may be implemented by a processor invoking computer-readable instructions stored in a memory.

此外,本公开中旨在提供一种渲染方法,因此在具体执行过程中所使用的渲染软件本公开并不做限制。本公开所述的方法也可以应用于不同的场景下,比如,对数字人头发进行离线渲染、在移动设备上实时渲染数字人头发等。In addition, the present disclosure aims to provide a rendering method, so the present disclosure does not limit the rendering software used in the specific execution process. The method described in the present disclosure can also be applied to different scenarios, such as offline rendering of digital human hair, real-time rendering of digital human hair on a mobile device, and the like.

参见图4所示,为本公开实施例提供的一种头发渲染方法的流程图,所述方法包括步骤S101~S105,其中:Referring to FIG. 4, which is a flowchart of a hair rendering method provided by an embodiment of the present disclosure, the method includes steps S101-S105, wherein:

S101,获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息。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, and each translucent hair piece model is modeled and generated according to hair pieces formed by multiple 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.

可选地,头发模型可以运行于计算机CPU(Central Processing Uni,中央处理器)、GPU(Graphics Processing Unit,图形处理器)以及存储器中,其包含网格化的模型信息以及和贴图纹理信息。相应地,作为示例,半透明发片模型以及不透明发片模型包含但不限于网格化的模型数据及贴图纹理数据或者其组合。其中,网格包括但不限于三角形网格、四边形网格、其他多边形网格或者其组合。本公开实施例中,网格为三角形网格。Optionally, the hair model may run in a computer CPU (Central Processing Uni, central processing unit), GPU (Graphics Processing Unit, graphics processing unit) and memory, which contains meshed model information and texture information. Correspondingly, as an example, the translucent hair piece model and the opaque hair piece model include, but are not limited to, meshed model data and map texture data, or a combination thereof. The meshes include, but are not limited to, triangular meshes, quadrilateral meshes, other polygonal meshes, or combinations thereof. In the embodiment of the present disclosure, the mesh is a triangular mesh.

示例性地,所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成。具体地,可以将多根头发分为一组,每一组头发都能够形成一个发片,并为每个发片进行建模,得到每一个发片分别对应的半透明发片模型,使得无需为每一根头发分别构建模型,减小了在渲染过程中所需要渲染的模型数量。相应的,每个半透明发片模型都包括多个顶点,不同位置的多个顶点之间相互连接,构成面片,从而形成头发模型的表面。Exemplarily, the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is modeled and generated according to a hair piece formed by a plurality of hairs. Specifically, multiple hairs can be grouped into a group, each group of hairs can form a hair piece, and each hair piece is modeled to obtain a translucent hair piece model corresponding to each hair piece, so that there is no need to Modeling each hair separately reduces the number of models that need to be rendered during the rendering process. Correspondingly, each translucent hair piece model includes a plurality of vertices, and the plurality of vertices at different positions are connected to each other to form a face piece, thereby forming the surface of the hair model.

示例性地,参见图5所示,为本公开实施例所提供的一种头发模型的示意图,该示意图包括多个发片模型,且位置A、位置B以及位置C处分别有多个发片模型,同一位置处的多个发片模型层叠设置,从而能够表征整个头发的发型,使得渲染出来的头发更加具有真实性。5 , which is a schematic diagram of a hair model provided by an embodiment of the present disclosure, the schematic diagram includes a plurality of hair piece models, and there are a plurality of hair pieces at positions A, B, and C respectively. Model, multiple hair piece models at the same position are stacked, so that the hairstyle of the entire hair can be represented, making the rendered hair more realistic.

其中,头发模型对应的颜色贴图是根据半透明发片模型生成的,颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在透明度通道的值,用于表征该像素点的透明度信息。半透明发片模型对应的透明值的取值范围可以为[0,255],或者,[0,1],半透明发片模型对应的透明值可以决定半透明发片模型的透明程度的呈现效果,半透明发片模型对应的透明值越大,该半透明发片模型的呈现效果表现为越不透明。The color map corresponding to the hair model is generated according to the translucent hair piece model, and the color map includes multiple color channels and transparency channels. The value of each pixel in the color map in the transparency channel is used to represent the value of the pixel. Transparency information. The value range of the transparency value corresponding to the translucent hair piece model can be [0, 255], or, [0, 1], the transparency value corresponding to the translucent hair piece model can determine the presentation of the degree of transparency of the translucent hair piece model Effect, the larger the transparency value corresponding to the translucent hair piece model, the more opaque the rendering effect of the translucent hair piece model appears.

具体地,颜色贴图中的多个颜色通道分别为R颜色通道、G颜色通道以及B颜色通道。其中,R颜色通道的值为该像素点的红色通道值,G颜色通道的值为该像素点的绿色通道值,B颜色通道的值为该像素点的蓝色通道值。颜色通道对应的颜色值的取值范围可以为[0,255],或者,[0,1],颜色通道对应的颜色值可以决定半透明发片模型的颜色的呈现效果,颜色通道对应的颜色值越大,该半透明发片模型的颜色的呈现效果越深。Specifically, the multiple color channels in the color map are an R color channel, a G color channel, and a B color channel, respectively. Among them, the value of the R color channel is the value of the red channel of the pixel, the value of the G color channel is the value of the green channel of the pixel, and the value of the B color channel is the value of the blue channel of the pixel. The value range of the color value corresponding to the color channel can be [0, 255], or [0, 1]. The color value corresponding to the color channel can determine the rendering effect of the color of the translucent hair piece model. The color corresponding to the color channel The higher the value, the darker the color rendering of the translucent hair piece model.

在一种可能的实施方式中,在所述头发模型为表征头发根部的头发模型的情况下,所述头发模型还包括不透明发片模型,所述不透明发片模型与所述多个半透明发片模型层叠设置,且所述不透明发片模型靠近头皮位置。比如,再次参见图5所示,位置A以及位置B处的最内层发片模型为不透明发片模型。如此,可以避免由于颜色贴图的透明度信息造成将头皮渲染出来的问题,增加头发渲染的真实性。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 and the plurality of translucent hair pieces The patch models are arranged in layers, and the opaque hair patch models are positioned close to the scalp. For example, referring to Fig. 5 again, the innermost hair piece models at positions A and B are opaque hair piece models. In this way, the problem of rendering the scalp due to the transparency information of the color map can be avoided, and the authenticity of the hair rendering can be increased.

示例性地,参见图6所示,为本公开实施例所提供的一种位于同一位置多个发片模型的侧面示意图,该示意图包括位于同一位置的发片模型1、发片模型2、发片模型3以及发片模型4。其中,发片模型4为靠近头皮位置的不透明发片模型,发片模型1、发片模型2以及发片模型3为半透明发片模型。Exemplarily, referring to FIG. 6 , which is a schematic side view of a plurality of hair piece models located at the same position provided by an embodiment of the present disclosure, the schematic diagram includes a hair piece model 1 , a hair piece model 2 , and a hair piece model 2 located at the same position. Piece Model 3 and Hair Piece Model 4. The hair piece model 4 is an opaque hair piece model close to the scalp, and the hair piece model 1 , the hair piece model 2 and the hair piece model 3 are translucent hair piece models.

需要说明的是,头发模型以及头发模型对应的颜色贴图可以是预先制作好,存储在预设存储空间中,当需要执行对头发模型的渲染任务时,从该预设存储空间中读取头发模型以及对应的颜色贴图。It should be noted that the hair model and the color map corresponding to the hair model can be pre-made and stored in the preset storage space. When the rendering task of the hair model needs to be performed, the hair model is read from the preset storage space. and the corresponding color map.

S102,针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,所述第一渲染结果包括所述半透明发片模型相对于虚拟相机的深度信息。S102, for each translucent hair piece model, use the color map to perform opaque rendering on the translucent hair piece model, to obtain a first rendering result of the translucent hair piece model, the first rendering result Including depth information of the translucent hair piece model relative to the virtual camera.

具体地,可以通过着色器对半透明发片模型进行渲染。其中,着色器用于在3D形象渲染过程中进行模型渲染,以得到渲染图像。该着色器包括顶点着色器以及像素着色器,顶点着色器用于对模型顶点的几何关系进行计算,像素着色器用于对模型的颜色进行计算。Specifically, the translucent hair piece model can be rendered by a shader. Among them, the shader is used to render the model in the 3D image rendering process to obtain the rendered image. The shader includes a vertex shader and a pixel shader. The vertex shader is used to calculate the geometric relationship of the vertices of the model, and the pixel shader is used to calculate the color of the model.

示例性地,参见图7所示,为本公开实施例提供的一种对半透明发片模型进行不透明渲染的结果示意图,可以根据半透明发片模型在视觉坐标系中z轴方向的坐标值对该半透明发片模型进行渲染,以得到半透明发片模型相对于虚拟相机的深度信息。其中,深度信息用于表征半透明发片模型所处的位置信息,半透明发片模型对应的深度值越小,说明该半透明发片模型离虚拟相机越近。Exemplarily, referring to FIG. 7 , which is a schematic diagram of a result of opaque rendering of a translucent hair piece model provided by an embodiment of the present disclosure, the coordinate value of the translucent hair piece model in the z-axis direction in the visual coordinate system can be used according to the coordinate value of the translucent hair piece model. The translucent hair piece model is rendered to obtain depth information of the translucent hair piece model relative to the virtual camera. The depth information is used to represent the position information of the translucent hair piece model, and the smaller the depth value corresponding to the translucent hair piece model, the closer the translucent hair piece model is to the virtual camera.

其中,虚拟相机是一种通过控制一个或多个镜头的方式,呈现一个三维的虚拟世界。用于电子游戏的镜头系统旨在于最佳角度展示动作;广泛而言,这些镜头用于需要第三人称视角的三维虚拟世界。在找到一个适合的镜头后,可获得该虚拟相机的镜头的方位及旋转角度,而相关数据可供图形引擎渲染器(graphic engine renderer)生成视图(view)。Among them, the virtual camera is a way of presenting a three-dimensional virtual world by controlling one or more lenses. Lens systems used in video games are designed to show action at the best angle; broadly speaking, these lenses are used in three-dimensional virtual worlds that require a third-person perspective. After finding a suitable lens, the orientation and rotation angle of the lens of the virtual camera can be obtained, and the related data can be used by a graphic engine renderer to generate a view.

S103,利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果。S103, using the color map to perform translucent rendering on the translucent hair piece model, to obtain a second rendering result of the translucent hair piece model.

其中,半透明渲染是指根据颜色贴图上表述的透明度信息的强度,对模型进行透明处理,可以根据贴图绘制的强度决定最终渲染的透明程度。本实施方式中,通过半透明渲染的方式对头发发梢、碎发等部位进行渲染,使得渲染得到的头发模型更加贴近于人类头发的真实效果。Among them, translucent rendering means that the model is transparently processed according to the intensity of the transparency information expressed on the color map, and the degree of transparency of the final rendering can be determined according to the intensity of the map drawing. In this embodiment, the hair tips, broken hairs and other parts are rendered by means of translucent rendering, so that the rendered hair model is closer to the real effect of human hair.

可选地,在利用颜色贴图对半透明发片模型进行半透明渲染的过程中,半透明发片模型的顶点和颜色贴图的像素点之间具有对应关系,根据该对应关系,除了为每个半透明发片模型的顶点确定对应的颜色、纹理等信息外,还会利用颜色贴图中各个像素点分别在透明度通道中的值,确定第一模型中各个顶点分别对应的透明度值。其中,该透明度值用于表征该像素点对应的位置是否是透明的,因此,可以通过颜色贴图中各个像素点分别对应的透明度值,将位于内层的半透明发片模型对应的头发能够透过位于外层的半透明发片模型渲染出来,从而达到如图8所示的渲染效果。Optionally, in the process of translucent rendering of the translucent hair piece model by using the color map, there is a correspondence between the vertices of the translucent hair piece model and the pixels of the color map. In addition to determining the corresponding color, texture and other information of the vertices of the translucent hair piece model, the value of each pixel in the color map in the transparency channel is used to determine the transparency value corresponding to each vertex in the first model. Among them, the transparency value is used to indicate whether the position corresponding to the pixel is transparent. Therefore, through the transparency values corresponding to each pixel in the color map, the hair corresponding to the translucent hair piece model located in the inner layer can be transparent. It is rendered through the translucent hair piece model located in the outer layer, so as to achieve the rendering effect as shown in Figure 8.

S104,基于所述第一渲染结果以及所述第二渲染结果,得到所述半透明发片模型对应的渲染图像。S104, based on the first rendering result and the second rendering result, obtain a rendered image corresponding to the translucent hair piece model.

示例性地,在得到第一渲染结果以及第二渲染结果后,可以根据第一渲染结果以及第二渲染结果,得到半透明发片模型对应的渲染图像。其中,渲染图像可以是虚拟相机根据任一角度进行拍摄得到的,该渲染图像中包括颜色贴图中绘制的多根头发。Exemplarily, after the first rendering result and the second rendering result are obtained, a rendered image corresponding to the translucent hair piece model may be obtained according to the first rendering result and the second rendering result. The rendered image may be captured by a virtual camera according to any angle, and the rendered image includes a plurality of hairs drawn in the color map.

需要说明的是,由于第一次渲染采用的是不透明的渲染方式,而第二次渲染采用的是单层半透明的渲染方式,因此,通过第一渲染结果以及第二渲染结果得到的渲染图像是不会出现多个半透明模型之间排序发生错误的问题,进一步提升渲染结果的准确性。It should be noted that since the first rendering adopts the opaque rendering method, and the second rendering adopts the single-layer translucent rendering method, the rendered image obtained through the first rendering result and the second rendering result There is no problem of incorrect sorting between multiple translucent models, which further improves the accuracy of rendering results.

S105,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。S105 , fuse the respectively corresponding rendered images of the multiple translucent hair piece models to obtain the rendered images corresponding to the hair models.

在得到头发模型中每个半透明发片模型对应的渲染图像后,需要将多个半透明发片模型分别对应的渲染图像进行融合,以得到头发模型对应的渲染图像。After obtaining the rendered image corresponding to each translucent hair piece model in the hair model, it is necessary to fuse the respectively corresponding rendered images of the multiple translucent hair piece models to obtain the rendered image corresponding to the hair model.

可选地,可以基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Optionally, based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the plurality of translucent hair piece models may be fused to obtain the corresponding rendering images of the hair model. Render the image.

本实施方式中,由于半透明发片模型相对于虚拟相机的深度信息是用于确定该半透明发片模型相对于虚拟相机的位置,因此,通过深度信息将多张渲染图像进行融合,可以降低多个半透明发片模型之间的排序发生错误的情况,使得渲染后生成的图像更加贴近于真实效果。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, the depth information is used to fuse multiple rendered images, which can reduce The ordering of multiple translucent hair models was wrong, making the rendered image more realistic.

具体地,基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,确定所述多个半透明发片模型分别对应的渲染图像的融合顺序;基于所述融合顺序,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Specifically, based on the depth information of each translucent hair piece model relative to the virtual camera, determine the fusion order of the rendered images corresponding to the multiple translucent hair piece models respectively; The rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair model.

其中,每个半透明发片模型对应的渲染图像都是由许多像素点组成的,将多张渲染图像进行融合时,深度值较小的半透明发片模型离虚拟相机的距离越近,也即,深度值较小的半透明发片模型位于发片模型的前端,而深度值较大的半透明发片模型离虚拟相机的距离越远,也即,深度值较大的半透明发片模型位于发片模型的后端。Among them, the rendered image corresponding to each translucent hair piece model is composed of many pixels. 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 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 with a larger depth value. The model is located at the back end of the hairpiece model.

需要说明的是,多个半透明发片模型分别对应的渲染图像的融合顺序可以是根据深度值从小到大进行排序,还可以是根据深度值从大到小进行排序,具体不做限定。示例性地,若融合顺序是根据深度值从小到大进行排序得到的,则可以从深度值较小的半透明发片模型开始融合,也即,从头发模型的最外层开始融合;若融合顺序是根据深度值从大到小进行排序得到的,则可以从深度值较大的半透明发片模型开始融合,也即,从头发模型的最内层开始融合。It should be noted that the fusion order of the rendered images corresponding to the multiple translucent hair piece models may be sorted according to the depth value from small to large, or may be sorted according to the depth value from large to small, which is not specifically limited. Exemplarily, if the fusion order is obtained by sorting the depth values from small to large, the fusion can start from the translucent hair piece model with a smaller depth value, that is, start fusion from the outermost layer of the hair model; The order is obtained by sorting the depth values from large to small, and the fusion can start from the translucent hair piece model with a larger depth value, that is, from the innermost layer of the hair model.

本公开实施例中,在头发模型包括多个层叠设置的半透明发片模型的情况下,先对每个半透明发片模型进行不透明渲染,然后再对每个半透明发片进行半透明渲染得到每个半透明发片模型对应的渲染图像,接着再将多个半透明发片模型分别对应的渲染图像进行融合,得到头发模型对应的渲染图像,如此,可以通过不透明渲染得到每个半透明发片模型相对于虚拟相机的深度信息,进而可以减少不同的半透明发片模型在半透明渲染过程中发生渲染顺序出错的情况,提高了多个半透明物体渲染顺序的准确率,从而提升了多个半透明物体的渲染效果。In the embodiment of the present disclosure, when the hair model includes a plurality of translucent hair piece models arranged in layers, opaque rendering is first performed on each translucent hair piece model, and then translucent rendering is performed on each translucent hair piece The rendered image corresponding to each translucent hair piece model is obtained, and then the rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered image corresponding to the hair model. In this way, each translucent can be obtained by opaque rendering. The depth information of the hair piece model relative to the virtual camera can reduce the rendering sequence error of different translucent hair piece models during the translucent rendering process, and improve the accuracy of the rendering order of multiple translucent objects, thereby improving the Rendering of multiple translucent objects.

在一种可能的实施方式中,半透明发片模型包括靠近所述虚拟相机的正面以及远离所述虚拟相机的背面,具体地,参见图9所示,为本公开实施例所提供的另一种头发渲染方法的流程图,包括S201~S205: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. Specifically, referring to FIG. 9 , another embodiment of the present disclosure provides another A flowchart of a hair rendering method, including S201 to S205:

S201,获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息。S201, obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is modeled and generated according to hair pieces 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.

该步骤与图4中的步骤S101类似,在此不再赘述。This step is similar to step S101 in FIG. 4 and will not be repeated here.

S202,针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果。S202, for each translucent hair piece model, use the color map to perform opaque rendering on the back of the translucent hair piece model, to obtain a first rendering result of the translucent hair piece model.

本实施方式中,通过不透明的渲染方式,对半透明发片模型的背面进行渲染,可以在不影响最终渲染效果的基础上,得到所述半透明发片模型相对于虚拟相机的深度信息,以减少多个模型之间的排列顺序发生错误的情况。In this embodiment, the backside of the translucent hair piece model is rendered in an opaque rendering manner, and the depth information of the translucent hair piece model relative to the virtual camera can be obtained without affecting the final rendering effect, so as to Reduce the number of cases where the arrangement order between multiple models is wrong.

具体地,利用所述颜色贴图对所述半透明发片模型的背面进行颜色渲染,得到如图7的画面效果。如此,可以使得第一渲染结果中还包括颜色信息,增强了模型背面渲染效果。此外,由于第一次渲染只进行颜色渲染,因此,可以减少因进行过多不必要的渲染而造成资源浪费的情况发生。Specifically, color rendering is performed on the back surface of the translucent hair piece model by using the color map to obtain the picture effect as shown in FIG. 7 . In this way, the first rendering result can also include color information, which enhances the rendering effect of the back of the model. In addition, because the first rendering only performs color rendering, it can reduce the occurrence of resource waste caused by excessive unnecessary rendering.

S203,利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果。S203, using the color map to perform translucent rendering on the front surface of the translucent hair piece model, to obtain a second rendering result of the translucent hair piece model.

本实施方式中,利用颜色贴图先对半透明发片模型的背面进行不透明渲染,然后再通过半透明的渲染方式,对半透明发片模型的正面进行渲染,如此,可以在不影响渲染效果的同时,确定半透明发片模型所处的位置,减少渲染顺序发生错误的情况。In this embodiment, the backside of the translucent hair piece model is first rendered opaque by using the color map, and then the front side of the translucent hair piece model is rendered by the translucent rendering method. In this way, the rendering effect is not affected. At the same time, determine the position of the translucent hair piece model to reduce the error of rendering order.

具体地,参见图10所示,为本公开实施例所提供的一种对半透明发片模型的正面进行半透明渲染的方法流程图,包括S2031~S2032:Specifically, referring to FIG. 10 , a flowchart of a method for translucent rendering of the front surface of a translucent hair piece model provided by an embodiment of the present disclosure includes S2031 to S2032 :

S2031,获取所述半透明发片模型的位置信息以及光线方向信息。S2031: Acquire position information and light direction information of the translucent hair piece model.

其中,半透明发片模型的位置信息是指半透明发片模型相对于模拟光源所处的位置信息。光线方向信息是指模拟光源对半透明发片模型进行照射时的方向。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. The light direction information refers to the direction when the simulated light source illuminates the translucent hair piece model.

S2032,利用所述颜色贴图对所述半透明发片模型的正面进行颜色渲染,以及基于所述光线方向信息、和所述半透明发片模型的位置信息,对所述半透明发片模型的正面进行阴影渲染,得到所述第二渲染结果。S2032, using the color map to perform color rendering on the front surface of the translucent hair piece model, and based on the light direction information and the position information of the translucent hair piece model, perform color rendering on the translucent hair piece model. Shadow rendering is performed on the front side to obtain the second rendering result.

其中,阴影渲染是通过模拟光源对模型照射所产生的明暗程度,并用灰度色调或彩色输出,得到随光度近似连续变化的色调,达到模型不同位置的敏感对比,使模型具有一定的立体感,直观地表达模型不同位置的变化。Among them, shadow rendering is to simulate the degree of light and shade produced by the illumination of the light source on the model, and use grayscale tone or color output to obtain a tone that changes approximately continuously with the luminosity, so as to achieve the sensitive contrast of different positions of the model, so that the model has a certain three-dimensional sense. Visually express changes in different positions of the model.

本实施方式中,通过对半透明发片模型的正面进行颜色渲染,可以得到半透明发片模型的颜色信息,通过对半透明发片模型的正面进行阴影渲染,可以得到半透明发片模型的光影信息,根据半透明发片模型的颜色信息以及光影信息,可以使得头发的渲染效果更加真实、自然。In this embodiment, by performing color rendering on the front of the translucent hair piece model, the color information of the translucent hair piece model can be obtained. By performing shadow rendering on the front of the translucent hair piece model, the color information of the translucent hair piece model can be obtained. Light and shadow information, according to the color information and light and shadow information of the translucent hair piece model, can make the rendering effect of the hair more realistic and natural.

S204,基于所述第一渲染结果与所述第二渲染结果,得到所述半透明发片模型对应的渲染图像。S204, based on the first rendering result and the second rendering result, obtain a rendered image corresponding to the translucent hair piece model.

该步骤与图4中的步骤S104类似,在此不再赘述。This step is similar to step S104 in FIG. 4 and will not be repeated here.

S205,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。S205 , fuse the respectively corresponding rendered images of the multiple translucent hair piece models to obtain the rendered images corresponding to the hair models.

该步骤与图4中的步骤S105类似,在此不再赘述。This step is similar to step S105 in FIG. 4 and will not be repeated here.

本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above method of the specific implementation, the writing order of each step does not mean a strict execution order but constitutes any limitation on the implementation process, and the specific execution order of each step should be based on its function and possible Internal logic is determined.

基于同一发明构思,本公开实施例中还提供了与头发渲染方法对应的头发渲染装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述头发渲染方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiments of the present disclosure also provide a hair rendering device corresponding to the hair rendering method. Reference may be made to the implementation of the method, and repeated descriptions will not be repeated.

参照图11所示,为本公开实施例提供的一种头发渲染装置的结构示意图,所述装置1100包括:Referring to FIG. 11 , which is a schematic structural diagram of a hair rendering apparatus according to an embodiment of the present disclosure, the apparatus 1100 includes:

模型获取模块1101,用于获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;The model obtaining module 1101 is used to obtain a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is formed according to 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;

第一渲染模块1102,用于针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,所述第一渲染结果包括所述半透明发片模型相对于虚拟相机的深度信息;A first rendering module 1102, configured to perform opaque rendering on the translucent hair piece model by using the color map for each of the translucent hair piece models, to obtain a first rendering result of the translucent hair piece model, The first rendering result includes depth information of the translucent hair piece model relative to the virtual camera;

第二渲染模块1103,用于利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果;A second rendering module 1103, configured to perform translucent rendering on the translucent hair piece model by using the color map, to obtain a second rendering result of the translucent hair piece model;

图像生成模块1104,用于基于所述第一渲染结果以及所述第二渲染结果,得到所述半透明发片模型对应的渲染图像;An image generation module 1104, configured to obtain a rendered image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result;

图像融合模块1105,用于将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。The image fusion module 1105 is configured to fuse the respectively corresponding rendered images of the multiple translucent hair piece models to obtain the rendered images corresponding to the hair models.

在一种可能的实施方式中,在所述头发模型为表征头发根部的头发模型的情况下,所述头发模型还包括不透明发片模型,所述不透明发片模型与所述多个半透明发片模型层叠设置,且所述不透明发片模型靠近头皮位置。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 and the plurality of translucent hair pieces The patch models are arranged in layers, and the opaque hair patch models are positioned close to the scalp.

在一种可能的实施方式中,所述半透明发片模型包括靠近所述虚拟相机的正面以及远离所述虚拟相机的背面,所述第一渲染模块1102具体用于:In a possible implementation manner, 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:

利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果;Opaque rendering is performed on the back of the translucent hair piece model by using the color map to obtain a first rendering result of the translucent hair piece model;

所述第二渲染模块1103具体用于:The second rendering module 1103 is specifically used for:

利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果。Translucent rendering is performed on the front surface of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model.

在一种可能的实施方式中,所述第一渲染模块1102具体用于:In a possible implementation manner, the first rendering module 1102 is specifically used for:

利用所述颜色贴图对所述半透明发片模型的背面进行颜色渲染,得到所述第一渲染结果。Color rendering is performed on the back surface of the translucent hair piece model by using the color map to obtain the first rendering result.

在一种可能的实施方式中,所述第二渲染模块1103具体用于:In a possible implementation manner, the second rendering module 1103 is specifically used for:

获取所述半透明发片模型的位置信息以及光线方向信息;Obtain the position information and light direction information of the translucent hair piece model;

利用所述颜色贴图对所述半透明发片模型的正面进行颜色渲染,以及基于所述光线方向信息、和所述半透明发片模型的位置信息,对所述半透明发片模型的正面进行阴影渲染,得到所述第二渲染结果。Color rendering is performed on the front face of the translucent hair piece model by using the color map, and based on the light direction information and the position information of the translucent hair piece model, the front face of the translucent hair piece model is rendered in color. Shadow rendering to obtain the second rendering result.

在一种可能的实施方式中,所述图像融合模块1105具体用于:In a possible implementation manner, the image fusion module 1105 is specifically used for:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。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 respectively are fused to obtain a rendered image corresponding to the hair model.

在一种可能的实施方式中,所述图像融合模块1105具体用于:In a possible implementation manner, the image fusion module 1105 is specifically used for:

基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,确定所述多个半透明发片模型分别对应的渲染图像的融合顺序;Based on the depth information of each translucent hair piece model relative to the virtual camera, determining the fusion order of the rendered images corresponding to the plurality of translucent hair piece models respectively;

基于所述融合顺序,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Based on the fusion sequence, the respective rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair models.

基于同一技术构思,本申请实施例还提供了一种电子设备。参照图12所示,为本申请实施例所提供的一种电子设备1200的结构示意图,包括处理器1201、存储器1202和总线1203。其中,存储器1202用于存储执行指令,包括内存12021和外部存储器12022;这里的内存12021也称内存储器,用于暂时存放处理器1201中的运算数据,以及与硬盘等外部存储器12022交换的数据,处理器1201通过内存2021与外部存储器12022进行数据交换。Based on the same technical concept, the embodiments of the present application also provide an electronic device. Referring to FIG. 12 , a schematic structural diagram of an electronic device 1200 provided by an embodiment of the present application includes a processor 1201 , a memory 1202 , and a bus 1203 . Among them, the memory 1202 is used to store the execution instructions, including the memory 12021 and the external memory 12022; the memory 12021 here is also called the internal memory, which is used to temporarily store the operation data in the processor 1201 and the data exchanged with the external memory 12022 such as the hard disk, The processor 1201 exchanges data with the external memory 12022 through the memory 2021 .

本申请实施例中,存储器1202具体用于存储执行本申请方案的应用程序代码,并由处理器1201来控制执行。也即,当电子设备1200运行时,处理器1201与存储器1202之间通过总线1203通信,使得处理器1201执行存储器1202中存储的应用程序代码,进而执行前述任一实施例中所揭示的方法。In this embodiment of the present application, the memory 1202 is specifically used to store the application program 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 through the bus 1203, so that the processor 1201 executes the application code stored in the memory 1202, thereby executing the method disclosed in any of the foregoing embodiments.

其中,存储器1202可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-Only Memory,PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,EEPROM)等。The memory 1202 may be, but not limited to, a random access memory (Random Access Memory, RAM), a read only memory (Read Only Memory, ROM), a programmable read only memory (Programmable Read-Only Memory, PROM), or Erasable Programmable Read-Only Memory (EPROM), Electrical Erasable Programmable Read-Only Memory (EEPROM), etc.

处理器1201可能是一种集成电路芯片,具有信号的处理能力。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(NetworkProcessor,NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 1201 may be an integrated circuit chip with signal processing capability. The above-mentioned processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), Field Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention can be implemented or executed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

可以理解的是,本申请实施例示意的结构并不构成对电子设备1200的具体限定。在本申请另一些实施例中,电子设备1200可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can 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 less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的一种头发渲染方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the hair rendering method described in the foregoing method embodiments are executed. . Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.

本公开实施例所提供的一种计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行上述方法实施例中的一种头发渲染方法的步骤,具体可参见上述方法实施例,在此不再赘述。A computer program product provided by the embodiments of the present disclosure includes a computer-readable storage medium storing program codes, and the instructions included in the program codes can be used to execute the steps of a hair rendering method in the above method embodiments, specifically Reference may be made to the foregoing method embodiments, and details are not described herein again.

其中,上述计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。Wherein, the above-mentioned computer program product can be specifically implemented by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. Wait.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that, for the convenience and brevity of description, for the specific working process of the system and device described above, reference may be made to the corresponding process in the foregoing method embodiments, which will not be repeated here. In the several embodiments provided by the present disclosure, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. The apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。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 alone, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a processor-executable non-volatile computer-readable storage medium. Based on such understanding, the technical solutions of the present disclosure can be embodied in the form of software products in essence, or the parts that contribute to the prior art or the parts of the technical solutions. The computer software products are stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.

最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present disclosure, and are used to illustrate the technical solutions of the present disclosure rather than limit them. The protection scope of the present disclosure is not limited thereto, although referring to the foregoing The embodiments describe the present disclosure in detail. Those of ordinary skill in the art should understand that: any person skilled in the art can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present disclosure. Changes can be easily thought of, or equivalent replacements are made to some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered in the present disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims (10)

1.一种头发渲染方法,其特征在于,包括:1. a hair rendering method, is characterized in that, comprises: 获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;Obtain a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is modeled and generated according to the hair pieces 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 translucent hair piece model, use the color map to perform opaque rendering on the translucent hair piece model, to obtain a first rendering result of the translucent hair piece model, where the first rendering result includes all The depth information of the translucent hair piece model relative to the virtual camera; 利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果;Perform translucent rendering on the translucent hair piece model by using the color map to obtain a second rendering result of the translucent 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; 将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。The rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair model. 2.根据权利要求1所述的方法,其特征在于,在所述头发模型为表征头发根部的头发模型的情况下,所述头发模型还包括不透明发片模型,所述不透明发片模型与所述多个半透明发片模型层叠设置,且所述不透明发片模型靠近头皮位置。2 . The method according to claim 1 , wherein, in the case that the hair model is a hair model representing the root of the hair, the hair model further comprises an opaque hair piece model, the opaque hair piece model being the same as the hair model. 3 . The plurality of translucent hair piece models are stacked and arranged, and the opaque hair piece models are close to the scalp. 3.根据权利要求1或2所述的方法,其特征在于,所述半透明发片模型包括靠近所述虚拟相机的正面以及远离所述虚拟相机的背面,所述利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,包括:3. The method according to claim 1 or 2, wherein the translucent hair piece model includes a front face close to the virtual camera and a back face far from the virtual camera, and the color map is used to adjust the The translucent hair piece model is rendered opaque, and the first rendering result of the translucent hair piece model is obtained, including: 利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果;Opaque rendering is performed on the back of the translucent hair piece model by using the color map to obtain a first rendering result of the translucent hair piece model; 所述利用所述颜色贴图对所述半透明发片模型进行半透明渲染,得到所述半透明发片模型的第二渲染结果,包括:The translucent rendering of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model, including: 利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果。Translucent rendering is performed on the front surface of the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model. 4.根据权利要求3所述的方法,其特征在于,所述利用所述颜色贴图对所述半透明发片模型的背面进行不透明渲染,得到所述半透明发片模型的第一渲染结果,包括:4 . The method according to claim 3 , wherein the opaque rendering of the back surface of the translucent hair piece model by using the color map is performed to obtain a first rendering result of the translucent hair piece model, 4 . include: 利用所述颜色贴图对所述半透明发片模型的背面进行颜色渲染,得到所述第一渲染结果。Color rendering is performed on the back surface of the translucent hair piece model by using the color map to obtain the first rendering result. 5.根据权利要求3或4所述的方法,其特征在于,所述利用所述颜色贴图对所述半透明发片模型的正面进行半透明渲染,得到所述半透明发片模型的第二渲染结果,包括:5. The method according to claim 3 or 4, wherein the translucent rendering is performed on the front surface of the translucent hair piece model by using the color map to obtain the second half of the translucent hair piece model. Rendering results, including: 获取所述半透明发片模型的位置信息以及光线方向信息;Obtain the position information and light direction information of the translucent hair piece model; 利用所述颜色贴图对所述半透明发片模型的正面进行颜色渲染,以及基于所述光线方向信息、和所述半透明发片模型的位置信息,对所述半透明发片模型的正面进行阴影渲染,得到所述第二渲染结果。Color rendering is performed on the front face of the translucent hair piece model by using the color map, and based on the light direction information and the position information of the translucent hair piece model, the front face of the translucent hair piece model is rendered in color. Shadow rendering to obtain the second rendering result. 6.根据权利要求1-5任一所述的方法,其特征在于,所述将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像,包括:6. The method according to any one of claims 1-5, wherein the rendering images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair models, comprising: : 基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。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 respectively are fused to obtain a rendered image corresponding to the hair model. 7.根据权利要求6所述的方法,其特征在于,所述基于所述每个半透明发片模型相对于虚拟相机的深度信息,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像,包括:7 . The method according to claim 6 , wherein, based on the depth information of each translucent hair piece model relative to the virtual camera, the rendered images corresponding to the plurality of translucent hair piece models respectively are obtained. 8 . Perform fusion to obtain the rendered image corresponding to the hair model, including: 基于所述每个半透明发片模型相对于所述虚拟相机的深度信息,确定所述多个半透明发片模型分别对应的渲染图像的融合顺序;Based on the depth information of each translucent hair piece model relative to the virtual camera, determining the fusion order of the rendered images corresponding to the plurality of translucent hair piece models respectively; 基于所述融合顺序,将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。Based on the fusion sequence, the respective rendered images corresponding to the multiple translucent hair piece models are fused to obtain the rendered images corresponding to the hair models. 8.一种头发渲染装置,其特征在于,包括:8. A hair rendering device, comprising: 模型获取模块,用于获取头发模型以及所述头发模型对应的颜色贴图;所述头发模型包括多个层叠设置的半透明发片模型,每个半透明发片模型根据多根头发形成的发片进行建模生成,所述颜色贴图包括多个颜色通道以及透明度通道,所述颜色贴图中各个像素点在所述透明度通道的值,用于表征该像素点的透明度信息;a model obtaining module, used for obtaining a hair model and a color map corresponding to the hair model; the hair model includes a plurality of translucent hair piece models arranged in layers, and each translucent hair piece model is based on a hair piece formed by a plurality of hairs Perform modeling and generation, 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; 第一渲染模块,用于针对所述每个半透明发片模型,利用所述颜色贴图对所述半透明发片模型进行不透明渲染,得到所述半透明发片模型的第一渲染结果,所述第一渲染结果包括所述半透明发片模型相对于虚拟相机的深度信息;The first rendering module is configured to perform opaque rendering on the translucent hair chip model by using the color map for each of the translucent hair chip models, and obtain a first rendering result of the translucent hair chip model. 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 translucent rendering on the translucent hair piece model by using the color map to obtain a second rendering result of the translucent hair piece model; 图像生成模块,用于基于所述第一渲染结果以及所述第二渲染结果,得到所述半透明发片模型对应的渲染图像;an image generation module, configured to obtain a rendered image corresponding to the translucent hair piece model based on the first rendering result and the second rendering result; 图像融合模块,用于将所述多个半透明发片模型分别对应的渲染图像进行融合,得到所述头发模型对应的渲染图像。The image fusion module is used for fusing the rendered images corresponding to the multiple translucent hair piece models respectively to obtain the rendered images corresponding to the hair model. 9.一种电子设备,其特征在于,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当电子设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行如权利要求1至7任意一项所述的头发渲染方法。9. An electronic device, comprising: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the The memories communicate with each other through a bus, and when the machine-readable instructions are executed by the processor, the hair rendering method according to any one of claims 1 to 7 is executed. 10.一种计算机可读存储介质,其特征在于,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至7任意一项所述的头发渲染方法。10. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the hair rendering method according to any one of claims 1 to 7 is executed .
CN202210663477.2A 2022-06-13 2022-06-13 Hair rendering method, device, electronic device and storage medium Pending CN115063330A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210663477.2A CN115063330A (en) 2022-06-13 2022-06-13 Hair rendering method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210663477.2A CN115063330A (en) 2022-06-13 2022-06-13 Hair rendering method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN115063330A true CN115063330A (en) 2022-09-16

Family

ID=83200695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210663477.2A Pending CN115063330A (en) 2022-06-13 2022-06-13 Hair rendering method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN115063330A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630516A (en) * 2023-06-09 2023-08-22 广州三七极耀网络科技有限公司 3D characteristic-based 2D rendering ordering method, device, equipment and medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070103462A1 (en) * 2005-11-09 2007-05-10 Miller Gavin S Method and apparatus for rendering semi-transparent surfaces
CN106815883A (en) * 2016-12-07 2017-06-09 珠海金山网络游戏科技有限公司 The hair treating method and system of a kind of game role
US20180276878A1 (en) * 2017-03-24 2018-09-27 Mz Ip Holdings, Llc System and method for rendering shadows for a virtual environment
CN109389664A (en) * 2017-08-04 2019-02-26 腾讯科技(深圳)有限公司 Model pinup picture rendering method, device and terminal
CN111508053A (en) * 2020-04-26 2020-08-07 网易(杭州)网络有限公司 Model rendering method and device, electronic equipment and computer readable medium
WO2020207202A1 (en) * 2019-04-11 2020-10-15 腾讯科技(深圳)有限公司 Shadow rendering method and apparatus, computer device and storage medium
CN112862943A (en) * 2021-02-03 2021-05-28 网易(杭州)网络有限公司 Virtual model rendering method and device, storage medium and electronic equipment
CN113205583A (en) * 2021-04-28 2021-08-03 北京字跳网络技术有限公司 Scene rendering method and device, electronic equipment and readable storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070103462A1 (en) * 2005-11-09 2007-05-10 Miller Gavin S Method and apparatus for rendering semi-transparent surfaces
CN106815883A (en) * 2016-12-07 2017-06-09 珠海金山网络游戏科技有限公司 The hair treating method and system of a kind of game role
US20180276878A1 (en) * 2017-03-24 2018-09-27 Mz Ip Holdings, Llc System and method for rendering shadows for a virtual environment
CN109389664A (en) * 2017-08-04 2019-02-26 腾讯科技(深圳)有限公司 Model pinup picture rendering method, device and terminal
WO2020207202A1 (en) * 2019-04-11 2020-10-15 腾讯科技(深圳)有限公司 Shadow rendering method and apparatus, computer device and storage medium
CN111508053A (en) * 2020-04-26 2020-08-07 网易(杭州)网络有限公司 Model rendering method and device, electronic equipment and computer readable medium
CN112862943A (en) * 2021-02-03 2021-05-28 网易(杭州)网络有限公司 Virtual model rendering method and device, storage medium and electronic equipment
CN113205583A (en) * 2021-04-28 2021-08-03 北京字跳网络技术有限公司 Scene rendering method and device, electronic equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
温佩芝;朱立坤;黄佳;: "半透明三维物体表面光泽真实感实时渲染方法", 计算机应用, no. 10, 10 October 2016 (2016-10-10) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630516A (en) * 2023-06-09 2023-08-22 广州三七极耀网络科技有限公司 3D characteristic-based 2D rendering ordering method, device, equipment and medium
CN116630516B (en) * 2023-06-09 2024-01-30 广州三七极耀网络科技有限公司 3D characteristic-based 2D rendering ordering method, device, equipment and medium

Similar Documents

Publication Publication Date Title
US11257286B2 (en) Method for rendering of simulating illumination and terminal
CN112215934B (en) Game model rendering method and device, storage medium and electronic device
CN111862285B (en) Character skin rendering method and device, storage medium and electronic device
CN112316420A (en) Model rendering method, device, equipment and storage medium
CN114119847B (en) Graphic processing method, device, computer equipment and storage medium
CN108564646A (en) Rendering intent and device, storage medium, the electronic device of object
CN109903374B (en) Eyeball simulation method and device for virtual object and storage medium
CN114119848B (en) Model rendering method and device, computer equipment and storage medium
CN114241151B (en) Three-dimensional model simplification method, three-dimensional model simplification device, computer equipment and computer storage medium
CN114549719A (en) Rendering method, apparatus, computer equipment and storage medium
CN113936080B (en) Virtual model rendering method and device, storage medium and electronic equipment
CN112446943A (en) Image rendering method and device and computer readable storage medium
CN116310056A (en) Rendering method, rendering device, equipment and medium for three-dimensional model
CN114529657A (en) Rendering image generation method and device, computer equipment and storage medium
CN115063330A (en) Hair rendering method, device, electronic device and storage medium
CN114863078A (en) Model rendering method and device, computer equipment and storage medium
CN115082614A (en) Highlight generation method and device, computer equipment and storage medium
CN114972647A (en) Model rendering method and device, computer equipment and storage medium
CN117911600A (en) Method and device for generating stylized hand-drawing effect, storage medium and electronic device
CN115082615B (en) Rendering method, rendering device, computer equipment and storage medium
CN114494548A (en) Method, device and electronic device for generating virtual model
CN114972648A (en) Model rendering method, device, computer equipment and storage medium
CN116112657B (en) Image processing method, image processing device, computer readable storage medium and electronic device
CN114445558B (en) Image generation method, device, electronic equipment and storage medium
CN114998505A (en) Model rendering method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载