A thermal map rendering method, system, medium and device
Through instantiated rendering and off-screen rendering technology, combined with new smooth functions to process heat maps, the problems of slow and unsmooth rendering speed in the existing technology are solved, and high-performance and high-precision heat map display is achieved.
Patent Information
- Application Number
- CN202210507987.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2042-05-10
AI Technical Summary
The existing thermal graphics rendering technology is slow to process large sizes and large resolutions, resulting in stuttering of pages and failing to effectively use the graphics card hardware for acceleration, resulting in unsmooth display.
The instantiated rendering method and off-screen rendering technology are used to combine the new smooth function to perform gradient smoothing of heat points, and the results are cached in shared texture memory, reducing the CPU-GPU transfer process and improving performance.
It realizes high-performance thermal map rendering, reduces the number of rendered drawCalls, improves performance, ensures the smooth effect of thermal maps, and meets the display needs of super-large sizes and large resolutions.
Smart Images

Figure CN114937117B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a thermal map rendering method, system, medium and device. Background Art
[0002] At present, heat map is a commonly used technology in three-dimensional virtual simulation technology. It can realize the intuitive display of various types of data, such as: temperature, crowd density, road congestion, etc. It intuitively displays the degree of data aggregation in the form of gradient colors, providing an intuitive reference for data analysis and trend judgment.
[0003] Most existing technologies are based on canvas drawing, and their data calculation and processing process is based on the CPU. When dealing with large-scale and high-resolution thermal drawing, the calculation and drawing speed is relatively slow. The larger the resolution, the longer the calculation time, resulting in longer blocking time, which causes the display system page to freeze, seriously affecting the user experience and failing to meet interactive operations. A deeper look at the reasons behind this shows that this approach, based on canvas, uses the canvas's drawImage and getImageData methods, and other processes are performed in the CPU, failing to make good use of the graphics hardware for acceleration.
[0004] In view of this, the present invention proposes a multi-format high-performance thermal map rendering method to meet the needs of ultra-large-size and large-resolution thermal mapping, support multiple formats such as two-dimensional, three-dimensional, and mosaic points, and design a new smoothing function to make the overlay result smoother.
[0005] The prior art currently has the following problems:
[0006] Commonly used gradient techniques include linear and Gaussian smoothing. However, linear and Gaussian functions will have discontinuous jumps in value after multiple points are superimposed, resulting in an overall non-smooth curve.
[0007] Take the Gaussian function as an example. The projection range of the orthogonal camera is -1 on the left and 1 on the right. When the Gaussian function is drawn from the center of the single-point canvas, at the edge x = -1 and x = 1, the value of the Gaussian function is a very small value, but not 0, such as Figure 1 As shown in the figure, the value of the Gaussian curve at x = -1 and x = 1 is 0.0356. When multiple such functions are superimposed, the values of these small jumps will accumulate. When the accumulation reaches a certain level, the thermal image will have many folds, resulting in an unsmooth phenomenon, such as Figure 2 and Figure 3Of course, adjusting the Gaussian function σ parameter can make the boundary point infinitely close to 0. However, too large a σ value will cause the Gaussian curve to become a narrow strip, forming an overly steep curve, so that the thermal points formed are too concentrated in the center of the thermal point and insufficiently distributed around it.
[0008] In order to solve the problems existing in the existing technology, it is urgently necessary to develop a multi-format high-performance thermal map rendering method that meets the needs of ultra-large-size and large-resolution thermal mapping, supports multiple formats such as two-dimensional, three-dimensional, and mosaic points, and designs a new smoothing function to make the overlay result smoother. Summary of the invention
[0009] The technical problem to be solved by the present invention is to provide a thermal map rendering method, system, medium and device in view of the deficiencies in the prior art.
[0010] The technical solution of the present invention to solve the above technical problems is as follows:
[0011] The present invention provides a heat map rendering method, the method comprising:
[0012] Thermal point overlay rendering steps: construct the model to be rendered and the various resources required for the model to be rendered, render the model to be rendered in the thermal point overlay rendering pipeline using the instanced drawing mode, perform gradient smoothing on the thermal value of the thermal point based on a preset smoothing function, and use off-screen rendering technology to cache the grayscale overlay results of the thermal point in the shared texture memory;
[0013] User terminal rendering steps: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale overlay results of the thermal points based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing results to the user display page.
[0014] Preferably, the above-mentioned hot spot overlay rendering step further includes:
[0015] Steps for building smooth rendering: prepare the hotspot data, build the first scene, the first camera, the first geometry, the first rendering material, build the first rendering queue, and add the first camera and the first geometry to the first scene;
[0016] Smooth rendering parameter input step: multiple parameters required for rendering materials are input into the shader in the form of uniforms, and the thermal value data of the thermal point and the rotation, scaling and translation matrix of the thermal point are passed as vertex data to the vertex shader in the form of attributes;
[0017] Smoothing step: setting the size of the drawn thermal point to a predetermined size, passing the thermal data through the vertex shader and then processing it into the fragment shader, using a preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and using the triangle drawing mode to complete the smooth rendering;
[0018] Output smooth result step: The fragment shader outputs the grayscale overlay processing result of the hot spot to the frame buffer and then to the shared texture memory.
[0019] Preferably, the user terminal rendering step further includes:
[0020] Constructing the shader rendering step: constructing the second scene, the second camera, the second geometry, the second rendering material, constructing the second rendering queue, adding the second camera and the second geometry to the second scene, and constructing the gradient color band texture map;
[0021] Steps for transferring shading rendering parameters: select a rendering material from 2D normal, 3D, and mosaic as needed; transfer the smoothing results of the gradient color band texture map and the heat point to the shader in the form of uniforms texture;
[0022] Shading and rendering steps: the vertex coordinates of the heat point are transferred from the vertex shader to the fragment shader for processing, and the shading and rendering are completed using the triangle drawing mode;
[0023] Output shading result step: The fragment shader outputs the user terminal processing result of the hot spot to the user page.
[0024] Preferably, the above-mentioned shading and rendering step further comprises:
[0025] 3D material rendering step: construct the second geometric body into a 3D geometric body, pass the grayscale superposition result into the vertex shader, sample and extract the alpha value of the grayscale superposition result as the undulation height value, stretch and project the geometric body to achieve the 3D undulation effect of the geometric body, and complete the sampling of the gradient color band texture map in the fragment shader to achieve 3D material coloring;
[0026] Mosaic material rendering steps: in the fragment shader, the mosaic UV coordinates are calculated according to the mosaic size, a gradient weight coefficient is calculated from the center of the mosaic to the edge, the mosaic UV coordinates and texture coordinates are used to sample the gradient color band texture map respectively, and the two sampling results are mixed using the weight coefficient, and the mixed result is output.
[0027] 2D ordinary heat map material rendering steps: pass the gradient color band texture map and the smooth processing result of the heat point into the fragment shader through the uniforms texture form, and pass the heat point and the coordinates of the heat point into the shader through the attributes form, and pass the texture coordinates from the vertex shader to the fragment shader in the varyings form. Finally, in the fragment shader, use the alpha value of the smooth processing result after the heat point is superimposed to construct the sampling coordinate (alpha, 0.5), color the gradient color and sample it, and output the final heat map result.
[0028] Preferably, the preset smooth function is:
[0029]
[0030] Wherein z(x,y) is the height value corresponding to the smooth function of the thermal point at the plane point (x,y), x is the horizontal axis of the thermal point, y is the vertical axis of the thermal point, and (x,y) is the independent variable of the smooth function.
[0031] The present invention also provides a thermal map rendering system, which adopts the thermal map rendering method as described above, and the system includes:
[0032] Thermal point overlay rendering module: constructs the model to be rendered and the various resources required for the model to be rendered, renders the model to be rendered in the thermal point overlay rendering pipeline using the instanced drawing mode, performs gradient smoothing on the thermal value of the thermal point based on the preset smoothing function, and uses off-screen rendering technology to cache the grayscale overlay results of the thermal point in the shared texture memory;
[0033] User terminal rendering module: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale overlay results of the thermal points based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing results to the user display page.
[0034] Preferably, the above-mentioned hot spot overlay rendering module also includes:
[0035] Build a smooth rendering module: prepare the hotspot data, build the first scene, the first camera, the first geometry, the first rendering material, build the first rendering queue, and add the first camera and the first geometry to the first scene;
[0036] Smooth rendering parameter input module: pass various parameters required for rendering materials into the shader in the form of uniforms, and pass the hot spot data as vertex data into the hot spot overlay rendering pipeline;
[0037] Smoothing module: Set the size of the drawn thermal point to a predetermined size, pass the thermal data to the fragment shader after being processed by the vertex shader, use the preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and use the triangle drawing mode to complete the smooth rendering;
[0038] Output smooth result module: The fragment shader outputs the grayscale overlay processing results of the hot spots to the frame buffer and then to the shared texture memory.
[0039] Preferably, the above-mentioned user terminal rendering module also includes:
[0040] Constructing a shading rendering module: constructing a second scene, a second camera, a second geometry, a second rendering material, constructing a second rendering queue, adding the second camera and the second geometry to the second scene, and constructing a gradient color band texture map;
[0041] Shading rendering parameter input module: select a rendering material from 2D normal, 3D, and mosaic as needed; pass the smoothing results of the gradient color band texture map and thermal points into the shader in the form of uniforms texture;
[0042] Shading and rendering module: The vertex coordinates of the thermal point are transferred from the vertex shader to the fragment shader for processing, and the shading and rendering are completed using the triangle drawing mode;
[0043] Output shading result module: The fragment shader outputs the user terminal processing results of the hot spot to the user page.
[0044] The present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned thermal map rendering method when executed by a processor.
[0045] The present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the above-mentioned thermal map rendering method are implemented.
[0046] The beneficial effects of this method invention are:
[0047] 1) The present invention proposes a large-screen display system that meets the requirements of ultra-large size and high precision, and displays thermal map effects in various forms;
[0048] 2) The present invention uses instanceGeometry and instantiation rendering to greatly reduce the number of rendering drawCalls and significantly improve performance;
[0049] 3) The invention uses a new smoothing function to solve the edge folding phenomenon when the thermal points are superimposed, ensuring the smoothness of the thermal map;
[0050] 4) The present invention integrates multiple forms of thermal map drawing solutions such as two-dimensional, three-dimensional, and mosaic points, and the thermal map established by the present invention can meet the requirements of large-screen ultra-large size and high-precision effects.
[0051] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments of the present invention or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A Gaussian function diagram of the prior art Figure 1 ;
[0054] Figure 2 The Gaussian function superposition profile diagram of the prior art Figure 2 ;
[0055] Figure 3 This is a schematic diagram of the heat map result after superimposing the Gaussian function of the existing technology Figure 3 ;
[0056] Figure 4 A schematic diagram of the thermal map rendering method of the present invention;
[0057] Figure 5 A schematic diagram of a rendering pipeline process according to a specific embodiment of the present invention;
[0058] Figure 6 It is a schematic diagram of an instantiation mode of a specific embodiment of the present invention;
[0059] Figure 7 This is a schematic diagram of a three-dimensional surface of a smooth function according to an embodiment of the present invention;
[0060] Figure 8 It is a schematic diagram of a smooth function profile curve according to an embodiment of the present invention;
[0061] Fig. 9 A schematic cross-sectional view of grayscale superposition of an embodiment of the present invention;
[0062] Fig.10 Schematic diagram of the heat map result after grayscale superposition in an embodiment of the present invention;
[0063] Fig.11 A schematic diagram of generating a gradient color band on a terminal page according to an embodiment of the present invention;
[0064] Fig.12 The final rendering effect (2D) of the embodiment of the present invention is shown as follows Figure 1 ;
[0065] Fig.13 The final rendering effect (3D) of the embodiment of the present invention is shown as follows Figure 2 ;
[0066] Fig.14 The final rendering effect (mosaic) of the embodiment of the present invention is shown as follows Figure 3 ;
[0067] Fig.15 Schematic diagram of the thermal map rendering system of the present invention. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0069] The present invention aims to provide a multi-form, high-precision, and high-performance thermal map rendering method to meet the thermal mapping requirements in ultra-large-size large-screen systems, and at the same time design a new smoothing function to make the superposition result smoother.
[0070] The technical solution of the present invention to solve the above technical problems is as follows: Figure 4 As shown, the present invention provides a heat map rendering method, the method comprising:
[0071] Thermal point overlay rendering step S10: construct the model to be rendered and various resources required for the model to be rendered, render the model to be rendered in the thermal point overlay rendering pipeline using the instantiation drawing mode, perform gradient smoothing on the thermal value of the thermal point based on a preset smoothing function, and use off-screen rendering technology to cache the grayscale overlay result of the thermal point in the shared texture memory;
[0072] User terminal rendering step S20: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale overlay results of the thermal points based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing results to the user display page.
[0073] Preferably, the above-mentioned hot spot overlay rendering step S10 further includes:
[0074] Steps for building smooth rendering: prepare the hotspot data, build the first scene, the first camera, the first geometry, the first rendering material, build the first rendering queue, and add the first camera and the first geometry to the first scene;
[0075] Smooth rendering parameter input step: multiple parameters required for rendering materials are input into the shader in the form of uniforms, and the thermal value data of the thermal point and the rotation, scaling and translation matrix of the thermal point are passed as vertex data to the vertex shader in the form of attributes;
[0076] Smoothing step: setting the size of the drawn thermal point to a predetermined size, passing the thermal data through the vertex shader and then processing it into the fragment shader, using a preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and using the triangle drawing mode to complete the smooth rendering;
[0077] Output smooth result step: The fragment shader outputs the grayscale overlay processing result of the hot spot to the frame buffer and then to the shared texture memory.
[0078] Preferably, the user terminal rendering step S20 further includes:
[0079] Constructing the shader rendering step: constructing the second scene, the second camera, the second geometry, the second rendering material, constructing the second rendering queue, adding the second camera and the second geometry to the second scene, and constructing the gradient color band texture map;
[0080] Steps for transferring shading rendering parameters: select a rendering material from 2D normal, 3D, and mosaic as needed; transfer the smoothing results of the gradient color band texture map and the heat point to the shader in the form of uniforms texture;
[0081] Shading and rendering steps: the vertex coordinates of the heat point are transferred from the vertex shader to the fragment shader for processing, and the shading and rendering are completed using the triangle drawing mode;
[0082] Output shading result step: The fragment shader outputs the user terminal processing result of the hot spot to the user page.
[0083] Preferably, the above-mentioned shading and rendering step further comprises:
[0084] 3D material rendering steps: construct the second geometric body into a 3D geometric body, pass the grayscale superposition result into the vertex shader, sample and extract the alpha value of the grayscale superposition result as the undulation height value, stretch and project the geometric body to achieve the 3D undulation effect of the geometric body, and complete the sampling of the gradient color band texture map in the fragment shader to achieve 3D material coloring;
[0085] Mosaic material rendering steps: in the fragment shader, the mosaic UV coordinates are calculated according to the mosaic size, a gradient weight coefficient is calculated from the center of the mosaic to the edge, the mosaic UV coordinates and texture coordinates are used to sample the gradient color band texture map respectively, and the two sampling results are mixed using the weight coefficient, and the mixed result is output.
[0086] 2D ordinary heat map material rendering steps: pass the gradient color band texture map and the smooth processing result of the heat point to the fragment shader through the uniforms texture form, pass the heat point and the coordinates of the heat point to the shader through the attributes form, and pass the texture coordinates from the vertex shader to the fragment shader in the varyings form. Finally, in the fragment shader, the alpha value of the smooth processing result after the heat point is superimposed is used to construct the sampling coordinate (alpha, 0.5), the gradient color is sampled, and the final heat map result is output.
[0087] Preferably, the preset smooth function is:
[0088]
[0089] Wherein z(x,y) is the height value corresponding to the smooth function of the thermal point at the plane point (x,y), x is the horizontal axis of the thermal point, y is the vertical axis of the thermal point, and (x,y) is the independent variable of the smooth function.
[0090] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings:
[0091] The present invention uses WebGL to directly construct hot spots. For a large number of hot spots, objects with the same geometry and material but different world transformations, the present invention uses instanced rendering (Instance Geometry), which effectively reduces the number of drawCalls, thereby improving the overall rendering performance of the application. At the same time, the present invention uses off-screen rendering technology to overlay the rendering pipeline from the hot spots, and the output results are stored in the texture memory, which will be directly used by another rendering pipeline (user terminal rendering pipeline), eliminating the transfer process between the CPU and GPU, greatly improving speed and efficiency. The shared texture memory and rendering pipeline flow chart is shown below. Figure 5 As shown. The upper part is the heat point overlay rendering pipeline, and the lower part is the user terminal rendering pipeline, with a shared texture memory in the middle. In addition, in the heat point overlay rendering pipeline process, the smooth function constructed by the present invention performs radial gradient smoothing on the heat value of the heat point from the center of the circle to the surrounding area, and it will be smoother after completing multi-point overlay.
[0092] The specific steps of the present invention are divided into the following two processes: grayscale superposition of hot spots and terminal display.
[0093] 1. Grayscale overlay of hot spots
[0094] 1.1 Data preparation: input data in standard geojson format, convert it into [x,y,heatValue] format, and calculate the maximum and minimum values at the same time.
[0095] 1.2 Build a new scene 1, camera 1, instance geometry (InstanceGeometry), rendering material 1, build rendering queue 1, and add camera 1 and geometry 1 to scene 1;
[0096] 1.2.1 The process of creating instance geometry (InstanceGeometry) includes:
[0097] 1.2.1.1 First create a plane geometry (PlaneGeometry);
[0098] 1.2.1.2 Create a new three-dimensional position vector (position), quaternion orientation (orientation), three-dimensional scaling vector (scale), rotation, scaling and translation matrix variable (instanceMatrix), assign the thermal point coordinate information to position; convert position, orientation and scale to generate instanceMatrix. Store the thermal value of the thermal point in the heatValue array;
[0099] 1.3 Enter the hotspot overlay rendering pipeline from the graphics API (Application Programming Interface) entry, such as Figure 5 , pass in the heat value data (heatValue) of the heat point and the rotation, scaling and translation matrix (instanceMatrix) of the heat point as vertex data;
[0100] 1.4 Rendering material uses shader material, passes the circle radius value R, the maximum heat value (MaxHeatValue), and the minimum heat value (MinHeatValue) to the shader in the form of uniforms; passes the instanceMatrix and heatValue values to the vertex shader in the form of attributes;
[0101] 1.5 The vertex shader and fragment shader in the rendering pipeline are both programmable shaders, and programmers can encode and operate them; set the size of the drawing hot spot to 2R, such as Figure 6 As shown;
[0102] 1.6 In the vertex shader, multiply instanceMatrix by the local coordinates of the heat point, then multiply it by the projection, view, and model matrices, and finally output it to gl_Position; use varying to pass the heatValue from the vertex shader to the fragment shader.
[0103] 1.7 The data in the vertex shader is processed by hardware, assembled and rasterized before being passed to the fragment shader
[0104] In the 1.8 fragment shader, the smoothing function constructed by the present invention is used to smooth the thermal value of the thermal point from the center of the thermal point to the surrounding radial gradient, and it will be smoother after multi-point superposition;
[0105] In the 1.9 fragment shader, calculate the proportion of this heat value between the maximum heat value (MaxHeatValue) and the minimum heat value (MinHeatValue), multiply it by the result of the 1.8 process, and output the final result to the alpha channel of gl_FragColor;
[0106] 1.10 The drawing mode (drawMode) of this rendering process uses the triangle drawing mode and the instance drawing method;
[0107] 1.11 The camera uses an orthographic camera, and the left, right, bottom, top, near, and far parameters are set to -1, 1, -1, 1, 0.01, 2 respectively; the camera position is placed directly above the geometry, and the coordinates are (0, 1, 0);
[0108] 1.12 Set the transparent property of the rendering material to true;
[0109] 1.13 The fragment shader outputs the final processing result to the frame buffer and then to the texture memory in preparation for the next rendering pipeline.
[0110] 2. Terminal interface display
[0111] 2.1 Build new scene 2, camera 2, geometry 2, rendering material 2, and build rendering queue 2
[0112] 2.2 Construct a gradient color band texture map (colormap). The gradient color band texture map is a texture generated by canvas, with a width of 256 and a height of 1. By inputting 4 [0-1] values and corresponding colors, the 4 values are 0, 0.33, 0.66, and 1. The corresponding colors are: 'rgb(0,0,255)', 'rgb(0,255,0)', 'rgb(255,255,0)', and 'rgb(255,0,0)'. Then call the canvas's createLinearGradient and addColorStop functions to generate the corresponding gradient texture map. The process is as follows: Fig.11 shown.
[0113] 2.3 Rendering material uses shader material. You can choose different materials for rendering as needed:
[0114] 2.3.13D Materials
[0115] 2.3.1.1 The result (grayTexture) and gradient color band texture (colormap) generated by the previous rendering pipeline are passed in as textures through the uniforms global variable, and whether it is transparent (isOpacity) and the transparency value (opacityValue) are passed in as numerical values to the shader.
[0116] 2.3.1.2 The coordinates of the thermal point and the corresponding coordinates of this point are passed to the vertex shader in the form of attributes. The vertex coordinates are then passed from the vertex shader to the fragment shader in the form of varyings for use when sampling grayTexture and colormap.
[0117] 2.3.1.3 Perform certain subdivision operations on geometry 2 to meet the requirements of 3D geometry construction; pass the grayscale buffer result generated in step 1.12 into the vertex shader, sample and extract its alpha channel value, which is the result after superposition of the thermal value, stretch it a certain amount, add it to the Z component of the local coordinate position, and then multiply the superimposed local coordinate by the projection view model transformation matrix, and finally output it to gl_Position to achieve the 3D undulating effect of the geometry.
[0118] 2.3.1.4 In the fragment shader, the colormap and grayTexture are sampled respectively; grayTexture is sampled to obtain its alpha value; the colormap uses the texture coordinate (alpha, 0.5) to obtain the final display color after sampling, and the transparency is the product of the alpha value and the opacityValue.
[0119] 2.3.2 Mosaic material
[0120] 2.3.2.1 Rendering material uses shader material, and passes the result (grayTexture) and gradient band texture map (colormap) generated by the previous rendering pipeline in the form of textures through the uniforms global variable, and passes whether it is transparent (isOpacity), transparency value (opacityValue), texture size (texSize) and mosaic size (mosaicSize) to the fragment shader in numerical form.
[0121] 2.3.2.2 The coordinates of the thermal point and the corresponding coordinates of this point are passed to the vertex shader in the form of attributes. The texture coordinates (vUv) are then passed from the vertex shader to the fragment shader in the form of varyings for use when grayTexture and colormap sampling.
[0122] 2.3.2.3 In the fragment shader, first calculate the mosaic UV coordinates (uvMosaic) based on the mosaic size; then calculate a gradient weight percentage from the center of the mosaic to the edge;
[0123] 2.3.2.4 Use uvMosaic and vUv respectively to sample the colormap, mix the two results using percent, and output the result to the rgb channel of gl_FragColor.
[0124] 2.3.2.5 Multiply the alpha value of the uvMosaic result in the previous step by percent and then by opacityValue, and assign it to the alpha channel of gl_FragColor.
[0125] 2.3.32D common heat map material
[0126] 2.3.3.1 Rendering material uses shader material, and passes the result (grayTexture) and gradient band texture map (colormap) generated by the previous rendering pipeline in the form of textures through the uniforms global variable, and passes whether it is transparent (isOpacity) and the transparency value (opacityValue) in the form of values to the fragment shader.
[0127] 2.3.3.2 The coordinates of the thermal point and the corresponding coordinates of this point are passed to the vertex shader in the form of attributes. The texture coordinates are then passed from the vertex shader to the fragment shader in the form of varyings for use in grayTexture and colormap sampling. The sampling results are output to gl_FragColor.
[0128] 2.4 The drawing mode (drawMode) of this rendering process uses the triangle drawing mode (TRIANGLE_STRIP)
[0129] 2.5 The camera uses a perspective camera, the near clipping plane is 0.01, the far clipping plane is 10000, the far clipping plane viewport aspect ratio is the screen aspect ratio, and the field of view value is 30;
[0130] 2.6 The fragment shader outputs the final processing result to the user page.
[0131] In the process of constructing and drawing the heat point, a rectangular patch (two triangles) is drawn, and then an inscribed circle is constructed from the center of the rectangle to generate a gradient radiation circle, as shown below Figure 6 shown.
[0132] In the fragment shader, a circle is set to radiate from the center to the surroundings, and the thermal value is gradually changed, so that the multi-point superposition will be smoother. The present invention uses a new smoothing function, the equation is shown in Formula 1, the equation satisfies the second-order continuous differentiability, the boundary point value is 0, the equation surface and the curve profile are respectively as shown in Figure 7 and Figure 8 As shown, the curve is smooth enough before and after superposition. Fig. 9 As shown in the figure, the thick line is the cumulative value after superposition, and the thin line is the smooth function curve of a single thermal point. Figure 3 , the present invention generates a grayscale overlay map, such as Fig.10 As shown, it is smoother.
[0133]
[0134] Wherein z(x,y) is the height value corresponding to the smooth function of the thermal point at the plane point (x,y), x is the horizontal axis of the thermal point, y is the vertical axis of the thermal point, and (x,y) is the independent variable of the smooth function.
[0135] Furthermore, the superposition results of the rendering heat points in the previous process are transmitted to the user terminal rendering pipeline in the form of texture, and the superimposed heat value is stored in the texture alpha channel.
[0136] The terminal page rendering process is as follows: Construct the terminal rendering pipeline as follows Figure 5As shown in the lower part, a new scene 2, camera 2, geometry 2, rendering material 2 are constructed, and rendering queue 2 is constructed, and the result is finally returned to the user display page (on the browser). The geometry uses triangles, and the drawing mode (drawMode) uses the triangle drawing mode (TRIANGLE_STRIP). The camera uses a perspective camera, and the rendering material uses a shader material. The grayTexture generated by the previous rendering pipeline, the gradient band texture map (colormap), whether it is transparent (isOpacity), and the transparency value (opacityValue) are passed to the shader in the form of uniforms. The coordinates of the hot point and the corresponding coordinates of this point are passed to the vertex shader in the form of attributes, and the texture coordinates are then passed from the vertex shader to the fragment shader in the form of varyings. The rendering material blending mode is set to standard mode.
[0137] The gradient color band texture map (colormap) is a texture generated by canvas, with a width of 256 and a height of 1. It provides users with maximum flexibility through the external interface. Input n (n=4 in this case) [0-1] values and corresponding colors, and then call canvas's createLinearGradient and addColorStop functions to generate the corresponding gradient texture map. The process is as follows: Fig.11 shown.
[0138] The final rendering result is as follows Figure 12-14 As shown, this result is applicable to various scenarios, pure web pages, digital parks, three-dimensional earth, and is especially suitable for the thermal map effect of two- and three-dimensional integrated, multi-format large-size, high-precision large-screen display system.
[0139] The present invention also provides a thermal map rendering system, such as Fig.15 As shown, using the above-mentioned heat map rendering method, the system includes:
[0140] Thermal point overlay rendering module 10: constructs the model to be rendered and various resources required for the model to be rendered, renders the model to be rendered in the thermal point overlay rendering pipeline using the instantiation drawing mode, performs gradient smoothing on the thermal value of the thermal point based on a preset smoothing function, and uses off-screen rendering technology to cache the grayscale overlay result of the thermal point in the shared texture memory;
[0141] User terminal rendering module 20: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale overlay results of the thermal points based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing results to the user display page.
[0142] Preferably, the above-mentioned hot spot overlay rendering module 10 further includes:
[0143] Build a smooth rendering module: prepare the hotspot data, build the first scene, the first camera, the first geometry, the first rendering material, build the first rendering queue, and add the first camera and the first geometry to the first scene;
[0144] Smooth rendering parameter input module: multiple parameters required for rendering materials are input into the shader in the form of uniforms, and the thermal value data of the thermal point and the rotation, scaling and translation matrix of the thermal point are passed as vertex data to the vertex shader in the form of attributes;
[0145] Smoothing module: Set the size of the drawn thermal point to a predetermined size, pass the thermal data to the fragment shader after being processed by the vertex shader, use the preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and use the triangle drawing mode to complete the smooth rendering;
[0146] Output smooth result module: The fragment shader outputs the grayscale overlay processing results of the hot spots to the frame buffer and then to the shared texture memory.
[0147] Preferably, the user terminal rendering module 20 further includes:
[0148] Constructing a shading rendering module: constructing a second scene, a second camera, a second geometry, a second rendering material, constructing a second rendering queue, adding the second camera and the second geometry to the second scene, and constructing a gradient color band texture map;
[0149] Shading rendering parameter input module: select a rendering material from 2D, 3D, and mosaic as needed; pass the smoothing results of the gradient color band texture map and heat point into the shader in the form of uniforms texture.
[0150] Shading and rendering module: The vertex coordinates of the thermal point are transferred from the vertex shader to the fragment shader for processing, and the shading and rendering are completed using the triangle drawing mode;
[0151] Output shading result module: The fragment shader outputs the user terminal processing results of the hot spot to the user page.
[0152] The present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned thermal map rendering method when executed by a processor.
[0153] The present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the thermal map rendering method as described above when executing the program.
[0154] Compared with the prior art, the method of the present invention adopts:
[0155] 1) Use instanceGeometry and instanced rendering to greatly reduce the number of rendering drawCalls and significantly improve performance;
[0156] 2) Originality uses a new smoothing function to solve the edge folding phenomenon when the thermal points are superimposed, ensuring the smoothness of the thermal map;
[0157] 3) Multiple forms of heat map drawing solutions such as two-dimensional (2D), three-dimensional (3D), and mosaic points are integrated, and the heat map established by the present invention can meet the requirements of large-screen ultra-large size and high-precision effects.
[0158] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0159] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0160] In the embodiments provided by the present invention, it should be understood that the disclosed system / terminal device and method can be implemented in other ways. For example, the system / terminal device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[0161] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0162] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0163] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0164] Based on such understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or system that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0165] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
[0166] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A heat map rendering method, characterized in that: The method comprises: Thermal point overlay rendering step: constructing a model to be rendered and a variety of resources required for the model to be rendered, rendering the model to be rendered in a thermal point overlay rendering pipeline using an instantiated drawing mode, performing a gradient smoothing process on the thermal value of the thermal point based on a preset smoothing function, and using an off-screen rendering technology to cache the grayscale overlay result of the thermal point in a shared texture memory; User terminal rendering step: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale superposition result of the thermal point based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing result to the user display page; The preset smooth function is Wherein z(x,y) is the height value corresponding to the smooth function of the thermal point at the plane point (x,y), x is the horizontal axis of the thermal point, y is the vertical axis of the thermal point, and (x,y) is the independent variable of the smooth function.
2. The heat map rendering method according to claim 1, characterized in that: The step of overlaying and rendering the hot spots also includes: Constructing smooth rendering steps: preparing hot spot data, constructing a first scene, a first camera, a first geometry, a first rendering material, constructing a first rendering queue, and adding the first camera and the first geometry to the first scene; Smooth rendering parameter input step: multiple parameters required for rendering materials are input into the shader in the form of uniforms, and the thermal value data of the thermal point and the rotation, scaling and translation matrix of the thermal point are passed as vertex data to the vertex shader in the form of attributes; Smoothing step: setting the size of the drawn thermal point to a predetermined size, passing the thermal data through the vertex shader and then processing it into the fragment shader, using the preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and using the triangle drawing mode to complete the smooth rendering; Output smooth result step: the fragment shader outputs the grayscale overlay processing result of the hot spot to the frame buffer, and then outputs it to the shared texture memory.
3. The heat map rendering method according to claim 2, characterized in that: The user terminal rendering step further includes: Constructing the shaded rendering step: constructing a second scene, a second camera, a second geometric body, a second rendering material, constructing a second rendering queue, adding the second camera and the second geometric body to the second scene, and constructing the gradient color band texture map; Shading rendering parameter input step: select a rendering material from 2D normal, 3D, and mosaic as needed; input the gradient color band texture map and the smoothing result of the heat point into the shader in the form of uniforms texture; Shading and rendering step: the vertex coordinates of the thermal point are transferred from the vertex shader to the fragment shader for processing, and the shading and rendering are completed using a triangle drawing mode; Outputting the shading result step: the fragment shader outputs the user terminal processing result of the hot spot to the user page.
4. The heat map rendering method according to claim 3, characterized in that: The shading rendering step further comprises: 3D material rendering step: constructing a 3D geometric body on the second geometric body, and passing the grayscale superposition result into the vertex shader, sampling and taking out the alpha value of the grayscale superposition result as the undulation height value, and stretching and projecting the geometric body to achieve the 3D undulation effect of the geometric body, and completing the sampling of the gradient color band texture map in the fragment shader to achieve 3D material coloring; Mosaic material rendering step: in the fragment shader, according to the mosaic size, the mosaic UV coordinates are calculated, a gradient weight coefficient is calculated from the center of the mosaic to the edge, the mosaic UV coordinates and the texture coordinates are respectively used to sample the gradient color band texture map, and the two sampling results are mixed using the weight coefficient, and the mixed result is output; 2D ordinary heat map material rendering steps: pass the gradient color band texture map and the smooth processing result of the heat point into the fragment shader through the uniforms texture form, and pass the heat point and the coordinates of the heat point into the shader through the attributes form, and pass the texture coordinates from the vertex shader to the fragment shader in the varyings form. Finally, in the fragment shader, use the alpha value of the smooth processing result after the heat point is superimposed to construct the sampling coordinate (alpha, 0.5), color the gradient color and sample it, and output the final heat map result.
5. A heat map rendering system, using the heat map rendering method according to any one of claims 1 to 4, characterized in that: The system comprises: Thermal point overlay rendering module: constructs the model to be rendered and the various resources required for the model to be rendered, renders the model to be rendered in the thermal point overlay rendering pipeline using the instantiation drawing mode, performs gradient smoothing on the thermal value of the thermal point based on a preset smoothing function, and uses off-screen rendering technology to cache the grayscale overlay result of the thermal point in the shared texture memory; User terminal rendering module: construct a gradient color band texture map, select different rendering materials according to rendering needs, render the grayscale overlay result of the thermal point based on the gradient color band texture map in the user terminal rendering pipeline, and output the final thermal map processing result to the user display page.
6. The thermal map rendering system according to claim 5, characterized in that: The hot spot overlay rendering module also includes: Constructing a smooth rendering module: preparing hot spot data, constructing a first scene, a first camera, a first geometry, a first rendering material, constructing a first rendering queue, and adding the first camera and the first geometry to the first scene; Smooth rendering parameter input module: multiple parameters required for rendering materials are input into the shader in the form of uniforms, and the thermal value data of the thermal point and the rotation, scaling and translation matrix of the thermal point are passed as vertex data to the vertex shader in the form of attributes; Smoothing module: setting the size of the drawn thermal point to a predetermined size, passing the thermal data to the fragment shader after being processed by the vertex shader, using the preset smoothing function in the fragment shader to smooth the thermal value of the thermal point from the center of the circle to the surrounding radial gradient, and using the triangle drawing mode to complete the smooth rendering; Output smooth result module: The fragment shader outputs the grayscale overlay processing result of the thermal point to the frame buffer and then outputs it to the shared texture memory.
7. The thermal map rendering system according to claim 6, characterized in that: The user terminal rendering module also includes: Constructing a shading rendering module: constructing a second scene, a second camera, a second geometric body, a second rendering material, constructing a second rendering queue, adding the second camera and the second geometric body to the second scene, and constructing the gradient color band texture map; Shading rendering parameter input module: select a rendering material from 2D normal, 3D, and mosaic as needed; pass the gradient color band texture map and the smoothing result of the thermal point into the shader in the form of uniforms texture; Shading and rendering module: transferring the vertex coordinates of the thermal point from the vertex shader to the fragment shader for processing, and completing shading and rendering using a triangle drawing mode; Output shading result module: The fragment shader outputs the user terminal processing result of the hot spot to the user page.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the thermal map rendering method described in any one of claims 1 to 4 are implemented.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the heat map rendering method as described in any one of claims 1 to 4 are implemented.
