Particle special effect display method, electronic device, and computer-readable storage medium
By associating particle position information with a unit scene space, particle effects are displayed based on the unit scene space within the field of view, solving the problem of excessive load during particle effect rendering and achieving more efficient rendering and detection.
Patent Information
- Application Number
- PCT/CN2025/144932
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-08
- Filing Date
- 2025-12-23
- Publication Date
- 2026-11-12
AI Technical Summary
Particle effects can cause excessive device load during rendering, and the large number of particles in existing technologies leads to excessive load on detection and rendering.
By associating particle position information with a unit scene space, particle effects are displayed based on the unit scene space within the field of view, reducing the rendering and detection load.
It significantly reduces the workload of particle rendering and detection, and improves rendering efficiency.
Smart Images

Figure CN2025144932_12112026_PF_FP_ABST
Abstract
Description
Particle effects display methods, electronic devices and computer-readable storage media
[0001] This application claims priority to Chinese patent application filed on May 8, 2025, with application number 202510591739.2 and entitled "Particle Effect Display Method, Electronic Device and Computer-Readable Storage Medium", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of terminal technology, and in particular to a particle effect display method, electronic device, and computer-readable storage medium. Background Technology
[0003] Particle effects are a technique that simulates the movement of a large number of tiny particles to represent natural phenomena or special visual effects. Currently, to enhance the aesthetics of the user interface (UI) and improve the user experience, more and more products are adopting particle effects. However, particle effects involve a large number of particles, thus placing a significant load on the device when rendering them. Summary of the Invention
[0004] Based on the above research, this application provides a particle effect display method, an electronic device, and a computer-readable storage medium, which can reduce the load during particle rendering.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] Firstly, a method for displaying particle effects is provided. The method further includes: responding to a particle effect rendering instruction, displaying a frame containing particle effects; the frame is one of a series of consecutive frames, and each frame in the series includes particle effects corresponding to visible particles. Specifically, the visible particles corresponding to each frame are a subset of the multiple particles corresponding to each frame that are to be rendered; visible particles refer to particles located within a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of the multiple particles, and the position information of each particle among the multiple particles is related to the unit scene space it is located in.
[0007] The solution provided in the first aspect above associates particle position information with a unit scene space and displays the image, including particle effects, based on the particles within that unit scene space within the field of view. This significantly reduces the number of particles that need to be rendered when creating particle effects, thereby reducing the workload of particle rendering. Furthermore, determining whether a particle is within the field of view based on the unit scene space also reduces the detection workload.
[0008] As an example, a unit scene space can be a cube with a set side length.
[0009] As an example, a unit scene space within the field of view can be detected using the visual cone.
[0010] As an example, the relationship between the position information of each particle in a group of particles and the unit scene space refers to the correlation between the position information of each particle and the unit scene space in which each particle is located. For each particle in a group of particles, the unit scene space in which each particle is located can be determined based on its position information.
[0011] As one possible implementation, before displaying a frame including particle effects, the method further includes: obtaining the indices of visible particles among multiple particles corresponding to a frame; each particle among multiple particles corresponding to a frame having a unique index; obtaining target attribute data of the visible particles from the particle memory space based on the indexes of the visible particles; and drawing the visible particles based on the target attribute data of the visible particles; wherein the particle memory space stores the target attribute data of each particle among multiple particles corresponding to a frame, and the target attribute data of each particle among multiple particles includes position information. Thus, by identifying particles by index, the attribute data of particles in the particle memory space does not need to be culled, thereby eliminating the need to create new memory space and avoiding the situation of constantly re-allocating vertex buffers and copying large amounts of data due to culling, further reducing the load.
[0012] As an example, particle memory space could be a vertex buffer.
[0013] As one possible implementation, the indexes of visible particles are stored in an index memory space. In this way, the electronic device can retrieve the indexes of visible particles from the index memory space, and based on these indexes, obtain the target attribute data of the visible particles from the particle memory space to render the particles. This avoids the need to constantly re-allocate vertex buffers and copy large amounts of data due to culling, further reducing the workload.
[0014] As one possible implementation, before displaying a frame including particle effects, the method further includes: creating an index for each of the multiple particles corresponding to a frame; creating an index memory space; storing the index of each particle in the multiple particles into the index memory space; and removing the indices of invisible particles from the index memory space; wherein the invisible particles are located outside the field of view in the unit scene space. Thus, by removing the indices of invisible particles outside the field of view, there is no need to remove the target attribute data of the particles, avoiding the need for continuous re-allocation of vertex buffers and large data copying due to removal, further reducing the load.
[0015] As one possible implementation, before displaying a frame including particle effects, the method further includes: acquiring the position information of each particle among multiple particles corresponding to a frame; determining the unit scene space where each particle is located based on the position information of each particle among multiple particles; and determining that each particle is a visible particle if its unit scene space is within the field of view. Thus, by dividing particles into unit scene spaces and calculating the unit scene space within the field of view, all particles within the field of view can be obtained, thereby enabling the rendering of particles within the field of view. This significantly reduces the number of particles to render and lowers the particle rendering load.
[0016] As one possible implementation, the method further includes: uniformly dividing the scene space of multiple particles corresponding to a frame to obtain multiple unit scene spaces; determining the unit scene space where each particle in the multiple particles is located based on the position information of each particle in the multiple particles, including: obtaining the unit scene space where each particle in the multiple particles is located based on the position information of each particle in the multiple particles and the side length of the unit scene space. Thus, by dividing the particles into unit scene spaces according to space and calculating the unit scene spaces within the field of view, all particles within the field of view can be obtained, thereby rendering the particles within the field of view. This can significantly reduce the number of particles to be rendered and reduce the particle rendering load.
[0017] As one possible implementation, obtaining the position information of each particle among multiple particles corresponding to a single frame includes: obtaining the initial attribute information of each particle, including the initial position and velocity of the particle in a single frame; and obtaining the position information of each particle based on its initial position and velocity. Thus, by determining the particle's position information through its initial position and velocity, and then determining the unit scene space in which the particle is located based on its position information, the accuracy of detection can be improved.
[0018] As an example, the particle's position information could be the particle's initial position in the next frame adjacent to a previous frame.
[0019] Secondly, a particle effect display method is provided, the method further comprising: displaying a first frame in response to a first particle effect rendering instruction; wherein the first frame includes particle effects corresponding to visible particles, and visible particles refer to particles located within a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of multiple particles, and the position information of each particle among the multiple particles is associated with the unit scene space; updating the unit scene space where each particle among the multiple particles is located according to the position information and movement speed of the multiple particles corresponding to the first frame; updating the visible particles in the unit scene space within the field of view; and displaying a second frame in response to a second particle effect rendering instruction; the second frame includes the updated particle effects of the visible particles.
[0020] The solution provided in the second aspect above associates particle position information with a unit scene space and displays the image, including particle effects, based on the particles within that unit scene space within the field of view. This significantly reduces the number of particles that need to be rendered when creating particle effects, thereby reducing the workload of particle rendering. Furthermore, determining whether a particle is within the field of view based on the unit scene space also reduces the detection workload.
[0021] As one possible implementation, based on the position information and motion speed of multiple particles corresponding to the first frame, the unit scene space in which each particle is located is updated. This includes: updating the position information of each particle based on its position information and motion speed; and updating the unit scene space in which each particle is located based on its updated position information. Thus, by updating the particle position information and then updating the unit scene space in which the particles are located based on their updated position information, the unit scene space in which the particles are located in each frame can be accurately obtained. Therefore, for each frame, rendering can be performed based on the particles within the unit scene space of the field of view, reducing the workload of particle rendering.
[0022] As one possible implementation, the method further includes: uniformly dividing the scene space of multiple particles to obtain multiple unit scene spaces; updating the unit scene space of each particle in the multiple particles according to the updated position information of each particle, including: updating the unit scene space of each particle in the multiple particles according to the updated position information of each particle and the side length of the unit scene space. Thus, by updating the unit scene space of the particles according to their updated position information, the unit scene space in which the particles are located in each frame can be accurately obtained. Therefore, for each frame, rendering can be performed based on the particles in the unit scene space within the field of view, reducing the workload of particle rendering.
[0023] As one possible implementation, updating the visible particles within a unit scene space within the field of view includes: updating the visible particles within a unit scene space within the field of view based on the updated position information of each particle. Thus, by updating the position information of particles and updating the visible particles within a unit scene space within the field of view, rendering can be performed for each frame based on the particles within the unit scene space within the field of view, reducing the workload of particle rendering.
[0024] Thirdly, a particle effect display device is provided. The device includes an effect display module, which is used to: display a frame containing particle effects in response to a particle effect rendering command; a frame is one of a series of frames, and each frame in the series includes particle effects corresponding to visible particles. The visible particles corresponding to each frame are a subset of the multiple particles in each frame that are to be rendered. Visible particles refer to particles located within a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of the multiple particles; and the position information of each particle in the multiple particles is associated with the unit scene space.
[0025] As one possible implementation, the particle effects display device further includes a particle rendering module. Before displaying a frame containing particle effects, the particle rendering module is used to: obtain the indices of visible particles among multiple particles corresponding to a frame; each particle among multiple particles corresponding to a frame has a unique index; obtain target attribute data of the visible particles from the particle memory space according to the index of the visible particles; and render the visible particles according to the target attribute data of the visible particles; wherein, the particle memory space stores the target attribute data of each particle among multiple particles included in a frame, and the target attribute data of each particle among multiple particles includes position information.
[0026] As one possible implementation, the index of the visible particles is stored in the index memory space.
[0027] As one possible implementation, the particle effects display device also includes a data preparation module and a particle space calculation module. Before displaying a frame containing particle effects, the data preparation module is used to: create an index for each of the multiple particles corresponding to a frame; create an index memory space; and store the index of each of the multiple particles into the index memory space. The particle space calculation module is used to remove the indices of invisible particles from the index memory space; wherein, the unit scene space where invisible particles are located is outside the field of view.
[0028] As one possible implementation, before displaying a frame containing particle effects, the particle space calculation module is further configured to: obtain the position information of each particle among multiple particles corresponding to a frame; determine the unit scene space in which each particle is located based on the position information of each particle among multiple particles; and for each particle, if the unit scene space in which the particle is located is within the field of view, the particle is a visible particle.
[0029] As one possible implementation, the particle space calculation module is specifically used to: uniformly divide the scene space of multiple particles corresponding to a frame to obtain multiple unit scene spaces; and obtain the unit scene space in which each particle is located based on the position information of each particle in the multiple particles and the side length of the unit scene space.
[0030] As one possible implementation, the particle effects display device also includes a particle calculation module, which is used to: obtain the initial attribute information of each particle in the multiple particles, including the initial position and movement speed of the particle in a frame; and obtain the position information of each particle in the multiple particles based on the initial position and movement speed of each particle in the multiple particles.
[0031] The beneficial effects of the solution provided in the third aspect described above can be found in the description of any embodiment in the first aspect, and will not be repeated here. The controller has the function of implementing the behavior in the method examples of any embodiment in the first aspect described above. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0032] Fourthly, a particle effects display device is provided, comprising an effects display module and a particle space calculation module. The effects display module is used to: display a first frame in response to a first particle effects rendering instruction; wherein the first frame includes particle effects corresponding to visible particles, and visible particles refer to particles located within a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of multiple particles, and the position information of each particle among the multiple particles is associated with the unit scene space. The particle space calculation module is used to: update the unit scene space where each particle among the multiple particles is located based on the position information and movement speed of the multiple particles corresponding to the first frame; and update the visible particles within the unit scene space within the field of view. The effects display module is used to: display a second frame in response to a second particle effects rendering instruction; the second frame includes the updated particle effects of the visible particles.
[0033] As one possible implementation, the particle space calculation module is specifically used to: update the position information of each particle in the multiple particles based on the position information and motion velocity of each particle in the multiple particles; and update the unit scene space in which each particle in the multiple particles is located based on the updated position information of each particle in the multiple particles.
[0034] As one possible implementation, the particle space calculation module is specifically used to: uniformly divide the scene space of multiple particles to obtain multiple unit scene spaces; and update the unit scene space in which each particle is located based on the updated position information of each particle in the multiple particles and the side length of the unit scene space.
[0035] As one possible implementation, the particle space calculation module is specifically used to: update the visible particles in the unit scene space within the field of view based on the unit scene space where each particle is located after updating its position information.
[0036] The beneficial effects of the solution provided in the fourth aspect above can be found in the description of any embodiment in the second aspect, and will not be repeated here. The controller has the function of implementing the behavior in the method example of any embodiment in the second aspect above. This function can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0037] A fifth aspect provides an electronic device, comprising: a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the electronic device in implementing a method as described in any possible implementation of the first aspect or a method as described in any possible implementation of the second aspect.
[0038] In a sixth aspect, a computer-readable storage medium is provided, on which computer program instructions are stored, which, when executed by a processing circuit, implement a method as described in any possible implementation of the first aspect or a method as described in any possible implementation of the second aspect.
[0039] In a seventh aspect, a computer program product comprising instructions is provided, which, when run on a computer, causes the computer to perform a method as described in any possible implementation of the first aspect or a method as described in any possible implementation of the second aspect. Attached Figure Description
[0040] Figure 1 is one of the flowcharts for creating particle effects using conventional techniques;
[0041] Figure 2 is a schematic diagram of particles within the field of view provided in an embodiment of this application;
[0042] Figure 3 is the second schematic diagram of the process of creating particle effects using conventional techniques;
[0043] Figure 4 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application;
[0044] Figure 5 is one of the flowcharts of the particle effect display method provided in the embodiments of this application;
[0045] Figure 6 is a schematic diagram of the division of a unit scene space provided in an embodiment of this application;
[0046] Figure 7 is a schematic diagram of the positional relationship between particles and unit scene space provided in the embodiments of this application;
[0047] Figure 8 is a schematic diagram of a unit scene space within the field of view provided in an embodiment of this application;
[0048] Figure 9 is one of the schematic diagrams of the particle effect display method provided in the embodiments of this application;
[0049] Figure 10 is a second schematic flowchart of the particle effect display method provided in the embodiments of this application;
[0050] Figure 11 is a schematic diagram of the index set of visible particles in a unit scene space within the field of view provided in an embodiment of this application;
[0051] Figure 12 is a second schematic diagram of the principle of the particle effect display method provided in the embodiments of this application;
[0052] Figure 13 is a schematic diagram of the principle of the particle effect display method provided in the embodiment of this application;
[0053] Figure 14 is a third schematic flowchart of the particle effect display method provided in the embodiments of this application;
[0054] Figure 15 is a schematic diagram of the functional modules of the particle effect display device provided in the embodiment of this application. Detailed Implementation
[0055] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0056] In the description of the embodiments of this application, unless otherwise stated, " / " means "or", for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0057] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.
[0058] Furthermore, in the embodiments of this application, words such as "exemplarily" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the term "exemplary" is intended to present concepts in a concrete manner.
[0059] Particle effects are a technique that simulates the movement of a large number of tiny particles to represent natural phenomena or special visual effects. In particle effects, each particle can move and change according to certain rules and algorithms, thereby simulating various natural phenomena or special visual effects.
[0060] Currently, particle effects are mostly rendered using two methods. The first method is explained below. As shown in Figure 1, the device rendering particle effects first prepares the particle data, i.e., obtains the attribute data of the particles to be rendered. Then, the particle attribute data is input into a shader storage buffer object (SSBO) for storage. Next, particle calculations are performed, and the attribute data of the particles to be rendered is updated in the SSBO based on the calculation results. After updating the attribute data of the particles to be rendered, the device can output the updated attribute data of the particles to be rendered in the SSBO and perform format conversion. After format conversion, the converted attribute data can be stored in the vertex buffer. Then, the device, such as the graphics processing unit (GPU), can read the attribute data from the vertex buffer and render each particle according to the attribute data to obtain the particle effect. However, since particle effects involve a large number of particles, rendering each particle individually would place a significant load on the GPU.
[0061] The second method will be explained below. As shown in Figure 2, after updating the particle attribute data, the device that renders particle effects checks whether the particles are within the field of view based on the particle attribute data, and removes the attribute data of particles outside the field of view. However, this method of checking whether each particle is within the field of view can lead to a large workload due to the large number of particles.
[0062] In addition, as shown in Figure 3, after the device for rendering particle effects removes the attribute data of particles outside the field of view (such as removing the attribute data of particle 2), the device needs to create a new vertex buffer, and then copy the attribute data of particles within the field of view from SSBO to the newly created vertex buffer in order to facilitate particle rendering.
[0063] Because the number of particles drawn is different from the number of particles in the data preparation stage after removing the attribute data of particles outside the field of view, a vertex buffer needs to be created for each frame, and the attribute data of particles within the field of view is copied to the newly created vertex buffer.
[0064] The creation of vertex buffers and data copying incur additional overhead, resulting in a higher workload for particle rendering.
[0065] Based on the above research, this application provides a particle effect display method. By associating particle position information with a unit scene space and displaying a screen including particle effects based on particles within the unit scene space within the field of view, the number of particles that need to be drawn can be significantly reduced when drawing particle effects, thereby reducing the workload of particle drawing. In addition, this application also reduces the detection workload by detecting whether particles are within the field of view based on the unit scene space.
[0066] The particle effect display method provided in this application identifies particles by index and obtains attribute data from the vertex cache by index, eliminating the need to remove particle attribute data, thereby avoiding memory creation and data copying caused by particle removal and further reducing the load.
[0067] As an example, the particle effect display method provided in this application embodiment can be used to draw special effects scenes such as fire, smoke, water flow, sparks, falling leaves, clouds, fog, snow, dust, meteor trails or light trails.
[0068] The particle effect display method provided in this application can be applied to electronic devices. In some examples, the electronic device can be a terminal. The terminal can be a mobile phone, tablet computer, watch, computer, virtual reality (VR) terminal device, augmented reality (AR) terminal device, etc.
[0069] To facilitate understanding of the particle effect display method provided in this application embodiment, the structure of the electronic device will be described below. Please refer to Figure 4, which is a schematic diagram of the structure of an electronic device provided in this application embodiment. As shown in Figure 4, the electronic device 400 may include a processor 410, a memory 420, a display screen 430, and a sensor module 440.
[0070] Processor 410 may include one or more processing units, such as a central processing unit (CPU), an application processor (AP), a modem processor, a GPU, an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.
[0071] The controller can be the nerve center and command center of the electronic device 400. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0072] The processor 410 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 410 is a cache memory. This memory can store instructions or data that the processor 410 has just used or that are used repeatedly. If the processor 410 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 410, and thus improves the efficiency of the system.
[0073] The memory 420 can be used to store computer executable program code, which includes instructions. The processor 410 executes various functional applications and data processing of the electronic device 400 by running the instructions stored in the memory 420. The memory 420 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of the electronic device 400 (such as audio data, image data, etc.). Furthermore, the memory 420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0074] As an example, the particle effect display method provided in this application embodiment can be pre-loaded into the memory 420 in the form of a computer program product, and the processor 410 can execute the instructions in the memory 420 to implement the steps of the particle effect display method provided in this application embodiment.
[0075] Electronic device 400 implements display functions through a GPU, display screen 430, and application processor. The GPU is a microprocessor for image processing, connecting the display screen 430 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 410 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0076] The display screen 430 is used to display images, videos, etc. The display screen 430 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 400 may include one or N display screens 430, where N is a positive integer greater than 1.
[0077] In this embodiment, the electronic device 400 can draw particle effects using a GPU and display the particle effects using a display screen 430.
[0078] In this embodiment, the sensor module 440 may include a pressure sensor and a touch sensor. The pressure sensor senses pressure signals and converts them into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 430. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may consist of at least two parallel plates with conductive material. When force is applied to the pressure sensor, the capacitance between the electrodes changes. The electronic device 400 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to the display screen 430, the electronic device 400 detects the intensity of the touch operation based on the pressure sensor. The electronic device 400 may also calculate the touch position based on the detection signal from the pressure sensor. In some embodiments, touch operations at the same touch position but with different intensities may correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.
[0079] A touch sensor, also known as a "touch panel," can be located on the display screen 430. The touch sensor and the display screen 430 together form a touchscreen, also called a "touch screen." The touch sensor detects touch operations applied to or near it. The touch sensor can then transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 430. In some embodiments, the touch sensor may also be located on the surface of the electronic device 400, in a different position than the display screen 430.
[0080] As an example, electronic device 400 can detect user triggering operations on display screen 430 for particle effects via pressure sensors and touch sensors, thereby triggering the rendering of particle effects.
[0081] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 400. In other embodiments of this application, the electronic device 400 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0082] The electronic device 400 provided in this application embodiment can run an operating system (OS). This operating system can be various operating systems used in industry, such as operating systems developed based on OpenHarmony, like HarmonyOS; or other operating systems such as Android™, iOS mobile operating systems; it can also be various open-source operating systems or their derivatives, such as Linux OS, and other embedded operating systems; or it can be a future new operating system, such as an AI operating system based on artificial intelligence. An operating system is a set of interconnected system software programs that manage and control the operation of electronic devices, utilize and run hardware and software resources, and provide public services to organize user interaction. In electronic devices, the operating system connects downwards to the physical devices at the hardware layer and provides a runtime environment for application software upwards.
[0083] An operating system typically includes: a kernel layer, a system service layer, a framework layer, and an application layer.
[0084] The application layer includes applications, which can include system applications and third-party applications.
[0085] As an example, an electronic device can run an application, receive a particle effect activation command triggered by the application, and draw particle effects according to the particle effect activation command.
[0086] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The framework layer includes: the ArkUI framework (which provides a complete infrastructure for UI development of system applications, including UI functions such as components, layouts, animations, and interactive events, as well as a real-time interface preview tool), the user application framework, and the Ability framework (an Ability is a lightweight application; the Ability framework schedules and manages the operation and lifecycle of Abilities). Different devices may have different operating systems, and the APIs they support may also differ.
[0087] The system service layer comprises the core capabilities of the system, providing services to applications through the framework layer. For example, the system service layer may include a graphics subsystem. This graphics subsystem primarily includes modules such as UI components, layout, animation, fonts, input events, window management, and rendering. The graphics subsystem provides graphics rendering and display output functions, and internally, through the rational utilization of system hardware resources, it provides a smooth and efficient display experience for the system.
[0088] As an example, electronic devices can use the functions provided by the graphics subsystem to render particle effects.
[0089] The kernel layer is the layer between hardware and software. It can include hardware drivers and the operating system kernel. In addition to providing hardware drivers, the kernel layer also supports functions such as memory management and system process management.
[0090] Because electronic devices vary greatly in type and form, and are used in a wide range of scenarios, the operating systems used in these devices may differ depending on their form and function, application scenarios, and user needs. The basic functions implemented by the electronic device provided in this application can be achieved using either a general-purpose operating system or a dedicated operating system; no specific limitation is imposed.
[0091] The particle effect display method provided in this application embodiment will be specifically described below with a concrete example. Please refer to Figure 5, which is one of the schematic flowcharts of the particle effect display method provided in this application embodiment. The method shown in Figure 5 can be applied to the electronic device shown in Figure 4. As shown in Figure 5, the particle effect display method provided in this application embodiment may include S501 to S506.
[0092] S501, the electronic device responds to the particle effect activation command and obtains the particle effect data of the current scene to be drawn. The particle effect data includes the initial attribute data of multiple particles.
[0093] In some examples, a particle effect activation command refers to an instruction that triggers an electronic device to run the particle effect rendering process. After receiving the particle effect activation command, the electronic device can respond to the command and begin rendering the particle effect.
[0094] As an example, a particle effect activation command can be a user-issued action to trigger a particle effect.
[0095] User actions that trigger particle effects can be actions taken on elements currently displayed on the electronic device that trigger particle effects. These elements can be icons, text, animated elements, etc., with no specific restrictions.
[0096] For example, using icons as an example, electronic devices can display icons that trigger particle effects on their screens. Users can interact with these icons to trigger particle effect activation commands. In this way, the electronic device can receive particle effect activation commands.
[0097] As another example, particle effect activation commands can be sent by applications running on the electronic device or issued by the device's system processes. For instance, if an electronic device is running a game application that needs to display particle effects, such as glowing trails, the game application can trigger a particle effect activation command. Similarly, if an electronic device needs to display a boot animation, the boot process can trigger a particle effect activation command.
[0098] It is understood that the above is merely an example of the instructions for triggering particle effects in this application and is not intended to be a specific limitation.
[0099] As an example, upon receiving a particle effect activation command, an electronic device can respond by acquiring particle effect data and rendering the particle effect based on that data. Since a particle effect is a dynamic effect that requires multiple consecutive frames to be displayed, the particle effect data acquired by the electronic device can be the particle effect data of the current frame to be rendered. This current frame can be any one of the multiple consecutive frames. In some examples, the electronic device can also acquire particle effect data from multiple consecutive frames. There are no specific limitations.
[0100] In the embodiments of this application, the particle effect data for different frames may be different. In some examples, the particle effect data for different frames may also be the same; there is no specific limitation.
[0101] The following explanation uses only one frame as an example. The particle rendering for the remaining frames can be referenced from the description of this frame, and will not be repeated below.
[0102] In this embodiment of the application, the particle effect data of the current scene to be drawn includes the initial attribute data of multiple particles corresponding to the current scene to be drawn. The initial attribute data of the particles refers to their original attribute values.
[0103] As an example, the initial attribute data of a particle may include information such as the particle's initial position, velocity, initial color, and initial transparency.
[0104] S502, the electronic device determines the target attribute data of each of the multiple particles corresponding to the current scene to be drawn, wherein the target attribute data includes the position information of the particle.
[0105] In some examples, the particle's target attribute data refers to the particle's target attribute value relative to the current scene to be drawn.
[0106] In this embodiment, the target attribute data of the particle includes at least the particle's position information. Specifically, the particle's position information can be the particle's target position at the end of the display time of the current frame to be drawn.
[0107] Since particle effects are dynamic effects, they need to be presented through multiple consecutive frames. Therefore, in some examples, the target position of the particle at the end of the display time of the current frame to be drawn can be the initial position of the particle in the next frame adjacent to the current frame to be drawn. That is, the particle's position information can be the initial position of the particle in the next frame adjacent to the current frame to be drawn. In this way, the movement and changes of the particles can be presented through multiple frames.
[0108] In some examples, target attribute data may also include the target color and target transparency of the particle in the current drawing frame.
[0109] In the embodiments of this application, the electronic device can determine the target attribute data of each particle based on the initial attribute data of each particle.
[0110] For example, an electronic device can obtain the position information of each particle based on its initial position and velocity. This position information can be obtained using the formula x′. n =x n +v×Δt yields the position information of each particle.
[0111] Where, x′ n This represents the position information of the nth particle. n Let v be the initial position of the nth particle in the current frame to be drawn. Let v be the velocity of the nth particle. Let Δt be the display time of the current frame to be drawn. In this embodiment, the display time of each frame is related to the frame rate. For example, when the frame rate is 60fps, the display time of each frame is 16ms.
[0112] For example, an electronic device can determine the target color of each particle in the current frame based on the initial color of each particle. The target color can be the same as the initial color of the particle.
[0113] For example, an electronic device can determine the target transparency of each particle in the current frame of view based on the initial transparency of each particle. The target transparency can be the same as the initial transparency of the particle. The specific process for determining the target color and target transparency will not be elaborated upon here.
[0114] S503, the electronic device uniformly divides the scene space of multiple particles corresponding to the current scene to be drawn, and obtains multiple unit scene spaces.
[0115] In some examples, the scene space of multiple particles refers to the virtual three-dimensional environment in which the multiple particles are located, which can be used to define the range of motion of the multiple particles.
[0116] In this embodiment, the electronic device can acquire the dimensions of the scene space and, based on these dimensions, uniformly divide the scene space. The dimensions of the scene space can be set by a particle system. A particle system is a technique in 3D computer graphics used to simulate specific visual effects.
[0117] As an example, the specific implementation of uniformly dividing the scene space by an electronic device can be to divide the scene space uniformly according to a set three-dimensional shape. For example, the scene space can be uniformly divided using three-dimensional shapes such as cuboids, cubes, regular tetrahedrons, and octahedrons.
[0118] Understandably, after uniformly dividing the scene space, multiple unit scene spaces can be obtained. Since the scene space is uniformly divided, the resulting multiple unit scene spaces have the same size.
[0119] To simplify calculations and reduce computational load, in this embodiment of the application, as shown in Figure 6, the electronic device can uniformly divide the scene space using cubes with set side lengths to obtain multiple unit scene spaces, each of which is a cube with a set side length. For example, a scene space with a size of 200*200*200 can be divided using cubes with a side length of 1, resulting in 8,000,000 unit scene spaces, each of which is also a cube with a side length of 1.
[0120] In some examples, the execution order of S503 and S502 can be interchanged. For example, an electronic device can first uniformly divide the scene space of multiple particles to obtain multiple unit scene spaces, and then determine the target attribute data of each particle.
[0121] This application embodiment does not impose specific restrictions on the execution order of S503 and S502.
[0122] S504, the electronic device determines the unit scene space where each of the multiple particles is located based on the position information of each particle among the multiple particles.
[0123] In some examples, scene space is typically defined based on a three-dimensional coordinate system, such as defining the position of each particle in the scene space and the position of each unit scene space, such as the position of each vertex in each unit scene space.
[0124] Therefore, the particle's position information includes coordinates in various directions within the three-dimensional coordinate system of the scene space. Similarly, the position of each vertex within a unit of scene space also includes coordinates in various directions within the three-dimensional coordinate system of the scene space.
[0125] Understandably, since a unit scene space is obtained by uniformly dividing the scene space, and each unit scene space has the same size, the position of each vertex in each unit scene space can be directly obtained from the divided unit scene space.
[0126] As an example, an electronic device can determine the unit scene space in which each particle is located based on the position information of each particle in the multiple particles and the position of each vertex in each unit scene space.
[0127] For ease of calculation, as shown in Figure 7, the origin of the three-dimensional coordinate system of the scene space can coincide with a vertex of one unit scene space. Based on this, the electronic device can determine the unit scene space where each of the multiple particles is located using the following formula: index x =x n / Δx+1 index y =y n / Δy+1 index z =z n / Δz+1
[0128] Among them, (x n y n , z n ) represents the position information of the nth particle. Δx is the side length of a unit scene space in the x-direction, Δy is the side length of a unit scene space in the y-direction, and Δz is the side length of a unit scene space in the z-direction. n / Δx+1 represents the relationship between x n Round the value of / Δx up, y n / Δy+1 represents the relationship between y n Round the value of / Δy up, z n / Δz+1 represents the relationship between z n The value of / Δz is rounded up. (index) x index y index z ) represents the position of the nth particle in the unit scene space, such as the position of the vertex of the unit scene space in the three-dimensional coordinate system.
[0129] For example, taking a cube with a side length of 1 as an example, if the position information of the nth particle is (1.5, 2.2, 2.4), then the position of the nth particle in the unit scene space is (2, 3, 3). In this way, the scene space where the nth particle is located can be obtained quickly, and the calculation is simple, consumes less computing resources, and therefore has a smaller computational load.
[0130] S505, the electronic device determines a unit scene space within the field of view and renders the particles within that unit scene space.
[0131] In this embodiment of the application, the field of view refers to the field of view corresponding to the camera angle of the virtual camera used by the electronic device when drawing particle effects.
[0132] As an example, electronic devices can determine the unit scene space within their field of view using a view frustum. As shown in Figure 8, the view frustum is a square pyramid defined by the position and orientation of the virtual camera, representing the range that the virtual camera can see from the current viewpoint.
[0133] As an example, an electronic device can determine the position of each unit scene space in the camera coordinate system and the cone size of the virtual camera's view frustum. Based on the position of each unit scene space in the camera coordinate system and the cone size of the view frustum, the positional relationship between each unit scene space and the view frustum is detected. The unit scene space within the field of view is then obtained based on this positional relationship.
[0134] For example, for each unit scene space, if the positional relationship between the unit scene space and the view frustum indicates that the unit scene space is wholly or partially located within the view frustum, then the unit scene space is within the field of view. If the positional relationship between the unit scene space and the view frustum indicates that the unit scene space is completely outside the view frustum, then the unit scene space is outside the field of view.
[0135] Understandably, for each unit of scene space, its position in camera coordinates can be obtained through coordinate system transformation. For example, based on the position of the unit of scene space in a 3D coordinate system, its position in camera coordinates can be obtained through coordinate system transformation.
[0136] For each unit of scene space, if the unit of scene space is within the field of view, then the particles in the unit of scene space are also within the field of view. If the unit of scene space is outside the field of view, then the particles in the unit of scene space are also outside the field of view.
[0137] Understandably, an object within the field of view is considered visible from the virtual camera's perspective. Therefore, a unit of scene space within the field of view is a visible unit of scene space, and particles within that unit of scene space are visible particles. A unit of scene space outside the field of view is an invisible unit of scene space, and particles within that unit of scene space are invisible particles.
[0138] In this embodiment, after obtaining a unit scene space within its field of view, the electronic device can render particles within that unit scene space and not render particles outside that unit scene space. That is, the electronic device renders visible particles within its field of view and does not render invisible particles outside that field of view.
[0139] As an example, electronic devices can send particle effect rendering instructions (such as the vkCmdDraw instruction) to the GPU, which then renders visible particles. Upon receiving the particle effect rendering instruction, the GPU can respond and render visible particles on the current screen.
[0140] S506, the electronic device displays images including particle effects.
[0141] In some examples, an electronic device, such as a GPU within the device, can display the image after it has completed drawing the current image in response to particle effect rendering instructions.
[0142] Understandably, each frame displayed by an electronic device includes particle effects for the visible particles in that frame.
[0143] This embodiment of the application obtains all particles within the field of view by dividing particles into unit scene spaces and calculating the unit scene space within the field of view, thereby rendering the particles within the field of view. This significantly reduces the number of particles to render and lowers the particle rendering load.
[0144] To better understand the particle effect display method provided in this application embodiment, the implementation process of the particle effect display method provided in this application embodiment will be specifically explained below using the example shown in Figure 5 and in conjunction with Figure 9. Please refer to Figure 9, which is one of the schematic diagrams of the particle effect display method provided in this application embodiment. Figure 9 shows one of the data flow and control flow directions of the particle effect display method provided in this application embodiment. As shown in Figure 9, the electronic device can first prepare particle data. For example, it can obtain the initial attribute data of multiple particles corresponding to the current screen to be drawn, create a first memory space, and input the initial attribute data of multiple particles into the created first memory space. For ease of understanding, Figure 9 uses the initial attribute data as the initial position (as shown in (xn, yn, zn) in Figure 9) as an example for illustration.
[0145] After preparing the particle data, the electronic device can perform particle calculations. For example, based on the initial position of each particle, the position information of each particle is calculated, and the initial position of each particle is updated to the position information in the first memory space (as shown in (xn',yn',zn' in Figure 9).
[0146] After obtaining the position information of each particle, the electronic device can eliminate invisible particles based on spatial decoupling. That is, the electronic device calculates the unit scene space where each particle is located based on its position information, and also calculates the unit scene space within the field of view, thus obtaining the visible particles within the field of view and the invisible particles outside the field of view. After obtaining the visible particles within the field of view and the invisible particles outside the field of view, the electronic device can remove the position information of the invisible particles from the first memory space. Understandably, after removing the position information of the invisible particles from the first memory space, the first memory space stores the position information of the visible particles.
[0147] The electronic device then creates a second memory space (such as a vertex buffer) and copies the position information of visible particles from the first memory space to the second memory space. In this way, the electronic device can draw particles based on the position information of the visible particles in the second memory space. For example, consider particles with position information (x2', y2', z2') and (x3', y3', z3') that are invisible, while the rest are visible. As shown in Figure 9, after removing the position information of invisible particles from the first memory space and copying the position information of visible particles from the first memory space to the second memory space, the second memory space will no longer contain the position information (x2', y2', z2') and (x3', y3', z3').
[0148] During particle rendering, the electronic device can first bind a second memory space, that is, bind the second memory space to a specified vertex input binding slot using a binding instruction. This ensures that the GPU can obtain the position information of visible particles from the second memory space. After binding the second memory space, the electronic device can send particle effect rendering instructions (such as the vkCmdDraw instruction) to the GPU. Upon receiving the particle effect rendering instruction, the GPU can respond to it, read the particle position information from the second memory space according to the instruction, and render the particles based on that position information.
[0149] To reduce the load associated with creating a second memory space (such as a vertex buffer) and copying data, in this embodiment, particles can be identified by index, and the target attribute data of visible particles can be obtained according to the index. This eliminates the need to remove attribute data from the memory space, thus avoiding the need to continuously re-allocate vertex buffers and copy large amounts of data due to removal. Based on this, referring to Figure 10, the particle effect display method provided in this embodiment may include S1001 and S1009.
[0150] S1001, the electronic device responds to the particle effect activation command and obtains the particle effect data of the current scene to be drawn. The particle effect data includes the initial attribute data of multiple particles.
[0151] The process of S1001 can be referred to the process of S501, and will not be repeated here.
[0152] S1002, the electronic device creates an array of particles and an index array.
[0153] In this embodiment, the electronic device can create a particle array based on the particle effect data of the current scene to be drawn. Each element in the particle array corresponds one-to-one with each particle in the particle effect data. Each element in the particle array represents the initial attribute data of a particle. Each element in the particle array has a unique identifier, such as an array index. Through this unique identifier, the electronic device can access and manipulate specific elements in the particle array.
[0154] In this embodiment of the application, the electronic device can create an index for each particle in the particle effect data to obtain an index array.
[0155] In this embodiment, the index array includes the index of each particle in the particle effect data, and the index of each particle can be a unique identifier for that particle in the particle array. Thus, the attribute data of the corresponding particle can be obtained from the particle array through the index in the index array.
[0156] As an example, an indexed array can be an array of unsigned integers (Unsigned Int).
[0157] S1003, the electronic device creates a particle memory space and an index memory space. The particle memory space is used to store the particle array, and the index memory space is used to store the index array.
[0158] In this embodiment, particle memory space refers to the memory space allocated for particle effect data, used to store particle arrays. Index memory space refers to the memory space allocated for index arrays, used to store index arrays.
[0159] In this embodiment of the application, after creating the particle memory space and the index memory space, the electronic device can store the particle array into the particle memory space and the index array into the index memory space.
[0160] In some examples, the execution order of S1003 and S1002 can be interchanged. For example, an electronic device can first create a particle memory space and an index memory space, then create a particle array and an index array, and store the particle array in the particle memory space and the index array in the index memory space.
[0161] This application embodiment does not impose specific restrictions on the execution order of S1002 and S1003.
[0162] S1004, the electronic device determines the target attribute data of each of the multiple particles corresponding to the current drawing screen, wherein the target attribute data includes the position information of the particle.
[0163] The specific process of S1004 can be referred to the process of S502, and will not be repeated here.
[0164] In this embodiment, after obtaining the target attribute data for each particle, the electronic device can update the initial attribute data of each particle in the particle array to the target attribute data. Thus, the particle memory space stores the target attribute data for each particle.
[0165] S1005, the electronic device uniformly divides the scene space of multiple particles corresponding to the current scene to be drawn, and obtains multiple unit scene spaces.
[0166] S1006, the electronic device determines the unit scene space where each of the multiple particles is located based on the position information of each particle among the multiple particles.
[0167] The processes of S1005 and S1006 can be referred to the processes of S504 and S505 above, and will not be repeated here.
[0168] S1007, the electronic device determines the unit scene space within the field of view and removes the indexes of particles in the unit scene space outside the field of view from the index memory space.
[0169] The process by which electronic devices determine whether a unit scene space is within the field of view can refer to the process in S505 above, and will not be repeated here.
[0170] In this embodiment, after obtaining a unit scene space within its field of view, the electronic device acquires the index of visible particles in each unit scene space within that field of view. Thus, the electronic device can obtain a set of indices of visible particles within the unit scene space of its field of view.
[0171] As shown in Figure 11, tile(index) x index y index z `tile(x, y, z)` represents a unit of scene space within the field of view. `tile(index)` x index y index zThe indices in `tile(x, y, z)` and `tile(x, y, z)` are the indices of visible particles. See indices 1, 3, 6, and n in Figure 11.
[0172] As an example, an electronic device can match the set of indices of visible particles with the index array in the index memory space, and remove indices in the index array that do not match the set. In this way, the electronic device can remove the indices of particles in a unit scene space outside the field of view from the index memory space, so that the index array in the index memory space only retains the indices of visible particles.
[0173] S1008, the electronic device retrieves the target attribute data of the visible particles from the particle memory space based on the index of the visible particles, and draws the visible particles based on the target attribute data of the visible particles.
[0174] In this embodiment, the particle memory space stores the target attribute data of all particles corresponding to the current scene to be drawn; that is, the particle memory space stores the target attribute data of both visible and invisible particles. To draw only visible particles, the electronic device can retrieve the target attribute data of visible particles from the particle memory space based on their indexes, and then draw the visible particles according to this data.
[0175] For example, the electronic device can retrieve the index of a visible particle from an index array and match the index of the visible particle with the unique identifier of each element in the particle array. For each element in the particle array, if the unique identifier of the element matches the index of a visible particle, it indicates that the element is the target attribute data of the visible particle. In this way, the electronic device can retrieve the target attribute data of the visible particle from the particle memory space based on the index of the visible particle.
[0176] As an example, an electronic device can send particle effect rendering instructions (such as the vkCmdDrawIndexed instruction) to the GPU, which then renders visible particles. Upon receiving the particle effect rendering instruction, the GPU can respond by retrieving the index of the visible particle from the index array, obtaining the target attribute data of the visible particle from the particle memory space based on the index, and then rendering the visible particles on the current screen based on the target attribute data.
[0177] S1009, the electronic device displays a picture including particle effects.
[0178] The specific process of S1009 can be referred to the process of S506, and will not be repeated here.
[0179] In this embodiment, particles are identified by indexes, and the attribute data of the particles are obtained according to the indexes. There is no need to remove the attribute data of the particles, so there is no need to create new memory space. The memory space of the particle array can be reused directly, avoiding the situation of constantly re-allocating vertex buffers and copying large amounts of data due to removal, and further reducing the load.
[0180] To better understand the particle effect display method provided in this application embodiment, the implementation process of the particle effect display method provided in this application embodiment will be specifically explained below using the example shown in Figure 10 and in conjunction with Figure 12. Please refer to Figure 12, which is a second schematic diagram of the principle of the particle effect display method provided in this application embodiment. Figure 12 shows the data flow and control flow of the particle effect display method provided in this application embodiment. For ease of understanding, Figure 12 uses the particle's position as an example for illustration based on the particle's attribute data.
[0181] As shown in Figure 12, the electronic device can first prepare particle data, such as creating a particle array, an index array, a particle memory space, and an index memory space, and then store the particle array into the particle memory space and the index array into the index memory space.
[0182] After preparing the particle data, the electronic device can perform particle calculations to obtain the position information of each particle, and update the particle array according to the position information of each particle, that is, update the initial position of each particle in the particle array to the position information of each particle.
[0183] After obtaining the position information of each particle, the electronic device can remove the indices of invisible particles based on spatial decoupling. That is, the electronic device calculates the unit scene space where each particle is located based on its position information, and calculates the unit scene space within the field of view. Then, it removes the indices of particles in the invisible unit scene space from the index memory space. As shown in Figure 12, indices 2 and 4 are removed from the index array in the index memory space. In this way, the index array in the index memory space only retains the indices of visible particles.
[0184] The electronic device can then perform particle rendering. During particle rendering, the electronic device can first bind the particle memory space and the index memory space; that is, it uses binding instructions to bind the particle memory space and the index memory space to specified vertex input binding slots. This ensures that the GPU can obtain the index from the index array in the index memory space and, based on the index, retrieve the position information of the particle array from the particle memory space.
[0185] After binding the particle memory space and the index memory space, the electronic device can send particle effect drawing instructions (such as the vkCmdDrawIndexed instruction) to the GPU. After receiving the particle effect drawing instruction, the GPU can obtain the index in the index array from the index memory space according to the particle effect drawing instruction, obtain the position information of the corresponding particle in the particle array from the particle memory space according to the index in the index array, and perform particle drawing according to the position information of the corresponding particle.
[0186] In order for the GPU to successfully read the target attribute data in the particle array, in this embodiment of the application, after obtaining the target attribute data of each particle, the particle memory space can also be format converted so that the GPU can successfully access the particle memory space and read the attribute data from the particle memory space.
[0187] Please refer to Figure 13, which uses particle attribute data as an example for explanation. As shown in Figure 13, after obtaining the position information of each particle, the electronic device can also perform format conversion on the particle memory space. This format conversion can involve converting the data description structure of the particle memory space. By converting the data description structure of the particle memory space into a data description structure that the GPU can access and read, the GPU can successfully access the particle memory space and read its position information.
[0188] Accordingly, when the electronic device performs particle rendering, it can first bind the format-converted particle memory space and index memory space. That is, the format-converted particle memory space and index memory space are bound to the specified vertex input binding slot through binding instructions. In this way, it can be ensured that the GPU can obtain the index in the index array from the index memory space, obtain the position information of the particle array from the format-converted particle memory space according to the index, and perform particle rendering according to the position information of the particles.
[0189] In this embodiment, after the particle memory space undergoes format conversion, it can be considered as a vertex buffer. Thus, when rendering particle effects, the electronic device does not need to request and create a vertex buffer, nor does it need to copy the particle's target attribute data to the vertex buffer. Particle effects can be rendered by reusing the particle array's memory space, reducing the load associated with creating a vertex buffer and copying data.
[0190] This application embodiment detects visible particles and identifies them by index within a unit scene space. This reduces the load on particle visibility detection and rendering. Furthermore, it avoids the need for continuous re-allocation of vertex buffers and large data copies due to culling, further reducing the load.
[0191] Since particle effects are dynamic effects, they need to be presented by multiple consecutive frames. To better understand the embodiments of this application, the process of displaying particle effects across multiple frames will be described below with reference to FIG14. As shown in FIG14, the particle effect display method provided in the embodiments of this application may further include S1401 to S1404.
[0192] S1401, the electronic device responds to the first particle effect rendering instruction and displays the first frame, wherein the first frame includes particle effects corresponding to visible particles.
[0193] In this embodiment, visible particles refer to particles located within a unit scene space within the field of view. The unit scene space is obtained by dividing the scene space of multiple particles corresponding to the first frame.
[0194] In the embodiments of this application, the position information of each particle among the multiple particles is associated with a unit scene space. For example, the position information of each particle among the multiple particles is associated with the unit scene space in which each particle is located.
[0195] As an example, for each of a plurality of particles, the electronic device can determine the unit scene space in which each particle is located based on the position information of each particle. Based on the unit scene space in which each particle is located, the correlation between the position information of each particle and the unit scene space in which each particle is located can be obtained.
[0196] Understandably, the specific process of S1401 can be referred to the examples shown in Figures 5 and 10, and will not be described in detail here.
[0197] S1402, the electronic device updates the unit scene space where each of the multiple particles is located based on the position information and movement speed of the multiple particles corresponding to the first frame.
[0198] Because particle effects are dynamic effects, they need to be presented across multiple consecutive frames. Therefore, after the electronic device renders the particle effects for the first frame, it also needs to render the particle effects for subsequent frames, such as the second frame. The first and second frames are adjacent frames.
[0199] As an example, an electronic device can first determine that each particle in the multiple particles corresponding to the second frame is located in a unit scene space, and then draw the visible particles in the unit scene space within the field of view to obtain the particle effects of the second frame.
[0200] In this embodiment, the position information of multiple particles corresponding to the first frame can be the initial position of multiple particles corresponding to the second frame. Therefore, the electronic device can update the unit scene space where each particle is located based on the position information and movement speed of multiple particles corresponding to the first frame, thereby obtaining the unit scene space where each particle is located in the unit scene space of multiple particles corresponding to the second frame.
[0201] For example, the specific implementation of the electronic device updating the unit scene space of each of the multiple particles based on the position information and motion speed of the multiple particles corresponding to the first frame can be as follows: The electronic device updates the position information of each of the multiple particles based on the position information and motion speed of the multiple particles corresponding to the first frame. Then, based on the updated position information of each of the multiple particles, it updates the unit scene space of each of the multiple particles.
[0202] Similarly, electronic devices can be accessed via x′ n =x n +v×Δt updates the position information of each particle. Where x n This represents the position information of the nth particle corresponding to the first frame. v represents the velocity of the nth particle corresponding to the first frame. n This represents the updated position information of the nth particle. Δt is the display time of the second frame.
[0203] Understandably, the position information of the nth particle corresponding to the first frame can be the initial position of the nth particle in the second frame. The updated position information of the nth particle can be the target position of the nth particle at the end of the display time of the second frame.
[0204] Because changes in particle position information can cause changes in the unit scene space in which the particle resides. For example, before updating its position information, the nth particle might be located in the unit scene space tile(x1, y1, z1). After updating its position information, the nth particle might be located in the unit scene space tile(x2, y2, z2). Therefore, after obtaining the updated position information of each particle, the electronic device can update the unit scene space in which each particle resides based on the updated position information.
[0205] In this embodiment, the unit scene space is obtained by uniformly dividing the scene space of multiple particles. Therefore, the electronic device can redetermine the unit scene space where each particle is located after updating its position information based on the updated position information of each particle and the side length of the unit scene space, thereby updating the unit scene space where each particle is located. The specific process can be referred to in S504, and will not be elaborated here.
[0206] Understandably, after updating the unit scene space where each particle is located, we obtain the unit scene space where each particle is located among the multiple particles corresponding to the second frame.
[0207] S1403, The electronic device updates the visible particles in a unit scene space within its field of view.
[0208] Because changes in particles within a unit of scene space can alter the visible particles within the field of view, the electronic device may also change. For example, within a unit of scene space tile (x1, y1, z1) within the field of view, there may be visible particles n1, n2, and n3. However, after the particle position information is updated, the unit of scene space tile (x1, y1, z1) may only contain visible particles n1 and n2. Therefore, the electronic device also needs to update the visible particles within the unit of scene space within the field of view.
[0209] For example, after obtaining the unit scene space where each particle is located after the updated position information, the electronic device can update the visible particles in the unit scene space within the field of view according to the unit scene space where each particle is located after the updated position information.
[0210] For each particle whose position information has been updated, the electronic device can determine whether the unit scene space in which the particle is located is within the field of view. If the unit scene space in which the particle is located is within the field of view, then the particle is a visible particle. By detecting whether the unit scene space in which each particle is located after its position information has been updated is within the field of view, the updating of visible particles within the field of view can be achieved. The specific process can be referred to S505.
[0211] After updating the visible particles in a unit scene space within its field of view, the electronic device obtains the visible particles from the multiple particles corresponding to the second frame.
[0212] S1404, the electronic device responds to the second particle effect rendering instruction and displays a second frame; the second frame includes the particle effects of the updated visible particles.
[0213] Once the electronic device obtains the visible particles from among the multiple particles corresponding to the second frame, it can send a second particle effect rendering command to the GPU. Upon receiving the second particle effect command, the GPU can respond and render the visible particles from among the multiple particles corresponding to the second frame. After completing the rendering of the second frame, the electronic device can display the second frame, which includes the updated particle effects of the visible particles. The specific process can be found in S506 and will not be elaborated upon here.
[0214] Understandably, based on the descriptions of S1401 to S1404, in some examples, during the rendering of particle effects across multiple frames, the target attribute data of multiple particles corresponding to each frame in the multi-frame sequence can be the initial attribute data of multiple particles corresponding to the next adjacent frame. Specifically, the initial attribute data of multiple particles corresponding to the first frame in the multi-frame sequence can be generated by the particle system.
[0215] Therefore, in the process of rendering particle effects across multiple frames, if the number of particles corresponding to the multiple frames remains unchanged, the electronic device can reuse the particle memory space. It only needs to update the attribute data in the particle memory space, without creating a new particle memory space, thereby reducing the load when rendering particle effects.
[0216] Similarly, when the number of particles remains unchanged across multiple frames, electronic devices can reuse index memory space. They only need to update the index of visible particles in the index memory space, without creating a new index memory space, which can further reduce the load when rendering particle effects.
[0217] Understandably, the above explanation only uses the particle effects of the second frame as an example. The drawing of the third frame, ..., the nth frame can also refer to the drawing process of the second frame, which will not be elaborated here.
[0218] The functional modules for implementing the particle effect display method provided in the embodiments of this application will be described below. Please refer to Figure 15, which is a schematic diagram of the functional modules of the particle effect display device provided in the embodiments of this application. The particle effect display device shown in Figure 15 can be applied to the electronic device shown in Figure 4.
[0219] As shown in Figure 15, the particle effects display device 100 provided in this embodiment may include a data preparation module 101, a particle calculation module 102, a particle space calculation module 103, a particle rendering module 104, and an effects display module 105. It is understood that the functional modules included in the particle effects display device 100 can be deployed in software form within the operating system of an electronic device, such as within the various layers of the operating system. Different functional modules can be deployed in different layers or in the same layer. The specific layer to which they are deployed can be set according to actual needs, and this embodiment does not impose specific limitations here.
[0220] The data preparation module 101 is used to create particle arrays, index arrays, particle memory spaces, and index memory spaces, and to store particle arrays into particle memory spaces and index arrays into index memory spaces.
[0221] The particle calculation module 102 is used to determine the target attribute data of the particles. For example, the particle calculation module 102 can calculate the position information of the particles based on their motion velocity and initial position.
[0222] The particle space calculation module 103 is used to divide the scene space into multiple unit scene spaces, and determine the unit scene space where the particle is located based on the particle's position information.
[0223] The particle space calculation module 103 can also be used to determine the unit scene space within the field of view, and obtain the index of visible particles within the field of view based on the unit scene space within the field of view.
[0224] The particle rendering module 104 is used to obtain the target attribute data of the visible particles within the field of view from the particle memory space based on the index of the visible particles within the field of view, and to render the visible particles within the field of view based on the target attribute data of the visible particles within the field of view.
[0225] The special effects display module 105 is used to display images including particle effects.
[0226] Based on the functional modules shown in Figure 15, when rendering particle effects, the electronic device can obtain the particle's position information based on the particle's initial attribute data, and determine the unit scene space where the particle is located based on the particle's position information. Then, by detecting the unit scene space within the field of view, the index of the visible particles within the field of view is obtained. After obtaining the index of the visible particles within the field of view, the target attribute data of the visible particles within the field of view can be obtained from the particle memory space based on the index of the visible particles within the field of view, and the visible particles within the field of view are rendered based on the target attribute data of the visible particles within the field of view. In this way, by dividing the particles into unit scene spaces, detecting whether the unit scene space is within the field of view, and rendering the particles in the unit scene space within the field of view, the number of particles rendered is greatly reduced, thereby reducing the particle rendering load, and also reducing the load of detecting whether particles are visible. Furthermore, by identifying particles by index, there is no need to remove the particle attribute data, thus avoiding memory creation and data copying caused by particle removal, further reducing the load.
[0227] Based on the same inventive concept, embodiments of this application provide an electronic device, which may specifically include a memory, a processor, and one or more computer programs. The memory and processor can be connected via one or more communication buses. The one or more computer programs are stored in the memory and configured to be executed by the processor, and when executed by the processor, they perform the functions or steps in the methods shown in Figures 5 and 10.
[0228] This application also provides a computer-readable storage medium storing computer program instructions, which, when executed by a processing circuit, implement the functions or steps in the methods shown in Figures 5 and 10 above.
[0229] In addition, embodiments of this application may also provide a chip system, which includes a processing circuit and a storage medium. The storage medium stores computer program instructions. When the computer program instructions are executed by the processing circuit, they implement the functions or steps in the methods shown in Figures 5 and 10 above.
[0230] In addition, embodiments of this application may also provide a computer program product containing instructions, which, when run on a computer, causes the computer to perform the functions or steps in the methods shown in Figures 5 and 10 above.
[0231] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working processes of the chip system, electronic device, computer-readable storage medium, and computer program product containing instructions described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0232] It is understood that the steps of the methods or algorithms described in conjunction with the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory, flash memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, registers, hard disks, portable hard disks, read-only optical disks, or any other form of storage medium. An exemplary embodiment involves a storage medium coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an application-specific integrated circuit (ASIC). Alternatively, the ASIC can reside within an electronic device. Of course, the processor and storage medium can also exist as discrete components within an electronic device.
[0233] In an alternative approach, when implemented in software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disk (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0234] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. A method for displaying particle effects, characterized in that, The method further includes: In response to a particle effect rendering command, a frame containing particle effects is displayed; the frame is one of a series of frames, and each frame of the series of frames includes particle effects for the corresponding visible particles. Wherein, the visible particles corresponding to each frame are the particles to be drawn among the multiple particles corresponding to each frame, and the visible particles refer to the particles in a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of the multiple particles, and the position information of each particle in the multiple particles is related to the unit scene space.
2. The method according to claim 1, characterized in that, Before displaying a frame including particle effects, the method further includes: Obtain the index of the visible particle among the multiple particles corresponding to the frame; each particle among the multiple particles corresponding to the frame has a unique index; The target attribute data of the visible particles are obtained from the particle memory space according to the index of the visible particles; The visible particles are drawn based on their target attribute data. The particle memory space stores the target attribute data of each particle in the plurality of particles corresponding to the frame, and the target attribute data of each particle in the plurality of particles includes the position information.
3. The method according to claim 2, characterized in that, The indexes of the visible particles are stored in the index memory space.
4. The method according to claim 3, characterized in that, Before displaying a frame including particle effects, the method further includes: Create an index for each particle among the multiple particles corresponding to the frame; Create the index memory space; The index of each of the plurality of particles is stored in the index memory space; Remove the indices of invisible particles from the index memory space; wherein the invisible particles are located in a unit scene space outside the field of view.
5. The method according to any one of claims 1-4, characterized in that, Before displaying a frame including particle effects, the method further includes: Obtain the position information of each particle among multiple particles corresponding to a frame, and determine the unit scene space where each particle is located based on the position information of each particle among multiple particles; For each particle: if the unit scene space where the particle is located is within the field of view, the particle is determined to be a visible particle.
6. The method according to claim 5, characterized in that, The method further includes: The scene space of multiple particles corresponding to a single frame is uniformly divided to obtain multiple unit scene spaces; The step of determining the unit scene space where each of the plurality of particles is located based on the position information of each particle includes: Based on the position information of each of the plurality of particles and the side length of the unit scene space, the unit scene space in which each of the plurality of particles is located is obtained.
7. The method according to claim 5 or 6, characterized in that, The step of obtaining the position information of each particle among multiple particles corresponding to a single frame includes: The initial attribute information of each of the plurality of particles is obtained, including the initial position and motion speed of the particle in a frame. Based on the initial position and velocity of each of the plurality of particles, the position information of each of the plurality of particles is obtained.
8. A method for displaying particle effects, characterized in that, The method further includes: In response to the first particle effect rendering command, the first frame is displayed; wherein, the first frame includes particle effects corresponding to visible particles, the visible particles refer to particles located in a unit scene space within the field of view; the unit scene space is obtained by dividing the scene space of multiple particles, and the position information of each particle in the multiple particles is associated with the unit scene space. Based on the position information and movement speed of multiple particles corresponding to the first frame, update the unit scene space where each of the multiple particles is located; Update visible particles within a unit of scene space that is within the field of view; In response to the second particle effect rendering command, a second frame is displayed; the second frame includes the updated particle effects of visible particles.
9. The method according to claim 8, characterized in that, The step of updating the unit scene space of each of the multiple particles based on the position information and motion speed of the multiple particles corresponding to the first frame includes: Update the position information of each particle in the plurality of particles based on the position information and motion velocity of each particle in the plurality of particles; Based on the updated position information of each of the plurality of particles, update the unit scene space in which each of the plurality of particles is located.
10. The method according to claim 9, characterized in that, The method further includes: The scene space of the multiple particles is uniformly divided to obtain multiple unit scene spaces; The step of updating the unit scene space where each of the plurality of particles is located based on the updated position information of each particle includes: Based on the updated position information of each of the plurality of particles and the side length of the unit scene space, update the unit scene space in which each of the plurality of particles is located.
11. The method according to any one of claims 8-10, characterized in that, The update of visible particles within a unit scene space within the field of view includes: Based on the updated location information of each particle in the unit scene space, update the visible particles in the unit scene space within the field of view.
12. An electronic device, characterized in that, include: Memory is used to store computer program instructions; A processor for executing the computer program instructions to support the electronic device in implementing the method as described in any one of claims 1-7 or the method as described in any one of claims 8-11.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processing circuit, implement the method as described in any one of claims 1-7 or the method as described in any one of claims 8-11.
14. A computer program product containing instructions, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1-7 or the method as described in any one of claims 8-11.
