Virtual object rendering method and device, storage medium, and electronic device

By using low-precision grids for physical simulation and high-resolution grids for rendering in the game, the problem of low efficiency in fabric simulation in the game is solved, and the effect of improving processing efficiency is achieved.

CN111773719BActive Publication Date: 2025-03-14BEIJING PERFECT WORLD SOFTWARE TECH DEV CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010583263.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-23
Publication Date
2025-03-14
Estimated Expiration
2040-06-23

AI Technical Summary

Technical Problem

In the prior art, fabric simulation is less efficient in games, especially on mobile terminals, resulting in large computing overhead and affecting game performance.

Method used

Low-precision mesh is used for physical simulation calculations, and high-resolution mesh model is used for rendering during the rendering stage. The specific steps include obtaining low-resolution and high-resolution models, simulating the low-resolution model through the physics engine, determining the target pose, and using the vertex positions in the low-resolution model to determine the vertex positions of the high-resolution model, and finally rendering using the high-resolution model.

Benefits of technology

The calculation amount in the physical simulation stage is reduced, the processing efficiency of the game is improved, the problem of low data processing efficiency is solved, and the simulation effect is maintained.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111773719B_ABST
    Figure CN111773719B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for rendering a virtual object, a storage medium, and an electronic device. The method includes: obtaining a first model and a second model, the first model and the second model are used to represent a target object in a virtual scene, the facet accuracy of the first model is lower than the facet accuracy of the second model; simulating the first model through a physical engine to determine the target posture of the target object; using the vertex positions of the facets in the first model to determine the vertex positions of the facets in the second model, wherein the vertex positions of the facets in the first model are the vertex positions when the first model is in the target posture; and using the second model to render the target object in the target posture. The present application solves the technical problem of low efficiency of data processing in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of games, and more specifically, to a method and device for rendering a virtual object, a storage medium, and an electronic device. Background Art

[0002] Currently, as players and developers pursue higher quality games, more realistic and natural animation effects have become one of the goals of many games. Among them, real-time cloth simulation, as a key feature, can be widely used in many scenarios such as character clothing and scene softness. It can not only improve the shortcomings of traditional skeletal animation, such as stiffness and rough details, but also solve the problems of vertex animation that cannot be interacted and has large storage space, thereby greatly improving the realism of the game experience. Figure 1 shown.

[0003] Currently, the commonly used physics engines PhysX, Bullet and Havok provide complete cloth systems, among which Nvidia's PhysX is widely used. The two major mainstream 3D engines Unity and Unreal use the cloth solution in PhysX by default. The mainstream cloth simulation algorithms are the force-based mass-spring model (Mass-Spring Model) and the position-based constraint solution model (Position Based Dynamic).

[0004] In the spring-mass model, Figure 2 As shown in the figure, the vertices of the model are regarded as mass points, and the relationship between the mass points is represented by springs. The springs can be set to different types, such as stretch springs, shear springs, and bend springs. During the simulation, the force on each mass point is calculated based on the external force (such as gravity, wind force, etc.) and the spring force, and then the acceleration is calculated, and then the velocity and position of the mass point in a very short time step are calculated. In order to make the simulation results stable, a smaller step size is usually set, and multiple iterations are performed for each frame. The calculation amount of this solution is relatively large.

[0005] The position-based constraint solving model is similar to the spring-mass model, except that the relationship between vertices is expressed by constraints, and the solution of the model is not based on force, but on position, solving the constraint function. Compared with the spring-mass model, the position-based constraint solving model is more stable, but it still requires iterative calculations during simulation, and still requires a lot of calculations. It can be seen that from an algorithmic point of view, the runtime calculation overhead of cloth is relatively large.

[0006] Considering the widespread application of Unity engine in the field of mobile games, in the implementation of Unity cloth, Unity's cloth system is based on Nvidia's PhysX implementation, and a lot of encapsulation is done to shield the internal details and simplify the use of cloth. Unity's cloth is encapsulated into a Component, and its use is very simple: first, add a cloth component to the gameObject where the SkinnedMeshRenderer is located; then edit the properties of each vertex of the cloth, and adjust other properties and collision body information in the cloth component; the effect achieved is as follows Figure 3 shown.

[0007] In addition to using Unity's built-in cloth system, there are other plug-ins in the Asset Store that can achieve or approach the effect of dynamic cloth, such as Dynamic Bone, Obi Cloth, etc. Obi Cloth is a plug-in for simulating cloth. The core cloth solver is implemented in C++, and the other parts are implemented in C#. Obi Cloth provides rich cloth features and a friendly cloth editing experience. It is not too complicated to use, and the simulation effect is also very good. Figure 4 As shown, its efficiency is much lower than the cloth that comes with Unity, and there are some compatibility issues between different versions of Unity, so its application is relatively limited.

[0008] In addition, the Dynamic Bone plug-in commonly used on mobile platforms can also be used to approximate cloth effects in some cases. This plug-in is based on the physical simulation method of bones. It regards bones as chain structures connected by joints, simulates the movement of bone chains through physical calculations, and then acts on the vertices of the model through Skin.

