A method and apparatus for generating a fog effect simulation image

By employing GPS coordinate transformation and the Lambert illumination model in fog effect simulation, and combining altitude and depth factors to calculate scattering intensity, the problem of unrealistic fog effect simulation in existing technologies has been solved, achieving a more realistic fog effect simulation.

CN116128989BActive Publication Date: 2026-05-22CHONGQING UNISINSIGHT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHONGQING UNISINSIGHT TECH CO LTD
Filing Date
2022-11-28
Publication Date
2026-05-22

Smart Images

  • Figure CN116128989B_ABST
    Figure CN116128989B_ABST
Patent Text Reader

Abstract

The application provides a method and device for generating a fog effect simulation image. The method comprises: performing preliminary rendering on an original image by a fog effect parameter to generate an initial fog effect image, wherein the fog effect parameter comprises an altitude influence parameter; obtaining pixel altitude information of a pixel in a GPS space and camera altitude information of a camera in the GPS space by using a Unity world space coordinate to GPS space method according to texture mapping coordinates of the pixel in the initial fog effect image and preset coordinates of the camera in the world space; calculating an altitude factor according to the altitude influence parameter, the pixel altitude information and the camera altitude information, wherein the altitude factor can affect the fog effect intensity according to the altitude; calculating the altitude factor and a preset depth factor to obtain a mixed color; and rendering the initial fog effect image by using the mixed color to generate the fog effect simulation image. The application improves the authenticity and accuracy of the fog effect simulation image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image simulation technology, and in particular to a method and apparatus for generating fog effect simulated images. Background Technology

[0002] Fog effects generally describe the appearance of objects being shrouded in a certain color (grayish-white) from a direction far from our viewpoint. This effect can adjust the color tone of the image and increase the sense of depth in a three-dimensional world.

[0003] Currently, there are two main methods for achieving fog effects. In graphics engines, the fog effect is typically achieved by mixing the fog color with the object color based on the distance of the shooting device. This is the simplest method, using linear or non-linear influence factor calculations based on the distance of the shooting device. Another common method combines height and depth. This approach simulates fog effects more realistically, incorporating fog's influence not only horizontally but also vertically. In this height- and depth-based fog effect, the height and depth values ​​are based on linear influence factors within the 3D engine's world space.

[0004] To simulate the fog effect of the real Earth's atmospheric environment, since the Earth is a near-spherical shape and its surface is curved on a macroscopic scale, the Y-axis of Unity3D's world space cannot accurately calculate the impact of height on the fog effect, thus failing to accurately simulate a realistic fog effect. Summary of the Invention

[0005] The purpose of this application is to provide a method and apparatus for generating fog effect simulation images, thereby solving the problem of generating fog effect simulation images. The specific technical solution is as follows:

[0006] Firstly, a method for generating a fog effect simulation image is provided, the method comprising:

[0007] The original image is initially rendered using fog effect parameters to generate an initial fog effect image, wherein the fog effect parameters include altitude influence parameters;

[0008] Based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained by using the Unity world space coordinate to GPS space method.

[0009] An altitude factor is calculated based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, wherein the altitude factor can affect the fog effect intensity according to the altitude.

[0010] The altitude factor and the preset depth factor are calculated to obtain the mixed color;

[0011] The initial fog effect image is rendered using the mixed colors to generate a fog effect simulation image.

[0012] Optionally, the calculation of the altitude factor and the preset depth factor to obtain the mixed color includes:

[0013] Determine the view vector in world space from the perspective of the camera device;

[0014] Determine the light source vector in the world space, wherein the light source vector indicates the direction vector of the light source in the world space pointing to the world space coordinates of the pixel, and the light source is the sun;

[0015] The scattering intensity is obtained by using the Lambert illumination model based on the preset scattering index parameters, the viewpoint vector, and the light source vector.

[0016] The exp2 function is used to calculate the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color.

[0017] Optionally, based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained using the Unity world space coordinate to GPS space method, including:

[0018] The world space coordinates of the pixels are determined based on the texture map coordinates of the pixels in the initial fog effect image;

[0019] The world space coordinates of the pixel, the world space geocentric position passed in by the fog effect control script, and the map zoom level are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the pixel.

[0020] The preset world space coordinates of the shooting device, the world space geocentric position and map zoom level passed in by the fog effect control script are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the shooting device;

