Method and device for physically simulating cloth in a virtual scene

By receiving constraint information between cloth vertices and simulation environment information in a virtual scene, and using GPU for iterative calculation, the "clipping" problem of traditional mass-spring systems in complex cloth simulation is solved, achieving more stable and realistic cloth performance and interaction, and improving calculation speed.

CN115423910BActive Publication Date: 2026-04-28ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
Filing Date
2022-08-23
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

When simulating complex multi-layered fabrics and interactions with complex environments, existing technologies often struggle to calculate accurate convergence results using traditional point-spring systems, leading to "clipping" issues and reducing the realism of characters in 3D games.

Method used

By receiving constraint information between cloth vertices and simulation environment information, it uses a graphics processor to perform iterative calculations. It combines the constraint information between cloth vertices and simulation environment information to perform simulated calculations of the cloth, providing rich interaction between the cloth and the environment. It also uses a GPU for iterative calculations to improve the calculation speed.

Benefits of technology

Stable simulation of complex multi-layered fabrics was achieved, improving the realism and richness of the interaction between the fabric and the environment, reducing the "clipping" phenomenon, and significantly improving the calculation speed through GPU calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115423910B_ABST
    Figure CN115423910B_ABST
Patent Text Reader

Abstract

The application provides a physical simulation method and device for cloth in a virtual scene, wherein the physical simulation method for cloth in a virtual scene comprises the following steps: receiving a simulation instruction for a target cloth in a virtual scene; loading an initial cloth object corresponding to the target cloth in response to the simulation instruction, wherein the initial cloth object comprises constraint information between cloth vertices; receiving simulation environment information for the target cloth; performing simulation calculation of the target cloth according to the simulation environment information and the initial cloth object based on the constraint information between the cloth vertices, to obtain a target cloth object; and rendering the target cloth object in the virtual scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of physical simulation technology, and in particular to a method for physically simulating cloth in a virtual scene. This application also relates to an apparatus for physically simulating cloth in a virtual scene, a computing device, and a computer-readable storage medium. Background Technology

[0002] With the development of 3D virtual scene physics simulation technology, users have higher requirements for the realism of characters in virtual scenes. Among them, the physics simulation of clothing and fabric of virtual characters is crucial to improving the overall realism of the characters.

[0003] Currently, the mainstream approach to physics-based cloth simulation is based on the mass-spring system method. This method treats the cloth as a set of vertices and edges, and uses linear integrals of the elastic system to calculate the simulation results. While this method is relatively easy to implement and suitable for simulating simple single-layer cloth structures, it struggles to calculate accurate convergence results when dealing with complex multi-layer cloth structures and interactions with complex environments. This is due to the numerous self-collisions between the cloth elements, leading to noticeable clipping issues that significantly reduce the overall realism of characters in 3D games. Summary of the Invention

[0004] In view of this, embodiments of this application provide a method for physically simulating cloth in a virtual scene. This application also relates to an apparatus for physically simulating cloth in a virtual scene, a computing device, and a computer-readable storage medium, to solve the aforementioned problems existing in the prior art.

[0005] According to a first aspect of the embodiments of this application, a method for physically simulating cloth in a virtual scene is provided, comprising:

[0006] Receive simulation commands for the target cloth in the virtual scene;

[0007] In response to the simulation command, an initial cloth object corresponding to the target cloth is loaded, wherein the initial cloth object includes constraint information between cloth vertices;

[0008] Receive simulated environmental information for the target fabric;

[0009] Based on the constraint information between the cloth vertices, the target cloth is simulated and calculated according to the simulation environment information and the initial cloth object to obtain the target cloth object;

[0010] The target cloth object is rendered in the virtual scene.

[0011] Optionally, loading the initial fabric object corresponding to the target fabric includes:

[0012] Determine whether the initial fabric data corresponding to the target fabric is stored;

[0013] If so, load the initial fabric object based on the initial fabric data;

[0014] If not, read the fabric resource information of the target fabric, generate initial fabric data based on the fabric resource information, and load the initial fabric object based on the initial fabric data.

[0015] Optionally, read the fabric resource information of the target fabric and generate initial fabric data based on the fabric resource information, including:

[0016] Read the vertex color information and vertex physical attribute information of the target cloth;

[0017] Obtain the constraint information between the vertices of the target cloth based on the vertex color information;

[0018] Initial cloth data is generated based on the vertex physical attribute information and the constraint information between cloth vertices.

[0019] Optionally, reading the vertex color information of the target fabric includes:

[0020] Read the red channel data, green channel data, and blue channel data from the color channels.

[0021] Optionally, constraint information between fabric vertices is obtained based on the vertex color information of the target fabric, including:

[0022] Based on the red channel data, the green channel data, and the blue channel data, spring constraint information, tether constraint information, and rigid body constraint information between the fabric vertices are generated.

[0023] Optionally, receive simulation environment information for the target cloth in the virtual scene, including:

[0024] Receive at least one of the following for a target cloth in a virtual scene: character collision information, environment collision information, and cloth update information.

[0025] Optionally, based on the constraint information between the cloth vertices, and according to the simulation environment information and the initial cloth object, the simulation calculation of the target cloth is performed, including:

[0026] Create an initial scene simulation cache array;

[0027] Add the constraint information between cloth vertices, the simulation environment information, and the initial cloth object to the initial scene simulation cache array;

