Role reloading method based on Unity engine

By combining multi-level skeletal mapping and mesh influence weight parameters, the problems of resource redundancy and mapping failure in character costume changing under the Unity engine are solved, achieving efficient and accurate character costume changing and rendering optimization.

CN120997358APending Publication Date: 2025-11-21GUIYANG YUWAN SCI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511136134.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing character costume-changing methods based on the Unity engine suffer from problems such as resource redundancy, high memory pressure, increased number of DrawCalls, high clipping rate, failure of skeletal structure mapping, and difficulty in standardizing the workflow.

Method used

By employing multi-level skeletal mapping technology, a skeletal mapping relationship is established through name-structure-position matching. Combined with mesh influence weight parameters and GPU instantiation rendering, efficient binding and rendering of clothing and character skeletons are achieved.

Benefits of technology

It achieves efficient and accurate bone mapping, reduces resource redundancy and memory pressure, reduces the number of DrawCalls, improves costume changing efficiency and rendering performance, and supports seamless costume changing across body types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997358A_ABST
    Figure CN120997358A_ABST
Patent Text Reader

Abstract

The invention provides a role reloading method based on a Unity engine, and the method comprises the steps: obtaining a role reloading request which comprises target role information and target clothing information; performing'name-structure-position 'multi-level skeleton mapping on the garment skeleton of the target garment and the role skeleton of the target role based on the role reloading request, and determining a skeleton mapping relationship; obtaining a grid influence weight parameter of a role skeleton of the target role on the target garment; and based on the skeleton mapping relation and the grid influence weight parameter, binding the target garment to the role skeleton of the target role, and adding the role skeleton into a rendering queue. Through'name-structure-position 'multi-level skeleton mapping, efficient and accurate skeleton mapping is realized, and the workload of personnel is effectively reduced. The garment is divided into a plurality of grids, so that the updating range can be reduced, and roles of different body types can be realized. GPU instantiation rendering is used, so that the DrawCall is effectively reduced, and the system operation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development technology, and more specifically, to a character costume changing method based on the Unity engine. Background Technology

[0002] The Unity engine provides basic costume replacement functions: SkinnedMeshRenderer, Avatar system, and Animator component. Existing solutions are mainly divided into: overall model replacement method, mesh merging method, and bone mapping method.

[0003] The overall model replacement method directly replaces the complete character model, which is simple to operate but has serious memory redundancy. Different outfits require repeated storage of the entire set of skeleton and skinning data, resulting in resource redundancy and memory pressure.

[0004] The mesh merging method combines multiple component meshes into a single mesh, but it requires stacking multiple SkinnedMeshRenderers, which significantly increases the number of DrawCalls. Furthermore, due to differences in bone binding, the clipping rate is high when combining across components, and the skinning weight is not easy to adjust.

[0005] Skeletal mapping enables cross-model costume changes by establishing skeletal mapping relationships. However, it often suffers from mapping failures due to hierarchical or naming discrepancies in skeletal structures. Furthermore, skinning weights need to be manually adjusted to adapt to different body types, and the weights need to be repeatedly calibrated for each body type. This makes the workflow difficult to standardize and results in low development efficiency.

[0006] Therefore, providing a more efficient character costume changing solution is a technical problem that needs to be solved in this field. Summary of the Invention

[0007] The purpose of this application is to provide a character costume changing method based on the Unity engine, so as to efficiently realize character costume changing.

[0008] To achieve the above objectives, the embodiments of this application are implemented in the following manner: In a first aspect, embodiments of this application provide a character costume-changing method based on the Unity engine, comprising: obtaining a character costume-changing request, wherein the character costume-changing request includes target character information and target clothing information; based on the character costume-changing request, performing a multi-level "name-structure-position" bone mapping between the clothing skeleton of the target clothing and the character skeleton of the target character to determine the bone mapping relationship; obtaining the mesh influence weight parameters of the character skeleton of the target character on the target clothing; and based on the bone mapping relationship and the mesh influence weight parameters, binding the target clothing to the character skeleton of the target character and adding it to the rendering queue.