[0021] The pixel elevation information in GPS space is obtained based on the GPS spatial coordinates corresponding to the pixel, and the pixel elevation information of the shooting device in GPS space is obtained based on the GPS spatial coordinates corresponding to the shooting device.

[0022] Optionally, determining the world space coordinates of a pixel based on its texture map coordinates in the initial fog image includes:

[0023] Obtain the texture map coordinates of the pixels in the initial fog effect image;

[0024] The world space coordinates of the pixel are determined by converting the pixel space to world space position based on the pixel's texture map coordinates and the preset linear depth value of the pixel.

[0025] Optionally, the altitude factor is calculated based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, including:

[0026] Determine the altitude difference between the pixel altitude information and the shooting device altitude information;

[0027] Based on the altitude difference and the altitude influence parameters passed in from the fog effect control script, the altitude factor is calculated using the exp2 function.

[0028] Optionally, determining the view vector in world space from the perspective of the imaging device includes:

[0029] The view vector in world space, with the camera as the viewpoint, is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the camera device.

[0030] Optionally, determining the light source vector in the world space includes:

[0031] The direction vector from the light source to the pixel's world space coordinates is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the light source.

[0032] Optionally, using the Lambert illumination model, the scattering intensity is obtained based on preset scattering index parameters, the viewpoint vector, and the light source vector, including:

[0033] The dot product result is obtained by multiplying the viewpoint vector by the light source vector;

[0034] The scattering intensity is obtained by returning the dot product result and a specified power of the preset scattering index parameter.

[0035] Optionally, the calculation of the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color includes:

[0036] The exp2 function is used to perform preliminary calculations on the altitude factor, the preset depth factor, and the scattering intensity to obtain intermediate values;

[0037] The mixed color is obtained based on the source view color, the fog effect color and the light source color passed in by the fog effect script controller, and the intermediate value, wherein the source view color is the color of the original image.

[0038] Secondly, an apparatus for generating a fog effect simulation image is provided, the apparatus comprising:

[0039] The rendering module is used to perform preliminary rendering of the original image based on fog effect parameters to generate an initial fog effect image, wherein the fog effect parameters include altitude influence parameters;

[0040] The module is used to obtain the pixel elevation information in GPS space and the camera elevation information in GPS space based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, using the Unity world space coordinate to GPS space conversion method.

[0041] The first calculation module is used to calculate an altitude factor based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, wherein the altitude factor can affect the fog effect intensity based on altitude.

[0042] The second calculation module is used to calculate the altitude factor and the preset depth factor to obtain the mixed color;

[0043] The generation module is used to render the initial fog effect image using the mixed colors to generate a fog effect simulation image.

[0044] Thirdly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0045] Memory, used to store computer programs;

[0046] The processor, when executing a program stored in memory, implements any of the steps of the method for generating a fog effect simulation image.

[0047] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements any of the steps of the method for generating a fog effect simulation image.

[0048] Beneficial effects of the embodiments in this application:

[0049] This application provides a method for generating a fog effect simulation image. GPS coordinates are used to simulate the Earth environment. Therefore, altitude influence parameters are used in both the initial and subsequent rendering of the original image. The mixed colors are also obtained from pixel altitude information in GPS space and the altitude information of the shooting device. Considering the influence of altitude influence parameters and GPS space altitude information on the fog effect, this application, when simulating fog effects in a real Earth environment, considers that fog effects based on GPS coordinates can more realistically simulate the curved surface environment of the Earth. Therefore, altitude influence parameters and the altitude information of pixels and the shooting device are used, improving the realism and accuracy of the fog effect simulation image.

[0050] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 A schematic diagram of the hardware environment for a method of generating a fog effect simulated image provided in an embodiment of this application;

[0053] Figure 2 A flowchart illustrating a method for generating a fog effect simulation image, as provided in an embodiment of this application;

[0054] Figure 3 This is a schematic diagram of fog effects on the Earth's surface that does not consider the influence of altitude in existing technologies.

[0055] Figure 4 This is a schematic diagram of the Earth's surface fog effect affected by altitude, provided as an embodiment of this application.

[0056] Figure 5 A flowchart illustrating the method for calculating pixel elevation information and imaging device elevation information provided in this application embodiment;