[0009] Compared with Unity's cloth, Dynamic Bone has a great advantage in efficiency. After all, the number of bones is much less than the number of model vertices. For slender models such as ribbons, the simulation effect is also good. But after all, DynamicBone is based on bones, and the simulation effect is obviously not as fine as vertex-based cloth. In addition, in order to make the model dynamic, additional bones and bindings must be made for the model. In addition, due to its chain-like characteristics, it is often only suitable for long strips of cloth simulation effects. As for large pieces of cloth, it seems powerless, such as Figure 5 As shown, in order to create the dynamic effect of the short skirt, the Dynamic Bone solution requires multiple bone chains, and in this case, the amount of calculation will be greatly increased.

[0010] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0011] The embodiments of the present application provide a method and device for rendering a virtual object, a storage medium, and an electronic device to at least solve the technical problem of low efficiency of data processing in related technologies.

[0012] According to one aspect of an embodiment of the present application, a method for rendering a virtual object is provided, comprising: obtaining a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and the facet accuracy of the first model is lower than the facet accuracy of the second model; simulating the first model through a physical engine to determine a target posture of the target object; using the vertex positions of the facets in the first model to determine the vertex positions of the facets in the second model, wherein the vertex positions of the facets in the first model are the vertex positions of the first model when the model is in the target posture; and using the second model to render the target object in the target posture.

[0013] According to another aspect of an embodiment of the present application, a rendering device for a virtual object is also provided, including: an acquisition unit, used to acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and the facet accuracy of the first model is lower than the facet accuracy of the second model; a simulation unit, used to simulate the first model through a physical engine to determine a target posture of the target object; a determination unit, used to determine the vertex positions of the facets in the second model using the vertex positions of the facets in the first model, wherein the vertex positions of the facets in the first model are the vertex positions of the first model when the first model is in the target posture; and a rendering unit, used to render the target object in the target posture using the second model.

[0014] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.

[0015] According to another aspect of an embodiment of the present application, an electronic device is further provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.

[0016] In the embodiment of the present application, the first model, which is a low-resolution model, is used for simulation in the simulation stage, and the second model, which is a high-resolution model, is used for rendering in the rendering stage. For meshes with complex structures that are difficult to simulate, simple models are used for simulation and complex models are used for rendering, rather than always using complex models for simulation and rendering. This reduces the amount of calculation in the physical simulation stage, can solve the technical problem of low data processing efficiency in related technologies, and thereby achieve the technical effect of improving processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1 is a schematic diagram of an optional rendering effect of a virtual object in the related art;

[0019] Figure 2 is a schematic diagram of an optional spring mass model in the related art;

[0020] Figure 3 is a schematic diagram of an optional rendering effect of a virtual object in the related art;

[0021] Figure 4 is a schematic diagram of an optional rendering effect of a virtual object in the related art;

[0022] Figure 5 is a schematic diagram of an optional rendering effect of a virtual object in the related art;

[0023] Figure 6 is a schematic diagram of an optional test result of virtual object rendering in the related art;

[0024] Figure 7 is a schematic diagram of an optional test result of virtual object rendering in the related art;

[0025] Figure 8 is a schematic diagram of an optional test result of virtual object rendering in the related art;

[0026] Fig. 9 is a schematic diagram of a hardware environment of a method for rendering a virtual object according to an embodiment of the present application;

[0027] Fig.10 is a flowchart of an optional method for rendering a virtual object according to an embodiment of the present application;

[0028] Fig.11 is a schematic diagram of a rendering effect of a virtual object according to an embodiment of the present application;

[0029] Fig.12 is a schematic diagram of a face of a virtual object according to an embodiment of the present application;

[0030] Fig.13 is a schematic diagram of a rendering scheme of a virtual object according to an embodiment of the present application;

[0031] Fig.14 is a schematic diagram of a rendering scheme of a virtual object according to an embodiment of the present application;

[0032] Fig.15 is a schematic diagram of a rendering effect of a virtual object according to an embodiment of the present application;

[0033] Fig.16 is a schematic diagram of a test result of virtual object rendering according to an embodiment of the present application;

[0034] Fig.17 is a schematic diagram of a test result of virtual object rendering according to an embodiment of the present application;

[0035] Fig.18 is a schematic diagram of an optional virtual object rendering device according to an embodiment of the present application; and

