A method for editing and rendering virtual hair

By using intermediate texture maps and visual windows in the game development engine to edit and render virtual hair, the problem of cumbersome hair production process and dull generation effects in the existing technology is solved, precise control of hair and natural realistic effects are achieved, simplifying the production process and improving efficiency.

CN119784914APending Publication Date: 2025-04-08BEIJING XUEJING TECHNOLOGY CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411866446.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The prior art is cumbersome and time-consuming to make hand-made hairs. The hair generated by the algorithm is too dull, lacks natural and realistic effects, and the production process is complicated.

Method used

By importing the basic hair model in the game development engine, using intermediate texture maps for preliminary rendering, and interactively editing in the visualization window, adjusting hair properties and storing them into the intermediate material, and finally reconstructing and rendering hair effects through the shader sampling texture map during the rendering stage.

Benefits of technology

It realizes precise control of hair and natural realistic effects, while simplifying the production process and improving production efficiency, suitable for high-demand graphics and animation projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784914A_ABST
    Figure CN119784914A_ABST
Patent Text Reader

Abstract

The present application provides a method for editing and rendering virtual hair, wherein after obtaining a basic hair model, the method imports it into a game development engine, and uses an intermediate material to preliminarily render it into a visualization window; then the hair model is visually edited in the visualization window, and the modified attribute values ​​are encoded and stored in the intermediate material. In the real-time rendering stage, the shader in the rendering pipeline decodes the hair attributes from the intermediate material, reconstructs the hair effect based on these attributes, and performs the final rendering. The embodiment of the present application ensures the freedom and accuracy of creation and significantly improves the production efficiency by directly performing visual editing in the engine. At the same time, the storage method based on intermediate texture encoding provides a flexible and efficient solution for the production and rendering of hair effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a virtual hair editing and rendering method, a computing device, and a computer-readable storage medium. Background Art

[0002] In the field of 3D modeling, generating and rendering natural and realistic hair structures has always been an important challenge. The existing technology for the production of virtual hair is usually directly manually produced in DCC modeling tools, and the direction, length, density and other properties of the hair are finely controlled to generate high-quality and realistic hair effects; but manual production of hair is a very tedious and time-consuming task, requiring artists to have rich technical experience and a high degree of meticulousness. The overall production cycle is too long and the effect cannot be seen directly in the rendering engine. In addition, hair can also be generated through algorithms in game engines. Although the production process is relatively simple, the generated hair is too rigid, and the hair in different parts cannot be differentiated and stylized. Therefore, there is an urgent need for a new type of hair editing and rendering method that can not only achieve precise control of hair and natural and realistic effects, but also simplify the production process. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a virtual hair editing and rendering method, a computing device and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of the present application, a method for editing and rendering virtual hair is provided, comprising:

[0005] Obtaining a hair model and importing it into a game development engine to complete preliminary rendering of the hair model;

[0006] Adjusting the properties of hair in any area in the visualization window of the game development engine and saving them in an intermediate material;

[0007] The intermediate material is obtained in the rendering stage to complete the rendering of the hair model.

[0008] According to a second aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the method for editing and rendering virtual hair when executing the instructions.

[0009] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the method for editing and rendering virtual hair are implemented.

[0010] In an embodiment of the present application, after obtaining the basic hair model, it is imported into the game development engine and initially rendered into a visualization window using a material containing an intermediate texture map; then the hair model is visually edited in the visualization window, and the modified attribute values ​​are encoded and stored in the RGB channel of the intermediate texture map. Therefore, in the real-time rendering stage, the shader in the rendering pipeline samples the intermediate texture map, decodes the hair attributes from the RGB channel of the texture, and then reconstructs the hair effect based on these attributes and performs the final rendering. By directly visually editing the basic hair model in the engine, the embodiment of the present application not only ensures the freedom and accuracy of creation, but also significantly improves the production efficiency. At the same time, the storage method based on intermediate texture encoding provides a flexible and efficient solution for the production and rendering of hair effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;

[0012] Figure 2 It is a flowchart of a method for editing and rendering virtual hair provided in an embodiment of the present application;

[0013] Figure 3 It is a schematic diagram of a visualization window in a game development engine provided in an embodiment of the present application. DETAILED DESCRIPTION

[0014] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0015] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0016] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".

[0017] In the present application, a virtual hair editing and rendering method, a computing device and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0018] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.

[0019] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0020] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0021] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.

