A particle rendering method and apparatus
By using particle state information and depth values to determine particle collisions, the computational load of particle rendering is reduced, improving computational efficiency and realism.
Patent Information
- Application Number
- CN202110600409.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-31
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2041-07-12
AI Technical Summary
Existing particle collision detection methods require a large amount of computation in complex virtual scenes, which cannot meet the real-time requirements.
By acquiring the state information of particles, it is determined whether a collision has occurred. If no collision has occurred, the position is calculated based on the falling time and speed, and the position of the particles that have not collided is directly rendered. If a collision has occurred, the collision position is determined or saved by the depth value, reducing the calculation of particle motion trajectory and scene object position.
It reduces the computational load of particle rendering, improving computational efficiency and realism.
Smart Images

Figure CN115423913B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image rendering technology, and in particular to a particle rendering method and apparatus. Background Technology
[0002] In computer graphics, collision detection mainly refers to whether two or more objects in a virtual scene occupy the same position at the same time. Collision detection has been a focus of attention and research since the advent of computers. With the development of computer technology, people's requirements for the realism of virtual scenes have become increasingly higher, and collision detection is crucial to whether a virtual scene has a sense of realism and immersion.
[0003] One of the main purposes of particle collision detection is to determine the rendering position of particles. For example, for snowflake particles, if a collision is detected between a snowflake particle and the ground in the rendered scene, the snowflake particle needs to be rendered at the point of collision to prevent it from continuing to fall after the collision. If no collision is detected, the snowflake particle needs to be rendered at the position it would have fallen at a set speed. The conventional particle collision detection method calculates the particle's trajectory at each frame without considering other objects in the rendered scene. Then, based on the particle's trajectory and the position information of other objects in the rendered scene, it determines whether the particle has collided with any other object, thus determining the particle's position. However, this method requires calculating the particle's trajectory at each frame and determining the collision based on the trajectory and the position information of other objects. Furthermore, with the development of virtualization technology, the increasing complexity of virtual scenes and the improved detail of objects, the computational load of particle collision detection is becoming increasingly large. Currently, this method can no longer meet the real-time requirements of particle rendering. Summary of the Invention
[0004] In view of this, embodiments of the present disclosure provide a particle rendering method and apparatus for reducing the computational load of particle rendering.
[0005] To achieve the above objectives, the present disclosure provides the following technical solutions:
[0006] In a first aspect, embodiments of this disclosure provide a particle rendering method, including:
[0007] Obtain the state information of the target particle;
[0008] When the state information is a first state information indicating that the target particle has not collided, the falling time of the target particle is obtained;
[0009] The first position is obtained based on the falling time and the falling speed of the target particle;
[0010] The target particle is rendered to the first position.
[0011] As an optional implementation of this disclosure, the method further includes:
[0012] When the state information is second state information indicating that the target particle has collided, the collision time of the target particle is obtained, and the collision time is used to indicate the falling time of the target particle before the collision.
[0013] The second position is obtained based on the collision time and the falling velocity of the target particle;
[0014] The target particle is rendered to the second position.
[0015] As an optional implementation of this disclosure, after obtaining the first position, the method further includes:
[0016] Obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space;
[0017] Determine whether the first depth value is greater than the second depth value;
[0018] If so, the target particle state information is updated to second state information indicating that the target particle has collided, and the falling time is saved as the collision time of the target particle, which indicates the falling time of the target particle before the collision.
[0019] As an optional implementation of this disclosure, the method further includes:
[0020] When the state information is second state information indicating that the target particle has collided, the collision position of the target particle is obtained, and the collision position is used to indicate the position of the target particle when it collided;
[0021] The target particle is rendered to the collision location.
[0022] As an optional implementation of this disclosure, after obtaining the first position, the method further includes:
[0023] Obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space;
[0024] Determine whether the first depth value is greater than the second depth value;
[0025] If so, the target particle state information is updated to second state information indicating that the target particle has collided, and the first position is saved as the collision position of the target particle, which indicates the position of the target particle when it collided.
[0026] As an optional implementation of this disclosure, obtaining the first depth value includes:
[0027] Based on the coordinates of the first position in the local space and the model matrix, obtain the coordinates of the first position in the world space;
[0028] Based on the coordinates of the first position in world space and the observation matrix, obtain the coordinates of the first position in view space;
[0029] Based on the coordinates of the first position in the view space and the projection matrix, obtain the coordinates of the first position in the clipping space;
[0030] The coordinates of the first position in the clipping space are normalized to obtain the coordinates of the first position in the screen space.
[0031] The first depth value is obtained based on the coordinates of the first position in screen space.
[0032] As an optional implementation of this disclosure, the method further includes:
[0033] When the falling time of the target particle reaches the threshold time, the target particle is controlled to return to the initial position, the falling time of the target particle is cleared to zero, and the state information of the target particle is updated to the first state information.
[0034] Secondly, embodiments of this disclosure provide a particle rendering apparatus, comprising:
[0035] The acquisition unit is used to acquire the state information of the target particle.
[0036] The processing unit is configured to obtain the falling time of the target particle when the state information is a first state information indicating that the target particle has not collided.
[0037] A calculation unit is used to obtain a first position based on the falling time and the falling speed of the target particle;
[0038] A rendering unit is used to render the target particle to the first position.
[0039] As an optional implementation of this disclosure, the processing unit is further configured to, when the state information is second state information indicating that the target particle has collided, obtain the collision time of the target particle, wherein the collision time is used to indicate the falling time of the target particle before the collision.
[0040] The computing unit is also used to obtain a second position based on the collision time and the falling speed of the target particle;
[0041] The rendering unit is also used to render the target particle to the second position.
[0042] As an optional implementation of this disclosure, the processing unit is further configured to, after the calculation unit obtains the first position, obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space, determine whether the first depth value is greater than the second depth value, and if so, update the target particle state information to second state information indicating that the target particle has collided, and save the falling time as the collision time of the target particle, wherein the collision time is used to indicate the falling time of the target particle before the collision.
[0043] As an optional implementation of this disclosure, the processing unit is further configured to obtain the collision position of the target particle when the state information is second state information indicating that the target particle has collided, wherein the collision position is used to indicate the position of the target particle when it collides;
[0044] The rendering unit is also used to render the target particle to the collision location.
[0045] As an optional implementation of this disclosure, the processing unit is further configured to, after the calculation unit obtains the first position, obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space, determine whether the first depth value is greater than the second depth value, and if so, update the target particle state information to second state information indicating that the target particle has collided, and save the first position as the collision position of the target particle, wherein the collision position is used to indicate the position of the target particle when it collides.
[0046] As an optional implementation of this disclosure, the processing unit is specifically configured to: obtain the coordinates of the first position in the world space based on the coordinates of the first position in the local space and the model matrix; obtain the coordinates of the first position in the view space based on the coordinates of the first position in the world space and the observation matrix; obtain the coordinates of the first position in the clipping space based on the coordinates of the first position in the view space and the projection matrix; normalize the coordinates of the first position in the clipping space to obtain the coordinates of the first position in the screen space; and obtain the first depth value based on the coordinates of the first position in the screen space.
[0047] As an optional implementation of this disclosure, the processing unit is further configured to control the target particle to return to its initial position, clear the falling time of the target particle to zero, and update the state information of the target particle to the first state information when the falling time of the target particle reaches a threshold time.
[0048] Thirdly, embodiments of this disclosure provide an electronic device, including: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to cause the electronic device to implement the particle rendering method described in any of the above embodiments when executing the computer program.
[0049] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing a computer program that, when executed by a computing device, causes the computing device to implement the particle rendering method described in any of the above embodiments.
[0050] Fifthly, this disclosure provides a computer program product that, when run on a computer, enables the computer to implement the particle rendering method described in any of the above embodiments.
[0051] The particle rendering method provided in this embodiment first obtains the state information of the target particle. If the state information is a first state indicating that the target particle has not collided, the method obtains the falling time of the target particle. Then, based on the falling time and the falling speed of the target particle, it obtains a first position and renders the target particle at the first position. That is, the particle rendering method provided in this embodiment adds state information to the particles and can indicate whether a collision has occurred through the particle's state information. When the state information indicates that a collision has not occurred, the method directly calculates the particle's position based on the falling time and the falling speed, and renders the particle at the calculated position. Since the particle rendering method provided in this embodiment can determine whether a collision has occurred through the particle's state information, it does not need to determine whether a collision has occurred based on the particle's trajectory and the position of objects in the rendered scene at each corresponding moment of each image frame. Therefore, the particle rendering method provided in this embodiment can reduce the computational load of obtaining particle positions, thereby reducing the computational load of particle rendering and improving computational efficiency. Attached Figure Description
[0052] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0053] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 This is one of the flowcharts of the particle rendering method provided in the embodiments of this disclosure;
[0055] Figure 2 This is the second flowchart of the particle rendering method provided in the embodiments of this disclosure;
[0056] Figure 3 The third step of the particle rendering method provided in this embodiment of the disclosure;
[0057] Figure 4 This is a schematic diagram of spatial transformation provided for an embodiment of the present disclosure;
[0058] Figure 5 This is a schematic diagram of the structure of the particle rendering apparatus provided in the embodiments of this disclosure;
[0059] Figure 6 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0060] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0061] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0062] In this disclosure, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in this disclosure should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner. Furthermore, in the description of the embodiments in this disclosure, unless otherwise stated, "a plurality of" means two or more.
[0063] Based on the above, this disclosure provides a particle rendering method, referring to... Figure 1 As shown, the particle rendering method includes the following steps:
[0064] S101. Obtain the state information of the target particle.
[0065] Specifically, the state information in this embodiment is information used to indicate the collision state of particles. The state information in this embodiment includes two types: a first state information indicating that the particles have not collided, and a second state information indicating that the particles have collided.
[0066] For example, the state information of the target particle can be represented by the values carried by a preset number of bits. For instance, the value of one bit can be used as the state information of the target particle. When the value of this bit is 0, it indicates that the target particle has not collided; when the value of this bit is 1, it indicates that the target particle has collided.
[0067] It should be noted that the collision of the target particle can be a collision between the target particle and the ground in the rendered scene, or a collision between the target particle and other objects in the rendered scene. This disclosure does not limit the scope of the collision.
[0068] S102. If the state information is a first state information indicating that the target particle has not collided, obtain the falling time of the target particle.
[0069] For example, the falling time of a target particle can be obtained from the starting falling time and the current time. The starting falling time can be the time when the falling time of the target particle was last reset to zero. For instance, if the last time the falling time of the target particle was reset to zero was t0, and the current time is t1, then the falling time of the target particle is t1 - t0.
[0070] For example, the falling time of the target particle can also be obtained based on the current image frame to be rendered. For instance, if the current image frame to be rendered is the 30th image frame and the image frame refresh rate is 60Hz / s, then the falling time of the particle is 0.5 seconds.
[0071] S103. Obtain the first position based on the falling time and the falling speed of the target particle.
[0072] In this embodiment, the falling speed of the target particle can be preset by the user according to the particle type. It should be noted that the target particle can fall at a preset speed at a constant speed, or it can fall with a preset acceleration and a preset initial speed to accelerate, or it can fall with a preset acceleration and a preset initial speed to decelerate.
[0073] It should be noted that the vertical coordinates of the target particle can only be obtained based on the falling time and the falling speed. To determine the target particle's position in three-dimensional space, its horizontal coordinates are also required. As an optional implementation of this disclosure, obtaining the horizontal coordinates of the target particle can include: obtaining the horizontal coordinates of the target particle based on its initial position coordinates. That is, by controlling the target particle to fall vertically, its horizontal coordinates remain the same as its initial position.
[0074] S104. Render the target particle to the first position.
[0075] The particle rendering method provided in this embodiment first obtains the state information of the target particle. If the state information is a first state indicating that the target particle has not collided, the method obtains the falling time of the target particle. Then, based on the falling time and the falling speed of the target particle, it obtains a first position and renders the target particle at the first position. That is, the particle rendering method provided in this embodiment adds state information to the particles and can indicate whether a collision has occurred through the particle's state information. When the state information indicates that a collision has not occurred, the method directly calculates the particle's position based on the falling time and the falling speed, and renders the particle at the calculated position. Since the particle rendering method provided in this embodiment can determine whether a collision has occurred through the particle's state information, it does not need to determine whether a collision has occurred based on the particle's trajectory and the position of objects in the rendered scene at each corresponding moment of each image frame. Therefore, the particle rendering method provided in this embodiment can reduce the computational load of obtaining particle positions, thereby reducing the computational load of particle rendering and improving computational efficiency.
[0076] This disclosure also provides another particle rendering method, see embodiments thereof. Figure 2 As shown, the particle rendering method includes:
[0077] S201. Obtain the state information of the target particle.
[0078] Similarly, the state information in this embodiment of the present disclosure is information used to indicate the collision state of particles. The state information in this embodiment of the present disclosure includes two types: a first state information indicating that the particles have not collided, and a second state information indicating that the particles have collided.
[0079] S202. Determine whether the target particle has collided based on the state information.
[0080] Specifically, the above step S202 (determining whether the target particle has collided based on the state information) is implemented as follows: when the state information is a first state information indicating that the target particle has not collided, it is determined that the target particle has not collided; when the state information is a second state information indicating that the target particle has collided, it is determined that the target particle has collided.
[0081] If it is determined in step S202 above that the target particle has not collided, then the following steps S203 to S208 are executed.
[0082] S203. Obtain the falling time of the target particle.
[0083] S204. Obtain the first position based on the falling time and the falling speed of the target particle.
[0084] S205. Render the target particle to the first position.
[0085] Please refer to the explanation and implementation of steps S203 to S205 above. Figure 1 The implementation and explanation of steps S102 to S104 in the illustrated embodiment will not be repeated here.
[0086] S206, Obtain the first depth value and the second depth value.
[0087] Wherein, the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space.
[0088] In this embodiment of the disclosure, the depth value of a location is used to characterize the distance of a certain location in the screen space from the camera. For example, the depth value of a first location is used to characterize the distance from the first location in the screen space to the camera.
[0089] In this embodiment of the disclosure, the depth value of the scene corresponding to the location is used to characterize the distance between the rendered scene corresponding to that location and the camera in screen space.
[0090] S207. Determine whether the first depth value is greater than the second depth value.
[0091] In step S207 above, if the first depth value is greater than the second depth value, then step S208 is executed. If the first depth value is less than or equal to the second depth value, then it is determined that the particle has not collided, there is no need to update the state information, the particle continues to fall, and the current rendering process ends.
[0092] S208. Update the target particle state information to the second state information, and save the falling time as the collision time of the target particle.
[0093] The collision time is used to indicate the duration of the target particle's fall before the collision occurs.
[0094] On the one hand, the above embodiments can obtain the depth value of the target particle's location and the scene depth corresponding to the target particle's location, and determine whether the target particle has collided based on the depth value of the target particle's location and the scene depth corresponding to the target particle's location. That is, the above embodiments provide an implementation method for detecting whether a particle has collided based on a depth value. Compared with detecting whether a particle has collided based on the particle's motion trajectory and the position of objects in the rendered scene, detecting whether a particle has collided based on a depth value can reduce the amount of computation when detecting whether a particle has collided.
[0095] On the other hand, since the above embodiments can update the target particle state information to a second state information indicating that the target particle has collided after determining that the target particle has collided, and save the falling time of the target particle as a collision time indicating the falling time of the target particle before the collision, the collision position of the target particle can be directly calculated based on the collision time in the subsequent rendering process, without having to detect whether the target particle has collided and then calculate the collision position of the target particle. Therefore, the above can further reduce the amount of calculation when rendering target particles.
[0096] In step S202 above, if it is determined that the target particle has collided (the state information is a second state information used to indicate that the target particle has collided), then the following steps S209 to S211 are executed.
[0097] S209. Obtain the collision time of the target particle.
[0098] The collision time is used to indicate the duration of the target particle's fall before the collision occurs.
[0099] S210. Obtain the second position based on the collision time and the falling speed of the target particle.
[0100] It should be noted that the second position is the position where the target particle collides.
[0101] Let the collision time be t and the falling velocity of the target particle be u. vel If the second position is pos.y, then the second position pos.y = t * u vel .
[0102] S211. Render the target particle to the second position.
[0103] Since the target particle will remain at the second position after a collision, rendering the target particle at the second position can make the movement of the target particle conform to the movement trajectory of particles in the real world, thereby improving the realism of particle rendering.
[0104] This disclosure also provides another particle rendering method, see embodiments thereof. Figure 3 As shown, the particle rendering method includes:
[0105] S301. Obtain the state information of the target particle.
[0106] S202. Determine whether the target particle has collided based on the state information.
[0107] Specifically, the above step S302 (determining whether the target particle has collided based on the state information) is implemented as follows: when the state information is a first state information indicating that the target particle has not collided, it is determined that the target particle has not collided; when the state information is a second state information indicating that the target particle has collided, it is determined that the target particle has collided.
[0108] In step S302 above, if it is determined that the target particle has not collided (the state information is the first state information), then the following steps S303 to S308 are executed.
[0109] S303. Obtain the falling time of the target particle.
[0110] S304. Obtain the first position based on the falling time and the falling speed of the target particle.
[0111] S305. Render the target particle to the first position.
[0112] Please refer to the implementation methods and explanations of the above steps S303 to S305. Figure 1 The implementation and explanation of steps S102 to S104 in the illustrated embodiment will not be repeated here.
[0113] S306, Obtain the first depth value and the second depth value.
[0114] Wherein, the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space.
[0115] In this embodiment of the disclosure, the depth value of a location is used to characterize the distance of a certain location in the screen space from the camera. For example, the depth value of a first location is used to characterize the distance from the first location in the screen space to the camera.
[0116] In this embodiment of the disclosure, the depth value of the scene corresponding to the location is used to characterize the distance between the rendered background at that location in screen space and the camera.
[0117] S307. Determine whether the first depth value is greater than the second depth value.
[0118] In step S307 above, if the first depth value is greater than the second depth value, then step S308 is executed; if the first depth value is less than or equal to the second depth value, then the current rendering process ends.
[0119] S308. Update the target particle state information to the second state information, and save the first position as the collision position of the target particle.
[0120] The collision location is used to indicate the position of the target particle when it collides with the target particle.
[0121] On the one hand, the above embodiments can obtain the depth value of the target particle's location and the scene depth corresponding to the target particle's location, and determine whether the target particle has collided based on the depth value of the target particle's location and the scene depth corresponding to the target particle's location. That is, the above embodiments provide an implementation method for detecting whether a particle has collided based on a depth value. Compared with detecting whether a particle has collided based on the particle's motion trajectory and the position of objects in the rendered scene, detecting whether a particle has collided based on a depth value can reduce the amount of computation when detecting whether a particle has collided.
[0122] On the other hand, since the above embodiment can save the first position as the collision position to indicate the position of the target particle when it collides after determining that the target particle has collided, the target particle can be rendered directly according to the collision position in the subsequent rendering process. There is no need to judge whether the target particle has collided based on the target particle's motion duration, motion trajectory, etc., nor is there a need to calculate and obtain the collision position of the target particle. Therefore, the above can further reduce the amount of calculation when rendering the target particle.
[0123] In step S302 above, if the state information is a second state information used to indicate that the target particle has collided, then the following steps S309 to S310 are executed.
[0124] S309. Obtain the collision position of the target particle.
[0125] The collision location is used to indicate the position of the target particle when it collides with the target particle.
[0126] S310. Render the target particle to the collision location.
[0127] Since the target particle will remain at the collision location after a collision, rendering the target particle at the collision location can make the movement of the target particle conform to the movement trajectory of particles in the real world, thereby improving the realism of particle rendering.
[0128] Figure 3The illustrated embodiments and Figure 2 The difference in the illustrated embodiment is that, Figure 2 The embodiment shown stores the collision time of the target particle, while Figure 3 The illustrated embodiment stores the collision positions of the target particles. While storing the collision time requires further calculation of the collision position based on the collision time and fall velocity during rendering, the time information data is relatively small and easy to store. Storing the collision positions allows for direct particle rendering based on these positions without additional calculations, but the position information data is larger and requires more storage space. In practical use, the choice can be made based on actual needs. Figure 2 or Figure 3 The particle rendering method provided in the illustrated embodiment is used to render particles.
[0129] As an optional implementation of this disclosure, the above Figure 2 , Figure 3 The implementation of steps S206 / S306 (obtaining the first depth value) in the illustrated embodiment may include the following steps:
[0130] Step a: Obtain the coordinates of the first position in the world space based on the coordinates of the first position in the local space and the model matrix.
[0131] Specifically, in this embodiment, the local space refers to the coordinate space corresponding to the particle model. The world space is the coordinate space used to define the location of each model. The model matrix is a transformation matrix that can place the model in the world space through transformations such as shifting, scaling, and rotating. Therefore, the coordinates of the first position in the world space can be obtained based on the coordinates of the first position in the local space and the model matrix.
[0132] Step b: Obtain the coordinates of the first position in the view space based on the coordinates of the first position in world space and the observation matrix.
[0133] Specifically, view space, also known as camera space, is the result of transforming world space into a coordinate space in front of the user's field of view. Therefore, view space is the coordinate space observed from the camera's perspective. Transforming world space into coordinates in front of the user's field of view is typically accomplished by a combination of translation and rotation transformations. These transformations are usually stored in the view matrix. Therefore, the coordinates of the first position in view space can be obtained based on the first position's coordinates in world space and the view matrix.
[0134] Step c: Obtain the coordinates of the first position in the clipping space based on the coordinates of the first position in the view space and the projection matrix.
[0135] Specifically, at the end of the rendering system's operation, the rendering system expects all points to fall within a specific range. All points outside this range should be clipped out and ignored. The remaining coordinates will become the visible fragments on the screen. The space formed by the visible fragments on the screen is the clipping space in this embodiment of the disclosure. The matrix used to transform the coordinate values in the view space into the coordinate values in the clipping space is called the projection matrix. Therefore, the coordinate values of the first position in the clipping space can be obtained based on the coordinate values of the first position in the view space and the projection matrix.
[0136] Step d: Normalize the coordinates of the first position in the clipping space to obtain the coordinates of the first position in the screen space.
[0137] Step e: Obtain the first depth value based on the coordinates of the first position in screen space.
[0138] That is, refer to Figure 4 As shown, the process of obtaining the first depth value includes: first, converting the local space into world space according to the model matrix; then, converting the world space into view space according to the observation matrix; then, converting the view space into clipping space according to the projection matrix; then, normalizing the clipping space to convert it into screen space; and finally, obtaining the first depth value according to the coordinates of the first position in the screen space.
[0139] As an optional implementation of this disclosure, based on the particle rendering method provided in the above embodiments, the particle rendering method provided in this disclosure further includes:
[0140] When the falling time of the target particle reaches the threshold time, the target particle is controlled to return to the initial position, the falling time of the target particle is cleared to zero, and the state information of the target particle is updated to the first state information.
[0141] That is, the particles fall periodically in the rendered scene at a certain time interval.
[0142] For example, the threshold duration can be 1 minute; every minute, the target particle is controlled to return to its initial position, the falling time of the target particle is reset to zero, and the state information of the target particle is updated to the first state information.
[0143] Based on the same inventive concept, as an implementation of the above method, this disclosure also provides a particle rendering device. This device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this device embodiment will not repeat the details of the aforementioned method embodiment one by one, but it should be clear that the particle rendering device in this embodiment can correspondingly implement all the contents of the aforementioned method embodiment.
[0144] This disclosure provides a particle rendering apparatus. Figure 5 This is a schematic diagram of the particle rendering device, as shown below. Figure 5 As shown, the particle rendering device 500 includes:
[0145] Acquisition unit 51 is used to acquire the state information of the target particle;
[0146] Processing unit 52 is configured to obtain the falling time of the target particle when the state information is a first state information indicating that the target particle has not collided.
[0147] The calculation unit 53 is used to obtain the first position based on the falling time and the falling speed of the target particle;
[0148] The rendering unit 54 is used to render the target particle to the first position.
[0149] As an optional implementation of this disclosure, the processing unit 52 is further configured to, when the state information is second state information indicating that the target particle has collided, obtain the collision time of the target particle, wherein the collision time is used to indicate the falling time of the target particle before the collision.
[0150] The computing unit is also used to obtain a second position based on the collision time and the falling speed of the target particle;
[0151] The rendering unit is also used to render the target particle to the second position.
[0152] As an optional implementation of this disclosure, the processing unit 52 is further configured to, after the calculation unit obtains the first position, obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space, determine whether the first depth value is greater than the second depth value, and if so, update the target particle state information to second state information indicating that the target particle has collided, and save the falling time as the collision time of the target particle, wherein the collision time is used to indicate the falling time of the target particle before the collision.
[0153] As an optional implementation of this disclosure, the processing unit 52 is further configured to obtain the collision position of the target particle when the state information is a second state information indicating that the target particle has collided, wherein the collision position is used to indicate the position of the target particle when it collides.
[0154] The rendering unit is also used to render the target particle to the collision location.
[0155] As an optional implementation of this disclosure, the processing unit 52 is further configured to, after the calculation unit obtains the first position, obtain a first depth value and a second depth value, wherein the first depth value is the depth value of the first position in the screen space, and the second depth value is the depth value of the scene corresponding to the first position in the screen space, determine whether the first depth value is greater than the second depth value, and if so, update the target particle state information to second state information indicating that the target particle has collided, and save the first position as the collision position of the target particle, wherein the collision position is used to indicate the position of the target particle when it collides.
[0156] As an optional implementation of this disclosure, the processing unit 52 is specifically configured to: obtain the coordinates of the first position in the world space based on the coordinates of the first position in the local space and the model matrix; obtain the coordinates of the first position in the view space based on the coordinates of the first position in the world space and the observation matrix; obtain the coordinates of the first position in the clipping space based on the coordinates of the first position in the view space and the projection matrix; normalize the coordinates of the first position in the clipping space to obtain the coordinates of the first position in the screen space; and obtain the first depth value based on the coordinates of the first position in the screen space.
[0157] As an optional implementation of this disclosure, the processing unit 52 is further configured to control the target particle to return to its initial position, clear the falling time of the target particle to zero, and update the state information of the target particle to the first state information when the falling time of the target particle reaches a threshold time.
[0158] Based on the same inventive concept, this disclosure also provides an electronic device. Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this disclosure, such as... Figure 6 As shown, the electronic device provided in this embodiment includes a memory 61 and a processor 62. The memory 61 is used to store a computer program; the processor 62 is used to enable the electronic device to implement the particle rendering method provided in the above embodiment when executing the computer program.
[0159] This disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a computing device, causes the computing device to implement the particle rendering method provided in the above embodiments.
[0160] This disclosure also provides a computer program product that, when run on a computer, enables the computer to implement the particle rendering method provided in the above embodiments.
[0161] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media containing computer-usable program code.
[0162] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0163] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0164] Computer-readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media can store information using any method or technology; the information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this disclosure.
Claims
1. A method of particle rendering, characterized by, The method comprises: acquiring state information of a target particle; in a case where the state information is first state information indicating that the target particle has not collided, acquiring a falling duration of the target particle; the collision of the target particle includes collision of the target particle with a ground in a rendering scene and collision of the target particle with other objects in the rendering scene; acquiring a first position according to the falling duration and a falling speed of the target particle; rendering the target particle to the first position; acquiring a first depth value and a second depth value; the first depth value is a depth value of the first position in a screen space, and the second depth value is a depth value of a scene corresponding to the first position in the screen space; determining whether the first depth value is greater than the second depth value; if yes, modifying the state information of the target particle to second state information indicating that the target particle has collided, and saving the first position as a collision position of the target particle, the collision position indicating a position of the target particle when the collision occurs.
2. The method of claim 1, wherein, The method further comprises: in a case where the state information is second state information indicating that the target particle has collided, acquiring a collision time of the target particle, the collision time indicating a falling duration of the target particle before the collision; acquiring a second position according to the collision time and the falling speed of the target particle; rendering the target particle to the second position.
3. The method of claim 1, wherein, After acquiring the first position, the method further comprises: acquiring a first depth value and a second depth value; the first depth value is a depth value of the first position in a screen space, and the second depth value is a depth value of a scene corresponding to the first position in the screen space; determining whether the first depth value is greater than the second depth value; if yes, modifying the state information of the target particle to second state information indicating that the target particle has collided, and saving the falling duration as a collision time of the target particle, the collision time indicating a falling duration of the target particle before the collision.
4. The method of claim 1, wherein, The method further comprises: in a case where the state information is second state information indicating that the target particle has collided, acquiring a collision position of the target particle, the collision position indicating a position of the target particle when the collision occurs; rendering the target particle to the collision position.
5. The method according to claim 1 or 3, characterized in that, The acquiring of the first depth value comprises: acquiring a coordinate value of the first position in a world space according to a coordinate value of the first position in a local space and a model matrix; acquiring a coordinate value of the first position in a view space according to the coordinate value of the first position in the world space and a view matrix; acquiring a coordinate value of the first position in a clip space according to the coordinate value of the first position in the view space and a projection matrix; performing normalization processing on the coordinate value of the first position in the clip space to acquire a coordinate value of the first position in a screen space; acquiring the first depth value according to the coordinate value of the first position in the screen space.
6. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: When the falling time length of the target particle reaches a threshold time length, the target particle is controlled to return to an initial position, the falling time length of the target particle is cleared, and state information of the target particle is updated to the first state information.
7. A particle rendering apparatus, characterized by comprising: The method comprises the following steps: An acquisition unit is configured to acquire state information of a target particle. A processing unit is configured to acquire a falling time length of the target particle when the state information is first state information indicating that the target particle has not collided. A calculation unit is configured to acquire a first position according to the falling time length and a falling speed of the target particle. A rendering unit is configured to render the target particle to the first position. The processing unit is further configured to acquire a first depth value and a second depth value after the calculation unit acquires the first position, the first depth value being a depth value of the first position in a screen space, the second depth value being a depth value of a scene corresponding to the first position in the screen space, judge whether the first depth value is greater than the second depth value, if yes, update the state information of the target particle to second state information indicating that the target particle has collided, and save the first position as a collision position of the target particle, the collision position being used to indicate a position of the target particle when the target particle collides.
8. An electronic device, comprising: The method comprises the following steps: A memory and a processor, the memory is configured to store a computer program; the processor is configured to execute the computer program, so that the electronic device implements the particle rendering method in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, when the computer program is executed by a computing device, the computing device implements the particle rendering method in any one of claims 1-6.
10. A computer program product, characterised in that, When the computer program product runs on the computer, the computer implements the particle rendering method in any one of claims 1-6.
Citation Information
Patent Citations
Particle system-based global rainfall effect simulation method
CN107886574A