[0057] Figure 6 This is a schematic diagram of fog effects without atmospheric scattering in existing technologies.

[0058] Figure 7 This is a schematic diagram of fog effects affected by atmospheric scattering, provided as an embodiment of this application.

[0059] Figure 8 A flowchart illustrating the process of generating a fog effect simulation image provided in an embodiment of this application;

[0060] Figure 9A schematic diagram of a device for generating a fog effect simulated image provided in an embodiment of this application;

[0061] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0062] 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.

[0063] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustration and has no specific meaning in itself. Therefore, "module" and "part" may be used interchangeably.

[0064] To address the problems mentioned in the background art, according to one aspect of the embodiments of this application, an embodiment of a method for generating a fog effect simulated image is provided.

[0065] Optionally, in the embodiments of this application, the above-described method for generating fog effect simulated images can be applied to, for example... Figure 1 The hardware environment shown consists of terminal 101 and imaging device 103. For example... Figure 1 As shown, a database 105 can be set up on or independently of terminal 101 to provide data storage services for terminal 101. Terminal 101 includes, but is not limited to, PC, tablet computer, etc.

[0066] A method for generating a fog effect simulation image in this embodiment can be executed by terminal 101 to generate a fog effect simulation image.

[0067] The following will describe in detail, with reference to specific embodiments, a method for generating a fog effect simulation image provided in this application, such as... Figure 2 As shown, the specific steps are as follows:

[0068] Step 201: Perform preliminary rendering of the original image using fog effect parameters to generate an initial fog effect image.

[0069] Among the fog effect parameters are altitude-related parameters.

[0070] The terminal acquires the original image from the shooting device, then transmits the preset fog effect parameters to the shader for fog effect calculation, renders and outputs the initial fog effect image.

[0071] The fog effect parameters include depth influence parameters, altitude influence parameters, scattering index parameters, and fog effect color. Specifically, these include: the current map zoom level (Scale), the world spatial Earth center coordinates (ObservationCenterPoint), the initial height parameter (HeightStart), the maximum height parameter (HeightEnd), the initial depth parameter (DepthStart), the maximum depth parameter (DepthEnd), the depth density factor (DepthDensit), the height density factor (HeightDensity), the fog effect color (FogColor), and the scattering index parameter (FogInscatteringExp).

[0072] The initial height parameter is the height of the horizon, the maximum height parameter is the maximum height parameter set by the technician, the initial depth parameter is the original depth of the image, the maximum depth parameter is the maximum depth parameter set by the technician, the depth density factor is the factor that affects the fog effect intensity due to depth, the height density factor is the factor that affects the fog effect intensity due to height, and the fog effect color is the set fog color.

[0073] Step 202: Based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained by using the Unity world space coordinate to GPS space conversion method.