[0022] In the prior art, whether it is manual production through DDC modeling or algorithmic generation of hair in the engine, each has significant limitations. Although manual production can generate high-quality hair, the process is cumbersome and time-consuming. Although algorithmic generation is efficient, the generated hair often lacks naturalness and fineness, especially for projects that require a high degree of realism and detail. For example, multi-layer virtual hair rendering is a method of simulating hair through visual effects rather than the geometry itself. It relies on mapping technology and vertex offset to generate the appearance of hair. By rendering multiple layers of translucent textures on the surface of the model, each layer represents a part of the hair, and superimposed together to produce a hair-like effect; then using vertex offset technology, the thickness and texture of the hair are simulated by offsetting the vertices (such as CN114119821A). Although this method reduces the number of rendered geometries and has low computational and rendering overheads, when the camera is close to the model, since the hair is only a virtual image generated by the visual superposition effect, this method will have defects or flaws, which reduces the realism of the hair.

[0023] Therefore, the embodiment of the present application provides a method for editing and rendering virtual hair. By combining manual design with intelligent algorithms, the method can achieve precise control of hair and natural and realistic effects, while simplifying the production process. Through the embodiment of the present application, the main defects in the prior art are overcome, the efficiency and quality of hair generation and rendering are greatly improved, and it is suitable for various high-demand graphics and animation projects. The flowchart of a method for editing and rendering virtual hair provided in the embodiment of the present application is as follows: Figure 2 As shown, the method includes steps 202 to 206.

[0024] Step 202: Obtain the hair model and import it into the game development engine to complete the preliminary rendering of the hair.

[0025] In this step, first obtain a basic hair structure model created by an artist using DDC modeling software (such as Maya, Blender, ZBrush, etc.). The hair structure model can be a line-based model or a patch-based model, which is used to determine the basic shape and direction of the hair.

[0026] Furthermore, the prepared hair model is imported into a game development engine (such as Unity or Unreal Engine), and a material suitable for hair is selected or created, including basic properties of hair, such as color, glossiness, transparency, etc. The material is applied to the hair model, and lighting and shadow effects are implemented through the rendering settings of the game engine to achieve a preliminary hair rendering effect.

[0027] When performing preliminary hair rendering, it is rendered into a visualization window of the game development engine, in which various properties of the hair can be previewed and adjusted in real time, such as Figure 3 The process of implementing this visualization window in the game development engine includes:

[0028] Create an editor window: Use the editor scripting API provided by the game engine to create a new editor window, such as Unity's EditorWindow class or Unreal Engine UMG (Unreal Motion Graphics).

[0029] Data Binding: Bind controls to the properties of the hair model. In Unity, you can use SerializedObject and SerializedProperty to access and modify object properties.

[0030] Real-time Rendering: Enable real-time rendering in the editor to ensure that when properties change, the scene is instantly updated to show the new hair effects.

[0031] Step 204: Adjust the properties of the hair in any area in the visualization window of the game development engine and save them in the intermediate material.

[0032] In step 202, when the hair model is imported into the game development engine and the preliminary rendering is completed, it is rendered into the visualization window of the game development engine, and the visualization window supports interactive editing functions, allowing developers to finely edit the hair properties of objects in the rendering scene through mouse operations, such as length, direction and density. During the editing process, the effect can also be previewed in real time through the visualization window, avoiding the problem of delayed effect feedback in traditional manual production.

[0033] Furthermore, the above interactive editing function is implemented through the following steps:

[0034] Step 402: Detect the user's input in the visualization window, such as determining the hair area to be modified based on the mouse operation.

[0035] Specifically, when the user clicks or drags the mouse in the visualization window, the ray casting technique is used to convert the 2D screen coordinates of the mouse click into a ray in the 3D world space. This ray is used to detect the collision point with the hair model in the scene to determine which area of ​​the hair model the user has selected.

[0036] Step 404: Modify the hair attributes of the selected area.

[0037] The specific hair model selection area is determined by the collision points detected by ray casting, and the UV coordinates of the area on the model surface are obtained; these UV coordinates are the coordinates on the texture map, which are used to locate the specific area that needs to be modified on the texture map. The UV coordinates can be used to accurately locate the part of the hair model that needs to be modified in terms of attributes.

[0038] Step 406: Store the modified hair attributes into the RGB channels of the intermediate texture map.