[0036] Fig.19 It is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0039] After studying the relevant technologies, the inventor found that although the simulation effect of cloth in the relevant technologies is very good, the efficiency issue is very important in the game, especially for mobile terminals (limited by factors such as volume and battery, the performance of the hardware is not as good as that of desktop devices). The inventor tested the operating efficiency of cloth with different vertex numbers on various platforms, such as Figures 6 to 8 ( Figure 6 This is the test result of Qualcomm Snapdragon 835 platform. Figure 7 This is the test result of Apple's A11 processor platform. Figure 8 The test results of Intel i5-6500 platform show that the total time for simulating 9 cloths with 1000 vertices on PC is less than 1ms, but on mobile, the same scale of cloth simulation takes about 5ms, which is a great cost for mobile terminals. Of course, on mobile platforms, when the number of vertices of cloth is limited to 100, the cost of 9 cloths is only about 1ms, which means that the cloth can be used without any worries, but the display effect will be worse.

[0040] Based on the above performance test conclusions, in order to afford cloth simulation on mobile terminals, according to one aspect of the embodiments of the present application, a method embodiment of a method for rendering a virtual object is provided. The present application provides a set of solutions that have both implementation effects and implementation efficiency. The solution uses low-precision grids for physical simulation calculations, and then applies dynamic effects to fine grid models, so that cloth simulation effects can be added while reducing performance consumption.

[0041] Optionally, in this embodiment, the virtual object rendering method can be applied to Fig. 9 In the hardware environment composed of terminal 901 and server 903 shown in FIG. Fig. 9 As shown, the server 903 is connected to the terminal 901 via a network, and can be used to provide services (such as game services, etc.) for the terminal or a client installed on the terminal. A database 905 can be set on the server or independently of the server to provide data storage services for the server 903. The above-mentioned network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 901 is not limited to a PC, a mobile phone, a tablet computer, etc.

[0042] The virtual object rendering method of the embodiment of the present application may be executed by the terminal 901, or may be executed by the server 903 and the terminal 901. The virtual object rendering method of the embodiment of the present application may be executed by the terminal 901 or by a client installed thereon. Fig.10 is a flowchart of an optional method for rendering a virtual object according to an embodiment of the present application, such as Fig.10 As shown, the method may include the following steps:

[0043] Step S1002, the terminal obtains a first model and a second model, the first model and the second model are used to represent the target object in the virtual scene, and the patch accuracy of the first model is lower than the patch accuracy of the second model. The terminal is the target terminal of the mobile device mentioned below.

[0044] The first model and the second model are both models used to describe the target object. The difference between the two models is only the different surface accuracy. For example, the first model uses N surfaces, and the second model uses M surfaces, where M is greater than N.

[0045] Step S1004: the terminal simulates the first model through a physical engine to determine a target posture of the target object.

[0046] All objects in the real world follow the laws of nature. In order to simulate the physical effects of the real world in the game, a physics engine is needed as an aid. The game engine usually has a built-in physics engine. Through the processing of the physics engine, objects in the game can move according to the laws of physical motion, such as being affected by natural constraints. Natural constraints include gravity, torque, and impulse. Objects can have mutual collision forces and friction between each other.

[0047] Step S1006: The terminal determines the vertex positions of the face patches in the second model using the vertex positions of the face patches in the first model, where the vertex positions of the face patches in the first model are the vertex positions of the first model when it is in the target posture.

[0048] Step S1008: The terminal renders the target object in the target posture using the second model.

[0049] When the terminal GPU is rendering, it includes vertex processing, rasterization calculation, texture mapping, and pixel processing. The job of the GPU is to complete the generation of 3D graphics, map the graphics to the corresponding pixels, calculate each pixel to determine the final color and complete the output.

[0050] Vertex processing: In this stage, the GPU reads the vertex data (including vertex positions) that describe the appearance of the 3D graphics and determines the shape and position relationship of the 3D graphics based on the vertex data, and builds the skeleton of the 3D graphics. These tasks are completed by the hardware-implemented Vertex Shader.

[0051] Rasterization calculation: The image actually displayed on the monitor is composed of pixels. The points and lines on the generated graphics need to be converted into corresponding pixels through a certain algorithm. The process of converting a vector graphic into a series of pixels is called rasterization. For example, a mathematically represented oblique line segment is eventually converted into a series of pixels in a staircase shape.

[0052] Texture Mapping: The polygons generated by the vertex unit only form the outline of the 3D object, while the texture mapping work completes the mapping of the polygonal surface, that is, pasting the corresponding image on the surface of the polygon to generate a "real" graphic. TMU (Texture Mapping Unit) is used to complete this work.

[0053] Pixel processing: During this stage (during the rasterization of each pixel), the GPU completes the calculation and processing of the pixels to determine the final attributes of each pixel. These tasks are completed by the hardware-implemented Pixel Shader. Final output: The ROP (rasterization engine) finally completes the output of the pixels. After 1 frame is rendered, it is sent to the video memory frame buffer.

[0054] In the scheme of the present application, the first model, which is a low-resolution model, is used for simulation in the simulation stage, and the second model, which is a high-resolution model, is used for rendering in the rendering stage. For meshes with complex structures that are difficult to simulate, simple models are used for simulation and complex models are used for rendering, rather than always using complex models for simulation and rendering. This reduces the amount of calculation in the physical simulation stage, can solve the technical problem of low data processing efficiency in related technologies, and thereby achieve the technical effect of improving processing efficiency.

[0055] In an optional embodiment, using the vertex positions of the face pieces in the first model to determine the vertex positions of the face pieces in the second model includes the following two implementation schemes, the first of which can be implemented through the following steps 11 and 12:

[0056] Step 11, searching for a target vertex in the second model, where the target vertex is a vertex in the second model that is within the current display area of ​​the target terminal, and the target terminal is used to control a player object in the virtual scene (which may be the above-mentioned target object or other objects).

[0057] Step 12: Calling a graphics processor to process the vertex positions of the facets in the first model to obtain the vertex positions of the target vertices in the second model.

[0058] Optionally, calling a graphics processor to process the vertex positions of the facets in the first model to obtain the vertex positions of the target vertices in the second model includes the following steps 121 and 122:

[0059] Step 121, saving the vertex positions of the face in the first model to a target cache, such as a compute buffer, where the target cache is a cache configured for a graphics processor for storing data to be processed.

[0060] In step 122, the graphics processor reads the vertex positions of the face patches in the first model from the target cache, and determines the vertex positions of the target vertices in the second model using the vertex positions of the face patches in the first model.

[0061] In another optional embodiment, the second method of determining the vertex positions of the face pieces in the second model by using the vertex positions of the face pieces in the first model can be implemented by the following steps 21 and 22:

[0062] Step 21 : searching for a plurality of target vertices in the second model, where the target vertices are vertices in the second model that are located in the current display area of ​​the target terminal.

[0063] Step 22, calling a graphics processor to perform parallel processing on the vertex positions of the facets in the first model to obtain vertex positions of a plurality of target vertices in the second model.

[0064] Optionally, calling a graphics processor to perform parallel processing on the vertex positions of the facets in the first model to obtain the vertex positions of multiple target vertices in the second model includes the following steps 221-222:

[0065] Step 221: Create a plurality of first threads in a graphics processor, wherein the number of the plurality of first threads is the same as the number of the plurality of target vertices.

[0066] Step 222, the vertex positions of the facets in the first model are processed in parallel by multiple first threads to obtain the vertex positions of multiple target vertices in the second model, each thread in the multiple first threads is used to obtain the vertex position of a target vertex, and the vertex positions of the target vertices obtained by any two threads in the multiple first threads are different, which is equivalent to a one-to-one correspondence between the first threads and the target vertices.

[0067] Optionally, considering that if a thread is called to process the vertex position of each target vertex, a large amount of GPU resources will be occupied in a short time, optimization can be performed in the following manner: calling a graphics processor to process the vertex positions of the facets in the first model in parallel to obtain the vertex positions of multiple target vertices in the second model, including the following steps 223-224:

[0068] Step 223: Create a plurality of second threads in the graphics processor, wherein the number of the plurality of second threads is less than the number of vertices of the plurality of target vertices.

[0069] Step 224, the vertex positions of the facets in the first model are processed in parallel by multiple second threads to obtain the vertex positions of multiple target vertices in the second model, wherein each of the multiple second threads is used to obtain the vertex position of at least one target vertex, and some or all of the multiple second threads are used to continue processing to obtain the vertex position of another target vertex after obtaining the vertex position of one target vertex, which is equivalent to the multiple second threads running in parallel, but each second thread can process multiple target vertices serially.

[0070] In the above implementation, determining the vertex positions of the face patches in the second model using the vertex positions of the face patches in the first model includes determining the vertex position of each vertex to be confirmed in the second model in the manner shown in the following steps 31-32:

[0071] Step 31 , searching the first model for a target face associated with a target vertex in the second model, where the target vertex is a vertex in the second model whose position is currently to be determined.

[0072] Step 32: determine the vertex position of the target vertex according to the association relationship between the target vertex and the target face and the vertex positions of all vertices of the target face.

[0073] In the above embodiment, the target patch is a triangular patch with three vertices, wherein the vertex position of the target vertex is determined according to the association relationship between the target vertex and the target patch and the vertex positions of all vertices of the target patch, the coordinate calculation shown in step 321 and the normal calculation shown in step 322:

[0074] Step 322: Determine the vertex coordinate P of the target vertex according to the following formula for describing the first relationship: ′ :

[0075] Among them, A is the coordinate of the first vertex of the triangular patch, B is the coordinate of the second vertex of the triangular patch, C is the coordinate of the third vertex of the triangular patch, α, β, γ are the set parameters, represents the vector from the first vertex to the second vertex, represents the vector from the first vertex to the third vertex, Express Taking the norm, the association relationship includes the first relationship.

[0076] Step 322, determine the vertex normal of the target vertex according to the following formula for describing the second relationship:

[0077] in, Represents the vertex normal of the first vertex in the triangle patch, Represents the vertex normal of the second vertex in the triangle patch, Represents the vertex normal of the third vertex in the triangle patch. α, β, and γ are set parameters. The association relationship includes the second relationship.

[0078] As an optional embodiment, the following is a detailed description of the application of the technical solution of the present application in the UNITY engine as an example. The solution uses a low-precision grid for physical simulation calculations, and then applies dynamic effects to a fine grid model, so that the cloth simulation effect can be added while reducing performance consumption.

[0079] This solution can be called Adhere Cloth. Its function is to make a face mesh move with the cloth. Adhere Cloth can be used to simulate with a low-resolution model and render with a high-resolution model. For meshes with complex structures that are difficult to simulate, simple models can be used for simulation and complex models can be used for rendering.

[0080] like Fig.11 As shown in the figure, the cloth used for simulation can be called the base mesh (i.e. the first model), and the driven mesh is called the Adhere Mesh (i.e. the second model). Fig.12 As shown in the figure, at the initial posture, each point P in the Adhere Mesh has a corresponding triangle in the base mesh (closest to P), and the point P can be represented by the centroid coordinates of the triangle ABC and the distance from the point to the triangle plane (such as Oh1, Oh2, Oh3). If this information is saved, the vertices of the AdhereMesh can be calculated from the vertices of the base mesh at runtime, and the normal of P is also interpolated from the vertex normals of the corresponding triangle.

[0081] During calculation, for each point P in the Adhere Mesh, traverse all triangles in the base mesh, find the triangle ABC closest to point P, draw a perpendicular line from point P to the plane of triangle ABC, and intersect at point O, then O can be expressed as:

[0082]

[0083] remember Then P can be expressed as:

[0084]

[0085] The indices id1, id2, id3 and 1-α-β, α, β, γ of the three points in the triangle corresponding to each point are saved for use at runtime.

[0086] Get the vertex positions and normals of the base mesh after the physical simulation is completed, then the vertices and normals of the Adhere Mesh can be calculated from the base mesh:

[0087]

[0088]

[0089] Where A, B, and C are the vertex coordinates of the triangle corresponding to P.

[0090] In the implementation of AdhereClothGPU, considering that each vertex of Adhere Mesh needs to be calculated in each frame, the amount of calculation is relatively large, so compute shader is used to speed up the calculation process.

[0091] like Fig.13 As shown, all calculations can be put into the OnWillRenderObject function, so that when the cloth is out of view, it does not need to be calculated every frame. In the OnWillRenderObject function, first get the vertices from the cloth and update the compute Buffer (i.e. the target buffer); then call the compute shader to calculate the vertex position and normal of the Adhere Mesh, and finally set the obtained vertex buffer (i.e. coordinates) and normal buffer (i.e. normals) to the material of the Adhere Mesh to replace the original vertices and normals. Using the compute shader to calculate the Adhere Mesh with 4000 vertices, the total time taken by the CPU and GPU is about 0.1ms, which greatly improves the performance.

[0092] Although the calculation speed is faster when using compute shader, in order to use computeBuffer data for rendering, additional modifications need to be made to the shader. In the vertex shader part, vertices and normals are obtained from StructuredBuffer. Some mobile devices do not support this feature, so this solution also implements the Job System version of Adhere Cloth.

[0093] AdhereClothJob uses Job System and Burst Compiler to improve performance. Each Job performs calculations for one Adhere Mesh, and can perform calculations in parallel when there are multiple Adhere Meshes in the scene. Fig.14As shown, in the update phase, the vertices and normals of the base mesh are obtained, and then the Job (such as Job1-Job3) is called for calculation; in the LateUpdate phase, the execution of the Job is waited for to be completed and the calculated vertices and normals are taken out, and the Graphics.DrawMesh interface is called to perform the final rendering.

[0094] Fig.15 The comparison between the application of Adhere Cloth and the direct use of the original model for simulation (ie, cloth) is given. It can be seen that although the solution of the present application is slightly less refined than the original model, Adhere Cloth can still maintain a good simulation effect.

[0095] This application makes a detailed comparison of the runtime efficiency when using cloth directly and Adhere Cloth, such as Fig.16 and Fig.17 As shown, the number of vertices of the cloth here is 2501, and the number of vertices of the low-resolution cloth is 121. The time of AdhereGPU and AdhereJob includes the time of cloth simulation and the calculation time of the add cloth plug-in. First, on the PC platform, AdhereClothGPU and AdhereClothJob have greatly improved compared to cloth, and the time is only about 1 / 5 of that of cloth; when testing on the mobile platform (taking Qualcomm 835 as an example), AdhereClothGPU cannot be used, and only AdhereClothJob can be used, which is also about 50% higher than using cloth directly.

[0096] In the technical solution of this application, the performance issues of Unity cloth in use are tested and optimized, and the Adhere Cloth plug-in in Unity is implemented. The Adhere Cloth plug-in is used to implement the LOD function on the cloth, improve the performance of the actual application of the cloth, and the application effect obtained in the actual project is very good; the current Job System version of AdhereCloth is still relatively time-consuming to use. Considering the efficiency issue, it is best to use a low-resolution cloth model directly when using cloth on a mobile platform. If a high-resolution model must be used, then Adhere Cloth can be used to improve efficiency.

[0097] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0099] According to another aspect of an embodiment of the present application, a virtual object rendering device for implementing the above-mentioned virtual object rendering method is also provided. Fig.18 is a schematic diagram of an optional virtual object rendering device according to an embodiment of the present application, such as Fig.18 As shown, the device may include:

[0100] An acquisition unit 1801 is configured to acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and a patch accuracy of the first model is lower than a patch accuracy of the second model;

[0101] A simulation unit 1803 is used to simulate the first model through a physical engine to determine the target posture of the target object;

[0102] A determining unit 1805 is used to determine the vertex positions of the face patches in the second model using the vertex positions of the face patches in the first model, wherein the vertex positions of the face patches in the first model are the vertex positions of the first model when the first model is in the target posture;

[0103] The rendering unit 1807 is configured to render the target object in the target posture by using the second model.

[0104] It should be noted that the acquisition unit 1801 in this embodiment can be used to execute step S1002 in the embodiment of the present application, the simulation unit 1803 in this embodiment can be used to execute step S1004 in the embodiment of the present application, the determination unit 1805 in this embodiment can be used to execute step S1006 in the embodiment of the present application, and the rendering unit 1807 in this embodiment can be used to execute step S1008 in the embodiment of the present application.

[0105] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Fig. 9 In the hardware environment shown, it can be implemented by software or by hardware.

[0106] Through the above modules, the first model, a low-resolution model, is used for simulation in the simulation stage, and the second model, a high-resolution model, is used for rendering in the rendering stage. For meshes with complex structures that are difficult to simulate, simple models are used for simulation and complex models are used for rendering, rather than always using complex models for simulation and rendering. This reduces the amount of calculation in the physical simulation stage, can solve the technical problem of low data processing efficiency in related technologies, and thereby achieve the technical effect of improving processing efficiency.