[0009] In conjunction with the first aspect, in the first possible implementation of the first aspect, based on the character's costume request, a multi-level skeletal mapping of "name-structure-position" is performed between the costume skeleton of the target garment and the character skeleton of the target character to determine the skeletal mapping relationship. This includes: determining the character skeleton of the target character and the costume skeleton of the target garment based on the target character information and target garment information in the character's costume request, wherein the skeleton nodes of the character skeleton are type I skeleton nodes, and the skeleton nodes of the costume skeleton include several type II skeleton nodes to be matched; performing a traversal name matching between each type II skeleton node and the type I skeleton node, and establishing a skeletal mapping relationship for the paired skeleton node pairs; if If there are unmatched Type II bone nodes, perform structural matching between the model hierarchy of the unmatched Type II bone nodes and the model hierarchy of the unmatched Type I bone nodes. Determine Type II and Type I bone nodes with consistent model hierarchy as matched bone node pairs and establish a bone mapping relationship. For Type II bone nodes that are still unmatched after name matching and structural matching, perform position matching between the unmatched Type II and Type I bone nodes in the same 3D space. Determine Type II and Type I bone nodes with the closest positions and orientations as matched bone node pairs and establish a bone mapping relationship.

[0010] In conjunction with the first possible implementation of the first aspect, in the second possible implementation of the first aspect, each type II bone node is subjected to traversal name matching with type I bone nodes, and a bone mapping relationship is established for the paired bone node pairs. This includes: calling the prefix processing rule and suffix processing rule for name matching, processing the name string of each type I bone node and the name string of each type II bone node to obtain the type I node name string corresponding to each type I bone node and the type II node name string corresponding to each type II bone node; for each type II node name string: performing regular expression matching between this type II node name string and each type I node name string; if a matching type I node name string exists, establishing a bone mapping relationship between the type I bone node to which this type I node name string belongs and the type II bone node to which this type II node name string belongs.

[0011] In conjunction with the first possible implementation of the first aspect, in the third possible implementation of the first aspect, the model hierarchy structure relationship of the unmatched type II bone nodes is structurally matched with the model hierarchy structure relationship of the unmatched type I bone nodes. Type II and type I bone nodes with consistent model hierarchy structure relationships are identified as matched bone node pairs, and a bone mapping relationship is established, including: for each unmatched type I bone node, obtaining its direct parent node and direct child node; for each unmatched type II bone node, obtaining its direct parent node and direct child node. For each unmatched type II bone node: If there is a type I bone node among the unmatched type I bone nodes that satisfies the bidirectional node mapping consistency with this type II bone node, determine that the type I bone node matches this type II bone node, and establish the bone mapping relationship between the type I bone node and this type II bone node. Wherein, the bidirectional node mapping consistency means that the direct parent node of the type I bone node has established a bone mapping relationship with the direct parent node of the type II bone node, and the direct child node of the type I bone node has established a bone mapping relationship with the direct child node of the type II bone node.

[0012] In conjunction with the first possible implementation of the first aspect, in the fourth possible implementation of the first aspect, the positions and orientations of unmatched Type II bone nodes and unmatched Type I bone nodes in the same three-dimensional space are matched to determine the Type II bone nodes and Type I bone nodes with the closest positions and orientations as the matched bone node pairs, and a bone mapping relationship is established. This includes: transforming the unmatched Type II bone nodes and unmatched Type I bone nodes into the same three-dimensional coordinate system under the target character's bound pose space to obtain the coordinates of each Type II bone node and the coordinates of each Type I bone node; for each unmatched Type II bone node: calculating the spatial position distance and orientation angle between this Type II bone node and each unmatched Type I bone node, determining the target Type I bone node from the unmatched Type I bone nodes, and establishing a bone mapping relationship between this Type II bone node and the target Type I bone node.

[0013] In conjunction with the first aspect, in the fifth possible implementation of the first aspect, the weight parameters of the influence of the target character's skeleton on the target clothing mesh are obtained, including: loading the preset base weight of the target clothing; obtaining the bone weight correction coefficient of the input target clothing; and correcting the preset base weight of the target clothing based on the bone weight correction coefficient to obtain the mesh influence weight parameters.

[0014] In conjunction with the first possible implementation of the first aspect, in the sixth possible implementation of the first aspect, the character's clothing is divided into several independent mesh components, and adjacent mesh components have an overlapping area of ​​a preset width at the boundary. Based on the target character information and target clothing information in the character dressing request, the character skeleton of the target character and the clothing skeleton of the target clothing are determined, including: determining the character skeleton of the target character according to the target character information in the character dressing request; determining the set of target mesh components to be activated for the target character's dressing according to the target clothing information in the character dressing request, wherein each target mesh component in the target mesh component set is associated with a version identifier; obtaining the original set of mesh components that have been activated for the target character according to the target character information in the character dressing request; comparing the version identifiers of the target mesh component set and the original mesh component set, determining each mesh component in the target mesh component set whose version identifier is different from that of each mesh component in the original mesh component set as the target clothing, and determining the clothing skeleton of each target clothing.