[0074] The terminal obtains the world coordinates (worldPos) of the pixel based on the texture map coordinates (uv) of the pixel in the initial fog effect image. Then, it passes the worldPos, the world space geocentric position (the position of the Earth's center in world space) WorldSpaceEarthCenterPosition passed in from the fog effect control script, and the map zoom level Vmap Earth Scale as parameters to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates of the corresponding pixel, thereby obtaining the pixel altitude information (altitude) in GPS space.

[0075] The terminal obtains the preset world space coordinates of the shooting device, WorldSpaceCameraPos, and then passes WorldSpaceCameraPos, the world space geocenter position WorldSpaceEarthCenterPosition passed in the fog effect control script, and the map zoom level Vmap Earth Scale as parameters to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the shooting device, thereby obtaining the shooting device altitude information camAltitude in GPS space.

[0076] Step 203: Calculate the altitude factor based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information.

[0077] The altitude factor can affect the fog effect intensity based on altitude.

[0078] The terminal determines the altitude difference between the pixel altitude information and the altitude information of the shooting device, and combines it with altitude influence parameters to obtain the altitude factor (altitudeFactor). This altitude factor can influence the fog effect intensity based on altitude. The formula for calculating the altitude factor can use the exp2 function or other functions; this application does not impose any restrictions.

[0079] Step 204: Calculate the altitude factor and the preset depth factor to obtain the mixed color.

[0080] After obtaining the altitude factor, the terminal performs a mixing calculation by combining the preset depth factor, source view color, and fog effect color FogColor, which yields the mixed color. The source view color is the original color of the image.

[0081] Step 205: Render the initial fog effect image using the mixed colors to generate a fog effect simulation image.

[0082] The terminal uses the mixed color to render the initial fog effect image, generating a fog effect simulation image.

[0083] In this application, GPS coordinates are used to simulate the Earth environment. Therefore, fog effect parameters, including altitude influence parameters, are used to initially render the original image to generate an initial fog effect image. Then, the pixel altitude information of the pixels in GPS space and the camera altitude information of the camera device in GPS space are obtained. Based on the altitude influence parameters, the pixel altitude information and the camera altitude information, an altitude factor is obtained. Finally, the initial fog effect image is rendered using a mixed color calculated from the altitude factor and depth factor to generate a fog effect simulation image.

[0084] Figure 3 This is a schematic diagram of fog effects on the Earth's surface, without considering the influence of altitude. Figure 4 This is a schematic diagram illustrating the effects of altitude on the Earth's surface fog. As you can see, Figure 4 Fog efficiency Figure 3 More obvious.

[0085] This application uses GPS coordinates to simulate the Earth environment. Therefore, elevation influence parameters are used in both the initial rendering and subsequent rendering of the original image. The mixed colors are also obtained from the pixel elevation information and the elevation information of the shooting device in GPS space. Considering the influence of elevation influence parameters and GPS space elevation information on fog effects, this application uses elevation influence parameters and the elevation information of pixels and shooting devices when simulating fog effects in a real Earth environment. This improves the realism and accuracy of the fog effect simulation image.

[0086] As an optional implementation, the calculation of the altitude factor and the preset depth factor to obtain the mixed color includes: determining the view vector in world space from the perspective of the shooting device; determining the light source vector in the world space, wherein the light source vector indicates the direction vector of the light source in the world space pointing to the world space coordinates of the pixel, and the light source is the sun; using the Lambert illumination model, obtaining the scattering intensity based on the preset scattering index parameter, the view vector, and the light source vector; and using the exp2 function to calculate the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color.

[0087] The fog effect needs to take into account the scattering of the Earth's atmosphere, that is, the color mixing effect produced by the scattering of light sources (sunlight) in the real environment. Therefore, this application also incorporates scattering intensity to calculate the mixed colors produced by sunlight scattering, depth and altitude.

[0088] The terminal determines the view vector in world space from the perspective of the shooting device. Specifically, the view vector in world space from the perspective of the shooting device is obtained by subtracting the world space coordinates of the pixels from the world space coordinates of the shooting device.

[0089] The formula for calculating the view vector is: viewDir = WorldSpaceCameraPos - worldPos, where viewDir is the view vector, WorldSpaceCameraPos is the world space coordinate of the shooting device, and worldPos is the world space coordinate of the pixel.

[0090] The terminal determines the light source vector in the world space, which indicates the direction vector of the light source pointing to the world space coordinates of the pixel. The light source is the sun. Specifically, the direction vector of the light source pointing to the world space coordinates of the pixel is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the light source.

[0091] The formula for calculating the light source vector is: lightDir = worldSpaceLightPos - worldPos, where lightDir is the light source vector, worldSpaceLightPos is the world space coordinate of the light source, and worldPos is the world space coordinate of the pixel.

[0092] The terminal employs the Lambert lighting model to obtain the scattering intensity based on a preset scattering index parameter, the viewing angle vector, and the light source vector. Specifically, it multiplies the light source vector by the viewing angle vector to obtain the dot product; then, it returns the dot product result and a specified power of the preset scattering index parameter to obtain the scattering intensity.

[0093] The formula for calculating scattering intensity is: inscattering' = pow(dot(viewDir, lightDir), FogInscatteringExp), where dot is a dot product, that is, the view vector viewDir is multiplied by the light vector lightDir, and pow is the scattering exponent parameter FogInscatteringExp raised to the power of the dot product of the view vector and the light vector, which gives the scattering intensity inscattering'.

[0094] After obtaining the scattering intensity, the terminal uses the exp2 function to perform preliminary calculations on the altitude factor, the preset depth factor, and the scattering intensity to obtain intermediate values.

[0095] The formula for calculating the intermediate value is:

[0096] inscattering = inscattering' * (1 - saturate(exp2(altitudeFactor))) * depthFactor, where inscattering is the intermediate value, inscattering' is the scattering intensity, the saturate function returns 0 if the input value is less than 0, and 1 if the input value is greater than 1, altitudeFactor is the altitude factor, and depthFactor is the depth factor.

[0097] The mixed color is obtained based on the source view color, the fog effect color FogColor and the light source color LightColor passed in by the fog effect script controller, and the intermediate value, wherein the source view color is the color of the original image.

[0098] In this application, the scattering intensity caused by the Earth's atmosphere was also considered, and the light source color was incorporated when calculating the final mixed color, making the final mixed color more realistic and improving the realism and accuracy of the fog effect simulation image.

[0099] The calculation process for the preset depth factor is as follows:

[0100] Step 1: Calculate the screen space coordinates (scrPos) of the pixels in the initial fog image in the vertex shader. Specifically, use Unity's ComputeScreenPos method, passing in the pixel's position (pos) in clip space, to obtain and output the pixel's screen space coordinates (scrPos).

[0101] Step 2: Sample the camera depth map CameraDepthTexture using the pixel's screen space coordinates (scrPos) to obtain the pixel's depth value.

[0102] Specifically, the pixel's depth value is obtained by passing the pixel's screen space coordinates (scrPos) and a preset camera depth map (CameraDepthsTexture) to the Unity sampledepth method provided by Unity.

[0103] Step 3: Convert the depth value to a linear depth value in the range [0, 1] (linearDepth);

[0104] Specifically, the Linear01Depth method provided by Unity is used to convert the depth value into a linear depth value between 0 and 1, called linearDepth.

[0105] Step 4: Calculate the depth factor (depthFactor) by combining the linear depth value (linearDepth). There are three calculation methods:

[0106] The first type specifically refers to:

[0107] depthFactor=(DepthEnd-linearDepth) / (DepthEnd-DepthStart);

[0108] The first type is linear fog effect, which is obtained by performing a linear operation on the limit depth parameter DepthEnd and the initial depth parameter DepthStart.

[0109] The second type specifically refers to:

[0110] depthFactor=exp(-(curDepthDensity*linearDepth*ProjectionParams.z));

[0111] The second type is exponential fog, where the exp method is an exponential function with base e and input value as the exponent. Here, curDepthDensity = ((DepthDensity * 0.01) / Vmap Earth Scale), where curDepthDensity is an intermediate value, DepthDensity is the depth density factor, Vmap Earth Scale is the map zoom level, and ProjectionParams.z is the distance to the Unity camera's farplane (far section).

[0112] The third type specifically refers to:

[0113] depthFactor=exp(-pow(curDepthDensity*linearDepth*ProjectionParams.z, 2));

[0114] The third calculation is similar to the second, also involving exponential fog effects. pow is a function that returns a specified power of the input value, specifically the power of 2 of the value of curDepthDensity*linearDepth*ProjectionParams.z, which is then calculated using the exp2 function.

[0115] As an optional implementation method, such as Figure 5 As shown, based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained using the Unity world space coordinate to GPS space method, including:

[0116] Step 501: Determine the world space coordinates of the pixels based on the texture map coordinates of the pixels in the initial fog effect image.

[0117] The terminal obtains the texture map coordinates (uv) of the pixels in the initial fog effect image. Based on the texture map coordinates of the pixels and the preset linear depth value (linearDepth) of the pixels, the world space coordinates (worldPos) of the pixels are determined by a method of converting pixel space to world space position.

[0118] Step 502: Take the world space coordinates of the pixel, the world space geocentric position passed in by the fog effect control script, and the map zoom level, and pass them to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the pixel.

[0119] The terminal passes the pixel's Unity world space coordinates (worldPos), the world space geocenter position (WorldSpaceEarthCenterPosition) passed in from the fog effect control script, and the map zoom level (Vmap Earth Scale) as parameters to the Unity world space coordinate to GPS space method to obtain the corresponding pixel's GPS space coordinates (GPSPos).

[0120] Step 503: Input the preset world space coordinates of the shooting device, the world space geocentric position and map zoom level passed in by the fog effect control script, and input the method of converting Unity world space coordinates to GPS space to obtain the GPS space coordinates corresponding to the shooting device.

[0121] The terminal passes the world space coordinates of the shooting device (WorldSpaceCameraPos), the world space geocenter position (WorldSpaceEarthCenterPosition) passed in the fog effect control script, and the map zoom level (VmapEarthScale) as parameters to the Unity world space coordinate to GPS space conversion method to obtain the corresponding GPS space coordinates of the shooting device.

[0122] Step 504: Obtain the pixel elevation information in GPS space based on the GPS spatial coordinates corresponding to the pixel, and obtain the pixel elevation information of the shooting device in GPS space based on the GPS spatial coordinates corresponding to the shooting device.

[0123] The terminal obtains the pixel elevation information in GPS space based on the GPS spatial coordinates corresponding to the pixel, and obtains the pixel elevation information of the shooting device in GPS space based on the GPS spatial coordinates corresponding to the shooting device.

[0124] In this application, the method of converting Unity world space coordinates to GPS space is used to obtain the pixel elevation information of the pixel in GPS space and the pixel elevation information of the shooting device in GPS space by taking into account the geocentric position in world space and the map zoom level.

[0125] The terminal determines the altitude difference between the pixel altitude information and the shooting device altitude information. Based on the altitude difference and the altitude influence parameters passed from the fog effect control script, the terminal calculates the altitude factor using the exp2 function.

[0126] The formula for calculating the altitude factor is:

[0127] altitudeFactor'=FogFallOff*0.01*(altitude-camAltitude-(HeightEnd-HeightStart));

[0128] altitudeFactor=HeightDensity*exp2(altitudeFactor')

[0129] Where FogFallOff is the altitude attenuation parameter, altitude is the pixel altitude information, camAltitude is the shooting device altitude information, HeightEnd is the extreme altitude parameter, HeightStart is the initial altitude parameter, altitudeFactor' is the intermediate altitude factor, altitudeFactor is the altitude factor, HeightDesity is the altitude density factor, and exp2 is an exponential function with base 2 and the input value is the exponent.

[0130] Figure 6 This is a schematic diagram illustrating the fog effect without atmospheric scattering. Figure 7 This is a diagram illustrating the effect of fog on atmospheric scattering. As you can see, Figure 6 and Figure 7 The fog effect at the middle circle has a different color.

[0131] Optionally, embodiments of this application also provide a flowchart of the process for generating fog effect simulation images, such as... Figure 8 As shown, the specific steps are as follows.

[0132] Step 1: Pass the fog effect parameters to the specific shader via the script, and perform preliminary rendering of the original image using the fog effect parameters to generate the initial fog effect image;

[0133] Step 2: Calculate the depth factor of the fog effect based on the camera depth map and the screen space coordinates of the pixels;

[0134] Step 3: Based on the linear depth information and UV information corresponding to the pixels, obtain the world space coordinates of the pixels, determine the world space coordinates of the shooting device, and calculate the altitude factor of the fog effect.

[0135] Step 4: Calculate the scattering intensity of sunlight based on the light source vector and the viewing angle vector.

[0136] Step 5: Perform color mixing calculations using depth factor, altitude factor, and scattering intensity to obtain the fog color affected by sunlight.

[0137] Step 6 uses the mixed colors to render the initial fog effect image, generating a fog effect simulation image.

[0138] Based on the same technical concept, embodiments of this application also provide an apparatus for generating fog effect simulated images, such as... Figure 9 As shown, the device includes:

[0139] The rendering module 901 is used to perform preliminary rendering of the original image using fog effect parameters to generate an initial fog effect image, wherein the fog effect parameters include altitude influence parameters;

[0140] The module 902 is used to obtain the pixel elevation information in GPS space and the camera elevation information in GPS space based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, using the Unity world space coordinate to GPS space method.

[0141] The first calculation module 903 is used to calculate an altitude factor based on the altitude influence parameters, the pixel altitude information and the shooting device altitude information, wherein the altitude factor can affect the fog effect intensity based on the altitude.

[0142] The second calculation module 904 is used to calculate the altitude factor and the preset depth factor to obtain the mixed color;

[0143] The generation module 905 is used to render the initial fog effect image using the mixed colors to generate a fog effect simulation image.

[0144] Optionally, the second computing module 904 is used for:

[0145] Determine the view vector in world space from the perspective of the camera device;

[0146] Determine the light source vector in the world space, wherein the light source vector indicates the direction vector of the light source in the world space pointing to the world space coordinates of the pixel, and the light source is the sun;

[0147] The scattering intensity is obtained by using the Lambert illumination model based on the preset scattering index parameters, the viewpoint vector, and the light source vector.

[0148] The exp2 function is used to calculate the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color.

[0149] Optionally, module 902 is used for:

[0150] The world space coordinates of the pixels are determined based on the texture map coordinates of the pixels in the initial fog effect image;

[0151] The world space coordinates of the pixel, the world space geocentric position passed in by the fog effect control script, and the map zoom level are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the pixel.

[0152] The preset world space coordinates of the shooting device, the world space geocentric position and map zoom level passed in by the fog effect control script are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the shooting device;

[0153] The pixel elevation information in GPS space is obtained based on the GPS spatial coordinates corresponding to the pixel, and the pixel elevation information of the shooting device in GPS space is obtained based on the GPS spatial coordinates corresponding to the shooting device.

[0154] Optionally, module 902 is used for:

[0155] Obtain the texture map coordinates of the pixels in the initial fog effect image;

[0156] The world space coordinates of the pixel are determined by converting the pixel space to world space position based on the pixel's texture map coordinates and the preset linear depth value of the pixel.

[0157] Optionally, the first computing module 903 is used for:

[0158] Determine the altitude difference between the pixel altitude information and the shooting device altitude information;

[0159] Based on the altitude difference and the altitude influence parameters passed in from the fog effect control script, the altitude factor is calculated using the exp2 function.

[0160] Optionally, the second computing module 904 is used for:

[0161] The view vector in world space, with the camera as the viewpoint, is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the camera device.

[0162] Optionally, the second computing module 904 is used for:

[0163] The direction vector from the light source to the pixel's world space coordinates is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the light source.

[0164] Optionally, the second computing module 904 is used for:

[0165] The dot product result is obtained by multiplying the viewpoint vector by the light source vector;

[0166] The scattering intensity is obtained by returning the dot product result and a specified power of the preset scattering index parameter.

[0167] Optionally, the second computing module 904 is used for:

[0168] The exp2 function is used to perform preliminary calculations on the altitude factor, the preset depth factor, and the scattering intensity to obtain intermediate values;

[0169] The mixed color is obtained based on the source view color, the fog effect color and the light source color passed in by the fog effect script controller, and the intermediate value, wherein the source view color is the color of the original image.

[0170] According to another aspect of the embodiments of this application, this application provides an electronic device, such as... Figure 10 As shown, the system includes a memory 1003, a processor 1001, a communication interface 1002, and a communication bus 1004. The memory 1003 stores a computer program that can run on the processor 1001. The memory 1003 and the processor 1001 communicate through the communication interface 1002 and the communication bus 1004. When the processor 1001 executes the computer program, it implements the steps of the above method.

[0171] The memory and processor in the aforementioned electronic devices communicate with each other via a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0172] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0173] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0174] According to another aspect of the embodiments of this application, a computer-readable medium having processor-executable non-volatile program code is also provided.