[0107] Optionally, the determination unit includes: a first search module, used to search from the first model for a target facet associated with a target vertex in the second model, wherein the target vertex is a vertex in the second model whose vertex position is currently to be determined; and a first determination module, used to determine the vertex position of the target vertex based on an association relationship between the target vertex and the target facet and the vertex positions of all vertices of the target facet.

[0108] Optionally, the target patch is a triangular patch with three vertices, wherein the determination module is further configured to:

[0109] The vertex coordinates P of the target vertex are determined according to the following formula for describing the first relationship: ′ :

[0110] Wherein, A is the coordinate of the first vertex of the triangular patch, B is the coordinate of the second vertex of the triangular patch, C is the coordinate of the third vertex of the triangular patch, α, β, γ are the set parameters, represents the vector from the first vertex to the second vertex, represents the vector from the first vertex to the third vertex, Express Taking the norm, the association relationship includes the first relationship.

[0111] Optionally, the target patch is a triangular patch with three vertices, wherein the determination module is further configured to:

[0112] The vertex normal of the target vertex is determined according to the following formula for describing the second relationship:

[0113] in, represents the vertex normal of the first vertex in the triangle patch, represents the vertex normal of the second vertex in the triangle patch, represents the vertex normal of the third vertex in the triangular face, α, β, γ are set parameters, and the association relationship includes the second relationship.