[0015] In conjunction with the sixth possible implementation of the first aspect, in the seventh possible implementation of the first aspect, after adding the rendering queue, the method further includes: detecting all character instances to be rendered in the scene, merging character instances with completely identical complete character clothing configurations into the same character instance set; for each character instance set: if the character instance set contains at least two character instances, perform GPU instantiation rendering, if the character instance set contains only a single character instance, perform standard skinning rendering.

[0016] In conjunction with the seventh possible implementation of the first aspect, the eighth possible implementation of the first aspect involves performing GPU instantiation rendering, including: submitting all mesh components of the complete character costume to be rendered in the character instance set through the Graphics.DrawMeshInstanced API; storing the bone transformation matrix of each character instance in the character instance set to the ComputeBuffer and passing it to the GPU through the Shader Property; and completing the rendering of all character instances in the character instance set in a single DrawCall.

[0017] In conjunction with the eighth possible implementation of the first aspect, in the ninth possible implementation of the first aspect, during the rendering process, the method further includes: determining the range of the distance between the character instance and the camera, wherein the range includes the first range. Second Scope and the third range ; Obtain the high-precision model, medium-precision model, and low-precision model corresponding to the complete character costume pre-stored in the system; For character instances within the first distance range, select the pre-stored high-precision model for rendering; For character instances within the second distance range, select the pre-stored medium-precision model for rendering; For character instances within the third distance range, select the pre-stored low-precision model for rendering.

[0018] Beneficial effects: This solution obtains the character's costume change request and performs a multi-level "name-structure-position" skeletal mapping between the target costume's skeleton and the target character's skeleton to determine the skeletal mapping relationship. Then, it obtains the mesh influence weight parameters of the target character's skeleton on the target costume and binds the target costume to the target character's skeleton accordingly, adding it to the rendering queue. Addressing the mapping failure issue in cross-model mapping of traditional skeletal mapping costume change techniques, this solution creatively designs a multi-level "name-structure-position" skeletal mapping technique to achieve efficient and accurate skeletal mapping. In the name mapping stage, prefix and suffix processing rules for name matching are invoked to perform regular expression matching on the name string, achieving precise mapping. For skeletal nodes that cannot be mapped through name matching, structure matching is performed. The direct parent and direct child nodes of the skeletal node are taken and consistency matching is performed. If the direct parent and direct child nodes of a type II skeletal node have established corresponding mapping relationships with the direct parent and direct child nodes of the same type I skeletal node, then this type II skeletal node is determined to match this type I skeletal node, establishing a mapping relationship, completing structure matching, and achieving precise mapping. For skeletal nodes that cannot establish a mapping relationship through name matching and structure matching (generally a small number), position matching can be performed. The skeletal node with the closest spatial distance and directional angle is selected as the matching skeletal node, thereby achieving accurate skeletal mapping. Name matching, which has the highest mapping accuracy, is given priority, followed by structure matching, and then spatial matching. This achieves intelligent and efficient skeletal mapping with high accuracy. Of course, a small amount of manual skeletal mapping correction can also be performed on the basis of "name-structure-position" matching to ensure mapping accuracy and effectively reduce the workload of personnel.

[0019] The process involves loading the preset base weights of the target clothing; obtaining the skeletal weight correction coefficients of the target clothing; and adjusting the preset base weights of the target clothing based on the skeletal weight correction coefficients to obtain the mesh influence weight parameters. This allows for adjustment of the mesh influence weight parameters, enabling seamless clothing changes for characters of different body types. Character clothing is divided into several independent mesh components, with a certain width of overlap at the boundaries of adjacent mesh components, providing space for smooth transitions and effectively reducing clipping rates. Version identifiers for the mesh components guide clothing updates, reducing the system workload during clothing changes. GPU instantiation allows for batch rendering of multiple characters with the same clothing and materials, effectively reducing draw calls. Furthermore, rendering is performed using models of different precision based on the distance between different character instances and the camera, improving rendering efficiency.

[0020] 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

[0021] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application 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.

[0022] Figure 1 A flowchart illustrating a Unity engine-based character costume changing method provided in this application embodiment. Detailed Implementation

[0023] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0024] Please see Figure 1 , Figure 1 This is a flowchart of a character costume change method based on the Unity engine. The Unity engine-based character costume change method can be applied to electronic devices (such as smartphones, computers, etc.), and includes steps S10, S20, S30, and S40.

[0025] In order to achieve efficient costume changes for the character, in this embodiment, the electronic device can run step S10.

[0026] Step S10: Obtain the character outfit request, wherein the character outfit request includes target character information and target clothing information.

