War fog rendering method, device, medium and product

By sampling the color values ​​of the fog of war texture in the shader and executing differential rendering logic, the problem of game objects appearing or hiding in the fog of war is solved, achieving natural edge transitions and improved visual performance.

CN120884892BActive Publication Date: 2026-05-19SHANGHAI AOMENGNI TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI AOMENGNI TECHNOLOGY CO LTD
Filing Date
2025-07-18
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

The appearance or hiding of game objects in the fog of war is rather abrupt, resulting in poor rendering.

Method used

The shader takes the fog of war texture and the texture coordinates of the current fragment as input, obtains the color value through sampling, and executes differentiated rendering logic based on the type and color value of the rendered object, including the processing of non-transparent and transparent objects, to achieve progressive transitions and dynamic transparency changes.

Benefits of technology

It achieves a natural edge transition effect for the fog of war, enhancing the immersion and visual expressiveness of the game scene, and solving the problem of the disconnect between logic and presentation in traditional solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120884892B_ABST
    Figure CN120884892B_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the technical field of computer, and disclose a war fog rendering method, device, medium and product. The method comprises the following steps: inputting a war fog texture and a texture coordinate of a current segment in a shader; sampling the war fog texture according to the texture coordinate to determine a color value of a target pixel; and executing different rendering logics according to a type of a rendering object and the color value to generate a war fog, wherein the type of the rendering object comprises a non-transparent object or a transparent object. At least the technical problem that the display or hiding effect of a game object in a war fog is relatively rough and the rendering effect is poor in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, device, medium, and product for rendering fog of war. Background Technology

[0002] In gaming, the fog of war is a common mechanic used to limit a player's field of vision, simulating the uncertainty of intelligence on a real battlefield. The fog of war obscures areas that a player has not yet explored or are outside their current field of vision, making these areas appear as unexplored darkness or a semi-transparent, blurry effect on the map. Areas obscured by the fog of war do not reveal enemy units, buildings, or their special effects, thus increasing the game's strategic depth and exploration. Players must use unit movement, scouting abilities, or vision-enhancing items to dispel the fog of war and gradually reveal map information. This mechanic is widely used in real-time strategy, multiplayer online battle arena, and large-scale strategy games, enhancing the game's tactical depth while preventing players from gaining an unfair advantage by having full map information.

[0003] In traditional fog of war implementations, a fog map is typically generated on the CPU or GPU first. This fog map uses different grayscale values ​​to mark the visibility of various areas of the map. When rendering game objects such as characters, units, or effects, it is first determined whether the game object's location is within the "visible area" of the fog map before deciding whether to display the game object.

[0004] However, the inventors discovered at least the following technical problems in the related technology: the effect of displaying or hiding game objects in the fog of war is rather abrupt and the rendering effect is poor. Summary of the Invention

[0005] One objective of this application is to provide a method, device, medium, and product for rendering fog of war, at least to solve the technical problem in the related art where the display or hiding effect of game objects in fog of war is rather abrupt and the rendering effect is poor.

[0006] To achieve the above objectives, some embodiments of this application provide the following aspects:

[0007] In a first aspect, some embodiments of this application also provide a method for rendering fog of war. The method includes: inputting a fog of war texture and texture coordinates of a current fragment into a shader; sampling the fog of war texture according to the texture coordinates to determine the color value of a target pixel; and executing different rendering logic according to the type of the rendering object and the color value to generate fog of war; the type of the rendering object includes non-transparent objects or transparent objects.

[0008] Secondly, some embodiments of this application also provide an electronic device, the electronic device comprising: one or more processors; and a memory storing computer program instructions, which, when executed, cause the processor to perform the steps of the method described above.

[0009] Thirdly, some embodiments of this application also provide a computer-readable medium having computer program instructions stored thereon, which can be executed by a processor to implement the method described above.

[0010] Fourthly, some embodiments of this application also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the method described above.

[0011] Compared with related technologies, the solution provided in this application provides basic data for subsequent processing by inputting the fog of war texture and the texture coordinates of the current fragment into the shader; sampling the fog of war map based on the texture coordinates to obtain color values ​​ensures the reliability of the rendering judgment basis. Furthermore, because differentiated rendering logic is executed according to the type of the rendered object (non-transparent or transparent) and the color value, for non-transparent objects, pixel visibility can be controlled by calculating the relationship between the color value and a threshold, achieving a gradual transition from fully visible to completely hidden; for transparent objects, the color value can be used as a transparency modulation coefficient, allowing the special effect transparency to dynamically change with the fog intensity. This method of driving dual-path rendering with unified sampling results completely changes the binary display state (either visible or hidden) caused by directly clipping or disabling rendering in traditional solutions. It achieves a smooth transition of visibility through continuous color values, not only making the fog coverage present a natural edge transition effect, but also deeply binding the special effect display logic with the fog intensity. Therefore, it can not only effectively solve the problem of the awkward display / hiding effect of game objects in the fog in the traditional solution, but also solve the technical problems such as the disconnect between logic and performance in the traditional solution, so that the fog of war can make the occlusion effect of different objects conform to the physical law, significantly enhancing the immersion and visual expressiveness of the game scene. Attached Figure Description

