A method, apparatus, device, and medium for outlining skeletal animated characters.
By using offline pre-computation and runtime space transformation, the smooth normals of the skeletal animation character model are converted to tangent space storage. Combined with the skeletal transformation matrix, smooth normals in world space are generated, which solves the problem of stroke breakage and misalignment of skeletal animation characters and achieves efficient and continuous stroke effects.
Patent Information
- Application Number
- CN202611346463.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-06
AI Technical Summary
In existing technologies for rendering skeletal animation characters, the outline effect is prone to breakage and misalignment, and the computational resources consumed are too large, making it difficult to maintain high-quality continuous outlines in real-time rendering scenes.
By pre-compiling smooth normals in the model space offline and converting them to tangent space for storage, and combining them with the runtime skeleton transformation matrix to construct the TBN transformation matrix, smooth normals in the world space are quickly generated for outlining.
During the movement of skeletal animation characters, ensuring continuous and smooth outlines reduces computational load, solves the problems of outline breakage and misalignment, and improves rendering efficiency.
Smart Images

Figure CN123052160A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics rendering technology, and in particular to a method, apparatus, device and medium for outlining skeletal animated characters. Background Technology
[0002] Adding outlines (outlines) to objects is an important technique in non-realistic rendering, widely used in animation, games, and other scenarios. Currently, a relatively efficient and flexible method for rendering outlines of static objects is to achieve this through material normal expansion. The normals used for expansion are not the original geometric normals used in the model's shading calculations, but rather smoothed normals. This is because if the original normals of the model were used directly for expansion, discontinuities would appear at the expanded vertex positions at the model's edges or abrupt changes in normals, resulting in visual defects such as broken or misaligned outlines, severely impacting the visual quality of the outline.
[0003] However, the aforementioned smooth normal-based outlining scheme is primarily applicable to static objects and cannot be directly applied to 3D skeletal animation characters. This is because skeletal animation characters undergo real-time deformation of model vertices through bone skinning, resulting in continuous changes in the direction of normals in model space. If the processing method used for static objects is applied, theoretically, the smooth normals for the current pose need to be recalculated every frame during runtime, which consumes enormous computational resources and is inefficient and unacceptable in real-time rendering scenarios. If the real-time calculation of smooth normals is abandoned, and the original deformed normals are directly used for outlining, the same stroke breakage problem as the hard edge outlining of static objects will inevitably occur, severely impairing the rendering effect. Therefore, how to obtain smooth, continuous, and high-quality outlining effects with lower runtime overhead in the outlining rendering of skeletal animation characters has become a pressing technical challenge in this field. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method, apparatus, device and medium for outlining skeletal animation characters. By combining offline pre-computation with runtime space transformation, continuous and smooth outlining can be obtained with low performance overhead during real-time rendering of skeletal animation, and high-quality outlining effect can still be maintained when the character is moving.
[0005] This application provides a method for outlining a skeletal animated character, the outlining method including: Calculate the smooth normals in model space for each vertex of the target character's model; For each vertex, the model space smooth normal of that vertex is transformed to the tangent space to obtain the tangent space smooth normal of that vertex. Write the tangent space smooth normal of each vertex into the preset vertex properties of the corresponding vertex for storage; When rendering the animation of the target character, the TBN transformation matrix of each vertex from tangent space to world space is constructed in real time based on the skeletal transformation matrix of the target character in the current frame. For each vertex, the tangent space smoothing normal is read from the vertex's preset vertex attributes, and the world space smoothing normal of the vertex in the current frame is determined based on the tangent space smoothing normal of the vertex and the TBN transformation matrix. Based on the smooth world space normals of each vertex in the current frame, the model of the target character is expanded with normals to generate the outline of the target character in the current frame.
[0006] Furthermore, the model space smoothing normals of each vertex of the target character's model are calculated, including: Traverse each triangle unit of the target character's model, and perform the following processing on each vertex of each triangle: obtain two adjacent edge vectors starting from the current vertex, calculate the angle between the two adjacent edge vectors, perform a cross product operation on the two adjacent edge vectors and normalize them to obtain the face normal of the current vertex under the triangle, and use the angle value as the weight corresponding to the face normal. For each vertex, the face normals and corresponding weights of all triangles to which it belongs are summarized, the total weight is calculated, and the face normals are weighted and summed according to the ratio of their corresponding weights to the total weight. The summation result is then normalized to obtain the smooth normal of the model space for that vertex.
[0007] Furthermore, calculating the model space smoothing normals of each vertex of the target character's model also includes: Before calculating the angle between two adjacent vectors and performing the cross product operation on the two adjacent vectors, each of the two adjacent vectors is magnified by a preset factor.
[0008] Furthermore, for each vertex, the model space smooth normal of that vertex is transformed to the tangent space to obtain the tangent space smooth normal of that vertex, including: Obtain the original normal and original tangent in the model space of the vertex; The secondary tangent is calculated based on the original normal and the original tangent; Using the original tangent, secondary tangent, and original normal in the model space as row vectors, a first TBN matrix is constructed. The first TBN matrix is the transformation matrix from the tangent space to the model space. Transpose the first TBN matrix to obtain the second TBN matrix from the model space to the tangent space; Multiply the model space smooth normal of the vertex by the second TBN matrix to obtain the tangent space smooth normal of the vertex.
[0009] Furthermore, based on the target character's skeletal transformation matrix in the current frame, a TBN transformation matrix for each vertex from tangent space to world space is constructed in real time, including: The tangent, bitangent, and normal of each vertex in world space are determined based on the bone transformation matrix of the current frame. Using the tangent, bitangent, and normal in world space as row vectors, we construct the TBN transformation matrix for each vertex from tangent space to world space.
[0010] Furthermore, the world space smooth normal of the vertex in the current frame is determined based on the tangent space smooth normal of the vertex and the TBN transformation matrix, including: Multiply the tangent space smooth normal of the vertex by the TBN transformation matrix to obtain the world space smooth normal of the vertex in the current frame.
[0011] Furthermore, the preset vertex attributes are stored in the second set of UV coordinate channels in the model mesh of the target character.
[0012] This application embodiment also provides a tracing device for a skeletal animation character, the tracing device comprising: The calculation module is used to calculate the model space smoothing normals of each vertex of the target character's model; The transformation module is used to transform the model space smooth normal of each vertex to the tangent space to obtain the tangent space smooth normal of that vertex. The storage module is used to write the tangent space smooth normal of each vertex into the preset vertex attributes of the corresponding vertex for storage; The construction module is used to construct the TBN transformation matrix of each vertex from tangent space to world space in real time based on the skeletal transformation matrix of the target character in the current frame when performing animation rendering of the target character. The determination module is used to read the tangent space smoothing normal from the preset vertex attributes of each vertex, and determine the world space smoothing normal of the vertex in the current frame based on the tangent space smoothing normal of the vertex and the TBN transformation matrix. The generation module is used to extend the normals of the target character's model based on the smooth normals of each vertex in the world space of the current frame, and generate the outline of the target character in the current frame.
[0013] This application embodiment also provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the outline method for skeletal animation characters described above are performed.
[0014] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the outline method for a skeletal animation character as described above.
[0015] This application provides a method, apparatus, device, and medium for outlining skeletal animated characters. The smooth normal is converted to tangent space for storage. At runtime, the world space TBN matrix is constructed by combining the skeletal transformation matrix of the current frame, which can quickly restore the accurate world space smooth normal under the current pose.
[0016] In this way, regardless of the character's animation posture, the outward stroke lines can be guaranteed to be continuous and smooth, resolving visual defects such as broken or misaligned strokes in skeletal animation characters. Furthermore, by moving the computationally intensive weighted calculation of smoothing normals to the offline preprocessing stage, the process only needs to be performed once on a single model for permanent reuse. During runtime, only the stored tangent space smoothing normals need to be read from the vertex attributes, and a simple spatial transformation using the TBN matrix is required to obtain the world space smoothing normals for outward strokes, reducing runtime computation and computational load.
[0017] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating a skeletal animation character outline method provided in an embodiment of this application is shown; Figure 2 This illustration shows a structural schematic diagram of a skeletal animation character outline device provided in an embodiment of this application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.
[0021] Research has shown that adding outlines (outlines) to objects is an important technique in non-realistic rendering, widely used in animation, games, and other scenarios. Currently, a relatively efficient and flexible method for rendering outlines on static objects is to achieve this through normal expansion in the material. The rendering process of this method is as follows: First, the object is rendered normally; then, the object's vertices are expanded outward along the normal direction, causing the object to expand its area in screen space. The expanded area is then rendered as the outline color and superimposed on the original object to create the outline effect. It's important to note that the normals used for expansion are not the original geometric normals used in the model's shading calculations, but rather smooth normals. This is because if the model's original hard-edge normals are used directly for expansion, discontinuities will appear at the edges or abrupt changes in normals, resulting in broken or misaligned outline lines and other visual defects, severely affecting the visual quality of the outline.
[0022] Based on this, this application provides a method for outlining skeletal animation characters, which can obtain continuous and smooth outlines with lower performance overhead during real-time rendering of skeletal animation, and maintain high-quality outline effects even when the character is moving.
[0023] Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for outlining a skeletal animated character, as provided in an embodiment of this application. Figure 1 As shown in the figure, the outlining method for skeletal animation characters provided in this application embodiment includes steps S101 to S106. This outlining method can be divided into two stages: offline preprocessing and runtime rendering. The offline preprocessing stage is executed in the model editing environment and only needs to be executed once, specifically including steps S101 to S103; the runtime rendering stage is executed frame-by-frame during real-time rendering, specifically including steps S101 to S106. The execution method of each step will be described in detail below.
[0024] S101. Calculate the model space smoothing normals of each vertex of the target character's model.
[0025] This step is performed in model space, calculating the smooth normal of each vertex using an angle-weighted method to ensure the stroke lines remain continuous and unbroken during subsequent stroke expansion. The specific implementation process is as follows: First, initialize the data structure: create a vertex-normal-weight mapping dictionary to map each vertex index to the corresponding list of normal weights. The normal weights are stored as structures, each containing a face normal vector and a weight value. Simultaneously, load the triangle index data, vertex coordinate data, original normal data, and original tangent data of the target character model mesh; these data can be directly read from standard mesh format files, and this application does not impose any restrictions on this.
[0026] Next, traverse all triangular units, that is, according to the triangle index, take three vertex indices to form a triangle each time. For each traversed triangle, read the indices of the three vertices of the triangle in sequence (for example, the vertices corresponding to indices 0, 1, and 2 respectively), and process the three vertices of the triangle as follows: Step 1: For the target vertex in the current triangle, obtain the two adjacent edge vectors originating from that vertex; for example, for vertex 0, the two adjacent edges are the vectors pointing from vertex 0 to vertex 1 and from vertex 0 to vertex 2; for vertex 1, the two adjacent edges are the vectors pointing from vertex 1 to vertex 2 and from vertex 1 to vertex 0; for vertex 2, the two adjacent edges are the vectors pointing from vertex 2 to vertex 0 and from vertex 2 to vertex 1.
[0027] Step 2: Calculate the angle (in radians) between the two adjacent edge vectors and use this angle as the weight in the subsequent weighted average. The larger the angle, the greater the contribution of the vertex to the triangle. Simultaneously, perform a cross product operation on the two adjacent edge vectors and normalize the result to obtain the face normal of the triangle at the target vertex. This face normal represents the geometric normal direction of the vertex within the local region of the triangle.
[0028] Preferably, before calculating the angle between two adjacent edge vectors and performing the cross product operation on them, each edge vector is first enlarged by a preset factor, and then the cross product operation is performed and normalized. This is because when the model scale is small or the triangle is narrow, the values of the edge vectors may be very small, and direct calculation can easily introduce floating-point precision errors. In a specific embodiment, the preset factor is 10,000 times. Enlarging the edge vectors before calculation can effectively improve numerical stability and ensure the accuracy of the surface normal calculation results.
[0029] Step 3: Store the face normals and included angle values into a structure, where the included angle value serves as the weight of the face normal. Add this structure to the normal weight list of the target vertex in the mapping dictionary. Thus, the final normal weight list for each vertex contains the face normals of all triangles belonging to that vertex at that vertex and their corresponding weights.
[0030] Finally, the model space smoothing normal is calculated vertex-by-vertex: All vertices in the mapping dictionary are traversed, and a weighted average of the normal weights for each vertex is performed to obtain the model space smoothing normal for that vertex. Specifically, this includes: For each vertex, retrieve all corresponding normal weight structures from the mapping dictionary and calculate the sum of all weight values. For each normal weight structure, determine the ratio of the weight value to the total weight value and multiply it by the face normal vector. Then, add all the weighted face normal vectors together and finally normalize the sum to obtain the smooth normal of the vertex in the model space.
[0031] S102. For each vertex, transform the model space smooth normal of the vertex to the tangent space to obtain the tangent space smooth normal of the vertex.
[0032] Considering that the vertex positions and normal directions in model space continuously change with bone deformation during the movement of a skeletal animated character, directly storing the smooth normals in model space will become invalid during animation playback. Therefore, this embodiment transforms the smooth normals in model space to tangent space for storage, utilizing the characteristic that tangent space updates synchronously with vertex deformation to achieve accurate reuse of smooth normals during animation rendering.
[0033] In one possible implementation, step S102 may include: S1021. Obtain the original normal and original tangent in the model space of the vertex; these data may come from the mesh data of the target character model, and this application does not restrict them.
[0034] S1022. The secondary tangent is calculated based on the original normal and the original tangent.
[0035] In this step, the secondary tangent is calculated based on the original normal and the original tangent. The formula for calculating the secondary tangent is: Secondary tangent = Original normal × Original tangent × w-component of the original tangent.
[0036] S1023. Construct the first TBN matrix by using the original tangent, secondary tangent, and original normal in the model space as row vectors.
[0037] Here, the original tangent, secondary tangent, and original normal in the model space are used as row vectors to construct the first TBN matrix. The first TBN matrix is the transformation matrix from the tangent space to the model space; the first row: tangent; the second row: secondary tangent; the third row: normal.
[0038] S1024. Transpose the first TBN matrix to obtain the second TBN matrix obtained by inverse transformation from model space to tangent space.
[0039] S1025. Multiply the model space smooth normal of the vertex by the second TBN matrix to obtain the tangent space smooth normal of the vertex.
[0040] Here, the model space smooth normal of the vertex is multiplied by the second TBN matrix, which transforms the model space smooth normal from the model space to the tangent space to obtain the tangent space smooth normal of the vertex.
[0041] S103. Write the tangent space smooth normal of each vertex into the preset vertex attributes of the corresponding vertex for storage.
[0042] In this embodiment, the preset vertex attributes are stored in the second set of UV coordinate channels (UV2 channels) in the model mesh of the target character. The UV2 channels are typically used to store lightmap coordinates. This embodiment utilizes a general vertex channel to store custom data, eliminating the need for additional expansion of the vertex data structure and providing good compatibility.
[0043] S104. When performing animation rendering of the target character, construct the TBN transformation matrix of each vertex from tangent space to world space in real time according to the skeletal transformation matrix of the target character in the current frame.
[0044] During game or application runtime, the target character is under continuous skeletal animation, with the position and normal direction of each vertex changing every frame. During the rendering of each frame, the stroke effect for the current pose is quickly generated using offline stored tangent space smoothing normals.
[0045] In specific implementation, step S104 may include: Based on the bone transformation matrix of the current frame, determine the tangent, binormal, and normal of each vertex in world space; using the tangent, bitangent, and normal in world space as row vectors, construct the TBN transformation matrix of each vertex from tangent space to world space.
[0046] In practical implementation, skinning calculations can first be performed on each vertex based on the bone transformation matrix of the current frame to obtain the tangent vector, bitangent vector, and normal vector of that vertex in the world space coordinate system after the bone transformation of the current frame. The specific calculation method can refer to existing technologies, and this application does not impose any limitations on it.
[0047] Then, using the tangent vector, bitangent, and normal vector in world space as row vectors, a TBN transformation matrix is constructed. This TBN transformation matrix is the TBN transformation matrix from tangent space to world space. Its arrangement is similar to the first TBN matrix: the first row represents the tangent; the second row represents the bitangent; and the third row represents the normal.
[0048] S105. For each vertex, read the tangent space smoothing normal from the vertex's preset vertex attributes, and determine the vertex's world space smoothing normal in the current frame based on the vertex's tangent space smoothing normal and the TBN transformation matrix.
[0049] In practice, the tangent space smooth normal is read from the vertex's preset vertex attributes (e.g., UV2 channels). Then, the tangent space smooth normal is multiplied by the TBN transformation matrix to obtain the world space smooth normal of the vertex in the current frame. This achieves the transformation from tangent space to world space.
[0050] Through the above transformation, the offline stored tangent space smooth normal is restored to the smooth normal direction in world space in the current frame of rendering, and this direction accurately reflects the geometric features under the current bone pose.
[0051] S106. Based on the smooth normals of each vertex in the world space of the current frame, the model of the target character is expanded with normals to generate the outline of the target character in the current frame.
[0052] In practice, the model of the target character is expanded outward based on the smooth normal of each vertex in the world space of the current frame (that is, the vertex is translated outward by a certain distance along the normal direction), so that the area occupied by the model in the screen space is expanded. The expanded area is rendered as the outline color and superimposed on the normally rendered character image to generate the outline of the target character in the current frame.
[0053] The specific implementation of normal expansion can adopt existing technologies, and this application does not impose any restrictions here. Since the normals used for expansion are smooth world space normals, even in positions where the character's joints are bent or folded, the stroke lines can still remain continuous, smooth, and unbroken.
[0054] At this point, the outline rendering for the current frame is complete. Repeat steps S104 to S106 in the next frame to achieve a real-time, continuous outline effect for the skeletal animation character.
[0055] This application provides a method for outlining skeletal animation characters. The smooth normal is converted to tangent space for storage. At runtime, the world space TBN matrix is constructed by combining the skeletal transformation matrix of the current frame, so that the accurate world space smooth normal under the current pose can be quickly restored.
[0056] In this way, regardless of the character's animation posture, the outward stroke lines can be guaranteed to be continuous and smooth, resolving visual defects such as broken or misaligned strokes in skeletal animation characters. Furthermore, by moving the computationally intensive weighted calculation of smoothing normals to the offline preprocessing stage, the process only needs to be performed once on a single model for permanent reuse. During runtime, only the stored tangent space smoothing normals need to be read from the vertex attributes, and a simple spatial transformation using the TBN matrix is required to obtain the world space smoothing normals for outward strokes, reducing runtime computation and computational load.
[0057] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a skeletal animation character outlining device provided in an embodiment of this application. Figure 2 As shown, the outlining device 200 includes: Calculation module 210 is used to calculate the model space smoothing normals of each vertex of the target character's model; Transformation module 220 is used to transform the model space smooth normal of each vertex to the tangent space to obtain the tangent space smooth normal of the vertex. Storage module 230 is used to write the tangent space smooth normal of each vertex into the preset vertex attributes of the corresponding vertex for storage; The construction module 240 is used to construct the TBN transformation matrix of each vertex from tangent space to world space in real time based on the skeletal transformation matrix of the target character in the current frame when performing animation rendering of the target character. The determination module 250 is used to read the tangent space smoothing normal from the preset vertex attributes of each vertex, and determine the world space smoothing normal of the vertex in the current frame based on the tangent space smoothing normal of the vertex and the TBN transformation matrix. The generation module 260 is used to extend the normal of the target character model based on the smooth normal of each vertex in the world space of the current frame, and generate the outline of the target character in the current frame.
[0058] Furthermore, when calculating the model space smoothing normals of each vertex of the target character's model, the calculation module 210 is used to: Traverse each triangle unit of the target character's model, and perform the following processing on each vertex of each triangle: obtain two adjacent edge vectors starting from the current vertex, calculate the angle between the two adjacent edge vectors, perform a cross product operation on the two adjacent edge vectors and normalize them to obtain the face normal of the current vertex under the triangle, and use the angle value as the weight corresponding to the face normal. For each vertex, the face normals and corresponding weights of all triangles to which it belongs are summarized, the total weight is calculated, and the face normals are weighted and summed according to the ratio of their corresponding weights to the total weight. The summation result is then normalized to obtain the smooth normal of the model space for that vertex.
[0059] Furthermore, when calculating the model space smoothing normals of each vertex of the target character's model, the calculation module 210 is also used to: Before calculating the angle between two adjacent vectors and performing the cross product operation on the two adjacent vectors, each of the two adjacent vectors is magnified by a preset factor.
[0060] Furthermore, when the transformation module 220 transforms the model space smooth normal of each vertex to the tangent space to obtain the tangent space smooth normal of that vertex, the transformation module 220 is used to: Obtain the original normal and original tangent in the model space of the vertex; The secondary tangent is calculated based on the original normal and the original tangent; Using the original tangent, secondary tangent, and original normal in the model space as row vectors, a first TBN matrix is constructed. The first TBN matrix is the transformation matrix from the tangent space to the model space. Transpose the first TBN matrix to obtain the second TBN matrix from the model space to the tangent space; Multiply the model space smooth normal of the vertex by the second TBN matrix to obtain the tangent space smooth normal of the vertex.
[0061] Furthermore, when the construction module 240 constructs the TBN transformation matrix of each vertex from tangent space to world space in real time based on the skeletal transformation matrix of the target character in the current frame during animation rendering of the target character, the construction module 240 is used to: The tangent, bitangent, and normal of each vertex in world space are determined based on the bone transformation matrix of the current frame. Using the tangent, bitangent, and normal in world space as row vectors, we construct the TBN transformation matrix for each vertex from tangent space to world space.
[0062] Furthermore, when determining the world space smooth normal of a vertex in the current frame based on the tangent space smooth normal and the TBN transformation matrix, the determining module 250 is used to: Multiply the tangent space smooth normal of the vertex by the TBN transformation matrix to obtain the world space smooth normal of the vertex in the current frame.
[0063] Furthermore, the preset vertex attributes are stored in the second set of UV coordinate channels in the model mesh of the target character.
[0064] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 includes a processor 310, a memory 320, and a bus 330.
[0065] The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 and the memory 320 communicate via the bus 330. When the machine-readable instructions are executed by the processor 310, the steps of the outline method for the skeletal animation character as described in the above method embodiment can be executed. For specific implementation details, please refer to the method embodiment, which will not be repeated here.
[0066] This application also provides a computer-readable storage medium storing a computer program. When the computer program is run by a processor, it can execute the steps of the outline method for skeletal animation characters as described in the above method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.
[0067] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0068] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0069] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0070] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0071] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, 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 application. 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.
[0072] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application 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, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such 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 this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for outlining skeletal animated characters, characterized in that, The outlining method includes: Calculate the smooth normals in model space for each vertex of the target character's model; For each vertex, the model space smooth normal of that vertex is transformed to the tangent space to obtain the tangent space smooth normal of that vertex. Write the tangent space smooth normal of each vertex into the preset vertex properties of the corresponding vertex for storage; When rendering the animation of the target character, the TBN transformation matrix of each vertex from tangent space to world space is constructed in real time based on the skeletal transformation matrix of the target character in the current frame. For each vertex, the tangent space smoothing normal is read from the vertex's preset vertex attributes, and the world space smoothing normal of the vertex in the current frame is determined based on the tangent space smoothing normal of the vertex and the TBN transformation matrix. Based on the smooth world space normals of each vertex in the current frame, the model of the target character is expanded with normals to generate the outline of the target character in the current frame.
2. The outlining method according to claim 1, characterized in that, Calculate the model space smooth normals of each vertex of the target character's model, including: Traverse each triangle unit of the target character's model, and perform the following processing on each vertex of each triangle: obtain two adjacent edge vectors starting from the current vertex, calculate the angle between the two adjacent edge vectors, perform a cross product operation on the two adjacent edge vectors and normalize them to obtain the face normal of the current vertex under the triangle, and use the angle value as the weight corresponding to the face normal. For each vertex, the face normals and corresponding weights of all triangles to which it belongs are summarized, the total weight is calculated, and the face normals are weighted and summed according to the ratio of their corresponding weights to the total weight. The summation result is then normalized to obtain the smooth normal of the model space for that vertex.
3. The outlining method according to claim 2, characterized in that, Calculating the model space smooth normals of each vertex of the target character's model also includes: Before calculating the angle between two adjacent vectors and performing the cross product operation on the two adjacent vectors, each of the two adjacent vectors is magnified by a preset factor.
4. The outlining method according to claim 1, characterized in that, For each vertex, the model space smooth normal of that vertex is transformed to the tangent space to obtain the tangent space smooth normal of that vertex, including: Obtain the original normal and original tangent in the model space of the vertex; The secondary tangent is calculated based on the original normal and the original tangent; Using the original tangent, secondary tangent, and original normal in the model space as row vectors, a first TBN matrix is constructed. The first TBN matrix is the transformation matrix from the tangent space to the model space. Transpose the first TBN matrix to obtain the second TBN matrix from the model space to the tangent space; Multiply the model space smooth normal of the vertex by the second TBN matrix to obtain the tangent space smooth normal of the vertex.
5. The outlining method according to claim 1, characterized in that, In real time, based on the target character's skeletal transformation matrix in the current frame, a TBN transformation matrix is constructed for each vertex from tangent space to world space, including: The tangent, bitangent, and normal of each vertex in world space are determined based on the bone transformation matrix of the current frame. Using the tangent, bitangent, and normal in world space as row vectors, we construct the TBN transformation matrix for each vertex from tangent space to world space.
6. The outlining method according to claim 1, characterized in that, The world space smooth normal of the vertex in the current frame is determined based on the tangent space smooth normal of the vertex and the TBN transformation matrix, including: Multiply the tangent space smooth normal of the vertex by the TBN transformation matrix to obtain the world space smooth normal of the vertex in the current frame.
7. The outlining method according to claim 1, characterized in that, The preset vertex attributes are stored in the second set of UV coordinate channels in the model mesh of the target character.
8. A tracing device for a skeletal animated character, characterized in that, The outlining device includes: The calculation module is used to calculate the model space smoothing normals of each vertex of the target character's model; The transformation module is used to transform the model space smooth normal of each vertex to the tangent space to obtain the tangent space smooth normal of that vertex. The storage module is used to write the tangent space smooth normal of each vertex into the preset vertex attributes of the corresponding vertex for storage; The construction module is used to construct the TBN transformation matrix of each vertex from tangent space to world space in real time based on the skeletal transformation matrix of the target character in the current frame when performing animation rendering of the target character. The determination module is used to read the tangent space smoothing normal from the preset vertex attributes of each vertex, and determine the world space smoothing normal of the vertex in the current frame based on the tangent space smoothing normal of the vertex and the TBN transformation matrix. The generation module is used to extend the normals of the target character's model based on the smooth normals of each vertex in the world space of the current frame, and generate the outline of the target character in the current frame.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. The machine-readable instructions are executed by the processor to perform the steps of the outlining method for a skeletal animated character as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the outlining method for a skeletal animated character as described in any one of claims 1 to 7.
