A fluid rendering z-clip system, method and storage medium based on mathematical sign distance field and pose correction

By using a fluid rendering interleaving and culling method based on mathematical symbolic distance field and dynamic attitude correction, the problem of visual anomalies caused by fluid rendering entering the interior of rigid bodies is solved, achieving efficient rendering effects with low overhead, decoupled viewpoint and deformation adaptation.

CN122289496APending Publication Date: 2026-06-26SHANGHAI YINSHENG INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI YINSHENG INFORMATION TECH CO LTD
Filing Date
2026-05-29
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing technologies, when fluid rendering is interspersed within rigid bodies in 3D virtual scenes, visual anomalies occur. This results in high computational overhead, deep coupling of viewpoint and state, incompatibility with deformation animations, and poor mobile adaptation.

Method used

A fluid rendering interleaving culling method based on mathematical symbolic distance field and dynamic attitude correction is adopted. By acquiring the real-time attitude data of the target object, the local protection space boundary is dynamically corrected in the fragment shader. The composite symbolic distance field value is calculated using mathematical analytical formula to determine whether the fluid pixel is located inside the protection space and to perform rendering culling.

Benefits of technology

Completely decouples from camera viewpoint, immune to mesh deformation, with extremely low computational overhead, suitable for mobile devices, improves rendering quality and efficiency, and avoids visual flicker and erroneous culling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289496A_ABST
    Figure CN122289496A_ABST
Patent Text Reader

Abstract

This invention discloses a fluid rendering interleaving culling system, method, and storage medium based on mathematical symbolic distance field and pose correction. The method acquires real-time spatial pose data of target objects in a virtual scene; during the fragment shader stage, the boundary of the local protected space is dynamically corrected based on the pose data to determine the relative position of the fluid pixels to be rendered; the composite symbolic distance field value of the fluid pixels within the local protected space is calculated based on a preset mathematical analytical formula, this value being a combination of the distance attenuation value of the basic geometry and the directional truncation value of at least one clipping plane; based on the composite symbolic distance field value, it is determined whether the fluid pixel falls inside the protected space; if so, rendering culling or zeroing the opacity is performed. This invention completely decouples the camera's viewpoint state, is completely immune to mesh topology deformation interference from target objects, achieves high-precision fitting of irregularly shaped spaces while having extremely low computational overhead, and is suitable for real-time rendering requirements on mobile devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer graphics and game development technology, specifically to a fluid rendering interleaving culling system, method, and storage medium based on mathematical symbolic distance field and pose correction. Background Technology

[0002] In existing 3D virtual scene development (such as 3D games and virtual reality), when movable rigid bodies or vehicles with internal spaces (such as underwater vehicles, ships, mechs, etc.) traverse fluid media (such as water surfaces, fog, dust, etc.), the rendered surface of the fluid often intersects into the internal space of the rigid body (for example, a horizontal surface being rendered into the cockpit of an underwater vehicle), severely disrupting the visual immersion. To address this visual anomaly caused by object intersecting, existing industry solutions suffer from the following main drawbacks:

[0003] Mesh Boolean operations and physical slicing: The intersection of the fluid mesh and the carriage mesh is calculated in real time by the CPU and the mesh is regenerated. This method has extremely high computational overhead, severely drags down the frame rate, and is completely unsuitable for mobile devices with extremely high real-time requirements or limited computing power.

[0004] Screen-space-based stencil buffering: Utilizing multi-channel rendering, the carriage mask is first written to the stencil buffer, and then stencil testing and culling are performed during fluid rendering. This technique is highly dependent on the camera's spatial position. When the camera's viewpoint is inside the carriage and the external water surface is above, the system is prone to incorrectly culling the water surface that should be displayed correctly through the windows because the screen space is covered by the interior mesh mask. Furthermore, the client needs to write complex state machines to switch between stencil test conditions, resulting in a high degree of coupling between the rendering logic and the client's business logic.

[0005] Mesh distance field technology: Spatial voxel distance field data of the model surface is pre-computed or generated in real time for culling, which is highly dependent on static mesh topology. When the vehicle undergoes skeletal skinning animation or vertex deformation, it is necessary to re-voxelize and generate distance field data every frame on the CPU or GPU, resulting in serious computational latency and consuming a large amount of 3D texture memory bandwidth, which is difficult to bear on mobile devices.

[0006] Therefore, there is an urgent need for a fluid rendering interleaving culling method that can completely decouple the camera viewpoint, is immune to the effects of mesh deformation, and has extremely low computational overhead. Summary of the Invention

[0007] This invention aims to provide a fluid rendering interleaving culling method based on mathematical symbol distance field and dynamic posture correction, in order to solve the problems of high computational overhead, deep coupling of view state, incompatibility with deformation animation, and poor mobile adaptation in the prior art.

