Resource processing method and apparatus, device, medium and program product
By introducing world space coordinate systems and physical simulations in TressFx, the problem that hair resources cannot be dynamically offset in virtual character movements is solved, achieving a more natural and realistic hair movement effect.
Patent Information
- Application Number
- PCT/CN2024/090736
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-21
- Filing Date
- 2024-04-30
- Publication Date
- 2024-12-26
AI Technical Summary
When TressFx simulates the movement of virtual characters, the hair resources cannot be shifted dynamically, resulting in unreal motion effects.
By introducing the world space coordinate system, the spatial change information of the virtual character from the first game scene to the second game scene is obtained, the static resource data acting on the hair resources are generated, and the dynamic resource data is generated, and physical simulation is performed based on this to realize the hair resources. Real sports performance.
It improves the naturalness and reality of hair resources in virtual character movement, so that hair resources can be dynamically offset and simulates the movement effects in the real world more realistically.
Smart Images

Figure CN2024090736_26122024_PF_FP_ABST
Abstract
Description
Resource processing method, device, equipment, medium and program product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on June 21, 2023, application number 202310747712.9, and application name “A resource processing method, device, equipment, medium and program product”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, in particular to the field of games, and specifically to a resource processing technology. Background Art
[0003] The TressFx (hair rendering) hair framework is a hair rendering solution based on physical simulation. The open source TressFx can be integrated into various self-developed rendering engines to achieve hair rendering, making the TressFx hair rendering solution widely used.
[0004] While TressFx currently uses a spring-mass system to simulate each strand of hair, achieving relatively realistic and comprehensive hair dynamics, it still has some drawbacks. For example, when simulating the movement of an avatar, TressFx maintains the avatar's position unchanged, meaning the avatar walks, runs, jumps, and other movements in the same location. This results in the avatar's hair assets remaining relatively fixed to the avatar during movement, making it impossible to reflect the dynamic offset of the hair assets.
[0005] Therefore, optimizing TressFx when integrating it into a self-developed rendering engine will help improve the hair rendering effect of the self-developed rendering engine.
[0006] Summary of the Invention
[0007] The embodiments of the present application provide a resource processing method, apparatus, device, medium, and program product that can introduce a world space coordinate system into TressFx, helping hair resources follow the movement of virtual characters to achieve realistic motion performance.
[0008] In one aspect, an embodiment of the present application provides a resource processing method, which is executed by a computer device and includes:
[0009] Acquire spatial change information of the virtual character; the spatial change information is used to indicate the position change of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene;
[0010] Obtaining static resource data of the virtual character's hair resource in the second game scene; the static resource data is used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene;
[0011] Based on the static resource data and the spatial change information, dynamic resource data of the hair resource in the second game scene is obtained; the dynamic resource data is used to reflect the dynamic characteristics of the hair resource moving with the movement of the virtual character;
[0012] Physical simulation is performed on the hair resource based on the dynamic resource data; the physical simulation is used to control the hair resource to simulate the movement performance in the real world when the virtual character moves from the first game scene to the second game scene.
[0013] On the other hand, an embodiment of the present application provides a resource processing device, which is deployed on a computer device and includes:
[0014] An acquisition unit, configured to acquire spatial change information of a virtual character; the spatial change information is used to indicate a position change of the virtual character in a world space coordinate system when the virtual character moves from a first game scene to a second game scene;
[0015] The acquisition unit is further configured to acquire static resource data of the hair resource of the virtual character in the second game scene; the static resource data is configured to reflect static characteristics of the hair resource of the virtual character when the virtual character is in a static state in the second game scene;
[0016] a processing unit configured to obtain dynamic resource data of the hair resource in the second game scene based on the static resource data and the spatial change information; the dynamic resource data being configured to reflect the dynamic characteristics of the hair resource moving with the movement of the virtual character;
[0017] The processing unit is also used to perform physical simulation on the hair resource based on the dynamic resource data; the physical simulation is used to control the hair resource to simulate the movement performance in the real world when the virtual character moves from the first game scene to the second game scene.
[0018] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising:
[0019] a processor for loading and executing computer programs;
[0020] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the resource processing method is implemented.
[0021] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is suitable for being loaded by a processor and executing the above-mentioned resource processing method.
[0022] On the other hand, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the above-mentioned resource processing method.
[0023] In an embodiment of the present application, spatial change information of a virtual character in a world space coordinate system can be obtained when the virtual character moves from a first game scene to a second game scene. This spatial change information reflects the position change of the virtual character in world space. Then, support is provided for applying this spatial change information to the static resource data of the virtual character's hair resource in the second game scene to obtain dynamic resource data of the hair resource in the second game scene. The static resource data is used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene, while the dynamic resource data is used to reflect the dynamic characteristics of the hair resource as it moves with the movement of the virtual character. Finally, a physical simulation can be performed on the hair resource based on the dynamic resource data of the hair resource. This physical simulation enables the hair resource to simulate real-world motion during the virtual character's movement from the first game scene to the second game scene. That is, the hair resource simulates real-world motion during the virtual character's movement from the first game scene to the second game scene based on the physical simulation. It can be seen that the embodiment of the present application adds world space simulation to TressFx. By applying the spatial change information when the virtual character moves from the first game scene to the second game scene to the static resource data of the hair resource, the dynamic resource data of the hair resource in the second game scene can be obtained. Based on the dynamic resource data, the hair resource can be more accurately controlled to dynamically offset as the virtual character moves, so that the hair resources in the game world simulate and restore the movement performance of the hair resources in the real world as much as possible, thereby improving the naturalness and realism of the hair resources in the game scene where the virtual character moves. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0025] FIG1a is a schematic structural diagram of a hair resource provided by an exemplary embodiment of the present application;
[0026] FIG1b is a schematic structural diagram of another hair resource provided by an exemplary embodiment of the present application;
[0027] FIG1c is a schematic structural diagram of a wind farm provided by an exemplary embodiment of the present application;
[0028] FIG1 d is a schematic diagram of a guide hair and a slave hair provided by an exemplary embodiment of the present application;
[0029] FIG2 is a comparative schematic diagram of a hair piece model and a hair strand model provided by an exemplary embodiment of the present application;
[0030] FIG3 is a flow chart of a resource processing method provided by an exemplary embodiment of the present application;
[0031] FIG4 is a schematic diagram of a world space coordinate system provided by an exemplary embodiment of the present application;
[0032] FIG5 is a schematic diagram of a virtual character undergoing displacement and / or rotation provided by an exemplary embodiment of the present application;
[0033] FIG6 is a schematic diagram of a hair being affected by gravity and wind, provided by an exemplary embodiment of the present application;
[0034] FIG7 is a flow chart of another resource processing method provided by an exemplary embodiment of the present application;
[0035] FIG8 a is a schematic diagram of a virtual horsetail provided by an exemplary embodiment of the present application;
[0036] FIG8 b is a schematic diagram of a virtual braid provided by an exemplary embodiment of the present application;
[0037] FIG8 c is a schematic diagram of another virtual horsetail provided by an exemplary embodiment of the present application;
[0038] FIG9 is a schematic structural diagram of a resource processing device provided by an exemplary embodiment of the present application;
[0039] FIG10 is a schematic structural diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0041] This embodiment of the application proposes a resource processing solution, which is specifically a solution for physical simulation of hair resources based on the TressFx framework. The following is a brief introduction to the technical terms and related concepts involved in this embodiment of the application, including:
[0042] 1. Physical simulation of hair resources.
[0043] Hair resource physics simulation, also referred to as hair physics simulation, is a computer graphics technology based on physics principles. It is used to simulate the dynamic behavior of hair resources (or simply hair) or other slender, soft objects. Hair can include, but is not limited to, hair (such as various hairstyles (e.g., ponytails, buns, or braids), various bangs (e.g., sideburns or straight bangs), and sideburns), beards (e.g., mustaches, beards, or moustaches), and body hair. The following examples of this application use hair resources as an example for illustration, which is specifically explained here.
[0044] Hair physics simulation mainly uses a spring-mass system to describe each hair resource, and takes into account the influence of external factors such as gravity or wind on the movement of the hair resource, so as to simulate as much as possible the movement effect of the hair resource when it is affected by various external factors in the real world. In the spring-mass system, a hair resource is regarded as consisting of multiple mass points (or particles) connected by springs; each mass point on a hair resource has a position vector and a velocity vector, and two adjacent mass points are connected by springs. When the external force generated by external factors acts on the mass points on the hair resource, the changes in the position and velocity of the mass points can cause the hair resource as a whole to move and deform, thereby simulating the movement performance of hair in the real world.
[0045] 2. TressFx framework.
[0046] TressFx is a technology for implementing physical simulation of hair, specifically hair and fur rendering technology based on physical simulation. TressFx primarily uses PBD (Position-Based Dynamics) to achieve realistic dynamic hair motion effects. PBD is a physical simulation technology based on constraints (or simply constraints); by applying a series of constraints to each particle, the particle's motion is controlled to simulate the dynamic behavior of the object composed of the particles. In PBD, each particle has a position vector and a velocity vector, and adjacent particles can be connected by springs. Springs can be used to represent the interaction between two connected particles caused by different types of forces. These forces can include, but are not limited to, external forces such as gravity, air resistance, wind, or pulling.
[0047] At the same time, in PBD, hair resources may also be subject to various constraints, including but not limited to length constraints, angle constraints, global shape constraints, gravity constraints, local shape constraints, and motion following constraints, etc.; thus, in the process of physical simulation of hair resources, iterative calculations will be performed according to the various constraints set, and the calculation results will be applied to the relevant particles that make up the hair resources, so as to control the movement of the relevant particles through multiple constraints, thereby ensuring the movement authenticity of the hair resources. In addition, in addition to the various features of PBD described above, TressFx also supports GPU (graphics processing unit) acceleration and multi-threaded parallel processing; compared with other hair rendering technologies that support CPU (Central Processing Unit) processing and single-threaded processing, it can effectively improve hair rendering efficiency.
[0048] To better understand TressFx, the following briefly introduces its basic principles in conjunction with the hair resource shown in Figure 1a. As shown in Figure 1a, TressFx attaches each hair resource (e.g., a single head) to a virtual hair (or strand) on a virtual character (actor). The virtual character (specifically, the character's head) serves as the hair-attached object. Virtual hair is a continuous chain of multiple hair segments, each consisting of two endpoints connected by a virtual spring. Each endpoint of each hair segment serves as a point mass. For example, hair strand 101 shown in Figure 1a contains 10 continuous segments (hair segment 1 → hair segment 2 → ... → hair segment 10). Hair segment 1 is directly attached to the avatar via point mass 102, and hair segment 2 → ... → hair segment 10 are sequentially connected to hair segment 1. In an actual virtual scene, if you want to simulate the movement of hair resources following the movement of a virtual character, you need to control the movement of the hair resource's particles to facilitate the hair resource to simulate the movement performance of real hair in the real world.
[0049] In order to make the physical simulation of hair resources closer to real phenomena and improve the realism and authenticity of hair resources, the following constraints are also imposed on the physical movement of hair resources for physical calculation of hair resources; these constraints include but are not limited to:
[0050] a) The two mass points of the hair segment 1 at the root of the hair resource (which can be called root mass points, such as mass points 102 and 103 shown in Figure 1a) remain relatively fixed to the virtual character (i.e., the attachment point of the hair); while the mass points contained in the hair segments connected to the root hair segment 1 are constrained by gravity (gravitational force) and the action of the spring connecting the mass points, resulting in a free-fall effect. In other words, when the hair resource is on the head model of the virtual character, the root hair segment in the hair resource is directly connected to the head model of the virtual character. The influence of the head model's skeleton on movement directly acts on the two root mass points of the root hair segment, and then transmits the influence to the mass points of the subsequent hair segments in the hair resource, achieving the movement effect of the entire hair resource.
[0051] b) The hair resource itself has certain curvatures (global shape constraints) that need to be maintained. It should be understood that, because hair resources have a certain degree of stiffness (i.e., the ability of a material or structure to resist elastic deformation when subjected to force), they often exhibit a certain degree of flexibility or curvature; therefore, in the process of simulating the movement of hair resources, it is necessary to maintain the original curvature of the hair resource in order to achieve more accurate hair simulation. In TressFx, global shape constraints are mainly used to constrain several particles in the hair resource located behind the root of the hair, so that the hair resource composed of these particles maintains a basic curvature, simulating the styling effect of hair in the real world. As shown in Figure 1b, several particles in the hair resource that are located after the hair line segment 1 (such as particles 104, 105, 106 and 107) need to maintain a certain curved shape. In this case, a global shape constraint can be used to ensure that the shape connected by these particles remains in a certain curved shape. Specifically, after calculating the impact of the gravity constraint on these particles, a compensatory force is added to these particles to resist the change in gravity, thereby pulling back the change in the position of the particles due to the gravity constraint, thereby achieving a certain curved shape connected by these particles.
[0052] c) When following the movement of an attachment, the hair resource needs to implement a corresponding particle motion strategy (Velocity Shock Propagation, VSP), which means that the acceleration involved will affect the position of the hair. VSP, or velocity shock propagation, refers to the fact that when the velocity of the attachment to which the hair resource is attached changes (i.e., vibration occurs), the vibration caused by the velocity will propagate from the attachment to the hair resource, causing the hair resource to move. When the attachment to which the hair resource is attached (such as a virtual character, which can be the head model of the virtual character) changes in acceleration, a traction acceleration will be generated on the hair resource, thereby exerting a force on the hair resource; at this time, the hair resource will produce a fluttering effect due to the force caused by the traction acceleration. For example, if the virtual character has long hair and suddenly accelerates forward under the control of the game player, the virtual character's hair will be blown up.
[0053] d) The position of each particle in a hair asset is affected by the adjacent particles before and after it. This means that the motion of adjacent particles follows a spring-mass model. Local Shape Constraints (LSCs) are typically used to calculate the new position of a particle in a hair asset after being affected by the particles before and after it.
[0054] e) If there is a wind field in the virtual scene where the hair resource is located, the hair resource will also be affected by the wind force (wind influence) in the wind field, and produce the effect of fluttering in the wind. By using wind field calculation, the movement performance of the hair resource in a windy environment can be simulated. Among them, TressFx mainly uses the pyramid wind field (pyramid wind) shown in Figure 1c, or pyramid wind, to implement wind field calculation; simply, TressFx uses the remainder of 20 (assuming that the number of particles on the hair resource is not a multiple of 20) to generate a pseudo-random number, and then uses the pseudo-random number to mix with the four side directions of the pyramid to obtain a fused wind direction within the range of the pyramid wind field, and uses the fused wind direction as the wind direction for the wind field calculation of the current particle.
[0055] f) The length of each hair segment in a hair asset (length constriants) must remain constant, and the total length of the hair asset should also remain constant. Specifically, in real-world applications, hair assets are fixed in length, but this can change during physical simulations, leading to poor simulation accuracy. TressFx supports length constraints (which are used to keep the length of the hair asset constant during the character's motion) to mitigate this issue.
[0056] g) The collision detection system in TressFx is implemented based on Signed Distance Field (SDF). SDF requires a large overhead and consumes a lot of performance when performing collision detection on millions of nodes.
[0057] The above constraints a)-g) are exemplary constraints set by TressFx for the physical movement of hair resources. Furthermore, considering that virtual characters often have a large number of hair resources, TressFx also supports dividing hair resources into guide strands and follower strands to reduce the amount of physical calculations required for hair resources. During physical simulations, dynamic and wind field simulations need to be performed on guide strands. The physical simulation results for follower strands are generated by offsetting the guide strands, while collision detection and correction are performed on all hair strands. An exemplary schematic diagram of generating follower strands from guide strands can be seen in Figure 1d. As shown in Figure 1d, during the actual physical simulation process, the aforementioned physical simulation calculations are performed on guide strands 108. Then, by offsetting guide strands 108 (e.g., by shifting their position), corresponding follower strands 109 are generated. This reduces the amount of calculations while ensuring the volume of hair in the virtual character.
[0058] In actual applications, TressFx provides a relatively complete hair resource simulation solution, but some of the simulation solutions provided by TressFx are still worth optimizing and expanding. In order to better cope with faster and more complex animations after integrating the open source TressFx into the self-developed rendering engine and improve the authenticity of hair resources, the embodiment of the present application expands on the encapsulated hair simulation framework TressFx and optimizes some problems in TressFx. The following is a brief introduction to the extensions and improvements of TressFx in the resource processing solution provided by the embodiment of the present application, and the extensions and improvements are further introduced in detail in the subsequent embodiments; among them:
[0059] 1) Expand based on TressFx.
[0060] Considering that the displacement of the virtual character itself will affect the mass points of the hair resource, as described above, the acceleration involved in the hair resource following the movement of the attachment body will affect the position of the hair. However, the physical simulation implemented by TressFx requires that the virtual character itself not be displaced. For example, when the virtual character performs actions such as walking, running, and jumping in place, the virtual character often moves in the real scene, such as running from the first virtual scene to the second virtual scene. That is, the movement of the virtual character will have a displacement in the world space. Therefore, when TressFx does not support world space displacement, if the virtual character performs actions such as running, the hair resource of the virtual character always maintains a relatively fixed posture with the virtual character, and the dynamic offset effect of the hair resource changing with the movement of the virtual character cannot be reflected.
[0061] To better control the shape and movement of hair assets during avatar motion, the present application adds world-space simulation and global offset functionality to TressFx. These features effectively analyze the impact of the avatar's displacement on the particles in the hair asset, and adapt and personalize adjustments to the avatar's motion to achieve optimal hair asset movement. By adding world-space simulation and global offset to TressFx, the position, direction, and overall shape of the hair asset can be more precisely controlled, resulting in more realistic motion performance.
[0062] In an embodiment of the present application, during the movement of a virtual character, spatial change information of the virtual character can be obtained; this spatial change information is used to indicate the position change of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene. Then, the virtual character's hair resource stores static resource data in each game scene. This static resource data can be used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene. At this time, dynamic resource data of the hair resource in the second game scene can be generated based on the static resource data and the obtained spatial change information. This dynamic resource data is used to reflect the dynamic characteristics of the hair resource as it moves with the movement of the virtual character. Finally, by performing physical simulation of the hair resource based on the dynamic resource data, the hair resource can simulate the movement performance in the real world during the movement of the virtual character from the first game scene to the second game scene.
[0063] It can be seen that the embodiment of the present application adds world space simulation to TressFx. By applying the spatial change information when the virtual character moves from the first game scene to the second game scene to the static resource data of the hair resource, the dynamic resource data of the hair resource in the second game scene can be obtained. Based on the dynamic resource data, the hair resource can be more accurately controlled to dynamically offset as the virtual character moves, so that the hair resources in the game world simulate and restore the movement performance of the hair resources in the real world as much as possible, thereby improving the naturalness and realism of the hair resources in the game scene where the virtual character moves.
[0064] 2) Optimization based on TressFx.
[0065] ① Optimize the dynamic effects of hair resources, including flowing, lateral movement, and fine hair dynamics. In order to achieve a more realistic hair simulation effect, a physics engine is used in TressFx to simulate the movement of hair, and the effects of factors such as gravity, air resistance, and the displacement of the virtual character itself on the movement of hair resources are taken into account. Furthermore, considering that the number of parameters corresponding to the various factors provided by TressFx is relatively large, the embodiments of this application support optimizing the calculation process through parameter control, using animated skinning data (Skinning Data) to modify local shape constraints, and other methods to enhance the hair simulation effect of the virtual character during movement.
[0066] ② It should be understood that multiple hair resources can form a hair resource set, and the hair resource set can present a fixed shape (or a specific shape); for example, the fixed shape of the hair resource set includes any of the following: a virtual ponytail, a virtual bun, and a virtual braid. For the sake of convenience, the fixed shape of the hair resource set is taken as an example of a virtual ponytail (or simply a ponytail). In TressFx, if a virtual character performs a quick squatting action in situ (such as from squatting to standing up, or from standing up to squatting), then during the movement of the virtual character, the virtual ponytail is prone to problems such as the base of the ponytail being raised, the ends of the ponytail being spread out, lacking a sense of drape, and length being elongated. Therefore, the embodiments of the present application provide a variety of technical means to achieve better control of the overall shape and collision problems of the virtual ponytail, and adjust the length constraint to optimize the elongation effect.
[0067] For example, when addressing the problem of virtual ponytails tending to lift high and lacking a sense of drape, parameters such as the elastic coefficient and gravity parameter can be added to prevent the ponytail from lifting high and enhance the sense of drape. Another example is when addressing the problem of the virtual ponytail's tail tip easily spreading out, coefficients can be added to the local shape constraint to accurately identify the virtual ponytail's tail tip. Further constraints can be added to fix the overall shape of the tail tip, preventing the tail tip from spreading too much and appearing unnatural during the virtual character's movement. For example, when TressFx processes the impact of speed changes, the only thing that ultimately participates in the calculation of changing the position of the particles in the hair resource is the position change. This calculation method will cause the hair resource to stretch. Even if the length constraint can alleviate the hair stretching problem to a certain extent, when the stiffness and damping of the hair resource are small, the acceleration is too large, and the speed mutation is too large, there will still be a relatively obvious stretching phenomenon. The embodiment of the present application supports alleviating the hair stretching problem by adjusting the calculation order between multiple constraint conditions on the one hand, and supports alleviating the hair stretching problem by correcting the constraint formula of the length constraint on the other hand, similar to adding a stiffness coefficient to alleviate the hair stretching problem.
[0068] ③ Velocity vibration propagation (VSP) in TressFx is an important calculation process in physical simulation. Currently, the calculation amount of VSP is relatively large. The embodiment of the present application supports modification of the calculation process of VSP and specializes its calculation method. While improving the calculation efficiency and realizing the hair simulation process more quickly, it can obtain better velocity vibration propagation effect.
[0069] ④ Optimize the hair resource generation strategy. In the parallel hair resource generation scheme provided by TressFx, which uses 64 hair resources as a group, this embodiment of the application no longer performs overlapping rendering on the redundant hair resources contained in the last generation group. Instead, it hides the redundant hair resources by changing their display space. This avoids problems such as hair thickening caused by overlapping rendering, ensures the quality and reliability of the generated hair resources, and improves the authenticity of hair rendering.
[0070] In the embodiments of the present application, on the one hand, the self-developed rendering engine provided in the embodiments of the present application implements hair resource rendering based on TressFx. Compared to hair piece models, the use of continuous curves to represent individual virtual hairs can better capture the real and subtle movements and changes of hair resources, and present a more natural and realistic effect. In addition, the use of continuous curve modeling can precisely control the overall shape, improving the flexibility of shape control. A schematic diagram comparing an exemplary hair piece model rendering hair resource and TressFx rendering hair resource can be seen in Figure 2. On the other hand, the embodiments of the present application add world space simulation and other methods to TressFx, allowing art designers to more accurately grasp the position, direction, and overall shape of the particles in the hair resource, achieving more realistic motion expression. On the other hand, the embodiments of the present application optimize some existing solutions in TressFx. Compared to the original solution in TressFx, the embodiments of the present application can more accurately control and grasp the position and direction of each particle in the hair resource, thereby effectively grasping the overall shape of the hair resource plan composed of the hair resources. In summary, the embodiments of the present application further improve the performance and effect of hair resource simulation on the basis of TressFx through the expansion and optimization of the above-mentioned technologies, expand the scope of use and effect of hair resource simulation solutions in practical applications, and meet the effect requirements of 3A games (i.e., games with high development costs, long development cycles, and high resource consumption).
[0071] As described above, the resource processing solution provided in the embodiments of this application is based on the TressFx framework. Therefore, the resource processing solution provided in the embodiments of this application is universal and applicable to all application scenarios that integrate the TressFx framework and require hair resource rendering. Application scenarios may include, but are not limited to, gaming scenarios, digital human scenarios, VR (Virtual Reality) scenarios, AR (Augmented Reality) scenarios, and so on.
[0072] In one possible implementation, the application scenario can be a game scenario. There are a variety of game characters in the game scenario, and game players can perform movements such as running, jumping, and flying by controlling the game characters. The resource processing solution provided in the embodiment of the present application is used to render the hair resources of the game characters during movement, so that the dynamic effects of the hair resources can simulate the dynamic performance that the hair of the game characters should present when performing movements in a real environment as much as possible, and highly restore the movement performance of the hair resources. For example, when a game character in a game scene is running fast, the hair resources of the game character will change dynamically with the game character; when the game character runs to the right, the root particle of the hair resource of the game character is connected to the head model of the game character, but the tail particle of the hair resource is always on the left side of the root particle. When the game character suddenly stops, the tail particle of the hair resource will be on the right side of the root particle due to inertia.
[0073] In one possible implementation, the application scenario can be a digital human scenario. A digital human, or virtual human, is a digital human image close to a human image created using digital technology. Digital humans can be applied to various fields, including but not limited to: being applied to audio and video calls, in which case the real person in the audio and video call can be transformed into a digital human, and the digital human simulates the real person's hairstyle, expression, and movements, etc.; or being applied to a guided human-computer interaction scenario, in which the digital human can explain the content to the user (such as intelligent explanation in a museum) or prompt actions (such as prompting the user to perform certain operations in the interface); and so on. The embodiment of the present application does not limit the application field of the digital human. When the digital human can be applied to any application field, the resource processing solution provided in the embodiment of the present application can be used to physically simulate the hair resources of the digital human, in order to pursue a more realistic and detailed hair rendering effect, providing the user with an immersive experience.
[0074] In one possible implementation, the application scenario may be a VR scenario or an AR scenario. VR and AR are two simulation technologies that can bring users into a virtual world. The difference between the two is that AR adds digital information to the real world, allowing users to experience the richness and interactivity of digital information in the original environment, while VR completely isolates the real world and places users in a virtual environment. In a VR scenario or an AR scenario, it may be necessary to render a virtual avatar in the virtual world. For example, the avatar may be a person or animal with hair resources. In this case, the resource processing solution provided in the embodiment of the present application can be used to render the hair resources of the avatar, so as to improve the realism of the avatar in the VR scenario or the AR scenario and enhance the user's immersive experience.
[0075] It should be noted that the above is only an exemplary description of the application scenarios to which the embodiments of the present application are applicable, and does not limit the application scenarios to which the embodiments of the present application are applicable.
[0076] It should also be noted that the embodiments of the present application support the execution of resource processing solutions by computer devices. Among them, the computer device can be any device deployed with a self-developed rendering engine, which integrates the TressFx framework and uses this solution to expand and optimize the framework. Among them, the computer device can be a terminal device, and the terminal device can include but is not limited to: smart phones, tablet computers, portable personal computers, mobile Internet devices (Mobile Internet Devices, referred to as MID), vehicle-mounted devices, head-mounted devices and other devices. The embodiments of the present application do not limit the type of terminal devices, which is explained here. Optionally, the computer device can be a server, and the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms; the embodiments of the present application do not limit the specific type of server.
[0077] Based on the resource processing scheme described above, the embodiment of the present application proposes a more detailed resource processing method. From the above description, it can be seen that the resource processing scheme provided by the embodiment of the present application mainly expands and optimizes TressFx. The extension part of TressFx (i.e., adding world space simulation and global offset functions to TressFx) will be described in detail below in conjunction with Figure 3. Figure 3 shows a flow chart of a resource processing method provided by an exemplary embodiment of the present application; the resource processing method can be executed by the computer device mentioned above, and the resource processing method may include but is not limited to the steps shown in S301-S304:
[0078] S301: Acquire spatial change information of a virtual character.
[0079] The spatial change information of the virtual character can be used to indicate: when the virtual character moves from the first game scene to the second game scene, the position change of the virtual character in the world space coordinate system. In other words, the spatial change information represents the change in the position of the virtual character when it moves in the world space coordinate system. Among them, the game scene involved in the embodiment of the present application can correspond to an image frame, that is, one game scene corresponds to one image frame, and the image frame can be used to describe the game scene from the image dimension. Then, when multiple consecutive image frames are played in sequence, the dynamic process of the virtual character moving from one game scene to another game scene can be presented.
[0080] The embodiments of the present application support obtaining spatial change information of a virtual character by using different image frames containing the movement process of the virtual character. In one possible implementation, a first image frame corresponding to the first game scene when the virtual character is in the first game scene can be obtained, and the first spatial position information of the virtual character in the first image frame in the world space coordinate system can be calculated. The first spatial position information is used to indicate the spatial position of the virtual character in the first game scene. Similarly, a second image frame corresponding to the second game scene when the virtual character is in the second game scene can be obtained, and the second spatial position information of the virtual character in the second image frame in the world space coordinate system can be calculated. The second spatial position information is used to indicate the spatial position of the virtual character in the second game scene. Among them, in 3D (Dimensions) games (i.e., games that use spatial stereo computing technology to implement operations), the above-mentioned spatial position information (such as the first spatial position information and the second spatial position information) can be expressed as (x, y, z). x represents the position of the virtual character on the horizontal axis x of the world space coordinate system, y represents the position of the virtual character on the vertical axis y of the world space coordinate system, and z represents the position of the virtual character on the vertical axis z of the world space coordinate system. When x=0, y=0, and z=0, the point (0, 0, 0) is the origin of the world space coordinate system. Finally, the spatial change information of the virtual character can be calculated based on the first spatial position information of the virtual character in the first game scene and the second spatial position information of the virtual character in the second game scene.
[0081] An exemplary schematic diagram of an exemplary world space coordinate system can be seen in Figure 4. As shown in Figure 4, for the convenience of explanation, a dot 401 represents a virtual character. It is assumed that the first spatial position information of the virtual character in the first game scene is represented by (x1, y1, z1). When the virtual character moves from the first game scene to the second game scene, it is assumed that the second spatial position information of the virtual character in the second game scene is represented by (x2, y2, z2). Then, the values of the same axis in the first spatial position information (x1, y1, z1) and the second spatial position information (x2, y2, z2) are subtracted (such as position x1 on the horizontal axis - position x2, position y1 on the vertical axis - position y2, position z1 on the vertical axis - position z2), and the value obtained by subtraction is the movement distance of the virtual character on the axis, and the sign obtained by subtraction (such as positive sign "+" or negative sign "-") represents the direction of movement of the virtual character along the axis.
[0082] S302: Obtain static resource data of the virtual character's hair resource in the second game scene.
[0083] S303: Based on the static resource data and the spatial change information, dynamic resource data of the hair resource in the second game scene is obtained.
[0084] In S302-S303, it is worth noting that ① the virtual character's hair resource has static resource data in each image frame (i.e., the game scene) (specifically, the static resource data of the root particle of each hair resource). This static resource data can be used to reflect the static characteristics of the hair resource when the virtual character is static in the corresponding game scene. Among them, the static resource data can specifically include static position information and static direction information of the hair resource, and the static characteristics are characterized by this static position information and static direction information. Among them, the static position information is used to indicate the position of the hair resource when the virtual character remains motionless in the game scene, and the static direction information is used to indicate the direction of the hair resource when the virtual character remains motionless in the game scene (the direction of the hair resource can be simply understood as the rotation angle of the attachment to which the hair resource is attached. For example, if the attachment is the head model of the virtual character, then the rotation angle can be the rotation angle of the head model).
[0085] ② The spatial change information between two image frames (such as the first image frame and the second image frame mentioned above) when the virtual character moves can be expressed in a matrix form. The spatial change information in the rectangular form includes the displacement information and rotation information of the virtual character between the two image frames. Among them, the displacement information in the spatial change information is used to indicate: the displacement distance and displacement direction and other information generated when the virtual character moves from the first game scene to the second game scene. For example, the displacement information indicates that when the virtual character moves from the first game scene to the second game scene, it moves 10 meters (displacement distance) along the positive direction (displacement direction) of the x-axis of the world space coordinate system. The rotation information in the spatial change information is used to indicate: when the virtual character moves from the first game scene to the second game scene, the rotation angle of the virtual character's head model in the world space coordinate system. From a visual effect point of view, the virtual character's head model is deflected, such as the rotation caused by tilting the head to look to the left, or looking up. An exemplary schematic diagram of a virtual character moving from the first game scene to the second game scene with simultaneous displacement and rotation can be seen in Figure 5. As shown in the first figure in Figure 5, when the avatar changes from a frontal orientation to tilting its head toward the upper left corner, the avatar's head model is determined to have rotated. At this point, the spatial change information includes rotation information (such as rotation angle and direction) for the avatar's head model. As shown in the second figure in Figure 5, when the avatar changes from a sideways orientation and stationary position to turning its head and running, the avatar's head model not only shifts but also rotates. At this point, the spatial position information includes both displacement information (such as displacement direction and distance) and rotation information.
[0086] Based on the above basic introduction to static resource data and spatial variation information, after obtaining the static resource data of the virtual character's hair resource in the second game scene (or second image frame) and the spatial variation information of the virtual character in the world space coordinate system when the virtual character moves from the first game scene (or first image frame) to the second game scene, the spatial variation information can be applied to the static resource data to calculate new data. This new data is the spatial position data of the hair resource with a global spatial transformation (the static resource data only contains the static position of the skin of the head model, without displacement information, rotation information, etc.). As described above, spatial variation information can be represented as a matrix, so the aforementioned process of applying the spatial variation information to the static resource data can be understood as multiplying the matrix by the static resource data. One possible implementation method may include, but is not limited to: determining the static position information of the hair resource in the second game scene from the static resource data, and determining the dynamic position information of the hair resource in the second game scene based on the static position information and the displacement information in the spatial variation information. Similarly, the static orientation information of the hair resource in the second game scene is determined from the static resource data, and the dynamic orientation information of the hair resource in the second game scene is determined based on the static orientation information and the rotation information in the spatial variation information. Thus, the dynamic position information and dynamic orientation information obtained from the two aforementioned steps constitute the dynamic resource data of the hair resource in the second game scene (i.e., the new data mentioned above). This dynamic resource data is used to reflect the dynamic characteristics of the hair resource as it moves with the avatar. For example, if the avatar moves to the left, the tips of the hair resource will follow the leftward motion, slightly lagging behind the avatar's speed, to simulate the motion of the hair resource as it moves with the avatar in the real world.
[0087] Thus, by applying the spatial variation information generated by the avatar's motion to the static resource data of the avatar's hair resource in the second image frame, the hair resource can be converted from static resource data to dynamic resource data. Based on this dynamic resource data, the hair resource is then driven to follow the avatar's motion, creating a corresponding dynamic effect. This approach not only offers the advantages of simple and convenient computation, but also allows for more precise control of the hair resource's motion, enhancing the effect of the hair resource recreating the real-world dynamic effect of the hair resource following the avatar's motion.
[0088] S304: Perform physical simulation on the hair resource based on the dynamic resource data.
[0089] It should be understood that in the real world, the dynamic effects of hair resources are affected by a variety of factors. In addition to the aforementioned influence of the movement of the attachment to which the hair resource is attached, they are also affected by external factors. External factors may include, but are not limited to, wind, gravity, and the resistance caused by the movement of the attachment. Even if there is an external force pulling on the hair resource (such as the hair resource being caught on an external element (such as a branch or button)), it can also be affected by the pulling force. The present embodiment does not limit the external factors that affect the hair resource.
[0090] Based on this, in order to make the movement performance of the hair resource in the game scene as close as possible to the movement performance in similar scenes in the real world, the embodiment of the present application, after obtaining the dynamic resource data of the virtual character's hair resource in the second game scene based on the aforementioned steps when the virtual character moves from the first game scene to the second game scene, will further perform physical simulation on the hair resource based on the dynamic resource data. Through this physical simulation, the hair resource can simulate the movement performance in the real environment during the movement of the virtual character from the first game scene to the second game scene, thereby improving the realism and authenticity of the movement performance of the hair resource. Among them, the external factors mentioned above act on the hair resource in the form of constraints; for example, if the external factor is gravity, then the hair resource will be subject to the constraint corresponding to the gravity factor, and when this constraint acts on the hair resource, the hair resource will be subjected to a downward force.
[0091] In one possible implementation, after obtaining the dynamic resource data of the virtual character's hair resource in the second game scene, one or more constraints that the virtual character is subject to during its movement from the first game scene to the second game scene can be obtained. Corresponding to the external factors described above, the constraints here may include, but are not limited to, wind constraints, gravity constraints, drag constraints, and length constraints. Then, based on the one or more constraints and the dynamic resource data, a physical simulation can be performed on the root particles of the hair resource. As can be seen from the above description, a hair resource is a virtual hair composed of multiple chain-like particles. The root particles here refer to two adjacent particles in the hair resource that are attached to an attachment (such as the virtual character's head model). The principle of performing physical simulation based on one or more constraints and dynamic resource data can specifically include: when calculating multiple constraints, simulating the constraint effects of the multiple constraints interacting with each other in a real environment, thereby achieving simulation calculations for multiple constraints.
[0092] For example, assume that a virtual character is affected by gravity and wind while moving from a first game scene to a second game scene. As shown in FIG6 , the wind direction of the wind field is from right to left. In this case, the virtual character's hair resource (e.g., hair resource 601) will droop downward due to gravity. Meanwhile, the wind from right to left will partially offset the downward force caused by gravity, and the tail particle of the hair resource will appear to move to the left, simulating the movement of hair resources in the real world when affected by wind and gravity.
[0093] In summary, on the one hand, by obtaining spatial change information when the virtual character moves from the first game scene to the second game scene, and applying this spatial change information to the static resource data of the hair resource, it is possible to obtain dynamic resource data of the hair resource in the second game scene. This dynamic resource data is used to reflect the dynamic characteristics of the hair resource as it moves with the movement of the virtual character. On the other hand, it is possible to obtain one or more constraints to which the virtual character is subject during the movement from the first game scene to the second game scene, and to perform a physical simulation of the hair resource through simulation calculation of one or more constraints and dynamic resource data. Through these two aspects, it is possible to simultaneously consider dynamic resource data and one or more constraints, thereby more accurately controlling the dynamic offset of the hair resource as the virtual character moves, so that the hair resource in the game world simulates and restores the movement performance of the hair resource in the real world as much as possible, thereby improving the naturalness and realism of the hair resource in the game scene where the virtual character moves.
[0094] The embodiment shown in FIG3 above mainly introduces the extension portion of the resource processing method for TressFx. The optimization content of the resource processing method for TressFx is described in detail below in conjunction with FIG7. FIG7 shows a flow chart of a resource processing method provided by an exemplary embodiment of the present application; the resource processing method can be executed by the computer device mentioned above. The memory processing method may include but is not limited to the steps shown in S701-S705:
[0095] S701: Acquire spatial change information of the virtual character and static resource data of the virtual character's hair resources in the second game scene.
[0096] It should be noted that, for the specific implementation process shown in S701 in the embodiment shown in FIG. 7 , reference may be made to the relevant description of the specific implementation process shown in S301 in the embodiment shown in FIG. 3 , and no further details will be given here.
[0097] S702: Acquire movement information of the virtual character.
[0098] S703: If it is detected based on the motion information that the spatial variation information needs to be optimized, the spatial variation information is optimized according to the motion information to obtain optimized spatial variation information.
[0099] In S702-S703, considering that in some scenarios, if all the spatial change information of the virtual character moving from the first game scene to the second game scene is applied to the static resource data of the hair resource in the second game scene, it may cause the shape of a fixed-shape hair resource set composed of multiple hair resources (such as a virtual ponytail) to change, thereby causing the dynamic effect of the hair resource to be unnatural. For example, the hair resource set of the virtual character is a virtual ponytail; when the virtual character is sprinting in a certain direction, if all the spatial change information of the virtual character during the sprinting process is applied to the root particle of each hair resource contained in the virtual hair, then it is very likely that the root of the virtual ponytail (that is, the position where the virtual ponytail is tied with a hair tie) will be raised very high due to the excessive movement speed (that is, the position change is too drastic), and the effect is unnatural.
[0100] Based on this, the embodiment of the present application supports determining whether the virtual character's movement is violent after obtaining the spatial change information of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene. If the movement is not violent, it means that applying all the spatial change information to the hair resource will not cause unnatural movement of the hair resource (such as the base of the ponytail curling up, etc.), and then directly executing the subsequent operation of applying the spatial change information to the static resource data. Conversely, if the movement is violent, it means that applying the spatial change information to the hair resource will cause the movement of the hair resource to be unnatural, and then a mechanism can be set to weaken the violent movement caused by the spatial change information to ensure the naturalness and authenticity of the hair resource.
[0101] In an embodiment of the present application, the movement information of the virtual character when the virtual character moves from the first game scene to the second game scene can be obtained first; the movement information may include at least one of the following: displacement distance, displacement direction and speed information, wherein the speed information may include average speed, acceleration and angular velocity, etc.
[0102] Then, based on the motion information, it is detected whether the spatial change information needs to be optimized. The method for determining whether the spatial change information needs to be optimized can be: ① If the displacement distance is greater than the displacement distance threshold, it is determined that the spatial change information needs to be optimized; that is, as long as the displacement distance is greater than the displacement distance threshold, it is determined that the virtual character is performing a violent movement and needs to be weakened. ② If the displacement distance is less than or equal to the displacement distance threshold, and the displacement direction indicates that the movement direction of the virtual character in the first game scene is different from the movement direction in the second game scene, and the speed information indicates that the speed of the virtual character is greater than the speed threshold, it is determined that the spatial change information needs to be optimized. The situation described above can be imagined as a situation where the virtual character first runs in a certain direction and then quickly runs in the opposite direction of the certain direction. In this case, the virtual character in the first image frame is moving in the certain direction, and the virtual character in the second image suddenly moves in the opposite direction of the certain direction. Then, directional inertia will be involved in the middle, so it is necessary to set a mechanism to make the process of changing direction in the middle not abrupt and not interfering with the model. Among them, the specific values of the various thresholds mentioned above (such as the displacement distance threshold and the speed threshold) can be obtained according to the test to obtain appropriate values. The specific values of the thresholds are not limited in the embodiments of the present application.
[0103] Finally, if the spatial variation information is determined to require optimization, i.e., the avatar's movement is intense, potentially causing unnatural hair resource motion, the spatial variation information can be optimized to mitigate artifacts such as clipping or unnatural effects on the hair resource caused by intense motion. For example, a motion threshold corresponding to the motion information can be obtained. If the motion information is displacement distance, the motion threshold is the aforementioned displacement distance threshold; if the motion information is velocity information, the motion threshold is the velocity threshold. Then, based on the difference between the motion information and the motion threshold, constraints are added to the avatar. Specifically, the difference between the motion information and the motion threshold is used to measure the degree of intense motion, and constraints are added based on this degree. Based on the added constraints, the spatial variation information is optimized. Specifically, the displacement and rotation information included in the spatial position information is updated to obtain optimized spatial position information. The new position and rotation information contained in this optimized spatial position information, when applied to the static resource data, results in dynamic resource data that prevents artifacts such as clipping or unnatural effects on the hair resource during intense motion, thereby restoring the natural motion effect of the hair resource in scenes with intense motion.
[0104] As can be seen from this, after obtaining spatial change information as the avatar moves from the first game scene to the second, this spatial change information is not first applied to the static resource data of the avatar's hair resources in the second game scene. Instead, it is first determined whether the avatar is moving vigorously, and then the spatial change information is optimized during such intense movement. This approach effectively avoids the effects of hair clipping and unnaturalness that would otherwise occur if the spatial change information were applied solely to the static resource data during intense movement.
[0105] It is worth noting that in the above-mentioned process of optimizing the spatial change information, the running information of the virtual character moving from the first game scene to the second game scene is re-acquired to determine whether the spatial change information needs to be optimized. As described above, the spatial change information itself contains the displacement information and rotation information of the virtual character when moving from the first game scene to the second game scene. Therefore, in the specific judgment process, it is also possible to no longer re-acquire the motion information of the virtual character, but to analyze the displacement and / or speed (such as acceleration and / or angular velocity, etc.) from the spatial change information for judgment. The implementation of this application does not limit the specific implementation method of judging whether the spatial change information needs to be optimized, that is, whether the virtual character is moving violently, and is specifically explained here.
[0106] S704: Based on the static resource data and the optimized spatial change information, dynamic resource data of the hair resource in the second game scene is obtained.
[0107] It should be understood that the specific implementation process of applying the optimized spatial change information to static resource data to obtain dynamic resource data is similar to the specific implementation process of applying the original spatial change information to static resource data to obtain dynamic resource data as shown in S303 in the embodiment shown in Figure 3 above. The only difference is that the specific values of the optimized spatial change information and the original spatial change information (such as the values of the elements contained in the matrix) are different, which will not be elaborated here.
[0108] S705: Perform physical simulation on the hair resource based on the dynamic resource data.
[0109] It should be noted that the specific implementation process shown in S705 can refer to the relevant description of the specific implementation process shown in S304 in the embodiment shown in Figure 3 above, and will not be repeated here.
[0110] As can be seen from the foregoing description, the resource processing solution provided in the embodiment of the present application extends and optimizes TressFx. S701-S705 above mainly provide the specific implementation content of adding a world space to TressFx. The following describes the optimization of TressFx.
[0111] (1) Optimization of parameter control and local shape constraints (LSC).
[0112] ① Parameter control. It is not difficult to understand that in the process of physical simulation of the hair resources of the virtual character, TressFx mainly realizes the physical simulation by providing a set of parameters; the parameters here can include parameters of various constraints, such as the parameters of gravity constraints (Gravity, G) and air resistance (i.e. the resistance encountered by physical movement in the air). In practical applications, if the parameter values of the parameters of the various constraints in the real world are simply brought into the simulation calculation for the hair resources, not only will the amount of calculation be large, but the calculation effect will also be poor. Based on this, the embodiments of the present application support considering the correlation between parameters, such as associating or integrating mutually influencing parameters together, so that the artist (the user who draws the hair resources) can easily adjust multiple parameters in a linked manner, while reducing the calculation overhead, it can also improve the accuracy of the simulation calculation. For example, in some scenarios, the changes can be unified into the stiffness deformation to avoid the additional calculation overhead brought about by calculating both the flexibility change and the stiffness deformation.
[0113] In one possible implementation, during the physical simulation of a virtual character's hair resource, a parameter group required for drawing the hair resource can be obtained, and the parameter group includes multiple parameters. Then, a correlation analysis is performed on the multiple parameters in the parameter group, mainly following the principle of whether the parameters in the real world influence and interact with each other, and whether different parameters can be integrated to perform a correlation analysis on the multiple parameters, and obtain the correlation relationship between the parameters in the parameter group. Finally, the artist can determine the parameter value of each parameter in the virtual world (or game world) based on the parameter value of each parameter in the parameter group in the real world and the correlation relationship between the parameters; in this way, the parameters of the associated or integrated parameters can be used to draw the hair resource, resulting in better quality and more realistic hair resources.
[0114] ② Modify the local shape constraints. The local shape constraints in TressFx are mainly used to calculate the position of a particle in the hair resource after being affected by the adjacent front and rear particles. The calculation steps of the local shape constraints are implemented according to the initialized static data of the particles on the hair resource (strand) (which can be simply understood as the initial position (InitialPos)). Taking into account the need to simulate the movement performance of the hair resource as the virtual character moves, this technology of using the initialized static data of the hair resource to perform local shape constraints will lead to poor simulation effects. Therefore, when calculating the local shape constraints for the hair resource, the embodiment of the present application will obtain the skinning data (Skinning Data) in the image frame after the virtual character moves to calculate the local shape constraints. Compared with the calculation based on static data, the hair simulation effect during the movement process can be better and more natural.
[0115] (2) Optimization of virtual ponytails (or fixed-shaped hairstyles such as virtual braids or virtual buns) composed of multiple hair resources.
[0116] As can be seen from the above description, when a virtual character simulated in TressFx performs a squat (or other actions that may cause the virtual character to change its vertical position quickly (such as vertical takeoff)), the virtual ponytail of the virtual character is likely to have problems such as being lifted high, lacking a sense of drape, being stretched, easily unraveling, and collision detection. Among them:
[0117] ① Regarding the problem that the virtual ponytail (or the hair ends of the virtual braid) are easy to spread out. Taking into account that the local shape of the hair resource is guaranteed by local shape constraints in TressFx, the embodiment of the present application mainly optimizes the local shape constraints to achieve the problem of controlling the virtual ponytail from spreading out through the optimized local shape constraints. In one possible implementation method, the local shape constraints of the hair resource set (i.e., the virtual ponytail) are obtained, and the local shape constraints are updated using a first recognition coefficient. The update here specifically adds a first recognition coefficient to the local shape constraint. The first recognition coefficient is mainly used to identify which part of the virtual ponytail is the hair resource that is easy to spread out. Then, the updated local shape constraint is used to identify and process the hair resource set, obtaining a first hair set in the hair resource set. The hair resources in the first hair set have a hair spreading probability greater than a preset threshold. For example, when the hair resource set is a virtual ponytail, the identified first hair set should be the entire virtual ponytail (as shown in FIG8a). For another example, when the hair resource set is a virtual braid, the identified first hair set should be the hair resources after the hair loop in the virtual braid (as shown in FIG8b). Finally, each hair resource in the first hair set is constrained to obtain a constrained hair set. The hair spreading probability of each hair resource in the constrained hair set is less than or equal to the preset threshold, so that the constrained hair set maintains a fixed shape or is not likely to spread out during the virtual character's squatting action.
[0118] ② Regarding the problem that virtual ponytails tend to curl up and lack a sense of drape. Similar to implementation method ①, in TressFx, the local shape of the hair resource is guaranteed by local shape constraints. Therefore, first, the local shape constraint of the hair resource set can be obtained, and the local shape constraint can be updated using a second recognition coefficient to obtain an updated local shape constraint. The second recognition coefficient is used to identify the part of the hair resource set that needs to avoid curling up or lacking a sense of drape (such as the root of the virtual ponytail, as shown in Figure 8c). Then, the hair resource set is identified and processed using the updated local shape constraint to obtain a second hair set in the hair resource set. The second hair set is the root resource set of the hair resource set (such as the root of the virtual ponytail) or the tail resource set (such as the hair tips of the virtual ponytail and virtual braid). Afterwards, the acceleration of the particle of the hair resource in the second hair set is obtained, and it is determined whether the acceleration is greater than the acceleration threshold. If the acceleration is greater than the acceleration threshold, it indicates that the second identified hair set is likely to have issues with curling or lacking drape. Therefore, these hair resources need to be processed to avoid this. For example, global motion parameters for the hair resource set can be obtained and weighted using attribute values to produce a weighted result. This weighted result is then used as the particle motion parameters for the particles in the hair resources in the second hair set. The particle motion parameters are then used to control the motion of these particles.
[0119] Considering that when an attached object (such as a virtual character) moves, the movement of the hair resource is primarily controlled by the particle motion strategy (VSP) in TressFx through the implicated acceleration. Therefore, embodiments of the present application can improve the VSP so that the improved VSP can be used to process the second hair set to avoid the problem of high sway or lack of drape. The VSP in TressFx is global, that is, the VSP of all particles in the hair resource of the virtual character (mainly the root particles) is the same, that is, the VSP value is effective for each particle. In order to achieve the differentiation of the VSP value of the particle, so that different particles follow the movement of the virtual character and present different following states, embodiments of the present application support setting elastic properties (with values in the range [0,1]) for the particles in the hair resource. Specifically, elastic properties can be set for each particle or some particles (such as the root particles) in the hair resource, so that the VSP value of the particle is adjusted by the elastic property. The precise control of the VSP of each particle avoids the problem of high sway and lack of drape. After determining that the acceleration of a particle in a hair resource is greater than an acceleration threshold, an attribute value of an elastic property can be determined for the particle based on the acceleration, such as a value of 0.3. Then, the global motion parameter (VSP) of the hair resource set is obtained and weighted using the attribute value to obtain a weighted result of 0.3*VSP. Finally, the weighted result is used as the particle motion parameter for the particles in the hair resources in the second hair set. In this way, by precisely controlling the particle motion parameters of each particle in the hair resource, the motion effect of the corresponding particle is controlled through the particle motion parameters.
[0120] ③ Addressing the issue of hair resources being easily stretched. As can be seen from the foregoing description, TressFx controls the length of hair resources by introducing length constraints. Therefore, embodiments of the present application strengthen length constraints to better control the length of hair resources, simulating a fixed length in the real world. On the one hand, strengthening length constraints can be achieved by adjusting the calculation order of multiple constraints for hair resources. For example, multiple constraints for a virtual character's hair resources are obtained, including at least a length constraint, and each constraint is calculated iteratively. In this way, during the sequential calculation of the multiple constraints, the calculation order of the multiple constraints is adjusted so that the adjusted length constraint is calculated at the end of the calculation process. In other words, the calculation position of the original length constraint can be adjusted from the front to the back, thereby avoiding the defect of weak control over the length of the hair resource due to premature calculation of the length constraint. On the other hand, the constraint formula for the length constraint can be corrected. Specifically, the constraint formula for the length constraint is obtained and constraint parameters are added to the constraint formula. The constraint parameters are used to correct the length of the virtual character's hair resource after movement. Adding constraint parameters to the constraint formula of the length constraint is similar to adding a stiffness coefficient. This stiffness coefficient allows the length constraint to pull the length of the hair resource back as much as possible. For example, if the original distance between two mass points is 10 cm, the distance after correction is 9 cm. Of course, the stiffness coefficient values of different hair resources may be different.
[0121] ④ Regarding the problem of collision detection. It is understandable that as the virtual character moves, the hair resources of the virtual character will collide with objects in the virtual environment or objects of the virtual character itself (such as hair accessories). At this time, effective collision detection and correction under collision (that is, making the hair resources after the collision present a natural collision state) are conducive to improving the authenticity of the hair resources. In TressFx, collision detection and correction are mainly based on signed distance fields (SDF). SDF collision correction consists of two parts: showing that a signed distance field is established between the hair resources and the object to be collided, and then using the calculation results for the hair resources (such as the calculation results of the simulation calculation mentioned above) to perform collision detection and correction in this signed distance field. However, it has been found in practice that SDF is very energy-consuming, and the more hair resources there are, the more energy it consumes. Therefore, after integrating TressFx into the self-developed rendering engine, the embodiment of the present application abandons the SDF and solves the collision problem based on capsules. Among them, the basic idea of using capsules to solve collision problems is to find the closest point between two line segments (such as hair resources and the edge of the object to be collided that will collide with the hair resources), simplifying the collision problem into a collision of spheres.
[0122] (3) Optimization of the VSP calculation process.
[0123] Considering the high computational overhead of VSP in TressFx, the embodiment of the present application divides the particles of the hair resource into global particles (global vertex) and local particles (local vertex). The parameter value of the VSP of the global particles is set to 0, so no VSP calculation is required, while the local particles still undergo VSP calculation. By simplifying the VSP calculation of some particles in this way, some VSP calculations are effectively reduced, thereby reducing the VSP calculation overhead. The optimization ideas for the VSP calculation process mainly include: in the process of calculating the global motion parameter VSP of the hair resource set through the thread, obtaining the hair resources processed by the thread, and performing hair recognition processing on the hair resources to obtain the recognition results of the hair resources. The identification result is used to indicate whether the hair resource is a guide hair or a slave hair. The slave hair is obtained by offsetting the guide hair. Alternatively, the identification result is used to indicate whether the particle in the corresponding hair resource is a root particle or a non-root particle of the hair resource. The root particle and the attachment of the hair resource remain relatively fixed. In other words, first check whether the particle in the hair resource processed by the current thread is a root particle, or check whether the hair resource is a slave hair.
[0124] Then, if the recognition result indicates that the hair resource is a subordinate hair strand, or the recognition result indicates that the particle corresponding to the hair resource is a root particle of the hair resource, then the process returns directly, i.e., interrupting or omitting the processing of the current thread. Conversely, if the recognition result indicates that the hair resource is a subordinate hair strand, or the recognition result indicates that the particle corresponding to the hair resource is a non-root particle of the hair resource, then the process continues. Specifically, the parameters required for VSP calculation (including rotation quaternions, translation vectors and coefficients, etc.) are obtained, and the new and old positions of the current particle before and after the movement are obtained, and a check is made to see whether the z coordinate change of the current particle in the world space coordinate system is too large. If so, then the process returns directly, i.e., interrupting or omitting the processing of the current thread. If not, then the new and old positions of the current particle before and after the movement are saved in the fields HairVertexPositions and HairVertexPositionsPrev.
[0125] (4) Optimization of hair production.
[0126] The embodiment of the present application optimizes some of the original hair resource generation strategies in TressFx to improve hair production efficiency, help artists quickly create hair resources that meet the requirements, and ensure the quality and reliability of hair resources. For example, the embodiment of the present application can modify the generation strategy to avoid the problem of poor hair resource rendering effect caused by redundant overlapping rendering of hair. In one possible implementation, first, the number K of hair resources to be produced is obtained, where K is a positive integer. Then, the number K is divided into m generation groups, and k hair resources are generated in parallel in each generation group, and m*k≥K, m and k are positive integers; if m*k>K, then the excess m*kK hair resources are obtained from the mth generation group of the m generation groups. Finally, the m*kK hair resources are set to a hidden state, and the hidden state is used to indicate that the m*kK hair resources are hidden during rendering.
[0127] For example, TressFx supports GPU parallel processing, enabling the generation of k = 64 hair assets in parallel at a time. In practice, the number of hair assets is often not an integer of 64. For example, if the number of hair assets to be generated is K = 126, these 126 hair assets can be divided into two generation groups, each generating 64 hair assets. During the rendering process, all 64 hair assets generated by the first generation group can be rendered according to the rendering requirements of each hair asset (such as rendering position and direction). However, among the 64 hair assets generated by the second generation group, m*kK = 2 hair assets are redundant. In the original TressFx, these two redundant hair assets would be rendered overlappingly on the last hair asset in the 126 hair assets, resulting in visual artifacts such as blurring, darkening, or thicker width. The embodiment of the present application achieves the purpose of setting the two redundant hair resources to a hidden state by changing the display space of the two redundant hair resources, so that the two hair resources after setting are hidden during rendering, avoiding the unnatural appearance of the last hair resource.
[0128] In summary, on the one hand, the embodiments of the present application expand TressFx by adding world-space simulation. By applying the spatial change information of the virtual character moving from the first game scene to the second game scene on the static resource data of the hair resource, dynamic resource data of the hair resource in the second game scene can be obtained. Based on this dynamic resource data, the dynamic displacement of the hair resource as the virtual character moves can be more accurately controlled. This can more accurately simulate the influence of factors such as gravity, air resistance, and the displacement of the character itself on the hair resource during movement, making the hair resource more natural in terms of flowing, lateral movement, and fine hair dynamics, so that the hair resource in the game world closely simulates the movement performance of hair resources in the real world. On the other hand, the embodiments of the present application optimize some of the original solutions in TressFx, such as solving the problems of virtual ponytails easily rising, spreading, lacking drape, and stretching, thereby ensuring that the virtual ponytail can maintain its overall shape as the virtual character moves, and present a more realistic and natural movement performance.
[0129] The above describes in detail the method of the embodiment of the present application. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
[0130] FIG9 shows a schematic diagram of the structure of a resource processing device provided by an exemplary embodiment of the present application; the resource processing device can be used to perform some or all of the steps in the method embodiments shown in FIG3 or FIG7. Referring to FIG9, the resource processing device includes the following units:
[0131] The acquisition unit 901 is used to acquire spatial change information of the virtual character; the spatial change information is used to indicate the position change of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene;
[0132] The acquisition unit 901 is further configured to acquire static resource data of the hair resource of the virtual character in the second game scene; the static resource data is used to reflect the static characteristics of the hair resource of the virtual character when the virtual character is static in the second game scene;
[0133] The processing unit 902 is configured to obtain dynamic resource data of the hair resource in the second game scene based on the static resource data and the spatial change information; the dynamic resource data is configured to reflect the dynamic characteristics of the hair resource moving with the movement of the virtual character;
[0134] The processing unit 902 is also used to perform physical simulation on the hair resource based on the dynamic resource data; the physical simulation is used to control the hair resource to simulate the movement performance in the real world when the virtual character moves from the first game scene to the second game scene.
[0135] In one implementation, one game scene corresponds to one image frame, and the image frame is used to describe the game scene from an image dimension. When the acquisition unit 901 is used to acquire the spatial change information of the virtual character, it is specifically used to:
[0136] Obtaining a first image frame corresponding to the first game scene, and calculating first spatial position information of the virtual character in the first image frame in a world space coordinate system;
[0137] and obtaining a second image frame corresponding to the second game scene, and calculating second spatial position information of the virtual character in the second image frame in the world space coordinate system;
[0138] Based on the first spatial position information and the second spatial position information, spatial change information of the virtual character is calculated.
[0139] In one implementation, the spatial change information includes displacement information and rotation information; the dynamic resource data of the hair resource in the second game scene includes dynamic position information and dynamic direction information; and the processing unit 902 is configured to obtain the dynamic resource data of the hair resource in the second game scene based on the static resource data and the spatial change information, specifically for:
[0140] Determining static position information of the hair resource in the second game scene from the static resource data, and determining dynamic position information of the hair resource in the second game scene based on the static position information and displacement information in the spatial change information;
[0141] Static direction information of the hair resource in the second game scene is determined from the static resource data, and dynamic direction information of the hair resource in the second game scene is determined based on the static direction information and rotation information in the spatial change information.
[0142] In one implementation, the processing unit 902, when performing physical simulation on the hair resource based on the dynamic resource data, is specifically configured to:
[0143] Obtaining one or more constraints imposed on the virtual character during movement from the first game scene to the second game scene; the constraints comprising at least one of the following: gravity constraint, length constraint, and resistance constraint;
[0144] Based on one or more constraints and dynamic resource data, the root particle of the hair resource is physically simulated; the hair resource is a virtual hair composed of multiple chain-like particle points, and the root particle points refer to two adjacent particle points in the hair resource attached to the attachment body.
[0145] In one implementation, the processing unit 902 is further configured to:
[0146] Acquiring motion information of the virtual character, the motion information including at least one of the following: displacement distance, displacement direction, and speed information;
[0147] If it is detected based on the motion information that the spatial change information needs to be optimized, the spatial change information is optimized according to the motion information to obtain optimized spatial change information; wherein, if the displacement distance is greater than the displacement distance threshold, the spatial change information needs to be optimized; or, if the displacement distance is less than or equal to the displacement distance threshold, and the displacement direction indicates that the movement direction of the virtual character in the first game scene is different from the movement direction in the second game scene, and the speed information indicates that the speed of the virtual character is greater than the speed threshold, then the spatial change information needs to be optimized;
[0148] The processing unit 902 is configured to obtain dynamic resource data of the hair resource in the second game scene based on the static resource data and the spatial change information, specifically to:
[0149] Based on the static resource data and the optimized spatial change information, dynamic resource data of the hair resource in the second game scene is obtained.
[0150] In one implementation, the processing unit 902 is configured to optimize the spatial variation information according to the motion information, and when obtaining the optimized spatial variation information, specifically to:
[0151] Obtaining a motion threshold corresponding to the motion information;
[0152] Adding constraints to the virtual character based on the difference between the motion information and the motion threshold;
[0153] The spatial variation information is optimized based on the constraint conditions to obtain the optimized spatial variation information.
[0154] In one implementation, a hair resource refers to a virtual hair attached to a virtual character; the virtual hair is composed of multiple hair segments connected in a chain, and each hair segment is composed of two mass points connected by a virtual spring.
[0155] In one implementation, the processing unit 902 is further configured to:
[0156] Acquire multiple constraints for the hair resource of the virtual character; the multiple constraints include at least a length constraint; the length constraint is used to control the length of the hair resource to remain unchanged during the movement of the virtual character;
[0157] In the process of sequentially calculating multiple constraint conditions, the calculation order of the multiple constraint conditions is adjusted so that the adjusted length constraint is at the end of the calculation process;
[0158] Also, a constraint formula for the length constraint is obtained, and constraint parameters are added to the constraint formula; the constraint parameters are used to correct the length of the hair resource of the virtual character after movement.
[0159] In one implementation, the processing unit 902 is further configured to:
[0160] Obtaining a local shape constraint of the hair resource set, and updating the local shape constraint using a first recognition coefficient;
[0161] Using the updated local shape constraint to identify the hair resource set, a first hair set in the hair resource set is obtained; the hair spread probability of the hair resources in the first hair set is greater than a preset threshold;
[0162] Constraint processing is performed on each hair resource in the first hair set to obtain a constrained hair set, where the hair spread probability of each hair resource in the constrained hair set is less than or equal to a preset threshold.
[0163] In one implementation, the particles in the hair resource are set with elastic properties; the processing unit 902 is further configured to:
[0164] Obtaining a local shape constraint of the hair resource set, and updating the local shape constraint using a second recognition coefficient;
[0165] Using the updated local shape constraint to identify the hair resource set, a second hair set in the hair resource set is obtained; the second hair set is a root resource set or a tail resource set of the hair resource set;
[0166] Obtaining the acceleration of the mass point of the hair resource in the second hair set;
[0167] If the acceleration is greater than the acceleration threshold, the property value of the elastic property is determined for the particle based on the acceleration;
[0168] Obtaining the global motion parameters of the hair resource collection, and performing weighted processing on the global motion parameters using the attribute values to obtain a weighted processing result;
[0169] The weighted processing result is determined as the particle motion parameter of the particle of the hair resource in the second hair set; the particle motion parameter is used to control the motion effect of the particle.
[0170] In one implementation, the processing unit 902 is further configured to:
[0171] During the process of calculating the global motion parameters of the hair resource set through the thread, the hair resource processed by the thread is obtained, and hair recognition processing is performed on the hair resource to obtain a recognition result of the hair resource; the recognition result is used to indicate whether the hair resource is a guide hair strand or a slave hair strand, where the slave hair strand is obtained by offsetting the guide hair strand; or the recognition result is used to indicate whether a particle corresponding to the hair resource is a root particle or a non-root particle of the hair resource, where the root particle remains relatively fixed to the attachment body of the hair resource;
[0172] If the identification result indicates that the hair resource is a subordinate hair strand, or if the identification result indicates that the particle corresponding to the hair resource is a root particle of the hair resource, then the thread processing is interrupted;
[0173] If the recognition result indicates that the hair resource is a guide hair, or if the recognition result indicates that the particle corresponding to the hair resource is a non-root particle of the hair resource, the thread processing continues.
[0174] In one implementation, the processing unit 902 is further configured to:
[0175] Get the number K of hair resources to be produced; K is a positive integer;
[0176] Divide the quantity K into m generation groups, generate k hair resources in parallel in each generation group, and m*k≥K; m and k are positive integers;
[0177] If m*k>K, then obtain m*kK hair resources from the mth generation group among the m generation groups;
[0178] Set the m*kK hair resources to a hidden state, where the hidden state is used to indicate that the m*kK hair resources are hidden during rendering.
[0179] In one implementation, the processing unit 902 is further configured to:
[0180] Get the parameter group required to draw hair resources, which includes multiple parameters;
[0181] Perform correlation analysis on multiple parameters in the parameter group to obtain the correlation relationship between the parameters in the parameter group;
[0182] The parameter value of each parameter in the virtual world is determined according to the parameter value of each parameter in the real world and the correlation relationship between the parameters.
[0183] According to one embodiment of the present application, the various units in the resource processing device shown in Figure 9 can be separately or completely merged into one or several other units to constitute, or one (some) of the units can be further divided into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the resource processing device can also include other units. In practical applications, these functions can also be implemented with the assistance of other units and can be implemented by the collaboration of multiple units. According to another embodiment of the present application, a computer program (including program code) capable of executing the steps involved in the corresponding methods shown in Figures 3 and 7 can be run on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM). To construct a resource processing device as shown in Figure 9 and to implement the resource processing method of the embodiment of the present application. The computer program can be recorded on, for example, a computer-readable recording medium, loaded into the above-mentioned computing device via the computer-readable recording medium, and executed therein.
[0184] In an embodiment of the present application, spatial change information of a virtual character in a world space coordinate system can be obtained when the virtual character moves from a first game scene to a second game scene. This spatial change information reflects the position change of the virtual character in the world space. Then, support is provided for applying the spatial change information to the static resource data of the virtual character's hair resource in the second game scene to obtain dynamic resource data of the hair resource in the second game scene. The static resource data is used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene, while the dynamic resource data is used to reflect the dynamic characteristics of the hair resource as it moves with the movement of the virtual character. Finally, a physical simulation of the hair resource can be performed based on the dynamic resource data of the hair resource. This physical simulation can enable the hair resource to simulate the movement performance in the real world during the process of the virtual character moving from the first game scene to the second game scene. It can be seen that the embodiment of the present application adds world space simulation to TressFx. By applying the spatial change information when the virtual character moves from the first game scene to the second game scene to the static resource data of the hair resource, the dynamic resource data of the hair resource in the second game scene can be obtained. Based on the dynamic resource data, the hair resource can be more accurately controlled to dynamically offset as the virtual character moves, so that the hair resources in the game world simulate and restore the movement performance of the hair resources in the real world as much as possible, thereby improving the naturalness and realism of the hair resources in the game scene where the virtual character moves.
[0185] Figure 10 shows a schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application. Referring to Figure 10, the computer device includes a processor 1001, a communication interface 1002 and a computer-readable storage medium 1003. The processor 1001, the communication interface 1002 and the computer-readable storage medium 1003 can be connected via a bus or other means. The communication interface 1002 is used to receive and send data. The computer-readable storage medium 1003 can be stored in the memory of the computer device, and the computer-readable storage medium 1003 is used to store a computer program. The computer program includes program instructions, and the processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1003. The processor 1001 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function.
[0186] The embodiment of the present application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the processing system of the computer device. In addition, one or more instructions suitable for being loaded and executed by the processor 1001 are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory; optionally, it can also be at least one computer-readable storage medium located away from the aforementioned processor.
[0187] In one embodiment, one or more instructions are stored in the computer-readable storage medium; the processor 1001 loads and executes the one or more instructions stored in the computer-readable storage medium to implement the corresponding steps in the above-mentioned resource processing method embodiment; in a specific implementation, the one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and execute the various methods introduced in the above-mentioned embodiments.
[0188] Based on the same inventive concept, the principles and beneficial effects of solving problems by the computer device provided in the embodiment of the present application are similar to the principles and beneficial effects of solving problems by the resource processing method in the method embodiment of the present application. Please refer to the principles and beneficial effects of the implementation of the method. For the sake of concise description, they will not be repeated here.
[0189] The present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the terminal to execute the resource processing method.
[0190] Those skilled in the art will appreciate that the units and algorithmic steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0191] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted via a computer-readable storage medium. The computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD) or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0192] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any technical object of a person skilled in the art that is within the technical scope disclosed in the present application and that can be easily conceived of by a person skilled in the art is within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.
Claims
1. A resource processing method, the method being executed by a computer device, comprising: Obtaining spatial change information of the virtual character; The space change information is used to indicate the position change of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene; Acquire static resource data of the hair resource of the virtual character in the second game scene; The static resource data is used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene; Based on the static resource data and the spatial change information, dynamic resource data of the hair resource in the second game scene is obtained; The dynamic resource data is used to reflect the dynamic characteristics of the hair resource moving along with the movement of the virtual character; Performing physical simulation on the hair resource based on the dynamic resource data; The physical simulation is used to control the hair resource to simulate the movement performance in the real world during the movement of the virtual character from the first game scene to the second game scene.
2. The method according to claim 1, wherein one game scene corresponds to one image frame, and the image frame is used to describe the game scene from an image dimension; The obtaining of the spatial change information of the virtual character includes: Acquire a first image frame corresponding to a first game scene, and calculate first spatial position information of a virtual character in the first image frame in a world space coordinate system; And, obtaining a second image frame corresponding to a second game scene, and calculating second spatial position information of the virtual character in the second image frame in the world space coordinate system; Based on the first spatial position information and the second spatial position information, spatial change information of the virtual character is calculated.
3. The method according to claim 1, wherein the spatial change information includes displacement information and rotation information; the dynamic resource data of the hair resource in the second game scene includes dynamic position information and dynamic direction information; The obtaining, based on the static resource data and the spatial change information, dynamic resource data of the hair resource in the second game scene comprises: Determine static position information of the hair resource in the second game scene from the static resource data, and determine dynamic position information of the hair resource in the second game scene based on the static position information and the displacement information in the spatial change information; Static direction information of the hair resource in the second game scene is determined from the static resource data, and dynamic direction information of the hair resource in the second game scene is determined based on the static direction information and the rotation information in the spatial change information.
4. The method according to claim 1, wherein the physically simulating the hair resource based on the dynamic resource data comprises: Acquire one or more constraints to which the virtual character is subject during the process of moving from the first game scene to the second game scene; The constraint condition includes at least one of the following: gravity constraint, length constraint and resistance constraint; Based on the one or more constraints and the dynamic resource data, a physical simulation is performed on the root particles of the hair resource; the hair resource is a virtual hair composed of a plurality of chain particles, and the root particles refer to two adjacent particles in the hair resource attached to an attachment.
5. The method according to any one of claims 1 to 4, further comprising: Acquiring movement information of the virtual character, the movement information including at least one of the following: displacement distance, displacement direction and speed information; If it is detected based on the motion information that the spatial change information needs to be optimized, the spatial change information is optimized according to the motion information to obtain the optimized spatial change information; wherein, if the displacement distance is greater than a displacement distance threshold, the spatial change information needs to be optimized; or, if the displacement distance is less than or equal to the displacement distance threshold, and the displacement direction indicates that the movement direction of the virtual character in the first game scene is different from the movement direction in the second game scene, and the speed information indicates that the speed of the virtual character is greater than a speed threshold, then the spatial change information needs to be optimized; The obtaining, based on the static resource data and the spatial change information, dynamic resource data of the hair resource in the second game scene comprises: Based on the static resource data and the optimized spatial change information, dynamic resource data of the hair resource in the second game scene is obtained.
6. The method according to claim 5, wherein the step of optimizing the spatial variation information according to the motion information to obtain the optimized spatial variation information comprises: Acquire a motion threshold corresponding to the motion information; adding a constraint condition to the virtual character according to difference information between the motion information and the motion threshold; The spatial variation information is optimized based on the constraint condition to obtain the optimized spatial variation information.
7. The method according to claim 1, wherein the hair resource is a virtual hair attached to the virtual character; the virtual hair is composed of a plurality of hair segments connected in a chain manner, and each hair segment is composed of two mass points connected by a virtual spring; The hair resource set composed of a plurality of the hair resources presents a fixed shape.
8. The method of claim 7, further comprising: Acquire multiple constraints for the hair resource of the virtual character; The plurality of constraints include at least a length constraint; The length constraint is used to control the length of the hair resource to remain unchanged during the movement of the virtual character; In the process of sequentially calculating the plurality of constraint conditions, adjusting the calculation order of the plurality of constraint conditions so that the adjusted length constraint is at the tail calculation position in the calculation process; And, obtaining the constraint formula of the length constraint, and adding constraint parameters to the constraint formula; the constraint parameters are used to correct the length of the hair resource of the virtual character after movement.
9. The method of claim 7, further comprising: Acquire a local shape constraint of the hair resource set, and update the local shape constraint using a first recognition coefficient; The hair resource set is identified and processed by using the updated local shape constraint to obtain a first hair set in the hair resource set; the hair spreading probability of the hair resources in the first hair set is greater than a preset threshold; Constraint processing is performed on each hair resource in the first hair set to obtain a constrained hair set, wherein the hair spreading possibility of each hair resource in the constrained hair set is less than or equal to the preset threshold.
10. The method according to claim 7, wherein the particles in the hair resource are provided with elastic properties; the method further comprising: Acquire a local shape constraint of the hair resource set, and update the local shape constraint using a second recognition coefficient; Using the updated local shape constraint to identify the hair resource set, to obtain a second hair set in the hair resource set; the second hair set is a root resource set or a tail resource set of the hair resource set; Obtaining the acceleration of the particle of the hair resource in the second hair set; If the acceleration is greater than the acceleration threshold, determining a property value of an elastic property for the particle according to the acceleration; Acquire the global motion parameter of the hair resource set, and perform weighted processing on the global motion parameter using the attribute value to obtain a weighted processing result; The weighted processing result is determined as the particle motion parameter of the particle of the hair resource in the second hair set; the particle motion parameter is used to control the motion effect of the particle.
11. The method of claim 7, further comprising: In the process of calculating the global motion parameters of the hair resource set through the thread, the hair resource processed by the thread is obtained, and the hair resource is subjected to hair recognition processing to obtain the recognition result of the hair resource; the recognition result is used to indicate that the hair resource is a guide hair strand or a subordinate hair strand, and the subordinate hair strand is obtained by offsetting the guide hair strand; or the recognition result is used to indicate that the particle point corresponding to the hair resource is a root particle point or a non-root particle point of the hair resource, and the root particle point and the attachment body of the hair resource remain relatively fixed; If the recognition result indicates that the hair resource is the subordinate hair strand, or the recognition result indicates that the particle point corresponding to the hair resource is the root particle point of the hair resource, interrupting the processing of the thread; If the recognition result indicates that the hair resource is the guide hair, or if the recognition result indicates that the particle corresponding to the hair resource is a non-root particle of the hair resource, the processing of the thread continues.
12. The method of claim 1, further comprising: Get the number K of hair resources to be produced; K is a positive integer; The number K is divided into m generation groups, k hair resources are generated in parallel in each generation group, and m*k≥K; m and k are positive integers; If m*k>K, then obtain m*kK hair resources from the mth generation group among the m generation groups; The m*kK hair resources are set to a hidden state, where the hidden state is used to indicate that the m*kK hair resources are hidden during rendering.
13. The method of claim 1, further comprising: Acquire a parameter group required for drawing the hair resource, wherein the parameter group includes a plurality of parameters; Performing correlation analysis on the multiple parameters in the parameter group to obtain correlation relationships between the parameters in the parameter group; The parameter values of the parameters in the virtual world are determined according to the parameter values of the parameters in the real world and the association relationship between the parameters.
14. A resource processing device, the device being deployed on a computer device, comprising: An acquisition unit, used for acquiring spatial change information of a virtual character; The space change information is used to indicate the position change of the virtual character in the world space coordinate system when the virtual character moves from the first game scene to the second game scene; The acquisition unit is further used to acquire static resource data of the hair resource of the virtual character in the second game scene; the static resource data is used to reflect the static characteristics of the hair resource when the virtual character is static in the second game scene; A processing unit, configured to obtain dynamic resource data of the hair resource in the second game scene based on the static resource data and the spatial change information; The dynamic resource data is used to reflect the dynamic characteristics of the hair resource moving along with the movement of the virtual character; The processing unit is further used to perform physical simulation on the hair resource based on the dynamic resource data; the physical simulation is used to control the hair resource to simulate the movement performance in the real world during the movement of the virtual character from the first game scene to the second game scene.
15. A computer device comprising: a processor adapted to execute a computer program; A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the resource processing method according to any one of claims 1 to 13 is implemented.
16. A computer-readable storage medium storing a computer program, wherein the computer program is suitable for being loaded by a processor and executing the resource processing method according to any one of claims 1 to 13.
17. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the resource processing method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Virtual object hair treatment method and device, storage medium and electronic equipment
CN107221024A
Hair movement simulation method and device, electronic device and storage medium
CN110264552A
Hair rendering method, device and equipment for virtual object
CN114119821A
Hair treatment method, device and equipment for virtual object, medium and program product
CN115641375A
Hair treatment method and device for digital virtual object and storage medium
CN116258801A