[0012] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0013] Figure 1 An exemplary flowchart of a fog of war rendering method provided for some embodiments of this application;

[0014] Figure 2This is an exemplary structural diagram of an electronic device provided for some embodiments of this application. Detailed Implementation

[0015] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0016] The following terms are used in this document.

[0017] The central processing unit, or CPU, is manufactured using very large-scale integrated circuit technology and has the core functions of computation and control.

[0018] The graphics processing unit, or GPU, is the core hardware specifically designed for handling graphics rendering tasks and possesses powerful parallel computing capabilities.

[0019] A shader is a program that runs on the GPU and is specifically designed to generate various visual effects in the rendering pipeline.

[0020] First Embodiment

[0021] The first embodiment of this application relates to a method for rendering fog of war. For example... Figure 1 As shown, the method may include the following steps:

[0022] Step S101: Input the fog of war texture and the texture coordinates of the current fragment into the shader;

[0023] Step S102: Sample the fog of war texture according to the texture coordinates to determine the color value of the target pixel;

[0024] Step S103: Execute different rendering logic according to the type of the rendering object and the color value to generate fog of war; the type of the rendering object includes non-transparent objects or transparent objects.

[0025] The following sections will provide a detailed explanation of each of the above steps.

[0026] For step S101, for example, the fog of war texture can be bound to a uniform variable of the shader. The fog of war texture stores the visibility information (such as fully visible, partially visible, or completely occluded) of various areas of the map. Simultaneously, the world coordinates corresponding to the current fragment can be obtained from the rendering pipeline, assuming the world coordinates are p = (p... x ,p y ).