[0008] To achieve the above objectives, the present invention adopts the following technical solution:

[0009] A fluid rendering interleaving culling method based on mathematical symbolic distance field and pose correction includes acquiring the real-time pose of the target object, dynamically correcting the local guard space boundary in the fragment shader, calculating the composite symbolic distance field value based on mathematical analytical formulas, and determining and culling fluid pixels falling inside the guard space based on the value. This method completely decouples the culling logic from the camera viewpoint and is completely independent of mesh topology data.

[0010] This application provides a fluid rendering culling method, the core steps of which include: acquiring real-time spatial pose data of a target object in a virtual scene; dynamically correcting the boundary of the local protected space of the target object based on the pose data during the fragment shader stage to determine the relative position parameters of the fluid pixel relative to the local protected space; calculating the composite symbolic distance field value of the fluid pixel within the local protected space based on a preset mathematical analytical formula (this value is obtained by combining the distance attenuation value of the basic geometry with the directional truncation value of at least one clipping plane); determining whether the fluid pixel is located inside the local protected space based on the comparison result of the composite symbolic distance field value and a preset threshold, and if so, performing rendering culling or setting the opacity to zero.

[0011] First, the CPU or game engine logic layer passes the target object's current rotation matrix, position, and other pose data as constants (uniform) to the GPU's fragment shader. In the shader, for each fluid pixel to be rendered, based on the target object's pose data, the protection space boundary (e.g., a space defined by the sphere's center coordinates and the clipping plane normal) originally defined in the local coordinate system is rotated to align with the world coordinates or the fluid pixel's coordinate space. Then, the signed distance of the pixel from the protection space boundary is calculated using independent mathematical instructions (dot product, square root, signed function, etc.). Finally, if the distance value is less than or equal to 0 (i.e., the pixel falls inside the protection space), the fragment shader executes a discard instruction or forces the alpha channel to be set to 0, thereby terminating the rendering of that pixel. Because this determination is entirely based on the spatial coordinate field and does not rely on the screen-space stencil buffer, the culling result is unique and correct regardless of whether the virtual camera is inside or outside the target object.

[0012] Through the above-described technical solution, this invention solves the problem of erroneous culling caused by changes in camera viewpoint in existing template buffering technologies, while avoiding complex mesh Boolean operations on the CPU. By constructing the protection space using pure mathematical analytical expressions, it completely eliminates the dependence on sampling of mesh distance field textures, ensuring that the rendering overhead involves only a very small number of basic mathematical operations, allowing for efficient concurrent execution on mobile GPUs.

[0013] In some embodiments, the real-time spatial attitude data includes complete attitude information in the form of a rotation matrix or quaternion, or at least one or more of pitch, yaw, and roll angles; the boundary of the local protected space rotates or translates synchronously with the attitude data.

[0014] For dynamic vehicles with six degrees of freedom (such as submersibles that can pitch and roll in three-dimensional space), providing only a single pitch angle is insufficient to align the protected space with the vehicle's true orientation. By passing in a complete rotation matrix (or quaternion), the normal vector of the clipping plane or the coordinates of the fluid pixels can be transformed to a uniform attitude in the shader in one step. For example, multiplying the "up" direction (0,1,0) defined in the local coordinate system by the rotation matrix yields the actual top orientation of the vehicle in the world coordinate system, ensuring that the top plane of the protected space is always rigidly connected to the roof. If the target object only performs two-dimensional planar motion (such as land vehicles that do not involve roll), then passing in the pitch and yaw angles is sufficient.

[0015] This limitation enables the invention to adapt to target objects with different degrees of freedom of motion requirements, from simple single-axis rotation to complex omnidirectional postures, thus expanding the applicability of the method. At the same time, it allows developers to choose to transmit the fewest angle parameters according to actual performance requirements, balancing flexibility and efficiency.

[0016] In some embodiments, the technical solution of this application further defines two equivalent methods for “dynamically correcting the local protective space boundary”: rotating the normal direction vector of the clipping plane according to real-time spatial pose data, or performing an inverse matrix transformation on the world coordinates of the fluid pixel; and clarifies that the two methods are mathematically equivalent and can be implemented according to the coordinate space convention of the graphics rendering engine.

[0017] Method 1 (Rotated Normals): Keeping the fluid pixel coordinates unchanged in the world coordinate system, the predefined clipping plane normals in the local protected space (e.g., the normal to the top clipping plane is (0,1,0) in the local space) are transformed to the world coordinate system using an attitude rotation matrix, and then the dot product is calculated. Method 2 (Inverse Coordinate Transformation): Keeping the clipping plane normals defined unchanged in the local coordinate system, the world coordinates of the fluid pixels are transformed to the local coordinate system of the target object using an inverse attitude matrix, and then the range field is directly calculated in the local space. The composite symbolic range field values ​​calculated by both methods are exactly the same.