[0028] The initial scene simulation cache array is input into the graphics processor's solver for iterative calculation.

[0029] Optionally, the method further includes:

[0030] Receive a destruction command for the target fabric object;

[0031] The target cloth object in the virtual scene is destroyed in response to the destruction command.

[0032] According to a second aspect of the embodiments of this application, a physical simulation device for cloth in a virtual scene is provided, comprising:

[0033] The instruction receiving module is configured to receive simulated instructions for the target cloth in the virtual scene;

[0034] The loading module is configured to load an initial cloth object corresponding to the target cloth in response to the simulation command, wherein the initial cloth object includes constraint information between cloth vertices;

[0035] The information receiving module is configured to receive simulated environmental information for the target fabric;

[0036] The simulation module is configured to perform simulation calculations on the target cloth based on the constraint information between the cloth vertices, the simulation environment information, and the initial cloth object, to obtain the target cloth object;

[0037] The rendering module is configured to render the target cloth object in the virtual scene.

[0038] According to a third aspect of the present application, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the computer instructions to implement the steps of a physical simulation method for cloth in a virtual scene.

[0039] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer instructions, which, when executed by a processor, implement the steps of a method for physically simulating cloth in a virtual scene.

[0040] The physical simulation method for cloth in a virtual scene provided in this application includes receiving a simulation instruction for a target cloth in the virtual scene; loading an initial cloth object corresponding to the target cloth in response to the simulation instruction, wherein the initial cloth object includes constraint information between cloth vertices; receiving simulation environment information for the target cloth; performing simulation calculations on the target cloth based on the constraint information between cloth vertices, according to the simulation environment information and the initial cloth object, to obtain the target cloth object; and rendering the target cloth object in the virtual scene.

[0041] One embodiment of this application implements the simulation of cloth by solving the constraint information between cloth vertices. Compared with the traditional simulation method based on mass-spring system, the cloth behavior is richer, more stable when handling complex multi-layered cloth, and less prone to clipping. At the same time, the method provided by this application provides the influence of simulation environment information on the cloth, making the interaction between the cloth and the environment richer and more diverse. Depending on the surrounding environment, the cloth will also have different interactive behaviors, which greatly improves the realism of the cloth physics simulation.

[0042] Secondly, the method provided in this application introduces a graphics processing unit (GPU) for iterative calculation, which greatly improves the calculation speed compared to traditional central processing unit (CPU) calculation. It also provides comprehensive visual art tools, allowing users to easily perform custom editing of cloth and supporting WYSIWYG real-time simulation functionality. Attached Figure Description

[0043] Figure 1 This is a flowchart illustrating a physical simulation method for cloth in a virtual scene according to an embodiment of this application;

[0044] Figure 2 This is a flowchart illustrating a physical simulation method for cloth in a virtual scene applied to a game scenario, provided by an embodiment of this application.

[0045] Figure 3 This is a schematic diagram of the structure of a physical simulation device for cloth in a virtual scene provided in one embodiment of this application;

[0046] Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation

[0047] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0048] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.

[0049] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0050] With the development of 3D game physics simulation technology, users have increasingly higher demands for the realism of game characters. Among these demands, the physics simulation of clothing fabric is crucial for enhancing the overall realism of the character. Currently, the mainstream approach to physics-based cloth simulation is based on the "mass-spring system" method. This method treats the cloth as a set of vertices and edges, using linear integrals of the elastic system to calculate the mesh simulation results. This method is relatively easy to implement and suitable for simulating simple single-layer cloth structures. However, when dealing with complex multi-layer cloth structures and interactions with complex environments, the traditional mass-spring system struggles to calculate accurate convergence results due to numerous self-collisions between the cloth layers. This leads to noticeable "clipping" problems, which significantly reduce the overall realism of characters in 3D games.

[0051] Based on this, this application provides a method for physically simulating cloth in a virtual scene. This application also relates to a device for physically simulating cloth in a virtual scene, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.

[0052] Figure 1 The flowchart illustrates a physical simulation method for cloth in a virtual scene according to an embodiment of this application, specifically including the following steps:

[0053] Step 102: Receive simulation instructions for the target cloth in the virtual scene.

[0054] With the development of computer technology, there is an increasing need to simulate and generate clothing for virtual characters in virtual scenarios, such as game scenes, animation scenes, virtual live streaming scenes, etc. This application does not limit the definition of virtual scenarios.

[0055] The target fabric specifically refers to the fabric simulated and generated in the virtual scene. This fabric can be the clothing of a virtual character or a separate piece of fabric. For example, in a game scene, if clothing is generated for a game character, then the clothing can be the target fabric. Similarly, in an animation scene, there are scenes of clothes drying or dyeing workshops, and the clothes and dyed fabric can also be regarded as target fabric. In this application, the specific content of the target fabric is not limited.

[0056] The simulation command specifically refers to the command to physically simulate the target cloth in a virtual scene. The method provided in this application is applied to a terminal, which can be a desktop computer, laptop computer, tablet computer, smart mobile terminal, etc. The simulation command can be issued directly by the user, or it can be issued by other applications controlled by the user.

[0057] Step 104: In response to the simulation command, load the initial cloth object corresponding to the target cloth, wherein the initial cloth object includes constraint information between cloth vertices.

[0058] The initial cloth object specifically refers to the data carrier generated in advance based on the cloth data corresponding to the target cloth. The initial cloth object includes the vertex rendering information of the cloth, the physical attribute data of each vertex in the cloth, and the constraint information between the vertices in the cloth.

