Three-dimensional scene sky rendering method, system and device and medium
By constructing atmospheric scattering and sky view lookup tables, and calculating light source color and brightness in real time, the accuracy problem of dynamic sky rendering in 3D scenes is solved, and the consistency of lighting and spatial depth are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies cannot accurately simulate dynamic sky effects in 3D scenes, resulting in insufficient visual uniformity and immersion, especially in the simulation of complex atmospheric phenomena such as sunset and twilight.
By constructing atmospheric scattering lookup tables and sky view lookup tables, the modulation factor of light source color and sky radiance are calculated in real time. Combined with atmospheric perspective lookup tables for rendering, the consistency of lighting conditions and spatial depth are ensured.
It achieves consistency in lighting conditions for the sky, objects, and clouds in a 3D scene, enhancing the sense of spatial depth and visual unity, and simulating a realistic dynamic sky effect.
Smart Images

Figure CN121810902A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of 3D rendering, and more particularly to a method, system, device, and medium for rendering the sky in a 3D scene. Background Technology
[0002] In browser-based 3D applications (such as digital twins, virtual cities, and online visualizations), the key to achieving visual immersion and spatial awareness lies in constructing a physically accurate and believable environment. Accurate sky rendering faithfully reflects the sun's position and the passage of time through dynamic color changes (such as from midday blue to dusk crimson); it suggests object distance through precise atmospheric perspective (i.e., the farther away an object is, the more blurred its outline and the more its color shifts towards atmospheric diffused light), creating a realistic sense of spatial depth; simultaneously, it provides a unified and harmonious lighting and color foundation for all atmospheric components such as clouds and fog. Therefore, achieving physically accurate sky rendering in 3D scenes is a decisive factor in enhancing environmental realism and ensuring the consistency and immersion of visual elements.
[0003] Common implementations often employ simple color gradients or static sky textures. While this method has extremely low performance overhead, its predefined and fixed color changes prevent dynamic calculation and response based on physical parameters such as solar altitude angle and atmospheric density. This results in an inability to accurately simulate complex atmospheric phenomena like sunsets and twilight. More importantly, this non-physical approximation method becomes disconnected from physically rendered objects and dynamically illuminated elements like volumetric clouds in the scene, disrupting the scene's visual unity. Ultimately, this approach sacrifices dynamic accuracy and physical consistency in sky rendering, failing to meet the stringent realism and immersive requirements of high-end 3D applications. Summary of the Invention
[0004] This invention provides a method, system, device, and medium for rendering the sky in a three-dimensional scene, which can achieve accurate dynamic rendering of the sky in a three-dimensional scene.
[0005] An embodiment of the present invention provides a method for rendering the sky in a three-dimensional scene, comprising:
[0006] Obtain the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction;
[0007] Based on the direction of the light source, the transmittance value of sunlight in the atmosphere is looked up from a preset atmospheric scattering lookup table. A color modulation factor is calculated based on the transmittance value, and the color of the light source is adjusted using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters.
[0008] Based on the light source direction and the camera parameters, the sky radiance is retrieved from a preset sky view lookup table for rendering to obtain a first rendering result. Then, the target light source color is used to render the scene materials and clouds in the 3D scene of the first rendering result to obtain a second rendering result. Finally, based on a preset atmospheric perspective lookup table, the scene objects in the second rendering result are subjected to color attenuation and diffused light mixing to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
[0009] This invention constructs an atmospheric scattering lookup table to facilitate the subsequent acquisition of corresponding projection probability values based on different light source directions, ensuring accurate and realistic reproduction of light and color phenomena. The transmittance values obtained by querying the atmospheric scattering lookup table accurately reflect the spectral attenuation of sunlight after passing through an atmosphere of specific thickness and composition, ensuring a solid physical basis for light source color modulation and enabling accurate and realistic reproduction of light and color phenomena. By sampling the sky view lookup table in real time, the sky color and brightness precisely corresponding to the current sun position and viewing angle can be obtained instantly, facilitating the realistic rendering of dynamic effects such as blue skies and sunsets. The target light source color (not the original white light) is used to illuminate the field. The scene materials and clouds in the background ensure that the lighting conditions of these scene elements are consistent with the lighting conditions of the sky background, fundamentally solving the problem of the disconnect between the lighting of the sky, objects, and clouds in traditional methods, and achieving visual physical consistency. By consulting the atmospheric perspective lookup table and applying precise color attenuation and scattered light superposition according to the actual distance of the objects, a realistic atmospheric perspective effect can be simulated. This not only enhances the spatial depth of the image, but also unifies the visual representation of scene objects with the current atmospheric state (determined by the sky rendering), completing a seamless and accurate spatial information transmission from the sky to the ground. Compared with existing technologies, this application can achieve accurate dynamic rendering of the sky in a 3D scene.
[0010] Further, the step of looking up the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the direction of the light source includes:
[0011] Calculate the height of the observation point position, wherein the camera parameters include the observation point position;
[0012] Calculate the dot product of the light source direction and the observation point position to obtain the zenith angle cosine value. Based on the zenith angle cosine value and the height, calculate the texture coordinates.
[0013] The transmittance value is obtained by looking up the information in the atmospheric scattering lookup table based on the texture coordinates.
[0014] The transmittance value obtained by consulting the atmospheric scattering lookup table accurately reflects the spectral attenuation of sunlight after passing through an atmosphere of specific thickness and composition, ensuring that the color modulation of the light source has a solid physical basis and can accurately reproduce the true color phenomena of light.
[0015] Furthermore, adjusting the light source color using the color modulation factor to obtain the modulated target light source color includes: calculating the scaling vector of each channel based on the color modulation factor, and multiplying the scaling vector with the light source color in each channel to obtain the modulated target light source color.
[0016] This process of transforming abstract atmospheric physical data into specific lighting instructions ensures that the color of sunlight accurately reflects the current atmospheric state, thus providing a dynamic and physically correct reference lighting for the entire scene, which is key to achieving visual uniformity.
[0017] Further, the step of retrieving the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters for rendering, to obtain a first rendering result, includes:
[0018] Determine the direction vector based on the location of the observation point;
[0019] The line-of-sight elevation angle is calculated based on the line-of-sight direction and the direction vector, wherein the camera parameters include the line-of-sight direction;
[0020] The azimuth angle is calculated based on the line of sight, the direction vector, and the light source direction. The line of sight elevation angle and the azimuth angle are then mapped to the texture coordinates of the sky view lookup table. The sky radiance is then sampled from the sky view lookup table based on the texture coordinates for rendering.
[0021] By sampling the sky view lookup table in real time, the sky color and brightness can be obtained instantly with a precise correspondence between the current sun position and the viewing angle, making it convenient to realistically render dynamic effects such as blue skies and sunsets.
[0022] Further, the step of using the target light source color to perform scene material rendering and cloud / fog rendering on the 3D scene in the first rendering result to obtain a second rendering result includes:
[0023] The target light source color is input into the physical rendering model to calculate the diffuse and specular components of scene objects, and atmospheric correction material rendering results are determined based on the diffuse and specular components.
[0024] The cloud and fog in the first rendering result are rendered based on the target light source color to obtain a cloud and fog rendering result, and a second rendering result is determined based on the material rendering result and the cloud and fog rendering result.
[0025] By using a unified light source color modulated by the atmosphere to drive the physical rendering model and cloud rendering, it is ensured that the lighting conditions of objects and clouds in the scene are completely consistent with the physical state of the sky background. This fundamentally solves the problem of the disconnect and visual fragmentation of lighting among the sky, objects and clouds in traditional methods, and achieves deep integration and visual unity of scene elements and atmospheric environment.
[0026] Furthermore, the sky rendering result is obtained by performing color attenuation and diffuse light mixing on the scene objects in the second rendering result based on a preset atmospheric perspective lookup table, including:
[0027] Obtain the scene color map and scene depth map corresponding to the second rendering result;
[0028] The scene depth map is preprocessed by a neighborhood minimization operation to obtain a depth processing result, and the actual distance is determined based on the depth processing result.
[0029] Based on the actual distance, the air transmittance and scattered incident light are retrieved from the air perspective lookup table;
[0030] The intensity of the scattered incident light is corrected using the color of the target light source to obtain a correction result. The scene color map is multiplied by the air transmittance to obtain a multiplication result. The multiplication result is then added to the correction result to obtain the sky rendering result.
[0031] By consulting an atmospheric perspective lookup table and applying precise color attenuation and diffused light overlay based on the actual distance of objects, a realistic atmospheric perspective effect can be simulated. This not only enhances the spatial depth of the image but also unifies the visual representation of objects in the scene with the current atmospheric state (determined by the sky rendering), achieving a seamless and accurate transfer of spatial information from the sky to the ground.
[0032] Furthermore, the atmospheric scattering lookup table includes a transmittance lookup table and a multiple scattering lookup table. The atmospheric scattering lookup table is constructed based on atmospheric physical and geometric parameters, including:
[0033] Based on the geometric parameters, a mapping relationship is established between the initial texture coordinates, the initial observation point height, and the initial light source direction. For the initial texture coordinates, a path is determined to pass through the atmosphere from the observation point along the initial light source direction.
[0034] The path is discretized into several step sizes, and the extinction coefficient corresponding to the sampling point of each step size is calculated based on atmospheric physical parameters.
[0035] Based on the extinction coefficients of all the stated step sizes, the initial transmittance of the entire path is calculated by integration, and the transmittance lookup table is obtained based on the initial transmittance.
[0036] Another embodiment of the present invention provides a sky rendering system for a three-dimensional scene, including: an acquisition module, a modulation module and a rendering module;
[0037] The acquisition module is used to acquire the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction;
[0038] The modulation module is used to look up the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the direction of the light source, calculate the color modulation factor based on the transmittance value, and adjust the color of the light source using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters.
[0039] The rendering module is used to look up the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters to perform rendering, thereby obtaining a first rendering result. It then uses the target light source color to perform scene material rendering and cloud / fog rendering on the 3D scene in the first rendering result to obtain a second rendering result. Finally, it performs color attenuation and diffused light mixing on the scene objects in the second rendering result based on a preset atmospheric perspective lookup table to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
[0040] Another embodiment of the present invention provides a terminal device, including: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, it implements the steps of the sky rendering method for a three-dimensional scene as described in the present invention.
[0041] Another embodiment of the present invention also provides a computer-readable storage medium item, including: a stored computer program, which, when the computer program is running, controls the device where the computer-readable storage medium is located to perform steps such as the sky rendering method of the three-dimensional scene of the present invention. Attached Figure Description
[0042] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 This is a flowchart illustrating an embodiment of the sky rendering method for a 3D scene provided in this application;
[0044] Figure 2 This is a flowchart illustrating one embodiment of steps S201 to S203 provided in this application;
[0045] Figure 3 This is a flowchart illustrating one embodiment of steps S301 to S303 provided in this application;
[0046] Figure 4 This is a flowchart illustrating one embodiment of steps S401 to S402 provided in this application;
[0047] Figure 5 This is a flowchart illustrating one embodiment of steps S501 to S504 provided in this application;
[0048] Figure 6 This is a structural schematic diagram of one embodiment of the sky rendering system for a three-dimensional scene provided in this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. 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.
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0051] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0052] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0053] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0054] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0055] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0056] In browser-based 3D applications, physically accurate sky rendering is crucial for creating immersion and a sense of spatial depth. It needs to dynamically respond to the sun's position, realistically simulate color changes such as sunset glow and twilight, and use atmospheric perspective to represent object distances, while providing a unified lighting basis for elements like clouds and fog. Existing solutions often use static sky maps or color gradients, which, while having low performance overhead, have fixed colors and cannot dynamically respond to physical parameters, making it difficult to accurately simulate complex atmospheric phenomena.
[0057] See Figure 1To achieve accurate dynamic rendering of the sky in a three-dimensional scene, an embodiment of the present invention provides a method for rendering the sky in a three-dimensional scene, including steps S101 to S103.
[0058] Step S101: Obtain the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction;
[0059] In some embodiments, the light source parameters are obtained by: combining the simulated world time (e.g., daytime, in hours) with a preset solar azimuth Rad, and calculating using a formula. Determine the solar polar angle, and then use the direction vector formula. The normalized direction of the light source is calculated, and once the direction vector is obtained, the direction of the light source can be determined. The color of the light source is usually initialized as white light or a reference spectrum based on a physical model, and its final color will be dynamically corrected through subsequent atmospheric modulation steps.
[0060] In some embodiments, camera parameters are derived directly from the real-time state of the WebGL rendering engine: the camera position (cameraPos) is the three-dimensional coordinates of the observer in world space, determined by the engine's view matrix; the camera orientation (cameraDir) is the forward vector calculated from the camera position and the target point, or extracted directly from the view matrix.
[0061] Step S102: Based on the direction of the light source, look up the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table, calculate the color modulation factor based on the transmittance value, and adjust the color of the light source using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters.
[0062] Please refer to Figure 2 In some embodiments, the atmospheric scattering lookup table includes a transmittance lookup table and a multiple scattering lookup table. The atmospheric scattering lookup table is constructed based on atmospheric physical and geometric parameters, including steps S201 to S203:
[0063] Step S201: Based on the geometric parameters, establish a mapping relationship between the initial texture coordinates, the initial observation point height, and the initial light source direction. For the initial texture coordinates, determine the path from the observation point through the atmosphere along the initial light source direction.
[0064] In some embodiments, firstly, geometric parameters, including the Earth's radius and the radius of the top of the atmosphere, need to be obtained. Then, initial texture coordinates are determined based on these geometric parameters. Next, for each texture coordinate (u, v), the observation point position is defined as P(v) = (0, h(v), 0), and the light source direction is defined as d(u) = normalize(0, cosθ, -sinθ), thus establishing a mapping relationship from texture coordinates to the physical space observation point and the light source direction. Finally, a path through the atmosphere from the observation point along the light source direction is determined based on this mapping relationship. This path is obtained by judging the intersection of light rays with the atmosphere, ensuring that the starting point of the path is the observation point and the ending point is the atmospheric boundary.
[0065] It should be noted that the Earth's effective radius R_ground, also known as the Earth's effective radius, is set to 6360.0 km. This value is used to determine the boundary of the lower atmosphere, which usually corresponds to sea level. R_top is the radius of the upper atmosphere, set to 6420.0 km. This value defines the outermost boundary of the atmosphere in the calculation.
[0066] It should be noted that the initial texture coordinates are obtained through normalization calculation: For LUT size Res=(W,H)=(256,32), pixel coordinates (x,y), where x∈{0,…,W-1}, y∈{0,…,H-1}, the normalized coordinates of the pixel center are: Where u corresponds to the cosine of the zenith angle (cosθ = 2u - 1, θ is the angle between the direction of the light source and the radial direction), and v corresponds to the height of the observation point (h(v) = (1-v)*R_ground + v*R_top, where R_ground and R_top are the Earth's radius and the radius of the top of the atmosphere, respectively).
[0067] Step S202: Discretize the path into several step lengths, and calculate the extinction coefficient corresponding to the sampling point of each step length based on atmospheric physical parameters;
[0068] In some embodiments, firstly, after the path is determined, it is discretized into N step sizes (e.g., N = 40) for numerical integration; then, for each step size i, the sampling point position is calculated as s_i = p_obs + t_i * d_sun, where t_i is the step size parameter, p_obs is the starting position of the observation point, and d_sun is the unit vector in the solar direction; subsequently, since atmospheric physical parameters include Rayleigh scattering coefficient, Mie scattering coefficient, and ozone absorption coefficient, the extinction coefficient ε(s_i) at sampling point s_i can be calculated based on these atmospheric physical parameters, using the following formula: In the formula, ∈ RayleighScat Let be the Rayleigh scattering extinction coefficient, ∈ MieScat The extinction coefficient of Mie scattering, ∈ RayleighAbs Let be the Rayleigh absorption coefficient, ∈MieAbs ε is the Mie extinction coefficient, and ε_OzoneAbs is the ozone extinction coefficient.
[0069] In some embodiments, the formulas for calculating the Rayleigh scattering extinction coefficient and the Rayleigh absorption coefficient are as follows:
[0070]
[0071] Where H R = gEarthRayleighScaleHeight, where gEarthRayleighScaleHeight is the Rayleigh scattering scaling factor, set to 0.0331. This value is used to normalize the intensity of Rayleigh scattering. RayleighScatteringScale is the wavelength-dependent intensity of Rayleigh scattering, set to vec3(0.005802f, 0.013558f, 0.033100f). This vector represents the scattering intensity for the red, green, and blue color channels, reflecting the physical phenomenon that shorter wavelength (blue) light is more easily scattered by air molecules than longer wavelength (red) light; RayleighAbsorptionScale is the Rayleigh absorption intensity, set to 0.0. In the current implementation, it is assumed that the effect of Rayleigh absorption on transmittance is negligible.
[0072] In some embodiments, the formulas for the Mie scattering extinction coefficient and the Mie absorption extinction coefficient are as follows:
[0073]
[0074] Where H M =gEarthMieScaleHeight, where gMieScatteringScale is the scaling factor for Mie scattering, set to 1.0. This value is used to adjust the overall intensity of Mie scattering. MieAbsorptionScale is the scaling factor for Mie absorption, set to 1.0. This value is used to adjust the overall intensity of Mie absorption.
[0075] In some embodiments, the formula for calculating the ozone absorption extinction coefficient is as follows: This vector reflects the ozone layer's absorption intensity of light at different wavelengths, with the strongest absorption of green light and the weakest absorption of blue light. The parameters 25.0 and 15.0 together define an effective ozone absorption model centered at 25 kilometers and extending within a 15-kilometer radius above and below it, with the intensity decreasing linearly. A calculation result of 0 indicates that ozone absorption can be disregarded.
[0076] Step S203: Based on the extinction coefficients of all the said step lengths, calculate the initial transmittance of the entire path by integration, and obtain the transmittance lookup table based on the initial transmittance.
[0077] In some embodiments, the initial transmittance of the entire path is calculated by integration based on the extinction coefficients of all step sizes, thereby obtaining a transmittance lookup table. Here, transmittance T(P(v),d(u)) represents the transmittance of light rays from the observation point along the solar direction, approximated using discrete integration: T(P(v),d(u))≈∏_{i=0}^{N-1}exp(-ε(s_i)×Δt_i), where Δt_i is the length of the i-th step size (if equal step sizes are used, then Δt_i=L / N, where L is the total path length). This formula accumulates the initial transmittance of the entire path by multiplying the transmittance of each step size (i.e., exp(-ε(s_i)×Δt_i)). After calculation, the initial transmittance is stored at the corresponding texture coordinates (u,v) in the transmittance lookup table, forming the final transmittance lookup table. This lookup table is used for quickly querying solar transmittance in real-time rendering, avoiding repeated calculations of complex integrals.
[0078] In some embodiments, the construction process of the multi-scattering texture lookup table is as follows: First, to simulate the contribution of light to sky brightness after multiple scatterings in the atmosphere, this method adopts an importance sampling strategy, discretizing the hemisphere into sqrtSamples×sqrtSamples (8*8) grids, and generating a representative sub-direction vector for each grid. This direction is calculated using spherical coordinate formulas: Zenith angle and azimuth And convert it to a Cartesian coordinate vector. Next, for each sub-direction Discrete integration is performed along its path, dividing the path into multiple step sizes Δt, with each step size position... Calculate the extinction coefficient at this point. (The calculation method is consistent with the transmittance lookup table, and is the sum of Rayleigh scattering, Mie scattering, Rayleigh absorption, Mie absorption, and ozone absorption coefficients), and the step-size transmittance is calculated. At the same time, the location along the solar direction can be quickly retrieved using a pre-calculated transmittance lookup table. The incident light intensity is calculated, and the contribution of internal scattered light is calculated by combining the Rayleigh phase function and the Mie phase function. Then, the total brightness and the multiple scattering factor are accumulated. Finally, the total brightness is calculated and multiplied by empirical parameters to obtain the final storage value, thereby constructing a multiple scattering texture lookup table.
[0079] In some embodiments, the step of searching for the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the light source direction includes: calculating the height of the observation point position, wherein the camera parameters include the observation point position; calculating the dot product of the light source direction and the observation point position to obtain the zenith angle cosine value; calculating texture coordinates based on the zenith angle cosine value and the height; and searching for the transmittance value from the atmospheric scattering lookup table based on the texture coordinates. Specifically, firstly, the observation point position p in the camera parameters is obtained, and the height of the observation point position is calculated. That is, the distance of the observation point relative to the Earth's center; then, calculate the unit direction vector between the light source direction and the observation point position. The dot product of these two values yields the cosine value of the zenith angle, μ = d. sun ·u. Next, based on the cosine value of the zenith angle μ and the height The texture coordinates (u,v) are calculated, where u is normalized to the range [0,1] using the clamp function, i.e., u = clamp(0.5 + 0.5μ, 0.0, 1.0); and v is obtained by mapping the height h to the relative height of the atmosphere. Finally, based on the calculated texture coordinates (u,v), the transmittance value T(u,v) of sunlight in the atmosphere is obtained by sampling from a pre-defined atmospheric scattering lookup table (Transmittance LUT), calculated as: T(P,V) = exp(-∫σ t (h)ds), where σ t (h) represents the total extinction coefficient at height h.
[0080] It should be noted that each pixel in a LUT stores: That is, from a spatial point Along the direction of the sun The transmittance at time L is the transmissivity reflected from space to a spatial point. In the integration, whenever L is needed... in In this case, simply look up the table: This avoids repeating expensive path integral calculations during multiscattering.
[0081] The transmittance value obtained by consulting the atmospheric scattering lookup table accurately reflects the spectral attenuation of sunlight after passing through an atmosphere of specific thickness and composition, ensuring that the color modulation of the light source has a solid physical basis and can accurately reproduce the true color phenomena of light.
[0082] In some embodiments, the color modulation factor is calculated based on the transmittance value. Once the transmittance value is obtained, it can be directly defined as the color modulation factor. That is, the transmittance vector T itself is a channel-by-channel (RGB) scaling factor, which quantifies the filtering and attenuation effect of the atmosphere on the original solar spectrum. For example, at dusk, as light passes through a thicker layer of atmosphere, short-wavelength blue light is scattered in large quantities, resulting in a significant decrease in the transmittance of the blue channel, while the transmittance of the red channel is relatively high, thus making the modulated light color reddish.
[0083] In some embodiments, adjusting the light source color using the color modulation factor to obtain the modulated target light source color includes: calculating the scaling vector of each channel based on the color modulation factor, and multiplying the scaling vector with the light source color in each channel to obtain the modulated target light source color. Specifically, firstly, after obtaining the air permeability value, the calculated transmittance vector T (i.e., the color modulation factor, as the scaling vector) is multiplied channel by channel (i.e., R, G, and B channels respectively) with the original solar light source color vector S to obtain the modulated target light source color S′, which accurately reflects the true color of sunlight reaching the scene under current atmospheric conditions. For example, at a clear noon, S′ is close to white; while at sunset, S′ will show a warm orange-red hue.
[0084] This process of transforming abstract atmospheric physical data into specific lighting instructions ensures that the color of sunlight accurately reflects the current atmospheric state, thus providing a dynamic and physically correct reference lighting for the entire scene, which is key to achieving visual uniformity.
[0085] Step S103: Based on the light source direction and the camera parameters, the sky radiance is retrieved from a preset sky view lookup table for rendering to obtain a first rendering result. The target light source color is used to render the scene materials and clouds in the three-dimensional scene of the first rendering result to obtain a second rendering result. Based on a preset atmospheric perspective lookup table, the scene objects in the second rendering result are subjected to color attenuation and diffused light mixing to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
[0086] It should be noted that the sky view lookup table is generated based on the atmospheric scattering lookup table. Specifically, it uses a pre-calculated transmittance texture lookup table (TLUT) and multi-scattering texture lookup table (multi-Scattering LUT) as inputs, and synthesizes the final sky view through a ray step integration algorithm. The specific generation process includes: First, determining the propagation path of light in the atmosphere and the maximum integration distance based on the camera position and the line-of-sight direction mapped from pixel coordinates; then, discretizing the path into multiple step sizes, and for each step size's sampling point, obtaining the direct light transmittance from that point to the sun by querying the transmittance texture lookup table, and simultaneously querying the multi-scattering texture lookup table to obtain the sky brightness contribution of that point due to multiple scattering; then, combining the atmospheric extinction coefficient and phase function of the current step size, calculating the contribution of that step size to single scattering and multiple scattering, and multiplying it by the cumulative transmittance from the camera to the current sampling point to obtain the increment of the final brightness for that step size; finally, accumulating the brightness increments of all steps to obtain the total sky radiance along the line-of-sight direction, and storing it in the corresponding texture coordinates of the sky view lookup table. This method efficiently aggregates data from the transmittance lookup table and the multiple scattering lookup table, enabling high-precision, real-time simulation of complex sky phenomena that include single scattering, multiple scattering, and contributions from surface reflection.
[0087] Please refer to Figure 3 In some embodiments, the step of looking up the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters to perform rendering and obtain a first rendering result includes: steps S301 to S303.
[0088] Step S301: Determine the direction vector based on the position of the observation point;
[0089] In some embodiments, given the observation point position P (obtained from camera parameters, in kilometers or meters), the direction vector u is obtained by normalizing the observation point position:
[0090] Step S302: Calculate the viewing elevation angle based on the viewing direction and the direction vector, wherein the camera parameters include the viewing direction;
[0091] In some embodiments, firstly, the observation point height h and the Earth's radius R are combined. earth Calculate the horizon angle θ h The calculation formula is: Then, combined with the horizon angle θ h With line of sight The line-of-sight elevation angle θ is calculated. alt The calculation formula is: In the formula, the direction of the line of sight is The normal direction is the observation point.
[0092] Step S303: Calculate the azimuth angle based on the line of sight, the direction vector, and the light source direction, and map the line of sight elevation angle and the azimuth angle to the texture coordinates of the sky view lookup table. Sample the sky radiance from the sky view lookup table based on the texture coordinates for rendering.
[0093] In some embodiments, the direction of the line of sight is first considered. Calculate the azimuth angle using the direction vector u and the light source direction dsun. And construct a local coordinate system Next, the line of sight is projected onto the tangent plane (perpendicular to the direction vector u) and normalized to obtain the projection vector. Then, the components of the projection vector in the local coordinate system are calculated, from which the azimuth angle can be obtained. Finally, the line-of-sight elevation angle θ alt and azimuth θ azi By mapping the texture coordinates to the sky view lookup table and sampling from the sky view lookup table based on the texture coordinates, the sky radiance (stored as RGB values) can be obtained, which is used to render the dynamic sky in real time to form the first rendering result.
[0094] It should be noted that the mapped texture coordinates are: Where, in |θ alt In the near-perpendicular case of |→π / 2, let θ azi =0, to avoid singularities.
[0095] It should be noted that, Derived from the camera projection process: pixel coordinates are first mapped to normalized device coordinates (NDC), and then combined with the camera's main viewing direction and view frustum geometry parameters (dir, right, up, s_w, s_h) to normalize and obtain the viewing direction in world space.
[0096] By sampling the sky view lookup table in real time, the sky color and brightness can be obtained instantly with a precise correspondence between the current sun position and the viewing angle, making it convenient to realistically render dynamic effects such as blue skies and sunsets.
[0097] Please refer to Figure 4 In some embodiments, the step of using the target light source color to perform scene material rendering and cloud and fog rendering on the three-dimensional scene in the first rendering result to obtain the second rendering result includes steps S401 to S402.
[0098] Step S401: Input the target light source color into the physical rendering model to calculate the diffuse and specular components of the scene objects, and determine the atmospheric correction material rendering result based on the diffuse and specular components.
[0099] In some embodiments, the atmospherically corrected target light source color is used as the primary directional light source input in the Physically Based Rendering (PBR) model. This light source color already incorporates the spectral effects of atmospheric scattering. In the PBR shading calculation, this target light source color is used to calculate the diffuse and specular components of scene objects, respectively. The diffuse component is calculated using a Lambertian model, and the specular component is calculated using a physically based BRDF model, thereby obtaining a material rendering result with consistent color under the influence of the atmospheric environment.
[0100] In some embodiments, the calculation process for the diffuse reflection component is as follows: Where σ λ (r) represents the optical thickness of the atmosphere at position r with respect to wavelength λ, and L represents the ray path length. This process can be pre-calculated offline for generating LUTs or volumetric scattering maps.
[0101] Step S402: Render the clouds and fog in the first rendering result based on the target light source color to obtain a cloud and fog rendering result, and determine a second rendering result based on the material rendering result and the cloud and fog rendering result.
[0102] In some embodiments, the same set of atmospherically corrected target light source colors is used to drive the rendering calculations of clouds and fog, ensuring that the color representation of clouds and fog maintains physical consistency with the sky background and scene materials. For the rendering of clouds and fog, a density field can be generated using a noise function and combined with illumination integral to represent dynamic clouds, or a depth-based fog effect model can be used. However, the core is to use a unified target light source color as the lighting input for clouds and fog, so that clouds and fog naturally present the same changes in glow and shadow as the sky at different sun altitudes, thereby eliminating the sense of disjointedness in the image and ensuring the color unity of all elements in the scene.
[0103] By using a unified light source color modulated by the atmosphere to drive the physical rendering model and cloud rendering, it is ensured that the lighting conditions of objects and clouds in the scene are completely consistent with the physical state of the sky background. This fundamentally solves the problem of the disconnect and visual fragmentation of lighting among the sky, objects and clouds in traditional methods, and achieves deep integration and visual unity of scene elements and atmospheric environment.
[0104] Please refer to Figure 5 In some embodiments, the scene objects in the second rendering result are subjected to color attenuation and scattered light mixing based on a preset atmospheric perspective lookup table to obtain a sky rendering result, including steps S501 to S504.
[0105] Step S501: Obtain the scene color map and scene depth map corresponding to the second rendering result;
[0106] In some embodiments, the scene color map C corresponding to the second rendering result is obtained. scene and scene depth map D scene The scene color map contains the original rendered colors of all objects in the 3D scene, while the scene depth map records the view depth information corresponding to each pixel, which is the basis for subsequent calculations of atmospheric perspective effects.
[0107] Step S502: Perform depth preprocessing on the scene depth map through a neighborhood minimization operation to obtain a depth processing result, and determine the actual distance based on the depth processing result;
[0108] In some embodiments, the scene depth map C scene Preprocessing is performed to obtain the effective depth d of the pixel. pixel That is, by sampling the depths of several directions around a pixel, the minimum value is taken as the effective depth d of that pixel. pixel The relevant formula is: d pixel =min(d pixel ,d neighboring ); then, the effective depth value d pixel Converted to the actual distance Z from the camera to the scene object pixel To obtain the length of light propagation, the relevant formula is: Z pixel =LinearDepthToDistance(d pixel ,z near ,z far In the formula, z near z is the distance to the nearest cutting surface. far The distance to the far cutting surface.
[0109] It should be noted that the preprocessing employs a neighborhood minimization operation, which samples the depth in several directions around the pixel and takes the minimum value to effectively suppress depth noise and avoid artifacts during subsequent blending. Then, the linearized depth values are converted into the actual distance from the camera to the scene objects.
[0110] Step S503: Based on the actual distance, query the air transmittance and scattered incident light from the air perspective lookup table;
[0111] In some embodiments, based on the actual distance Z pixel Query the air transmittance t from the preset air transmittance lookup table pixel and scattered incident light i pixelThe lookup table pre-stores transmittance and scattering brightness at slices of different line-of-sight directions and distances near the camera origin (e.g., within a 32-kilometer radius). During the query, the actual distance Z is used as the reference. pixel The mapping is used as a depth index in the lookup table to efficiently obtain the light transmittance at the current pixel location due to atmospheric extinction, as well as the amount of scattered light that reaches the point from the top of the atmosphere and is transmitted back to the camera. The relevant formula for the lookup is: In the formula, f(Z) pixel ) is the LUT depth normalization function, which ensures that the interpolation changes continuously in the lookup table.
[0112] It should be noted that the aerial perspective LUT only pre-stores the transmittance within a 32km line-of-sight range. If the range exceeds this, the RaymarchingScatering function still needs to be used to calculate the corresponding transmittance. If it is certain that the scene's line-of-sight range will not exceed 32km, this can be ignored.
[0113] Step S504: The intensity of the scattered incident light is corrected using the color of the target light source to obtain a correction result. The scene color map is multiplied by the air transmittance to obtain a multiplication result. The multiplication result is then added to the correction result to obtain the sky rendering result.
[0114] In some embodiments, the intensity of the queried scattered incident light is corrected using the modulated target light source color, wherein the correction formula is i pixel ←i pixel ·I sun This ensures that the lighting conditions match the overall lighting conditions of the scene; subsequently, the scene color map C is applied. scene With air transmittance T pixel Multiply by this to obtain the object's color after atmospheric attenuation, then multiply this result by the corrected scattered incident light I. pixel Adding together is C final =C scene ·T pixel +I pixel In the formula, where C scene T represents the original scene color. pixel For the transmittance obtained from the LUT query, I pixel The scattered incident light obtained from the LUT query; finally, a sky rendering result C is synthesized, which incorporates realistic atmospheric perspective effects. final It perfectly presents the color attenuation of distant objects and the contribution of atmospheric scattering light.
[0115] By consulting an atmospheric perspective lookup table and applying precise color attenuation and diffused light overlay based on the actual distance of objects, a realistic atmospheric perspective effect can be simulated. This not only enhances the spatial depth of the image but also unifies the visual representation of objects in the scene with the current atmospheric state (determined by the sky rendering), achieving a seamless and accurate transfer of spatial information from the sky to the ground.
[0116] This invention constructs an atmospheric scattering lookup table to facilitate the subsequent acquisition of corresponding projection probability values based on different light source directions, ensuring accurate and realistic reproduction of light and color phenomena. The transmittance values obtained by querying the atmospheric scattering lookup table accurately reflect the spectral attenuation of sunlight after passing through an atmosphere of specific thickness and composition, ensuring a solid physical basis for light source color modulation and enabling accurate and realistic reproduction of light and color phenomena. By sampling the sky view lookup table in real time, the sky color and brightness precisely corresponding to the current sun position and viewing angle can be obtained instantly, facilitating the realistic rendering of dynamic effects such as blue skies and sunsets. The target light source color (not the original white light) is used to illuminate the field. The scene materials and clouds in the background ensure that the lighting conditions of these scene elements are consistent with the lighting conditions of the sky background, fundamentally solving the problem of the disconnect between the lighting of the sky, objects, and clouds in traditional methods, and achieving visual physical consistency. By consulting the atmospheric perspective lookup table and applying precise color attenuation and scattered light superposition according to the actual distance of the objects, a realistic atmospheric perspective effect can be simulated. This not only enhances the spatial depth of the image, but also unifies the visual representation of scene objects with the current atmospheric state (determined by the sky rendering), completing a seamless and accurate spatial information transmission from the sky to the ground. Compared with existing technologies, this application can achieve accurate dynamic rendering of the sky in a 3D scene.
[0117] like Figure 6 As shown, based on the above method embodiments, corresponding apparatus embodiments are provided;
[0118] An embodiment of the present invention provides a sky rendering system for a three-dimensional scene, including: an acquisition module 100, a modulation module 200, and a rendering module 300;
[0119] The acquisition module 100 is used to acquire the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction;
[0120] The modulation module 200 is used to look up the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the direction of the light source, calculate the color modulation factor based on the transmittance value, and adjust the color of the light source using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters.
[0121] The rendering module 300 is used to look up the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters to perform rendering, thereby obtaining a first rendering result. It then uses the target light source color to perform scene material rendering and cloud / fog rendering on the 3D scene in the first rendering result to obtain a second rendering result. Finally, it performs color attenuation and diffused light mixing on the scene objects in the second rendering result based on a preset atmospheric perspective lookup table to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
[0122] It is understood that the above-described device embodiments correspond to the method embodiments of the present invention, and can implement the sky rendering method for three-dimensional scenes provided by any of the above-described method embodiments of the present invention.
[0123] It should be noted that the device embodiments described above are merely illustrative, and some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can specifically be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0124] Based on the above embodiments of the sky rendering method for three-dimensional scenes, another embodiment of the present invention provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the sky rendering method for three-dimensional scenes of any embodiment of the present invention.
[0125] For example, in this embodiment, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal device.
[0126] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0127] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, 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, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device via various interfaces and lines.
[0128] Based on the above-described method embodiments, another embodiment of the present invention provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute the sky rendering method for a three-dimensional scene as described in any of the above-described method embodiments of the present invention.
[0129] The modules / units integrated in the device / terminal equipment, if implemented as software functional units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0130] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for rendering the sky in a three-dimensional scene, characterized in that, include: Obtain the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction; Based on the direction of the light source, the transmittance value of sunlight in the atmosphere is looked up from a preset atmospheric scattering lookup table. A color modulation factor is calculated based on the transmittance value, and the color of the light source is adjusted using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters. Based on the light source direction and the camera parameters, the sky radiance is retrieved from a preset sky view lookup table for rendering to obtain a first rendering result. Then, the target light source color is used to render the scene materials and clouds in the 3D scene of the first rendering result to obtain a second rendering result. Finally, based on a preset atmospheric perspective lookup table, the scene objects in the second rendering result are subjected to color attenuation and diffused light mixing to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
2. The sky rendering method for a three-dimensional scene according to claim 1, characterized in that, The step of searching for the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the direction of the light source includes: Calculate the height of the observation point position, wherein the camera parameters include the observation point position; Calculate the dot product of the light source direction and the observation point position to obtain the zenith angle cosine value. Based on the zenith angle cosine value and the height, calculate the texture coordinates. The transmittance value is obtained by looking up the information in the atmospheric scattering lookup table based on the texture coordinates.
3. The sky rendering method for a three-dimensional scene according to claim 1, characterized in that, The step of adjusting the color of the light source using the color modulation factor to obtain the modulated target light source color includes: calculating the scaling vector of each channel based on the color modulation factor, and multiplying the scaling vector with the light source color in each channel to obtain the modulated target light source color.
4. The sky rendering method for a three-dimensional scene according to claim 2, characterized in that, The first rendering result is obtained by retrieving the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters, and then rendering the result. This includes: Determine the direction vector based on the location of the observation point; The line-of-sight elevation angle is calculated based on the line-of-sight direction and the direction vector, wherein the camera parameters include the line-of-sight direction; The azimuth angle is calculated based on the line of sight, the direction vector, and the light source direction. The line of sight elevation angle and the azimuth angle are then mapped to the texture coordinates of the sky view lookup table. The sky radiance is then sampled from the sky view lookup table based on the texture coordinates for rendering.
5. The sky rendering method for a three-dimensional scene according to claim 1, characterized in that, The second rendering result is obtained by using the target light source color to perform scene material rendering and cloud / fog rendering on the 3D scene in the first rendering result, including: The target light source color is input into the physical rendering model to calculate the diffuse and specular components of scene objects, and atmospheric correction material rendering results are determined based on the diffuse and specular components. The cloud and fog in the first rendering result are rendered based on the target light source color to obtain a cloud and fog rendering result, and a second rendering result is determined based on the material rendering result and the cloud and fog rendering result.
6. The sky rendering method for a three-dimensional scene according to claim 1, characterized in that, The sky rendering result is obtained by performing color attenuation and diffuse light mixing on the scene objects in the second rendering result based on a preset atmospheric perspective lookup table, including: Obtain the scene color map and scene depth map corresponding to the second rendering result; The scene depth map is preprocessed by a neighborhood minimization operation to obtain a depth processing result, and the actual distance is determined based on the depth processing result. Based on the actual distance, the air transmittance and scattered incident light are retrieved from the air perspective lookup table; The intensity of the scattered incident light is corrected using the color of the target light source to obtain a correction result. The scene color map is multiplied by the air transmittance to obtain a multiplication result. The multiplication result is then added to the correction result to obtain the sky rendering result.
7. The sky rendering method for a three-dimensional scene according to any one of claims 1-6, characterized in that, The atmospheric scattering lookup table includes a transmittance lookup table and a multiple scattering lookup table. The atmospheric scattering lookup table is constructed based on atmospheric physical and geometric parameters, including: Based on the geometric parameters, a mapping relationship is established between the initial texture coordinates, the initial observation point height, and the initial light source direction. For the initial texture coordinates, a path is determined to pass through the atmosphere from the observation point along the initial light source direction. The path is discretized into several step sizes, and the extinction coefficient corresponding to the sampling point of each step size is calculated based on atmospheric physical parameters. Based on the extinction coefficients of all the stated step sizes, the initial transmittance of the entire path is calculated by integration, and the transmittance lookup table is obtained based on the initial transmittance.
8. A sky rendering system for a three-dimensional scene, characterized in that, include: Acquisition module, modulation module, and rendering module; The acquisition module is used to acquire the current light source parameters and camera parameters, wherein the light source parameters include light source color and light source direction; The modulation module is used to look up the transmittance value of sunlight in the atmosphere from a preset atmospheric scattering lookup table based on the direction of the light source, calculate the color modulation factor based on the transmittance value, and adjust the color of the light source using the color modulation factor to obtain the modulated target light source color. The atmospheric scattering lookup table is constructed based on atmospheric physical parameters and geometric parameters. The rendering module is used to look up the sky radiance from a preset sky view lookup table based on the light source direction and the camera parameters to perform rendering, thereby obtaining a first rendering result. It then uses the target light source color to perform scene material rendering and cloud / fog rendering on the 3D scene in the first rendering result to obtain a second rendering result. Finally, it performs color attenuation and diffused light mixing on the scene objects in the second rendering result based on a preset atmospheric perspective lookup table to obtain a sky rendering result. The sky view lookup table is generated based on the atmospheric scattering lookup table.
9. A terminal device, characterized in that, include: One or more processors; A memory, coupled to the processor, for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the steps of the sky rendering method for a three-dimensional scene as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, include: A stored computer program, wherein, when the computer program is executed, the device containing the computer-readable storage medium controls the execution of the sky rendering method for a three-dimensional scene as described in any one of claims 1-7.