[0114] Optionally, the determination unit includes: a second search module, used to search for a target vertex in the second model, wherein the target vertex is a vertex in the second model located within a current display area of ​​a target terminal, and the target terminal is used to control objects in the virtual scene; a second determination module, used to call a graphics processor to process the vertex position of the face in the first model to obtain the vertex position of the target vertex in the second model.

[0115] Optionally, the second determination module is also used to: save the vertex positions of the face patches in the first model to a target cache, wherein the target cache is a cache configured for the graphics processor for storing data to be processed; the graphics processor reads the vertex positions of the face patches in the first model from the target cache, and uses the vertex positions of the face patches in the first model to determine the vertex positions of the target vertices in the second model.

[0116] Optionally, the determination unit includes: a third search module, used to search for multiple target vertices in the second model, wherein the target vertex is a vertex in the second model that is located within the current display area of ​​the target terminal; a third determination module, used to call a graphics processor to perform parallel processing on the vertex positions of the facets in the first model to obtain the vertex positions of the multiple target vertices in the second model.

[0117] Optionally, the third determination module is also used to: create multiple first threads in the graphics processor, wherein the number of threads of the multiple first threads is the same as the number of vertices of the multiple target vertices; obtain the vertex positions of the multiple target vertices in the second model by parallel processing the vertex positions of the facets in the first model through the multiple first threads, wherein each thread in the multiple first threads is used to obtain the vertex position of one of the target vertex, and the vertex positions of the target vertices obtained by any two threads in the multiple first threads are different.

[0118] Optionally, the third determination module is also used to: create multiple second threads in the graphics processor, wherein the number of the multiple second threads is less than the number of the multiple target vertices; and perform parallel processing on the vertex positions of the facets in the first model by the multiple second threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each of the multiple second threads is used to obtain the vertex position of at least one of the target vertices, and each of the multiple second threads is used to, after obtaining the vertex position of one of the target vertices, continue processing to obtain the vertex position of another of the target vertices.

[0119] Although the cloth simulation effect in the related art is very good, the efficiency issue is very important in the game, especially for mobile terminals (limited by factors such as volume and battery, the hardware performance is not as good as desktop devices). In order to afford cloth simulation on mobile terminals, according to one aspect of the embodiment of the present application, a method embodiment of a method for rendering a virtual object is provided. The present application provides a set of solutions that have both implementation effect and implementation efficiency. The solution uses a low-precision grid for physical simulation calculations, and then applies dynamic effects to a fine grid model, so that the cloth simulation effect can be added while reducing performance consumption.

[0120] In the technical solution of this application, the performance issues of Unity cloth in use are tested and optimized, and the Adhere Cloth plug-in in Unity is implemented. The Adhere Cloth plug-in is used to implement the LOD function on the cloth, improve the performance of the actual application of the cloth, and the application effect obtained in the actual project is very good; the current Job System version of AdhereCloth is still relatively time-consuming to use. Considering the efficiency issue, it is best to use a low-resolution cloth model directly when using cloth on a mobile platform. If a high-resolution model must be used, then Adhere Cloth can be used to improve efficiency.

[0121] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Fig. 9 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.

[0122] According to another aspect of an embodiment of the present application, a server or terminal for implementing the above-mentioned virtual object rendering method is also provided.

[0123] Fig.19 is a structural block diagram of a terminal according to an embodiment of the present application, such as Fig.19 As shown, the terminal may include: one or more ( Fig.19 (only one is shown) processor 1901, memory 1903, and transmission device 1905, as shown in Fig.19 As shown, the terminal may also include an input and output device 1907 .

[0124] Among them, the memory 1903 can be used to store software programs and modules, such as the program instructions / modules corresponding to the rendering method and device of the virtual object in the embodiment of the present application. The processor 1901 executes various functional applications and data processing by running the software programs and modules stored in the memory 1903, that is, the rendering method of the virtual object described above is realized. The memory 1903 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1903 may further include a memory remotely arranged relative to the processor 1901, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0125] The above-mentioned transmission device 1905 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 1905 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1905 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.