[0059] Specifically, the constraint information between fabric vertices refers to the constraint relationship between each fabric vertex and its neighboring fabric vertices in the target fabric, such as the movement information, stiffness information, deformation information, etc. between vertices.

[0060] In practical applications, the initial cloth object may be pre-generated and stored in the terminal, or it may be generated based on simulation instructions. The initial cloth object is generated based on the initial cloth data and then loaded. Specifically, loading the initial cloth object corresponding to the target cloth includes:

[0061] Determine whether the initial fabric data corresponding to the target fabric is stored;

[0062] If so, load the initial fabric object based on the initial fabric data;

[0063] If not, read the fabric resource information of the target fabric, generate initial fabric data based on the fabric resource information, and load the initial fabric object based on the initial fabric data.

[0064] In practical applications, loading the initial cloth object requires pre-reading the color information corresponding to the cloth from the target model file of the virtual scene. This color information is used to generate the cloth. The target model specifically refers to the 3D model used for loading the cloth, which can be a virtual character. The color information includes four color channels: red, green, blue, and transparency. The transparency channel data needs to be converted to a 32-bit floating-point number using Power exponentiation to determine the quality of the cloth.

[0065] The vertex data, topology information, and skeletal skinning information of the target model are then formatted and stored in the MeshBuffer data structure for subsequent rendering to generate cloth.

[0066] At this point, it is determined whether the initial fabric data corresponding to the target fabric is pre-saved in the terminal. The initial fabric data is pre-built and generated based on the fabric information resources. If the initial fabric data is pre-saved in the terminal, the initial fabric data can be read from the fabric file used to save the initial fabric data, and the initial fabric object can be loaded and generated based on the initial fabric data.

[0067] If the initial fabric data is not saved in the terminal, it is necessary to obtain the fabric resource information of the target fabric, generate the initial fabric data based on the fabric resource information, and then load the initial fabric object based on the initial fabric data.

[0068] Specifically, the process involves reading the fabric resource information of the target fabric and generating initial fabric data based on the fabric resource information, including:

[0069] Read the vertex color information and vertex physical attribute information of the target cloth;

[0070] Obtain the constraint information between the vertices of the target cloth based on the vertex color information;

[0071] Initial cloth data is generated based on the vertex physical attribute information and the constraint information between cloth vertices.

[0072] In practical applications, technicians will pre-generate the art resources of the cloth, that is, the cloth resource information of the target cloth. Specifically, technicians will use the vertex brush tool provided in this application to edit the vertex colors of the target model, which are divided into vertex color information and vertex physical attribute information.

[0073] Vertex color information is stored in the red, green, blue and opacity channels, respectively, with each channel storing different data required for cloth generation.

[0074] Specifically, reading the vertex color information of the target fabric includes:

[0075] Read the red channel data, green channel data, and blue channel data from the color channels.

[0076] Specifically, color channel data is stored in the diffuse color map of the target model. Each color channel occupies 8 bytes of data, represented by decimal 0-255. The meaning of each color channel data includes:

[0077] 1. Red Channel: This channel stores the maximum movement range of the cloth vertex relative to the skin vertex. It limits the movement range of the vertex in the X, Y, and Z axes of space, with a value of 0-255 in centimeters. When the value is 0, it means that the skin controls the movement completely. When the value is 255, it means that the cloth controls the movement completely. When the value is between 0 and 255, the movement is controlled by the cooperation of the skin and the cloth.

[0078] 2. Green Channel: This channel stores information related to cloth particle groups. Its values ​​are as follows: 0-49 indicates particle follow-movement, meaning the particle will follow the corresponding particle; 50-99 indicates vertex merging, meaning the following point will merge with the corresponding point into a single particle; 100-149 indicates anchor point function, ensuring that hard ornaments on the cloth will maintain their original shape without deformation; 150-199 indicates collision group differentiation, allowing multiple layers of cloth to force collisions; 254 is a special value that forces invisible cloth completely inside multiple layers not to be drawn.

[0079] 3. Blue channel: This channel represents the stiffness of the fabric. 0 is the stiffest (no deformation at all), and 255 is the softest (default value). The smaller the value, the stiffer the fabric, and the larger the value, the softer the fabric.

[0080] 4. Transparency channel: This channel records the fabric's quality information.

[0081] Technicians also need to create vertex physical property information, which includes the fabric subdivision level, smoothness coefficient, elasticity information, and so on.

[0082] Accordingly, constraint information between fabric vertices is obtained based on the vertex color information of the target fabric, including:

[0083] Based on the red channel data, the green channel data, and the blue channel data, spring constraint information, tether constraint information, and rigid body constraint information between the fabric vertices are generated.

[0084] After obtaining the red channel data, green channel data, and blue channel data, the spring constraint information, rope constraint information, and rigid body constraint information between the fabric vertices can be generated.

[0085] The following is a further explanation of how to generate the initial fabric data:

[0086] Based on the topological structure information of the vertices generated in the above steps and stored in the MeshBuffer, the adjacency data information of the vertices is generated, and the adjacency data information of each vertex is stored in a two-dimensional array.

[0087] Based on the adjacency data between vertices mentioned above, vertex index information at the boundary between cloth and non-cloth areas is generated for subsequent processing.

