A water information uniform encoding and decoding shader system and method
By sharing common shader files on the CPU and GPU sides, unified encoding and decoding of water area information is achieved, which solves the rendering anomaly problem caused by inconsistent encoding logic in the 3D graphics rendering pipeline, improves rendering accuracy and stability, and reduces system maintenance complexity and computational overhead.
Patent Information
- Application Number
- CN202611381123.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-27
AI Technical Summary
In the 3D graphics rendering pipeline, the independent maintenance of encoding rules and decoding logic on the CPU and GPU sides leads to semantic discrepancies, resulting in abnormal output of water surface flow field rendering. It also increases the cross-end conversion computational overhead and rendering latency, which cannot meet the requirements of real-time rendering.
A unified encoding and decoding shader system for water area information is adopted. By sharing a common shader file at the data generation end and the image rendering end, the encoding function and the decoding function are inversely related, which realizes the semantic consistency of multi-attribute water area flow field data throughout the entire link, avoids rendering anomalies caused by cross-end logical separation, and reduces system maintenance overhead.
It achieves full-link semantic consistency of water flow field data, improves the physical semantic restoration accuracy and visual presentation stability of rendering and decoding, reduces cross-end transmission interface adaptation overhead and hardware resource consumption, and ensures the response synchronization of real-time water rendering.
Smart Images

