Implementation method for fog principle in three-dimensional simulation scene
By calculating the relative height of the camera and object and the related parameters of the fog, dynamically calculate the fog color changes, solving the problem that the fog color changes are independent of the camera position in the prior art, and improving the fidelity of the three-dimensional simulation scene.
Patent Information
- Application Number
- CN202411837202.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-13
AI Technical Summary
The prior art cannot calculate the change in the fog color based on the height between the camera and the fog, resulting in a reduced simulation effect.
By calculating the relative height h of the camera and the object, fog effect concentration fog is calculated, and combining atmospheric scattering and light transmission attenuation, the total attenuation of fog under sunlight and atmospheric scattering Ifonal and fog scattering color Cinscattering are finally calculated based on these parameters FogColor.
The fog color changes dynamically according to the camera position changes, improving the fidelity and simulation effect of the three-dimensional simulation scene.
Smart Images

Figure CN119784924A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of realization of simulated fog, and in particular to a method for realizing the fog principle in a three-dimensional simulated vision. Background Art
[0002] A Chinese patent discloses a remote sensing image haze simulation method based on dark channel prior with application number CN201510329446.3. The remote sensing image haze simulation method based on dark channel prior includes the following steps: 1. remote sensing image data acquisition; 2. calculation of the dark channel map of the image; 3. global atmospheric light estimation; 4. transmission map extraction; 5. simulation of haze remote sensing image.
[0003] The remote sensing image haze simulation method based on dark channel prior can make the haze concentration level known by simulating haze remote sensing images, without the need for manual identification and classification, thereby providing haze true value for image quality evaluation and defogging algorithm research. However, the remote sensing image haze simulation method based on dark channel prior still has the following disadvantages: it cannot calculate the change of fog color according to the height between the camera and the fog, resulting in the camera position changing during the simulation process but the fog color cannot change accordingly, resulting in reduced simulation effect. Summary of the invention
[0004] The present invention aims to provide a method for realizing the fog principle in a three-dimensional simulated vision scene, so as to solve the problem that the change of fog color cannot be calculated according to the height between a camera and the fog in the prior art.
[0005] To achieve the above object, the present invention adopts the following technical solution: The present invention discloses a method for realizing the fog principle in a three-dimensional simulated scene, comprising the following steps:
[0006] S1, calculate the fog concentration fog according to the relative height h between the camera and the object;
[0007] S2. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final ;
[0008] S3. Calculate the fog scattering color C inscattering ;
[0009] S4, based on the fog concentration fog, the total attenuation of atmospheric light transmission I final and the fog scattering color C inscattering Calculate the fog color change FogColor.
[0010] Preferably, step S1 comprises the following steps:
[0011] S11, calculating the change value falloff of the relative height h between the camera and the object, falloff = (HeightFallOff*h), where HeightFallOff is the height attenuation coefficient;
[0012] S12, calculate the relationship between fog concentration and h, FogFactor, FogFactor = (1-exp2(-falloff)) / falloff;
[0013] S13. Calculate the fog density fog, fog = FogDensity*FogFactor, FogDensity = exp(-h), FogDensity is the fog density obtained by h.
[0014] Preferably, step S2 comprises the following steps:
[0015] S21. Calculation of atmospheric scattering I sacttering , I sacttering The calculation formula is:
[0016] I sacttering =I0·(pow(max(0,cosθ),w))
[0017] Where I0 is the initial heat dissipation intensity; θ is the angle between the observation direction and the light source direction; w is the weight factor, reflecting the intensity of atmospheric scattering; max(0,cosθ) means: when cosθ>0, the value is cosθ, when When pow(max(0,cosθ),w) represents max(0,cosθ) to the power of w;
[0018] S22. Calculate the atmospheric light transmission attenuation T(d), T(d) = exp(-k·d); T(d) represents the degree of light intensity attenuation after the light passes a certain distance d; k represents: attenuation coefficient, reflecting the absorption and scattering ability of the atmosphere; d represents the distance of light propagation from the object to the camera;
[0019] S23, calculate the height attenuation integral M,
[0020] S24. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final ;
[0021] I final =I0·(max(0,cosθ))w·exp(-k·d)·(1-exp(-k·d))
[0022] Preferably, in step S3, C inscattering The calculation formula is:
[0023] C in sacttering=((1-a)·C ND +a·C D )+S·H
[0024] In the above formula, C ND It is the non-directional color scattered by haze, which means the scattered color of haze without the influence of a specific light source direction;
[0025] C D It is the directional scattering color of the haze, which means the color effect of the haze in the direction of the light source when the haze is illuminated by a specific light source;
[0026] S is the contribution of sky atmosphere to haze, which is related to viewpoint height, terrain, weather conditions and atmospheric composition factors;
[0027] H is a factor related to the height or visibility distance of haze and sky atmospheric scattering, describing the effect of distance on the sky atmospheric contribution;
[0028] S·H means calculation by weighted product.
[0029] Preferably, the calculation formula of FogColor in step S4 is: FogColor=I final (1-fog)+C inscatternig .
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] In the present application, firstly, by analyzing the relationship between h (the relative height between the camera and the fog) and the fog concentration fog, a calculation formula of the fog concentration fog with respect to h is obtained, and at the same time, the height attenuation coefficient HeightFallOff (this coefficient reflects the change of the camera in the three-dimensional simulation scene) is used to calculate the change of h, so that the final obtained fog concentration fog is a calculation formula related to the change of h, so that the fog concentration fog can change with the change of the camera height, ensuring the fidelity of the three-dimensional simulation scene; then, by calculating the atmospheric scattering I sacttering , atmospheric light transmission attenuation T(d) and height attenuation integral M, thus obtaining the total attenuation I of fog under sunlight and atmospheric scattering final , which describes the total attenuation of fog between the object and the camera. The total attenuation is also related to the light propagation distance between the object and the camera, adapting to the change of the camera relative to the object. The total attenuation of fog under sunlight and atmospheric scattering I final It also changes with the distance between the camera and the object, ensuring that the camera moves finalwill also change to ensure the simulation effect; then, the fog scattering color C is calculated inscattering , the calculated fog scattering color C inscattering It shows that: light will scatter when passing through haze, affecting the final light intensity and color performance, making distant objects look more blurred and the color changes accordingly; finally, according to the fog effect concentration fog, the total attenuation of atmospheric light transmission I final and the fog scattering color C inscattering Calculate the fog color change FogColor. Finally, by controlling the fog effect concentration fog parameters, total attenuation I final Medium parameters and fog scattering color C inscattering The medium parameters obtain a realistic fog color rendering effect that changes dynamically according to the camera position, etc., which increases the simulation of the scene and realizes the interaction between atmospheric phenomena and the visual environment.
[0032] Other advantages, objectives and features of the present invention will be embodied in part through the following description, and in part will be understood by those skilled in the art through study and practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The figure is a flowchart of the steps for implementing the fog principle in a three-dimensional simulation scene. DETAILED DESCRIPTION
[0034] In order to make the technical means, creative features, objectives and functions of the present invention clearer and easier to understand, the present invention is further described below in conjunction with the accompanying drawings and specific embodiments:
[0035] like Figure 1 As shown, the present invention discloses a method for realizing the fog principle in a three-dimensional simulated scene, comprising the following steps:
[0036] S1, calculate the fog concentration fog according to the relative height h between the camera and the object;
[0037] S2. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final ;
[0038] S3. Calculate the fog scattering color C inscattering ;
[0039] S4, based on the fog concentration fog, the total attenuation of atmospheric light transmission I final and the fog scattering color C inscattering Calculate the fog color change FogColor.
[0040] Step S1 includes the following steps:
[0041] S11. Calculate the value falloff after the relative height h between the camera and the object changes, falloff = (HeightFallOff*h), where HeightFallOff is the height attenuation coefficient; (In this formula, the height attenuation coefficient HeightFallOff is multiplied by h to calculate the value obtained after the height changes with the height attenuation coefficient, that is, the changed height falloff)
[0042] S12. Calculate the relationship between fog concentration and h, FogFactor, FogFactor = (1-exp2(-falloff)) / falloff; (In this formula, the attenuation parameter is added by integral fitting method, so that the relationship between fog concentration and h is calculated according to the changing height falloff. The relationship between fog concentration and h is FogFactor)
[0043] S13. Calculate the fog density fog, fog = FogDensity*FogFactor, FogDensity = exp(-h), FogDensity is the fog density obtained by h. The higher the object is, the more serious the fog disappears when it reaches the camera, and the lower the object is, the stronger the fog effect will be after reaching the camera, simulating the phenomenon that the fog layer in the real world is usually higher in concentration at low altitudes and lower in concentration at high altitudes.
[0044] Step S2 includes the following steps:
[0045] S21. Calculation of atmospheric scattering I sacttering , I sacttering The calculation formula is:
[0046] I sacttering =I0·(pow(max(0,cosθ),w))(This formula describes how light is dissipated in different directions in the atmosphere, and the intensity of the dissipated light is proportional to θ)
[0047] Where I0 is the initial heat dissipation intensity; θ is the angle between the observation direction and the light source direction; w is the weight factor, reflecting the intensity of atmospheric scattering; max(0,cosθ) means: when cosθ>0, the value is cosθ, and when cosθ≤0, the value is 0; pow(max(0,cosθ),w) means max(0,cosθ) raised to the power of w;
[0048] S22. Calculate the atmospheric light transmission attenuation T(d), T(d) = exp(-k·d) (this formula represents the process in which light gradually weakens due to absorption and scattering during its propagation in the atmosphere); T(d) represents the degree of light intensity attenuation after the light passes a certain distance d; k represents the attenuation coefficient, which reflects the absorption and scattering ability of the atmosphere; d represents the distance of light propagation from the object to the camera;
[0049] S23, calculate the height attenuation integral M, (k(z): This is the attenuation coefficient at a specific altitude z in the atmosphere)
[0050] S24. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final (I final It reflects: the effect of fog under sunlight and atmospheric scattering);
[0051] I final =I0·(max(0,cosθ))w·exp(-k·d)·(1-exp(-k·d))(T(d) describes the attenuation effect experienced during light propagation. The closer T(d) is to 1, the smaller the attenuation is, and the less the light intensity decays; conversely, the closer T(d) is to 0, the more serious the attenuation is, and the greater the loss of light intensity. 1-T(d) reflects the relationship between "remaining light intensity" and "scattered light intensity". In fact, although light will attenuate during propagation, the light scattered in the atmosphere will still be transmitted to the observer's eyes. Use 1 -T(d) (that is: 1-exp(-k·d)) means that we have to consider the intensity of scattered light that can actually reach the observer after attenuation. In this way, we can accurately simulate the light transmission process in the atmosphere in computer graphics, rendering and other fields to generate more realistic visual effects. The final light intensity is affected not only by the intensity and scattering direction of the light source, but also by the attenuation effect in the atmosphere. The intensity of atmospheric scattering gradually weakens as the distance of light propagation increases, and at the same time, absorption and scattering in the atmosphere will further attenuate the final light intensity. )
[0052] Step S3C inscattering The calculation formula is:
[0053] C in sacttering=((1-a)·C ND +a·C D )+S·H
[0054] In the above formula, C ND It is the non-directional color scattered by haze, which means the scattered color of haze without the influence of a specific light source direction;
[0055] C DIt is the directional scattering color of the haze, which means the color effect of the haze in the direction of the light source when the haze is illuminated by a specific light source;
[0056] a is the interpolation factor, which indicates the degree of transition between two colors, and its range is [0,1];
[0057] S is the contribution of sky atmosphere to haze, which is related to viewpoint height, terrain, weather conditions and atmospheric composition factors;
[0058] H is a factor related to the height or visibility distance of haze and sky atmospheric scattering, describing the effect of distance on the sky atmospheric contribution;
[0059] S·H means calculated by weighted product. Directional and non-directional scattering are mixed: First, the scattered color of haze is a mixture of two different scattering components: non-directional scattering and directional scattering. The directionality of the scattering is adjusted according to the distance between the observer and the haze through the interpolation factor a. When the distance is closer (a is larger), the haze shows more directional scattering effects, and vice versa. Contribution of the sky atmosphere: Next, the scattering effect of the sky is also added to the final haze color, especially the sky scattering contribution related to altitude or viewing distance. This contribution is calculated by S·H, which enhances the haze color in the distant field of view, usually a slight superposition of the sky color to further enrich the color effect of the fog.
[0060] Preferably, the calculation formula of FogColor in step S4 is: FogColor=I final (1-fog)+C inscatternig .
[0061] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. A method for realizing the fog principle in a three-dimensional simulated scene, characterized in that: The steps include: S1, calculate the fog concentration fog according to the relative height h between the camera and the object; S2. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final ; S3. Calculate the fog scattering color C inscattering ; S4, based on the fog concentration fog, the total attenuation of atmospheric light transmission I final and the fog scattering color C inscattering Calculate the fog color change FogColor.
2. The method for realizing fog principle in three-dimensional simulation scene according to claim 1, characterized in that: Step S1 includes the following steps: S11, calculating the change value falloff of the relative height h between the camera and the object, falloff = (HeightFallOff*h), where HeightFallOff is the height attenuation coefficient; S12, calculate the relationship between fog concentration and h, FogFactor, FogFactor = (1-exp2(-falloff)) / falloff; S13. Calculate the fog density fog, fog = FogDensity*FogFactor, FogDensity = exp(-h), FogDensity is the fog density obtained by h.
3. The method for realizing fog principle in three-dimensional simulation scene according to claim 1, characterized in that: Step S2 includes the following steps: S21. Calculation of atmospheric scattering I sacttering , I sacttering The calculation formula is: I sacttering =I0·(pow(max(0,cosθ),w)) Where I0 is the initial heat dissipation light intensity; θ is the angle between the observation direction and the light source direction; w is the weight factor, reflecting the intensity of atmospheric scattering; max(0,cosθ) means: when cosθ>0, the value is cosθ, and when cosθ≤0, the value is 0; pow(max(0,cosθ),w) means max(0,cosθ) raised to the power of w; S22. Calculate the atmospheric light transmission attenuation T(d), T(d) = exp(-k·d); T(d) represents the degree of light intensity attenuation after the light passes a certain distance d; k represents: attenuation coefficient, reflecting the absorption and scattering ability of the atmosphere; d represents the distance of light propagation from the object to the camera; S23, calculate the height attenuation integral M, S24. Calculate the total attenuation of fog under sunlight and atmospheric scattering I final ; I final =I0·(max(0,cosθ))w·exp(-k·d)·(1-exp(-k·d))。 4. The method for realizing fog principle in three-dimensional simulation scene according to claim 1, characterized in that: Step S3C inscattering The calculation formula is: C insacttering =((1-a)·C ND +a·C D )+S·H In the above formula, C ND It is the non-directional color scattered by haze, which means the scattered color of haze without the influence of a specific light source direction; C D It is the directional scattering color of the haze, which means the color effect of the haze in the direction of the light source when the haze is illuminated by a specific light source; S is the contribution of sky atmosphere to haze, which is related to viewpoint height, terrain, weather conditions and atmospheric composition factors; H is a factor related to the height or visibility distance of haze and sky atmospheric scattering, describing the effect of distance on the sky atmospheric contribution; S·H means calculation by weighted product; a is the interpolation factor, which indicates the degree of transition between two colors and its range is [0,1].
5. The method for realizing fog principle in three-dimensional simulation scene according to claim 1, characterized in that: The calculation formula of FogColor in step S4 is: FogColor = I final (1-fog)+C inscatternig .
Citation Information
Patent Citations
Remote sensing image haze simulation method based on dark-channel priori knowledge
CN104881879A
Fog effect processing method and device
CN110097627A
Multi-scattering real-time rendering method and device and electronic equipment
CN117274473A
Visualization method and system of electrical schematic diagram
CN118780186A
Systems and methods for the real-time and realistic simulation of natural atmospheric lighting phenomenon
US20060176303A1