[0088] The MeshBuffer data is further subdivided based on the subdivision level in the vertex physical attribute information. The data that needs to be subdivided includes vertex position, normal, tangent, UV coordinates, mesh index, color channel information, subset information, boundary vertex information, etc.

[0089] Cloth object data is constructed based on the subdivided MeshBuffer data. Spatial information of the vertices is generated from the cloth object data and placed in a 3D array for subsequent accelerated calculations. Simultaneously, a mapping relationship between model vertices and cloth particles is generated based on the cloth object data and the green channel data from the subdivided color channels.

[0090] Based on the mapping relationship between vertices and cloth particles, generate mapped cloth particle index data. Based on the cloth particle index data, generate vertex adjacency data and save it to a two-dimensional array.

[0091] Based on the green channel information from the subdivided color channels, the grouping and following information of the cloth particles are generated. At the same time, based on the green channel data, the phase parameters of the particles are generated. Each independent cloth object will have a randomly generated phase base, which is mixed with the particle grouping to obtain the final phase value.

[0092] Based on the subdivided mesh index and boundary vertex information, vertex index information for rendering is generated.

[0093] Based on the subdivided vertex normals and tangents, the initial cloth normals and tangents are generated.

[0094] Mesh element information is generated based on the adjacency data of the vertices mentioned above, which is used to determine the connected regions of the cloth.

[0095] Rigid body constraint information between particles is generated based on the green and blue channel data from the subdivided color channel data. This rigid body constraint information is used to represent the following motion and stiffness of the fabric.

[0096] Based on the smoothing coefficient information in the vertex physical attribute information, the appearance of the connection between cloth and non-cloth is smoothed.

[0097] Based on the fabric object data mentioned above, spring constraint information between fabric particles is generated. This spring constraint information is used to reflect the stretching and bending behavior of the fabric.

[0098] Based on the fabric elasticity information in the vertex physical property information, the tether constraint information of the fabric is generated to limit the excessive stretching of the fabric.

[0099] The generated initial cloth data is serialized and stored in a disk file. The initial cloth data includes: vertex topology information, vertex adjacency data information, vertex index information at the boundary between cloth and non-cloth, vertex spatial information, mapping relationship between model vertices and cloth particles, cloth particle index data, vertex index information, cloth normal and tangent data, mesh element information, rigid body constraint information, smoothing coefficient information, spring constraint information, tether constraint information, etc.

[0100] After obtaining the initial fabric data, the initial fabric object can be loaded based on the initial fabric data.

[0101] Step 106: Receive simulated environment information for the target fabric.

[0102] Specifically, the simulated environment information refers to the environmental information in the virtual scene that affects the physical performance of the target cloth. The physical simulation performance of the target cloth will only be generated after the simulated environment information for the target cloth is received.

[0103] Furthermore, it receives simulated environment information for the target cloth in a virtual scene, including:

[0104] Receive at least one of the following for a target cloth in a virtual scene: character collision information, environment collision information, and cloth update information.

[0105] In practical applications, simulated environment information includes at least one of character collision information, environment collision information, and cloth update information. Specifically, character collision information refers to the collision information of dynamic virtual objects that affect the target cloth, such as the impact information of character A pulling character B. Environment collision information refers to the collision information of static virtual objects on the target cloth, such as the impact information of simulated wind in the virtual environment on character B. Cloth update information can be understood as the custom impact information of the target cloth, such as the impact information of character B's behavior of wearing clothes in the virtual scene on the cloth.

[0106] In practical applications, the received simulated environment information can be one of the following: character collision information, environment collision information, and cloth update information, or any combination of two or three. This application does not impose any limitations on this.

[0107] Step 108: Based on the constraint information between the cloth vertices, perform simulation calculations of the target cloth according to the simulation environment information and the initial cloth object to obtain the target cloth object.

[0108] The method provided in this application, after obtaining the simulation environment information, can perform simulation calculations of the target cloth based on the simulation environment information and the initial cloth object, under the constraints of the cloth vertex constraint information. Specifically,

[0109] Specifically, based on the constraint information between the cloth vertices, and according to the simulation environment information and the initial cloth object, the simulation calculation of the target cloth is performed, including:

[0110] Create an initial scene simulation cache array;

[0111] Add the constraint information between cloth vertices, the simulation environment information, and the initial cloth object to the initial scene simulation cache array;

[0112] The initial scene simulation cache array is input into the graphics processor's solver for iterative calculation.

[0113] Before loading the initial cloth object, a cloth physics scene corresponding to the target cloth needs to be created. Specifically, when creating the virtual scene, it is necessary to select whether to create a cloth physics scene corresponding to the target cloth based on the scene creation options. If a cloth physics scene needs to be created, the scene simulation buffer array SimBuffers is initialized, the corresponding physical parameters are read and set from the scene configuration file corresponding to the virtual scene, a physics calculator is created based on the physical parameters, and the physics calculator is deployed on the graphics processing unit (GPU).

[0114] When loading the target model into the virtual scene, a map operation is performed on the initial scene simulation buffer array SimBuffers to allow the central processing unit (CPU) to read and write access. The initial cloth data mentioned above is written into SimBuffers, including the position, velocity, phase, index, and normal information of cloth particles, the length, stiffness, and index information of spring constraints, and the position, rotation, strength, index, and index offset data of rigid body constraints.

[0115] Perform an unmap operation on SimBuffers to allow the graphics processing unit (GPU) to read and write access, and pass the data from SimBuffers to the GPU for iterative computation by the physical processor deployed on the GPU.