Figure CN123181682A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics technology, and specifically to a unified encoding and decoding shader system and method for water area information. Background Technology
[0002] In 3D graphics rendering pipelines and heterogeneous computing systems, the central processing unit (CPU) is responsible for calculating and packaging the raw physical data and storing it in intermediate textures; the graphics processing unit (GPU) performs spatial sampling and decoding of the intermediate textures through shader programs to drive efficient real-time rendering of physical fields.
[0003] In traditional cross-platform transmission and rendering solutions for water flow field data, CPU-side encoding rules and GPU-side decoding logic are typically developed and maintained independently. Due to the lack of unified semantic constraints and standardized interfaces, when the system adjusts the encoding mapping formula, normalization parameters, or channel allocation strategy, it is necessary to modify the CPU-side packaging code and multiple shader programs on the GPU side. This separate maintenance mechanism can lead to semantic discrepancies in encoding and decoding when the logic updates at both ends are asynchronous. This results in numerical errors in the physical quantities recovered from the GPU's unpacking, ultimately causing abnormal output in the water surface flow field rendering.
[0004] To mitigate semantic discrepancies, related technologies employ parameter alignment by refactoring cross-platform communication logic or adding intermediate verification protocols. However, these methods typically require writing repetitive inline mapping logic in the shader code, increasing code redundancy and system maintenance complexity, and impacting cross-platform interface debugging efficiency. Furthermore, when rendering water surfaces requires packaging and unpacking multi-attribute physical quantities, it adds extra cross-platform conversion computation overhead and rendering latency, failing to meet the computational efficiency requirements of real-time rendering scenarios. Summary of the Invention
[0005] This application provides a unified encoding and decoding shader system and method for water area information, which realizes the semantic consistency of multi-attribute water flow field data from the data generation end to the image rendering end and maintains a single data source, avoiding rendering anomalies caused by cross-end logic separation and reducing system maintenance overhead.
[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0007] According to a first aspect of the embodiments of this application, a unified encoding and decoding shader system for water area information is provided. The system includes a data generation end and an image rendering end. The data generation end includes an acquisition module and an encoding module. The image rendering end includes a shader module and a decoding module. The acquisition module is used to acquire the original flow field data and common shader file of the target water area. The original flow field data includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file includes at least an encoding function and a decoding function. The encoding module is used to map each component in the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value based on the encoding function to obtain multi-channel data, and then merge the data of each channel to obtain an intermediate raster texture. The coloring module is used to spatially sample the intermediate grid texture to obtain the corresponding target pixel data; The decoding module is used to perform decoding calculations on the target pixel data based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value, so as to perform water area rendering processing based on the original flow field data; wherein, the image rendering end shares the common shader file, and the encoding function and the decoding function are inverse operations.
[0008] In some example embodiments of this application, based on the foregoing scheme, the encoding module is specifically used for: The multi-channel data is obtained by mapping the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value based on the flow vector encoding function, the flow velocity encoding function, and the water area type weight value in the encoding function.
[0009] In some example embodiments of this application, based on the foregoing scheme, the stream vector encoding function includes preset coefficients and preset biases, and the encoding module is specifically used for: Calculate the first product value of the first component in the two-dimensional flow vector and the preset coefficient, and determine the sum of the first product value and the preset bias as the first channel data; Calculate the second product value of the second component in the two-dimensional flow vector and the preset coefficient, and determine the sum of the second product value and the preset bias as the second channel data.
[0010] In some example embodiments of this application, based on the foregoing scheme, the encoding module is specifically used for: The flow velocity scalar value is normalized by division based on the preset maximum flow velocity value, and the flow velocity scalar value is mapped to a preset interval to obtain the third channel data. The water area type weight value is subjected to amplitude limiting processing based on a preset interval truncation function, and the water area type weight value is mapped to a preset interval to obtain the fourth channel data.
[0011] In some example embodiments of this application, based on the foregoing scheme, the encoding module is specifically used for: The mapping process is performed based on a pre-configured encoding function header file, wherein the encoding function header file contains inline functions that are logically consistent with the common shader file, so that the encoding result at the data generation end is semantically consistent with the decoding result at the image rendering end.
[0012] In some example embodiments of this application, based on the foregoing scheme, the decoding module is specifically used for: The flow vector decoding function, flow velocity decoding function, and water area type weight decoding function based on the aforementioned decoding function are used to decode the multi-channel data in the target pixel data to obtain the original flow field data.
[0013] In some example embodiments of this application, based on the foregoing scheme, the intermediate grid texture adopts a 16-bit half-precision floating-point texture format.
[0014] According to a second aspect of the embodiments of this application, a unified encoding, decoding, and coloring method for water area information is provided, the method comprising: Obtain the raw flow field data and common shader file of the target water area. The raw flow field data includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file includes at least an encoding function and a decoding function. Based on the encoding function, each component in the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value are mapped to obtain multi-channel data. The data from each channel are then merged to obtain an intermediate raster texture. Spatial sampling is performed on the intermediate grid texture to obtain the corresponding target pixel data; The target pixel data is decoded and calculated based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. Water area rendering is then performed based on the original flow field data. The image rendering end that performs the decoding calculation shares the common shader file, and the encoding function and the decoding function are inverse operations.
[0015] According to a third aspect of the embodiments of this application, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method as described in the second aspect.
[0016] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method as described in the second aspect.
[0017] This application provides a unified encoding and decoding shader system for water area information. It obtains a common shader file containing both encoding and decoding functions at the data generation end, and this common shader file is shared by the image rendering end. Therefore, compared to the traditional approach of independently maintaining the encoding logic at the data generation end and the decoding logic at the image rendering end, this system enables centralized maintenance and shared reuse of encoding and decoding logic under a single data source. This avoids rule conflicts and code redundancy caused by asynchronous cross-end development, and ensures the consistency of encoding and decoding rules at the system architecture level.
[0018] Furthermore, by setting the encoding and decoding functions in the common shader file to be inverse operations, and performing reverse decoding calculations on the spatially sampled target pixel data based on the decoding function at the image rendering end, the original flow field data containing two-dimensional flow vectors, flow velocity scalar values, and water area type weight values is restored. Thus, during cross-end flow field data transfer and parsing, it can be ensured that each pixel data has a definite physical semantics throughout the entire chain from encoding and writing at the data generation end, storage and mapping of intermediate raster textures to spatial sampling and decoding restoration at the image rendering end. This avoids numerical restoration deviations and water rendering anomalies caused by mismatches in encoding and decoding mapping logic, improving the accuracy of physical semantic restoration during rendering and decoding, and the stability of the visual representation of the water surface.
[0019] Furthermore, the encoding module maps each component of the two-dimensional flow vector, the scalar value of the flow velocity, and the weight value of the water area type based on the encoding function, and merges them into an intermediate raster texture of multi-channel data. The shading module then performs spatial sampling on the intermediate raster texture. This allows the mapping and integration of multi-attribute water flow field physical quantities into a unified texture data structure, reducing the interface adaptation overhead and memory bus access frequency when cross-end transmission and processing multi-source discrete data in the graphics pipeline. It also provides a standardized and unified data input interface for downstream shader programs. Simultaneously, the modular calling method based on shared public shader files avoids writing repetitive inline mapping logic in the shader code of each image rendering end, simplifying the calculation process in cross-end data communication and the rendering pipeline. This reduces the computational overhead and hardware resource consumption during real-time water area rendering, avoids rendering stuttering and latency caused by complex cross-end data logic, and ensures real-time synchronization between data generation and screen water flow field rendering response.
[0020] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this application, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0022] Figure 1 The schematic diagram illustrates the structure of a unified encoding and decoding shader system for water information according to some embodiments of this application.
[0023] Figure 2 The illustration shows a flowchart of a unified encoding, decoding, and coloring method for water area information according to some embodiments of this application.
[0024] Figure 3 The illustration schematically shows a hardware structure diagram of a computer device according to some embodiments of this application.
[0025] Figure 4 A schematic diagram of a computer-readable storage medium according to some embodiments of this application is shown.
[0026] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of systems and methods consistent with some aspects of this application as detailed in the appended claims.
[0028] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0029] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0030] Furthermore, the accompanying drawings are for illustrative purposes only and are not necessarily drawn to scale. The block diagrams shown in the drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor systems and / or microcontroller systems.
[0031] In this example embodiment, a unified encoding and decoding shader system for water area information is first provided, such as... Figure 1 As shown, Figure 1 A schematic diagram illustrating the structure of a unified encoding / decoding shader system for water area information according to some embodiments of this application is shown. (Reference) Figure 1 As shown, the unified encoding and decoding shader system for water area information may include a data generation end and an image rendering end. The data generation end includes an acquisition module 110 and an encoding module 120, and the image rendering end includes a shader module 130 and a decoding module 140.
[0032] The unified encoding and decoding shader system for water area information in this example embodiment will be further described below.
[0033] In the example implementation of this application, the acquisition module is used to acquire the original flow field data and common shader file of the target water area. The original flow field data includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file includes at least an encoding function and a decoding function.
[0034] In the example implementation of this application, the acquisition module is deployed at the data generation end (such as the central processing unit CPU end) to load and read the multi-dimensional physical quantity data of the water area to be rendered during the initialization or data update stage of the water area rendering pipeline. At the same time, it reads the common shader file stored in the graphics processor (GPU) accessible storage medium to provide a unified semantic benchmark for subsequent texture packaging and shader compilation.
[0035] Specifically, the raw flow field data is a multi-attribute data set used to characterize the physical flow properties of the target water body. The two-dimensional flow vector includes the first component. (i.e., the X-axis component) and the second component (i.e., the Y-axis component), used to represent the direction of water flow in a two-dimensional plane coordinate system, and the range of values for each component is as follows: ; Flow velocity scalar value A non-negative real number used to characterize the speed of water flow; water area type weight value. These are scalar coefficients, and their values range from... The ratio between these values is used to characterize the transitional mixing ratio between different water body types.
[0036] The system pre-builds a common shader file for shared use by the image rendering end. This common shader file is stored in a storage medium accessible to the graphics processor. The common shader file centrally stores and maintains the declarations of encoding and decoding functions that are shared by the data generation end and the image rendering end. This common shader file is organized using a modular file structure, avoiding the hard-coding and repetitive scattering of encoding and decoding function definitions in individual shader programs.
[0037] For example, the encoding and decoding functions centrally declared in the public shader file include: a flow vector encoding function and a flow vector decoding function, used to declare the inverse mapping interface between each component in the two-dimensional flow vector and the corresponding channel data in the intermediate raster texture; a flow velocity encoding function and a flow velocity decoding function, used to declare the inverse mapping interface between the flow velocity scalar value and the corresponding channel data based on the system's preset maximum flow velocity normalization parameter; a water area type weight encoding function and a water area type weight decoding function, used to declare the inverse mapping interface between the water area type weight value and the corresponding channel data; and a multi-attribute unified encoding function and a multi-attribute unified decoding function, used to declare a unified calling interface for packaging data containing two-dimensional flow vectors, flow velocity scalar values, and water area type weight values into four-dimensional vector pixel data at once, or for unpacking four-dimensional vector pixel data at once and restoring it into the corresponding multi-dimensional original flow field data.
[0038] In some example implementations, the acquisition module retrieves a common shader file from the storage medium and loads the common shader file into a shader management architecture accessible to the graphics processor. The common shader file centrally defines the encoding and decoding functions for multiple physical quantities of the flow field, so that multiple shader stages inside the image rendering end (such as vertex shaders and fragment shaders) can directly share and reference the function declarations and implementations in the common shader file through preprocessor-included instructions during the shader compilation or execution phase, thereby avoiding the repeated and scattered definition of encoding and decoding logic by each shader program.
[0039] It should be noted that the acquisition module establishes a single data source sharing mechanism for the image rendering end by uniformly acquiring and injecting the common shader file into the graphics processor. When the decoding rules, normalization coefficients, or channel mapping relationships of the water flow field change, only the function implementations in the common shader file need to be updated and maintained. The individual shader programs (such as vertex shaders and fragment shaders) that directly reference the common shader file can automatically synchronize and maintain the latest decoding semantics. This avoids the cumbersome maintenance and update omissions caused by hard coding in various shader programs on the image rendering end, and ensures the standardization and consistency of the flow field data parsing semantics during the rendering stage.
[0040] In the example implementation of this application, the encoding module maps each component, velocity scalar value, and water area type weight value in the two-dimensional flow vector based on the encoding function to obtain multi-channel data, and merges the data of each channel to obtain the intermediate raster texture.
[0041] In the example implementation of this application, the encoding module is deployed at the data generation end (such as the central processing unit CPU) to receive the raw flow field data read by the acquisition module, and to map the continuous multi-attribute physical quantity data into multi-channel pixel data that meets the requirements of the graphics rendering pipeline by calling a predefined encoding function. Finally, it is written and constructed into an intermediate raster texture as a data carrier for cross-end transmission and storage.
[0042] Specifically, the encoding module performs mapping processing based on a pre-configured encoding function header file. This header file contains inline functions with logic consistent with the common shader file. The header file converts the attribute encoding functions written in the shader language into equivalent inline functions on the CPU. When the encoding module performs mapping processing on the raw flow field data on the CPU, it directly calls the expanded inline functions in the encoding function header file to generate corresponding single-channel data to form multi-channel data. This ensures that the normalization parameters and mapping operation logic used by the encoding module at the data generation end are consistent with the common shader file called by the image rendering end on the GPU, thus ensuring semantic consistency between the encoding result at the data generation end and the decoding result at the image rendering end.
[0043] For example, the encoding module performs mapping processing on the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value respectively through the flow vector encoding function, the flow velocity encoding function, and the water area type weight encoding function in the encoding function header file.
[0044] Furthermore, the stream vector coding function includes preset coefficients and preset biases. These preset coefficients can be... The preset bias can be The encoding module obtains the first component (i.e., the X-axis component, with a value range of...) in the two-dimensional flow vector. After that, calculate the first product value of the product between the first component and the preset coefficient, and then add the first product value to the preset bias. The sum obtained is then determined as the corresponding channel data.
[0045] The encoding module obtains the second component (i.e., the Y-axis component, with a value range of) in the two-dimensional flow vector. After that, calculate the second product value of the product between the second component and the preset coefficient, and then add the second product value to the preset bias. The sum obtained is then determined as the corresponding channel data.
[0046] Through the above mapping calculation, the range of values is... The first and second components of the two-dimensional flow vector within the interval are respectively mapped to... The first and second channel data within the normalized interval.
[0047] Furthermore, after acquiring the input flow velocity scalar value, the encoding module performs division normalization on the flow velocity scalar value based on a preset maximum flow velocity normalization parameter, and then limits the normalization result to a preset interval using an interval truncation function. The obtained values are then designated as the third channel data, and the corresponding mapping formula is: in, This represents the input flow rate scalar value. This represents the system's preset maximum flow rate normalization parameter. Represents the interval limiting function (when Time return ,when Time return Return to the previous page for all other cases. ), This represents the channel data corresponding to the flow velocity scalar value in the intermediate raster texture.
[0048] After obtaining the water area type weight value, the encoding module performs amplitude limiting on the water area type weight value based on a preset interval truncation function, restricting the value to a preset interval. Within this, the corresponding channel data is obtained, and the corresponding mapping formula is: In the formula, This indicates the weight value for the water area type. This represents the interval cutoff function. Channel data representing the water type weight values in the intermediate raster texture.
[0049] The encoding module calls the multi-attribute unified encoding function in the encoding function header file, and then sequentially calls the individual attribute encoding functions to merge the channel data into four-dimensional vector pixel data. Subsequently, the encoding module writes the merged pixel data into a pre-allocated texture storage space, generating an intermediate raster texture corresponding to the target water area. In this intermediate raster texture, the multi-channel data at each pixel location respectively stores the two-dimensional flow vector component encoding, flow velocity scalar encoding, and water area type weight encoding at that sampling point, realizing the merging and storage of multi-attribute data in a unified raster data structure.
[0050] Therefore, by having the encoding module call an inline encoding function on the central processing unit that is strictly consistent with the preset logic of the common shader file, the mapping rules used by the data generation end when packaging and writing the flow field data are kept strictly symmetrical in terms of parameters and numerical calculations with the decoding rules used by the image rendering end when reading the texture on the graphics processor end. This avoids semantic deviation problems caused by the separation of code maintenance on the CPU end and the GPU end from the architectural level, and ensures consistent data semantics throughout the entire data transmission and parsing chain.
[0051] In the example implementation of this application, the coloring module 130 performs spatial sampling on the intermediate grid texture to obtain the corresponding target pixel data.
[0052] In the example implementation of this application, the shading module 130 is deployed on the image rendering end (such as the vertex shader or fragment shader on the graphics processing unit GPU) to respond to the rendering instructions of the image rendering end, obtain the texture sampling coordinates corresponding to the intermediate raster texture, and perform spatial sampling operation on the intermediate raster texture containing multi-attribute encoded data based on the texture sampling coordinates to extract the target pixel data containing four channel components for subsequent decoding calculation and rendering processing by the decoding module.
[0053] Specifically, the shading module receives the two-dimensional texture coordinates generated by vertex attributes or fragment interpolation in the graphics rendering pipeline, and performs spatial sampling operations on the intermediate raster texture (which can be a 32-bit RGBA or GL_RGBA8 format raster texture) stored in video memory, in combination with texture sampler variables (such as a two-dimensional texture sampler object of type sampler2D).
[0054] For example, in the main function of the fragment shader or vertex shader, the shading module calls the texture sampling function built into the shader language, passing in the texture sampler and texture sampling coordinates, and performs sampling. When performing spatial sampling operations, the target pixel data obtained by the shading module contains the corresponding multi-channel data.
[0055] It should be noted that the target pixel data obtained by the shading module through spatial sampling of the intermediate raster texture corresponds to the two-dimensional flow vector component encoding value, flow velocity scalar encoding value, and water area type weight encoding value stored in the encoding stage at the data generation end. Through this spatial sampling step, the image rendering end extracts the target pixel data at the target sampling point and passes the target pixel data as input parameters to the decoding module, which then calls the decoding function in the shared public shader file to perform data reconstruction.
[0056] In the example implementation of this application, the decoding module 140 performs decoding calculations on the target pixel data based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value, so as to perform water area rendering processing based on the original flow field data; wherein, the image rendering end shares a common shader file, and the encoding function and the decoding function are inverse operations.
[0057] In the example implementation of this application, the decoding module 140 is deployed on the image rendering end (such as the vertex shader or fragment shader on the graphics processing unit GPU) to receive the target pixel data obtained by the shading module 130 through spatial sampling, and to perform decoding calculations on the multi-channel pixel data by calling the decoding function that is shared and referenced from the public shader file, so as to restore the original flow field data containing the two-dimensional flow vector, the flow velocity scalar value and the water area type weight value, so as to drive the water surface rendering pipeline.
[0058] Specifically, when the decoding module performs decoding calculations on the target pixel data, it calls the attribute decoding functions defined in the common shader file to decode the data of each channel in the target pixel data to restore the original flow field data.
[0059] For example, the target pixel data contains multi-channel data. The decoding module performs the following decoding processing on the multi-channel data in the target pixel data through the flow vector decoding function, the flow velocity decoding function, and the water area type weight decoding function: After obtaining the channel data corresponding to each component in the two-dimensional flow vector, the decoding module can determine the difference between the channel data corresponding to each component and the preset bias, and then determine the corresponding component by multiplying the difference corresponding to each component with the reciprocal of the preset coefficient.
[0060] After obtaining the channel data corresponding to the flow velocity scalar value, the decoding module can perform a multiplication calculation based on the system's preset maximum flow velocity normalization parameter to reconstruct the flow velocity scalar value. The corresponding decoding formula is: in, This represents the channel data corresponding to the scalar value of the target pixel data flow rate. This represents the preset maximum flow rate normalization parameter. This represents the scalar value of the flow rate obtained from decoding.
[0061] After obtaining the channel data corresponding to the water area type weight, the decoding module decodes the water area type weight value based on the water area type weight decoding function. The corresponding decoding formula is: in, This represents the channel data corresponding to the water area type weight of the target pixel data. This represents the weight value of the restored water area type (the value is in the range of...). Within the interval).
[0062] Furthermore, regarding texture storage precision, intermediate raster textures can be stored using a 16-bit half-precision floating-point texture format. This is significantly more precise than 8-bit single-channel encoding formats (such as GL_RGBA8, which have a lower precision). Using a 16-bit half-precision floating-point texture format, the storage bits for single-channel data can be extended to 16 bits (encoding precision is...). This format increases the precision of numerical data representation and enables the recording of smaller flow field variations. Under this format, the encoding / decoding function interfaces in common shader files remain consistent.
[0063] It should be noted that the decoding module directly shares and references common shader files on the image rendering end through preprocessor directives (such as #include), ensuring that the encoding at the data generation end and the decoding at the image rendering end use the same set of common shader files as the data source. This ensures that every pixel data has consistent data semantics throughout the entire chain, from encoding and writing at the data generation end, storing intermediate raster textures, to spatial sampling and decoding at the image rendering end, avoiding deviations in physical quantity reconstruction caused by inconsistencies in encoding and decoding logic.
[0064] like Figure 2 As shown, Figure 2 This is a flowchart illustrating a unified encoding, decoding, and coloring method for water area information according to an exemplary embodiment of this application, which includes steps 201-204.
[0065] Step 201: Obtain the raw flow field data and common shader file of the target water area. The raw flow field data shall include at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file shall include at least an encoding function and a decoding function.
[0066] In the exemplary embodiment of this disclosure, the original flow field data is a multi-attribute data set used to characterize the physical flow properties of the target water body. The two-dimensional flow vector includes a first component (i.e., the X-axis component) and a second component (i.e., the Y-axis component), used to represent the direction of water flow in a two-dimensional plane coordinate system. The value range of each component is as follows: The velocity scalar value is a non-negative real number used to characterize the speed of water flow; the water area type weight is a scalar coefficient, and its value ranges from... The ratio between these values is used to characterize the transitional mixing ratio between different water body types.
[0067] The common shader file centrally stores and maintains the declarations of encoding and decoding functions that can be shared and called by both the data generation and image rendering ends. This common shader file is organized using a modular file structure, avoiding the hard-coding and dispersion of encoding and decoding function definitions in individual shader programs.
[0068] In some example implementations, the data generation end is pre-configured with an encoding function header file that is semantically consistent with the common shader file. The encoding function header file defines the encoding functions written in the shader language as equivalent inline functions that are executed on the central processing unit, so that the data generation end can directly call and expand them when performing flow field mapping processing, thereby ensuring that the encoding logic when the data generation end writes to the texture is strictly consistent with the operation rules of the common shader file referenced by the image rendering end.
[0069] It should be noted that by building a cross-end shared maintenance mechanism with a common shader file as the core benchmark, and combining it with an equivalent encoding function header file at the data generation end, the heterogeneous ends can maintain synchronization based on preset mapping rules when the flow field rules change. The individual shader programs (such as vertex shaders and fragment shaders) that directly reference this common shader file can automatically maintain the latest decoding semantics. This avoids the cumbersome maintenance and update omissions caused by scattered hard coding at each stage of the graphics pipeline, eliminates the semantic deviation problem caused by the separation of code maintenance between the CPU and GPU ends, and ensures consistent data semantics throughout the entire chain of data generation, storage, sampling and decoding.
[0070] Step 202: Based on the encoding function, each component, velocity scalar value and water area type weight value in the two-dimensional flow vector are mapped to obtain multi-channel data, and the data of each channel are merged to obtain the intermediate raster texture.
[0071] In the exemplary implementation of this disclosure, when mapping the raw flow field data, the corresponding single-channel data is generated by calling the attribute encoding functions defined in the common shader file or the corresponding CPU-side encoding header file to form multi-channel data. This multi-channel data includes the channel data obtained after mapping the two-dimensional flow vector, the velocity scalar value, and the water area type weight value.
[0072] The data from each channel can be merged to form vector pixel data, and the merged pixel data is written into a pre-allocated texture storage space to generate an intermediate raster texture corresponding to the target water area (a 32-bit RGBA or GL_RGBA8 format raster texture can be used). In this intermediate raster texture, each pixel location stores the corresponding two-dimensional flow vector X component encoding, two-dimensional flow vector Y component encoding, flow velocity scalar encoding, and water area type weight encoding for that sampling point, thus realizing the merging and storage of multi-attribute data in a unified raster data structure.
[0073] Step 203: Spatial sampling is performed on the intermediate grid texture to obtain the corresponding target pixel data.
[0074] In an example implementation of this disclosure, the graphics rendering pipeline receives two-dimensional texture coordinates generated by vertex attributes or fragment interpolation, and performs spatial sampling operations on intermediate raster textures stored in video memory in conjunction with texture sampler variables (such as two-dimensional texture sampler objects of type sampler2D).
[0075] For example, in the main function (such as the main() function) of the fragment shader or vertex shader, the texture sampler and texture sampling coordinates are passed in by calling the texture sampling function built into the shader language.
[0076] Furthermore, during the spatial sampling operation, the acquired target pixel data contains corresponding channel data. The target pixel data obtained by spatially sampling the intermediate raster texture is then passed as an input parameter to the decoding step, which calls the decoding function in the shared common shader file to perform data reconstruction.
[0077] The intermediate raster texture can be stored using a 16-bit half-precision floating-point texture format. This is significantly more precise than an 8-bit single-channel encoding format (such as GL_RGBA8, which has a lower encoding precision). Using a 16-bit half-precision floating-point texture format, the storage bits for single-channel data can be extended to 16 bits (encoding precision is...). This format increases the precision of numerical data representation and enables the recording of smaller flow field variations. Under this format, the encoding / decoding function interfaces in common shader files remain consistent.
[0078] Step 204: Decode the target pixel data based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value, so as to perform water area rendering processing based on the original flow field data; wherein, the image rendering end that performs the decoding calculation shares a common shader file, and the encoding function and the decoding function are inverse operations.
[0079] In the example implementation of this disclosure, when decoding the target pixel data, the decoding functions of each attribute defined in the common shader file are called to decode the data of each channel in the target pixel data respectively, so as to restore the original flow field data.
[0080] In some example implementations, a unified decoding function with multiple attributes is also defined in the common shader file. The target pixel data can be passed in by a single call to the corresponding interface, and three sub-functions can be called sequentially within that interface. The output parameters return the restored two-dimensional flow vector, flow velocity scalar value, and water area type weight value.
[0081] It should be noted that the common shader file is directly shared and referenced by preprocessor instructions at the image rendering end, ensuring that the encoding at the data generation end and the decoding at the image rendering end use the same common shader file as the data source. This ensures that every pixel data has consistent data semantics throughout the entire chain, from encoding and writing at the data generation end, storing intermediate raster textures, to spatial sampling and decoding at the image rendering end, avoiding deviations in physical quantity restoration caused by inconsistencies in encoding and decoding logic.
[0082] It should be noted that the unified encoding and decoding coloring method for water area information in this embodiment is used to implement the corresponding unified encoding and decoding coloring system for water area information in the aforementioned system embodiments, and has the beneficial effects of the corresponding embodiments, which will not be repeated here.
[0083] The embodiments of the unified encoding and decoding shader system for water information in this application can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented in software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor reading the corresponding computer program instructions from non-volatile memory into memory and executing them. From a hardware perspective, such as... Figure 3 The diagram shown is a hardware structure diagram of a computer device containing a unified encoding and decoding shader system for water area information according to an embodiment of this application. Except for... Figure 3In addition to the processor 310, memory 330, network interface 320, and non-volatile memory 340 shown, the server or electronic device where the water information unified encoding and decoding shader system is located in the embodiment may also include other hardware depending on the actual function of the computer device, which will not be described in detail here.
[0084] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0085] In one example embodiment of this application, a computer-readable storage medium is also provided, on which a program 400 capable of implementing the methods described above is stored. In some possible embodiments, various aspects of this application may also be implemented as a program product 400, which includes program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this application according to various exemplary embodiments of this application.
[0086] In the description of this application, the terms "first" and "second" are used for description only and do not indicate relative importance or imply the number of technical features. Therefore, the features referred to as "first" or "second" may explicitly or implicitly include at least one of those features. "A plurality of" means at least two, unless otherwise expressly defined.
[0087] Through the description of the above embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.
[0088] Finally, the above preferred embodiments are only used to illustrate the technical solutions of this application and are not restrictive. Although this application has been described in detail, those skilled in the art should understand that changes in form and detail can be made without departing from the scope defined by the claims of this application. The dimensions in the drawings are not related to the specific physical object, and the physical object dimensions can be arbitrarily changed.
Claims
1. A unified encoding and decoding shader system for water area information, the system comprising a data generation end and an image rendering end, characterized in that, The data generation end includes an acquisition module and an encoding module, and the image rendering end includes a coloring module and a decoding module. The acquisition module is used to acquire the original flow field data and common shader file of the target water area. The original flow field data includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file includes at least an encoding function and a decoding function. The encoding module is used to map each component in the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value based on the encoding function to obtain multi-channel data, and then merge the data of each channel to obtain an intermediate raster texture. The coloring module is used to spatially sample the intermediate grid texture to obtain the corresponding target pixel data; The decoding module is used to perform decoding calculations on the target pixel data based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value, so as to perform water area rendering processing based on the original flow field data; wherein, the image rendering end shares the common shader file, and the encoding function and the decoding function are inverse operations.
2. The system according to claim 1, characterized in that, The encoding module is specifically used for: The multi-channel data is obtained by mapping the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value based on the flow vector encoding function, the flow velocity encoding function, and the water area type weight value in the encoding function.
3. The system according to claim 2, characterized in that, The stream vector encoding function includes preset coefficients and preset biases, and the encoding module is specifically used for: Calculate the first product value of the first component in the two-dimensional flow vector and the preset coefficient, and determine the sum of the first product value and the preset bias as the first channel data; Calculate the second product value of the second component in the two-dimensional flow vector and the preset coefficient, and determine the sum of the second product value and the preset bias as the second channel data.
4. The system according to claim 1 or 2, characterized in that, The encoding module is specifically used for: The flow velocity scalar value is normalized by division based on the preset maximum flow velocity value, and the flow velocity scalar value is mapped to a preset interval to obtain the third channel data. The water area type weight value is subjected to amplitude limiting processing based on a preset interval truncation function, and the water area type weight value is mapped to a preset interval to obtain the fourth channel data.
5. The system according to claim 1, characterized in that, The encoding module is specifically used for: The mapping process is performed based on a pre-configured encoding function header file, wherein the encoding function header file contains inline functions that are logically consistent with the common shader file, so that the encoding result at the data generation end is semantically consistent with the decoding result at the image rendering end.
6. The system according to claim 1, characterized in that, The decoding module is specifically used for: The flow vector decoding function, flow velocity decoding function, and water area type weight decoding function based on the aforementioned decoding function are used to decode the multi-channel data in the target pixel data to obtain the original flow field data.
7. The system according to claim 1, characterized in that, The intermediate grid texture uses a 16-bit half-precision floating-point texture format.
8. A unified encoding, decoding, and coloring method for water area information, characterized in that, The method includes: Obtain the raw flow field data and common shader file of the target water area. The raw flow field data includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. The common shader file includes at least an encoding function and a decoding function. Based on the encoding function, each component in the two-dimensional flow vector, the flow velocity scalar value, and the water area type weight value are mapped to obtain multi-channel data. The data from each channel are then merged to obtain an intermediate raster texture. Spatial sampling is performed on the intermediate grid texture to obtain the corresponding target pixel data; The target pixel data is decoded and calculated based on the decoding function to restore the original flow field data, which includes at least a two-dimensional flow vector, a flow velocity scalar value, and a water area type weight value. Water area rendering is then performed based on the original flow field data. The image rendering end that performs the decoding calculation shares the common shader file, and the encoding function and the decoding function are inverse operations.
9. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method of claim 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in claim 8.