[0027] Next, we can determine the origin coordinates of the map as o = (o x ,o y The width w and height h of the map are determined using the coordinate transformation formula: (u,v)=((p) x -o x ) / w,(p y -o y The world coordinates are mapped to texture coordinates using the following method: (u, v). In other words, the world coordinates are scaled to the [0, 1] range by dividing the offset of the world coordinates relative to the map origin by the map's width and height, thus matching the sampling dimension of the fog of war texture. The calculated (u, v) is the texture coordinate of the current fragment on the fog of war texture. This completes the association between world space and texture space.

[0028] For step S102, for example, in the shader, the fog of war texture is sampled using the calculated normalized texture coordinates (UV coordinates) to obtain the color value pix of the target pixel. For example, the UV coordinates can be mapped to the physical location of the texture, and then the color value pix of the corresponding texel can be extracted using algorithms such as bilinear interpolation. Since the fog of war texture is usually a grayscale image, the R, G, and B channel values ​​of the grayscale image are equal (e.g., (0.2, 0.2, 0.2)). This value directly encodes the visibility state of the corresponding location in the game world. For example, white (RGB≈1.0) indicates full visibility, gray (e.g., RGB≈0.5) indicates partial visibility, and black (RGB≈0.0) indicates complete occlusion.

[0029] For step S103, for example, during the rendering process, the system can first determine whether the rendered object is a non-transparent object or a transparent object, and simultaneously obtain the color value of the rendered object. Then, based on the type of the rendered object and the specific details of the color value, differentiated rendering logic is invoked to generate a fog of war that can simulate occlusion effects, thereby meeting specific visual performance requirements in scenarios such as games.

[0030] Non-transparent objects are those that light cannot penetrate, completely obscuring the scene behind them. Their pixels completely cover or replace the color values ​​at the corresponding positions in the frame buffer during rendering. Physical buildings in the game scene (such as castle walls and houses), terrain and landforms (such as mountains and rocks), and the main body of character models (such as warrior armor and character torsos) all fall under the category of non-transparent objects. Transparent objects are those that allow some light to pass through, requiring transparency blending to achieve the visual effect. Environmental effects (such as fire and smoke), water surfaces and glass, and skill and magic effects (such as shields and teleportation rings) all fall under the category of transparent objects.

[0031] For steps S101 to S103, for example, when implementing a fog of war effect in game development, the following steps can be followed: Pass the fog of war texture (e.g., a black and white noise image, where white represents visible areas and black represents invisible areas) into the shader; calculate the position of the current rendered pixel in world space and convert it to the corresponding texture coordinates (UV). Assume the UV coordinates of a pixel are (0.3, 0.5); then sample the fog of war texture using the UV coordinates (0.3, 0.5) and extract the color value at that location. Assume the sampling result is (0.8, 0.8, 0.8, 1.0). Since it's a grayscale image, the RGB channel values ​​are the same, and 0.8 indicates that the area is nearly visible (white is 1.0), and is less affected by the fog. Finally, execute the corresponding rendering logic based on the type and color value of the rendered object. Assuming the rendered object is a non-transparent object (e.g., a building), visibility can be directly determined based on the color value. If the color value > a threshold, the pixel is rendered normally; if the color value ≤ a threshold, the pixel is discarded (making it invisible). In the example, a color value of 0.8 > 0.5, so the building remains visible. Assuming the object being fogged is transparent (like glass), the color value can be used as a transparency multiplier. Original transparency × color value = final transparency. In the example, if the glass's original transparency is 0.7, the final transparency is 0.7 × 0.8 = 0.56, resulting in a semi-transparent effect. The denser the fog (the lower the color value), the lower the transparency. In this way, fog of war can apply a physically intuitive occlusion effect to different types of objects, concealing strategic information while maintaining visual consistency.

[0032] Understandably, in related technologies, the system typically renders game characters, units, or effects through the following process: First, it obtains the coordinates of the effect in world space, converts them into texture coordinates for a fog of war map, and then samples the visibility value of that location. If the sampling result shows that the location is in an invisible area (e.g., the color value is below a certain threshold), the rendering process for that effect is skipped; if it is in a visible or semi-transparent transition area, the transparency or display intensity of the effect is adjusted according to the visibility value. It is evident that the direct cropping or disabling of rendering in related technologies results in a lack of smooth transitions when effects appear or disappear in the fog, disrupting player immersion; it fails to achieve a gradual transition in fog coverage, lacking visual hierarchy and causing a loss of visual depth; and the effect display logic cannot be correlated with fog intensity, potentially revealing player location information due to abnormal display, thus presenting a technical problem of a disconnect between logic and presentation.

[0033] It is not difficult to see that, compared with related technologies, the solution provided in this application provides basic data for subsequent processing by inputting the fog of war texture and the texture coordinates of the current fragment into the shader; and by sampling the fog of war map based on the texture coordinates to obtain color values, ensuring the reliability of the rendering judgment basis. Furthermore, because differentiated rendering logic is executed according to the type of the rendered object (non-transparent or transparent) and the color value, for non-transparent objects, pixel visibility can be controlled by calculating the relationship between the color value and the threshold, achieving a gradual transition from fully visible to completely hidden; for transparent objects, the color value can be used as a transparency modulation coefficient, allowing the special effect transparency to dynamically change with the fog intensity. This method of driving dual-path rendering with a unified sampling result completely changes the binary display state (either visible or hidden) caused by directly clipping or disabling rendering in traditional solutions. It achieves a smooth transition of visibility through continuous color values, not only making the fog coverage present a natural edge transition effect, but also deeply binding the special effect display logic with the fog intensity. Therefore, it can not only effectively solve the problem of the awkward display / hiding effect of game objects in the fog in the traditional solution, but also solve the technical problems such as the disconnect between logic and performance in the traditional solution, so that the fog of war can make the occlusion effect of different objects conform to the physical law, significantly enhancing the immersion and visual expressiveness of the game scene.

[0034] Second Embodiment

[0035] The second embodiment of this application relates to a method for rendering fog of war. The second embodiment is an improvement upon the first embodiment, specifically in that it provides a concrete implementation method for executing different rendering logic based on the type of the rendering object and the color value.

[0036] Specifically, in some embodiments, the step of executing different rendering logic based on the type of the rendering object and the color value, i.e., step S103, may further include:

[0037] If the rendered object is a non-transparent object, then the distance parameter is determined according to the texture coordinates, the clipping value is determined according to the distance parameter and the color value, and the visual attributes of the non-transparent object are adjusted according to the clipping value.

[0038] If the object to be rendered is transparent, the target transparency is determined based on the color value; the visual attributes of the object to be rendered are adjusted based on the target transparency.

[0039] Specifically, when the rendered object is determined to be non-transparent, the rendering logic can calculate a distance parameter based on texture coordinates. This distance parameter reflects the spatial relationship between the current pixel and the object's center. Subsequently, the system combines this distance parameter with color values ​​to calculate a clipping value. This clipping value controls the visual appearance of the object's surface. By adjusting the clipping value, effects such as edge blurring, enhanced surface details, or hiding specific areas can be achieved, thereby precisely controlling the visual properties of non-transparent objects and enabling them to exhibit the desired material texture or special visual effects.

[0040] Specifically, when the rendered object is determined to be non-transparent, the rendering logic can directly use the color value to determine the target transparency. Once the target transparency is determined, the system can adjust the object's visual properties accordingly, allowing light to partially penetrate the object and producing a semi-transparent effect. This processing method can not only simulate the optical properties of common transparent materials such as glass and water surfaces, but also achieve special effects such as fade-in / fade-out and smoke diffusion by dynamically adjusting transparency, greatly enhancing the realism and visual expressiveness of the rendered scene.

[0041] It is not difficult to see that this application embodiment provides a specific implementation method for executing different rendering logic based on the type of the rendering object and the color value. For non-transparent objects, the distance parameter is determined by texture coordinates, and then a clipping value is generated by combining the color value. This allows the system to dynamically adjust visual attributes based on the spatial position and color characteristics of the object's surface, thereby achieving effects such as enhanced material details and smooth edge transitions, significantly improving the realism of non-transparent objects. For transparent objects, the transparency is determined directly based on the color value, which can accurately simulate the physical phenomenon of light penetrating the object, allowing materials such as glass and liquids to present a natural semi-transparent effect, avoiding visual distortion caused by inappropriate rendering methods. This differentiated rendering strategy fundamentally ensures that different types of objects can present visual effects that conform to physical laws during rendering, thereby improving the overall rendering quality and scene immersion.

[0042] Third Embodiment

[0043] The third embodiment of this application relates to a method for rendering fog of war. The third embodiment is an improvement upon the second embodiment, specifically in that it provides a concrete implementation method for determining distance parameters based on the texture coordinates.

[0044] Specifically, in some embodiments, determining the distance parameter based on the texture coordinates may further include the following steps:

[0045] Step S103A1: Determine the periodic texture coordinates based on the texture coordinates and the predefined scalar coefficients; the scalar coefficients are used to control the frequency of the fog of war edge texture.

[0046] Step S103A2: Determine the distance parameter based on the periodic texture coordinates and the predefined reference point coordinates; wherein, the reference point coordinates are used to control the reference center for distance calculation, so as to affect the transition effect of the edge of the fog of war.

[0047] For step A103A1, for example, the texture coordinates (uv) can be multiplied by a predefined scalar coefficient (Scale), and then the fractional part operation can be applied to the result to obtain the periodic texture coordinates (PeriodicUV). The corresponding mathematical expression can be: PeriodicUV = frac(uv × Scale); where the frac function returns the fractional part of the input value, equivalent to x - floor(x). The result returned by the frac function always falls within the range [0, 1).

[0048] The scalar coefficient is used to control the frequency of the edge texture in the fog of war, i.e., the density of texture repetition. A larger scalar coefficient allows the uv×Scale value to change more rapidly, causing PeriodicUV to change drastically even with small changes in the uv space. This results in a shorter texture period, denser edge texture details, and a more fragmented, jagged edge effect. Conversely, a smaller scalar coefficient allows the uv×Scale value to change more gradually, causing PeriodicUV to change smoothly over a larger range in the uv space. This results in a longer texture period, smoother and wider edge transitions, and reduced jaggedness. Essentially, this step scales the texture coordinate space and uses fractional operations to achieve periodic tiling. The larger the scalar coefficient Scale, the more severe the scaling, and the more texture periods (higher frequency) can be accommodated within a unit ([0,1]) of the original texture coordinate space, resulting in denser details. Thus, by adjusting the scalar coefficient for linear scaling rather than periodic folding, discontinuities at the edges can be avoided.

[0049] For step A103A2, for example, the Euclidean distance between the periodic texture coordinates (PeriodicUV) and the predefined reference point coordinates (Center) can be calculated, and this distance can be used as the distance parameter (Dist). The corresponding mathematical expression can be: Dist = distance(PeriodicUV, Center) = sqrt((PeriodicUV.x - Center.x)^2 + (PeriodicUV.y - Center.y)^2).

[0050] The reference point coordinates are used to control the reference center position for distance calculation, directly affecting the shape of the fog of war edge transition. The reference point coordinates can be a central reference point (e.g., (0.5, 0.5)), causing the Dist to exhibit a radial distribution increasing from the center point outwards, thus producing a circular (or elliptical, depending on the uniformity of the UV space) gradient effect centered on the reference point. The reference point coordinates can also be an eccentric reference point (e.g., (0.2, 0.7)), changing the gradient direction of the Dist and shifting the center of the transition area to the reference point position. This can create a non-centrally symmetrical, irregular transition shape. In this step, the Euclidean distance calculation method provides a mathematically precise controllable transition model for the fog of war edge. Developers can flexibly shape the visual representation of the fog of war boundary by adjusting the position of the Center, achieving a smooth transition from a fully visible area to a completely invisible area.

[0051] Combining steps A103A1 and S103A2, the process of determining the distance parameter based on the texture coordinates can be refined into the following formula: Distance parameter (Dist) = distance(frac(texture coordinates (uv) * scalar coefficient (Scale)), reference point coordinates (Center)).

[0052] For example, suppose we are developing a fog of war effect for a game map. The system can obtain the texture coordinates of the current pixel: uv = (0.15, 0.22). Set Scale = 230.

[0053] Calculate uv×Scale=(0.15×230,0.22×230)=(34.5,50.6).

[0054] Next, the `frac` operation maps the texture coordinates to a periodically repeating mesh space, i.e., `PeriodicUV = frac(34.5, 50.6) = (0.5, 0.6)`. It's important to note that even small values ​​like `uv` (0.1, 0.2) multiplied by `Scale = 230` result in `(23.0, 46.0)`, but the `frac` operation returns `(0.0, 0.0)`, thus normalizing these values ​​to the [0, 1) range. The physical meaning of this process is that it divides the original [0, 1) × [0, 1) texture space into 230 × 230 tiny repeating mesh units. The relative position within each mesh (i.e., the result of the `frac` operation) determines the specific shape of that point in the periodic texture. For example, `(0.0, 0.0)` represents the starting point (top left corner) of each repeating unit, and `(0.5, 0.6)` represents the middle position within a unit. Adjusting the `Scale` parameter controls the frequency of this repetition. In this example, when Scale = 230, the texture is repeated 230 times in each direction of the UV space, forming a dense, periodic pattern. This mechanism allows for the creation of infinitely extending, complex texture effects within a finite texture space through mathematical transformations, while maintaining computational efficiency and visual controllability.

[0055] Further, assuming the reference point coordinates Center = (0.5, 0.5), calculate the Euclidean distance from PeriodicUV(0.5, 0.6) to Center(0.5, 0.5): Dist = sqrt((0.5-0.5)^2 + (0.6-0.5)^2) = sqrt(0 + 0.01) = 0.1. The distance parameter Dist = 0.1 can be used in subsequent calculations to achieve a gradient effect at the edge of the fog.

[0056] It should be noted that this embodiment can also be an improvement based on the first embodiment.

[0057] It is not difficult to see that in the embodiments of this application, by multiplying the texture coordinates by a predefined scalar coefficient to determine the periodic texture coordinates, the scalar coefficient can directly control the frequency of the fog of war edge texture. A larger coefficient produces denser edge details due to shortening the texture period, while a smaller coefficient achieves a smoother transition effect by lengthening the texture period. Furthermore, the Euclidean distance calculated based on the periodic texture coordinates and the predefined reference point coordinates is used as a distance parameter, which allows the setting of the reference point coordinates to precisely control the reference center for distance calculation. In turn, by changing the position of the reference center, diverse fog edge shapes such as circular gradients and eccentric transitions can be achieved. This modular parameter control mechanism makes the fog of war rendering process highly flexible and customizable, and can achieve the technical effect of accurately shaping the visual representation of the fog boundary according to actual needs.

[0058] Fourth embodiment

[0059] The fourth embodiment of this application relates to a method for rendering fog of war. The fourth embodiment is an improvement upon the second embodiment, specifically in that it provides a concrete implementation method for determining a clipping value based on the distance parameter and the color value.

[0060] Specifically, in some embodiments, determining the clipping value based on the distance parameter and the color value may further include the following steps:

[0061] Step S103B1: Subtract the color value from the distance parameter to obtain a first difference value representing the sampling distance difference;

[0062] Step S103B2: Subtract a predefined transition threshold from the first difference to obtain a cropping value for pixel-level cropping; wherein, the transition threshold is used to determine the critical boundary at which a non-transparent object gradually disappears in the fog of war.

[0063] For step S103B1, for example, in the fog of war rendering process, by subtracting the color value pix from the distance parameter D to generate a first difference Δ1 (Δ1 = pix - D), the correlation between pixel color attributes and spatial location can be effectively established. The color value pix (ranging from 0 to 1, typically representing brightness) and the distance parameter D (a larger value indicates the pixel is farther from the center of the fog of war) have a dynamic relationship: when a pixel is far from the center of the fog, D increases, and since the upper limit of pix is ​​1, the difference Δ1 decreases accordingly; conversely, when closer to the center, D decreases, and Δ1 increases. This calculation method mathematically couples visual brightness with spatial distance: on the one hand, high-brightness areas, due to their larger pix values, retain a higher Δ1 during subtraction, thus possessing stronger anti-fog capabilities, allowing objects to maintain high visibility in the fog; on the other hand, distant areas, due to their larger D values, significantly lower Δ1, strengthening the fog's occlusion effect on objects. Therefore, the system can dynamically adjust the visual attributes of non-transparent objects based on the value of Δ1, achieving a natural transition effect of "the farther away from the center, the lower the visibility", making the rendering of the fog of war more in line with the logic of human visual perception.

[0064] For step S103B2, for example, after obtaining the first difference Δ1, the final reduction value Δc can be calculated by subtracting the predefined transition threshold T (a constant with a value range of 0-1). The calculation formula is Δc = Δ1 - T.

[0065] Optionally, in some embodiments, adjusting the visual properties of the non-transparent object according to the clipping value may include: discarding the current segment to achieve a hiding effect when the clipping value is less than 0; and retaining the current segment to display the non-transparent object when the clipping value is greater than or equal to 0.

[0066] Specifically, when Δc>0, the first difference is greater than the transition threshold, and the corresponding pixel will be fully preserved and rendered as completely opaque, ensuring that the object is clearly visible in this area; when Δc<0, it indicates that the first difference is less than the transition threshold, and the pixel will be cropped, and the rendering result will be completely transparent, simulating the effect of the object being completely covered by fog.

[0067] By adjusting the transition threshold T, developers can flexibly control the visual appearance of the fog of war: a smaller threshold reduces the severity of the clipping criteria, allowing more pixels to be retained, thus expanding the visible area and generating soft, natural fog edges; while a larger threshold increases the clipping threshold, causing many pixels to become transparent due to Δc < 0, thereby compressing the visible area and creating sharp, distinct fog boundaries. This allows non-transparent objects to achieve a smooth transition from being clearly visible to completely hidden when passing through the fog of war, significantly enhancing the realism and immersive experience of the game scene.

[0068] For steps S103B1 and S103B2, for example, suppose there is a non-transparent object in a fog of war area in a game scene. The color value of a certain pixel is converted to 0.7 (which can be understood as a brightness value; the larger the value, the brighter the pixel). The distance parameter calculated through steps S103A1 and S103A2 is 0.9 (representing the distance from the pixel to the center of the fog). Step S103B1 is executed, subtracting the color value from the distance parameter, i.e., 0.7 - 0.9 = -0.2, to obtain the first difference value. This first difference value reflects the difference in the relationship between the pixel's color and distance. Next, assuming a predefined transition threshold of 0.1, in step S103B2, the first difference is subtracted from the transition threshold, i.e., -0.2 - 0.1 = -0.3, to obtain the clipping value -0.3. Since the clipping value is negative, it means that the pixel is closer to being transparent under the influence of the fog of war. During the final rendering, the pixel will be clipped or its opacity will be reduced, so that the object will appear to fade away gradually, thus achieving a visual representation of a non-transparent object transitioning naturally in the fog.

[0069] Optionally, in some embodiments, the clipping value (Δc) can be combined with the discard command and depth testing to achieve the fading effect of non-transparent objects. For example, the color value can be subtracted from the distance parameter to obtain a first difference (Δ1), and then a predefined transition threshold (T) can be subtracted to obtain the clipping value Δc. When Δc > 0, the pixel is retained and the object remains visible; when Δc < 0, the corresponding pixel should be clipped. At this time, the discard command is used to remove pixels with Δc < 0 from the rendering pipeline and not participate in subsequent rendering. In the depth testing stage, as the object gradually enters the fog area, the clipping value Δc of more pixels becomes negative, and the corresponding pixels are discarded. The visible pixels continue to decrease, and the object looks as if it is gradually disappearing in the fog. This achieves a natural fading effect of non-transparent objects in the fog of war based on depth testing, enhancing the immersion and realism of the scene.

[0070] It should be noted that this embodiment may also be an improvement based on the first embodiment and / or the third embodiment.

[0071] It is not difficult to see that in this embodiment, by subtracting the color value from the distance parameter to obtain the first difference, the calculation of the clipping value can integrate the pixel color characteristics and spatial position information, thereby reflecting the relative position difference of the pixel in the fog. On this basis, the clipping value is obtained by subtracting the predefined transition threshold from the first difference. Since the transition threshold is a quantitative indicator of the critical boundary, it can accurately control the transition range of non-transparent objects from visibility to disappearance. Therefore, this step-by-step calculation of the clipping value achieves the effect of dynamically controlling the visibility of the pixel in the fog of war according to the specific situation of the pixel, which is conducive to achieving a natural and smooth gradual disappearance of non-transparent objects in the fog.

[0072] Fifth embodiment

[0073] The fifth embodiment of this application relates to a method for rendering fog of war. The fifth embodiment is an improvement upon the second embodiment, specifically in that it provides a concrete implementation method for determining the target transparency based on the color value.

[0074] Specifically, in some embodiments, determining the target transparency based on the color value includes: determining the target transparency based on the original transparency and the color value.

[0075] For example, the basic transparency information of the pixel can first be obtained from the original material or texture (usually stored as the alpha channel of the color value). The original transparency is used to characterize the transparency property of the object itself; for example, glass has a high transparency (close to 1), while semi-transparent fabric has a low transparency (e.g., around 0.5).

[0076] Furthermore, the original transparency can be multiplied by the color value to obtain the final target transparency. For example, if the original transparency is 0.7 and the color value is 0.4 (for darker areas), the target transparency may be adjusted to 0.7 × 0.4 = 0.28, making the area closer to transparent in the fog of war.

[0077] Optionally, in some embodiments, adjusting the visual properties of the rendered object according to the target transparency may include: simultaneously reducing the object's brightness and saturation according to the target transparency, and achieving a color gradient at the boundary of the fog of war through channel blending.

[0078] For example, when adjusting the visual properties of a transparent object, the object's brightness and saturation can be reduced proportionally to the target's transparency. The lower the target transparency (the closer the object is to being completely transparent), the greater the reduction in brightness and saturation. For instance, when the target transparency is 0.5, the brightness and saturation can be adjusted to 50% of their original values. Thus, in reality, when observing an object through fog, not only will the object's visibility decrease, but its color vibrancy and brightness will also be weakened due to scattering and absorption. In this way, the rendering system can simulate the energy attenuation effect of light passing through fog, causing objects to gradually fade and blur at their boundaries, enhancing their integration with the environment.

[0079] For example, in the boundary areas of fog of war, channel blending can be used to dynamically blend the original color of objects with the color of the fog. Specifically, the blending weight is calculated based on the target's transparency: when the target transparency is close to 1 (fully visible), the original color of the object is retained; when the target transparency is close to 0 (completely invisible), it gradually transitions to the color of the fog (usually gray or light blue). This channel blending can be achieved through linear interpolation, for example, using the formula: Final Color = Original Object Color × Target Transparency + Fog Color × (1 - Target Transparency). In this way, as an object enters or leaves the fog area, its color smoothly transitions from its original color to the color of the fog, eliminating the harsh boundaries that may occur in traditional rendering and making the transition effect of fog of war more natural and realistic.

[0080] It should be noted that this embodiment may also be an improvement based on any one or more of the first, third, and fourth embodiments.

[0081] It is not difficult to see that this application embodiment provides a specific implementation method for determining the target transparency based on the color value. This processing method achieves a natural transition effect for transparent objects in fog of war: the bright parts of the object (such as highlights or luminous areas) can resist the obstruction of fog and maintain high visibility; while the dark parts are more easily swallowed by fog, which conforms to the physical law of light penetrating transparent media in the real world. By dynamically adjusting the transparency of each pixel, the system can accurately simulate the visual performance of different materials in fog of war, significantly improving the realism and immersion of the scene.

[0082] Based on the above embodiments, it can be seen that this application has at least the following beneficial effects:

[0083] 1. Naturally transitioning visual presentation enhances immersion.

[0084] This application integrates fog of war occlusion with special effects rendering, using the color values ​​(pixels) of the fog of war texture sampled by the shader as the core parameter for transparency calculation. As the special effects move between the fog area and the visible area, the gradual change in pixel value from 0 to 1 synchronously drives a smooth change in the effect's transparency, achieving a natural transition effect of "revealing itself in the fog." This completely changes the binary display (either visible or invisible) problem caused by direct clipping rendering in traditional solutions. This gradual change based on continuous mathematical mapping conforms to the laws of human visual perception, giving the fog occlusion effect a rich sense of realism and significantly enhancing the immersive experience of the game scene.

[0085] II. Natural visual transitions enhance immersion.

[0086] Employing a "unified parameter-driven mechanism," all effects (skills, buffs, character appearances, etc.) use the color value (pixels) of the fog of war texture as the sole input to the rendering logic. For example, if a skill effect is located in a fog-covered area (pixels close to 0), it will be automatically dimmed or hidden to prevent revealing its location information to the enemy. Unlike traditional solutions that rely on CPU pre-judgment and suffer from latency issues, this application uses shaders to perform real-time calculations on the GPU, ensuring zero-latency synchronization between the fog state and the effect's appearance. Even in complex scenes with rapid movement and dynamic changes in field of view, it maintains consistency between logic and visuals, eliminating rendering errors caused by positional information discrepancies.

[0087] III. Wide equipment compatibility and special effects adaptability

[0088] The implementation is based on a standard rendering workflow combining texture sampling and shaders, without relying on advanced GPU features (such as ray tracing and geometry shaders). Therefore, it can run smoothly on various terminal devices, including mobile and PCs, significantly lowering the hardware requirements. Meanwhile, the "dual-path rendering logic" abstracts fog processing into a unified framework: for non-transparent effects, pixels are discarded using the discard command; for transparent effects, visual attributes are modulated through target transparency. This architecture allows various effects such as smoke, magical halos, and ambient lighting to directly integrate with the fog sampling logic, eliminating the need to develop separate adaptation code for different effects, greatly reducing development workload and improving project iteration efficiency.

[0089] IV. Innovative breakthroughs in technical architecture to solve traditional pain points

[0090] This application fundamentally solves three core problems of traditional fog of war technology by using a shader sampling mechanism and a unified rendering framework: replacing binary judgments with continuous parameters (pixels) to eliminate the abruptness of visual presentation; replacing CPU pre-judgment with real-time GPU calculations to avoid the disconnect between logic and presentation; and replacing customized development with a general framework to improve the scalability of special effects adaptation. This technical solution, which deeply couples "dynamic visibility control" with "visual artistic expression," not only strengthens the information hiding mechanism at the strategic level of the game but also enhances the visual quality through natural visual transitions, while reducing the technical implementation cost, achieving a dual optimization of gameplay and technology.

[0091] It is not difficult to see that the step division of the various methods in the embodiments of this application is only for clear description. In implementation, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the protection scope of this application. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are all within the protection scope of this application.

[0092] Furthermore, some embodiments of this application also provide an electronic device. The electronic device can be various forms of digital computer, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, etc. The electronic device can also be various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices.

[0093] The electronic device includes: one or more processors; and a memory storing computer program instructions that, when executed, cause the processor to perform the steps of the methods provided in any one or more of the above embodiments. Figure 2An exemplary structural diagram of the electronic device is disclosed. The electronic device includes one or more processors 1101, a memory 1102, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components are interconnected via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some other embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations. The components, their connections and relationships, and their functions shown herein are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.

[0094] The electronic device may further include an input device 1103 and an output device 1104. The processor 1101, memory 1102, input device 1103 and output device 1104 may be connected by a bus or other means, as shown in the figure, which is connected by a bus.

[0095] Input device 1103 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 1104 may include a display device, auxiliary lighting device (e.g., LED), and haptic feedback device (e.g., vibration motor). The display device may include, but is not limited to, a liquid crystal display, a light-emitting diode display, and a plasma display. In some embodiments, the display device may be a touch screen.

[0096] To provide interaction with the user, the electronic device can be a computer. The computer has: a display device (e.g., a cathode ray tube or LCD monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback); and input from the user can be received in any form (e.g., voice input or tactile input).

[0097] In this embodiment, a computer-readable medium stores a computer program / instructions that, when executed by a processor, implement the steps of the methods provided in any one or more of the above embodiments. This computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into that device. The aforementioned computer-readable medium carries one or more computer-readable instructions.

[0098] The memory 1102 can serve as a non-transitory computer-readable storage medium, used to store non-transitory software programs, non-transitory computer-executable programs, and modules. The processor 1101 executes various functional applications and data processing of the server by running the non-transitory software programs, instructions, and modules stored in the memory 1102, thereby implementing the program instructions / modules corresponding to the methods provided in any one or more of the embodiments described above in this application.

[0099] The memory 1102 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 1102 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 1102 may optionally include memory remotely located relative to the processor 1101, and these remote memories can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0100] It should be noted that the computer-readable medium described in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections having one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0101] Computer-readable media include permanent and non-permanent, removable and non-removable media, which can store information by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory, static random access memory, dynamic random access memory, other types of random access memory, read-only memory, electrically erasable programmable read-only memory, flash memory or other memory technologies, read-only optical discs, digital versatile optical discs or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0102] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including local area networks (LANs) or wide area networks (WANs), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0103] In the above embodiments, all or part of the implementation can be achieved through software, hardware, firmware, or any combination thereof. For example, it can be implemented using an application-specific integrated circuit (ASIC), a general-purpose computer, or any other similar hardware device. In some embodiments, the software program of this application can be executed by a processor to implement the above steps or functions. Similarly, the software program of this application (including related data structures) can be stored in a computer-readable recording medium, such as RAM memory, magnetic or optical drives, floppy disks, and similar devices. In addition, some steps or functions of this application can be implemented in hardware, for example, as circuitry that cooperates with a processor to perform the various steps or functions.