[0116] By using GPUs for iterative calculations, the computation speed and efficiency are greatly improved compared to traditional CPU-based methods.

[0117] The following sections will further explain the updating and calculation process for character collision information, environment collision information, and cloth update information.

[0118] Taking character collision information as an example, the creation and update process for character collision data is as follows:

[0119] When the character's skeletal animation is updated, the collision data bound to the bones is also updated. The collision data is then filtered by bone name to obtain filtered collision data.

[0120] Filtered collision data is used, and the required capsule colliders are generated based on the capsule's position, rotation, radius, and other information.

[0121] Obtain the current collider information and determine if the number of current colliders matches the number of colliders in the capsule. Based on the determination result, decide whether to rebuild the collision information. If reconstruction is required, clear the current collider information, rebuild the collider data, and mark the update type as reconstruction.

[0122] Traverse the above collider information and record the collision information of the current frame, including the radius, half height, position, and rotation quaternion of the capsule. This collision information is used to set the current collider state in the virtual physical space.

[0123] Traverse the above collision information and record the collision information of the previous frame, including the radius, half height, position, and rotation quaternion of the capsule. This collision information is used for continuous collision detection.

[0124] Based on the update type flag, determine whether to reconstruct the colliders in the virtual scene. If yes, remove existing collider data from SimBuffers, delete the current collider object, and generate a new capsule collider based on the collision information of the current frame, adding it to SimBuffers. If no, update the position and rotation information of the capsule colliders in the current and previous frames based on the collision information of the current and previous frames.

[0125] Perform an unmap operation on SimBuffers to allow the graphics processing unit (GPU) to read and write access, and pass the data from SimBuffers to the GPU for iterative computation by the physical processor deployed on the GPU.

[0126] Taking environmental collision information as an example, the creation and update process for character collision data is as follows:

[0127] When a static object in a virtual scene is loaded into the scene, it is necessary to determine whether it is a logical collision object of the target cloth. If not, the static object is loaded directly. If it is, the object attribute information of the static object, such as vertices, indexes, world matrix, bounding box information, etc., needs to be obtained and stored in the environment collision data structure.

[0128] When the target virtual character is loaded into the virtual scene or moves beyond a certain distance, the environmental collision body is regenerated using the aforementioned environmental collision data.

[0129] Based on the bounding box information of the static object and the world coordinate information of the character, the spatial positional relationship between the static object and the target virtual character is determined. If there is spatial overlap, it is determined that the two have collided.

[0130] After determining that a collision has occurred, it is necessary to judge whether the collision data is reasonable based on the vertex and index information of the static objects saved above. If it is reasonable, a map operation is performed on SimBuffers to allow the CPU to read and write access.

[0131] If a corresponding collider is detected, the existing collider data in SimBuffers is removed and the current collider object is deleted. If no collider is detected, the vertices within a specific range of the target virtual character are found based on the vertex and index information of the static object, and a new mesh is generated for collision calculation. A physical collider is then generated based on the newly generated mesh data and added to SimBuffers.

[0132] Perform an unmap operation on SimBuffers to allow the graphics processing unit (GPU) to read and write access, and pass the data from SimBuffers to the GPU for iterative computation by the physical processor deployed on the GPU.

[0133] Taking cloth update information as an example, the character collision data creation and update process is as follows:

[0134] While updating the target model, the target cloth is also updated. The external data that needs to be obtained includes the world matrix of the target model, the bone matrix and number of bones of the target model, and the current skinning animation information.

[0135] Update the animation state of the initial cloth object using the current skinning animation information.

[0136] Using the bone offset matrix information stored in the MeshBuffer data structure and the bone matrix of the target model, the vertex transformation matrix and normal transformation matrix of the initial cloth object are calculated.

[0137] The model skinning index and weight information in the MeshBuffer data structure, as well as the initial position, normal, and tangent data of the cloth vertices, and the bone matrix information are used to calculate the cloth vertex position, normal, and tangent data after real-time skinning updates.

[0138] The fabric vertex data is further subdivided using the subdivided fabric subdivision level information.

[0139] If the initial cloth object has already been loaded into the virtual scene, the particle data in the virtual scene is further updated. A map operation is performed on SimBuffers to allow CPU read and write access.

[0140] Based on the transparency channel data in the subdivided color channel data, cloth vertices and non-cloth vertices are distinguished. For non-cloth vertices, the cloth vertex position information and the mapping relationship between vertices and cloth particles are used to update the corresponding cloth particle positions through the skinned vertex positions. For cloth vertices, the green channel data in the subdivided color channel data is used to update their grouped and followed positions. Simultaneously, for cloth vertices, the red channel data in the subdivided color channel data, along with vertex position information, is used to limit their maximum movement distance relative to the skinned vertex positions.

[0141] Perform an unmap operation on SimBuffers to allow the graphics processing unit (GPU) to read and write access, and pass the data from SimBuffers to the GPU for iterative computation by the physical processor deployed on the GPU.

[0142] The physics engine corresponding to the virtual scene updates the data, and the cloth physics scene is updated iteratively in sync. Scene physics parameters are set, and these parameters can be modified in real time. Cloth particle data and simulation environment information (character collision information, environment collision information, cloth update information) stored in SimBuffers are input into the GPU. The GPU performs iterative calculation and updates of particle constraints, and the updated particle position, velocity, phase, and detection data are transferred to the CPU and stored in SimBuffers.