[0126] Specifically, the memory 1903 is used to store application programs.

[0127] The processor 1901 may call the application stored in the memory 1903 through the transmission device 1905 to perform the following steps:

[0128] Acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and a patch accuracy of the first model is lower than a patch accuracy of the second model;

[0129] Simulating the first model through a physical engine to determine a target posture of the target object;

[0130] Determining the vertex positions of the patch in the second model using the vertex positions of the patch in the first model, wherein the vertex positions of the patch in the first model are the vertex positions of the first model when it is in the target posture;

[0131] The target object in the target posture is rendered using the second model.

[0132] The processor 1901 is further configured to execute the following steps:

[0133] Creating a plurality of first threads in the graphics processor, wherein the number of threads of the plurality of first threads is the same as the number of vertices of the plurality of target vertices;

[0134] The vertex positions of the facets in the first model are processed in parallel by the multiple first threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each thread in the multiple first threads is used to obtain the vertex position of one of the target vertices, and the vertex positions of the target vertices obtained by any two threads in the multiple first threads are different.

[0135] The processor 1901 is further configured to execute the following steps:

[0136] Creating a plurality of second threads in the graphics processor, wherein the number of threads of the plurality of second threads is less than the number of vertices of the plurality of target vertices;

[0137] The vertex positions of the facets in the first model are processed in parallel by the multiple second threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each of the multiple second threads is used to obtain the vertex position of at least one of the target vertices, and each of the multiple second threads is used to, after obtaining the vertex position of one of the target vertices, continue processing to obtain the vertex position of another of the target vertices.

[0138] By adopting the embodiment of the present application, a scheme of "obtaining a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and the mesh accuracy of the first model is lower than that of the second model; simulating the first model through a physical engine to determine the target posture of the target object; using the vertex positions of the mesh in the first model to determine the vertex positions of the mesh in the second model, wherein the vertex positions of the mesh in the first model are the vertex positions of the first model when the model is in the target posture; and using the second model to render the target object in the target posture" is provided. In the simulation stage, the first model, a low-resolution model, is used for simulation, and in the rendering stage, the second model, a high-resolution model, is used for rendering. For meshes with complex structures that are difficult to simulate, a simple model is used for simulation and a complex model is used for rendering, rather than always using a complex model for simulation and rendering. This reduces the amount of computation in the physical simulation stage, and can solve the technical problem of low efficiency of data processing in related technologies, thereby achieving the technical effect of improving processing efficiency.

[0139] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0140] It can be understood by those skilled in the art that Fig.19 The structure shown is for illustration only, and the terminal may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Fig.19 It does not limit the structure of the above electronic device. For example, the terminal may also include Fig.19 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Fig.19 Different configurations are shown.

[0141] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0142] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the virtual object rendering method.

[0143] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0144] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0145] Acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and a patch accuracy of the first model is lower than a patch accuracy of the second model;

[0146] Simulating the first model through a physical engine to determine a target posture of the target object;

[0147] Determining the vertex positions of the patch in the second model using the vertex positions of the patch in the first model, wherein the vertex positions of the patch in the first model are the vertex positions of the first model when it is in the target posture;

[0148] The target object in the target posture is rendered using the second model.

[0149] Optionally, the storage medium is further configured to store program codes for executing the following steps:

[0150] Creating a plurality of first threads in the graphics processor, wherein the number of threads of the plurality of first threads is the same as the number of vertices of the plurality of target vertices;

[0151] The vertex positions of the facets in the first model are processed in parallel by the multiple first threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each thread in the multiple first threads is used to obtain the vertex position of one of the target vertices, and the vertex positions of the target vertices obtained by any two threads in the multiple first threads are different.

[0152] Optionally, the storage medium is further configured to store program codes for executing the following steps:

[0153] Creating a plurality of second threads in the graphics processor, wherein the number of threads of the plurality of second threads is less than the number of vertices of the plurality of target vertices;

[0154] The vertex positions of the facets in the first model are processed in parallel by the multiple second threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each of the multiple second threads is used to obtain the vertex position of at least one of the target vertices, and each of the multiple second threads is used to, after obtaining the vertex position of one of the target vertices, continue processing to obtain the vertex position of another of the target vertices.

