A webgpu-based address lumen range normalization shading method and system
Patent Information
- Application Number
- CN202610911384.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2046-06-24
AI Technical Summary
[0005]本申请目的是提供一种基于WebGPU的地址腔体范围归一化着色方法和系统,以解决现有技术中腔体范围归一化着色不足的问题
[0016]本申请所提供的基于WebGPU的地址腔体范围归一化着色方法,首先通过对目标数值范围参数的极值进行数值交换和范围限定,建立了稳定的归一化映射口径,有效避免了外部输入反转、边界相等或非法值等异常情况导致的颜色映射失真。
Smart Images

Figure CN122473328B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of browser-based 3D visualization and computer graphics technology, and in particular relates to an address cavity range normalization shading method and system based on WebGPU. Background Technology
[0002] In the field of engineering visualization, the operational status display of cavities such as underground salt caverns, well shafts, and chemical storage tanks requires mapping multi-physical field data such as pressure, temperature, and concentration into intuitive color distributions to assist engineers in parameter adjustment and decision-making. WebGPU, as a next-generation browser-side GPU interface, provides a crucial technological foundation for high-performance browser-side 3D visualization due to its stronger parallel computing capabilities and more efficient rendering pipeline control, and has broad application prospects in scenarios such as industrial simulation and underground space visualization.
[0003] In existing technologies, field data shading for cavity-type 3D models on the browser side typically relies on the CPU to calculate color parameters layer by layer and render each layer of geometry separately through multiple draw calls. Some solutions use WebGL combined with Three.js to implement clipping plane layering, or use texture lookup tables to map values to colors. However, the normalization intervals in these solutions are usually directly passed in by the caller without verification and used for calculation. Furthermore, color parameter generation and geometry rendering are both completed serially in the main thread or in a single GPU submission.
[0004] However, when faced with high-frequency external data updates, the aforementioned existing technical solutions are limited by the inherent overhead of serial computation and multiple drawing calls, making it difficult to guarantee the real-time performance and smoothness of shading parameter generation and rendering output. Furthermore, when external input numerical range parameters exhibit anomalies such as inversion, boundary equality, or illegal values, existing solutions lack effective fault tolerance and protection mechanisms, easily leading to color mapping distortion or even rendering results that are unusable, affecting the reliability and interpretability of the displayed results. Therefore, existing technologies suffer from insufficient performance of address cavity field data shading in high-frequency update scenarios and unstable rendering results under abnormal input, resulting in inadequate cavity range normalization shading. Summary of the Invention
[0005] The purpose of this application is to provide a WebGPU-based address cavity range normalization coloring method and system to solve the problem of insufficient cavity range normalization coloring in the prior art.
[0006] To address the aforementioned technical problems, in a first aspect, this application provides a WebGPU-based address cavity range normalization coloring method, comprising: Obtain the data package including model identifier, field type sequence, numerical range parameters, and rendering region parameters; After overwriting and merging the local cache configuration with the data packet, a set of state parameters including the target model identifier, target field type sequence, target numerical range parameters, and target rendering area parameters is extracted. The cavity model object is determined by matching the target model identifier with the current scene model identifier. By exchanging and limiting the extreme values of the target numerical range parameters, the target field type sequence is mapped and truncated to obtain a normalized coefficient sequence. By calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping, a gradient coefficient sequence with the same length as the target field type sequence is obtained. After writing the target field type sequence, normalization coefficient sequence, gradient coefficient sequence and target rendering region parameters into the first buffer of WebGPU, the computation shader calculates the color parameters, shading enhancement parameters and clipping parameters corresponding to each level based on the data in the first buffer and writes them into the second buffer. The WebGPU rendering pipeline is used to perform instantiated rendering in a single draw call to generate multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer according to the instance index to perform layered shading and range limitation on each geometric instance, and outputs a normalized rendering frame.
[0007] Optionally, after overwriting and merging the local cache configuration with the data packet, a set of state parameters including the target model identifier, target field type sequence, target numerical range parameters, and target rendering region parameters is extracted. The cavity model object is determined by matching the target model identifier with the current scene model identifier, including: The model identifier, field type sequence, numerical range parameter, and rendering region parameter in the local cache configuration are selected from the model identifier, field type sequence, numerical range parameter, and rendering region parameter in the data packet according to a preset priority rule, resulting in a set of state parameters including the target model identifier, target field type sequence, target numerical range parameter, and target rendering region parameter. Perform text consistency verification between the target model identifier and the scene model identifier being displayed; If the consistency check fails, execute the resource release command and retrieve the original three-dimensional geometry data according to the target model identifier, and determine the retrieved original three-dimensional geometry data as the cavity model object; If the consistency check passes, the current video memory usage remains unchanged, and the geometry being displayed is identified as the cavity model object.
[0008] Optionally, by numerically exchanging and limiting the range of the extreme values of the target numerical range parameter, a normalized coefficient sequence is obtained by mapping and truncating the target field type sequence, including: After resolving the first and second extreme values in the target numerical range parameter into floating-point numbers, the largest value among the first and second extreme values is determined as the maximum mapping boundary, and the smallest value is determined as the minimum mapping boundary. When the difference between the maximum mapping boundary and the minimum mapping boundary is greater than or equal to the preset difference threshold, the difference between the maximum mapping boundary and the minimum mapping boundary is determined as the target range range; otherwise, the preset difference threshold is determined as the target range range. Calculate the deviation difference between the numerical value of each field type in the target field type sequence and the minimum mapping boundary, and calculate the ratio of the deviation difference to the target range range to obtain the initial coefficient sequence; When the coefficient value in the initial coefficient sequence is greater than 1, it is corrected to 1; when the coefficient value in the initial coefficient sequence is less than 0, it is corrected to 0, thus obtaining the normalized coefficient sequence.
[0009] Optionally, by calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping, a gradient coefficient sequence with the same length as the target field type sequence is obtained, including: Calculate the absolute value of the difference between each pair of adjacent field type values in the target field type sequence to obtain the absolute difference sequence; Extract the maximum and minimum values from the absolute difference sequence, and determine them as the upper and lower bounds of the gradient, respectively. When the difference between the upper bound and the lower bound of the gradient is greater than or equal to a preset minimum threshold, the difference between the upper bound and the lower bound of the gradient is determined as the gradient mapping range; otherwise, the preset minimum threshold is determined as the gradient mapping range. Calculate the boundary difference between each absolute difference in the absolute difference sequence and the lower bound of the gradient, and calculate the ratio of the boundary difference to the gradient mapping range to obtain the initial gradient sequence; The values at the end of the initial gradient sequence are inserted after the end position to obtain a gradient coefficient sequence with the same length as the target field type sequence.
[0010] Optionally, after writing the target field type sequence, normalized coefficient sequence, gradient coefficient sequence, and target rendering region parameters into the first buffer of the WebGPU, the computation shader calculates the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level based on the data in the first buffer and writes them into the second buffer, including: The target field type sequence, normalized coefficient sequence, and gradient coefficient sequence are byte-aligned and then placed into the first buffer of WebGPU; The target field type sequence, normalized coefficient sequence, and gradient coefficient sequence are retrieved from the first buffer using a computational shader based on a parallel index. Color parameters are obtained by numerical interpolation of the preset primary colors according to the normalized coefficient sequence, and the luminance components of the color parameters are weighted according to the gradient coefficient sequence to obtain the shading enhancement parameters. The display scale value in the target rendering region parameter is mapped to the height extreme value of the cavity model object in the vertical direction to obtain the vertical height threshold used for planar clipping as the clipping parameter. The color parameter, shading enhancement parameter and clipping parameter are written into the second buffer of WebGPU in the order of their corresponding hierarchical indexes.
[0011] Optionally, color parameters are obtained by numerical interpolation of a preset primary color based on a normalized coefficient sequence, and the luminance components of the color parameters are weighted and calculated based on a gradient coefficient sequence to obtain shading enhancement parameters, including: Extract multiple first color components from the preset base color and multiple second color components from the preset target color. Use each normalized value in the normalized coefficient sequence as the numerical mixing ratio to perform linear interpolation mixing calculation on the second color components and the first color components to obtain the color parameters corresponding to each level. The base brightness values are extracted from the color parameters. The corresponding gradient coefficients in the gradient coefficient sequence are used as weighting coefficients to calculate the weighted product of the base brightness values, thus obtaining the shading enhancement parameters corresponding to each level.
[0012] Optionally, the WebGPU rendering pipeline is used to perform instantiated rendering in a single draw call to generate multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer based on the instance index to perform layered shading and range limitation on each geometric instance, outputting a normalized rendering frame, including: Associate and map the vertex attribute data of the cavity model object with the storage address of the second buffer, and configure the drawing instance cardinality of the rendering pipeline according to the total number of field type sampling points of the target field type sequence. Initiate a single draw call instruction to generate multiple geometry instances in parallel in the scene, and use the unique count value assigned to each geometry instance by the rendering pipeline to determine the instance index; The fragment shader retrieves the corresponding level's color parameters, shading enhancement parameters, and clipping parameters from the second buffer based on the instance index. The fragment shader assigns pixel values to the corresponding geometric instances based on color parameters and shading enhancement parameters, and compares the spatial coordinate values of the geometric instances with the clipping parameters. Only fragments whose spatial coordinate values are within the visible range defined by the clipping parameters are retained to generate a normalized rendering frame.
[0013] Secondly, this application provides an address cavity range normalization shader system based on WebGPU, comprising: The acquisition module is used to acquire data packets including model identifier, field type sequence, numerical range parameters, and rendering region parameters; The determination module is used to extract a set of state parameters, including the target model identifier, target field type sequence, target numerical range parameters, and target rendering area parameters, after overwriting and merging the local cache configuration and data packets. The cavity model object is determined by matching the target model identifier with the current scene model identifier. The calculation module is used to map and truncate the target field type sequence to obtain a normalized coefficient sequence by exchanging and limiting the extreme values of the target numerical range parameter. It also calculates the absolute difference between adjacent sampling points in the target field type sequence and performs interval mapping to obtain a gradient coefficient sequence with the same length as the target field type sequence. The calculation module is also used to write the target field type sequence, normalization coefficient sequence, gradient coefficient sequence and target rendering region parameters into the first buffer of WebGPU, and then use the calculation shader to calculate the color parameters, shading enhancement parameters and clipping parameters corresponding to each level based on the data in the first buffer and write them into the second buffer. The rendering module utilizes the WebGPU rendering pipeline to perform instantiated rendering through a single draw call, generating multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer based on the instance index to perform layered shading and range limitation on each geometric instance, and outputs a normalized rendering frame.
[0014] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor, configured to implement the steps of the WebGPU-based address cavity range normalization coloring method as described in the first aspect above, when executing the computer program.
[0015] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps of the WebGPU-based address cavity range normalization coloring method described in the first aspect above.
[0016] The WebGPU-based address cavity range normalization coloring method provided in this application first establishes a stable normalization mapping caliber by exchanging and limiting the extreme values of the target numerical range parameter, effectively avoiding color mapping distortion caused by abnormal situations such as external input reversal, boundary equality, or illegal values.
[0017] Subsequently, the WebGPU compute shader is used to compute the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level in parallel based on the normalized coefficient sequence, gradient coefficient sequence, and other data in the first buffer. This transforms the serial parameter generation process into parallel execution by the GPU, significantly reducing the computational load on the main thread.
[0018] Finally, instantiation rendering is performed through a single draw call of the WebGPU rendering pipeline, merging multiple layered draws into a single GPU submission, significantly reducing rendering overhead. Therefore, this application achieves a high-performance closed loop for shading parameter generation and rendering output in high-frequency update scenarios while ensuring fault tolerance for abnormal inputs. It solves the technical problems in the prior art where address cavity field data shading has insufficient performance in high-frequency update scenarios and unstable rendering results under abnormal inputs, leading to insufficient cavity range normalization shading.
[0019] Furthermore, this application first selects and merges the local cache configuration and parameters in the data packet according to a preset priority rule, avoiding inconsistencies caused by multi-source parameter chaos. Then, by performing text consistency verification between the target model identifier and the current scene model identifier, the current video memory usage remains unchanged and the currently displayed geometry is directly reused when the verification passes, avoiding unnecessary resource release and reconstruction operations, and significantly reducing GPU resource management overhead caused by model reloading.
[0020] Resource release and re-retrieval of original 3D geometric data are only performed when verification fails, ensuring the accurate correspondence between model objects and target identifiers. Therefore, this application improves overall rendering performance in high-frequency external data update scenarios by reducing redundant model reloading and memory operations, providing effective support for solving the technical problem of insufficient performance of address cavity field data shading in high-frequency update scenarios. Attached Figure Description
[0021] To more clearly illustrate the technical solutions of the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 A flowchart illustrating an address cavity range normalization coloring method based on WebGPU provided in this application embodiment; Figure 2 A flowchart illustrating a method for determining a cavity model object provided in an embodiment of this application; Figure 3 A flowchart illustrating a method for outputting normalized rendering frames, provided in an embodiment of this application; Figure 4 A schematic diagram of a WebGPU-based double-buffered parallel shading and instantiated layered rendering data stream provided for an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a WebGPU-based address cavity range normalization coloring system provided in an embodiment of this application. Detailed Implementation
[0023] In browser-based visualization of address cavity field data coloring, existing solutions rely on the traditional mode of CPU-side serial traversal and multiple GPU drawing calls, which leads to key defects in high-frequency data update scenarios: on the one hand, the serial calculation of color parameters layer by layer consumes main thread resources, and multiple drawing calls exacerbate GPU submission overhead, resulting in a decrease in rendering frame rate and stuttering.
[0024] On the other hand, the numerical range parameters of external inputs are used directly for normalization calculations without verification. When extreme value reversals, boundary overlaps, or illegal values occur, the mapping results are distorted or even trigger rendering anomalies. This contradiction stems from the inefficient use of parallel computing capabilities by traditional CPU serial architectures and the lack of fault-tolerant protection mechanisms for abnormal inputs, necessitating a high-performance GPU parallel shading method.
[0025] To address the aforementioned issues, this application proposes a WebGPU-based address cavity range normalization shading method. Its core lies in the deep integration of intelligent error correction of numerical range parameters with the GPU's parallel computing pipeline, achieving end-to-end optimization from data fault tolerance to rendering output. Specifically, after receiving external data packets, the extreme values of the target numerical range parameters are first swapped and range-limited to establish a stable normalization mapping and generate a normalization coefficient sequence and a gradient coefficient sequence.
[0026] The sequence is then written to the first buffer of the WebGPU, and the color parameters, shading enhancement parameters, and clipping parameters for each level are calculated in parallel using the computation shader and written to the second buffer. Finally, instantiation rendering is performed through a single draw call of the rendering pipeline, and the fragment shader extracts parameters based on the instance index to complete the layered shading and range limitation. This method abandons the traditional CPU serial computation and multiple draw mode, and through the coordinated cooperation of parameter error correction mechanism and GPU parallel pipeline, ensures that stable and reliable normalized mapping results can be obtained under different abnormal input scenarios.
[0027] This method eliminates the distortion risk caused by extreme value anomalies and transfers the computational load of shading parameter generation and multi-layer rendering to the GPU for parallel execution. It solves the problems of insufficient high-frequency update performance and unstable rendering due to abnormal input caused by serial calculation and lack of fault tolerance in the existing technology, and significantly improves the real-time performance and engineering reliability of address cavity field data shading.
[0028] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] To address the problems of existing technologies, embodiments of this application provide a WebGPU-based address cavity range normalization coloring method, apparatus, device, computer storage medium, and computer program product. The WebGPU-based address cavity range normalization coloring method provided in this application embodiment will be described first below.
[0030] Figure 1 A flowchart illustrating an embodiment of the WebGPU-based address cavity range normalization coloring method provided in this application is shown. Figure 1 As shown, the method includes: S101. Obtain a data packet including model identifier, field type sequence, numerical range parameters, and rendering region parameters.
[0031] In the application scenario of address cavity visualization, a data packet refers to a structured data object that includes business information and rendering control parameters, and is received from an external business terminal via WebSocket, HTTP interface, or message bus. A model identifier is a string identifier used to uniquely locate the target address cavity model, and can be a business semantic identifier such as a salt cavern number, wellbore number, or storage tank equipment number.
[0032] A field type sequence refers to a set of physical quantity values obtained by sampling sequentially from bottom to top or top to bottom along the vertical direction of the cavity, and may include discrete sampled values of multiple physical fields such as pressure, temperature, concentration, and salinity. The numerical range parameter refers to the upper and lower boundary values used to establish the normalization mapping aperture, and may include a minimum boundary value (minValue) and a maximum boundary value (maxValue), used to map the original values in the field type sequence to a unified range.
[0033] Rendering area parameters refer to a set of parameters used to control the visible range and display ratio of the cavity model. These parameters can include numerical parameters such as the liquid level display ratio fillPercent and the bottom surface display ratio bottomPercent, and their values are usually floating-point numbers between 0 and 1.
[0034] In the specific implementation process, the browser first establishes a communication connection with the external business end, such as listening for real-time data pushes via a WebSocket long connection or periodically pulling updated data via an HTTP polling interface. When the external business end triggers a cavity status update, it sends a JSON formatted data packet to the browser end. This data packet includes fields such as instruction type (type), effect type (effectType), model identifier (fbxBaseName), field type sequence (value), numerical range parameters (minValue and maxValue), and rendering area parameters (fillPercent and bottomPercent).
[0035] For example, to display the temperature field of a cavity in an underground salt cavern, the data packet sent by the external service terminal can be as follows: type="setState", effectType="field type", fbxBaseName="JK3-4" (identifying wells 3-4 of the salt cavern), value=[285.5, 288.2, 290.1, 291.8, 293.5] (representing the temperature values of the five sampling layers from bottom to top), minValue="280.0" and maxValue="300.0" (indicating a temperature range of 280 to 300), fillPercent=0.75 (indicating the liquid level is displayed up to 75% height), and bottomPercent=0.2 (indicating the bottom surface is displayed starting from 20% height). After receiving the data packet, the browser parses the JSON text and extracts the values of each field, temporarily storing them in memory variables.
[0036] S102. After overwriting and merging the local cache configuration and data packet, extract the set of state parameters including the target model identifier, target field type sequence, target numerical range parameter and target rendering area parameter. Then, determine the cavity model object by matching the target model identifier with the current scene model identifier.
[0037] Overwrite merging prioritizes the parameters in the data packet to update the corresponding parameters in the local cache configuration, and uses the corresponding parameters in the local cache configuration when the corresponding parameters in the data packet are missing.
[0038] Optionally, step S102, after overwriting and merging the local cache configuration with the data packet, extracts a set of state parameters including the target model identifier, target field type sequence, target numerical range parameters, and target rendering region parameters. The process of determining the cavity model object by matching the target model identifier with the current scene model identifier can specifically include: Figure 2 A flowchart illustrating a method for determining a cavity model object according to an embodiment of this application is shown. Figure 2As shown, when processing multi-source configuration information, a preset priority rule is first introduced to cover and selectively extract the model identifier, field type sequence, numerical range parameters and rendering area parameters covered in the local cache configuration and the received data packet, thereby recombining a set of state parameters including the target model identifier and other target dimensions.
[0039] To avoid redundant rendering and optimize underlying scheduling, a text-level consistency check needs to be performed between the extracted target model identifier and the currently displayed scene model identifier. If the check result shows that the two are inconsistent, it means that the currently rendered scene can no longer match the presentation requirements of the latest data package. At this time, a resource release command will be triggered to clear the old occupied space, and new 3D geometric raw data will be retrieved directly based on the target model identifier, and it will be established as the cavity model object to be processed.
[0040] Conversely, if the verification passes successfully, it indicates that the current scene model perfectly matches the latest requirements. In this case, the existing memory usage is maintained without modification, and the currently displayed geometry is reused as the required cavity model object. This conditional branching architecture effectively balances the accuracy of model updates with the computational overhead of graphics rendering. This method includes: S1021. Select the model identifier, field type sequence, numerical range parameter and rendering region parameter in the local cache configuration and the model identifier, field type sequence, numerical range parameter and rendering region parameter in the data packet according to the preset priority rules to obtain a set of state parameters including target model identifier, target field type sequence, target numerical range parameter and target rendering region parameter.
[0041] Local cache configuration It refers to a snapshot of the last rendering state saved in the browser's local persistent storage. It can be a JSON format configuration object written through localStorage and includes fields such as the model identifier, field type sequence, numerical range parameters, and rendering region parameters used in the last rendering. It provides the ability to restore historical parameters when the browser is refreshed or reloaded.
[0042] State parameter set This refers to configuring local caching. The final parameter set obtained by merging the currently received data packets according to a preset priority rule, and including the target model identifier. Target field type sequence Minimum boundary value of the target Target maximum boundary value Target liquid level display ratio Scale with the bottom of the target .
[0043] The preset priority rule refers to the overriding strategy followed when selecting between the local cache configuration and the field with the same name in the data packet. Its core idea is to use the corresponding parameter in the data packet as the priority to overwrite and update the corresponding parameter in the local cache configuration, and to use the corresponding parameter in the local cache configuration when the corresponding parameter in the data packet is missing. The preset priority rules are shown in Table 1 below: Table 1: Preset Priority Rules Comparison Table
[0044] As shown in Table 1, the preset priority rule performs overwrite selection field by field according to parameter category: for fields that exist in the data packet and are not empty, the values in the data packet are directly written into the status parameter set. For fields missing in the data packet, configure the local cache. The corresponding field value is read as a supplement to ensure... It remains fully effective in any update scenario.
[0045] In the specific implementation process, the local cache configuration object is first read from the browser's localStorage. The stored field values are extracted and used as basic parameters for later use. Then, according to the preset priority rules in Table 1, the parameters in the local cache configuration are compared with the parameters in the data packet. The corresponding parameters in the data packet are selected with higher priority. If the corresponding parameters in the data packet are missing, the corresponding parameters in the local cache configuration are used.
[0046] Specifically, for the fbxBaseName field, if the field exists in the data packet and is not empty, then it will be treated as... Otherwise from Read this field as For the value field, the target field type sequence is obtained using the same rules. For the minValue and maxValue fields, we obtain respectively and For the fillPercent and bottomPercent fields, we get... and Finally, all the above fields are integrated into a set of state parameters. .
[0047] S1022. Perform text consistency verification between the target model identifier and the scene model identifier being displayed.
[0048] Current scene model identifier This refers to the string identifier corresponding to the cavity model that has been loaded and is being rendered in the current 3D scene, and is related to the target model identifier. They have the same field format and all originate from the fbxBaseName field in the data packet. Text consistency verification refers to... and The process of performing a complete string match comparison is used to determine whether the target cavity model of the current request is consistent with the model already loaded in the scene.
[0049] In the specific implementation process, the current scene model identifier is first read from the memory state variables. Next, Target model identifier in and Perform a character-by-character comparison: if the two are completely identical, the verification passes and the process proceeds to S1024; if there is any difference in any character, the verification fails and the process proceeds to S1023.
[0050] S1023. If the consistency check fails, execute the resource release command and retrieve the original three-dimensional geometric data according to the target model identifier, and determine the retrieved original three-dimensional geometric data as the cavity model object.
[0051] Resource release commands refer to the proactive release operations performed on the GPU memory and related rendering resources already occupied in the current scene when switching models. They can include the destruction and memory reclamation of loaded geometry buffers, material objects and texture resources, and are used to avoid memory leaks and long-term instability caused by model switching.
[0052] 3D geometric raw data refers to the geometric structure data, such as vertex coordinates, normal vectors, and facet indices, included in the cavity 3D model file retrieved from the resource server or local resource library based on the target model identifier. This raw geometric description can be in formats such as FBX, GLTF, or OBJ. A cavity model object refers to the cavity geometry structure in the 3D scene that can be directly accessed by the rendering pipeline after the 3D geometric raw data has been loaded and the GPU buffer has been initialized. This object includes vertex attribute data and the corresponding GPU buffer binding relationships.
[0053] In the specific implementation process, the resource release command is executed first. The corresponding geometry buffers, material objects, and texture resources are destroyed one by one by calling the destruction interface to release the GPU memory they occupy, and the memory in the system is then cleared. Updated to .
[0054] Next according to The system sends a request to the resource server or retrieves the corresponding 3D geometric raw data file from the local resource library. After parsing the file, it extracts geometric attribute data such as vertex coordinate sequence, normal vector sequence, and face index sequence, uploads it to the GPU buffer to complete scene initialization, and records it as the current cavity model object in the scene state variable.
[0055] S1024. If the consistency check passes, keep the current video memory usage unchanged and determine the displayed geometry as the cavity model object.
[0056] The memory occupancy status refers to the allocated state of the geometry buffer, material objects, and texture resources corresponding to the current cavity model in the GPU memory. Keeping the memory occupancy status unchanged means skipping the resource release and reloading process to directly reuse the geometry data already in the memory, thereby significantly reducing the GPU resource management overhead per frame in high-frequency data update scenarios.
[0057] The geometry being displayed refers to the cavity model geometry data that has been loaded and is ready for rendering in the current 3D scene. It has the same data structure as the cavity model object obtained through the reload process in S1023, and both include vertex attribute data and the corresponding GPU buffer binding relationship.
[0058] In the specific implementation process, the first step is to determine whether the text consistency check in S1022 has passed, that is... and Completely consistent, confirming that the target cavity model and the currently loaded model in the scene are the same object. Then, skipping the resource release and geometry reloading processes, directly read the current cavity model object reference from the scene state variables, maintaining its GPU buffer binding relationship. Finally, the geometry being displayed is identified as the cavity model object.
[0059] This embodiment ensures the integrity and consistency of the state parameter set under any update scenario, which not only effectively reduces the GPU resource management overhead in high-frequency update scenarios, but also improves rendering response efficiency and avoids the risk of memory leaks.
[0060] S103. By exchanging and limiting the extreme values of the target numerical range parameter, the target field type sequence is mapped and truncated to obtain a normalized coefficient sequence. By calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping, a gradient coefficient sequence with the same length as the target field type sequence is obtained.
[0061] Optionally, step S103, which involves numerically exchanging and limiting the range of extreme values of the target numerical range parameter to map and truncate the target field type sequence to obtain a normalized coefficient sequence, may specifically include: S1031. After resolving the first and second extreme values in the target numerical range parameter into floating-point numbers, the value with the largest value among the first and second extreme values is determined as the maximum mapping boundary, and the value with the smallest value is determined as the minimum mapping boundary.
[0062] The first and second extreme values refer to the set of state parameters. Minimum boundary value of the target Maximum boundary value of the target The corresponding original input value. Maximum mapping boundary. The minimum mapping boundary refers to the larger of the analytical results of the first and second extreme values. It refers to the smaller value.
[0063] In the specific implementation process, the first step is to set the state parameters. Minimum boundary value of the target Maximum boundary value of the target Each variable is converted to a floating-point number using a floating-point parsing method; if parsing fails, a default value is used instead. Then, the two values are compared, and the larger one is determined as the maximum mapping boundary. The smaller one is determined as the minimum mapping boundary. ,Right now , .
[0064] S1032. When the difference between the maximum mapping boundary and the minimum mapping boundary is greater than or equal to the preset difference threshold, the difference between the maximum mapping boundary and the minimum mapping boundary is determined as the target range range; otherwise, the preset difference threshold is determined as the target range range.
[0065] Target range extremely poor This refers to the denominator value used for subsequent normalization mapping, determined by the maximum mapping boundary. With minimum mapping boundary The difference is determined after being limited to a range and is used to map the original values in the field type sequence to a unified interval.
[0066] Preset difference threshold This refers to the lower limit threshold where the range of the protected target is not lower than a certain minimum positive number. The preset difference threshold is determined by taking the upper confidence limit of the measurement error after statistical analysis of the inherent error distribution of sensor measurement equipment for similar physical quantity fields in history. The preset difference thresholds are shown in Table 2 below: Table 2: Preset Difference Threshold Comparison Table
[0067] As shown in Table 2, the preset difference threshold is... Reference values are provided based on different physical quantity field types, and can be adjusted according to business accuracy requirements during actual deployment. Its core function is to... and When the difference is too small or even equal, This serves as a fallback for the target range range, preventing division by zero or numerical overflow during subsequent normalization calculations.
[0068] In the specific implementation process, the first step is to calculate... and The difference Next, the target range range is determined according to the following rules: ,in The preset difference threshold is selected from Table 2 based on the current physical field type.
[0069] S1033. Calculate the deviation difference between the numerical value of each field type in the target field type sequence and the minimum mapping boundary, and calculate the ratio of the deviation difference to the target range range to obtain the initial coefficient sequence.
[0070] Deviation difference refers to the target field type sequence Values for each field type With minimum mapping boundary The difference between them reflects the degree of deviation of the sampled layer value from the normalization lower bound. Initial coefficient sequence This refers to the sequence obtained by calculating the ratio of the deviation difference to the target range range for each element in the target field type sequence, which can be denoted as: And the values of each element may exceed Interval.
[0071] In the specific implementation process, the target field type sequence is first traversed. The numerical values for each field type in the data Calculate its boundary with the minimum mapping. Deviation difference Then divide the deviation by the target range. , obtained the initial coefficients in Finally, All After performing the above calculations on each element sequentially, the resulting sequence of initial coefficients is obtained. .
[0072] S1034. When the coefficient value in the initial coefficient sequence is greater than 1, it is corrected to 1; when the coefficient value in the initial coefficient sequence is less than 0, it is corrected to 0, thus obtaining the normalized coefficient sequence.
[0073] Normalized coefficient sequence This refers to the initial coefficient sequence The final sequence obtained by performing interval truncation operation on each element in the sequence can be denoted as: And each of its elements The truncation operation ensures that when the field type value exceeds the mapping boundary defined by the numerical range parameter, the normalization result is clamped within the legal range to avoid abnormal saturation or negative value distortion in subsequent color mapping.
[0074] In the specific implementation process, the initial coefficient sequence is first traversed. Each element in Perform the following truncation rule on it: If Then it is corrected to ,like Then it is corrected to Otherwise, keep the original value unchanged. Next, all the truncated parts... The elements are integrated into a normalized coefficient sequence. .
[0075] This embodiment effectively addresses the abnormal situation of extreme value reversal in external data packets, not only eliminating the risk of division by zero when extreme values are equal, but also ensuring the numerical stability of normalization calculations and avoiding color mapping distortion.
[0076] Optionally, step S103, which involves calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping to obtain a gradient coefficient sequence with the same length as the target field type sequence, may specifically include: S1035. Calculate the absolute value of the difference between each pair of adjacent field type values in the target field type sequence to obtain the absolute difference sequence.
[0077] Absolute difference sequence This refers to the target field type sequence The sequence obtained by taking the absolute value of the difference between each pair of adjacent sampled points can be denoted as: And the first of them element Indicates the first Layer and First The magnitude of numerical variation between layers. Because the target field type sequence has [a certain number of layers]. There are sampling points and adjacent value pairs have . Group, therefore, absolute difference sequence The length is .
[0078] In the specific implementation process, the target field type sequence is first traversed. From the middle One to the first For each element, for each pair of adjacent values Calculate the absolute value of the difference Then all of them The absolute differences are integrated into an absolute difference sequence. .
[0079] S1036. Extract the maximum and minimum values from the absolute difference sequence and determine them as the upper and lower bounds of the gradient, respectively.
[0080] Gradient upper bound Refers to the absolute difference sequence The maximum value of all elements in the set, and the lower bound of the gradient. Refers to the absolute difference sequence The minimum value of all elements in the sequence. In practice, this involves traversing the absolute difference sequence. Extract the maximum and minimum values, and obtain them respectively. and .
[0081] S1037. When the difference between the upper boundary of the gradient and the lower boundary of the gradient is greater than or equal to the preset minimum threshold, the difference between the upper boundary of the gradient and the lower boundary of the gradient is determined as the gradient mapping range; otherwise, the preset minimum threshold is determined as the gradient mapping range.
[0082] gradient mapping range This refers to the denominator value used to perform interval normalization on the absolute difference sequence, and is bounded by the upper bound of the gradient. With gradient lower bound boundary The difference is determined after being limited to a range. A preset minimum threshold is used. This refers to the lower limit threshold that protects the gradient mapping range from being lower than a certain minimum positive number.
[0083] The preset minimum threshold is determined based on the minimum effective physical gradient difference calculated from the analog-to-digital conversion resolution and spatial sampling interval of the data acquisition device. The preset minimum thresholds are shown in Table 3 below: Table 3: Preset Minimum Threshold Comparison Table
[0084] As shown in Table 3, the preset minimum threshold is... Reference values are given according to different physical quantity field types. Its core function is to provide reference values when all elements in the absolute difference sequence are completely equal. At that time, with This serves as a fallback for the gradient mapping range, preventing division by zero anomalies.
[0085] In the specific implementation process, the first step is to calculate... and The difference Next, the gradient mapping range is determined according to the following rules: ,in To preset the minimum threshold, select it from Table 3 according to the current physical field type.
[0086] S1038. Calculate the boundary difference between each absolute difference in the absolute difference sequence and the lower bound of the gradient, and calculate the ratio of the boundary difference to the gradient mapping range to obtain the initial gradient sequence.
[0087] Boundary difference refers to the sequence of absolute differences. Each element With gradient lower bound boundary The difference between them reflects the first The layer is the local change offset of the starting layer in the adjacent sampling point pair relative to the lower bound of the gradient, and is assigned to the th layer. A layer is a single-layer property representing the degree of drastic change in the local field value within that layer. Initial gradient sequence. This refers to the sequence obtained by calculating the ratio of the boundary difference to the gradient mapping range for each element in the absolute difference sequence, which can be denoted as... And the values of each element are in Within the range.
[0088] In the specific implementation process, the absolute difference sequence is first traversed. Each element in Calculate its boundary with the lower bound of the gradient. boundary difference Next, divide the boundary difference by the gradient mapping range. , obtained the Initial gradient coefficients in Finally, for All After performing the above calculations on each element sequentially, the resulting sequence is integrated to obtain the initial gradient sequence. .
[0089] S1039. Insert the values at the end of the initial gradient sequence into the end position to obtain a gradient coefficient sequence with the same length as the target field type sequence.
[0090] Gradient coefficient sequence This refers to the initial gradient sequence The final gradient coefficient sequence obtained by appending a value identical to the last element to the end can be denoted as: And its length is related to the target field type sequence. The lengths are the same. .
[0091] Among them, the first Gradient coefficients To belong to the The local variation characteristics of a single layer are based on the first layer. The layer and its adjacent layer The normalized variation magnitude between layers is used to represent the first layer. The single-layer attribute value representing the degree of abrupt change in field values in the region where the layer is located, for the last layer that has no successor adjacent layers. The layer then follows the first one. The local variation characteristics of the layer are used as its gradient coefficients.
[0092] In the specific implementation process, the initial gradient sequence is read first. The last element Next, Add to After the end position, the length is obtained as gradient coefficient sequence .
[0093] This embodiment extracts the spatial variation amplitude information of the physical quantity field between each layer in the vertical direction of the cavity. This not only eliminates the risk of division by zero when the variation amplitudes between each layer are exactly the same, but also ensures that each sampling layer corresponds to a complete gradient coefficient.
[0094] S104. After writing the target field type sequence, normalization coefficient sequence, gradient coefficient sequence and target rendering region parameters into the first buffer of WebGPU, the computation shader calculates the color parameters, shading enhancement parameters and clipping parameters corresponding to each level based on the data in the first buffer and writes them into the second buffer.
[0095] Optionally, after writing the target field type sequence, normalization coefficient sequence, gradient coefficient sequence, and target rendering region parameters into the first buffer of the WebGPU in step S104, the process of using the computation shader to calculate the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level based on the data in the first buffer and writing them into the second buffer can specifically include: S1041. After byte-aligning the target field type sequence, normalized coefficient sequence, and gradient coefficient sequence, put them into the first buffer of WebGPU.
[0096] First buffer This refers to a GPU buffer object allocated in WebGPU memory for storing computation shader input data, including a sequence of target field types. Normalized coefficient sequence and gradient coefficient sequence An independent buffer segment.
[0097] Byte alignment refers to the process of standardizing the byte layout of the sequence in the GPU buffer according to the byte alignment rules of WebGPU memory before writing the sequence data. Specifically, it involves packing every four adjacent 32-bit floating-point numbers in the same sequence into a 16-byte data unit. When the value is not a multiple of 4, the missing positions in the last data unit that are less than 4 floating-point numbers are filled with numerical values. Padding is performed to ensure that each sequence is stored contiguously with an alignment granularity of 16 bytes. Based on the above packing method, the first... The floating-point element corresponding to the layer is located at the th position in the sequence. The first 16-byte data unit On each component.
[0098] In the specific implementation process, the first step is to determine the target field type sequence. Normalized coefficient sequence With gradient coefficient sequence length Following the alignment rule of packing every 4 floating-point numbers into a 16-byte data unit, the number of data units required for each sequence is determined as follows: The required number of bytes is determined as follows: The number of bytes is calculated, and the total number of bytes required for the three sets of sequences is calculated accordingly. At the same time, the floating-point elements of each sequence are arranged into data units that meet the alignment requirements according to the above packing method.
[0099] Next, the total number of bytes calculated is compared. With the current first buffer in GPU memory Allocated capacity: If the required number of bytes does not exceed the current capacity, it is reused directly; if it exceeds the current capacity, the current first buffer is destroyed. Then, according to the round-up memory page policy, a GPU buffer with sufficient capacity is reallocated.
[0100] Specifically, using 256 bytes as the memory page granularity to meet the constraint that the starting offset of the storage buffer binding in WebGPU must be aligned to 256 bytes, the required total number of bytes is... The new buffer capacity is allocated after rounding up to the nearest memory page. ,Right now bytes, and accordingly request a capacity of [number] bytes from WebGPU. The new GPU buffer of bytes serves as the first buffer after expansion. Finally, align the following... , and Write to the first buffer after verifying the capacity is valid. The corresponding buffer segment completes the secure transfer of data from CPU memory to GPU memory.
[0101] S1042. Use the computation shader to retrieve the target field type sequence, normalized coefficient sequence, and gradient coefficient sequence from the first buffer according to the parallel index.
[0102] Parallel Index This refers to the global call index assigned to each computation unit by the WebGPU computation shader during parallel execution, which is determined jointly by the workgroup index of the workgroup to which the computation unit belongs and the local call index within the workgroup. ,in For the pre-declared workgroup size, For workgroup indexing, This is an index for local calls within a workgroup.
[0103] The value within the legal range is to Furthermore, it corresponds one-to-one with the hierarchical position in the target field type sequence, enabling each computational unit to... Value read independently Data at corresponding levels in the middle to achieve full coverage Parallel computation of each level of coloring parameters.
[0104] In the specific implementation process, the first buffer is first... Associate with the binding group of the compute shader, and declare middle , and Read permissions for the three buffers are specified. Next, a fixed workgroup size is declared in the compute shader entry function. As in this embodiment, take The total number of workgroups, i.e., the number of workgroups to be scheduled, is configured using a rounding-up method. This increases the total number of scheduled global call units. Not less than the total number of levels .
[0105] Then based on the total number of working groups The computation shaders are then started to execute in parallel. Within each parallel computation unit, the computation shaders first execute... Calculate its global call index and in Return directly to discard any out-of-bounds call units resulting from rounding up; At that time, the compute shader uses this global call index. From respectively Read the first The field type value corresponding to the layer Normalization coefficient With gradient coefficients .
[0106] S1043. Perform numerical interpolation on the preset primary color according to the normalized coefficient sequence to obtain color parameters, and perform weighted calculation on the luminance component of the color parameters according to the gradient coefficient sequence to obtain shading enhancement parameters.
[0107] Color parameters This refers to the computation shader for each level. The generated RGB color values are used to drive the pixel assignment of the geometric instance of this layer and are calculated by interpolation and mixing of preset primary colors through normalization coefficients.
[0108] Shading enhancement parameters It refers to the enhanced brightness value obtained by multiplying the brightness component of the color parameter with the gradient coefficient as the weighting coefficient, and is used to achieve a visual highlighting effect in the hierarchical area where the physical quantity field value changes drastically, so as to help engineers identify the abrupt change area of field distribution.
[0109] Preset base color This refers to the base color parameter that serves as the starting point for color interpolation, and is either passed in from the `color` field in the data packet or used as the default configuration when this field is missing in the data packet. Preset base colors are shown in Table 4 below: Table 4: Preset Primary Color Reference Table
[0110] As shown in Table 4, the preset base colors A reference color scheme is provided based on the type of physical quantity field, prioritizing the color value passed from the color field in the data packet. When the color field is missing, the default hue value is taken from the corresponding physical field type in Table 4 to ensure the visual recognizability of the color mapping results in different scenarios.
[0111] In the specific implementation process, firstly, within each parallel computing unit, the computation shader... For the mixing ratio Perform linear interpolation blending calculations between the target color and the preset target color to obtain the first... Layer color parameters Then from Extract the luminance component from it, and use it to... The luminance components are multiplied by the weighting coefficients to obtain the first... Layer Shading Enhancement Parameters .
[0112] S1044. Map the display ratio value in the target rendering region parameter to the height extreme value of the cavity model object in the vertical direction to obtain the vertical height threshold used for planar clipping as the clipping parameter, and write the color parameter, shading enhancement parameter and clipping parameter into the second buffer of WebGPU in the order of the corresponding hierarchical index.
[0113] The height extreme value refers to the geometric boundary value of the cavity model object in the vertical height direction, including the maximum height of the cavity model's bounding box. With minimum height It is also used to establish the mapping relationship between the display scale value in the target rendering area parameters and the actual height coordinates in three-dimensional space.
[0114] The vertical height threshold refers to the actual three-dimensional height coordinate value obtained by linearly mapping the display scale value to the height extreme value, including the liquid level plane clipping threshold. Cutting threshold with bottom plane Cutting parameters It refers to the and The constructed planar clipping boundary parameter pair is used to perform a planar clipping operation on geometric instances in the fragment shader to retain only the spatial coordinates located at... and Fragments within the interval between.
[0115] Second buffer This refers to a GPU buffer object allocated in WebGPU memory to store compute shader output data, storing the color parameters corresponding to each layer in hierarchical index order. Shading enhancement parameters With cutting parameters .
[0116] In the specific implementation process, the geometric boundary in the vertical height direction is first extracted from the vertex attribute data of the cavity model object to obtain the maximum height. With minimum height Next, the state parameter set... Target liquid level display ratio Scale with the bottom of the target By performing linear mapping with the height extrema, the liquid level plane clipping threshold and the bottom plane clipping threshold are obtained:
[0117]
[0118] in The cut-off height is the top plane height of the visible area of the cavity. The cutting height is the bottom plane of the visible area of the cavity; the two together constitute the cutting parameters. Then, in the compute shader, each level... Corresponding color parameters Shading enhancement parameters With cutting parameters Index by hierarchy Write to the second buffer in sequence The corresponding storage location.
[0119] This embodiment significantly reduces the computational load of the main thread, enabling layers with significant field value abrupt changes to exhibit stronger visual highlights during rendering. This not only improves the recognizability of the field distribution but also achieves precise limitation of the visible range of the cavity.
[0120] Optionally, step S1043, which involves performing numerical interpolation on the preset primary color based on the normalized coefficient sequence to obtain color parameters, and then weighting the luminance components of the color parameters based on the gradient coefficient sequence to obtain shading enhancement parameters, may specifically include: S10431. Extract multiple first color components from the preset primary color and multiple second color components from the preset target color. Use each normalized value in the normalized coefficient sequence as the numerical mixing ratio to perform linear interpolation mixing calculation on the second color components and the first color components to obtain the color parameters corresponding to each level.
[0121] The first color component refers to the preset primary color. In the RGB color space, the red, green, and blue components can be represented as vectors. Furthermore, it originates from the preset primary color configuration determined according to Table 4 in S1043. Preset target color. This refers to the target color parameter, which serves as the endpoint of color interpolation, and the preset primary color. Together they form the two ends of the color boundary of the linear interpolation hybrid calculation and can be configured according to the type of physical quantity field and business display requirements.
[0122] The second color component refers to the preset target color. In the RGB color space, the red, green, and blue components can be represented as vectors. It also participates in the linear interpolation calculation of each level of color parameters together with the first color component. The preset target colors are shown in Table 5 below: Table 5: Preset Target Color Reference Table
[0123] As shown in Table 5, the preset target color A reference color scheme is provided based on the type of physical field, typically using a bright white color scheme, in conjunction with the preset base color. This creates a contrast between light and dark areas, causing layers with higher normalization coefficients to approach brighter tones in the interpolation results, and layers with lower normalization coefficients to approach the base color. This results in a visually intuitive contrast in field distribution levels along the vertical direction of the cavity. In actual deployment, the corresponding field types of each physical quantity can be adjusted according to the business display requirements. Configuration.
[0124] In the specific implementation process, the first step is to start with the preset base color. Extract the first color component And according to Table 5, from the preset target color Extract the second color component Then, within each parallel computing unit, normalized coefficients are used... As a numerical mixing ratio, linear interpolation mixing calculations are performed on each channel of the first color component and the second color component to obtain the... Layer color parameters Values for each channel:
[0125] in Normalized coefficient sequence The Middle The normalized values corresponding to the layers, The larger The closer it gets to the preset target color , The smaller the value, the closer it is to the preset base color. Finally, for all... Each parallel computing unit sequentially performs the above interpolation calculation to obtain the color parameter set corresponding to each level. .
[0126] S10432. Extract the basic brightness value from the color parameters, use the corresponding gradient coefficient in the gradient coefficient sequence as the weighting coefficient, and perform a weighted product calculation on the basic brightness value to obtain the shading enhancement parameter corresponding to each level.
[0127] Basic brightness value It refers to the first Layer color parameters The base brightness representation value of the geometric instance in this layer, extracted from the RGB channel values, can be obtained by... The values of the red, green, and blue channels are calculated by weighting and summing them according to the standard brightness weighting coefficient, and are used to represent the overall brightness of the color parameters of this layer in visual perception.
[0128] In the specific implementation process, the color parameters obtained from S10431 are first processed within each parallel computing unit. In the RGB three-channel values, the red component is multiplied by 0.299, the green component by 0.587, and the blue component by 0.114 according to the standard brightness weighting coefficient, and then summed to obtain the _____. The base brightness value of the layer .
[0129] Next, the gradient coefficient sequence The corresponding gradient coefficients As a weighting coefficient, for Perform the product calculation to obtain the first... Layer Shading Enhancement Parameters ,in Gradient coefficient sequence The Middle The gradient coefficients corresponding to the layer.
[0130] This embodiment provides an intuitive visual representation of the field distribution hierarchy in the vertical direction of the cavity, enabling layers with dramatic changes in physical field values to exhibit stronger highlighting effects during subsequent rendering. It not only effectively highlights abrupt changes in field distribution but also significantly improves engineers' ability to quickly identify key features of the field situation and enhances their decision-making efficiency.
[0131] S105. Utilize the WebGPU rendering pipeline to perform instantiated rendering through a single draw call to generate multiple geometric instances corresponding to the cavity model object. Extract rendering parameters from the second buffer based on the instance index using the fragment shader to perform layered shading and range limitation on each geometric instance, and output a normalized rendering frame.
[0132] Optionally, step S105 utilizes the WebGPU rendering pipeline to perform instantiation rendering through a single draw call to generate multiple geometric instances corresponding to the cavity model object. The process of extracting rendering parameters from the second buffer using the fragment shader based on the instance index to perform layered shading and range limitation on each geometric instance, and outputting a normalized rendering frame, can specifically include: Figure 3 A flowchart illustrating an embodiment of the output normalization rendering frame method provided in this application is shown. Figure 3 As shown, the process of outputting the normalized rendering frame unfolds sequentially from step S1051 to step S1054, and a visible interval condition judgment branch for a single fragment is introduced at step S1054: First, in step S1051, the vertex attribute data of the cavity model object is associated and mapped with the storage address of the second buffer, and the rendering pipeline's drawing instance cardinality is configured according to the total number of field type sampling points of the target field type sequence. .
[0133] Subsequently, in step S1052, a single draw call instruction is initiated to generate multiple geometry instances in parallel in the scene, and the unique count value assigned to each geometry instance by the rendering pipeline is determined as the instance index. Next, in step S1053, the fragment shader determines the fragment based on the instance index. Retrieve the color parameters of the corresponding level from the second buffer. Shading enhancement parameters and cutting parameters .
[0134] Finally, in step S1054, the vertical height spatial coordinates of each geometric instance fragment are... The boundary is compared with the visible range defined by the clipping parameters, and the comparison result is used as a judgment condition to split the process into two processing branches: when When a fragment is located within the visible area between the bottom cutting plane and the liquid level cutting plane, the fragment is retained and the color enhancement parameter is applied. For color parameters The brightness channel performs modulation overlay to complete pixel assignment before writing to the frame buffer. or The fragment is discarded without being written to the frame buffer. After all fragments of all geometry instances have completed the above boundary comparison and pixel assignment, the rendering pipeline outputs a normalized rendered frame. This method includes: S1051. Associate and map the vertex attribute data of the cavity model object with the storage address of the second buffer, and configure the drawing instance base of the rendering pipeline according to the total number of field type sampling points of the target field type sequence.
[0135] Association mapping refers to binding the GPU vertex buffer slots corresponding to the vertex attribute data of the cavity model object to the second buffer. The storage address is associated with the declaration operation in the vertex stage of the WebGPU rendering pipeline, so that the rendering pipeline can access the vertex geometry data and the corresponding shading parameters of each layer at the same time when performing instantiation rendering, thus providing the fragment shader with a complete source of rendering data layer by layer.
[0136] Drawing instance cardinality This refers to the total number of geometry instances configured during a single draw call in the rendering pipeline, which can be a sequence of target field types. Total number of field type sampling points It also determines the number of geometry instances that the rendering pipeline generates in parallel during a single draw call.
[0137] In the specific implementation process, firstly, the GPU vertex buffer corresponding to the vertex attribute data of the cavity model object is bound to the vertex input slot of the rendering pipeline, and at the same time, the second buffer is... The storage address is declared as a read-only storage buffer in the rendering pipeline binding group, establishing vertex attribute data and The mapping relationships between the coloring parameters at each level are then established. Next, the target field type sequence is used. Total number of sampling points As the base number of drawing instances Write the drawing call configuration parameters into the rendering pipeline to specify that this single drawing call needs to generate in parallel. A geometric instance.
[0138] Finally, the shader modules of the vertex shader and fragment shader in the rendering pipeline were bound together, and the rendering pipeline state parameters were determined based on the geometric topological features of the cavity model object, which is presented as a closed surface. These parameters included enabling depth testing to handle complex occlusion relationships. Since the cavity model object is a closed surface and the viewpoint needs to observe the internal structure of the cavity through the near-side cavity wall, the culling mode was fixed to cull the front faces, i.e., cull the outer surface fragments whose triangle faces have normals facing the viewer, while retaining the inner wall fragments whose normals face away from the viewer. Simultaneously, color blending was disabled and configured for opaque writing to avoid spatial order disorder caused by the superposition of transparency in a large number of unsorted geometric instances.
[0139] S1052, Initiate a single draw call instruction to generate multiple geometry instances in parallel in the scene, and use the unique count value assigned to each geometry instance by the rendering pipeline to determine the unique count value as the instance index.
[0140] A single draw call instruction refers to triggering all operations simultaneously through a single drawIndexed or draw interface call in the WebGPU rendering pipeline. The GPU instructions for drawing each geometry instance. The unique count value refers to the value automatically assigned to each geometry instance by the rendering pipeline during instantiation rendering. to An incrementing integer number that can be read from a built-in variable in the vertex and fragment shaders, and whose value is unique and non-overlapping among different geometric instances in the rendering pipeline.
[0141] Instance Index This refers to an integer identifier that uses a unique count value directly as a hierarchical access index, and whose value range is [value range missing]. to , with the second buffer The storage order of the shading parameters at each level corresponds one-to-one so that each geometric instance can be accessed. Precisely locate and read The corresponding color parameters, shading enhancement parameters, and clipping parameters are specified in the text.
[0142] In the specific implementation process, the drawing interface of the WebGPU rendering channel encoder is first called, and the vertex index data of the cavity model object and the drawing instance cardinality are passed in. Initiate a single draw call instruction. Then the rendering pipeline... Automatically assign from each geometry instance to The unique count value is read during the vertex shader phase through a built-in instance identifier variable and used as the instance index. It is passed to the subsequent fragment shader stage.
[0143] Finally, the rendering pipeline uses the complete vertex geometry data of the cavity model object as a template to generate in parallel within the scene. There are 3 geometric instances, each sharing the same vertex geometry but holding an independent instance index. This allows for the implementation of a fragment shading-based approach in subsequent fragment shading stages. Differentiated layered coloring.
[0144] S1053. Using the fragment shader, retrieve the corresponding level's color parameters, shading enhancement parameters, and clipping parameters from the second buffer based on the instance index.
[0145] A fragment shader is a programmable shader that executes independently for each fragment after rasterization of each geometric instance in the WebGPU rendering pipeline. Its input parameters include only the instance index passed by the vertex shader interpolation. It also includes the fragment's three-dimensional spatial coordinates and other geometric attributes, and its output is the fragment's final color and depth values.
[0146] Fragment shaders are indexed by instance From the second buffer in the form of storage address offset Locate and read the first Color parameters corresponding to the layer Shading enhancement parameters With cutting parameters This enables layer-by-layer differentiated pixel assignment and range limitation logic.
[0147] In the specific implementation process, the instance index passed from the vertex shader stage is first received in the input declaration of the fragment shader program. At the same time, it was stated that the second buffer... The read-only access binding. Then the fragment shader... Calculate the offset The Middle The starting address for storing layer data is used to sequentially read the color parameters corresponding to that layer. Shading enhancement parameters With cutting parameters This is temporarily stored in the local variables of the fragment shader. Finally, confirm. Ensure the integrity of data reading at each layer, guaranteeing that color parameters, shading enhancement parameters, and clipping parameters are all correctly loaded.
[0148] S1054. The fragment shader assigns pixel values to the corresponding geometric instances based on the color parameters and shading enhancement parameters, and compares the spatial coordinate values of the geometric instances with the clipping parameters at the boundary. Only fragments whose spatial coordinate values are within the visible range defined by the clipping parameters are retained to generate a normalized rendering frame.
[0149] Pixel assignment refers to the fragment shader assigning color parameters. With shading enhancement parameters The operation of writing the merged calculation to the current fragment's output color channel is specifically described as follows: right The brightness channels are modulated and superimposed to make the layers of the field value change area present a stronger bright visual effect in the final rendered frame.
[0150] Spatial coordinate values This refers to the actual coordinates of the current fragment in the vertical height direction within the 3D scene coordinate system. These coordinates are calculated by the rendering pipeline during the rasterization stage using vertex coordinate interpolation and are used in the fragment shader along with clipping parameters. The defined visible interval boundaries are compared.
[0151] A normalized rendering frame refers to the final rendering result output to the frame buffer after layered shading and planar clipping. In this frame, the visible fragments of each geometric instance have had their pixel values assigned according to the shading parameters generated by the normalized coefficient sequence and gradient coefficient sequence, and only the spatial coordinates are retained. and Fragments between.
[0152] In the specific implementation process, the spatial coordinates of the current fragment's vertical height direction are first read from the fragment shader. Compare it with the trimming parameters read from S1053 Perform boundary comparison: If or If the current fragment is discarded, the discard instruction will be executed and it will not be written to the frame buffer; if If so, the current fragment is retained and the pixel assignment stage begins.
[0153] Next, the retained fragments are enhanced with color enhancement parameters. For color parameters The brightness channel is modulated and superimposed to obtain the final output color of the fragment. ,in The first one calculated in S10431 Layer RGB color parameters, The first one calculated in S10432 Layer shading enhancement parameters are then written to the corresponding pixel positions in the frame buffer. Finally, all... After all fragments of a geometric instance have completed the boundary comparison and pixel assignment operations described above, the rendering pipeline outputs a normalized rendering frame.
[0154] This embodiment significantly reduces the instruction synchronization overhead between the CPU and GPU, not only achieving layer-by-layer differentiated pixel assignment and highlight rendering, but also accurately preserving the effective fragments within the cavity's visible range, thus achieving an organic unity between high-performance instantiated layered shading and precise definition of the visible range.
[0155] Figure 4 This illustration shows a schematic diagram of a WebGPU-based double-buffered parallel shading and instantiated hierarchical rendering data flow provided in one embodiment of this application. Figure 4 As shown, the data stream starts from the main thread data preparation 401 and passes through the first buffer 410, the compute shader 420, the second buffer 430, the rendering pipeline 440, multiple geometry instances 450 and fragment shader 460 in sequence, and finally converges to the normalized rendering frame 470.
[0156] Among them, the main thread data preparation 401 is located on the browser's main thread side and is used to prepare the target field type sequence in the state parameter set. Normalized coefficient sequence Gradient coefficient sequence The parameters of the target rendering region are transmitted to the graphics processor side after being aligned with the bytes. The first buffer 410, the compute shader 420, the second buffer 430, the rendering pipeline 440, the multiple geometry instances 450, the fragment shader 460, and the normalized rendering frame 470 are all located on the graphics processor side.
[0157] The output of the main thread data preparation 401 is connected to the input of the first buffer 410, and the output of the first buffer 410 is connected to the input of the computation shader 420. The computation shader 420 follows the parallel index. Color parameters are calculated in parallel at each level. Shading enhancement parameters With cutting parameters Then its output is connected to the input of the second buffer 430. The second buffer 430 stores the above parameters in hierarchical index order and its output is connected to the input of the rendering pipeline 440.
[0158] Rendering pipeline 440 performs instantiation rendering in a single draw call to generate multiple geometry instances 450, each geometry instance 450 holding an instance index that corresponds one-to-one with each layer. The outputs of multiple geometric instances 450 are connected to fragment shader 460, while another input of fragment shader 460 is connected to the output of second buffer 430, to adjust the output according to the instance index. Retrieve the second buffer 430 Color parameters corresponding to the layer Shading enhancement parameters With cutting parameters Each geometric instance 450 is layered and colored, and the spatial coordinates of the vertical height of the fragments are set. Compare with the visible interval boundary to perform range-limited clipping.
[0159] The output of fragment shader 460 is connected to normalized rendering frame 470 to assign values to completed pixels and satisfy the requirements. Fragments are written to the frame buffer, and normalized rendered frames 470 are output.
[0160] Figure 5 This application provides a schematic diagram of a specific implementation of a WebGPU-based address cavity range normalized shader system, with reference to... Figure 5 The system may include: The acquisition module 510 is used to acquire a data packet including model identifier, field type sequence, numerical range parameters and rendering region parameters; The determination module 520 is used to extract a set of state parameters, including the target model identifier, target field type sequence, target numerical range parameters, and target rendering area parameters, after overwriting and merging the local cache configuration and data packet. The cavity model object is determined by matching the target model identifier with the current scene model identifier. The calculation module 530 is used to obtain a normalized coefficient sequence by mapping and truncating the target field type sequence by exchanging and limiting the extreme values of the target numerical range parameter, and to obtain a gradient coefficient sequence with the same length as the target field type sequence by calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping. The calculation module 530 is also used to write the target field type sequence, normalization coefficient sequence, gradient coefficient sequence and target rendering region parameters into the first buffer of WebGPU, and then use the calculation shader to calculate the color parameters, shading enhancement parameters and clipping parameters corresponding to each level according to the data in the first buffer and write them into the second buffer. The rendering module 540 is used to perform instantiated rendering through a single draw call using the WebGPU rendering pipeline to generate multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer according to the instance index to perform layered shading and range limitation on each geometric instance, and outputs a normalized rendering frame.
[0161] The WebGPU-based address cavity range normalization shading system of this application embodiment is used to implement the aforementioned WebGPU-based address cavity range normalization shading method. Therefore, the specific implementation of the WebGPU-based address cavity range normalization shading system can be found in the embodiment section of the WebGPU-based address cavity range normalization shading method above. The specific implementation can be referred to the description of the corresponding embodiments, which will not be repeated here.
[0162] Electronic devices may include processors and memory storing computer program instructions.
[0163] Specifically, the processor may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0164] The memory may include a large-capacity storage device for data or instructions. For example, and not limitingly, the memory may include a hard disk drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory may include removable or non-removable (or fixed) media. Where appropriate, the memory may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, the memory is non-volatile solid-state memory.
[0165] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of this disclosure.
[0166] The processor implements any of the WebGPU-based address cavity range normalization coloring methods described in the above embodiments by reading and executing computer program instructions stored in memory.
[0167] In one example, the electronic device may also include a communication interface and a bus. The processor, memory, and communication interface are connected via the bus and communicate with each other.
[0168] The communication interface is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0169] A bus, including hardware, software, or both, couples components of an online data traffic metering device together. For example, and not limitingly, a bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, a bus may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0170] The electronic device can execute the WebGPU-based address cavity range normalization coloring method in the embodiments of this application, thereby realizing the WebGPU-based address cavity range normalization coloring method described in conjunction with the accompanying drawings.
[0171] Furthermore, in conjunction with the WebGPU-based address cavity range normalization coloring method in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores computer program instructions; when executed by a processor, these computer program instructions implement any of the WebGPU-based address cavity range normalization coloring methods in the above embodiments.
[0172] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0173] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0174] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0175] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0176] The foregoing has provided a detailed description of the WebGPU-based address cavity range normalization coloring method and system. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A WebGPU-based address cavity range normalization coloring method, applied to a browser, characterized in that, include: Acquire a data package including model identifier, field type sequence, numerical range parameters, and rendering region parameters. The field type sequence refers to the set of physical quantity values sampled sequentially from bottom to top or from top to bottom along the vertical direction of the cavity. The field type sequence includes discrete sampled values of multi-physics fields such as pressure, temperature, concentration, and salinity. The numerical range parameters refer to the upper and lower boundary values used to establish the normalized mapping aperture. The numerical range parameters include minimum and maximum boundary values and are used to map the original values in the field type sequence to a unified range. The rendering region parameters refer to the set of parameters used to control the visible range and display ratio of the cavity model. The rendering region parameters include liquid level display ratio and bottom surface display ratio and are floating-point numbers with values ranging from 0 to 1. After overwriting and merging the local cache configuration with the data packet, a set of state parameters including the target model identifier, target field type sequence, target numerical range parameter and target rendering area parameter is extracted. The cavity model object is determined by matching the target model identifier with the current scene model identifier. By exchanging and limiting the extreme values of the target numerical range parameter, the target field type sequence is mapped and truncated to obtain a normalized coefficient sequence. By calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping, a gradient coefficient sequence with the same length as the target field type sequence is obtained. After writing the target field type sequence, the normalization coefficient sequence, the gradient coefficient sequence, and the target rendering region parameters into the first buffer of WebGPU, the computation shader calculates the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level based on the data in the first buffer and writes them into the second buffer. The color parameters refer to the RGB color values generated by the computation shader for each level to drive the pixel assignment of the corresponding level's geometric instance. The color parameters are obtained by interpolating and mixing preset primary colors with normalization coefficients. The shading enhancement parameters refer to the enhanced brightness values obtained by multiplying the brightness components of the color parameters with gradient coefficients as weighting coefficients. The shading enhancement parameters are used to achieve visual highlighting effects in the level region where the physical quantity field values change drastically to help engineers identify abrupt changes in the field distribution. The clipping parameters refer to the plane clipping boundary parameter pair composed of the liquid level plane clipping threshold and the bottom plane clipping threshold. The clipping parameters are used to perform plane clipping operations on geometric instances in the fragment shader to retain only fragments whose spatial coordinates are located in the interval between the liquid level plane clipping threshold and the bottom plane clipping threshold. The WebGPU rendering pipeline is used to perform instantiated rendering through a single draw call to generate multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer according to the instance index to perform layered shading and range limitation on each geometric instance, and outputs a normalized rendering frame.
2. The method according to claim 1, characterized in that, The step of overwriting and merging the local cache configuration with the data packet to extract a set of state parameters including the target model identifier, target field type sequence, target numerical range parameters, and target rendering region parameters, and determining the cavity model object by matching the target model identifier with the current scene model identifier, includes: The model identifier, field type sequence, numerical range parameter, and rendering region parameter in the local cache configuration are selected from the model identifier, field type sequence, numerical range parameter, and rendering region parameter in the data packet according to a preset priority rule to obtain the set of state parameters including the target model identifier, the target field type sequence, the target numerical range parameter, and the target rendering region parameter; Perform a text consistency check between the target model identifier and the scene model identifier currently being displayed; If the consistency check fails, execute the resource release command and retrieve the original three-dimensional geometry data according to the target model identifier, and determine the retrieved original three-dimensional geometry data as the cavity model object; If the consistency check passes, the current video memory usage remains unchanged, and the displayed geometry is identified as the cavity model object.
3. The method according to claim 1, characterized in that, The step of mapping and truncating the target field type sequence to obtain a normalized coefficient sequence by numerically exchanging and limiting the extreme values of the target numerical range parameter, including: After parsing the first and second extreme values in the target numerical range parameter into floating-point numbers, the value with the largest value among the first and second extreme values is determined as the maximum mapping boundary, and the value with the smallest value is determined as the minimum mapping boundary; When the difference between the maximum mapping boundary and the minimum mapping boundary is greater than or equal to a preset difference threshold, the difference between the maximum mapping boundary and the minimum mapping boundary is determined as the target range range; otherwise, the preset difference threshold is determined as the target range range. Calculate the deviation difference between the value of each field type in the target field type sequence and the minimum mapping boundary, and calculate the ratio of the deviation difference to the target range range to obtain the initial coefficient sequence; When the coefficient value in the initial coefficient sequence is greater than 1, it is corrected to 1; when the coefficient value in the initial coefficient sequence is less than 0, it is corrected to 0, thus obtaining the normalized coefficient sequence.
4. The method according to claim 1, characterized in that, The step of calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping to obtain a gradient coefficient sequence with the same length as the target field type sequence includes: Calculate the absolute value of the difference between each pair of adjacent field type values in the target field type sequence to obtain the absolute difference sequence; The maximum and minimum values are extracted from the absolute difference sequence and determined as the upper and lower bound boundaries of the gradient, respectively. When the difference between the upper bound of the gradient and the lower bound of the gradient is greater than or equal to a preset minimum threshold, the difference between the upper bound of the gradient and the lower bound of the gradient is determined as the gradient mapping range; otherwise, the preset minimum threshold is determined as the gradient mapping range. Calculate the boundary difference between each absolute difference in the absolute difference sequence and the lower bound of the gradient, and calculate the ratio of the boundary difference to the gradient mapping range to obtain the initial gradient sequence; The value at the end of the initial gradient sequence is inserted after the end position to obtain the gradient coefficient sequence with the same length as the target field type sequence.
5. The method according to claim 1, characterized in that, After writing the target field type sequence, the normalized coefficient sequence, the gradient coefficient sequence, and the target rendering region parameters into the first buffer of the WebGPU, the computation shader calculates the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level based on the data in the first buffer and writes them into the second buffer, including: The target field type sequence, the normalized coefficient sequence, and the gradient coefficient sequence are byte-aligned and then placed into the first buffer of WebGPU; The computation shader retrieves the target field type sequence, the normalized coefficient sequence, and the gradient coefficient sequence from the first buffer according to the parallel index; The color parameters are obtained by numerical interpolation of the preset primary color according to the normalized coefficient sequence, and the luminance component of the color parameters is weighted according to the gradient coefficient sequence to obtain the shading enhancement parameters. The display ratio value in the target rendering region parameter is mapped to the height extreme value of the cavity model object in the vertical direction to obtain the vertical height threshold for planar clipping as the clipping parameter. The color parameter, the shading enhancement parameter and the clipping parameter are written into the second buffer of WebGPU in the order of their corresponding hierarchical indexes.
6. The method according to claim 5, characterized in that, The step of obtaining the color parameters by performing numerical interpolation on the preset primary color according to the normalized coefficient sequence, and then performing weighted calculation on the luminance component of the color parameters according to the gradient coefficient sequence to obtain the shading enhancement parameters includes: Extract multiple first color components from the preset primary color and multiple second color components from the preset target color. Use each normalized value in the normalized coefficient sequence as a numerical mixing ratio to perform linear interpolation mixing calculation on the second color components and the first color components to obtain the color parameters corresponding to each level. The base brightness value is extracted from the color parameters, and the base brightness value is weighted and multiplied using the corresponding gradient coefficient in the gradient coefficient sequence as a weighting coefficient to obtain the shading enhancement parameter corresponding to each level.
7. The method according to claim 1, characterized in that, The process of using the WebGPU rendering pipeline to perform instantiation rendering through a single draw call to generate multiple geometric instances corresponding to the cavity model object, extracting rendering parameters from the second buffer based on the instance index using a fragment shader, performing layered shading and range limitation on each geometric instance, and outputting a normalized rendering frame includes: The vertex attribute data of the cavity model object is associated and mapped with the storage address of the second buffer, and the drawing instance cardinality of the rendering pipeline is configured according to the total number of field type sampling points of the target field type sequence. The single draw call instruction is initiated to generate the multiple geometric instances in parallel in the scene, and the unique count value assigned to each geometric instance by the rendering pipeline is used to determine the instance index. The fragment shader retrieves the color parameters, shading enhancement parameters, and clipping parameters of the corresponding level from the second buffer based on the instance index. The fragment shader assigns pixel values to the corresponding geometric instances based on the color parameters and the shading enhancement parameters, and compares the spatial coordinate values of the geometric instances with the clipping parameters to retain only fragments whose spatial coordinate values are within the visible range defined by the clipping parameters, thereby generating the normalized rendering frame.
8. A WebGPU-based address cavity range normalized shader system, characterized in that, include: The acquisition module is used to acquire a data package including model identifier, field type sequence, numerical range parameters, and rendering area parameters. The field type sequence refers to the set of physical quantity values sampled sequentially from bottom to top or from top to bottom along the vertical direction of the cavity. The field type sequence includes discrete sampled values of multi-physics fields such as pressure, temperature, concentration, and salinity. The numerical range parameters refer to the upper and lower boundary values used to establish the normalized mapping aperture. The numerical range parameters include minimum and maximum boundary values and are used to map the original values in the field type sequence to a unified range. The rendering area parameters refer to the set of parameters used to control the visible range and display ratio of the cavity model. The rendering area parameters include liquid level display ratio and bottom surface display ratio and are floating-point numbers with values ranging from 0 to 1. The determination module is used to extract a set of state parameters, including target model identifier, target field type sequence, target numerical range parameter and target rendering area parameter, after overwriting and merging the local cache configuration with the data packet; and to determine the cavity model object by matching the target model identifier with the current scene model identifier. The calculation module is used to map and truncate the target field type sequence to obtain a normalized coefficient sequence by exchanging and limiting the extreme values of the target numerical range parameter, and to obtain a gradient coefficient sequence with the same length as the target field type sequence by calculating the absolute difference between adjacent sampling points in the target field type sequence and performing interval mapping. The calculation module is further configured to write the target field type sequence, the normalization coefficient sequence, the gradient coefficient sequence, and the target rendering region parameters into the first buffer of the WebGPU, and then use the computation shader to calculate the color parameters, shading enhancement parameters, and clipping parameters corresponding to each level based on the data in the first buffer and write them into the second buffer. The color parameters refer to the RGB color values generated by the computation shader for each level to drive the pixel assignment of the corresponding level geometric instance. The color parameters are obtained by interpolation and mixing of preset primary colors through normalization coefficients. The shading enhancement parameters refer to the enhanced brightness values obtained by multiplying the brightness components of the color parameters with gradient coefficients as weighting coefficients. The shading enhancement parameters are used to achieve visual highlighting effects in the level region where the physical quantity field values change drastically to help engineers identify abrupt changes in the field distribution. The clipping parameters refer to the plane clipping boundary parameter pair composed of the liquid level plane clipping threshold and the bottom plane clipping threshold. The clipping parameters are used to perform plane clipping operations on geometric instances in the fragment shader to retain only fragments whose spatial coordinates are located in the interval between the liquid level plane clipping threshold and the bottom plane clipping threshold. The rendering module is used to perform instantiated rendering through a single draw call using the WebGPU rendering pipeline to generate multiple geometric instances corresponding to the cavity model object. The fragment shader extracts rendering parameters from the second buffer according to the instance index to perform layered shading and range limitation on each geometric instance and outputs a normalized rendering frame.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the WebGPU-based address cavity range normalization coloring method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, enables the implementation of the WebGPU-based address cavity range normalization coloring method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Three-dimensional volume data visualization parallel rendering method based on OpenCL
CN111369661A
WebGPU-based three-dimensional model loading method and system
CN119359884A