Hair material rendering method and device, electronic equipment and readable storage medium
Patent Information
- Application Number
- CN202310725985.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-06-16
AI Technical Summary
当前较为常用的毛发渲染方案为“视差渲染”方案,需要将一个模型多次绘制(也即,多pass)以达到毛发的感觉,其性能压力仍然较大,而且模型边缘处较为平滑,无法表现出毛刺感觉,同时近距离观看模型可发现明显瑕疵
[0008] The hair material rendering method, apparatus, electronic device, and readable storage medium provided in this invention, after acquiring the model to be rendered, determine the final texture coordinates of the model, then determine the first offset corresponding to the final texture coordinates, and perform vertex offset on the vertices in the final texture coordinates based on the first offset to obtain offset texture coordinate patches. Next, perform texture sampling on the offset texture coordinate patches to obtain sampled texture coordinate patches, so that the sampled texture coordinate patches produce a hair-like effect. Finally, determine the second offset corresponding to the sampled texture coordinate patches, and adjust the orientation of the sampled texture coordinate patches based on the second offset to obtain the hair material model. Before actual rendering, the above method rearranges the texture coordinate patches of the model to be rendered to simulate multiple renderings of the model, significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture sampling based on the first offset can give the model a noticeable jagged appearance. Finally, adjusting the patch orientation based on the second offset yields a hair material model with better rendering effect. This invention also effectively alleviates the problem of obvious flaws being visible when viewing the model at close range.
Smart Images