[0175] Optionally, in embodiments of this application, the computer-readable medium is configured to store program code for the processor to execute the above-described method.

[0176] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0177] In specific implementation, the embodiments of this application can be referred to the above embodiments and have corresponding technical effects.

[0178] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0179] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0180] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0181] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0182] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0183] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0184] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0185] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further restrictions, the element defined by the phrase "including a method for generating a fog effect simulation image" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0186] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for generating a fog effect simulated image, characterized in that, The method includes: The original image is initially rendered using fog effect parameters to generate an initial fog effect image, wherein the fog effect parameters include altitude influence parameters; Based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained by using the Unity world space coordinate to GPS space method. An altitude factor is calculated based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, wherein the altitude factor can affect the fog effect intensity according to the altitude. The altitude factor and the preset depth factor are calculated to obtain the mixed color; The initial fog effect image is rendered using the mixed colors to generate a fog effect simulation image; The calculation of the altitude factor and the preset depth factor yields the following mixed colors: Determine the view vector in world space from the perspective of the camera device; Determine the light source vector in the world space, wherein the light source vector indicates the direction vector of the light source in the world space pointing to the world space coordinates of the pixel, and the light source is the sun; The scattering intensity is obtained by using the Lambert illumination model based on the preset scattering index parameters, the viewpoint vector, and the light source vector. The exp2 function is used to calculate the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color. Here, the exp2 function is an exponential function with base 2 and the input value is the exponent. The altitude factor, calculated based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, includes: Determine the altitude difference between the pixel altitude information and the shooting device altitude information; Based on the altitude difference and the altitude influence parameters passed in from the fog effect control script, the altitude factor is calculated using the exp2 function.