[0018] This step, located between obtaining fluid pixel coordinates and calculating the projection offset distance, is a crucial step in coordinate unification. Method 1 is typically suitable for scenarios with a small number of clipping planes and negligible normal rotation overhead; Method 2 is suitable for scenarios where spatial parameters (such as sphere center coordinates and plane offsets) are fixed in local space and frequent rotations of a large number of fluid pixel coordinates are required. Developers can choose the method that best suits the engine's shader compiler optimization features.

[0019] In some embodiments, the technical solution of this application discloses specific calculation steps for the composite symbolic distance field value: First, calculate the Euclidean distance from the fluid pixel coordinates to the center point of the basic geometry (such as a sphere), and obtain the attenuation value of the basic geometry by combining the radius parameter and the edge hardness parameter; then calculate the dot product of the direction vector from the center point to the fluid pixel and the normalized clipping plane normal to obtain the projected offset distance, and then perform difference and sign function operations on this distance and the preset plane offset to generate a directional truncation value; finally, perform multiplication or intersection operations on the basic geometry attenuation value and the directional truncation value to merge them and output the composite symbolic distance field value.

[0020] Taking a spherical base geometry as an example, the formula for calculating the attenuation value of the base geometry is saturate((Radius-Dist) / max(Radius*(1-Hardness),epsilon)), where Dist is the Euclidean distance, and the Hardness parameter controls the gradient bandwidth between complete preservation and complete removal. When Hardness=0, a hard boundary is generated; when Hardness>0, a hard boundary is generated. Figure 2 The edge transition effect is shown. For directional cutoff values, the projected offset distance P_offset is obtained through dot product. For example, for top clipping: MaskTop=saturate(sign(TopOffset-P_offset)), which means that if P_offset>TopOffset, the sampling point is outside the top plane, and 0 is returned; otherwise, 1 is returned. Multiply SphereResult by MaskTop and MaskBottom. Only when all factors are positive, Result>0, and the pixel is determined to fall inside the protection space.

[0021] The center point of the basic geometry is typically set at the geometric center of the target object's internal space (e.g., the center of the cockpit), and its radius should be large enough to completely enclose the internal space. The normal vector of the clipping plane points outwards from the object (e.g., the normal of the top clipping plane points upwards), and the plane offset defines the signed distance from the center point to the plane.

