Virtual hair rendering method and device, electronic equipment and readable storage medium
By constructing a wrapping model on the surface of the virtual hair model and determining the target vertex normal, the problem of poor hair effect at the sharp corners of the low-face hair model in mobile games is solved, and a uniform and neat hair effect is achieved, avoiding the disadvantages of increasing rendering burden and development cost.
Patent Information
- Application Number
- CN202411968512.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-06-03
AI Technical Summary
In mobile games, due to device performance limitations, the hair effects at the sharp corners of the low-face hair model often have bad phenomena such as frying, disordered order, and interlacing. The existing technology improves the effect through surface addition but increases the rendering burden and development cost.
By constructing a wrapping model on the surface of the virtual hair model, the model surface rules are used to determine the target vertex normal based on the positional relationship between the wrapping model and the target model area, and hair rendering is performed based on the preset hair material to generate uniform and neat virtual hair.
It effectively improves the hair effect of the virtual hair model, avoids the adverse hair effect caused by uneven distribution of vertex normals, and avoids the disadvantages of increasing the number of model faces and development costs.
Smart Images

Figure CN120088379A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graphics rendering technology, and in particular to a method, apparatus, electronic device, and computer-readable storage medium for rendering virtual hair. Background Art
[0002] In mobile games, due to the limitations of mobile device performance, the number of faces of virtual models cannot be too large. At the sharp corners of the hair material model with a low number of faces, the hair always shows bad effects such as frizzy, disordered, and interpenetrating. In related technologies, the sharp corners of the low-face model are added with faces to make the sharp corners round, so as to improve the hair effect. However, this will increase the number of faces of the model, thus increasing the rendering burden, resulting in more consumption of mobile memory and computing resources; and, adding faces to the model requires additional design and debugging work, increasing the development time and cost. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, and computer-readable storage medium for rendering virtual hair to optimize the hair performance at the sharp corners of the virtual hair model.
[0004] In a first aspect, an embodiment of this application provides a method for rendering virtual hair, the method includes:
[0005] Determine a virtual hair model, where the virtual hair model includes at least one irregular end;
[0006] Construct a wrapping model on the surface of the virtual hair model to wrap a target model area on the virtual hair model, so that the model surface of the virtual hair model is regular, where the target model area includes at least the irregular end, the target model area includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices;
[0007] Based on the positional relationship between the wrapping model and the target model area, determine target second vertices that match each of the first vertices from the plurality of second vertices;
[0008] Render the virtual hair model based on a preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, so as to generate corresponding virtual hair on the virtual hair model.
[0009] In a second aspect, an embodiment of this application provides a device for rendering virtual hair, the device includes:
[0010] An acquisition module, configured to determine a virtual hair model, where the virtual hair model includes at least one irregular end;
[0011] A processing module, configured to construct a wrapping model on the surface of the virtual hair model for wrapping a target model area on the virtual hair model, so as to regularize the model surface of the virtual hair model, where the target model area at least includes the irregular end, the target model area includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices;
[0012] A determination module, configured to determine, based on the positional relationship between the wrapping model and the target model area, target second vertices that match each of the first vertices from the plurality of second vertices;
[0013] A rendering module, configured to perform hair rendering on the virtual hair model based on a preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, so as to generate corresponding virtual hair on the virtual hair model.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, where the electronic device includes:
[0015] A memory and a processor, the memory and the processor being coupled;
[0016] The memory is used to store one or more computer instructions;
[0017] The processor is configured to execute the one or more computer instructions to implement the virtual hair rendering method according to any one of the first aspects above.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which one or more computer instructions are stored, and is characterized in that the instructions are executed by a processor to implement the virtual hair rendering method according to any one of the first aspects above.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, where the computer program implements the virtual hair rendering method according to any one of the first aspects above when executed by a processor.
[0020] Compared with the prior art, the present application has the following advantages:
[0021] The virtual hair rendering method provided by this application determines a virtual hair model, where the virtual hair model includes at least one irregular end; a wrapping model for wrapping a target model area on the virtual hair model is constructed on the surface of the virtual hair model to make the model surface of the virtual hair model regular, where the target model area includes at least the irregular end, the target model area includes multiple first vertices, and the wrapping model includes multiple second vertices; based on the positional relationship between the wrapping model and the target model area, target second vertices matching each of the first vertices are determined from the multiple second vertices; based on a preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, the virtual hair model is rendered with hair to generate corresponding virtual hair on the virtual hair model.
[0022] Compared with the prior art, this application constructs a wrapping model on the surface of the virtual hair model to wrap the target model area on the virtual hair model, so that the model surface of the virtual hair model is regular. For the model vertices in the non-target model area of the virtual hair model, the vertex normal of the model vertex uses the original vertex normal of the model vertex. However, for each first vertex in the target model area of the virtual hair model, the vertex normal of the target second vertex matching the first vertex is used to replace the vertex normal of the first vertex. In this way, based on the preset hair material, virtual hair with a very uniform, neat, and non-intersecting distribution can be generated on the virtual hair model, avoiding bad hair effects such as frizzy hair, disorder, and intersection caused by uneven distribution of vertex normals and mutual intersection, and greatly improving the hair effect. Description of the Drawings
[0023] The drawings described herein are used to provide a further understanding of this application and form a part of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation to this application. In the drawings:
[0024] Figure 1 It is a schematic diagram of the effect of adding hair material to a low-polygon model after face addition processing in the prior art;
[0025] Figure 2 It is a schematic flowchart of the virtual hair rendering method provided by one embodiment of this application;
[0026] Figure 3 It is a schematic diagram of the hair effect at the irregular end of a 3D model provided by one embodiment of this application;
[0027] Figure 4 It is a schematic diagram of the hair effect of a virtual hair model with a regular surface contour provided by one embodiment of this application;
[0028] Figure 5 Schematic diagram of the vertex normal of the package model and the virtual hair model before and after updating the vertex normal provided by one embodiment of the present application;
[0029] Figure 6 Schematic diagram of the virtual hair and the corresponding package model provided by one embodiment of the present application;
[0030] Figure 7 Effect diagram of the generated virtual hair provided by one embodiment of the present application;
[0031] Figure 8 Schematic diagram of the operations performed for drawing the hair flow direction on the virtual hair model after generating the virtual hair provided by one embodiment of the present application;
[0032] Figure 9 Hair flow direction diagram corresponding to a virtual hair model provided by one embodiment of the present application;
[0033] Figure 10 Schematic diagram of the structure of the rendering device for virtual hair provided by one embodiment of the present application;
[0034] Figure 11 Schematic diagram of the hardware structure of the electronic device provided by one embodiment of the present application.
[0035] Through the above-mentioned drawings, the clear embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and text descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0036] To make the objectives, advantages and features of the present application clearer, the present application will be clearly and completely described below in conjunction with the drawings and specific implementation manners. In the following description, many specific details are set forth to fully understand the present application. However, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present application.
[0037] It should be noted that in the description of this application, terms such as "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance, as well as a specific order or sequence. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances. In addition, in the description of this application, unless otherwise specified, the term "plural" means two or more. The term "and / or" describes the association relationship of associated objects and indicates that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0038] Next, the prior art related to this application and the problems existing in the prior art will be described:
[0039] In mobile games, since the performance of mobile devices is generally lower than that of computers or game consoles, their processing power for graphics resources is limited. Therefore, it is required that the number of faces of virtual models in mobile games cannot be too large to avoid more memory occupation and higher CPU / GPU load, which may cause problems such as frame rate drop and device heating. For elements such as hair that are rich in details and require a large number of polygons to represent, the hair at the sharp corners of the low-polygon hair material model always shows bad effects such as frizzy, disordered, and interpenetrating.
[0040] In the related art, the sharp corners of the low-polygon model are added with faces to make the sharp corners round, thereby improving the hair effect. As Figure 1 shown, the three-dimensional model after face addition and the effect diagrams before and after adding hair material to the three-dimensional model after face addition. Among them, the sharp corners of the three-dimensional model after face addition become more rounded, and adding hair material to the three-dimensional model after face addition avoids bad hair effects such as frizzy and disordered due to sharp corners to a certain extent. Figure 1 FIG. is a schematic diagram of the effect of adding hair material to a low-polygon model after face addition in the prior art.
[0041] However, the above-mentioned related art will increase the number of faces of the model, thereby increasing the rendering burden, resulting in more consumption of mobile memory and computing resources. In addition, adding faces to the model requires additional design and debugging work, increasing the development time and cost.
[0042] Based on the above existing problems, in order to optimize the sharp hair effect of the low polygon hair model, the present application provides a rendering method for virtual hair, a rendering device for virtual hair corresponding to the method, an electronic device capable of implementing the rendering method for virtual hair, and a computer-readable storage medium. The following provides embodiments to describe the above method, device, electronic device, and computer-readable storage medium in detail.
[0043] In order to make the purpose and technical solution of the present application more clearly intuitive, the method provided by the embodiments of the present application will be described in detail below in conjunction with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. It can be understood that the following several embodiments can exist independently, and the following embodiments and the features in the embodiments can be combined with each other without conflict. For the same or similar content, it will not be repeated in different embodiments. In addition, the step timing in the following method embodiments is only an example and is not strictly limited. In some cases, the steps shown or described can be executed in a different order.
[0044] The present application provides a rendering method, device, electronic device, and computer-readable storage medium for virtual hair. Specifically, the rendering method for virtual hair in one embodiment of the present application can be executed by a computer device, where the computer device can be a terminal or a server, etc. The terminal can be a terminal device such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, etc. The terminal can also include a client, and the client can be a game application client, a browser client carrying a game program, or an instant messaging client, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0045] Next, in conjunction with Figure 2 , the rendering method for virtual hair provided in one embodiment of the present application will be described. Figure 2 is a schematic flowchart of the rendering method for virtual hair provided in one embodiment of the present application.
[0046] As Figure 2 shown, the rendering method for virtual hair includes steps S10 - S40:
[0047] S10. Determine a virtual hair model, where the virtual hair model includes at least one irregular end.
[0048] S20. Construct a wrapping model on the surface of the virtual hair model to wrap the target model area on the virtual hair model, so as to regularize the model surface of the virtual hair model. The target model area includes at least an irregular end, the target model area includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices.
[0049] S30. Based on the positional relationship between the wrapping model and the target model area, determine the target second vertices that match each first vertex from the plurality of second vertices.
[0050] S40. Based on the preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, perform hair rendering on the virtual hair model to generate corresponding virtual hairs on the virtual hair model.
[0051] Next, the above steps S10 - S40 will be described in detail.
[0052] As described above, the virtual hair model belongs to a three - dimensional model for which hair is to be generated. The virtual hair model includes a plurality of model vertices, and adjacent model vertices are connected to form polygon patches. The number of the formed polygon patches is less than a preset number threshold. The polygon patches are connected to form the surface contour of the virtual hair model, and the surface contour of the virtual hair model includes at least one irregular end. Here, the irregular end refers to an end with an irregular and sharp edge shape in some model areas of the virtual hair model.
[0053] Each vertex in the three - dimensional model has a vertex normal. This vertex normal is a vector that first points from the vertex to the outside of the model surface, and this vector represents the normal direction of the surface where the vertex is located. For a three - dimensional model with at least one irregular end, the vertex normals of the vertices at the irregular ends in the three - dimensional model may be discontinuous or change sharply in direction. Since the hair growth direction of the hair material is based on the orientation of the vertex normals, this will cause a sudden change in the hair growth direction at the irregular places of the three - dimensional model, resulting in bad hair effects such as frizzy hair, disordered order, and interpenetration. Especially for a three - dimensional model with a low number of faces, if the number of polygon faces is too small, it is more likely to be unable to accurately represent complex geometric shapes, especially at the irregular ends of the three - dimensional model.
[0054] Exemplarily, as Figure 3 shown, the surface of the virtual hair model has multiple irregular ends. After adding the hair material to the virtual hair model, the hairs growing at the tips in the virtual hair model show a messy hair effect. Among them, Figure 3 This is a schematic diagram of the hair effect at the irregular ends in the three - dimensional model provided by one embodiment of the present application.
[0055] However, for a virtual hair model with a regular surface contour (i.e., a virtual hair model with a regular shape and wiring), its vertex normals are evenly distributed perpendicular to the gimbal, and there is no intersection between the vertex normals. Therefore, after adding a hair material, as Figure 4 shown, the hair growing on the surface of the virtual hair model will be very uniform and neat, without any bad effects such as frizzy hair, disorder, and intersection. Figure 4 FIG. is a schematic diagram of the hair effect of a virtual hair model with a regular surface contour provided by one embodiment of the present application.
[0056] In the embodiment of the present application, in order to avoid the above-mentioned bad hair effects. For the virtual hair model, a wrapping model is constructed to wrap the target model area on the virtual hair model, so that the model surface of the virtual hair model is regular. Among them, the target model area at least includes an irregular end, and the target model area includes a plurality of first vertices. The wrapping model includes a plurality of second vertices, and adjacent second vertices are connected to each other to form polygon patches, and the polygon patches are connected to each other to form a smooth surface contour of the wrapping model edge, and the wrapping model can completely wrap the virtual hair model. Preferably, the angle between adjacent polygon patches in the wrapping model is an obtuse angle, which can avoid unnatural protrusions or sharp corners on the surface of the wrapping model, so as to ensure smoother transitions between polygon patches on the surface of the wrapping model.
[0057] It should be noted that since the edge of the wrapping model is smooth, the vertex normals of the wrapping model are evenly distributed and there is no intersection between the vertex normals. As Figure 5 shown in (a) of FIG., the virtual hair model and the vertex normals of the model vertices of the virtual hair model, the wrapping model and the vertex normals of the second vertices on the wrapping model. Among them, taking area 1 in the virtual hair model as an example, the vertex normals of the model vertices in area 1 (i.e., the target model area with an irregular end) in the virtual hair model are distributed disorderly, the vertex normal directions are relatively messy, and there is intersection between them. Taking area 2 in the wrapping model as an example, the vertex normals of the second vertices in area 2 (i.e., the area used to wrap area 1 in the virtual hair model) in the wrapping model are evenly distributed and there is no intersection between the vertex normals.
[0058] Next, two possible implementation methods for constructing a wrapping model for wrapping the target model area on the virtual hair model will be described by way of example.
[0059] An alternative implementation method is to first construct an initial wrapping model based on the topological structure of the virtual hair model. Subsequently, based on the target model area on the virtual hair model, the topological structure of the initial wrapping model is adjusted to obtain a wrapping model for wrapping the target model area on the virtual hair model.
[0060] In the embodiments of the present application, 3D modeling software (such as Blender, 3ds Max, Maya, etc.) can be used to construct an initial wrapping model with the same topological structure as the virtual hair model based on the topological structure of the virtual hair model. Subsequently, based on the target model area on the virtual hair model, the topological structure of the initial wrapping model is adjusted. For example, the topological structure of the wrapping model area in the wrapping model that wraps the target model area in the virtual hair model is adjusted, such as adjusting the positions of vertices or edges, and the surface of the model is smoothed using a smoothing tool (such as the Smooth Tool in Blender) to ensure that the edges are smooth and there are no sharp corners, and to ensure that the angle between two adjacent polygon patches is greater than 90 degrees to form an obtuse transition, thereby obtaining a wrapping model that wraps the target model area on the virtual hair model.
[0061] By adjusting based on the topological structure of the virtual hair model, it can be ensured that the wrapping model precisely adapts to the shape of the virtual hair model, avoiding unnecessary gaps or overlaps. Adjusting the topological structure provides a high degree of flexibility and can be finely adjusted according to specific requirements. Through the processing of the smoothing tool, it can be ensured to obtain a wrapping model that wraps the target model area on the virtual hair model.
[0062] In another alternative embodiment, first, a preset geometric model similar to the geometric shape of the virtual hair model is obtained. Subsequently, based on the target model area on the virtual hair model, the preset geometric model is deformed to obtain a wrapping model that wraps the target model area on the virtual hair model.
[0063] In the embodiments of the present application, first, a preset geometric model similar to the geometric shape of the virtual hair model is selected. For example, if the virtual hair model is a head model, a standard head geometric model can be selected. The preset geometric model is placed near the virtual hair model to ensure that it generally wraps the virtual hair model. Based on the target model area on the virtual hair model, deformation tools (such as the Proportional Editing Tool, Lattice Modifier, Shrinkwrap Modifier in Blender) are used to deform the area in the preset geometric model that is used to wrap the target model area in the virtual hair model, so that while the preset geometric model wraps the target model area in the virtual hair model, it better adapts to the shape of the virtual hair model. The surface of the model is smoothed using a smoothing tool (such as the Smooth Tool in Blender) to ensure that the edges are smooth and there are no sharp corners, and to ensure that the angle between two adjacent polygon patches is greater than 90 degrees to form an obtuse transition.
[0064] By using a preset geometric model, a wrapping model that roughly conforms to the shape of the virtual hair model can be quickly generated, saving time and effort. Based on the target model area on the virtual hair model, the shape of the model can be automatically adjusted through a deformation tool, reducing the workload of manual adjustment. And through processing with a smoothing tool, while making the preset geometric model wrap the target model area in the virtual hair model, it can better adapt to the shape of the virtual hair model.
[0065] Next, in conjunction with Figure 6 , an exemplary description will be given of the wrapping model created for the virtual hair model. Figure 6 FIG. is a schematic diagram of virtual hair and a corresponding wrapping model provided in an embodiment of the present application.
[0066] As Figure 6 shows two sets of examples, each set of examples includes a virtual hair model and its corresponding wrapping model. As Figure 6 shown, taking the irregular end 1 in the virtual hair model 1 in Example 1 as an example, the model area in the virtual hair model 1 with the irregular end 1 is wrapped by the wrapping model 1. Taking the irregular end 2 in the virtual hair model 2 in Example 2 as an example, the model area in the virtual hair model 2 with the irregular end 2 is wrapped by the wrapping model 2.
[0067] In an embodiment of the present application, after constructing a wrapping model for wrapping the target model area on the virtual hair model, based on the positional relationship between the wrapping model and the target model area, target second vertices matching each first vertex are determined from multiple second vertices. Subsequently, based on the preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, hair rendering is performed on the virtual hair model to generate corresponding virtual hair on the virtual hair model.
[0068] In this process, for the model vertices in the non-target model regions of the virtual hair model, the vertex normals of the model vertices adopt the original vertex normals of the model vertices. However, for the first vertices in each target model region of the virtual hair model, the vertex normals of the target second vertices that match the first vertices are used to replace the vertex normals of the first vertices. That is to say, the vertex normals of each first vertex are updated to the vertex normals of the target second vertices that match the first vertices. Since the distribution of the vertex normals of the second vertices in the wrapping model is uniform and there is no intersection between the vertex normals. Therefore, after updating the vertex normals of each first vertex to the vertex normals of the target second vertices that match the first vertices, the distribution of the vertex normals of the first vertices in the target model regions on the virtual hair model is also relatively uniform, and there is no intersection between the vertex normals. Based on the preset hair material, the virtual hair model with updated vertex normals is subjected to hair rendering. After the rendering is completed, virtual hair is generated on the virtual hair model, and the virtual hair growing on the surface of the virtual hair model is evenly distributed, neat, and without intersection, avoiding bad effects such as frizzy hair, disorder, and intersection caused by uneven distribution of vertex normals and intersection between them.
[0069] The virtual hair rendering method provided by the embodiment of the present application first determines a virtual hair model including at least one irregular end. Then, a wrapping model for wrapping the target model regions on the surface of the virtual hair model is constructed on the surface of the virtual hair model to make the model surface of the virtual hair model regular. Based on the positional relationship between the wrapping model and the target model regions, target second vertices that match each first vertex are determined from multiple second vertices. For the model vertices in the non-target model regions of the virtual hair model, the vertex normals of the model vertices adopt the original vertex normals of the model vertices. However, for the first vertices in each target model region of the virtual hair model, the vertex normals of the target second vertices that match the first vertices are used to replace the vertex normals of the first vertices. In this way, based on the preset hair material, virtual hair that is evenly distributed, neat, and without intersection can be generated on the virtual hair model, avoiding bad hair effects such as frizzy hair, disorder, and intersection caused by uneven distribution of vertex normals and intersection between them, and greatly improving the hair effect.
[0070] Based on the above embodiments, the virtual hair rendering method provided by the embodiment of the present application is further described below.
[0071] An optional implementation manner, a possible implementation manner of the above step S20 "Based on the positional relationship between the wrapping model and the target model regions, determine target second vertices that match each first vertex from multiple second vertices" includes step S201:
[0072] S201. For each first vertex in the target model area, determine the second vertex closest to the first vertex among multiple second vertices as the target second vertex that matches the first vertex.
[0073] In the embodiments of the present application, after aligning the positions and directions of the virtual hair model and the wrapping model, for each first vertex in the target model area of the virtual hair model, determine the second vertex closest to the first vertex among multiple second vertices in the wrapping model as the target second vertex that matches the first vertex. In this way, the vertex normals of the model area in the wrapping model that wraps the target model area are passed to the target model area in the virtual hair model, that is, the target model area in the virtual hair model inherits the vertex normals of the model area in the wrapping model that wraps the target model area.
[0074] After aligning the positions and directions of the virtual hair model and the wrapping model, for each first vertex in the target model area of the virtual hair model, determine the second vertex closest to the first vertex among multiple second vertices in the wrapping model as the target second vertex that matches the first vertex. In this way, the vertex normal of the target second vertex that matches the first vertex is used as the vertex normal of the first vertex, which can ensure that the vertex normal distribution in the target model area of the virtual hair model is uniform and without intersection.
[0075] It should be noted that before passing the vertex normals of the wrapping model to the virtual hair model, it must be ensured that the UV surface of the virtual hair model is positive, that is, the normal direction of the UV surface is consistent with the normal direction of the three-dimensional model surface. If the UV surface of the virtual hair model is reverse (that is, the normal direction of the UV surface is inconsistent with the normal direction of the three-dimensional model surface), it will cause a hair effect where the hair grows in the reverse direction when generating virtual hair for the virtual hair model subsequently.
[0076] An optional implementation manner. A possible implementation of step S30, "Render the virtual hair model based on the preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices", includes steps S301 - S302:
[0077] S301. Replace the vertex normal of the first vertex on the virtual hair model with the vertex normal of the target second vertex that matches the first vertex to obtain the virtual hair model with updated vertex normals.
[0078] S302. Render the virtual hair model with updated vertex normals based on the preset hair material.
[0079] Next, steps S301 - S302 will be described in detail.
[0080] In the embodiments of the present application, first, the wrapping model is aligned with the virtual hair model (i.e., in terms of position and orientation). The purpose of aligning the models is to ensure that the positions and orientations of the wrapping model and the virtual hair model in space are consistent, so that the transmitted vertex normal information can be accurately applied to the virtual hair model. After the two models are aligned, the vertex normal of the first vertex on the virtual hair model is replaced with the vertex normal of the corresponding and matching target second vertex, and the virtual hair model with updated vertex normals is obtained. In this way, the vertex normals in the target model area of the virtual hair model with updated vertex normals are consistent with the normal distribution and normal direction of the vertex normals in the model area of the wrapping model that includes the target model area. Since the vertex normals of the above-mentioned wrapping model are evenly distributed and there is no intersection between the vertex normals. Therefore, the vertex normals in the target model area of the virtual hair model with updated vertex normals are also evenly distributed and have no intersection.
[0081] Exemplarily, as Figure 5 shown in (b) of, taking area 2 in the wrapping model as an example, the vertex normals of the second vertices in area 2 of the wrapping model (i.e., the area used to wrap area 1 in the virtual hair model) are evenly distributed, and there is no intersection between the vertex normals. The vertex normals of the model vertices in area 1 (i.e., the target model area with irregular ends) in the virtual hair model with updated vertex normals are evenly distributed, and there is no intersection between the vertex normals.
[0082] In the embodiments of the present application, after updating the vertex normals of the virtual hair model based on the vertex normals of the wrapping model, based on a preset hair material, the virtual hair model with updated vertex normals is subjected to hair rendering, and virtual hair is generated on the virtual hair model after the rendering is completed.
[0083] Next, in combination with Figure 7 , an exemplary display and description are given of the hair effect of the virtual hair model with updated vertex normals after hair rendering, and virtual hair is generated on the virtual hair model after the rendering is completed. Figure 7 is the effect diagram of the generated virtual hair provided by one of the embodiments of the present application.
[0084] As Figure 7 shown, two groups of examples are presented. The virtual hair models in Example 1 and Example 2 are a head model and a leg model respectively. For Example 1 and Example 2, the original hair effect, the original vertex normals of the virtual hair model, the vertex normals of the wrapping model and the virtual hair model, the virtual hair model with updated vertex normals, and the hair effect of the virtual hair model after adding the hair material are respectively shown. As Figure 7 shown, in Example 1 and Example 2, compared with the original hair effect, the hair effect of the virtual hair model after adding the hair material is neater, and there are no bad effects such as frizzy hair, disorder, and intersection.
[0085] In particular, for a 3D model with a low polygon count, without increasing the polygon count, the rendering method of virtual hair provided by the present application can achieve very good performance in the hair effect produced by the virtual hair model, and can also meet the requirement of smooth operation on various mobile devices. At the same time, since the polygon count is not increased, the debugging difficulty of production staff can be reduced, repeated testing and verification can be minimized, production costs can be saved, and work efficiency can be improved.
[0086] An optional implementation manner, the rendering method of virtual hair provided by the embodiments of the present application further includes the step of: adjusting the vertex normal of the second vertex according to the preset hair growth direction of the target model area.
[0087] In the embodiments of the present application, after obtaining the wrapping model that wraps the target model area on the virtual hair model to make the model surface of the virtual hair model regular, the vertex normal of the second vertex in the model area that wraps the target model area in the wrapping model can also be adjusted according to the preset hair growth direction of the target model area (i.e., the desired hair growth direction). Since the hair growth direction is based on the vertex normal, adjusting the vertex normal of the second vertex in the wrapping model according to the preset hair growth direction helps the virtual hair growing on the virtual hair model after adding the hair material to have the same growth direction as the preset hair growth direction, achieving the expected effect.
[0088] An optional implementation manner, the rendering method of virtual hair provided by the embodiments of the present application further includes the following steps S501 and / or S502:
[0089] S501. When the distance between the first polygon patch and the second polygon patch in the virtual hair model is less than the first distance threshold, set the pixel value of the vertex color of the model vertices included in the first polygon patch and the second polygon patch to the first pixel value. Or,
[0090] S502. When the distance between the first polygon patch and the second polygon patch in the virtual hair model is greater than the second distance threshold, set the pixel value of the vertex color of the model vertices included in the first polygon patch and the second polygon patch to the second pixel value. Wherein, the hair length corresponding to the vertex color of the first pixel value is shorter than the hair length corresponding to the vertex color of the second pixel value.
[0091] In the embodiments of the present application, considering that if the distance between polygon patches in the virtual hair model is too close, this will cause hair to interpenetrate. The present application controls the length of virtual hair by controlling the vertex color of model vertices to avoid the phenomenon of hair interpenetration.
[0092] When the distance between the first polygon patch and the second polygon patch in the virtual hair model is less than the first distance threshold, it indicates that the distance between the first polygon patch and the second polygon patch is too close. In order to avoid the hair growing at the first polygon patch from intersecting with the hair growing at the second polygon patch, the pixel values of the vertex colors of the model vertices included in the first polygon patch and the second polygon patch are set to the first pixel value that controls the hair to be shorter. For example, the first pixel value can be the pixel value corresponding to black, and black is used to control the hair to be shorter.
[0093] When the distance between the first polygon patch and the second polygon patch in the virtual hair model is greater than the second distance threshold, it indicates that the distance between the first polygon patch and the second polygon patch is relatively far, indicating that the hair growing at the first polygon patch and the hair growing at the second polygon patch will not intersect. Then the hair growing at the first polygon patch and the second polygon patch can be relatively longer. Therefore, the pixel values of the vertex colors of the model vertices included in the first polygon patch and the second polygon patch are set to the second pixel value that controls the hair to be longer. For example, the second pixel value can be the pixel value corresponding to white, and white is used to control the hair to be longer.
[0094] In the embodiments of the present application, for example, by drawing vertex colors in 3ds Max to control the length of the hair, it can effectively avoid the hair from intersecting with each other caused by the polygon patches of the virtual hair model being too close to each other, and further improve the hair effect of the virtual hair model.
[0095] An optional implementation manner is that after step 301 "replace the vertex normal of the first vertex on the virtual hair model with the vertex normal of the target second vertex corresponding to the first vertex to obtain the virtual hair model with updated vertex normals", and after passing the vertex normal of the wrapped model to the virtual hair model to obtain the virtual hair model with updated vertex normals, the rendering method of the virtual hair provided by the embodiments of the present application further includes the following steps S601 - S602. A possible implementation manner based on steps S601 - S602 of step S40 includes step S603:
[0096] S601. Generate a hair flow map corresponding to the virtual hair model based on the virtual hair model with updated vertex normals.
[0097] S602. Adjust the hair flow in the hair flow map according to the preset hair flow direction.
[0098] S603. Render the model vertices in the virtual hair model with updated vertex normals based on the adjusted hair flow map and the preset hair material.
[0099] Next, steps S601 - S603 will be described in detail.
[0100] In the embodiment of the present application, based on the virtual hair model after updating the vertex normals, a hair flow map corresponding to the virtual hair model is generated. This hair flow map visually shows the flow direction of each hair growing on the virtual hair model. Obtaining the hair flow map can help developers understand and adjust the overall hair flow. After generating the hair flow map, the hair direction in the flow map can be adjusted according to the pre - set hair flow direction. This means that if it is desired for the hair to flow in a specific way, such as along the growth direction of the scalp or a specific wind direction, this can be achieved by modifying the arrows or lines in the flow map. Finally, using the adjusted hair flow map and the pre - set hair materials (such as color, glossiness, transparency, etc.), hair rendering is performed on each "model vertex" of the virtual hair model. A "model vertex" generally refers to the starting point or root of each hair. In this way, it can be ensured that the rendering of each hair conforms to the preset flow and material characteristics, making the entire virtual hair model look more realistic and natural.
[0101] Exemplarily, substance painter can be combined to draw a Flowmap (i.e., hair flow chart) to control the growth direction of detailed hair, making the hair growth smoother. Specifically, based on the normal information baked on the virtual hair model, in the substance painter software, as Figure 8 shown, when only checking "nrm", a small texture map with an rgb value of 128, 255, 128 needs to be pasted into the Normal and the path - following drawing setting method is opened. Figure 8 This is a schematic diagram of the operations performed for drawing the hair flow of the virtual hair model after generating virtual hair provided in one embodiment of the present application. The generated hair flow map can be referred to Figure 9 as Figure 9 shown. The direction indicated by the arrow on the virtual hair model (such as a cat 3D model) is the flow direction of the hair growing at the current position of the arrow. Among them, Figure 9 This is a hair flow map corresponding to a virtual hair model provided in one embodiment of the present application.
[0102] An alternative implementation manner is that the method for rendering virtual hair provided in the embodiment of the present application further includes the following steps after step S40: S70. Adjust the target style of the generated virtual hair, and the target style includes at least one of the following: length, thickness, color, and shadow.
[0103] In the embodiments of the present application, after generating virtual hair on the virtual hair model, by comprehensively adjusting the length, thickness, color, and shadow of the hair, the hair effect of the virtual hair model can be made visually closer to reality.
[0104] The rendering device for virtual hair provided by the present application will be described below. The rendering device for virtual hair described below can be mutually referred to corresponding to the rendering method for virtual hair described above.
[0105] Figure 10 It is a schematic structural diagram of the rendering device for virtual hair provided by one embodiment of the present application. As Figure 10 shown, the rendering device 1000 for virtual hair includes: an acquisition module 1001, a processing module 1002, an update module 1003, and a rendering module 1004.
[0106] The acquisition module is used to determine a virtual hair model, where the virtual hair model includes at least one irregular end;
[0107] The processing module is used to construct a wrapping model on the surface of the virtual hair model for wrapping a target model area on the virtual hair model, so that the model surface of the virtual hair model is regular, where the target model area includes at least the irregular end, the target model area includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices;
[0108] The determination module is used to determine, based on the positional relationship between the wrapping model and the target model area, a target second vertex that matches each of the first vertices from the plurality of second vertices;
[0109] The rendering module is used to perform hair rendering on the virtual hair model based on a preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertices, so as to generate corresponding virtual hair on the virtual hair model.
[0110] An alternative embodiment is characterized in that the determination module is specifically used for:
[0111] For each of the first vertices in the target model area, the second vertex closest to the first vertex among the plurality of second vertices is determined as the target second vertex that matches the first vertex.
[0112] An alternative embodiment is characterized in that the rendering module is specifically used for:
[0113] Replacing the vertex normal of the first vertex on the virtual hair model with the vertex normal of the target second vertex that matches the first vertex to obtain a virtual hair model with updated vertex normals;
[0114] Based on a preset hair material, perform hair rendering on the virtual hair model after updating the vertex normals.
[0115] An optional implementation, the processing module is specifically configured to:
[0116] Based on the topological structure of the virtual hair model, construct an initial wrapping model;
[0117] Based on the target model area on the virtual hair model, adjust the topological structure of the initial wrapping model to obtain a wrapping model that wraps the target model area on the virtual hair model.
[0118] An optional implementation, the processing module is specifically configured to:
[0119] Obtain a preset geometric model similar to the geometric shape of the virtual hair model;
[0120] Based on the target model area on the virtual hair model, deform the preset geometric model to obtain a wrapping model that wraps the target model area on the virtual hair model.
[0121] An optional implementation, the processing module is further configured to:
[0122] Adjust the vertex normal of the second vertex according to the preset hair growth direction of the target model area.
[0123] An optional implementation, the updating module is specifically configured to:
[0124] When the distance between the first polygon patch and the second polygon patch in the virtual hair model is less than the first distance threshold, set the pixel value of the vertex color of the model vertices included in the first polygon patch and the second polygon patch to the first pixel value; or,
[0125] When the distance between the first polygon patch and the second polygon patch in the virtual hair model is greater than the second distance threshold, set the pixel value of the vertex color of the model vertices included in the first polygon patch and the second polygon patch to the second pixel value;
[0126] Wherein, the hair length corresponding to the vertex color of the first pixel value is shorter than the hair length corresponding to the vertex color of the second pixel value.
[0127] An optional implementation, the device further includes an adjustment module, and the adjustment module is specifically configured to:
[0128] Based on the virtual hair model after updating the vertex normals, generate a hair flow map corresponding to the virtual hair model;
[0129] Adjust the hair flow direction in the hair flow map according to the preset hair flow direction.
[0130] Specifically, the rendering module is used for:
[0131] Perform hair rendering on the model vertices in the virtual hair model with updated vertex normals based on the adjusted hair flow map and the preset hair material.
[0132] In an optional implementation, the included angle between adjacent polygon patches in the wrapping model is an obtuse angle.
[0133] In an optional implementation, the adjustment module is further used for:
[0134] Adjust the target style of the generated virtual hair, where the target style includes at least one of the following: length, thickness, color, and shadow.
[0135] The virtual hair rendering device provided in this embodiment can be used to execute the technical solutions of the above-mentioned virtual hair rendering method embodiments. The implementation principles and technical effects are similar, and will not be elaborated here.
[0136] Figure 11 The following is a schematic hardware structure diagram of an electronic device provided in one embodiment of the present application. As Figure 11 shown, the electronic device 1100 in this embodiment includes: a processor 1101 and a memory 1102; where
[0137] The memory 1102 is used to store computer execution instructions;
[0138] The processor 1101 is used to execute the computer execution instructions stored in the memory to implement each step executed by the virtual hair rendering method in the above embodiment. For specific details, reference can be made to the relevant descriptions in the foregoing method embodiments.
[0139] Optionally, the memory 1102 can be either independent or integrated with the processor 1101.
[0140] When the memory 1102 is independently set, the electronic device further includes a bus 1103 for connecting the memory 1102 and the processor 1101.
[0141] One embodiment of the present application further provides a computer-readable storage medium, in which computer execution instructions are stored. When the processor executes the computer execution instructions, the technical solutions corresponding to the virtual hair rendering method executed by the above-mentioned electronic device in any of the foregoing embodiments are implemented.
[0142] One embodiment of the present application further provides a computer program product, which includes: a computer program stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to enable the electronic device to execute the technical solution corresponding to the virtual hair rendering method in any of the above embodiments.
[0143] Although the present application is disclosed above with preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be determined by the scope defined by the claims of the present application.
[0144] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the device or module can be in an electrical, mechanical or other form.
[0145] The above integrated modules implemented in the form of software function modules can be stored in a computer-readable storage medium. The above software function modules are stored in a storage medium, including several instructions for causing an electronic device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods described in various embodiments of the present application.
[0146] It should be understood that the above processor can be a central processing module (English: Central Processing Unit, abbreviated as: CPU), and can also be other general-purpose processors, digital signal processors (English: Digital Signal Processor, abbreviated as: DSP), application specific integrated circuits (English: Application Specific Integrated Circuit, abbreviated as: ASIC), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed by the hardware processor, or executed by the combination of the hardware and software modules in the processor.
[0147] The memory may include high-speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a portable hard drive, a read-only memory, a magnetic disk, or an optical disc, etc.
[0148] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, the buses in the drawings of this application are not limited to only one bus or one type of bus.
[0149] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disc. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0150] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes: ROM, RAM, magnetic disk, or optical disc and other media that can store program codes.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for rendering virtual hair, characterized in that: The method comprises: determining a virtual hair model, wherein the virtual hair model comprises at least one irregular end; Constructing a wrapping model on the surface of the virtual hair model for wrapping a target model area on the virtual hair model, so that the model surface of the virtual hair model is regular, wherein the target model area at least includes the irregular end, the target model area includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices; Based on the positional relationship between the package model and the target model area, determining a target second vertex matching each of the first vertices from the plurality of second vertices; Based on the preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertex, hair rendering is performed on the virtual hair model to generate corresponding virtual hair on the virtual hair model.
2. The method according to claim 1, characterized in that: The determining, based on the positional relationship between the package model and the target model region, target second vertices matching each of the first vertices from the plurality of second vertices comprises: For each of the first vertices in the target model region, a second vertex among the plurality of second vertices that is closest to the first vertex is determined as a target second vertex that matches the first vertex.
3. The method according to claim 1, characterized in that: The performing hair rendering on the virtual hair model based on the preset hair material, the model vertices corresponding to the virtual hair model, and the target second vertex includes: Replacing the vertex normal of the first vertex on the virtual hair model with the vertex normal of a target second vertex that matches the first vertex, to obtain a virtual hair model with updated vertex normals; Based on the preset hair material, hair rendering is performed on the virtual hair model after updating the vertex normals.
4. The method according to claim 1, characterized in that: The step of constructing a wrapping model on the surface of the virtual hair model for wrapping a target model area on the virtual hair model comprises: Based on the topological structure of the virtual hair model, construct an initial wrapping model; Based on the target model area on the virtual hair model, the topological structure of the initial wrapping model is adjusted to obtain a wrapping model that wraps the target model area on the virtual hair model.
5. The method according to claim 1, characterized in that The step of constructing a wrapping model on the surface of the virtual hair model for wrapping a target model area on the virtual hair model comprises: Acquire a preset geometric model that is similar to the geometric shape of the virtual hair model; Based on the target model area on the virtual hair model, the preset geometric model is deformed to obtain a wrapping model that wraps the target model area on the virtual hair model.
6. The method according to claim 1, characterized in that The method further comprises: The vertex normal of the second vertex is adjusted according to the preset hair growth direction of the target model area.
7. The method according to claim 1, characterized in that The method further comprises: When the distance between the first polygonal patch and the second polygonal patch in the virtual hair model is less than a first distance threshold, setting the pixel values of the vertex colors of the model vertices included in the first polygonal patch and the second polygonal patch to the first pixel value; or When the distance between the first polygonal patch and the second polygonal patch in the virtual hair model is greater than a second distance threshold, setting the pixel values of the vertex colors of the model vertices included in the first polygonal patch and the second polygonal patch to a second pixel value; The hair length corresponding to the vertex color of the first pixel value is shorter than the hair length corresponding to the vertex color of the second pixel value.
8. The method according to claim 3, characterized in that After replacing the vertex normal of the first vertex on the virtual hair model with the vertex normal of the target second vertex corresponding to the first vertex and matching it to obtain the virtual hair model with updated vertex normals, the method further includes: Based on the virtual hair model after updating the vertex normals, generating a hair flow map corresponding to the virtual hair model; According to a preset hair flow direction, adjusting the hair flow direction in the hair flow direction map; Based on the preset hair material, hair rendering is performed on the virtual hair model after updating the vertex normals, including: Based on the adjusted hair flow map and the preset hair material, hair rendering is performed on the model vertices in the virtual hair model after the vertex normals are updated.
9. The method according to claim 1, characterized in that: The angles between adjacent polygonal facets in the wrapping model are obtuse angles.
10. The method according to claim 1, characterized in that The method further comprises: The target style of the generated virtual hair is adjusted, where the target style includes at least one of the following: length, thickness, color, and shadow.
11. A virtual hair rendering device, characterized in that: The device comprises: An acquisition module, configured to determine a virtual hair model, wherein the virtual hair model comprises at least one irregular end; a processing module, configured to construct, on the surface of the virtual hair model, a wrapping model for wrapping a target model region on the virtual hair model, so that the model surface of the virtual hair model is regular, wherein the target model region at least includes the irregular end, the target model region includes a plurality of first vertices, and the wrapping model includes a plurality of second vertices; A determination module, configured to determine, from the plurality of second vertices, a target second vertex that matches each of the first vertices based on a positional relationship between the package model and the target model region; A rendering module is used to perform hair rendering on the virtual hair model based on a preset hair material, model vertices corresponding to the virtual hair model, and the target second vertex, so as to generate corresponding virtual hair on the virtual hair model.
12. An electronic device, characterized in that: The electronic device comprises: Processor; and The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the virtual hair rendering method according to any one of claims 1 to 10 is executed.
13. A computer-readable storage medium, characterized in that: A data processing program is stored, and the program is run by a processor to execute the virtual hair rendering method according to any one of claims 1 to 10.
Citation Information
Cited By
Scene rendering method and device, electronic equipment and target vehicle
CN121962397A