[0155] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0156] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0157] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0158] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0159] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0160] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0161] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0162] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0163] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for rendering a virtual object, characterized in that: include: Acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and a patch accuracy of the first model is lower than a patch accuracy of the second model; Simulating the first model through a physical engine to determine a target posture of the target object; Determining the vertex positions of the patch in the second model using the vertex positions of the patch in the first model, wherein the vertex positions of the patch in the first model are the vertex positions of the first model when it is in the target posture; Rendering the target object in the target posture using the second model; Among them, using the vertex positions of the facets in the first model to determine the vertex positions of the facets in the second model includes determining the vertex position of each vertex to be confirmed in the second model in the following manner: searching for a target facet associated with a target vertex in the second model from the first model, the target facet being a triangular facet with three vertices, and the target vertex being the vertex of the vertex position to be currently determined in the second model; determining the vertex position of the target vertex based on the association relationship between the target vertex and the target facet and the vertex positions of all vertices of the target facet; and determining the vertex coordinates of the target vertex according to the following formula used to describe the first relationship: Wherein, A is the coordinate of the first vertex of the triangular patch, B is the coordinate of the second vertex of the triangular patch, C is the coordinate of the third vertex of the triangular patch, α, β, γ are the set parameters, represents the vector from the first vertex to the second vertex, represents the vector from the first vertex to the third vertex, Express Take the norm, the association relationship includes the first relationship, and determine the vertex normal of the target vertex according to the following formula for describing the second relationship in, represents the vertex normal of the first vertex in the triangle patch, represents the vertex normal of the second vertex in the triangle patch, represents the vertex normal of the third vertex in the triangular face, α, β, γ are set parameters, and the association relationship includes the second relationship.

2. The method according to claim 1, characterized in that Determining the vertex positions of the face pieces in the second model by using the vertex positions of the face pieces in the first model includes: Searching for a target vertex in the second model, wherein the target vertex is a vertex in the second model that is located in a current display area of ​​a target terminal, and the target terminal is used to control an object in the virtual scene; A graphics processor is called to process the vertex positions of the face pieces in the first model to obtain the vertex positions of the target vertices in the second model.

3. The method according to claim 2, characterized in that Calling a graphics processor to process the vertex positions of the facets in the first model to obtain the vertex positions of the target vertices in the second model includes: Saving the vertex positions of the face pieces in the first model to a target cache, wherein the target cache is a cache configured for the graphics processor for storing data to be processed; The graphics processor reads the vertex positions of the patches in the first model from the target cache, and determines the vertex positions of the target vertices in the second model using the vertex positions of the patches in the first model.

4. The method according to claim 1, characterized in that: Determining the vertex positions of the face pieces in the second model by using the vertex positions of the face pieces in the first model includes: Searching for a plurality of target vertices in the second model, wherein the target vertices are vertices in the second model that are located in a current display area of ​​the target terminal; A graphics processor is called to perform parallel processing on the vertex positions of the facets in the first model to obtain the vertex positions of the plurality of target vertices in the second model.

5. The method according to claim 4, characterized in that Calling a graphics processor to perform parallel processing on the vertex positions of the facets in the first model to obtain the vertex positions of the plurality of target vertices in the second model comprises: Creating a plurality of first threads in the graphics processor, wherein the number of threads of the plurality of first threads is the same as the number of vertices of the plurality of target vertices; The vertex positions of the facets in the first model are processed in parallel by the multiple first threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each thread in the multiple first threads is used to obtain the vertex position of one of the target vertices, and the vertex positions of the target vertices obtained by any two threads in the multiple first threads are different.

6. The method according to claim 4, characterized in that Calling a graphics processor to perform parallel processing on the vertex positions of the facets in the first model to obtain the vertex positions of the plurality of target vertices in the second model comprises: Creating a plurality of second threads in the graphics processor, wherein the number of threads of the plurality of second threads is less than the number of vertices of the plurality of target vertices; The vertex positions of the facets in the first model are processed in parallel by the multiple second threads to obtain the vertex positions of the multiple target vertices in the second model, wherein each thread in the multiple second threads is used to obtain the vertex position of at least one of the target vertices, and the threads in the multiple second threads are used to, after obtaining the vertex position of one of the target vertices, continue processing to obtain the vertex position of another of the target vertices.

7. A virtual object rendering device, characterized in that: include: An acquisition unit, configured to acquire a first model and a second model, wherein the first model and the second model are used to represent a target object in a virtual scene, and a patch accuracy of the first model is lower than a patch accuracy of the second model; A simulation unit, configured to simulate the first model through a physical engine to determine a target posture of the target object; a determining unit, configured to determine the vertex positions of the patch in the second model by using the vertex positions of the patch in the first model, wherein the vertex positions of the patch in the first model are the vertex positions of the first model when the first model is in the target posture; a rendering unit, configured to render the target object in the target posture using the second model; The determining unit includes: a first search module, used to search the target patch associated with the target vertex in the second model from the first model, wherein the target patch is a triangular patch with three vertices, and the target vertex is the vertex of the current vertex position to be determined in the second model; a first determination module, used to determine the vertex position of the target vertex according to the association relationship between the target vertex and the target patch and the vertex positions of all vertices of the target patch; The determination module is further used to determine the vertex coordinates of the target vertex according to the following formula for describing the first relationship: Wherein, A is the coordinate of the first vertex of the triangular patch, B is the coordinate of the second vertex of the triangular patch, C is the coordinate of the third vertex of the triangular patch, α, β, γ are the set parameters, represents the vector from the first vertex to the second vertex, represents the vector from the first vertex to the third vertex, Express Taking the norm, the association relationship includes the first relationship, The determination module is further used to determine the vertex normal of the target vertex according to the following formula for describing the second relationship: in, represents the vertex normal of the first vertex in the triangle patch, represents the vertex normal of the second vertex in the triangle patch, represents the vertex normal of the third vertex in the triangular face, α, β, γ are set parameters, and the association relationship includes the second relationship.

8. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 6 when executed.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the method described in any one of claims 1 to 6 through the computer program.

Citation Information

Patent Citations

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

    CN111028320A