[0143] Step 110: Render the target cloth object in the virtual scene.

[0144] Obtain the SimBuffers containing updated particle position, velocity, phase, and discovery data from the above steps, retrieve the updated cloth data from the SimBuffers, and render the target cloth object in the virtual scene based on the cloth data in the SimBuffers.

[0145] When the target cloth is no longer needed in the virtual scene, the target cloth object can be destroyed within the virtual scene. Specifically, the method further includes:

[0146] Receive a destruction command for the target fabric object;

[0147] The target cloth object in the virtual scene is destroyed in response to the destruction command.

[0148] The destruction command can be either a destruction command for the target cloth object or a command to destroy the virtual scene. When a destruction command for the target cloth object is received, the target cloth object in the virtual scene will be destroyed directly.

[0149] When the received instruction is to destroy the virtual scene, it is necessary to first determine whether the current virtual scene is referenced by other scenes. If the reference count of the virtual scene is 0, the remaining commands in the command queue of the current virtual scene are processed until the command queue is cleared. Then, the cloth object data, collision data, SimBuffers data are destroyed in sequence, the cloth solver is destroyed, and the virtual scene is destroyed.

[0150] The physical simulation method for cloth in a virtual scene provided in this application includes receiving a simulation instruction for a target cloth in the virtual scene; loading an initial cloth object corresponding to the target cloth in response to the simulation instruction, wherein the initial cloth object includes constraint information between cloth vertices; receiving simulation environment information for the target cloth; performing simulation calculations on the target cloth based on the constraint information between cloth vertices, according to the simulation environment information and the initial cloth object, to obtain the target cloth object; and rendering the target cloth object in the virtual scene.

[0151] The method provided in this application enables the simulation of cloth by utilizing constraint information between cloth vertices. Compared to traditional simulation methods based on mass-spring systems, this method provides richer cloth behavior, greater stability when handling complex multi-layered cloth, and reduces the likelihood of clipping. Furthermore, the method provides information on the impact of the simulation environment on the cloth, resulting in richer and more diverse interactions between the cloth and the environment. Depending on the surrounding environment, the cloth will exhibit different interactive behaviors, significantly improving the realism of the cloth physics simulation.

[0152] Secondly, by deploying the solver on a GPU and using the GPU to assist in iterative calculations, the calculation speed is significantly improved compared to traditional CPU-based methods. Furthermore, the method in this application provides comprehensive art tools, allowing users to easily customize and edit cloth, and supports WYSIWYG real-time simulation functionality.

[0153] The following is in conjunction with the appendix Figure 2 Taking the application of the physical simulation method for cloth in a virtual scene provided in this application in a game scene as an example, the physical simulation method for cloth in a virtual scene will be further explained. Among them, Figure 2 This application provides a flowchart illustrating a physical simulation method for cloth in a virtual game scene, according to an embodiment of the present application. The method specifically includes the following steps:

[0154] Step 202: Initialize the cloth physics scene.

[0155] In the embodiments provided in this application, taking the creation of clothing information for virtual characters in a game scene as an example, the physical scene of the cloth is first initialized, and the scene simulation cache array SimBuffer is created.

[0156] Step 204: Determine if pre-generated fabric data exists. If not, proceed to steps 206-208. If yes, proceed to step 210.

[0157] In the embodiments provided in this application, it is determined whether pre-generated fabric data already exists in the terminal. If not, fabric data needs to be generated, i.e., steps 206-208 are executed. If so, the pre-generated fabric data can be used directly.

[0158] Step 206: Editing the fabric art resources.

[0159] In the embodiments provided in this application, if the terminal has not pre-generated cloth data, it is necessary to obtain cloth art resources. The user generates cloth data based on the cloth art resources.

[0160] Step 208: Generate fabric data and proceed to step 210.

[0161] In the embodiments provided in this application, after obtaining the cloth art resources, cloth data is generated based on the cloth art resources.

[0162] Step 210: Load the cloth object.

[0163] In the embodiments provided in this application, a fabric object is loaded based on pre-generated fabric data.

[0164] Step 212: Update fabric data.

[0165] In the embodiments provided in this application, pre-generated fabric data is updated based on custom fabric update information.

[0166] Step 214: Create character collision data.

[0167] In the embodiments provided in this application, if there are collisions between other virtual characters and the target virtual character in the virtual scene, it is also necessary to create character collision data.

[0168] Step 216: Character collision data update.

[0169] In the embodiments provided in this application, updated data for the cloth is generated based on character collision data.

[0170] Step 218: Environment collision data creation.

[0171] In the embodiments provided in this application, if the virtual scene also involves the influence of environmental information on the target virtual character, it is also necessary to create environmental collision data.

[0172] Step 220: Update environmental collision data.

[0173] In the embodiments provided in this application, updated data for the fabric is generated based on environmental collision data.

[0174] It should be noted that there is no necessary order between steps 214-216, steps 218-220, and steps 204-212.

[0175] Step 222: Cloth physics scene update and calculation.

[0176] In the embodiments provided in this application, the cloth data updated with the custom cloth update information, the cloth data updated with the character collision data, and the cloth data updated with the environment collision data in the above steps are used to update and solve the cloth physics scene. Specifically, the CPU obtains the cloth data updated with the custom cloth update information, the cloth data updated with the character collision data, and the cloth data updated with the environment collision data, and sends the cloth update data to the GPU. A physics calculator is deployed in the GPU, and the cloth update data is updated through the GPU to obtain the physics calculation data.

