Method, device and apparatus for rendering hair of virtual objects
By using the vertex drawing modifier in the virtual object model to store hair attribute data and combining it with vertex resource data for multi-layer rendering, the problem of unrealistic hair rendering effects is solved, dynamic control of hair length and direction is achieved, and the rendering effect is improved.
Patent Information
- Application Number
- CN202111372566.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-18
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2041-11-18
AI Technical Summary
In the existing technology, the hair rendering effect of virtual objects is unrealistic, the local hair is uniform in length and lacks direction, resulting in unsatisfactory rendering effect.
The resource channel in the vertex painting modifier is used to store the attribute data of hair changes, including hair trend and length data, and combined with the vertex resource data of the virtual object model to export to the model data, and transmitted to the rendering engine for multi-layer hair rendering to control the hair length and direction.
Dynamic control of hair length and direction is achieved, which improves the hair rendering effect of virtual object models and makes the hair show natural changes and directions.
Smart Images

Figure CN114119821B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of rendering technology, and in particular to a method, device and apparatus for rendering hair of a virtual object. Background Art
[0002] With the rapid development of computer graphics technology, virtual objects are increasingly being used in games and animations for educational applications, and the variety of educational applications is also increasing. In order to attract more children, improving the realism of virtual objects is essential. However, the production of fur for animal virtual objects has always been a challenge in real-time graphics due to complex lighting, large numbers of fur, and difficult abstraction of physical effects. In the early days, this could only be replaced by a number of meshes. Later, with the advancement of hardware technology, 3D models of fur based on empirical models and physics-based construction were developed, and virtual objects' fur was rendered based on these 3D models.
[0003] Specifically, when rendering hair for virtual objects, the 3D model is typically rendered in multiple layers. Each layer is expanded in the normal direction using a noise map. After each expansion, the texture is permeated according to a certain unit value. This reduces the number of renderings per layer, resulting in a gradual progression of hair from thick to thin at medium and long distances. However, in the related art, when rendering hair for virtual objects, local hair is rendered using a fixed length, resulting in a relatively uniform length of hair, without the directional characteristics of hair length, making the hair rendering effect less than ideal. Summary of the Invention
[0004] In view of this, the present application provides a method, device and equipment for rendering hair of virtual objects. The main purpose is to solve the problem in the prior art that the length of hair rendered is relatively uniform and does not have the directionality of the hair length function, so that the hair rendering effect does not achieve the ideal effect.
[0005] According to a first aspect of the present application, a method for rendering hair of a virtual object is provided, which is applied to a production end and includes:
[0006] For the virtual object model, use the resource channel in the vertex paint modifier to store the attribute data of the hair changes;
[0007] exporting the attribute data of the hair change in combination with vertex resource data of the virtual object model to model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0008] The model data is transmitted to a rendering engine so that the rendering engine calculates vertex offset information of the hair according to attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair.
[0009] Furthermore, the attribute data of the hair change includes hair trend data and hair length data. For the virtual object model, the attribute data of the hair change is stored using the resource channel in the vertex drawing modifier, specifically including:
[0010] Setting a first vertex drawing modifier for the virtual object model, and using a color offset value of a vertex color channel in the first drawing modifier to store hair trend data;
[0011] A second vertex paint modifier is set for the virtual object model, and the color gradient value of the vertex transparency channel in the second paint modifier is used to store hair length data.
[0012] Furthermore, the step of setting a first vertex drawing modifier for the virtual object model and using the color offset value of the vertex color channel in the first drawing modifier to store the hair trend data specifically includes:
[0013] Setting a first vertex paint modifier for the virtual object model, and using the first vertex paint modifier to add color changes to the hair in the virtual object model;
[0014] According to the color change of the hair in the virtual object model, a color offset value of the vertex color channel is determined, and the color offset value is used to store the hair trend data.
[0015] Furthermore, the step of setting a second vertex drawing modifier for the virtual object model and using the color gradient value of the vertex transparency channel in the second drawing modifier to store the hair length data specifically includes:
[0016] Setting a second vertex painting modifier for the virtual object model, and using the second vertex painting modifier to add length changes to the hair in the virtual object model;
[0017] According to the length change of the hair in the virtual object model, a color gradient value of the vertex transparency channel is determined, and the color gradient value is used to store the hair length data.
[0018] Furthermore, before exporting the attribute data of the hair change in combination with the vertex resource data of the virtual object model to the model data, the method further includes:
[0019] Adding vertices to the virtual object model and determining vertex positions of the virtual object model;
[0020] According to the vertex positions of the virtual object model, the object model is expanded into texture coordinate information and normal direction information of the texture resource according to the texture coordinates, and the texture resource information at each vertex position is obtained by summarizing;
[0021] Vertex resource data of the virtual object model is generated by combining the vertex positions of the object model and the texture resource information at each vertex position.
[0022] According to a second aspect of the present application, a method for rendering hair of a virtual object is provided, which is applied to a rendering engine, comprising:
[0023] Receiving model data, and reading vertex resource data and hair change attribute data of a virtual object model from the model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0024] Calculating vertex offset information of the hair according to the attribute data of the hair changes in the model data, wherein the vertex offset information includes hair direction information and hair length information of the virtual object model;
[0025] Multi-layer hair rendering is performed on the texture resource information at each vertex position along the hair direction information according to the hair length information.
[0026] Furthermore, the attribute data of the hair change includes hair trend data and hair length data, the hair trend data includes the color value of the hair in different color channels, and the hair length data includes the grayscale value of the hair at different levels of transparency. The vertex offset information of the hair is calculated based on the attribute data of the hair change in the model data, specifically including:
[0027] Calculating hair direction information of a virtual object model formed along a normal direction according to the color values of the hair in different color channels and vertex position coordinates in the hair trend data;
[0028] The grayscale values of the hair at different transparencies in the hair length data are mapped to the hair length information of the virtual object model.
[0029] Furthermore, the performing multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information specifically includes:
[0030] Determining the number of rendering layers for hair rendering according to the hair length information;
[0031] For each layer of hair rendering, the texture resource information at each vertex position is read into the vertex shader and expanded along the hair direction information to determine the vertex offset position information after each layer of hair rendering;
[0032] According to the number of rendering layers of the hair rendering, multiple layers of hair rendering are repeatedly performed based on the vertex offset positions after each layer of hair rendering.
[0033] Furthermore, for each layer of hair rendering, after reading texture resource information at each vertex position in the vertex shader and performing outward rendering along the hair direction information, and determining vertex offset position information after each layer of hair rendering, the method further includes:
[0034] Fitting the anisotropic information of the virtual object model in the world space in a fragment shader based on the vertex offset position information after rendering each layer of hair, and performing pixel filling using the fitted color information to obtain rendering data for each layer of hair;
[0035] According to the number of rendering layers of the hair rendering, multiple layers of hair rendering are repeatedly performed based on the hair rendering data of each layer.
[0036] Furthermore, before obtaining the hair rendering data for each layer by fitting the anisotropic information of the virtual object model in the world space in a fragment shader based on the vertex offset position information after rendering each layer of hair, and performing pixel filling using the fitted color information, the method further includes:
[0037] Get the ambient lighting information and highlight information in the game scene;
[0038] The normal information of each fragment obtained by interpolating the ambient lighting information and the highlight information in the game scene is used to determine the anisotropic information of the virtual object model in the world space.
[0039] According to a third aspect of the present application, a device for rendering hair of a virtual object is provided, comprising:
[0040] A setting unit for storing attribute data of hair changes using a resource channel in a vertex paint modifier for a virtual object model;
[0041] an exporting unit, configured to export the attribute data of the hair change in combination with vertex resource data of the virtual object model to model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0042] A transmission unit is used to transmit the model data to a rendering engine, so that the rendering engine calculates the vertex offset information of the hair according to the attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair.
[0043] Furthermore, the attribute data of the hair change includes hair trend data and hair length data, and the setting unit includes:
[0044] A first setting module is configured to set a first vertex drawing modifier for the virtual object model, and use a color offset value of a vertex color channel in the first drawing modifier to store hair trend data;
[0045] The second setting module is used to set a second vertex drawing modifier for the virtual object model, and use the color gradient value of the vertex transparency channel in the second drawing modifier to store hair length data.
[0046] Furthermore, the first setting module is specifically used to set a first vertex drawing modifier for the virtual object model, and use the first vertex drawing modifier to add color changes to the hair in the virtual object model;
[0047] The first setting module is further configured to determine a color offset value of a vertex color channel according to the color change of the hair in the virtual object model, and use the color offset value to store hair trend data.
[0048] Furthermore, the second setting module is specifically used to set a second vertex drawing modifier for the virtual object model, and use the second vertex drawing modifier to add length changes of hair in the virtual object model;
[0049] The second setting module is further configured to determine a color gradient value of a vertex transparency channel according to a change in the length of hair in the virtual object model, and use the color gradient value to store hair length data.
[0050] Furthermore, the device further comprises:
[0051] a determining unit, configured to add vertices to the virtual object model and determine vertex positions of the virtual object model before exporting the attribute data of the hair change in combination with the vertex resource data of the virtual object model to the model data;
[0052] an expansion unit, configured to expand the object model into texture coordinate information and normal direction information of a texture resource according to the vertex positions of the virtual object model according to the texture coordinates of the texture, and to obtain texture resource information at each vertex position;
[0053] The production unit is used to combine the vertex positions of the object model and the texture resource information at each vertex position to produce vertex resource data of the virtual object model.
[0054] According to a fourth aspect of the present application, a device for rendering hair of a virtual object is provided, comprising:
[0055] a receiving unit, configured to receive model data and read vertex resource data and hair change attribute data of a virtual object model from the model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0056] a calculation unit, configured to calculate vertex offset information of the hair according to attribute data of the hair changes in the model data, wherein the vertex offset information includes hair direction information and hair length information of the virtual object model;
[0057] A rendering unit is configured to perform multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information.
[0058] Furthermore, the attribute data of the hair change includes hair trend data and hair length data, the hair trend data includes color values of the hair in different color channels, and the hair length data includes grayscale values of the hair at different levels of transparency, and the calculation unit includes:
[0059] a calculation module, configured to calculate hair direction information of a virtual object model formed along a normal direction based on the color values of the hair in different color channels and vertex position coordinates in the hair trend data;
[0060] A mapping module is used to map the grayscale values of the hair at different transparency levels in the hair length data into hair length information of the virtual object model.
[0061] Furthermore, the rendering unit includes:
[0062] A determination module, configured to determine the number of rendering layers for hair rendering based on the hair length information;
[0063] An expansion module is used to read the texture resource information at each vertex position in the vertex shader for each layer of hair rendering, perform expansion drawing along the hair direction information, and determine the vertex offset position information after each layer of hair rendering;
[0064] The rendering module is used to repeatedly perform multiple layers of hair rendering based on the vertex offset position after each layer of hair rendering according to the number of rendering layers of the hair rendering.
[0065] Furthermore, the rendering unit further includes:
[0066] a fitting module, configured to, during the rendering of each layer of hair, read texture resource information at each vertex position in a vertex shader and perform outward expansion rendering along the hair direction information, determine vertex offset position information after rendering each layer of hair, then, in a fragment shader, fit various anisotropic information of the virtual object model in world space based on the vertex offset position information after rendering each layer of hair, and perform pixel filling using the fitted color information to obtain rendering data for each layer of hair;
[0067] The rendering module is specifically configured to repeatedly perform multiple layers of hair rendering based on the hair rendering data of each layer according to the number of rendering layers of the hair rendering.
[0068] According to a fifth aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in the first aspect when executing the computer program.
[0069] According to a sixth aspect of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0070] By means of the above-mentioned technical solution, the present application provides a method, apparatus, and device for rendering hair of a virtual object. Compared with the existing method of rendering local hair of a virtual object using a fixed length, the present application uses a resource channel in a vertex drawing modifier to store attribute data of hair changes for a virtual object model. The attribute data of hair changes is exported to model data in combination with vertex resource data of the virtual object model. The vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position. The model data is further transmitted to a rendering engine, so that the rendering engine calculates vertex offset information of the hair based on the attribute data of hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair. The entire rendering process uses a vertex drawing modifier to store the attribute data of hair changes, so that the rendering engine adds hair length control and direction control to the virtual object model, thereby adjusting and controlling the hair length and direction, so that the rendered hair has changes and directions, and improves the hair rendering effect of the virtual object model.
[0071] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0073] Figure 1 A schematic diagram showing a flow chart of a method for rendering hair of a virtual object provided in an embodiment of the present application is shown;
[0074] Figure 2a The effect diagram of selecting vertex color channel to store hair trend data according to an embodiment of the present application is shown;
[0075] Figure 2b The effect diagram of using the vertex transparency channel to store hair length data according to an embodiment of the present application is shown;
[0076] Figure 3 A schematic diagram showing a flow chart of another method for rendering hair of a virtual object provided in an embodiment of the present application is shown;
[0077] Figure 4 A schematic diagram showing a flow chart of another method for rendering hair of a virtual object provided in an embodiment of the present application is shown;
[0078] Figure 5 A schematic structural diagram of a hair rendering device for a virtual object provided in an embodiment of the present application is shown;
[0079] Figure 6 A schematic structural diagram of another virtual object hair rendering device provided in an embodiment of the present application is shown;
[0080] Figure 7 A schematic structural diagram of another virtual object hair rendering device provided in an embodiment of the present application is shown;
[0081] Figure 8 A schematic structural diagram of another virtual object hair rendering device provided in an embodiment of the present application is shown;
[0082] Figure 9 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0083] The present invention will now be discussed with reference to several exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the present invention, rather than to imply any limitation on the scope of the present invention.
[0084] As used herein, the term "including" and variations thereof are to be interpreted as open-ended terms meaning "including, but not limited to." The term "based on" is to be interpreted as "based, at least in part, on." The terms "one embodiment" and "an embodiment" are to be interpreted as meaning "at least one embodiment." The term "another embodiment" is to be interpreted as meaning "at least one other embodiment."
[0085] With the continuous development of online education, educational applications continue to emerge, and the corresponding educational content, types of education and educational functions continue to increase. Games or animations can even be added to educational applications to help children improve their knowledge, vision, thinking and other abilities. For example, educational applications with identification functions can help children identify various animals by displaying the habits, growth environment, daily food, etc. of animals in the application. Educational applications with hand-drawing functions can allow children to hand-draw various animals by displaying drawing boards and pictures of corresponding animals in the application.
[0086] For virtual objects with hair that appear in educational applications, such as small animals, small dolls, small leaves, etc., corresponding operations can be controlled by creating corresponding games or animations, such as controlling a little tiger to shake its head or controlling small leaves to fall. Specifically, in the process of rendering hair for virtual objects, the three-dimensional model is usually rendered in multiple layers. Each layer is expanded in the normal direction through a noise map. After each expansion, the map is transparent according to a certain unit value. In this way, each layer is rendered, a fixed number of renderings are reduced, and the effect of hair from thick to thin is produced at medium and long distances. However, in the process of rendering hair of virtual objects in related technologies, local hair is rendered using a fixed length rendering method, resulting in the rendered hair being relatively uniform in length and not having the directionality of the hair length function, making the hair rendering effect less than ideal.
[0087] In order to solve this problem, this embodiment provides a method for rendering hair of a virtual object. Figure 1 As shown, the method is applied to a client for game or animation production in an educational application, and includes the following steps:
[0088] 101. For the virtual object model, use the resource channel in the vertex painting modifier to store the attribute data of the hair changes.
[0089] Designing virtual object models is a crucial step in creating games or animations in educational applications. Hair is a crucial component of this process, and the authenticity of the hair production greatly impacts the visual quality of the virtual object. While hair production primarily targets animal hair, it can also be applied to human hair, grass, and more.
[0090] Since virtual object models are composed of several faces, each of which is composed of vertices and edges, the shape of the virtual object model can be changed by modifying it, for example, by collapsing multiple vertices into a single vertex. Specifically, when creating hair, the vertex data of the virtual object model can be set using the Vertex Painter modifier. For example, vertex colors can be painted on the virtual object, which points are painted on a face-by-face basis, and the length of the painted vertices can be controlled. The set vertex data can then be used to control the hair generation of the virtual object model.
[0091] Since the Vertex Paint Modifier is equipped with resource channels, different resource channels can be used to achieve different display effects for vertices. For example, by using the vertex color channel to specify color values, different color changes of the vertex can be obtained. By using the vertex transparency channel and the lighting channel to specify drawing values, the transparency and shading of the vertex color can be obtained respectively. Here, the resource channels in the Vertex Paint Modifier are used to store the attribute data of hair changes, and different hair effects can be achieved through the attribute data of hair changes. For example, for virtual object model A, object A can be selected for vertex painting, and the vertex color can be specified using the color channel. The amount of color applied to the vertex depends on the distance of the vertex from the position of the drawing cursor on the face. The more faces selected, the more changes in the new color. The transparency channel is used to control the color intensity to achieve a color gradient effect.
[0092] The execution subject of this embodiment can be a hair rendering device or apparatus for a virtual object, which can be configured on a client side of a game or animation production. The game or animation production application can create or import a virtual object model and edit the virtual object model. Here, the resource channel in the vertex drawing modifier is used to store attribute data of hair changes. The attribute data of hair changes includes at least hair length, hair direction, hair density, etc., which can display the hair effect of the virtual object during the animation process from multiple dimensions. Specifically, during the hair rendering process of the virtual object model, since educational applications are generally rendered in real time during use, and real-time rendering has a lower frame rate requirement, a relatively good rendering effect is achieved.
[0093] 102. Export the attribute data of the hair change in combination with the vertex resource data of the virtual object model to model data.
[0094] Among them, the vertex resource data of the virtual object model records the vertex position information and the texture resource information at each vertex position. Vertices are the basic elements in the 3D world. In the 3D world that can be drawn by computers, any object is composed of polygons, which can be triangular, quadrilateral, etc. Due to the special properties of triangular shapes, that is, triangles, they are widely used in the 3D world. Three points are required to form a triangle, and these points are the vertex data of the virtual object model. The vertex position information is the xyz coordinate value of a single vertex in the model space, and the texture resource information at each vertex position is the resource attribute information of a single vertex in the model space, which can specifically include the texture UV coordinate value of the vertex, the vertex normal, the vertex size, the vertex diffuse reflection, etc.
[0095] Considering the virtual object model, the texture resource information at each vertex position is equivalent to a bitmap that can be applied to the primitives. For example, you can create some patterns, or you can use some grass, dirt, and rocks for some three-dimensional primitives and pile them into a mountain to form a hillside background, or a road sign or cliff. Here, the vertices are mainly used to form the hair of the virtual object model. Furthermore, this texture resource information can also be added with texture techniques such as texture fusion (opaque or transparent) and light mapping to improve the display effect of the virtual object model's hair.
[0096] In games or animations, virtual object models are described using polygonal meshes. Model data can store vertex information for all polyhedrons describing the virtual object model. This vertex information includes not only rapidly changing attribute information, such as vertex length, vertex direction, and vertex color, but also vertex resource texture information, such as vertex three-dimensional coordinates, vertex normal vectors, and vertex texture coordinates. Furthermore, since the model's texture may be lost or the texture effect may be unsatisfactory during the process of exporting vertex texture resource data to the model data, it is also possible to pre-existingly use the vertex texture coordinates to expand the vertex texture resource on the virtual object model to form a texture map. This allows the vertex texture resource information to be exported to the model data in the form of a texture map, while retaining the corresponding vertex texture resource information.
[0097] 103. Transmit the model data to a rendering engine, so that the rendering engine calculates vertex offset information of the hair according to attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair.
[0098] It is understandable that due to the complexity of virtual object models, modeling tools such as games or animations are often used in actual applications. The number of faces of the model may be thousands, and a specific data format is required to save the model data into a file and hand it over to the rendering engine for drawing. At this time, after receiving the model data, the rendering engine needs to parse the model data according to the model format and read it into the project for rendering.
[0099] Specifically, in the rendering engine, after parsing the model data, it obtains the corresponding virtual object model vertex information such as the model's vertices, normals, texture coordinates, as well as the model organization's index data and metadata. It also describes the corresponding virtual object model's texture resource path and lighting parameter data. The read model data is further used to perform calculations involving lighting calculations, the number of rendering layers, and the rendering position, and rendering is performed based on the calculated data results.
[0100] In a specific application scenario, the hair rendering process for a virtual object model first reads the vertex positions of the model data for vertex positioning, and at the same time extracts the texture resource information and hair change attribute data on the model vertices. The hair change attribute data is used to calculate the vertex offset information of the hair. The vertex offset information is manifested as a hair direction effect on the one hand, and as a hair length effect on the other hand. The hair vertex offset information is further used to draw the hair of the virtual object model layer by layer, so that the hair of the virtual object model reaches the specified length in the corresponding direction.
[0101] The hair rendering method for a virtual object provided in an embodiment of the present application, compared to the current prior art method of using a fixed length to render local hair of a virtual object, uses a resource channel in a vertex drawing modifier to store attribute data of hair changes for a virtual object model, and exports the attribute data of hair changes in combination with the vertex resource data of the virtual object model to model data. The vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position. The model data is further transmitted to a rendering engine so that the rendering engine calculates vertex offset information of the hair based on the attribute data of hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair. The entire rendering process uses a vertex drawing modifier to store attribute data of hair changes so that the rendering engine adds hair length control and direction control to the virtual object model, thereby adjusting and controlling the hair length and direction so that the rendered hair has changes and directions, thereby improving the hair rendering effect of the virtual object model.
[0102] Furthermore, considering the particularity of the hair on the virtual object model, in order to achieve a more realistic hair rendering effect, the above-mentioned attribute data of the hair change includes hair trend data and hair length data. The hair trend data is equivalent to the trend of the hair direction. Since the hair direction values of different parts of the virtual object model are different, some parts are along the normal direction, and some parts are at a certain angle to the normal direction. Here, a first vertex drawing modifier can be set for the virtual object model, and the color offset value of the vertex color channel in the first drawing modifier is used to store the hair trend data; the hair length data is equivalent to the hair length. Since the hair length of different parts of the virtual object model is inconsistent, for example, the hair around the ears and nose of an animal is shorter, while the hair around the tail is longer, here a second vertex drawing modifier can be set for the virtual object model, and the color gradient value of the vertex transparency channel in the second drawing modifier is used to store the hair length data.
[0103] Furthermore, to improve the processing efficiency of hair variation attribute data, the first vertex drawing modifier can pre-set templates for hair trends in different parts of a virtual object, as well as correlation coefficients between hair trends in different parts. For example, when a virtual object's tail is wagging, the hair trend in the tail is set to be opposite to the wagging direction; when the virtual object's tail is pointing vertically, the hair trend in the tail is set to be vertical. Similarly, the second vertex drawing modifier can pre-set templates for hair length in different parts of a virtual object, as well as correlation coefficients between hair length in different parts of the virtual object. For example, the hair length in the tail of a virtual object can be set to be longer than that in the body, with the hair gradually lengthening from the base to the tip of the tail. By pre-setting templates and correlation coefficients for hair variation attribute data, hair trends and lengths for different parts of a virtual object can be generated and stored, enabling batch processing of hair variation attribute data, improving data processing efficiency. Furthermore, personalized modifications can be made to the batch-processed hair variation attribute data, such as adjusting the hair length or correcting the hair trend of individual parts.
[0104] Specifically, since the virtual object model has different color changes, and the offset value of the color change can indicate that the virtual object model has different hair direction requirements for different parts, for example, the tail part needs to be downward, and the ear part needs to be upward. Here, in the process of storing hair trend data, a first vertex drawing modifier can be set for the virtual object model, and the first vertex drawing modifier can be used to add the color change of the hair in the virtual object model. According to the color change of the hair in the virtual object model, the color offset value of the vertex color channel is determined. Here, it can be set that the larger the color offset value, the larger the hair offset angle along the normal direction, and the smaller the color offset value, the smaller the hair offset angle along the normal direction, and the color offset value is used to store the hair trend data.
[0105] Specifically, since the colors on the virtual object model have different transparency changes, and the different transparency changes can indicate that the virtual object model has different hair length requirements for different parts, for example, the mouth, paws, and areas around the ears have short hair requirements, while the back and tail have long hair requirements. In the process of storing hair length data, a second vertex drawing modifier can be set for the virtual object model, and the second vertex drawing modifier can be used to add the length change of the hair in the virtual object model. According to the length change of the hair in the virtual object model, the color gradient value of the vertex transparency channel is determined. Here, it can be set that the longer the hair, the higher the transparency, and the shorter the hair, the lower the transparency, and the color gradient value is used to store the hair length data.
[0106] In actual application scenarios, the first vertex painting modifier is used to brush various color changes on the virtual object model, and the vertex color channel is selected to store the hair trend data. Figure 2a As shown, different color values are used for different hair trends of the virtual object model. The corresponding colors are not shown in the figure here. The second vertex painting modifier is used to brush different grayscales on the virtual object model, and the vertex transparency channel is selected to store the hair length data. Figure 2b As shown, different grayscale values are used for different hair lengths of the virtual object model. As shown in the figure, the grayscale values of the face and limbs are higher and the hair is shorter, while the grayscale value of the tail and body is lower and the hair is longer.
[0107] Furthermore, considering the integrity of the exported model data, before exporting the attribute data of the hair changes in combination with the vertex resource data of the virtual object model to the model data, it is also necessary to produce the vertex resource data of the virtual object. Specifically, vertices can be added to the virtual object model, the vertex positions of the virtual object model can be determined, and according to the vertex positions of the virtual object model, the object model can be expanded into the texture coordinate information and normal direction information of the texture resource according to the texture coordinates of the map, and the texture resource information at each vertex position is summarized. The vertex resource information of the virtual object model is produced by combining the vertex position of the object model and the texture resource information at each vertex position.
[0108] The above embodiment describes the hair rendering process of a virtual object on the client side of a game or animation production of an educational application. Furthermore, in order to fully illustrate the implementation of this embodiment, this embodiment also provides another hair rendering method for a virtual object, which is applied to the rendering engine side. Figure 3 As shown, the method includes:
[0109] 201. Receive model data, and read vertex resource data of a virtual object model and attribute data of hair changes in the model data.
[0110] Specifically in the rendering engine, since the model data carries relevant data that the virtual object model needs to be rendered, the rendering engine can color and render the hair of the virtual object model by reading the vertex resource data and hair change attribute data of the virtual object model.
[0111] 202. Calculate vertex offset information of the hair according to the attribute data of the hair changes in the model data.
[0112] Typically, before a virtual object model is drawn on the screen, it needs to be converted from the 3D world to the screen's two-dimensional coordinate system. The rendering engine can use its own algorithms or a moon-based rendering engine to complete the coordinate conversion. Here, the vertex offset information for hair is the coordinate offset value of the vertex in the normal direction. Since the hair attribute change data reflects the attribute characteristics of the virtual object model in terms of hair direction and hair length, the vertex direction change information and vertex length change information can be extracted based on the hair attribute change data. Then, the vertex coordinate offset value in the normal direction can be determined based on the vertex direction change information and vertex length change information.
[0113] Here, the direction change information of the vertex is expressed using the color value of the color channel. Specifically, RGB can be used to express the change in hair direction. The length change information of the vertex is expressed using the gradient value of the transparency channel. Specifically, color transparency 0-1 can be used to express the change in hair length.
[0114] 203. Perform multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information.
[0115] The rendering process for the virtual object model here mainly includes the vertex shading part and the fragment shading part. In the vertex shading part, the vertex shader is mainly used to expand the vertices of the virtual object model along the hair direction information layer by layer according to the hair length information. The virtual object hair is drawn by drawing the texture resource information at each vertex position, and the object hair length and direction are controlled by the number of expansion drawing layers. In the fragment shading part, the fragment shader is mainly used to fill the middle surface of the virtual object model, and the anisotropic information formed by the light is used to control the object hair to have a better highlight effect.
[0116] Furthermore, as a refinement and extension of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, this embodiment provides another method for rendering hair of a virtual object, such as Figure 4 As shown, the method includes:
[0117] 301. Receive model data, and read vertex resource data of a virtual object model and attribute data of hair changes in the model data.
[0118] Specifically, in the process of reading the vertex resource data and hair change attribute data of the virtual object model in the model data, considering that different data types support different parsing types, we can judge the corresponding data types of the vertex resource data and the hair change attribute data respectively, and then define the data parser supported by the corresponding data type, and use the data parser of the corresponding data type to load and parse the resource list attached to the vertex resource data and the hair change attribute data one by one.
[0119] 302. Calculate hair direction information of a virtual object model formed along a normal direction based on the color values of the hair in different color channels and vertex position coordinates in the hair trend data.
[0120] Since hair has RGB color values on different color channels and vertex position coordinates have xyz values, the RGB color values can be used to determine the offset value in the xyz direction, and the hair direction information of the virtual object model formed along the normal direction can be calculated based on the offset value and the vertex position coordinates. Each color channel corresponds to a coordinate direction, and the specific value is determined by the color value on the corresponding color channel. For example, the r channel corresponds to the x coordinate direction, and the color value on the r channel is 0.5, so the offset value in the x coordinate direction is 0.5. The offset value is further summed with the vertex position coordinates to obtain the hair direction information of the virtual object model formed along the normal direction.
[0121] Furthermore, considering that the offset value may be affected by various conditions and factors, influencing factors can be added in the process of calculating the offset value, and the offset value can be determined in combination with the influencing factors, such as the influencing factors of other channels on the offset value, the influencing factors of ambient light on the offset value, etc.
[0122] 303. Map the grayscale values of the hair at different levels of transparency in the hair length data into hair length information of the virtual object model.
[0123] Since hair has corresponding grayscale values in different transparency channels, the grayscale value is used here as a representation of hair length. The larger the grayscale value, the longer the hair. Specifically, the standard hair length of the virtual object model can be set in advance, and the product of the grayscale value and the standard hair length is used to represent the hair length of the virtual object model to obtain the hair direction information of the virtual object model. For example, the standard hair length is set to 2, the grayscale value is distributed between 0-1, the grayscale value of the ear of the virtual object model is 0.2, and the calculated hair length is 0.4. The grayscale value of the tail is 1, and the calculated hair length is 2.
[0124] 304. Determine the number of rendering layers for hair rendering according to the hair length information.
[0125] Since the rendering process of a virtual object model is equivalent to an outward-drawing process based on vertex position offset information, the specific number of outward-drawing layers can be determined based on the hair length information. First, the initial spacing of each layer is determined, and the ratio of the hair length information to the initial spacing of each layer is used to calculate the number of hair rendering layers. The shorter the hair, the fewer rendering layers are required. For example, if the hair length is 1 and the initial spacing of each layer is 0.05, the hair of the vertex needs to be rendered 20 times to reach the corresponding hair length. For a hair length of 1, the hair of the vertex needs to be rendered 10 times to reach the corresponding hair length.
[0126] 305. For each layer of hair rendering, read the texture resource information at each vertex position in the vertex shader and perform outward rendering along the hair direction information to determine the vertex offset position information after each layer of hair rendering.
[0127] It can be understood that the vertex shader can access the vertex data in the virtual object model. Here, the instance array index can be used as the drawing index for the vertex data rendering process. The drawing index can be the index formed by the vertices in the rendering process of each layer of hair, or it can be the index formed by the vertices of the entire virtual object model. It can be set according to the requirements of the number of rendering layers. Further, the vertex shader can traverse the drawing elements in the virtual object model according to the drawing index. The drawing element is equivalent to the texture resource information at the vertex position, and then the texture resource information is expanded along the direction of the hair. The length of the hair is controlled by the number of expansion layers during the expansion drawing process. The outline of the virtual object model is changed after each expansion drawing until the hair reaches the set length information and direction information.
[0128] 306. Based on the vertex offset position information after rendering each layer of hair, fit the anisotropic information of the virtual object model in the world space in a fragment shader, and use the fitted color information to perform pixel filling to obtain rendering data for each layer of hair.
[0129] During the rendering process, vertex data undergoes a series of transformations in the vertex shader, and the output vertex offset position information needs to be handed over to the fragment shader for rasterization. Here, a structure needs to be defined for the output of the vertex shader and the input of the fragment shader to achieve information transmission. Each variable in the structure needs semantics and at least contains the offset position, otherwise the renderer cannot obtain the coordinates of the clipping space and cannot be displayed on the screen.
[0130] In order to better display the hair effect of the virtual object model, before using the fitted color information to fill pixels and obtain each layer of hair rendering data, the ambient lighting information and highlight information in the scene can be obtained, and the normal information of each fragment obtained by interpolation using the ambient lighting information and highlight information in the game scene can be determined to determine the anisotropic information of the virtual object model in the world space.
[0131] Here, when implementing anisotropic lighting in the rendering process, it does not mean that every vertex has different normal information in different directions. The calculation is based on the fragment shader. If the normals are homogeneous, it is only necessary to obtain the normal information of each fragment by interpolation. For anisotropy, it is necessary to recalculate the normals according to the normal perturbation rules in the fragment shader. In this way, although it looks like a plane, the pixels on it will form some texture and groove effects due to the normal perturbation, thereby showing more details. Moreover, the perturbation of the normal is usually regular, so the effect may be different in different directions, thereby showing anisotropic information.
[0132] 307 . Repeatedly perform multiple layers of hair rendering based on the hair rendering data of each layer according to the number of rendering layers of the hair rendering.
[0133] It should be noted that, since the hair length in the related art belongs to the rendering process of the vertex stage and the texture cannot be sampled, the embodiment of the present invention stores the vertex color value and the vertex transparency value in the virtual object model to reflect the hair trend and hair length through the vertex color value and the vertex transparency value. Then, in the process of performing multi-layer hair rendering, each layer of hair rendering data is drawn according to the hair length information and hair direction information, so that the hair length and hair direction can be continuously adjusted and controlled during the rendering process, thereby improving the hair rendering effect.
[0134] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides a hair rendering device for virtual objects in a game or animation production end that can be applied to educational applications, such as Figure 5 As shown, the device includes: a setting unit 41, a deriving unit 42, and a transmission unit 43.
[0135] A setting unit 41 can be used to store attribute data of hair changes using a resource channel in a vertex paint modifier for a virtual object model;
[0136] An exporting unit 42 may be configured to export the attribute data of the hair change in combination with vertex resource data of the virtual object model to model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0137] The transmission unit 43 can be used to transmit the model data to the rendering engine, so that the rendering engine calculates the vertex offset information of the hair based on the attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair.
[0138] The hair rendering device for virtual objects provided by an embodiment of the present invention, compared to the current prior art method of using a fixed length to render local hair of a virtual object, utilizes a resource channel in a vertex drawing modifier to store attribute data of hair changes for a virtual object model. The hair change attribute data is exported to model data in combination with vertex resource data of the virtual object model. The vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position. The model data is further transmitted to a rendering engine, so that the rendering engine calculates vertex offset information of the hair based on the hair change attribute data in the model data and performs multi-layer hair rendering on the texture resource information at each vertex position along the hair vertex offset information. The entire rendering process utilizes a vertex drawing modifier to store the hair change attribute data, so that the rendering engine adds hair length and direction control to the virtual object model, thereby adjusting and controlling the hair length and direction, so that the rendered hair has changes and directions, thereby improving the hair rendering effect of the virtual object model.
[0139] In specific application scenarios, such as Figure 6 As shown, the attribute data of hair changes include hair trend data and hair length data, and the setting unit 41 includes:
[0140] A first setting module 411 may be used to set a first vertex drawing modifier for the virtual object model, and use the color offset value of the vertex color channel in the first drawing modifier to store hair trend data;
[0141] The second setting module 412 can be used to set a second vertex drawing modifier for the virtual object model, and use the color gradient value of the vertex transparency channel in the second drawing modifier to store hair length data.
[0142] In a specific application scenario, the first setting module 411 may be used to set a first vertex drawing modifier for the virtual object model, and use the first vertex drawing modifier to add color changes to the hair in the virtual object model;
[0143] The first setting module 411 may be further configured to determine a color offset value of a vertex color channel according to the color change of the hair in the virtual object model, and use the color offset value to store hair trend data.
[0144] In a specific application scenario, the second setting module 412 may be specifically used to set a second vertex drawing modifier for the virtual object model, and use the second vertex drawing modifier to add length changes to the hair in the virtual object model;
[0145] The second setting module 412 may be further configured to determine a color gradient value of a vertex transparency channel according to a change in the length of hair in the virtual object model, and use the color gradient value to store hair length data.
[0146] In specific application scenarios, such as Figure 6 As shown, the device also includes:
[0147] The determining unit 44 may be configured to add vertices to the virtual object model and determine vertex positions of the virtual object model before exporting the hair change attribute data in combination with the vertex resource data of the virtual object model to the model data;
[0148] The expansion unit 45 may be configured to expand the object model into texture coordinate information and normal direction information of a texture resource according to the vertex positions of the virtual object model according to the texture coordinates, and summarize the texture resource information at each vertex position;
[0149] The production unit 46 may be configured to combine the vertex positions of the object model and the texture resource information at the respective vertex positions to produce vertex resource data of the virtual object model.
[0150] It should be noted that the other corresponding descriptions of the functional units involved in the hair rendering device for virtual objects in a game or animation production end of an educational application provided in this embodiment can be referred to. Figure 1 The corresponding description in will not be repeated here.
[0151] Further, as Figure 3-Figure 4 The specific implementation of the method, the embodiment of the present application provides a hair rendering device for virtual objects applied to the rendering engine side, such as Figure 7 As shown, the device includes: a receiving unit 51, a computing unit 52, and a rendering unit 53.
[0152] The receiving unit 51 may be configured to receive model data and read vertex resource data and hair change attribute data of the virtual object model from the model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position;
[0153] A calculation unit 52 may be configured to calculate hair vertex offset information based on the attribute data of the hair changes in the model data, wherein the vertex offset information includes hair direction information and hair length information of the virtual object model;
[0154] The rendering unit 53 may be configured to perform multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information.
[0155] In actual application scenarios, such as Figure 8 As shown, the attribute data of the hair change includes hair trend data and hair length data, the hair trend data includes the color value of the hair in different color channels, and the hair length data includes the grayscale value of the hair at different transparency levels. The calculation unit 52 includes:
[0156] The calculation module 521 can be used to calculate the hair direction information of the virtual object model formed along the normal direction according to the color values of the hair in different color channels and the vertex position coordinates in the hair trend data;
[0157] The mapping module 522 may be configured to map the grayscale values of the hair at different levels of transparency in the hair length data into hair length information of the virtual object model.
[0158] In actual application scenarios, such as Figure 8 As shown, the rendering unit 53 includes:
[0159] A determination module 531 may be configured to determine the number of rendering layers for hair rendering based on the hair length information;
[0160] The expansion module 532 may be used to read the texture resource information at each vertex position in the vertex shader for each layer of hair rendering and perform expansion along the hair direction information to determine the vertex offset position information after each layer of hair rendering;
[0161] The rendering module 533 may be configured to repeatedly perform multiple layers of hair rendering based on the vertex offset positions after each layer of hair rendering according to the number of rendering layers of the hair rendering.
[0162] In actual application scenarios, such as Figure 8 As shown, the rendering unit 53 further includes:
[0163] The fitting module 534 may be configured to, during the rendering of each layer of hair, read the texture resource information at each vertex position in the vertex shader and perform outward rendering along the hair direction information, determine the vertex offset position information after rendering each layer of hair, then, in the fragment shader, fit the anisotropic information of the virtual object model in the world space based on the vertex offset position information after rendering each layer of hair, and perform pixel filling using the fitted color information to obtain rendering data for each layer of hair;
[0164] The rendering module 533 may be specifically configured to repeatedly perform multiple layers of hair rendering based on the hair rendering data of each layer according to the number of rendering layers of the hair rendering.
[0165] It should be noted that for other corresponding descriptions of the functional units involved in the hair rendering device for virtual objects provided in this embodiment and applicable to the rendering engine side, please refer to Figure 3-Figure 4 The corresponding description in will not be repeated here.
[0166] Based on the above Figure 1 The method shown in FIG. 1 is a method for performing the above-mentioned operation. Accordingly, the embodiment of the present application further provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned operation is performed. Figure 1 The hair rendering method of the virtual object shown in FIG. Figure 3-Figure 4 The method shown in FIG. 1 is a method for performing the above-mentioned operation. Accordingly, the embodiment of the present application further provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned operation is performed. Figure 3-Figure 4 The hair rendering method for virtual objects shown.
[0167] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0168] Based on the above Figure 1 The method shown, and Figure 5-Figure 6 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides a physical device for hair rendering of a virtual object, which can be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 The hair rendering method for virtual objects shown.
[0169] Based on the above Figure 3-Figure 4 The method shown, and Figure 7-Figure 8 In order to achieve the above-mentioned purpose, the embodiment of the virtual device shown in the embodiment of the present application also provides another physical device for hair rendering of virtual objects, which can be a computer, a smart phone, a tablet computer, a smart watch, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 3-Figure 4 The hair rendering method for virtual objects shown.
[0170] Optionally, the two physical devices described above may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a Wi-Fi module, and the like. The user interface may include a display, an input unit such as a keyboard, and the like. Optionally, the user interface may also include a USB interface, a card reader interface, and the like. The network interface may optionally include a standard wired interface, a wireless interface (such as a Wi-Fi interface), and the like.
[0171] In an exemplary embodiment, see Figure 9 The physical device includes a communication bus, a processor, a memory, and a communication interface. It may also include an input / output interface and a display device. The various functional units can communicate with each other via the bus. The memory stores a computer program, and the processor is configured to execute the program stored in the memory and perform the painting mounting method described in the above embodiment.
[0172] Those skilled in the art will understand that the physical device structure for hair rendering of a virtual object provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0173] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device used to process store search information, supporting the execution of the information processing program and other software and / or programs. The network communication module is used to enable communication between components within the storage medium and with other hardware and software within the physical device used to process the information.
[0174] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the technical solution of the present application, compared with the current existing methods, the present application uses a vertex drawing modifier to store the attribute data of hair changes during the entire rendering process, so that the rendering engine can add hair length control and direction control to the virtual object model, and then adjust and control the hair length and direction, so that the rendered hair has changes and directions, thereby improving the hair rendering effect of the virtual object model.
[0175] Those skilled in the art will understand that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required to implement the present application. Those skilled in the art will understand that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple sub-modules.
[0176] The serial numbers of the above application are for descriptive purposes only and do not represent the advantages or disadvantages of the implementation scenarios. The above disclosure only discloses several specific implementation scenarios of the present application, but the present application is not limited thereto. Any changes that can be conceived by those skilled in the art should fall within the scope of protection of the present application.
Claims
1. A method for rendering hair of a virtual object, characterized in that: Applied to the production side, including: For a virtual object model, using a resource channel in a vertex paint modifier to store attribute data of hair changes, the attribute data of hair changes being used to achieve different hair effects, the attribute data of hair changes including hair trend data and hair length data, the hair trend data being stored using a color offset value of a vertex color channel in a first vertex paint modifier, and the hair length data being stored using a color gradient value of a vertex transparency channel in a second vertex paint modifier; exporting the attribute data of the hair change in combination with vertex resource data of the virtual object model to model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position; The model data is transmitted to a rendering engine so that the rendering engine calculates vertex offset information of the hair according to attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair, so that the hair of the virtual object model reaches a specified length in the corresponding direction, and the vertex offset information is expressed as hair direction special effects and hair length special effects.
2. The method according to claim 1, characterized in that For the virtual object model, the resource channel in the vertex painting modifier is used to store the attribute data of the hair changes, specifically including: Setting a first vertex painting modifier for the virtual object model, and using a color offset value of a vertex color channel in the first vertex painting modifier to store hair trend data; A second vertex painting modifier is set for the virtual object model, and the color gradient value of the vertex transparency channel in the second vertex painting modifier is used to store hair length data.
3. The method according to claim 2, characterized in that The step of setting a first vertex drawing modifier for the virtual object model and using a color offset value of a vertex color channel in the first vertex drawing modifier to store hair trend data specifically includes: Setting a first vertex paint modifier for the virtual object model, and using the first vertex paint modifier to add color changes to the hair in the virtual object model; According to the color change of the hair in the virtual object model, a color offset value of the vertex color channel is determined, and the color offset value is used to store the hair trend data.
4. The method according to claim 2, characterized in that The step of setting a second vertex painting modifier for the virtual object model and using the color gradient value of the vertex transparency channel in the second vertex painting modifier to store the hair length data specifically includes: Setting a second vertex painting modifier for the virtual object model, and using the second vertex painting modifier to add length changes to the hair in the virtual object model; According to the length change of the hair in the virtual object model, a color gradient value of the vertex transparency channel is determined, and the color gradient value is used to store the hair length data.
5. The method according to any one of claims 1 to 4, characterized in that Before exporting the attribute data of the hair change in combination with the vertex resource data of the virtual object model to the model data, the method further includes: Adding vertices to the virtual object model and determining vertex positions of the virtual object model; According to the vertex positions of the virtual object model, the object model is expanded into texture coordinate information and normal direction information of the texture resource according to the texture coordinates, and the texture resource information at each vertex position is obtained by summarizing; Vertex resource data of the virtual object model is generated by combining the vertex positions of the object model and the texture resource information at each vertex position.
6. A method for rendering hair of a virtual object, characterized in that: Applied to the rendering engine side, including: Receiving model data, and reading vertex resource data and hair change attribute data of a virtual object model from the model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position, and the hair change attribute data is used to achieve different hair effects, wherein the hair change attribute data includes hair trend data and hair length data, wherein the hair trend data is stored using a color offset value of a vertex color channel in a first vertex drawing modifier, and the hair length data is stored using a color gradient value of a vertex transparency channel in a second vertex drawing modifier; Calculating vertex offset information of the hair according to the attribute data of the hair changes in the model data, wherein the vertex offset information includes hair direction information and hair length information of the virtual object model; According to the hair length information, multi-layer hair rendering is performed on the texture resource information at each vertex position along the hair direction information, so that the hair of the virtual object model reaches a specified length in the corresponding direction, and the vertex offset information is expressed as hair direction special effects and hair length special effects.
7. The method according to claim 6, characterized in that The hair trend data includes the color values of the hair in different color channels, the hair length data includes the grayscale values of the hair at different transparency levels, and the vertex offset information of the hair is calculated based on the attribute data of the hair changes in the model data, specifically including: Calculating hair direction information of a virtual object model formed along a normal direction according to the color values of the hair in different color channels and vertex position coordinates in the hair trend data; The grayscale values of the hair at different transparencies in the hair length data are mapped to the hair length information of the virtual object model.
8. The method according to claim 6, characterized in that The performing multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information specifically includes: Determining the number of rendering layers for hair rendering according to the hair length information; For each layer of hair rendering, the texture resource information at each vertex position is read into the vertex shader and expanded along the hair direction information to determine the vertex offset position information after each layer of hair rendering; According to the number of rendering layers of the hair rendering, multiple layers of hair rendering are repeatedly performed based on the vertex offset positions after each layer of hair rendering.
9. The method according to claim 8, characterized in that After reading texture resource information at each vertex position in the vertex shader for rendering each layer of hair and performing outward rendering along the hair direction information, and determining vertex offset position information after rendering each layer of hair, the method further includes: Fitting the anisotropic information of the virtual object model in the world space in a fragment shader based on the vertex offset position information after rendering each layer of hair, and performing pixel filling using the fitted color information to obtain rendering data for each layer of hair; According to the number of rendering layers of the hair rendering, multiple layers of hair rendering are repeatedly performed based on the hair rendering data of each layer.
10. The method according to claim 9, characterized in that Before obtaining the hair rendering data for each layer by fitting the anisotropic information of the virtual object model in the world space in a fragment shader based on the vertex offset position information after rendering each layer of hair, and performing pixel filling using the fitted color information, the method further includes: Get the ambient lighting information and highlight information in the game scene; The normal information of each fragment obtained by interpolating the ambient lighting information and the highlight information in the game scene is used to determine the anisotropic information of the virtual object model in the world space.
11. A hair rendering device for a virtual object, characterized in that: include: a setting unit, configured to store, for a virtual object model, attribute data of hair changes using a resource channel in a vertex paint modifier, the attribute data of hair changes being used to achieve different hair effects, the attribute data of hair changes including hair trend data and hair length data, the hair trend data being stored using a color offset value of a vertex color channel in a first vertex paint modifier, and the hair length data being stored using a color gradient value of a vertex transparency channel in a second vertex paint modifier; an exporting unit, configured to export the attribute data of the hair change in combination with vertex resource data of the virtual object model to model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position; A transmission unit is used to transmit the model data to a rendering engine, so that the rendering engine calculates the vertex offset information of the hair according to the attribute data of the hair changes in the model data, and performs multi-layer hair rendering on the texture resource information at each vertex position along the vertex offset information of the hair, so that the hair of the virtual object model reaches a specified length in the corresponding direction, and the vertex offset information is expressed as hair direction special effects and hair length special effects.
12. A hair rendering device for a virtual object, characterized in that: include: a receiving unit, configured to receive model data and read vertex resource data and hair change attribute data of a virtual object model from the model data, wherein the vertex resource data of the virtual object model records vertex position information and texture resource information at each vertex position, and the hair change attribute data is used to achieve different hair effects, wherein the hair change attribute data includes hair trend data and hair length data, wherein the hair trend data is stored using a color offset value of a vertex color channel in a first vertex drawing modifier, and the hair length data is stored using a color gradient value of a vertex transparency channel in a second vertex drawing modifier; a calculation unit, configured to calculate vertex offset information of the hair according to attribute data of the hair changes in the model data, wherein the vertex offset information includes hair direction information and hair length information of the virtual object model; A rendering unit is used to perform multi-layer hair rendering on the texture resource information at each vertex position along the hair direction information according to the hair length information, so that the hair of the virtual object model reaches a specified length in the corresponding direction, and the vertex offset information is expressed as hair direction special effects and hair length special effects.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method for rendering hair of a virtual object according to any one of claims 1 to 10 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for rendering hair of a virtual object according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Special effect control method and device, electronic equipment and storage medium
CN113064539A
Three-dimensional virtual model rendering method, device and electronic equipment
CN113450441A