Method and device for generating flow field seed points under irregular region constraint in GPU
By mapping vector field data to raster data, determining the effective field range, and generating latitude and longitude textures, the problem of seed point generation for the particle system method in irregular regions under WebGL environment is solved, and the flow field visualization effect in irregular regions is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NAT UNIV OF DEFENSE TECH
- Filing Date
- 2022-07-01
- Publication Date
- 2026-06-23
AI Technical Summary
In the WebGL environment, how to efficiently generate seed points in the particle system method within irregular regions, especially the problem of random particle generation for land-sea boundary partitioning data, has not been effectively solved.
The effective field range is determined by mapping the vector field data to raster data of 0 or 1, calculating the latitude and longitude and encoding them as textures using RGBA, generating random particles as seed points for the flow field, and updating and drawing them in the WebGL environment.
This invention enables the random generation of seed points within irregular regions for flow field visualization under irregular region constraints, thereby improving the visualization effect of the particle system method in the WebGL environment.
Smart Images

Figure CN115239545B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for generating flow field seed points under irregular region constraints in a GPU. Background Technology
[0002] The particle system method is one of the most commonly used visualization methods for vector field data in computer graphics. Each particle has a certain life cycle, including three stages: "birth," "movement," and "death." Then, the positions of the particles at several time points during the movement stage are calculated, and the trajectories formed by these positions are drawn to obtain the visualization results of the vector field data. By leveraging the movement of a large number of particles, relatively realistic vector fields can be simulated, and the real-time dynamic interactive characteristics bring a strong sense of immersion.
[0003] In the visualization of vector field data based on the particle system method, particles need to be iteratively updated, continuously regenerating particle seed points (particles at their initial positions). The visualization effect of vector field data largely depends on the location of these seed point generation points; therefore, a suitable seed point generation method is crucial. When a particle's lifecycle ends, to maintain the total number of particles within the current viewport, a new particle needs to be generated within the effective region, which refers to the area containing vector field data. For example, if only wind field data for a specific province is to be displayed within the current viewport, then randomly generated particles must be located within the province's boundaries. Similarly, for ocean current data, if there are islands within the current viewport, then randomly generated particles must be located in the ocean area, not within the islands.
[0004] Since particles are randomly generated, ensuring that the generated particles are located within the irregular effective region is a challenge. CPUs offer a solution: pre-calculate the vector values corresponding to the positions of all pixels within the effective region and store them in an array. This array provides all candidate positions for regenerating the seed point. However, this method is not suitable for GPUs. Therefore, how to efficiently generate particles within irregular regions based on WebGL remains a problem. Existing algorithms have achieved the division of land and sea boundaries by cropping the convex polygon fill area, but they do not solve the problem of random particle generation for land and sea boundary data. Summary of the Invention
[0005] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for generating flow field seed points under irregular region constraints in a GPU, which can solve the problem of generating random particles in irregular regions under WebGL environment.
[0006] A method for generating flow field seed points under irregular region constraints in a GPU, the method comprising:
[0007] Acquire flow field vector data, and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value, and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values;
[0008] Obtain the raster data of the current viewport range, and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1;
[0009] Calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding;
[0010] The latitude and longitude texture is passed to the WebGL buffer, and random particles are generated in the GPU based on the latitude and longitude texture as seed points for the flow field.
[0011] Update and render flow field particles in the WebGL environment.
[0012] In one embodiment, the method further includes: acquiring an image corresponding to the raster data of the flow field;
[0013] Obtain the latitude and longitude range of the current viewport, and obtain the upper left corner coordinates and length and width information of the current viewport on the image based on the latitude and longitude range of the current viewport;
[0014] The getImageData function of the canvas tag obtains the pixel data of the current viewport range based on the coordinates of the top left corner and the width and height information of the current viewport; where each pixel data contains RGBA values;
[0015] Use the R value as the raster value for the corresponding position;
[0016] The effective field range within the current viewport range is determined based on the grid value of the current viewport range.
[0017] In one embodiment, the method further includes: acquiring the viewport image corresponding to the current viewport range;
[0018] For each pixel in the viewport image, determine whether the grid values of the four sampling points surrounding the pixel are all 1. If so, the pixel is determined to be a valid pixel; otherwise, the pixel is determined to be an invalid pixel.
[0019] The effective field range within the current viewport is constituted by all valid pixels within the current viewport range.
[0020] In one embodiment, the method further includes: traversing the viewport image along the x-axis and calculating the positions of all valid pixels on the y-axis corresponding to longitude x;
[0021] The latitude and longitude of all pixels are obtained based on the coordinates of all valid pixels and the latitude and longitude range of the current viewport.
[0022] In one embodiment, the method further includes: performing RGBA encoding on the latitude and longitude, storing the longitude information in RG, and storing the latitude information in BA.
[0023] In one embodiment, the method further includes: updating and drawing the flow field particles in a WebGL environment; during the update phase, setting an event listener, and updating the flow field particles if a drag or zoom event is triggered.
[0024] In one embodiment, the method further includes updating and rendering the flow field particles in a WebGL environment;
[0025] During the calculation phase of the rendering phase, the updated particle positions are calculated using four position textures and one velocity texture;
[0026] During the rendering phase of the drawing phase, particles are drawn to the screen using three frame buffers and one color buffer.
[0027] A flow field seed point generation device under irregular region constraints in a GPU, the device comprising:
[0028] The raster data determination module is used to acquire flow field vector field data and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values;
[0029] The effective field range determination module is used to acquire the raster data of the current viewport range and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1;
[0030] The latitude and longitude texture determination module is used to calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding;
[0031] The flow field seed point generation module is used to pass the latitude and longitude texture to the WebGL buffer and generate random particles in the GPU as flow field seed points based on the latitude and longitude texture.
[0032] Update the drawing module, which is used to update and draw flow field particles in the WebGL environment.
[0033] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0034] Acquire flow field vector data, and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value, and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values;
[0035] Obtain the raster data of the current viewport range, and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1;
[0036] Calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding;
[0037] The latitude and longitude texture is passed to the WebGL buffer, and random particles are generated in the GPU based on the latitude and longitude texture as seed points for the flow field.
[0038] Update and render flow field particles in the WebGL environment.
[0039] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0040] Acquire flow field vector data, and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value, and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values;
[0041] Obtain the raster data of the current viewport range, and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1;
[0042] Calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding;
[0043] The latitude and longitude texture is passed to the WebGL buffer, and random particles are generated in the GPU based on the latitude and longitude texture as seed points for the flow field.
[0044] Update and render flow field particles in the WebGL environment.
[0045] The aforementioned method, apparatus, computer device, and storage medium for generating flow field seed points under irregular region constraints in a GPU map the vector field data at the current position to raster data of 0 or 1 based on whether the data is a normal value. The effective field range within the current viewport is determined based on the raster data of the current viewport range, where any pixel within the effective field range is considered a valid pixel. A valid pixel is a pixel whose raster value is 1 at its four surrounding sampling points. The latitude and longitude corresponding to all pixels within the effective field range are calculated and mapped to a latitude and longitude texture using RGBA encoding. This latitude and longitude texture is then transmitted to a WebGL buffer, and random particles are generated in the GPU based on the texture as flow field seed points. The flow field particles are then updated and drawn in the WebGL environment. This invention pre-calculates the latitude and longitude information corresponding to all pixels within the effective region of the current viewport range and stores and transmits it in texture form, enabling the random generation of seed points within irregular regions in a WebGL environment for visualization of flow fields under irregular region constraints. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating a method for generating flow field seed points under irregular region constraints in a GPU in one embodiment.
[0047] Figure 2 This is a schematic diagram of the principle of valid pixel determination within an irregular range in one embodiment, where (a) is a diagram showing the positional relationship between the pixel and four surrounding sampling points, and (b) is a diagram of the real scene corresponding to the pixel;
[0048] Figure 3 This is a schematic diagram illustrating the RGBA encoding of latitude and longitude in one embodiment;
[0049] Figure 4 This is a schematic diagram illustrating the seed point generation and visualization process under irregular region constraints in one embodiment.
[0050] Figure 5 The calculation stage of the drawing stage in one embodiment involves a texture diagram, wherein (a) is a texture map of the particle's current position, (b) is a texture map of the particle's velocity, and (c) is a texture map of the particle's position in the previous stage.
[0051] Figure 6 A frame buffer object diagram in one embodiment;
[0052] Figure 7In one embodiment, the rendering phase involves a texture map;
[0053] Figure 8 The above is a visualization of global ocean current data after removing land and considering the constraints of irregular ocean regions in one embodiment. (a) is a global visualization of the irregular region, and (b) is a local visualization of the irregular region.
[0054] Figure 9 This is a structural block diagram of a flow field seed point generation device under irregular region constraints in a GPU in one embodiment.
[0055] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0057] In one embodiment, such as Figure 1 As shown, a method for generating flow field seed points under irregular region constraints in a GPU is provided, including the following steps:
[0058] Step 102: Obtain flow field vector data and map it to 0 or 1 raster data based on whether the vector field data at the current position is a normal value.
[0059] Where 1 indicates that the vector field data is a normal value, and 0 indicates that the vector field data is an abnormal value; a normal value in the vector field data means that there are no missing values in the vector field data.
[0060] Step 104: Obtain the raster data of the current viewport range, and determine the effective field range in the current viewport range based on the raster data of the current viewport range.
[0061] After preprocessing and calculating the raster data, the next step is to obtain the raster cell values for the corresponding region based on the current viewport range. Since the original raster data is mapped to an image, the `getImageData` function of the browser's canvas tag can be used to obtain the pixel data of a specified rectangular region. Each pixel contains four values: RGBA, and the R value can be used as the raster value for the corresponding position.
[0062] Then, the latitude and longitude of all pixels within the effective field are calculated. Specifically, this involves traversing along the x-axis and calculating the positions of all effective pixels on the y-axis corresponding to longitude x. Effective pixels are those within the vector field. A pixel's validity is determined by checking if the raster values of its four surrounding sampling points are all valid. If all four surrounding sampling points are valid, the pixel is effective, and its latitude and longitude can be calculated based on the current viewport's latitude and longitude range and the pixel's width and height. Otherwise, the pixel is invalid. Specifically... Figure 2 As shown, point AF is the sampling point of the original vector field data.
[0063] like Figure 2 (a) For pixel P1, there is a missing value A among its four surrounding points. Therefore, the red area may contain areas outside the effective field. The corresponding real-world scene diagram is shown below. Figure 2 As shown in (b), it can be seen that the corresponding area includes land and sea, so this is a dangerous area. Pixels in this area are invalid. For pixel P2, since the surrounding values are all valid, it can be considered that the area is within the valid field range, and the pixels in the area are also valid. Then the positions of all pixels in the area can be calculated.
[0064] Step 106: Calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude to latitude and longitude textures through RGBA encoding.
[0065] To ensure accuracy, latitude and longitude are encoded using RGBA. For example, RG can be used to store longitude and BA to store latitude. Figure 4 As shown.
[0066] Step 108: Pass the latitude and longitude texture to the WebGL buffer, and generate random particles in the GPU as seed points for the flow field based on the latitude and longitude texture.
[0067] Step 110: Update and render the flow field particles in the WebGL environment.
[0068] During the update phase, an event listener is set up. If a drag or zoom event is triggered, the update and drawing are performed.
[0069] In the aforementioned method for generating flow field seed points under irregular region constraints in a GPU, the vector field data at the current position is mapped to raster data of 0 or 1 based on whether it is a normal value. The effective field range within the current viewport is determined based on the raster data of the current viewport range, where any pixel within the effective field range is a valid pixel. A valid pixel is a pixel whose raster value is 1 at its four surrounding sampling points. The latitude and longitude corresponding to all pixels within the effective field range are calculated, and the latitude and longitude are mapped to a latitude and longitude texture using RGBA encoding. The latitude and longitude texture is passed to the WebGL buffer, and random particles are generated in the GPU based on the latitude and longitude texture as flow field seed points. The flow field particles are updated and drawn in the WebGL environment. This invention pre-calculates the latitude and longitude information corresponding to all pixels in the effective area within the current viewport range and stores it in texture form, enabling random generation of seed points within irregular regions in the WebGL environment for visualization of flow fields under irregular region constraints.
[0070] In one embodiment, the method further includes: acquiring the image corresponding to the raster data of the flow field; acquiring the latitude and longitude range of the current viewport, and obtaining the upper left corner coordinates and width and height information of the current viewport on the image based on the latitude and longitude range of the current viewport; obtaining the pixel data of the current viewport range based on the upper left corner coordinates and width and height information of the current viewport using the getImageData function of the canvas tag; wherein each pixel data contains an RGBA value; using the R value as the raster value at the corresponding position; and determining the effective field range in the current viewport range based on the raster value of the current viewport range.
[0071] In one embodiment, the method further includes: updating and drawing the flow field particles in a WebGL environment; during the update phase, setting an event listener, and updating the flow field particles if a drag or zoom event is triggered.
[0072] In one embodiment, the method further includes: updating and drawing the flow field particles in a WebGL environment; calculating the updated particle positions using four position textures and one velocity texture during the calculation phase of the drawing phase; and drawing the particles to the screen using three frame buffers and one color buffer during the rendering phase of the drawing phase.
[0073] In one specific embodiment, a random seed is generated based on latitude and longitude texture. The random latitude and longitude texture generation process is as follows:
[0074] Calculate the latitude and longitude range of the current viewport:
[0075] ;
[0076] Then, using canvas This method retrieves raster data for a specified rectangular area on the canvas. The coordinates of the top left corner and the width and height of the viewport:
[0077] ;
[0078] Calculate latitude and longitude using raster index:
[0079] ;
[0080] Calculate the latitude and longitude corresponding to each valid pixel in the current viewport, assuming the width and height of the current viewport pixels are respectively... and Then, in pixel space, the latitude and longitude at coordinates (x, y) can be calculated as follows:
[0081] ;
[0082] Retrieves raster data at a specified latitude and longitude, where `index` is the corresponding index in the raster data within the current viewport range. The implementation is as follows:
[0083] ;
[0084] Calculate the raster values of the four sampling points surrounding the coordinates (x, y). ,in For vector field data precision, ceil and floor are functions for rounding up and down, respectively, with the rounding float representing precision.
[0085] ;
[0086] ; ;
[0087] ; ;
[0088] ; ;
[0089] ;
[0090] Determine whether the pixel at coordinates (x, y) is a valid pixel based on the raster values of the four surrounding points:
[0091] ;
[0092] filter For pixels with a value of 0, store their corresponding latitude and longitude in an array. In this process, the latitude and longitude of all pixels within the current viewport's effective field of view are obtained, and then mapped to a width and height of RGBA encoding. and Texture:
[0093] ;
[0094] In another embodiment, such as Figure 4 As shown, the specific generation stage of random seed points involves the following steps: data preprocessing, initialization, update, and rendering. The initialization stage is completed in the CPU, including four steps: acquiring viewport-wide raster data, calculating pixel latitude and longitude within the effective area, mapping latitude and longitude textures, and generating random seed points. Simultaneously, event listeners are set in the program. If a drag or zoom event is triggered, the update stage is executed. This stage follows the same process as the initialization stage, except that the latitude and longitude textures are transferred to the GPU (WebGL buffer), and the random seed point generation steps are performed in the GPU. In the rendering stage, during the visualization of vector field data based on WebGL, each frame's rendering involves two stages: calculation and rendering. The calculation stage refers to calculating the position of the particles in the next frame based on the position and velocity of the particles in the current frame. The rendering stage refers to rendering particle trajectories based on specified triangular primitives.
[0095] During the computation phase, positions are updated using four position textures and one velocity texture. The `lastParticlePosition` texture stores the particle position from the previous frame, the `currentParticlePosition` texture stores the position from the current frame, the `nextParticlePosition` texture stores the position from the next frame, the `postProcessingPosition` texture stores information about post-processing for the next frame's particle position, including the end of the particle's lifecycle and regeneration, and boundary checks. The `particleSpeed` texture stores the particle velocity. The main textures involved in the computation phase are as follows: Figure 5 As shown.
[0096] During the rendering phase, particles are drawn to the screen using three frame buffers and one color buffer. Frame buffer objects can be used in place of color buffers or depth buffers, such as... Figure 6As shown, objects drawn in the framebuffer are not directly displayed on the canvas. They can be processed before being displayed on the screen, or the content of the framebuffer can be used directly as a texture image. This rendering process is also known as off-screen rendering. Framebuffer1 draws particle trajectories and saves them as textures. Framebuffer2 adds trailing effects to the particle trajectories and considers the impact of terrain on visualization. Framebuffer3 saves the particle trajectories for the next frame, and finally, the images are rendered to the screen through the color buffer. The main textures involved in the rendering stage are as follows: Figure 7 As shown.
[0097] In one specific embodiment, global ocean current data was selected, and the visualization effect under the constraints of irregular ocean regions after removing land was shown below. Figure 8 As shown.
[0098] It should be understood that, although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0099] In one embodiment, such as Figure 9 As shown, a flow field seed point generation device under irregular region constraints in a GPU is provided, including: a raster data determination module 1002, an effective field range determination module 1004, a latitude and longitude texture determination module 1006, a flow field seed point generation module 1008, and an update rendering module 1010, wherein:
[0100] The raster data determination module 1002 is used to acquire flow field vector field data and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that there are no missing values in the vector field data;
[0101] The effective field range determination module 1004 is used to acquire the raster data of the current viewport range and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; a valid pixel is a pixel whose raster value of the four surrounding sampling points is 1;
[0102] The latitude and longitude texture determination module 1006 is used to calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude to latitude and longitude texture through RGBA encoding;
[0103] The flow field seed point generation module 1008 is used to pass the latitude and longitude texture to the WebGL buffer and generate random particles in the GPU as flow field seed points based on the latitude and longitude texture.
[0104] Update drawing module 1010, used for updating and drawing flow field particles in the WebGL environment.
[0105] The effective field range determination module 1004 is also used to acquire the image corresponding to the raster data of the flow field; acquire the latitude and longitude range of the current viewport, and obtain the upper left corner coordinates and length and width information of the current viewport on the image based on the latitude and longitude range of the current viewport; obtain the pixel data of the current viewport range based on the upper left corner coordinates and length and width information of the current viewport through the getImageData function of the canvas tag; wherein, each pixel data contains RGBA values; use the R value as the raster value of the corresponding position; and determine the effective field range in the current viewport range based on the raster value of the current viewport range.
[0106] The effective field range determination module 1004 is also used to obtain the viewport image corresponding to the current viewport range;
[0107] For each pixel in the viewport image, determine whether the grid values of the four sampling points surrounding the pixel are all 1. If so, the pixel is determined to be a valid pixel; otherwise, the pixel is determined to be an invalid pixel. The valid field range in the current viewport range is formed by all valid pixels within the current viewport range.
[0108] The latitude and longitude texture determination module 1006 is also used to traverse the viewport image along the x-axis, calculate the position of all valid pixels on the y-axis corresponding to the longitude x, and obtain the latitude and longitude of all pixels based on the coordinate values of all valid pixels and the latitude and longitude range of the current viewport.
[0109] The latitude and longitude texture determination module 1006 is also used to perform RGBA encoding on latitude and longitude, storing longitude information in RG and latitude information in BA.
[0110] The update drawing module 1010 is also used to update and draw the flow field particles in the WebGL environment; during the update phase, an event listener is set, and if a drag or zoom event is triggered, the flow field particles are updated.
[0111] The update drawing module 1010 is also used to update and draw flow field particles in the WebGL environment; in the calculation phase of the drawing phase, the updated particle positions are calculated using four position textures and one velocity texture; in the rendering phase of the drawing phase, the particles are drawn to the screen using three frame buffers and one color buffer.
[0112] Specific limitations regarding the flow field seed point generation device under irregular region constraints in GPUs can be found in the limitations of the flow field seed point generation method under irregular region constraints in GPUs mentioned above, and will not be repeated here. Each module in the aforementioned flow field seed point generation device under irregular region constraints in GPUs can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the corresponding operations of each module.
[0113] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements a method for generating seed points for flow fields under irregular region constraints in a GPU. The display screen can be a liquid crystal display (LCD) or an e-ink display. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0114] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps in the above method embodiment.
[0116] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0117] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0118] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for generating seed points for flow fields under irregular region constraints in a GPU, characterized in that, The method includes: Acquire flow field vector data, and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value, and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values; Obtain the raster data of the current viewport range, and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1; Calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding; The latitude and longitude texture is passed to the WebGL buffer, and random particles are generated in the GPU based on the latitude and longitude texture as seed points for the flow field. Update and render flow field particles in a WebGL environment; Determining the effective field range within the current viewport range based on the grid values of the current viewport range includes: Get the viewport image corresponding to the current viewport range; For each pixel in the viewport image, determine whether the grid values of the four sampling points surrounding the pixel are all 1. If so, the pixel is determined to be a valid pixel; otherwise, the pixel is determined to be an invalid pixel. The effective field range within the current viewport is constituted by all valid pixels within the current viewport range.
2. The method according to claim 1, characterized in that, Acquire the raster data of the current viewport range, and determine the effective field range within the current viewport range based on the raster data of the current viewport range, including: Obtain the image corresponding to the raster data of the flow field; Obtain the latitude and longitude range of the current viewport, and obtain the upper left corner coordinates and length and width information of the current viewport on the image based on the latitude and longitude range of the current viewport; The getImageData function of the canvas tag obtains the pixel data of the current viewport range based on the coordinates of the top left corner and the width and height information of the current viewport; where each pixel data contains RGBA values; Use the R value as the raster value for the corresponding position; The effective field range within the current viewport range is determined based on the grid value of the current viewport range.
3. The method according to claim 1, characterized in that, Calculate the latitude and longitude corresponding to all pixels within the effective field range, including: The viewport image is traversed along the x-axis, and the positions of all valid pixels on the y-axis corresponding to longitude x are calculated. The latitude and longitude of all pixels are obtained based on the coordinates of all valid pixels and the latitude and longitude range of the current viewport.
4. The method according to claim 3, characterized in that, Mapping the latitude and longitude to a latitude and longitude texture via RGBA encoding includes: The latitude and longitude are encoded using RGBA, with the longitude information stored in RG and the latitude information stored in BA.
5. The method according to claim 4, characterized in that, Updating and rendering flow field particles in the WebGL environment includes: Update and draw the flow field particles in the WebGL environment; during the update phase, set up event listeners, and if a drag or zoom event is triggered, update the flow field particles.
6. The method according to claim 5, characterized in that, Updating and rendering flow field particles in the WebGL environment includes: Update and render flow field particles in a WebGL environment; During the calculation phase of the rendering phase, the updated particle positions are calculated using four position textures and one velocity texture; During the rendering phase of the drawing phase, particles are drawn to the screen using three frame buffers and one color buffer.
7. A flow field seed point generation apparatus under irregular region constraints in a GPU, used to implement the flow field seed point generation method under irregular region constraints in a GPU as described in any one of claims 1 to 6, characterized in that, The device includes: The raster data determination module is used to acquire flow field vector field data and map it to raster data of 0 or 1 based on whether the vector field data at the current position is a normal value; where 1 indicates that the vector field data is a normal value and 0 indicates that the vector field data is an abnormal value; the vector field data being a normal value means that the vector field data has no missing values; The effective field range determination module is used to acquire the raster data of the current viewport range and determine the effective field range in the current viewport range based on the raster data of the current viewport range; any pixel in the effective field range is a valid pixel; the valid pixel is a pixel whose raster value of the four surrounding sampling points is 1; The latitude and longitude texture determination module is used to calculate the latitude and longitude corresponding to all pixels in the effective field range, and map the latitude and longitude into a latitude and longitude texture through RGBA encoding; The flow field seed point generation module is used to pass the latitude and longitude texture to the WebGL buffer and generate random particles in the GPU as flow field seed points based on the latitude and longitude texture. Update the drawing module, which is used to update and draw flow field particles in the WebGL environment.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.