[0177] Step 224: Determine if the simulation has ended. If not, proceed to step 226; if yes, proceed to step 228.

[0178] In the embodiments provided in this application, it is determined whether the physical simulation of the cloth in the virtual scene has ended. If it has not ended, step 226 is executed; if it has ended, step 228 is executed.

[0179] Step 226: Obtain the physical calculation results for rendering, and continue to execute step 222.

[0180] In the embodiments provided in this application, the GPU obtains physical calculation data and sends the physical calculation data to the CPU. The CPU calculates cloth rendering data based on the physical calculation data and sends the cloth rendering data to the GPU, so that the GPU generates rendering results based on the cloth rendering data.

[0181] Step 228: Unload and destroy the physical scene of the cloth.

[0182] In the embodiments provided in this application, if the physical simulation of the cloth has ended, the physical scene of the cloth needs to be destroyed to release the corresponding computing resources.

[0183] The method provided in this application enables the simulation of cloth by utilizing constraint information between cloth vertices. Compared to traditional simulation methods based on mass-spring systems, this method provides richer cloth behavior, greater stability when handling complex multi-layered cloth, and reduces the likelihood of clipping. Furthermore, the method provides information on the impact of the simulation environment on the cloth, resulting in richer and more diverse interactions between the cloth and the environment. Depending on the surrounding environment, the cloth will exhibit different interactive behaviors, significantly improving the realism of the cloth physics simulation.

[0184] Secondly, by deploying the solver on a GPU and using the GPU to assist in iterative calculations, the calculation speed is significantly improved compared to traditional CPU-based methods. Furthermore, the method in this application provides comprehensive art tools, allowing users to easily customize and edit cloth, and supports WYSIWYG real-time simulation functionality.

[0185] Corresponding to the above method embodiments, this application also provides an embodiment of a physical simulation device for cloth in a virtual scene. Figure 3 This illustration shows a schematic diagram of a physical simulation device for cloth in a virtual scene according to an embodiment of this application. Figure 3 As shown, the device includes:

[0186] The instruction receiving module 302 is configured to receive simulated instructions for the target cloth in a virtual scene;

[0187] The loading module 304 is configured to load an initial cloth object corresponding to the target cloth in response to the simulation command, wherein the initial cloth object includes constraint information between cloth vertices;

[0188] The information receiving module 306 is configured to receive simulated environmental information for the target fabric;

[0189] The simulation module 308 is configured to perform simulation calculations on the target cloth based on the constraint information between the cloth vertices, the simulation environment information, and the initial cloth object, to obtain the target cloth object;

[0190] Rendering module 310 is configured to render the target cloth object in the virtual scene.

[0191] Optionally, the loading module 304 is further configured to:

[0192] Determine whether the initial fabric data corresponding to the target fabric is stored;

[0193] If so, load the initial fabric object based on the initial fabric data;

[0194] If not, read the fabric resource information of the target fabric, generate initial fabric data based on the fabric resource information, and load the initial fabric object based on the initial fabric data.

[0195] Optionally, the loading module 304 is further configured to:

[0196] Read the vertex color information and vertex physical attribute information of the target cloth;

[0197] Obtain the constraint information between the vertices of the target cloth based on the vertex color information;

[0198] Initial cloth data is generated based on the vertex physical attribute information and the constraint information between cloth vertices.

[0199] Optionally, the loading module 304 is further configured to:

[0200] Read the red channel data, green channel data, and blue channel data from the color channels.

[0201] Optionally, the loading module 304 is further configured to:

[0202] Based on the red channel data, the green channel data, and the blue channel data, spring constraint information, tether constraint information, and rigid body constraint information between the fabric vertices are generated.

[0203] Optionally, the information receiving module 306 is further configured to:

[0204] Receive at least one of the following for a target cloth in a virtual scene: character collision information, environment collision information, and cloth update information.

[0205] Optionally, the simulation module 308 is further configured to:

[0206] Create an initial scene simulation cache array;

[0207] Add the constraint information between cloth vertices, the simulation environment information, and the initial cloth object to the initial scene simulation cache array;

[0208] The initial scene simulation cache array is input into the graphics processor's solver for iterative calculation.

[0209] Optionally, the device further includes a destruction module configured to:

[0210] Receive a destruction command for the target fabric object;

[0211] The target cloth object in the virtual scene is destroyed in response to the destruction command.

[0212] The physical simulation device for cloth in a virtual scene provided in this application receives a simulation instruction for a target cloth in the virtual scene; loads an initial cloth object corresponding to the target cloth in response to the simulation instruction, wherein the initial cloth object includes constraint information between cloth vertices; receives simulation environment information for the target cloth; performs simulation calculation of the target cloth based on the constraint information between cloth vertices, according to the simulation environment information and the initial cloth object, to obtain the target cloth object; and renders the target cloth object in the virtual scene.

[0213] The apparatus provided in this application enables the simulation of cloth by utilizing constraint information between cloth vertices. Compared to traditional simulation methods based on mass-spring systems, this approach provides richer cloth representation, greater stability when handling complex multi-layered cloth, and reduces the likelihood of clipping. Furthermore, the method provides information on the impact of the simulation environment on the cloth, resulting in more diverse and richer interactions between the cloth and the environment. Depending on the surrounding environment, the cloth exhibits different interactive behaviors, significantly improving the realism of the cloth physics simulation.