Figure CN116726492B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model rendering technology, and in particular to a method, apparatus, electronic device, and readable storage medium for rendering hair materials. Background Technology
[0002] In games, hair rendering is typically performance-intensive. If a "fine, individual hairs" effect is desired, direct modeling would result in an excessively high polygon count. Therefore, alternative solutions are usually used to achieve a "fine, individual hairs" effect while keeping the model's polygon count low, thus balancing performance and visual appeal. Currently, the most commonly used hair rendering solution is "parallax rendering," which requires drawing a model multiple times (i.e., multiple passes) to achieve the desired hair texture. However, this method still places significant performance demands, and the model's edges are relatively smooth, failing to convey a fuzzy texture. Furthermore, noticeable imperfections can be observed when viewing the model up close. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a hair material rendering method, apparatus, electronic device and readable storage medium, which can significantly reduce the performance pressure of hair rendering, and make the model have obvious jaggedness, and can also effectively alleviate the problem that obvious flaws can be found when viewing the model at close range.
[0004] In a first aspect, embodiments of the present invention provide a method for rendering hair materials, comprising: acquiring a model to be rendered and determining the final texture coordinates of the model to be rendered; determining a first offset corresponding to the final texture coordinates, and performing vertex offset on vertices in the final texture coordinates based on the first offset to obtain offset texture coordinate patches; performing texture sampling on the offset texture coordinate patches to obtain sampled texture coordinate patches, so that the sampled texture coordinate patches produce a hair-like appearance; determining a second offset corresponding to the sampled texture coordinate patches, and adjusting the patch orientation of the sampled texture coordinate patches based on the second offset to obtain a hair material model.
[0005] Secondly, embodiments of the present invention also provide a hair material rendering apparatus, comprising: an arrangement module for acquiring a model to be rendered and determining the final texture coordinates of the model to be rendered; a first offset module for determining a first offset amount corresponding to the final texture coordinates, and performing vertex offset on vertices in the final texture coordinates based on the first offset amount to obtain offset texture coordinate patches; a sampling module for performing texture sampling on the offset texture coordinate patches to obtain sampled texture coordinate patches, so that the sampled texture coordinate patches produce a hair-like appearance; and a second offset module for determining a second offset amount corresponding to the sampled texture coordinate patches, and adjusting the patch orientation of the sampled texture coordinate patches based on the second offset amount to obtain a hair material model.
[0006] Thirdly, embodiments of the present invention also provide an electronic device, including a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the method described in any of the first aspects.
[0007] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method described in any of the first aspects.
[0008] The hair material rendering method, apparatus, electronic device, and readable storage medium provided in this invention, after acquiring the model to be rendered, determine the final texture coordinates of the model, then determine the first offset corresponding to the final texture coordinates, and perform vertex offset on the vertices in the final texture coordinates based on the first offset to obtain offset texture coordinate patches. Next, perform texture sampling on the offset texture coordinate patches to obtain sampled texture coordinate patches, so that the sampled texture coordinate patches produce a hair-like effect. Finally, determine the second offset corresponding to the sampled texture coordinate patches, and adjust the orientation of the sampled texture coordinate patches based on the second offset to obtain the hair material model. Before actual rendering, the above method rearranges the texture coordinate patches of the model to be rendered to simulate multiple renderings of the model, significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture sampling based on the first offset can give the model a noticeable jagged appearance. Finally, adjusting the patch orientation based on the second offset yields a hair material model with better rendering effect. This invention also effectively alleviates the problem of obvious flaws being visible when viewing the model at close range.
[0009] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0010] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0011] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of an existing hair rendering scheme provided in an embodiment of the present invention;
[0013] Figure 2 A flowchart illustrating a hair material rendering method provided in an embodiment of the present invention;
[0014] Figure 3 A schematic diagram of a texture coordinate structure provided in an embodiment of the present invention;
[0015] Figure 4 A schematic diagram of a model to be rendered provided in an embodiment of the present invention;
[0016] Figure 5 A schematic diagram of a material editor provided in an embodiment of the present invention;
[0017] Figure 6 A schematic diagram of another model to be rendered provided in an embodiment of the present invention;
[0018] Figure 7 A schematic diagram of another model to be rendered provided in an embodiment of the present invention;
[0019] Figure 8 A schematic diagram of another model to be rendered provided in an embodiment of the present invention;
[0020] Figure 9 A schematic diagram of another material editor provided in an embodiment of the present invention;
[0021] Figure 10 This is a schematic diagram of a hair material model provided in an embodiment of the present invention;
[0022] Figure 11 This is a schematic diagram of the structure of a hair material rendering device provided in an embodiment of the present invention;
[0023] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] Currently, see Figure 1 The diagram illustrates an existing hair rendering scheme. This scheme slightly inflates the mesh at the vertex stage to simulate fluffy hair (this step is optional); it also adds an offset value for hair jitter, which is then used to create the hair jitter effect. At the pixel stage, it samples multiple layers of disparity maps to simulate the hair effect. The disparity UV (texture coordinates) of each layer are inversely padded with the offset value of that layer. This, combined with the previous vertex offset, produces a visual effect where the bottom remains stationary while the movement increases towards the top. In the existing hair rendering scheme, completing the vertex and pixel stages constitutes one pass. For a model, the vertex and pixel stages are repeated multiple times. Each pass expands the vertex positions outward by a fixed value, and the disparity map layer by layer corrects the UV offset, ultimately achieving the visual hair effect. However, the above-mentioned hair rendering schemes have problems such as high performance pressure, poor jagged texture, and obvious flaws. Based on this, the present invention provides a hair material rendering method, device, electronic device, and readable storage medium, which can significantly reduce the performance pressure of hair rendering, make the model have obvious jagged texture, and effectively alleviate the problem of obvious flaws that can be found when viewing the model at close range.
[0026] To facilitate understanding of this embodiment, a hair material rendering method disclosed in this invention will first be described in detail, see [link to relevant documentation]. Figure 2 The diagram shows a flowchart of a hair material rendering method, which mainly includes the following steps S202 to S208:
[0027] Step S202: Obtain the model to be rendered and determine the final texture coordinates of the model to be rendered. Specifically, each face of the model to be rendered is unfolded and tiled to obtain a texture coordinate unfolded map, and each face of the model to be rendered is superimposed and fills the entire texture coordinate as the final texture coordinate of the model to be rendered.
[0028] Step S204: Determine the first offset corresponding to the final texture coordinates, and perform vertex offset on the vertices in the final texture coordinates based on the first offset to obtain the offset texture coordinate patch. In one embodiment, the texture coordinates of the vertices in the final texture coordinates can be used as parameters to perform vertex offset on each vertex, so that each vertex is squeezed outward, which is manifested as each vertex becoming a patch, and this patch can be recorded as the offset texture coordinate patch.
[0029] Step S206: The offset texture coordinate patch is sampled to obtain a sampled texture coordinate patch, thereby creating a hair-like effect on the sampled texture coordinate patch. In one embodiment, texture sampling is performed on each UV of the offset texture coordinate patch to create a hair-like effect on the sampled texture coordinate patch.
[0030] Step S208: Determine the second offset corresponding to the sampled texture coordinate patch, and adjust the patch orientation based on the second offset to obtain the hair material model. The second offset is used to adjust the patch orientation. In one embodiment, the texture coordinates of the vertices in the sampled texture coordinate patch can be used as parameters to offset each vertex, so that the patch faces the camera, thereby effectively improving the problem of severe hair interweaving in some locations.
[0031] The hair material rendering method provided in this embodiment of the invention rearranges the texture coordinate patches of the model to be rendered before actual rendering to simulate multiple renderings of the model, thereby significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture application are performed based on the first offset, which can make the model have obvious jagged edges. Finally, the orientation of the patches is adjusted based on the second offset to obtain a hair material model with better hair material rendering effect. This embodiment of the invention can also effectively alleviate the problem that obvious flaws can be found when viewing the model at close range.
[0032] To facilitate understanding of the foregoing embodiments, this invention provides a specific implementation method for hair material rendering.
[0033] Specifically, this embodiment of the invention provides an implementation method for step S202. When determining the final texture coordinates of the model to be rendered, the following can be referred to:
[0034] Each face of the model to be rendered is unfolded and tiled to obtain a texture coordinate unfolded map (i.e., the initial texture coordinates). The faces of the model are then superimposed and filled to create the final texture coordinates of the model to be rendered (i.e., the specially processed texture coordinates). See, for an example... Figure 3 The diagram illustrates a texture coordinate system. The left image shows the initial texture coordinates, and the right image shows the texture coordinates after special processing. Taking a cube-shaped model to be rendered as an example, the software's default texture coordinate unfolding is shown in the left image. The specially processed texture coordinates are obtained by superimposing each face of the model and filling the entire texture coordinate system, as shown in the right image.
[0035] For example, see Figure 4 The image shown is a schematic diagram of a model to be rendered. Figure 4The diagram illustrates the rearranged model to be rendered. In one implementation, the initial texture coordinate structure can be evenly rearranged multiple times onto the model to be rendered, such as... Figure 4 As shown, this fills the entire UV with the four vertices of each face of the model to be rendered.
[0036] Specifically, this embodiment of the invention provides an implementation of step S204. When determining the first offset corresponding to the final texture coordinates, the first offset corresponding to the final texture coordinates can be determined based on the texture coordinates of the vertices, model normals, intensity control parameters, and the tangent space to world space matrix in the final texture coordinates. In a specific implementation, see steps 1 to 3 below:
[0037] Step 1: Map the vertex texture coordinates in the final texture coordinates to the specified tangent interval. Optionally, the vertex UV can be mapped from [0, 1] to [-1, 1], where the specified tangent interval is also [-1, 1]. For example, the vertex UV can be mapped from [0, 1] to [-1, 1] using "(uv*2)-1".
[0038] Step 2: Based on the texture coordinates, model normals, and intensity control parameters within the specified tangent interval, generate the 3D vector corresponding to the vertex in the final texture coordinates. In one implementation, the product of the texture coordinates "(uv*2)-1", the model's self-generated normal, and the intensity control parameter customvalue within the specified tangent interval can be used as the 3D vector corresponding to the vertex, where the intensity control parameter customvalue is a user-defined parameter.
[0039] Step 3: Based on the tangent space to world space matrix, map the 3D vector corresponding to the vertex in the final texture coordinates from the specified tangent interval to the world space to obtain the first offset corresponding to the final texture coordinates.
[0040] For ease of understanding, see [link to relevant documentation]. Figure 5 The diagram shown is a schematic of a material editor. Figure 5 The meanings of each node are as follows: Multiply: mathematical symbol for "multiply"; Subtract: mathematical symbol for "subtract"; Saturate: a function that limits the input value to the range of 0-1; Mask B: outputs the B channel of the input value; Texcoord: the UV of the model; VertexNormalWS: the normal of the vertex (world coordinate space); Append: combines multiple values into a new vector. In the figure, A is a two-dimensional vector and B is a one-dimensional vector, so the output is a three-dimensional vector (Ax, Ay, Bx); Zoffset: a custom parameter, equivalent to customvual; Zpower: adjusts the intensity of the whole again, equivalent to customvual.
[0041] like Figure 5 The formula shown can be used to obtain the first offset:
[0042] vec3((uv*2)-1,normal.b*customvuale)*X;
[0043] Where X is the tangent space to world space matrix (i.e., the tangent space to world space matrix mentioned above), provided by the game engine (UE); (uv*2)-1 maps UV from [0,1] to [-1,1], and in normal.b*customvalue, normal is the model's self-generated normal, and customvalue is a custom parameter that controls the intensity.
[0044] In practical applications, after a special UV arrangement, each quad face will have a UV structure. Then, the first offset is determined using the aforementioned formula. Based on this first offset, vertex offsets are applied to the vertices in the final texture coordinates, achieving an outward extrusion effect, such as... Figure 6 A schematic diagram of another model to be rendered, and Figure 7 This is a schematic diagram of another model to be rendered. Figure 6 The outward squeezing effect after vertex offset is illustrated using a cube model as an example. Figure 7 This illustrates the outward extrusion effect after vertex offsetting in each final texture coordinate of the model to be rendered.
[0045] Specifically, this embodiment of the invention provides an implementation method for step S206. When performing texture sampling on the offset texture coordinate patch, a hair texture can be used to perform texture sampling on the offset texture coordinate patch. The texture sampling is a normal direct sampling, such as... Figure 8 The diagram shows another model to be rendered, where the left image is the hair texture used for the model to be rendered, and the right image is the effect of the model to be rendered after the texture is sampled.
[0046] Specifically, this embodiment of the invention provides an implementation of step S206. When determining the second offset corresponding to the sampled texture coordinate patch, the second offset corresponding to the sampled texture coordinate patch can be determined based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix. In a specific implementation, see steps a to b below:
[0047] Step a: Based on the texture coordinates of the vertices in the sampled texture coordinate patch and the intensity control parameters, determine the target orientation vector corresponding to the vertices in the sampled texture coordinate patch. See steps a1 to a3 below for details:
[0048] Step a1: In camera space, determine the initial orientation vector corresponding to each vertex in the sampled texture coordinate patch based on the vertices in the sampled texture coordinate patch. In one embodiment, the vertices in the sampled texture coordinate patch can be mapped in camera space, mapping the left side of the UV from [0,1] to [-1,1], thus obtaining the initial orientation vector corresponding to the vertex.
[0049] Step a2: Based on the camera space to local space matrix, map the initial orientation vectors corresponding to the vertices in the sampled texture coordinate patch from camera space to local space. In one implementation, the initial orientation vectors can be transformed from camera coordinate space to local coordinate space using the camera space to local space matrix provided by the game engine.
[0050] Step a3: In local space, the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch is scaled using the intensity control parameter to obtain the target orientation vector corresponding to the vertex in the sampled texture coordinate patch. Optionally, the initial orientation vector can be scaled by calculating the product of the intensity control parameter and the initial orientation vector corresponding to the vertex, thereby obtaining the target orientation vector corresponding to the vertex.
[0051] Step b: Based on the local space to world space matrix, map the target orientation vector corresponding to the vertex in the sampled texture coordinate patch from local space to world space to obtain the second offset corresponding to the sampled texture coordinate patch. In one implementation, the target orientation vector can be transformed from local coordinate space to world coordinate space using the local space to world space matrix provided by the game engine to obtain the required second offset.
[0052] For ease of understanding, see [link to relevant documentation]. Figure 9 The diagram shows another material editor. Figure 9 The meanings of each node are as follows: Lerp: interpolates between A and B, and the final value depends on Alpha. Alpha = 0 takes the value A, and Alpha = 1 takes the value B; PolygonSize: a custom parameter, equivalent to customvalue.
[0053] like Figure 9 The formula shown can be used to obtain the second offset:
[0054] vec3((uv*2)-1,0)*Y*customvuale*Z;
[0055] Where (uv*2)-1 maps the left side of UV from [0,1] to [-1,1]; Y is the camera space to local space matrix, which is a built-in matrix of the engine and can transform a vector from camera coordinate space to local coordinate space; Z is the local space to world space matrix, which is a built-in matrix of the engine and can transform a vector from local coordinate space to world coordinate space.
[0056] Because the orientation of each sampled texture coordinate patch is inconsistent, some locations may exhibit severe overlapping. Therefore, it is necessary to recalculate the orientation of each sampled texture coordinate patch to face the camera, and replace the vertex offset value (i.e., the aforementioned first offset) with a second offset, such as... Figure 10 The image shown is a schematic diagram of a hair material model. Figure 10 The illustration shows the final rendering effect of the hair material rendering method provided in the embodiment of the present invention.
[0057] In summary, the hair material rendering method provided in this embodiment of the invention is not suitable for multi-pass rendering. This embodiment of the invention presents the final effect through a single pass, which can effectively reduce performance pressure. In addition, this embodiment of the invention achieves the edge jagged effect through vertex offset and texture sampling. Furthermore, this embodiment of the invention does not use existing parallax algorithms, so there are no inherent flaws in parallax algorithms. The model rendered by the hair material rendering method provided in this embodiment of the invention does not have obvious flaws when viewed at very close distances.
[0058] Regarding the hair material rendering method provided in the foregoing embodiments, this invention provides a hair material rendering apparatus, see [link to previous embodiment]. Figure 11 The diagram shows a structural schematic of a hair texture rendering device, which mainly includes the following parts:
[0059] The layout module 1102 is used to obtain the model to be rendered and determine the final texture coordinates of the model to be rendered;
[0060] The first offset module 1104 is used to determine the first offset amount corresponding to the final texture coordinates, and to perform vertex offset on the vertices in the final texture coordinates based on the first offset amount to obtain the offset texture coordinate patch.
[0061] The sampling module 1106 is used to perform texture sampling on the offset texture coordinate patch to obtain the sampled texture coordinate patch, so that the sampled texture coordinate patch produces a hair-like effect.
[0062] The second offset module 1108 is used to determine the second offset corresponding to the sampled texture coordinate patch, and adjust the orientation of the sampled texture coordinate patch based on the second offset to obtain the hair material model.
[0063] The hair material rendering device provided in this embodiment of the invention rearranges the texture coordinate patches of the model to be rendered before actual rendering to simulate multiple renderings of the model, thereby significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture application are performed based on the first offset, which can make the model have obvious jagged edges. Finally, the orientation of the patches is adjusted based on the second offset to obtain a hair material model with better hair material rendering effect. This embodiment of the invention can also effectively alleviate the problem that obvious flaws can be found when viewing the model at close range.
[0064] In one embodiment, the layout module 1102 is further configured to: unfold and tile each face of the model to be rendered to obtain a texture coordinate unfolded map, and superimpose each face of the model to be rendered and fill the entire texture coordinate as the final texture coordinate of the model to be rendered.
[0065] In one embodiment, the first offset module 1104 is further configured to: determine the first offset corresponding to the final texture coordinates based on the texture coordinates of the vertices in the final texture coordinates, the model's self-generated normals, the intensity control parameters, and the tangent space to world space matrix.
[0066] In one embodiment, the first offset module 1104 is further configured to: map the texture coordinates of the vertices in the final texture coordinates to a specified tangent interval; generate a three-dimensional vector corresponding to the vertices in the final texture coordinates based on the texture coordinates, model self-generated normals, and intensity control parameters within the specified tangent interval; and map the three-dimensional vector corresponding to the vertices in the final texture coordinates from the specified tangent interval to the world space according to the tangent space to world space matrix to obtain the first offset corresponding to the final texture coordinates.
[0067] In one embodiment, the second offset module 1108 is further configured to: determine the second offset corresponding to the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix.
[0068] In one embodiment, the second offset module 1108 is further configured to: determine the target orientation vector corresponding to the vertex in the sampled texture coordinate patch based on the texture coordinates and intensity control parameters of the vertex in the sampled texture coordinate patch; and map the target orientation vector corresponding to the vertex in the sampled texture coordinate patch from the local space to the world space based on the local space to world space matrix to obtain the second offset corresponding to the sampled texture coordinate patch.
[0069] In one embodiment, the second offset module 1108 is further configured to: in camera space, determine the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch based on the vertex in the sampled texture coordinate patch; map the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch from camera space to local space based on the camera space to local space matrix; and in local space, scale the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch using intensity control parameters to obtain the target orientation vector corresponding to the vertex in the sampled texture coordinate patch.
[0070] The device provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0071] This invention provides an electronic device, specifically, the electronic device includes a processor and a storage device; the storage device stores a computer program, which is executed by the processor when it runs:
[0072] A method for rendering hair texture includes: acquiring a model to be rendered and determining the final texture coordinates of the model to be rendered; determining a first offset corresponding to the final texture coordinates, and performing vertex offset on the vertices in the final texture coordinates based on the first offset to obtain an offset texture coordinate patch; performing texture sampling on the offset texture coordinate patch to obtain a sampled texture coordinate patch, so that the sampled texture coordinate patch produces a hair-like effect; determining a second offset corresponding to the sampled texture coordinate patch, and adjusting the patch orientation of the sampled texture coordinate patch based on the second offset to obtain a hair texture model.
[0073] In one implementation, determining the final texture coordinates of a model to be rendered includes: unfolding and tiling each face of the model to be rendered to obtain a texture coordinate unfolded map, and superimposing each face of the model to be rendered and filling the entire texture coordinate as the final texture coordinates of the model to be rendered.
[0074] In one implementation, determining the first offset corresponding to the final texture coordinates includes: determining the first offset corresponding to the final texture coordinates based on the texture coordinates of the vertices, the model's self-generated normals, the intensity control parameters, and the tangent space to world space matrix in the texture coordinate structure.
[0075] In one implementation, determining the first offset corresponding to the final texture coordinates based on the texture coordinates of the vertices in the final texture coordinates, the model's self-generated normals, the intensity control parameters, and the tangent space to world space matrix includes: mapping the texture coordinates of the vertices in the final texture coordinates to a specified tangent interval; generating a three-dimensional vector corresponding to the vertices in the final texture coordinates based on the texture coordinates, model's self-generated normals, and intensity control parameters within the specified tangent interval; and mapping the three-dimensional vector corresponding to the vertices in the final texture coordinates from the specified tangent interval to world space according to the tangent space to world space matrix to obtain the first offset corresponding to the final texture coordinates.
[0076] In one embodiment, determining the second offset corresponding to the sampled texture coordinate patch includes: determining the second offset corresponding to the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix.
[0077] In one implementation, determining the second offset corresponding to the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix includes: determining the target orientation vector corresponding to the vertices in the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch and the intensity control parameters; and mapping the target orientation vector corresponding to the vertices in the sampled texture coordinate patch from the local space to the world space based on the local space to world space matrix to obtain the second offset corresponding to the sampled texture coordinate patch.
[0078] In one implementation, determining the target orientation vector corresponding to a vertex in a sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch and intensity control parameters includes: in camera space, determining the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch based on the vertices in the sampled texture coordinate patch; mapping the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch from camera space to local space based on the camera space to local space matrix; and in local space, scaling the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch using intensity control parameters to obtain the target orientation vector corresponding to a vertex in the sampled texture coordinate patch.
[0079] The electronic device provided in this invention rearranges the texture coordinate patches of the model to be rendered before actual rendering to simulate multiple renderings of the model, thereby significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture application are performed based on the first offset, which can make the model have obvious jagged edges. Finally, the orientation of the patches is adjusted based on the second offset to obtain a hair material model with better hair material rendering effect. This invention can also effectively alleviate the problem that obvious flaws can be found when viewing the model at close range.
[0080] Figure 12 The present invention provides a schematic diagram of the structure of an electronic device 100, which includes a processor 120, a memory 121, a bus 122 and a communication interface 123. The processor 120, the communication interface 123 and the memory 121 are connected through the bus 122. The processor 120 is used to execute executable modules, such as computer programs, stored in the memory 121.
[0081] The memory 121 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 123 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc.
[0082] Bus 122 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0083] The memory 121 is used to store programs. After receiving an execution instruction, the processor 120 executes the program. The method executed by the device for defining the flow process disclosed in any of the foregoing embodiments of the present invention can be applied to the processor 120 or implemented by the processor 120.
[0084] Processor 120 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 120 or by instructions in software form. Processor 120 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 121, and processor 120 reads the information from memory 121 and, in conjunction with its hardware, completes the steps of the above method.
[0085] The computer program product of the readable storage medium provided in the embodiments of the present invention includes a computer-readable storage medium storing program code, wherein the program code includes instructions that can be executed:
[0086] A method for rendering hair texture includes: acquiring a model to be rendered and determining the final texture coordinates of the model to be rendered; determining a first offset corresponding to the final texture coordinates, and performing vertex offset on the vertices in the final texture coordinates based on the first offset to obtain an offset texture coordinate patch; performing texture sampling on the offset texture coordinate patch to obtain a sampled texture coordinate patch, so that the sampled texture coordinate patch produces a hair-like effect; determining a second offset corresponding to the sampled texture coordinate patch, and adjusting the patch orientation of the sampled texture coordinate patch based on the second offset to obtain a hair texture model.
[0087] In one implementation, determining the final texture coordinates of a model to be rendered includes: unfolding and tiling each face of the model to be rendered to obtain a texture coordinate unfolded map, and superimposing each face of the model to be rendered and filling the entire texture coordinate as the final texture coordinates of the model to be rendered.
[0088] In one implementation, determining the first offset corresponding to the final texture coordinates includes: determining the first offset corresponding to the final texture coordinates based on the texture coordinates of the vertices, the model's self-generated normals, the intensity control parameters, and the tangent space to world space matrix in the texture coordinate structure.
[0089] In one implementation, determining the first offset corresponding to the final texture coordinates based on the texture coordinates of the vertices in the final texture coordinates, the model's self-generated normals, the intensity control parameters, and the tangent space to world space matrix includes: mapping the texture coordinates of the vertices in the final texture coordinates to a specified tangent interval; generating a three-dimensional vector corresponding to the vertices in the final texture coordinates based on the texture coordinates, model's self-generated normals, and intensity control parameters within the specified tangent interval; and mapping the three-dimensional vector corresponding to the vertices in the final texture coordinates from the specified tangent interval to world space according to the tangent space to world space matrix to obtain the first offset corresponding to the final texture coordinates.
[0090] In one embodiment, determining the second offset corresponding to the sampled texture coordinate patch includes: determining the second offset corresponding to the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix.
[0091] In one implementation, determining the second offset corresponding to the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix includes: determining the target orientation vector corresponding to the vertices in the sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch and the intensity control parameters; and mapping the target orientation vector corresponding to the vertices in the sampled texture coordinate patch from the local space to the world space based on the local space to world space matrix to obtain the second offset corresponding to the sampled texture coordinate patch.
[0092] In one implementation, determining the target orientation vector corresponding to a vertex in a sampled texture coordinate patch based on the texture coordinates of the vertices in the sampled texture coordinate patch and intensity control parameters includes: in camera space, determining the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch based on the vertices in the sampled texture coordinate patch; mapping the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch from camera space to local space based on the camera space to local space matrix; and in local space, scaling the initial orientation vector corresponding to a vertex in the sampled texture coordinate patch using intensity control parameters to obtain the target orientation vector corresponding to a vertex in the sampled texture coordinate patch.
[0093] The readable storage medium provided in this invention rearranges the texture coordinate patches of the model to be rendered before actual rendering to simulate multiple renderings of the model, thereby significantly reducing the performance pressure of hair rendering. Based on this, vertex offset and texture application are performed based on the first offset, which can make the model have obvious jagged edges. Finally, the orientation of the patches is adjusted based on the second offset to obtain a hair material model with better hair material rendering effect. This invention can also effectively alleviate the problem that obvious flaws can be found when viewing the model at close range.
[0094] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0095] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for rendering hair texture, characterized in that, include: Obtain the model to be rendered and determine the final texture coordinates of the model to be rendered; wherein, determining the final texture coordinates of the model to be rendered includes: unfolding and tiling each face of the model to be rendered to obtain a texture coordinate unfolded map, and superimposing each face of the model to be rendered and filling the entire texture coordinate as the final texture coordinates of the model to be rendered. Determine the first offset corresponding to the final texture coordinates, and perform vertex offset on the vertices in the final texture coordinates based on the first offset to obtain the offset texture coordinate patch; The offset texture coordinate patch is sampled to obtain a sampled texture coordinate patch, so that the sampled texture coordinate patch can produce a hair-like texture. Determine the second offset corresponding to the sampled texture coordinate patch, and adjust the orientation of the sampled texture coordinate patch based on the second offset so that the patch faces the camera to obtain the hair material model.
2. The hair material rendering method according to claim 1, characterized in that, Determining the first offset corresponding to the final texture coordinates includes: The first offset corresponding to the final texture coordinates is determined based on the vertex texture coordinates, model self-generated normals, intensity control parameters, and tangent space to world space matrix in the final texture coordinates.
3. The hair material rendering method according to claim 2, characterized in that, Based on the vertex texture coordinates, model self-generated normals, intensity control parameters, and the tangent space to world space matrix in the final texture coordinates, the first offset corresponding to the final texture coordinates is determined, including: Map the texture coordinates of the vertices in the final texture coordinates to the specified tangent interval; Based on the texture coordinates, model-generated normals, and intensity control parameters within the specified tangent interval, a three-dimensional vector corresponding to the vertex in the final texture coordinates is generated. Based on the tangent space to world space matrix, the three-dimensional vector corresponding to the vertex in the final texture coordinates is mapped from the specified tangent interval to world space to obtain the first offset corresponding to the final texture coordinates.
4. The hair material rendering method according to claim 1, characterized in that, Determining the second offset corresponding to the sampled texture coordinate patch includes: The second offset corresponding to the sampled texture coordinate patch is determined based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix.
5. The hair material rendering method according to claim 4, characterized in that, Based on the texture coordinates of the vertices in the sampled texture coordinate patch, the intensity control parameters, and the local space to world space matrix, the second offset corresponding to the sampled texture coordinate patch is determined, including: Based on the texture coordinates and intensity control parameters of the vertices in the sampled texture coordinate patch, determine the target orientation vector corresponding to the vertices in the sampled texture coordinate patch; Based on the local space to world space matrix, the target orientation vector corresponding to the vertex in the sampled texture coordinate patch is mapped from local space to world space to obtain the second offset corresponding to the sampled texture coordinate patch.
6. The hair material rendering method according to claim 5, characterized in that, Based on the texture coordinates and intensity control parameters of the vertices in the sampled texture coordinate patch, the target orientation vector corresponding to the vertices in the sampled texture coordinate patch is determined, including: In camera space, the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch is determined based on the vertex in the sampled texture coordinate patch; Based on the camera space to local space matrix, the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch is mapped from the camera space to the local space; In the local space, the initial orientation vector corresponding to the vertex in the sampled texture coordinate patch is scaled using the intensity control parameter to obtain the target orientation vector corresponding to the vertex in the sampled texture coordinate patch.
7. A hair texture rendering device, characterized in that, include: The layout module is used to obtain the model to be rendered and determine the final texture coordinates of the model to be rendered; wherein, determining the final texture coordinates of the model to be rendered includes: unfolding and tiling each face of the model to be rendered to obtain a texture coordinate unfolded map, and superimposing each face of the model to be rendered and filling the entire texture coordinate as the final texture coordinates of the model to be rendered. The first offset module is used to determine the first offset amount corresponding to the final texture coordinates, and to perform vertex offset on the vertices in the final texture coordinates based on the first offset amount to obtain the offset texture coordinate patch. The sampling module is used to perform texture sampling on the offset texture coordinate patch to obtain a sampled texture coordinate patch, so that the sampled texture coordinate patch produces a hair-like texture. The second offset module is used to determine the second offset amount corresponding to the sampled texture coordinate patch, and adjust the orientation of the sampled texture coordinate patch based on the second offset amount so that the patch faces the camera to obtain the hair material model.
8. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the method of any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Hair model generation method and device, computer equipment and storage medium
CN114842119A