[0039] Furthermore, the pixel positions on the intermediate texture map are determined by UV coordinates, and then the hair attributes are modified at these positions. In this step, the modification of hair direction, length, density and other attributes is achieved through mouse operation.

[0040] For example, after detecting the mouse drag event and calculating the moving direction of the mouse drag, the calculated moving direction is applied to the pixels on the intermediate texture map by traversing the UV coordinates in a determined area to modify multiple attributes of the hair.

[0041] In a possible implementation, the length of the hair is modified by the R channel of the first texture map:

[0042] if(isStarting2)

[0043] {

[0044] if(Vector3.Dot(Vector3.up,moveDir2)>0)

[0045] {

[0046] initV.x+=moveDir2.magnitude; / / When the mouse moves upward, increase the length

[0047] }

[0048] else if(Vector3.Dot(Vector3.up,moveDir2)<0)

[0049] {

[0050] initV.x-=moveDir2.magnitude; / / When the mouse moves down, the length decreases

[0051] }

[0052] nowColor.r = initV.x; / / Store the length modification information in the R channel of the first texture map

[0053] }

[0054] Furthermore, the density of the hair is modified by adjusting the G channel of the first texture map:

[0055] else if(isStarting3)

[0056] {

[0057] if(Vector3.Dot(Vector3.up,moveDir2)>0)

[0058] {

[0059] initV.y+=moveDir2.magnitude; / / When the mouse moves upward, the density increases

[0060] }

[0061] else if(Vector3.Dot(Vector3.up,moveDir2)<0)

[0062] {

[0063] initV.y-=moveDir2.magnitude; / / When the mouse moves down, the density decreases

[0064] }

[0065] nowColor.g = initV.y; / / Store density modification information to the R of the first texture map

[0066] aisle

[0067] }

[0068] Furthermore, for the hair direction information with three directions, the RGB channels of the second texture map are used to store the offset of the hair direction in the model space; wherein, since the channel cannot store negative numbers, and the offset vector of the hair direction may be negative; therefore, the offset vector is normalized and its value is mapped to between 0 and 1.

[0069] Vector3 initV=initColors[index++];

[0070] Color nowColor=meshTex2D.GetPixel(i,j);

[0071] if(isStarting1)

[0072] {

[0073] initV+=moveDir2;

[0074] initV=(initV+Vector3.one) / 2.0f;

[0075] nowColor.r = initV.x;

[0076] nowColor.g = initV.y;

[0077] nowColor.b = initV.z;

[0078] }

[0079] The above modification information is saved to the corresponding texture map file to complete the editing of the hair attributes. For example, the modification of the hair direction is saved to the second texture map _FurDirection, and the modification of the hair length and density is saved to the first texture map _FurMask.

[0080] In a possible implementation, the hair model includes one or more default intermediate texture maps.

[0081] Step 206: Obtain the generated intermediate material during the rendering stage to complete the rendering of the hair model.

[0082] In the rendering stage, the intermediate texture map in the material generated in step 204 is read in the shader, and then the rendering of the hair is completed according to the RGB channel values ​​of the texture map.

[0083] The rendering steps for the length and density of the hair (_FurMask) include:

[0084] (1) Sample the first texture map to obtain the color value according to the UV coordinates:

[0085] float4 maskColor=tex2Dlod(_FurMask,float4(uvav,0,0));

[0086] (2) Length control (R channel): Get the R channel value of the color value, determine the scaling ratio of the hair length based on the R channel value, and calculate the actual length of each hair segment based on the scaling ratio:

[0087] float finLengthRate=maskColor.r*10;

[0088] float finStep=_FinLength*finLengthRate / _FinJointNum;

[0089] (3) Density control (G channel): Get the G channel value of the color value and calculate the hair spacing coefficient:

[0090] float density=maskColor.g;

[0091] float uvXScale=length(uv0-uv12)*_Density*density;

[0092] Furthermore, the rendering steps for the hair direction (_FurDirection) include:

[0093] (1) Sample the second texture map according to the UV coordinates to obtain the color value of each channel:

[0094] float4 dirColor=tex2Dlod(_FurDirection,float4(uvav,0,0));

[0095] (2) Direction conversion: Convert the [0,1] range to the [-1,1] range and multiply by 10 to increase the strength of the direction offset:

[0096] dirColor.rgb=(2.0*dirColor.rgb-float3(1.0,1.0,1.0))*10;

[0097] (3) Direction synthesis: Mix the mapping direction with the initial growth direction and standardize to ensure the unit length of the final direction:

[0098] dir+=dirColor.rgb;

[0099] dir = normalize(dir);

[0100] Among them, the normal is used as the initial growth direction, float3 dir=normalOS0; normalOS0 is the normal of the object space. The basic growth direction of the hair is first based on the normal of the model surface, which ensures that the hair initially grows perpendicular to the surface. The hair in different areas will show different growth directions according to the direction map, which can achieve the natural bending and distribution effect of the hair.

[0101] Furthermore, these parameters are applied when generating vertices in the shader, and the vertices are added to the TriangleStream stream, thereby completing the rendering of the hair model.

[0102] In the above-mentioned embodiment of the present application, in order to realize efficient hair model production and corresponding rendering process, after obtaining the basic hair model, it is imported into the game development engine and initially rendered to the visualization window using the material containing the intermediate texture map, and these intermediate texture maps are used as the storage carrier of the attribute data; then the hair model is visually edited in the visualization window, for example, by calculating the moving distance of the mouse to modify the attributes of the hair in the target area, and the modified attribute values ​​are encoded and stored in the RGB channel of the intermediate texture map. Therefore, in the real-time rendering stage, the shader in the rendering pipeline samples the intermediate texture map, decodes the hair attributes from the RGB channel of the texture, and reconstructs the hair effect based on these attributes and performs the final rendering. The embodiment of the present application not only avoids the time-consuming and laborious problem of pure manual production, but also overcomes the defect of the rigid and single pure programmatic generation; by directly performing visual editing in the engine, it not only ensures the freedom and accuracy of creation, but also significantly improves the production efficiency. At the same time, the storage method based on the intermediate texture encoding ensures the efficient management and transmission of data, and provides a flexible and efficient solution for the production and rendering of hair effects.

[0103] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the virtual hair editing and rendering method are implemented.

[0104] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned virtual hair editing and rendering method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned virtual hair editing and rendering method.

[0105] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of a virtual hair editing and rendering method as described above.

[0106] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned virtual hair editing and rendering method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned virtual hair editing and rendering method.

[0107] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0108] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0109] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0110] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0111] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. A method for editing and rendering virtual hair, characterized in that: include: Obtaining a hair model and importing it into a game development engine to complete preliminary rendering of the hair model; Adjusting the properties of hair in any area in the visualization window of the game development engine and saving them in an intermediate material; The intermediate material is obtained in the rendering stage to complete the rendering of the hair model.

2. The method according to claim 1, wherein: The initial rendering of the hair model imported into the game development engine includes: When the hair model is initially rendered, it is rendered into a visualization window of the game development engine based on the API of the game development engine, and the preview and attribute editing of the hair model are implemented in the visualization window.

3. The method according to claim 1, wherein: The method of adjusting the properties of hair in any area in the visualization window of the game development engine and saving them in the intermediate material includes: detecting user input and determining a target hair area in the visualization window; Modifying the hair attributes of the target hair area according to the user operation; Store the modified fur attributes into the RGB channels of the intermediate texture map.

4. The method according to claim 3, wherein: Modification of the hair attributes of the target hair area according to user operations includes: Detect the mouse drag event and calculate the moving direction of the mouse drag, traverse the UV coordinates in the target hair area, and apply the moving direction to the pixels on the intermediate texture map as the modification value of the hair attribute.

5. The method according to claim 4, wherein: Storing the modified fur attributes into the RGB channels of the intermediate texture map includes: Storing the length information of the hair into the first channel of the first intermediate texture map; Storing the density information of the hair into the second channel of the first intermediate texture map; Store the hair's direction offset vector into the RGB channels of the second intermediate texture map.

6. The method according to claim 5, wherein: The step of storing the direction offset vector of the hair into the RGB channel of the second intermediate texture map comprises: After normalizing the offset vector, the x, y, and z components of the offset vector are respectively saved in the R, G, and B channels of the second intermediate texture map.

7. The method according to claim 1, wherein: The step of obtaining the intermediate material in the rendering stage and completing the rendering of the hair model includes: The intermediate texture map of the intermediate material is sampled in the shader, and vertices are constructed according to the RGB channel values ​​of the intermediate texture map to complete the rendering of the hair.

8. The method according to claim 1, wherein: The hair model is a basic hair structure model created in advance using 3D modeling software, and the basic hair structure model includes the intermediate material.

9. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method according to any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Hair rendering method, device and equipment for virtual object

    CN114119821A