2. The method according to claim 1, characterized in that, Based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, the pixel elevation information in GPS space and the shooting device elevation information in GPS space are obtained using the Unity world space coordinate to GPS space method, including: The world space coordinates of the pixels are determined based on the texture map coordinates of the pixels in the initial fog effect image; The world space coordinates of the pixel, the world space geocentric position passed in by the fog effect control script, and the map zoom level are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the pixel. The preset world space coordinates of the shooting device, the world space geocentric position and map zoom level passed in by the fog effect control script are passed to the Unity world space coordinate to GPS space method to obtain the GPS space coordinates corresponding to the shooting device; The pixel elevation information in GPS space is obtained based on the GPS spatial coordinates corresponding to the pixel, and the pixel elevation information of the shooting device in GPS space is obtained based on the GPS spatial coordinates corresponding to the shooting device.

3. The method according to claim 2, characterized in that, Determining the world space coordinates of a pixel based on its texture map coordinates in the initial fog image includes: Obtain the texture map coordinates of the pixels in the initial fog effect image; The world space coordinates of the pixel are determined by converting the pixel space to world space position based on the pixel's texture map coordinates and the preset linear depth value of the pixel.

4. The method according to claim 1, characterized in that, Determining the view vector in world space from the perspective of the photographing device includes: The view vector in world space, with the camera as the viewpoint, is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the camera device.