[0027] In this embodiment, when a user (actual user or developer) operates a character to change clothes on the client side of the electronic device, the electronic device can obtain a character changing clothes request. The character changing clothes request includes target character information and target clothing information. Target character information includes, for example, user ID, character number, character skeleton, and other related information, while target clothing information includes, for example, clothing type, clothing version identifier (here, the version identifier refers to the clothing's unique number, version number, etc.), clothing skeleton, and other related information.

[0028] After receiving the character's costume change request, the electronic device can proceed to step S20.

[0029] Step S20: Based on the character's costume change request, perform a multi-level skeleton mapping of "name-structure-position" between the costume skeleton of the target costume and the character skeleton of the target character to determine the skeleton mapping relationship.

[0030] In this embodiment, the electronic device can determine the character skeleton of the target character and the clothing skeleton of the target clothing based on the target character information and target clothing information in the character dressing request.

[0031] For ease of distinction, this embodiment refers to the bone nodes of the character skeleton as Type I bone nodes and the bone nodes of the clothing skeleton as Type II bone nodes. Therefore, the clothing skeleton contains several Type II bone nodes to be matched. Because some special clothing items (such as hats, capes, etc.) do not all need to be mapped to the character skeleton, but rather have some special bone nodes that do not need to be mapped to the character skeleton, such as capes, which contain some bone nodes that need to be mapped to the character skeleton and some that do not need to be mapped to the character skeleton.

[0032] For the character's clothing, this embodiment further divides the clothing into multiple independent mesh components, and sets an overlap area of ​​a preset width (e.g., about 10%) at the boundaries of adjacent mesh components. For example: Top: includes the front, back, sleeves, etc. Pants: divided into left leg, right leg, waistband, etc. Accessories: hats, gloves, shoes, etc. The specific method for determining the character skeleton and clothing skeleton of the target character and clothing in the case of dividing into independent mesh components is as follows: The electronic device can determine the target character's skeleton based on the target character information in the character dress-up request. Furthermore, it can determine the set of target mesh components (i.e., the combination of clothing the customer needs to change into) that need to be activated for the target character's dress-up based on the target clothing information in the request. Each target mesh component in the target mesh component set is associated with a version identifier. Then, based on the target character information in the dress-up request, it retrieves the original set of activated mesh components for the target character (i.e., the combination of clothing the customer is already wearing).

[0033] Then, the electronic device can compare the version identifiers of the target mesh component set with those of the original mesh component set, identify each mesh component in the target mesh component set whose version identifier is different from that of each mesh component in the original mesh component set as the target garment, and determine the garment skeleton of each target garment.

[0034] Once the character skeleton of the target character and the clothing skeleton of each target outfit are determined, the electronic device can perform multi-level skeleton mapping based on "name-structure-position". Of course, this is for cases where the target outfit is a new outfit for the target character. For cases where it is not the first time changing outfits, the electronic device can extract the already stored skeleton mapping relationship (the mapping relationship established when the target character first changes outfits will be stored), and there is no need to perform skeleton mapping again.

[0035] First, the electronic device can perform a traversal name matching between each type II bone node and a type I bone node to establish a bone mapping relationship for the paired bone node pairs.

[0036] For example, an electronic device can invoke prefix processing rules (prefix processing rules are generally designed specifically according to the naming habits developed) and suffix processing rules (e.g., ignoring the "_Bone" suffix) to process the name strings of each type I bone node and the name strings of each type II bone node, so as to obtain the type I node name string corresponding to each type I bone node and the type II node name string corresponding to each type II bone node.

[0037] At this point, for each type II node name string: the electronic device can perform regular expression matching between this type II node name string and each type I node name string. If a matching type I node name string exists, a skeletal mapping relationship is established between the type I skeletal node to which this type I node name string belongs and the type II skeletal node to which this type II node name string belongs. Of course, type II skeletal nodes for which a skeletal mapping relationship has been established will be recorded (actually, type II skeletal nodes with established skeletal mapping relationships are removed from the set of type II skeletal nodes to be matched).

[0038] This allows for the completion of skeletal mapping at the "name" level. If there are still unmatched Type II skeletal nodes, the electronic device can perform skeletal mapping at the "structure" level: the model hierarchical structure relationship of the unmatched Type II skeletal nodes is matched with the model hierarchical structure relationship of the unmatched Type I skeletal nodes, and Type II skeletal nodes and Type I skeletal nodes with consistent model hierarchical structure relationships are identified as matched skeletal node pairs, and a skeletal mapping relationship is established.

[0039] For example, for each unmatched Type I bone node, the electronic device can obtain its direct parent node and direct child node; similarly, for each unmatched Type II bone node, the electronic device can obtain its direct parent node and direct child node. In this embodiment, the direct parent node and direct child node refer to strictly adjacent hierarchical relationships in the bone hierarchy tree. The direct parent node is the only directly connected bone node at the previous level of the current bone node (or empty if none exists). The direct child node is the next directly connected bone node at the next level of the current bone node (there can be multiple direct child nodes; or empty if none exists).

[0040] Therefore, for each unmatched Type II skeletal node, the electronic device can determine: if there is a Type I skeletal node among the unmatched Type I skeletal nodes that satisfies the bidirectional node mapping consistency with this Type II skeletal node, then the Type I skeletal node is determined to be matched with this Type II skeletal node, and a skeletal mapping relationship is established between the Type I skeletal node and this Type II skeletal node. In this embodiment, bidirectional node mapping consistency means that the direct parent node of the Type I skeletal node has a skeletal mapping relationship with the direct parent node of this Type II skeletal node, and the direct child node of the Type I skeletal node has a skeletal mapping relationship with the direct child node of this Type II skeletal node (when there are multiple direct child nodes, the existence of one direct child node establishing a corresponding skeletal mapping relationship is considered as the existence of a skeletal mapping relationship between the direct child node of the Type I skeletal node and the direct child node of this Type II skeletal node).

[0041] For example, the direct parent node of Coat_Shoulder_L is Coat_Spine, and the direct child node of Coat_Shoulder_L is Coat_Elbow_L. Check if there are any unmatched character bones that satisfy the following conditions: the direct parent node is mapped to Coat_Spine (i.e., the character's parent node is mapped to Coat_Spine), and the direct child node is mapped to Coat_Elbow_L (i.e., the character's child node is mapped to Coat_Elbow_L). If there exists a character bone L_UpperArm, whose direct parent node L_Clavicle is mapped to Coat_Spine, and whose direct child node L_Forearm is mapped to Coat_Elbow_L, then it is determined that Coat_Shoulder_L and L_UpperArm satisfy the bidirectional node mapping consistency, and the bone mapping relationship between Coat_Shoulder_L and L_UpperArm can be established.

[0042] Based on this, electronic devices can achieve skeletal mapping matching at the "structure" level.

[0043] For Class II bone nodes that still do not match after name matching and structure matching, the electronic device can perform bone mapping at the "position" level. For example, the electronic device can perform position matching between the unmatched Class II bone nodes and the unmatched Class I bone nodes in the same three-dimensional space, determine the Class II bone nodes and Class I bone nodes with the closest positions and orientations as the matched bone node pairs, and establish a bone mapping relationship.

[0044] For example, the electronic device can transform unmatched Type II bone nodes and unmatched Type I bone nodes into the same three-dimensional coordinate system under the target character's bound pose space to obtain the coordinates of each Type II bone node and the coordinates of each Type I bone node.

[0045] For each unmatched Type II bone node: the electronic device can calculate the spatial distance and orientation angle between this Type II bone node and each unmatched Type I bone node, determine the target Type I bone node (e.g., the closest one with an orientation angle within 45°) from the unmatched Type I bone nodes, and establish a bone mapping relationship between this Type II bone node and the target Type I bone node.

[0046] Of course, developers can intervene at any stage of the skeleton mapping process to correct the mapping. Overall, during the name mapping stage, prefix and suffix processing rules for name matching are invoked to perform regular expression matching on the name strings, achieving precise mapping. For skeleton nodes that cannot be mapped through name matching, structural matching is performed. The direct parent and direct child nodes of the skeleton node are taken and subjected to consistency matching. If the direct parent and direct child nodes of a type II skeleton node both have corresponding mapping relationships with the direct parent and direct child nodes of the same type I skeleton node, then it is determined that this type II skeleton node matches this type I skeleton node, establishing a mapping relationship, completing structural matching, and achieving precise mapping. For skeletal nodes that cannot establish a mapping relationship through name matching and structure matching (generally a small number), position matching can be performed. The skeletal node with the closest spatial distance and directional angle is selected as the matching skeletal node, thereby achieving accurate skeletal mapping. Name matching, which has the highest mapping accuracy, is given priority, followed by structure matching, and then spatial matching. This achieves intelligent and efficient skeletal mapping with high accuracy. Of course, a small amount of manual skeletal mapping correction can also be performed on the basis of "name-structure-position" matching to ensure mapping accuracy and effectively reduce the workload of personnel.

[0047] After the skeletal mapping relationship is determined, the electronic device can proceed to step S30.

[0048] Step S30: Obtain the weight parameters of the influence of the target character's skeleton on the target clothing mesh.

[0049] In this embodiment, the electronic device can load the preset base weights of the target garment (which are pre-stored base weight parameters), and then obtain the bone weight correction coefficients of the target garment entered by the artist. Based on the bone weight correction coefficients, the preset base weights of the target garment are corrected to obtain the mesh influence weight parameters.

[0050] Manually adjusting the mesh influence weight parameters is currently the mainstream method. 3ds Max's "AutoSkin" tool can automatically calculate the vertex weight distribution (initial weight distribution) based on the model structure, and then make manual adjustments on this basis, which can improve work efficiency.

[0051] After adding skin, you can initially adjust the weights by using the tools to adjust the inner and outer rings of the envelope. The outer ring adjusts the range of influence of the weights; increasing the outer ring diameter increases the range of influence of the bones and the number of control points. The inner ring adjusts the transition strength of the weights; increasing the inner ring radius darkens the edge color of the selected bone control points, increasing their weight ratio, while decreasing the weight of other bones. The "Weight Editor" in the skin modifier allows for precise control over the weight of each vertex. Select single or multiple vertices to view and modify their weight distribution to each bone. When adjusting manually, pay special attention to areas prone to unnatural deformation, such as limb joints, shoulders, and hips. These areas usually require more meticulous weight adjustments to ensure smooth and natural animation.

[0052] For newly added clothing, after implementing skeletal mapping with the character's skeleton, artists can adjust the mesh influence weight parameters of the target character's skeleton on the target clothing, associate it with the corresponding character ID, and enter it into the system for later retrieval. This allows for adjustment of the mesh influence weight parameters, enabling seamless clothing changes for characters of different body types.

[0053] Of course, it can also be developed in the direction of intelligent adjustment in the future. For example, extract the body shape data of the target character, such as the proportion of bone length (e.g., arm length ratio, leg length ratio, etc., arm length ratio = length from acromion to carpal bone / total length of spine, leg length ratio = femur length / total length of spine), key circumference parameters (e.g., chest circumference, waist circumference, hip circumference, etc.), load the preset basic weights of the target clothing, and then use the body shape data of the target character to make preliminary corrections to the preset basic weights of the target clothing. At this time, the artists can then intervene to adjust and obtain the mesh influence weight parameters, which can reduce some of the workload.

[0054] After obtaining the weight parameters of the influence of the character skeleton on the mesh of the target clothing, the electronic device can run step S40.

[0055] Step S40: Based on the bone mapping relationship and mesh influence weight parameters, bind the target clothing to the target character's skeleton and add it to the rendering queue.

[0056] In this embodiment, the electronic device can bind the target clothing to the character skeleton of the target character based on the skeleton mapping relationship and mesh influence weight parameters. After binding each target clothing (independent mesh component) to the character skeleton, these mesh components can be added to the rendering queue as the bound clothing of the target character, waiting for rendering.

[0057] To reduce draw calls during rendering, this embodiment introduces GPU-instantiated rendering technology. Since dress-up scenes are diverse, and a single scene may contain multiple homogeneous character instances, the electronic device can detect all character instances to be rendered in the scene and merge those with identical complete costume configurations into a single character instance set. It should be noted that a complete character costume configuration includes all mesh components on the character (i.e., the mesh components that define the character's clothing, such as tops, pants, and accessories), and these components must be of the same material to be merged into the same character instance set for batch rendering.

[0058] For each set of character instances, if the set contains at least two character instances, GPU instantiation rendering can be performed; if the set contains only a single character instance, standard skinning rendering is performed.

[0059] Specifically, the GPU instantiation and rendering process is as follows: By submitting all the mesh components of the complete character costume that needs to be rendered from the character instance collection using the Graphics.DrawMeshInstanced API, and then storing the bone transformation matrix of each character instance in the character instance collection into a ComputeBuffer, and passing it to the GPU through the Shader Property, the rendering of all character instances in the character instance collection can be completed in a single DrawCall.

[0060] In addition, to improve rendering efficiency, the range of distance between the character instance and the camera can be determined during the rendering process. This range includes a first range. Second Scope and the third range In this embodiment, Take 3m, Take 20m.

[0061] Therefore, the electronic device can obtain the pre-stored high-precision model (a high-precision model constructed from complete mesh components), medium-precision model (a medium-precision model constructed after merging some meshes), and low-precision model (a low-precision model constructed after merging all mesh components) corresponding to the complete character costume in the system. For character instances within the first distance range, the pre-stored high-precision model can be selected for rendering; for character instances within the second distance range, the pre-stored medium-precision model can be selected for rendering; and for character instances within the third distance range, the pre-stored low-precision model can be selected for rendering.

[0062] Character clothing is divided into several independent mesh components, with a certain width of overlap between adjacent mesh components at their boundaries, providing space for smooth transitions and effectively reducing clipping rates. Version identifiers for these mesh components guide clothing updates, reducing system workload during clothing changes. GPU instantiation allows multiple characters with the same clothing and materials to be batch-rendered, effectively reducing draw calls. Furthermore, rendering is performed using models of varying precision based on the distance between different character instances and the camera, improving rendering efficiency.

[0063] In summary, this application provides a character costume-changing method based on the Unity engine. By obtaining a character costume-changing request, a multi-level "name-structure-position" skeletal mapping is performed between the target costume's skeleton and the target character's skeleton to determine the skeletal mapping relationship. Then, the influence weight parameters of the target character's skeleton on the target costume's mesh are obtained, and the target costume is bound to the target character's skeleton and added to the rendering queue accordingly. Addressing the mapping failure problem in cross-model mapping of skeletal mapping costume-changing techniques, this solution creatively designs a multi-level "name-structure-position" skeletal mapping technique to achieve efficient and accurate skeletal mapping. In the name mapping stage, prefix and suffix processing rules for name matching are invoked to perform regular expression matching on the name string, achieving precise mapping. For skeletal nodes that cannot be mapped through name matching, structural matching is performed. The direct parent and direct child nodes of the skeletal node are taken and subjected to consistency matching. If both the direct parent and direct child nodes of a type II skeletal node have corresponding mapping relationships with the direct parent and direct child nodes of the same type I skeletal node, then the type II skeletal node is determined to be matched with the type I skeletal node, establishing a mapping relationship and completing structural matching for accurate mapping. For skeletal nodes for which neither name matching nor structural matching can establish a mapping relationship (generally a small number), position matching can be performed. The skeletal node with the closest spatial distance and directional angle is selected as the matching skeletal node, thus achieving accurate skeletal mapping. Name matching, which has the highest mapping accuracy, is prioritized, followed by structural matching, and then spatial matching. This achieves intelligent and efficient skeletal mapping with high accuracy. Of course, a small amount of manual skeletal mapping correction can also be performed on the basis of "name-structure-position" matching to ensure mapping accuracy and effectively reduce the workload of personnel.

[0064] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.

[0065] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A character costume changing method based on the Unity engine, characterized in that, include: Obtain the character outfit request, which includes the target character information and the target clothing information; Based on the character's costume change request, a multi-level skeleton mapping of "name-structure-position" is performed between the costume skeleton of the target costume and the character skeleton of the target character to determine the skeleton mapping relationship. Obtain the weight parameters of the influence of the target character's skeleton on the target clothing mesh; Based on the skeleton mapping relationship and mesh influence weight parameters, the target clothing is bound to the character skeleton of the target character and added to the rendering queue.

2. The character costume changing method based on the Unity engine according to claim 1, characterized in that, Based on the character's costume change request, a multi-level skeletal mapping ("name-structure-position") is performed between the target costume's skeleton and the target character's skeleton to determine the skeletal mapping relationship, including: Based on the target character information and target clothing information in the character dress-up request, the character skeleton of the target character and the clothing skeleton of the target clothing are determined respectively. The skeleton nodes of the character skeleton are type I skeleton nodes, and the skeleton nodes of the clothing skeleton include several type II skeleton nodes to be matched. Perform a traversal name matching between each type II bone node and type I bone nodes, and establish a bone mapping relationship for the paired bone node pairs. If there are unmatched type II bone nodes, perform structural matching between the model hierarchical structure relationship of the unmatched type II bone nodes and the model hierarchical structure relationship of the unmatched type I bone nodes. Determine type II bone nodes and type I bone nodes with consistent model hierarchical structure relationships as matched bone node pairs and establish bone mapping relationships. For Class II bone nodes that still do not match after name matching and structure matching, the positions and orientations of the unmatched Class II bone nodes and unmatched Class I bone nodes in the same 3D space are matched to determine the Class II bone nodes and Class I bone nodes with the closest positions and orientations as the matched bone node pairs, and a bone mapping relationship is established.

3. The character costume changing method based on the Unity engine according to claim 2, characterized in that, Perform a traversal name matching process between each type II bone node and type I bone nodes, and establish a bone mapping relationship for the paired bone node pairs, including: The prefix and suffix processing rules for name matching are invoked to process the name strings of each type I bone node and the name strings of each type II bone node, so as to obtain the type I node name string corresponding to each type I bone node and the type II node name string corresponding to each type II bone node. For each type II node name string: perform regular expression matching between this type II node name string and each type I node name string; if a matching type I node name string exists, establish a skeletal mapping relationship between the type I skeletal node to which this type I node name string belongs and the type II skeletal node to which this type II node name string belongs.

4. The character costume changing method based on the Unity engine according to claim 2, characterized in that, The hierarchical structure of unmatched type II bone nodes is matched with that of unmatched type I bone nodes. Type II and type I bone nodes with consistent hierarchical structures are identified as matched bone node pairs, and a bone mapping relationship is established, including: For each unmatched Class I skeletal node, obtain its direct parent node and direct child node; For each unmatched type II bone node, obtain its direct parent node and direct child node; For each unmatched type II bone node: If there is a type I bone node among the unmatched type I bone nodes that satisfies the bidirectional node mapping consistency with this type II bone node, determine that the type I bone node matches this type II bone node, and establish the bone mapping relationship between the type I bone node and this type II bone node. Wherein, the bidirectional node mapping consistency means that the direct parent node of the type I bone node has established a bone mapping relationship with the direct parent node of the type II bone node, and the direct child node of the type I bone node has established a bone mapping relationship with the direct child node of the type II bone node.

5. The character costume changing method based on the Unity engine according to claim 2, characterized in that, The positions and orientations of unmatched Type II and Type I bone nodes in the same 3D space are matched to determine the closest Type II and Type I bone nodes as matched bone node pairs, and a bone mapping relationship is established, including: Transform the unmatched Type II bone nodes and unmatched Type I bone nodes into the same 3D coordinate system under the target character's bound pose space to obtain the coordinates of each Type II bone node and the coordinates of each Type I bone node. For each unmatched type II bone node: calculate the spatial distance and orientation angle between this type II bone node and each unmatched type I bone node, identify the target type I bone node from the unmatched type I bone nodes, and establish the bone mapping relationship between this type II bone node and the target type I bone node.

6. The character costume changing method based on the Unity engine according to claim 1, characterized in that, Obtain the weight parameters of the influence of the target character's skeleton on the target clothing's mesh, including: Load the target garment's preset base weights; Obtain the bone weight correction coefficient of the target garment; The preset base weights of the target clothing are corrected based on the bone weight correction coefficient to obtain the mesh influence weight parameters.

7. The character costume changing method based on the Unity engine according to claim 2, characterized in that, The character's clothing is divided into several independent mesh components. Adjacent mesh components have an overlapping area of ​​a preset width at their boundaries. Based on the target character information and target clothing information in the character's clothing change request, the character skeleton of the target character and the clothing skeleton of the target clothing are determined, including: Based on the target character information in the character costume request, determine the target character's skeleton; Based on the target clothing information in the character's clothing change request, determine the set of target mesh parts that need to be activated for the target character's clothing change. Each target mesh part in the target mesh part set is associated with a version identifier. Based on the target character information in the character costume request, obtain the set of original mesh parts that have been activated for the target character; By comparing the version identifiers of the target mesh component set with those of the original mesh component set, each mesh component whose version identifier is different from that of each mesh component in the original mesh component set is identified as the target garment, and the garment skeleton of each target garment is determined.

8. The character costume changing method based on the Unity engine according to claim 7, characterized in that, After adding to the rendering queue, the method further includes: Detect all character instances that need to be rendered in the scene, and merge character instances with completely identical costume configurations into the same character instance set; For each set of character instances: if the set of character instances contains at least two character instances, perform GPU instantiation rendering; if the set of character instances contains only a single character instance, perform standard skinning rendering.

9. The character costume changing method based on the Unity engine according to claim 8, characterized in that, Perform GPU instantiation rendering, including: Submit all mesh components of the complete character costume that need to be rendered from the collection of character instances using the Graphics.DrawMeshInstanced API; Store the bone transformation matrix of each character instance in the character instance collection into a ComputeBuffer, and pass it to the GPU via Shader Property; A single DrawCall renders all character instances in the character instance collection.

10. The character costume changing method based on the Unity engine according to claim 9, characterized in that, During the rendering process, the method further includes: Determine the range of distance between the character instance and the camera, where the range includes the first range. Second Scope and the third range ; Retrieve the high-precision, medium-precision, and low-precision models corresponding to the complete character costumes pre-stored in the system; For character instances within the first distance range, a pre-stored high-precision model is selected for rendering; For character instances within the second distance range, a pre-stored medium-precision model is selected for rendering; For character instances within the third distance range, a pre-stored low-precision model is selected for rendering.