[0104] The computer program product provided in this application includes one or more computer programs / instructions. When executed by a processor, these computer programs / instructions generate, in whole or in part, the processes or functions described in this application. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0105] The flowcharts or block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-specific system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0106] The scope of this application is defined by the appended claims rather than the foregoing description, and is therefore intended to encompass all variations falling within the meaning and scope of equivalents of the claims. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a device claim may also be implemented by a single unit or device in software or hardware. Terms such as "first," "second," etc., are used only for distinguishing descriptions and do not indicate any particular order, nor should they be construed as indicating or implying relative importance.

[0107] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily made by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims, and the above embodiments should be regarded as exemplary and non-limiting.

Claims

1. A method for rendering fog of war, characterized in that, The method includes: Enter the fog of war texture and the texture coordinates of the current fragment into the shader; The war fog texture is sampled based on the texture coordinates to determine the color value of the target pixel; Different rendering logic is executed based on the type of the rendered object and the color value to generate fog of war; the type of the rendered object includes non-transparent objects or transparent objects; The step of executing different rendering logic based on the type of the rendering object and the color value includes: if the rendering object is a non-transparent object, then a distance parameter is determined based on the texture coordinates, a clipping value is determined based on the distance parameter and the color value, and the visual attributes of the non-transparent object are adjusted based on the clipping value; if the rendering object is a transparent object, then a target transparency is obtained based on the color value as a transparency modulation coefficient; the visual attributes of the transparent object are adjusted based on the target transparency; the step of determining the distance parameter based on the texture coordinates includes: The periodic texture coordinates are determined based on the texture coordinates and predefined scalar coefficients; the scalar coefficients are used to control the frequency of the fog of war edge texture. Calculate the Euclidean distance between the periodic texture coordinates and the predefined reference point coordinates, and use this distance as a distance parameter; wherein, the reference point coordinates are used to control the reference center for distance calculation, so as to affect the transition effect of the edge of the fog of war; Determining the clipping value based on the distance parameter and the color value includes: Subtracting the color value from the distance parameter yields a first difference value characterizing the sampling distance difference; Subtracting the predefined transition threshold from the first difference yields the cropping value used for pixel-level cropping; wherein, the transition threshold is used to determine the critical boundary at which a non-transparent object gradually disappears in the fog of war. The adjustment of the visual properties of the non-transparent object based on the clipping value includes: When the reduction value is less than 0, the current segment is discarded to achieve the hiding effect; When the clipping value is greater than or equal to 0, the current fragment is retained to display the non-transparent object.

2. The method according to claim 1, characterized in that, Determining the target transparency based on the color value includes: determining the target transparency based on the original transparency and the color value.

3. The method according to claim 1, characterized in that, The step of adjusting the visual properties of the rendered object based on the target transparency includes: Based on the target transparency, the object's brightness and saturation are reduced simultaneously, and a color gradient at the boundary of the fog of war is achieved through channel blending.

4. An electronic device, characterized in that, The electronic device includes: One or more processors; and A memory storing computer program instructions, which, when executed, cause the processor to perform the steps of the method as described in any one of claims 1 to 3.

5. A computer-readable medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 3.

6. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 3.