5. The method according to claim 1, characterized in that, Determining the light source vector in the world space includes: The direction vector from the light source to the pixel's world space coordinates is obtained by subtracting the world space coordinates of the pixel from the world space coordinates of the light source.

6. The method according to claim 1, characterized in that, Using the Lambert illumination model, based on preset scattering index parameters, the viewpoint vector, and the light source vector, the scattering intensity is obtained as follows: The dot product result is obtained by multiplying the viewpoint vector by the light source vector. The scattering intensity is obtained by returning the dot product result and a specified power of the preset scattering exponent parameter.

7. The method according to claim 1, characterized in that, The calculation of the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color includes: The exp2 function is used to perform preliminary calculations on the altitude factor, the preset depth factor, and the scattering intensity to obtain intermediate values; The mixed color is obtained based on the source view color, the fog effect color and the light source color passed in by the fog effect script controller, and the intermediate value, wherein the source view color is the color of the original image.

8. A device for generating a fog effect simulated image, characterized in that, The device includes: The rendering module is used to perform preliminary rendering of the original image based on fog effect parameters to generate an initial fog effect image, wherein the fog effect parameters include altitude influence parameters; The module is used to obtain the pixel elevation information in GPS space and the camera elevation information in GPS space based on the texture map coordinates of the pixels in the initial fog effect image and the preset coordinates of the shooting device in world space, using the Unity world space coordinate to GPS space conversion method. The first calculation module is used to calculate an altitude factor based on the altitude influence parameters, the pixel altitude information, and the shooting device altitude information, wherein the altitude factor can affect the fog effect intensity based on altitude. The second calculation module is used to calculate the altitude factor and the preset depth factor to obtain the mixed color; A generation module is used to render the initial fog effect image using the mixed colors to generate a fog effect simulation image; The second calculation module is used for: Determine the view vector in world space from the perspective of the camera device; Determine the light source vector in the world space, wherein the light source vector indicates the direction vector of the light source in the world space pointing to the world space coordinates of the pixel, and the light source is the sun; The scattering intensity is obtained by using the Lambert illumination model based on the preset scattering index parameters, the viewpoint vector, and the light source vector. The exp2 function is used to calculate the altitude factor, the preset depth factor, and the scattering intensity to obtain the mixed color. Here, the exp2 function is an exponential function with base 2 and the input value is the exponent. The first calculation module is used for: Determine the altitude difference between the pixel altitude information and the shooting device altitude information; Based on the altitude difference and the altitude influence parameters passed in from the fog effect control script, the altitude factor is calculated using the exp2 function.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-7.