[0214] Secondly, by deploying the solver on a GPU and using the GPU to assist in iterative calculations, the calculation speed is significantly improved compared to traditional CPU-based methods. Furthermore, the method in this application provides comprehensive art tools, allowing users to easily customize and edit cloth, and supports WYSIWYG real-time simulation functionality.

[0215] The above is an illustrative scheme of a physical simulation device for cloth in a virtual scene according to this embodiment. It should be noted that the technical solution of this physical simulation device for cloth in a virtual scene and the technical solution of the physical simulation method for cloth in a virtual scene described above belong to the same concept. For details not described in detail in the technical solution of the physical simulation device for cloth in a virtual scene, please refer to the description of the technical solution of the physical simulation method for cloth in a virtual scene described above.

[0216] Figure 4 A structural block diagram of a computing device 400 according to an embodiment of this application is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.

[0217] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.

[0218] In one embodiment of this application, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.

[0219] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 400 can also be a mobile or stationary server.

[0220] The processor 420 executes the computer instructions to implement the physical simulation method for cloth in the virtual scene.

[0221] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the above-described physical simulation method for cloth in a virtual scene belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-described physical simulation method for cloth in a virtual scene.

[0222] An embodiment of this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the physical simulation method for cloth in a virtual scene as described above.

[0223] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the above-described method for physical simulation of cloth in a virtual scene belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the above-described method for physical simulation of cloth in a virtual scene.

[0224] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0225] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.

[0226] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0227] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0228] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.

Claims

1. A method for physically simulating cloth in a virtual scene, characterized in that, include: Receive simulation commands for the target cloth in the virtual scene; In response to the simulation command, it is determined whether initial cloth data corresponding to the target cloth is stored. If yes, an initial cloth object is loaded based on the initial cloth data. If no, the red channel data, green channel data, blue channel data, and vertex physical attribute information in the color channels are read. Spring constraint information, tether constraint information, and rigid body constraint information between cloth vertices are generated based on the red channel data, the green channel data, and the blue channel data. Initial cloth data is generated based on the vertex physical attribute information and the constraint information between cloth vertices. The initial cloth object is loaded based on the initial cloth data. The initial cloth object includes constraint information between cloth vertices, which is obtained based on the vertex color information of the target cloth. The vertex color information is data stored in the color channels used to generate the target cloth. The red channel data is used to store the maximum movement distance range limit of the cloth vertices relative to the skin vertices. The green channel data is used to store information related to the cloth particle swarm. The blue channel data is used to represent the softness and hardness of the cloth. Receive simulated environmental information for the target fabric; Based on the constraint information between the cloth vertices, the target cloth is simulated and calculated according to the simulation environment information and the initial cloth object to obtain the target cloth object; The target cloth object is rendered in the virtual scene.

2. The method as described in claim 1, characterized in that, Receive simulated environment information for the target cloth in the virtual scene, including: Receive at least one of the following for a target cloth in a virtual scene: character collision information, environment collision information, and cloth update information.

3. The method as described in claim 1, characterized in that, Based on the constraint information between the cloth vertices, the simulation calculation of the target cloth is performed according to the simulation environment information and the initial cloth object, including: Create an initial scene simulation cache array; Add the constraint information between cloth vertices, the simulation environment information, and the initial cloth object to the initial scene simulation cache array; The initial scene simulation cache array is input into the graphics processor's solver for iterative calculation.

4. The method as described in claim 1, characterized in that, The method further includes: Receive a destruction command for the target fabric object; The target cloth object in the virtual scene is destroyed in response to the destruction command.

5. A physical simulation device for cloth in a virtual scene, characterized in that, include: The instruction receiving module is configured to receive simulated instructions for the target cloth in the virtual scene; The loading module is configured to respond to the simulation command by determining whether initial cloth data corresponding to the target cloth is stored. If so, it loads an initial cloth object based on the initial cloth data. If not, it reads the red channel data, green channel data, blue channel data, and vertex physical attribute information from the color channels. Based on the red channel data, green channel data, and blue channel data, it generates spring constraint information, tether constraint information, and rigid body constraint information between cloth vertices. Based on the vertex physical attribute information and the constraint information between cloth vertices, it generates initial cloth data and loads the initial cloth object based on the initial cloth data. The initial cloth object includes constraint information between cloth vertices, which is obtained based on the vertex color information of the target cloth. The vertex color information is data stored in the color channels used to generate the target cloth. The red channel data is used to store the maximum movement distance range limit of the cloth vertices relative to the skin vertices. The green channel data is used to store information related to the cloth particle swarm. The blue channel data is used to represent the softness and hardness of the cloth. The information receiving module is configured to receive simulated environmental information for the target fabric; The simulation module is configured to perform simulation calculations on the target cloth based on the constraint information between the cloth vertices, the simulation environment information, and the initial cloth object, to obtain the target cloth object; The rendering module is configured to render the target cloth object in the virtual scene.

6. A computing device, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the computer instructions, it implements the steps of the method according to any one of claims 1-4.

7. A computer-readable storage medium storing computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Cloth animation generation method and device and computer readable storage medium

    CN111028320A

  • Compute Shader-based real-time cloth simulation method and system

    CN113127945A