[0022] By multiplying and fusing spherical attenuation with planar truncation, this invention can construct a rounded polyhedral-shaped protective space with minimal mathematical operations, combining the smooth sides of a sphere with the flat bottom / top of a plane, perfectly fitting the internal space of a vehicle (e.g., Figure 3 (As shown). The edge hardness parameter allows for semi-transparent blending of culling boundaries, avoiding visually harsh cuts and significantly improving rendering quality.

[0023] In some embodiments, the technical solution of this application further defines the cutting plane as a set of multiple cutting planes with different normal direction vectors and different plane offsets; when generating directional truncation values, the relationship between the projection offset distance of the fluid pixel on each cutting plane and the corresponding offset is calculated, and multiple truncation results are combined by continuous intersection operation or minimum value operation to fit a polyhedral protection boundary that matches the irregular space inside the target object.

[0024] For scenarios requiring the fitting of a cubic or hexahedral space (e.g., the cockpit of a submersible is approximately cuboid), six clipping planes can be defined. Each plane corresponds to a normal direction (±X, ±Y, ±Z) and an offset (corresponding to the left / right, front / back, and top / bottom boundaries, respectively). For each plane, the cutoff value Mask_i (value 0 or a smooth value) in that direction is calculated. Then, the minimum value of all Mask_i values ​​is taken (equivalent to a logical AND operation) to obtain the final clipping result. This invention does not limit the number of planes, nor does it require that the planes be pairwise orthogonal; therefore, it can simulate protective spaces of arbitrary convex polyhedral shapes.

[0025] This step occurs after calculating the cutoff value in a single direction. After traversing all planes, the multiple Mask_i values ​​obtained are merged and then multiplied by the base geometry attenuation value.

[0026] By introducing multi-plane combinations, this invention extends the ability to express protected space from a simple “sphere truncated” to any convex polyhedron, which can accurately match the irregular internal space of various vehicles (such as those with tilted windshields, asymmetric cabins, etc.), while still maintaining the high efficiency of pure mathematical analytical calculations without having to switch to complex mesh-based detection.

[0027] In some embodiments, the technical solution of this application defines the preset mathematical analytical formula of the local protection space as independent of the mesh topology data and vertex deformation animation data of the target object; and the calculation of the composite symbol distance field value and the rendering culling operation are both completed in the fragment shader through independent mathematical instructions, without the need to sample or generate mesh distance field texture data.

[0028] Unlike traditional MeshDistanceField technology, the protection space definition in this invention is completely independent of the target object's triangular mesh. Even if the target object's mesh undergoes drastic deformation every frame (e.g., vehicle collision deformation, door opening and closing, soft-bodied fish fin movement), the protection space is directly defined by parameters such as sphere center coordinates, radius, plane normal, and offset. These parameters can be updated independently of the mesh during animation (e.g., using skeletal animation to drive the center of the protection space to move with the cockpit), but the shape of the protection space itself does not need to be re-voxelized or regenerated. All decision calculations are performed in the fragment shader using basic ALU instructions such as addition, multiplication, dot product, and comparison, without involving texture sampling instructions.

[0029] This method is completely decoupled from the rendering pipeline of the target object. The fluid material shader only reads the protected space parameters from the constant buffer and does not need to access the vertex buffer or index buffer of the target object.

[0030] It completely eliminates the impact of mesh deformation on the anti-interference effect, while avoiding the huge memory bandwidth and computational overhead of regenerating 3D textures every frame using mesh distance field technology. This makes the invention particularly suitable for the resource-constrained environment of mobile GPUs and supports vehicles with high dynamic deformation (such as ragdoll physics and skinning animation).

[0031] In some embodiments, the technical solution of this application specifically defines the target object as a moving rigid body or vehicle with an internal space, and the fluid as a water surface, fog or sand particle material; and emphasizes that the rendering culling operation is not affected by the viewpoint position of the virtual camera located inside or outside the target object.

[0032] The culling determination of this invention is based solely on the relationship between the absolute coordinates of the fluid pixels in world space and the position of the protected space. This relationship does not change with the orientation or position of the camera. For example, when the camera enters the vehicle and looks out the window, the water surface pixels outside the window are still outside the protected space (because the window opening is not part of the protected space), and therefore will be rendered normally; while the air pixels inside the vehicle are inside the protected space and will be culled. In contrast, stencil buffering technology, because the mesh mask inside the vehicle fills the entire screen space, can cause the water surface outside the window to be incorrectly culled as well. This invention avoids this dilemma from a mathematical perspective.

[0033] Game developers no longer need to write complex rendering state switching code for the camera to move inside and outside the vehicle, which simplifies the client logic and completely eliminates visual flickering or erroneous culling caused by changes in perspective, significantly improving the user experience.

[0034] In some embodiments, the technical solution of this application specifies that the directional cutoff value is calculated using a smooth step function, so that a smooth transition effect associated with a preset edge hardness parameter is formed at the boundary of the cutting plane (e.g., Figure 2 (the outer gradient black region in the text), the smooth step function includes a smoothstep or a linear interpolation deformation formula based on saturate.

[0035] To avoid jagged edges or visual breaks caused by hard boundaries, this invention replaces the sign function with a function that has a smooth gradient. For example, it uses smoothstep(edge0, edge1, x) from HLSL, where edge0 = TopOffset - fadeWidth, edge1 = TopOffset + fadeWidth, and fadeWidth is inversely proportional to the edge hardness parameter. When x approaches TopOffset, MaskTop smoothly transitions from 1 to 0, rather than abruptly. Similarly, bottom clipping can use a 1-smoothstep form. This smooth transition makes the fluid pixels at the boundary of the protective space appear in a semi-transparent blended state, visually creating a... Figure 2 The gradient black border shown eliminates any abruptness.

[0036] By adding optional smooth boundary control, this invention allows the culling edges of the protected space to blend naturally with the surrounding fluids rather than being abruptly cut off. This is particularly suitable for fluid materials with inherently translucent properties, such as fog and dust, greatly enhancing the realism of the image. Furthermore, since the smooth step function requires only a few additional instructions on the GPU, the performance loss is negligible.

[0037] This embodiment provides a fluid rendering culling system, including: a pose acquisition module for acquiring real-time spatial pose data of target objects in a virtual scene; a shader calculation module, running in the graphics processing unit, for dynamically correcting the boundary of the local protection space based on the real-time spatial pose data during the fragment shader stage, and calculating the composite symbolic distance field value of the fluid pixel to be rendered based on a preset mathematical analytical formula; and a culling execution module for determining whether the fluid pixel is located inside the local protection space based on the composite symbolic distance field value, and performing a discard or zero-opaqueness operation when it is determined to be inside.

[0038] The pose acquisition module resides in the CPU or game engine logic layer. Each frame, it reads the rotational position data of the target object through the Transform component and packages it into a constant buffer before passing it to the GPU. The shader computation module resides in the fragment shader stage of the rendering pipeline. It receives fluid pixel coordinates interpolated from the vertex shader and reads pose data and guard space parameters (sphere center, radius, plane normal, offset, etc.) from the constant buffer, calculating the composite SDF value. The culling execution module is the final step of the shader computation module, performing discard or alpha write based on the calculation results. The three modules are connected in series in a data stream manner: the output of the pose acquisition module is one of the inputs to the shader computation module, and the output of the shader computation module is directly used by the culling execution module for judgment.

[0039] This system achieves a complete technical solution with minimal module division. Each module has a clear responsibility, making it easy to port to different graphics engines (such as Unity's Shader and Unreal's material system), and it can seamlessly cooperate with other rendering optimization technologies (such as Early-Z).

[0040] A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to perform the steps of the method.

[0041] Working principle: The storage medium can be a non-volatile medium such as flash memory, ROM, RAM, hard disk, or optical disc. When the program is read and loaded into the GPU or CPU for execution, it will process the fluid rendering of each frame in real time according to the aforementioned steps to achieve anti-interference effect.

[0042] The beneficial effects that the fluid rendering interleaving culling method based on mathematical symbolic distance field and pose correction disclosed in this application may bring include, but are not limited to:

[0043] 1. Completely decouple the camera's viewpoint state to eliminate viewpoint-related false rejections.

[0044] This invention calculates the composite symbolic distance field value of fluid pixels using a purely mathematical analytical formula in the fragment shader. It determines whether a pixel is inside a target object based on this value, rather than relying on the stencil buffer in screen space or pixel occlusion relationships. Therefore, regardless of whether the virtual camera is inside or outside the target object, the culling result is unique and correct. For example, when the camera is inside the vehicle's cockpit looking outwards, fluid pixels outside the window are rendered normally because they are outside the protected space, avoiding the erroneous culling of water surface pixels caused by the screen space being covered by the vehicle's mesh mask, as seen in existing stencil buffer techniques. Furthermore, this invention eliminates the need to write complex rendering state switching code for the camera moving inside and outside objects, completely decoupling the rendering logic from the client's viewpoint.

[0045] II. Completely immune to mesh topology deformation, compatible with dynamic vertex animation.

[0046] The protective space of this invention is constructed using a purely mathematical analytical formula (a combination of basic geometry and at least one clipping plane), and its definition is completely independent of the target object's mesh topology and vertex deformation animation data. The calculation of the entire composite symbolic distance field value and the rendering culling operation are all completed within the fragment shader through independent mathematical instructions, without the need to sample or generate mesh distance field texture data, nor to calculate the Boolean intersection of the fluid mesh and the object mesh in real time. Therefore, even if the target object undergoes arbitrary vertex deformations such as skeletal skinning animation, door opening and closing, or tire compression, the boundary shape and culling effect of the protective space remain stable and unaffected by any interference.

[0047] III. Extremely low computing power consumption and excellent mobile device compatibility

[0048] This invention eliminates expensive physical mesh intersection operations, complex CPU-side Boolean slicing, and large-capacity voxel distance field texture sampling. The entire culling process involves only basic mathematical instructions such as addition, multiplication, dot product, square root, and sign functions (or smooth step functions), and runs entirely concurrently within the GPU fragment shader. It does not rely on viewpoint state switching in client-side CPU logic code, nor does it require real-time generation or sampling of mesh distance field data. Compared to mesh distance field (MDF) technology, this invention avoids re-voxelization every frame and the memory bandwidth consumption of large-capacity 3D textures, achieving extremely low frame-by-frame rendering time and negligible memory usage on mobile GPUs, perfectly suited to the real-time rendering needs of mobile devices.

[0049] IV. High-precision irregular space fitting and edge-controllable visual quality

[0050] By multiplying or intersecting the distance attenuation value of a basic geometry (such as a sphere) with the directional truncation values ​​of multiple clipping planes, this invention can construct a rounded polyhedron-like irregular protective space analytically, accurately fitting the shape of a vehicle cockpit with internal space. As the number of clipping planes increases, it can fit the boundary of any convex polyhedron. Simultaneously, by introducing an edge hardness parameter and an optional smooth step function, the protective space boundary can form a continuously gradient, soft transition region, avoiding visual breaks or jagged edges caused by hard edge culling, significantly improving the realism of the rendering. Attached Figure Description

[0051] Figure 1The schematic diagram of the composite SDF spatial geometric parameters and clipping logic provided in the embodiment of the present invention shows the process of the basic spherical space being clipped by the top and bottom planes. The white area is the masked area that is retained, Normal is the normal vector of the clipping plane, d1 is the cutoff height / offset of the top clipping plane, and d2 is the cutoff height / offset of the bottom clipping plane.

[0052] Figure 2 The SDF protection volume edge transition effect diagram provided for the embodiment of the present invention shows the effect of... Figure 1 The final solid spatial boundary generated after parameter composite calculation has a gradient black area on its outermost side, which represents the range of smooth spatial transitions calculated by shader internal parameters (such as edge hardness and its smoothing function).

[0053] Figure 3 The schematic diagram of SDF protection space fitting and attitude alignment with target vehicle space provided in the embodiments of the present invention shows how the pure mathematical SDF protection space (white semi-transparent geometry) is precisely fitted with the internal cockpit shape of the target vehicle (cyan vehicle body mesh) in world space, and shows the attitude correction effect of the protection space tilting synchronously with the vehicle pitch angle. Detailed Implementation

[0054] Various exemplary embodiments, features, and aspects of this application will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.

[0055] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, an indirect connection through an intermediate medium, or the internal communication between two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0056] Example 1

[0057] This embodiment provides a fluid rendering interleaving culling method based on mathematical symbolic distance field and dynamic attitude correction. Preferably, all culling logic of this method is deployed and executed in the fluid material fragment shader of the graphics rendering engine (such as Unity, Unreal Engine, or a self-developed engine).

[0058] Combination Figure 1 (Parameter definition) Figure 2 (Hardness edge transition) and Figure 3 (Target vehicle space fitting), the specific execution steps and mathematical logic for calculating whether the fluid pixels to be rendered are culled in this embodiment are as follows:

[0059] 1. Spatial attitude synchronization and normal correction

[0060] When the target vehicle (such as Figure 3 As the cyan submersible moves within the scene, its pitch and other attitude data change in real time. Before each frame is rendered, the vehicle's current attitude matrix or angle parameters are passed as constants to the fluid material's shader.

[0061] Based on this pose data, the shader calculates or corrects the normal vector representing the clipping plane in real time (e.g., Figure 1 The Normal vector in the underlying logic is denoted as ClipNormal. For example, when the vehicle's tilt angle is 20°, the ClipNormal is also rotated 20° in the world or local coordinate system to ensure that the subsequently generated protection space is absolutely aligned with the vehicle body.

[0062] 2. Calculation of attenuation in the basic spherical space

[0063] Let the spatial coordinates of the fluid pixel currently being processed by the shader be A (sampling point), and the coordinates of the preset guard space center point be B (e.g., ...). Figure 1 (The center of the ball).

[0064] First, calculate the Euclidean distance Dist from sampling point A to center point B:

[0065]

[0066] Introducing the preset sphere radius parameter Radius (corresponding to) Figure 1 The parameter r in the text refers to the edge hardness parameter. The edge hardness parameter controls the smooth transition area of ​​the culling boundary (e.g., r). Figure 2 The outermost black gradient area). The basic spherical attenuation mask value, SphereResult, is calculated using the following linear interpolation and truncation formula:

[0067]

[0068] Here, saturate is a function that restricts the result to the interval [0,1], and ε is a minimal constant to prevent overflow during division by zero.

[0069] 3. Calculation of multi-directional planar cutting

[0070] In order to "cut" the basic sphere into an irregularly shaped space resembling a train carriage (such as... Figure 1 and Figure 3 (As shown in the figure, a flat bottom shape is used), introducing directional clipping logic.

[0071] First, calculate the direction vector from center point B to sampling point A, and then perform a dot product (DotProduct) with the normalized clipping plane normal N (i.e., ClipNormal) to obtain the projection offset distance P_offset of the sampling point in the normal direction:

[0072] .

[0073] Step 3.1 Bottom cropping: Import the bottom offset parameter BottomOffset (corresponding to...) Figure 1 (d2). Retain the portion where the projected offset distance is greater than this negative offset. Determine and truncate using the sign function `sign` to obtain the bottom mask value `MaskBottom`:

[0074] .

[0075] Step 3.2 Top Clipping: Introduce the top offset parameter TopOffset (corresponding to...) Figure 1 (d1). Retain the portion whose projected offset distance is less than this positive offset. Similarly, obtain the top mask value MaskTop:

[0076]

[0077] Note: If P_offset > TopOffset, the sign function returns a negative number or 0. After being truncated by saturate, it becomes 0, indicating that the pixel is outside the top plane and should be discarded.

[0078] 4. Spatial compounding and elimination execution

[0079] Finally, the basic spherical mask, bottom mask, and top mask obtained in the above steps are combined by a logical AND (multiplication) to obtain the final composite mask determination value Result for the fluid pixel:

[0080]

[0081] This Result describes... Figure 1 The precise mathematical boundary of the white area in the middle.

[0082] In the final output stage of the fragment shader, the Result value is checked. When Result > 0 (or greater than a certain minimum threshold), it is determined that the fluid pixel has fallen into the protective space inside the vehicle. The shader will call a discard instruction (such as discard in HLSL) to terminate the rendering of the pixel, or force the alpha channel transparency of its output to 0.

[0083] Through the above pure mathematical calculations, this invention achieves a perfect rendering effect that prevents water leakage by utilizing very few GPU instruction cycles, without relying on any complex client-side mesh state determination or high physical collision overhead.

[0084] Example 2

[0085] This embodiment extends several aspects of Embodiment 1 described above to adapt to more complex application scenarios or achieve better visual quality. These extensions can be used individually or in combination with Embodiment 1.

[0086] (a) Acquisition of complete spatial attitude data

[0087] In Example 1, only the pitch angle was used to correct the clipping plane normals. For scenarios requiring simultaneous handling of yaw and roll (e.g., aircraft or omnidirectional vehicles), this implementation expands the attitude data into a complete rotation matrix or quaternion. In the fragment shader, this rotation matrix is ​​applied to the normal vectors of all clipping planes, or used for inverse transformation of fluid pixel coordinates, enabling the guard space boundary to follow any rotational attitude of the target object. This expansion does not change the distance field calculation formula in Example 1, only increasing the dimension of the attitude data.

[0088] (ii) Coordinate inverse transformation correction method

[0089] In addition to the "rotate clipping plane normal" method described in Example 1, this implementation provides another equivalent approach: transforming the world coordinates of the fluid pixels into the local coordinate system through the inverse transformation of the target object's pose matrix. In this case, the normals of the clipping plane remain at their initial definition in the local coordinate system (e.g., the top plane normal is always (0,1,0)), eliminating the need for rotation every frame. The two methods are mathematically equivalent, and developers can freely choose based on the coordinate space conventions of their graphics rendering engines. For example, in Unreal Engine, the rotate normal method is more convenient because the material system tends to operate in world space; while in a self-developed engine, if a large number of pixels need to be transformed, the inverse coordinate transformation method may be more efficient.

[0090] (III) Smooth step function replacing sign function

[0091] In Example 1, the cutting plane uses a sign function (sign) to generate hard boundaries. To obtain... Figure 2 The smooth transition effect shown (including the gradient at the clipping plane boundary) in this implementation uses a smooth step function (such as smoothstep in GLSL or smoothstep in HLSL) instead of the sign function. Specifically:

[0092] For top clipping (preserving the region where Poffset < TopOffset):

[0093] ;

[0094] For bottom clipping (preserving the region where Poffset > BottomOffset):

[0095] ; where f is the smoothing width, which can be associated with the edge hardness parameter Hardness (e.g., f = k×(1 - Hardness)). When f approaches 0, the above formula degenerates into the sign function in Embodiment 1, so this extension is downward compatible with the hard boundary implementation.

[0096] (IV) Extension of multiple clipping planes

[0097] In Embodiment 1, only the top and bottom two clipping planes are used. For scenarios that need to fit complex irregular internal spaces (such as vehicles with inclined windshields and asymmetric cabins), this embodiment extends the number of clipping planes to multiple (such as left, right, front, back, etc.). Each clipping plane has an independent normal direction vector and offset. When calculating the directional truncation value, the relationship between the projection offset distance of the fluid pixel on each clipping plane and the corresponding offset is calculated respectively, and multiple truncation results are combined through continuous intersection operations (taking the minimum value or multiplication):

[0098] ;

[0099] Or

[0100] .

[0101] Then multiply PlanesResult by the base spherical attenuation value SphereResult to obtain the final composite SDF value. This extension enables the protected space to accurately fit any convex polyhedron shape.

[0102] This embodiment provides a fluid rendering occlusion culling system, including:<00,00241>

[0103] Pose acquisition module: used to acquire the real-time spatial pose data (including rotation matrix and position) of the target object in the virtual scene. This module runs on the CPU side and packs the pose data into a constant buffer and transfers it to the GPU every frame.

[0104] Shader Calculation Module: Running in the fragment shader stage of the graphics processing unit (GPU), it is used to dynamically correct the boundary of the local protected space based on the data passed in by the pose acquisition module (using any one of the above embodiment 1 or extended method), and calculate the composite symbol distance field value of the fluid pixel to be rendered (composed of basic geometry and at least one clipping plane) based on a preset mathematical analytical formula.

[0105] The culling execution module is integrated at the end of the shader calculation module. It is used to determine whether a pixel is located inside the local protection space based on the composite symbol distance field value, and to discard or set the transparency to zero for the fluid pixel when it is determined to be inside.

[0106] The output of the pose acquisition module serves as the input constant for the shader calculation module; the shader calculation module independently calculates the composite SDF value for each fluid pixel and inputs the result into the culling execution module; the culling execution module determines whether to discard the pixel based on this value.

[0107] In some embodiments, this implementation provides a computer-readable storage medium on which a computer program is stored. When executed by a processor (including a CPU and a GPU), the program implements the method steps of the basic embodiment or any extended embodiment described above. The storage medium includes, but is not limited to, non-volatile media such as ROM, RAM, flash memory, hard disk, and optical disk.

[0108] The above embodiments illustrate in detail the specific implementation of the technical solution of the present invention, the logical and connection relationships of each component, and the complete working process. Those skilled in the art will understand that various changes and modifications can be made to the above embodiments without departing from the principles and spirit of the present invention, and all such changes and modifications should fall within the protection scope of the appended claims.

Claims

1. A fluid rendering interleaving culling method based on mathematical symbolic distance field and attitude correction, characterized in that, Includes the following steps: Acquire real-time spatial pose data of target objects in a virtual scene; In the fragment shader stage of the graphics rendering pipeline, the spatial coordinates of the fluid pixel to be rendered are obtained, and the boundary of the local protective space of the target object is dynamically corrected according to the real-time spatial pose data, so as to determine the relative position parameters of the fluid pixel with respect to the local protective space. Based on a preset mathematical analytical formula, the composite symbol distance field value of the fluid pixel in the local protection space is calculated, wherein the composite symbol distance field value is calculated by combining the distance attenuation value of the basic geometry with the directional truncation value of at least one cutting plane. Based on the comparison result between the composite symbol distance field value and the preset threshold, it is determined whether the fluid pixel is located inside the local protection space. If so, rendering culling or zeroing of the transparency is performed on the fluid pixel.

2. The method according to claim 1, characterized in that, The real-time spatial attitude data includes complete attitude information in the form of a rotation matrix or quaternion, or at least one or more of pitch angle, yaw angle, and roll angle; the boundary of the local protected space rotates or translates synchronously with the attitude data.

3. The method according to claim 1, characterized in that, The "dynamic correction of the boundary of the local protection space" includes: rotating the normal direction vector of the clipping plane according to the real-time spatial pose data, or performing an inverse matrix transformation on the world coordinates of the fluid pixel, so that the mathematical boundary of the local protection space remains relatively static and aligned with the real-time physical pose of the target object; wherein, the rotation and the inverse transformation are mathematically equivalent and can be implemented according to the coordinate space convention of the graphics rendering engine.

4. The method according to claim 1, characterized in that, The calculation of the composite symbol distance field specifically includes: Calculate the Euclidean distance from the coordinates of the fluid pixel to the center point of the basic geometry, and calculate the attenuation value of the basic geometry based on the preset radius parameter and edge hardness parameter; Calculate the direction vector from the center point to the fluid pixel, and multiply it by the normalized normal direction vector of the clipping plane to obtain the projection offset distance. Then, perform difference and sign function operations on the projection offset distance and the preset plane offset to generate the directional truncation value. The composite symbol distance field value is output by multiplying or intersecting the basic geometric attenuation value with the directional truncation value.

5. The method according to claim 4, characterized in that, The at least one clipping plane includes multiple sets of clipping planes with different normal direction vectors and different plane offsets; when generating the directional truncation value, the relationship between the projection offset distance of the fluid pixel on each clipping plane and the corresponding offset is calculated, and multiple truncation results are combined by continuous intersection operation or minimum value operation to fit a polyhedral protection boundary that matches the irregular space inside the target object.

6. The method according to claim 1, characterized in that, The preset mathematical expression of the local protected space is independent of the mesh topology data and vertex deformation animation data of the target object; the calculation of the composite symbol distance field value and the rendering culling operation are both completed in the fragment shader through independent mathematical instructions, without the need to sample or generate mesh distance field texture data.

7. The method according to claim 1, characterized in that, The target object is a moving rigid body or vehicle with an internal space, and the fluid includes water surface, fog or sand particles; the rendering culling operation is not affected by the viewpoint position of the virtual camera inside or outside the target object.

8. The method according to claim 1, characterized in that, The directional cutoff value is calculated using a smooth step function, which creates a smooth transition effect at the boundary of the cutting plane that is associated with a preset edge hardness parameter. The smooth step function includes smoothstep or a linear interpolation deformation formula based on saturate.

9. A fluid rendering interleaving culling system, characterized in that, include: Pose acquisition module: used to acquire real-time spatial pose data of target objects in a virtual scene; Shader calculation module: running in the graphics processing unit, used to dynamically correct the boundary of the local protection space according to the real-time spatial pose data during the fragment shader stage, and calculate the composite symbol distance field value of the fluid pixel to be rendered based on the preset mathematical analytical formula. The composite symbol distance field value is obtained by combining the distance field of the basic geometry and at least one clipping plane. The rejection execution module is used to determine whether the fluid pixel is located inside the local protection space based on the distance field value of the composite symbol, and to discard or set the transparency to zero for the fluid pixel when it is determined to be inside.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method steps of any one of claims 1 to 8.