Image processing method and device, equipment and storage medium

By distinguishing shadow areas in fog effect rendering and dynamically adjusting the sampling level in combination with directional scattering information, the problem of light and shadow distortion in shadow areas is solved, achieving realism and visual consistency in fog effect rendering and improving the rendering effect.

CN121564178APending Publication Date: 2026-02-24NETEASE (SHANGHAI) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511786422.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Existing technologies for fog effect rendering suffer from distortion of lighting and shadow effects and visual consistency issues in shadow areas, resulting in unrealistic fog effect rendering results.

Method used

By distinguishing between shadow and non-shadow areas and combining directional scattering information to determine the target sampling level, the sampling accuracy of shadow areas is dynamically adjusted to ensure that the scattering effect of the special effects is related to the light source and viewing angle, and a suitable MIP level is used for rendering.

Benefits of technology

It improves the realism and visual consistency of fog effect rendering, avoids performance waste caused by indiscriminate high sampling, and balances realism with device operating efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121564178A_ABST
    Figure CN121564178A_ABST
Patent Text Reader

Abstract

The invention provides an image processing method and device, equipment and a storage medium, and the method comprises the steps: obtaining the texture information and light information of a current virtual scene, and determining at least one shadow region of the current virtual scene according to the position information of each entity object in the current virtual scene; furthermore, according to the camera direction information and the light source direction information of the current virtual scene, directional scattering information of the current virtual scene is determined, the directional scattering information is used for representing the scattering range in the current light direction, and according to the directional scattering information and the light length information, a target sampling level corresponding to the shadow area is determined; and sampling and rendering the shadow region in the texture information according to the target sampling hierarchy to obtain a rendering result of the shadow region. The problems of shadow area special effect physical distortion and visual inconsistency are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to an image processing method, apparatus, device, and storage medium. Background Technology

[0002] MipFog (Mip-map-based Fog) is a technique used to simulate realistic atmospheric scattering effects. By matching the fog color with the sky color, the fog color can produce a natural transition based on distance and viewing angle.

[0003] In existing technologies, real-time rendering based on MipFog technology typically optimizes volumetric fog rendering efficiency through multi-level texture sampling. Each texture layer can be called a MIP (Mixed Injection Layer). MIPs are categorized into high-level and low-level MIPs based on their position in the scene. MIPs closer to the sky are considered higher-level. Currently, real-time rendering primarily uses high-level MIPs to sample the skybox to obtain color values, and then uses these sampled color values ​​for fog effect rendering.

[0004] However, when performing MIP sampling on shadow areas using existing technology, using high-level MIP will cause distortion in the calculation of the internal scattering intensity of directional light sources, thereby destroying the sense of layering of fog effects and the realism of light and shadow. Summary of the Invention

[0005] The purpose of this application is to address the shortcomings of the prior art by providing an image processing method, apparatus, device, and storage medium to solve the problems of physical distortion and visual inconsistency between light and shadow in the existing fog effect rendering.

[0006] To achieve the above objectives, the technical solution adopted in this application is as follows: In a first aspect, this application provides an image processing method, the method comprising: The texture information and lighting information of the current virtual scene are obtained. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene. Based on the position information of each entity object in the current virtual scene, at least one shadow area of ​​the current virtual scene is determined; and based on the camera orientation information and light source orientation information of the current virtual scene, the directional scattering information of the current virtual scene is determined, wherein the directional scattering information is used to characterize the scattering range under the current light direction. Based on the directional scattering information and the light length information, the target sampling level corresponding to the shadow region is determined; The shadow region is rendered by sampling from the texture information according to the target sampling level, thereby obtaining the rendering result of the shadow region.

[0007] Secondly, this application provides an image processing apparatus, the apparatus comprising: The acquisition module is used to acquire texture information and lighting information of the current virtual scene. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene. The information determination module is used to determine at least one shadow area of ​​the current virtual scene based on the position information of each entity object in the current virtual scene; and to determine the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene, wherein the directional scattering information is used to characterize the scattering range under the current light direction. The layer determination module is used to determine the target sampling layer corresponding to the shadow area based on the directional scattering information and the light length information; The rendering module is used to sample from the texture information according to the target sampling level to render the shadow area and obtain the rendering result of the shadow area.

[0008] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of an image processing method as described in any one of the first aspects.

[0009] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of an image processing method as described in any one of the first aspects.

[0010] The beneficial effects of this application are as follows: By clearly distinguishing between shadow and non-shadow areas, and determining the target sampling level for shadow areas by combining directional scattering information, the scattering range of light in shadow areas can be processed. This ensures that the scattering effect of special effects can dynamically change with the light source and viewing angle, making the scattering range, density, and color of the special effects strongly correlated with physical factors such as the direction of the light source, the length of the light rays, the sky environment, and object occlusion, thus more closely resembling the optical laws of the real world and solving the problem of physical distortion in shadow area special effects. By dynamically adjusting the sampling accuracy of shadow areas through the target sampling level, the performance waste caused by indiscriminate high sampling can be avoided while ensuring the detail of special effects in shadow areas, balancing realism and equipment operating efficiency.

[0011] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 A schematic diagram of the rendering result of fog effect rendering based on existing technology is shown; Figure 2 A flowchart of an image processing method provided in an embodiment of this application is shown; Figure 3 This document illustrates a flowchart of a method for determining a shaded area according to an embodiment of this application. Figure 4 A flowchart illustrating a method for determining directional scattering information according to an embodiment of this application is shown; Figure 5 This document illustrates a flowchart of a method for determining a target sampling level, as provided in an embodiment of this application. Figure 6 This application provides a flowchart for determining the length of a light ray according to an embodiment of the present application. Figure 7 This document illustrates a flowchart of a method for determining an initial sampling level, as provided in an embodiment of this application. Figure 8 This application provides a flowchart for determining special effects impact information according to an embodiment of the present application. Figure 9 This document illustrates a flowchart of yet another method for determining the target sampling level, as provided in an embodiment of this application. Figure 10This document illustrates a flowchart of an embodiment of the present application for obtaining a rendering result; Figure 11 This invention provides a flowchart illustrating yet another method for obtaining a rendering result according to an embodiment of the present application. Figure 12 A schematic diagram of a rendering result provided in an embodiment of this application is shown; Figure 13 This illustration shows a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application; Figure 14 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

[0014] 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, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0015] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0016] In one embodiment of this disclosure, the image processing method can run on a local terminal device or a server. When the image processing method runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0017] In an optional implementation, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of image processing methods are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the information processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.

[0018] In an optional implementation, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally by downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.

[0019] In one possible implementation, this invention provides an image processing method that provides a graphical user interface through a terminal device, wherein the terminal device may be the aforementioned local terminal device or a client device in the aforementioned cloud interaction system.

[0020] In Mipfog technology, to achieve a more realistic fog effect, color values ​​are typically obtained by performing high-level MIP sampling on the skybox, and then the sampled color values ​​are blended with the fog color for rendering to obtain a more realistic rendering result.

[0021] However, existing technologies use the same fog effect rendering method for all areas, lacking coordinated processing of directional inward scattering lighting and shadow occlusion, which leads to poor fog effect rendering in the scene.

[0022] Specifically, existing technologies render fog effects in both shadow and non-shadow areas by sampling high-level MIPs. However, due to the influence of directional internal scattering lighting, fog in non-shadow areas facing the sun should be brighter, while fog in shadow areas should be darker because the light is blocked. But when rendering fog effects using existing technologies, because high-MIP textures themselves contain stronger sky lighting information, they incorrectly amplify the intensity of internal scattering light in shadow areas, causing the fog in shadows to be abnormally bright, violating the physical law that "shadow areas have weaker lighting, and the fog should be darker."

[0023] Reference Figure 1 This is a rendering illustration of a fog effect effect applied to a virtual scene with shadowed areas using existing technology. The shadowed areas of a mountain should ideally be rendered as darker colors when applying fog effects, but in practice, the rendered image using existing technology shows... Figure 1 The unreasonable bright fog shown indicates a physical distortion problem.

[0024] Furthermore, when rendering fog at the same depth, theoretically, the fog effect at the same depth should be guaranteed to transition continuously. However, when rendering fog effects based on existing technology, since there is no selective distinction between the MIP layers of shadow areas and non-shadow areas, there will be a problem of sudden brightness jumps at the shadow boundary of fog at the same depth. For example, the fog inside the shadow is abnormally bright, while the fog outside the shadow is normally dark, which destroys the visual consistency of fog as a "continuous volume medium".

[0025] Therefore, improving the realism and visual consistency of fog effects in virtual scenes and solving the physical distortion problem in fog effects in shadow areas has become the key to improving fog effect rendering.

[0026] Based on this, this application proposes an image processing method that, by co-processing the shadow area and the directional internal scattering light source, determines a more suitable MIP level for the shadow area, solves the problem of physical distortion in the rendering of fog effects in the shadow area, and ensures visual consistency of fog effects in the shadow area and the non-shadow area.

[0027] It should be noted that the following embodiments of this application are only illustrated using fog effects as an example. It should be understood that the image processing method of this application can also be applied to other special effects similar to fog effects, such as cloud shadow effects or light effects, and should not be limited to fog effects.

[0028] Next, combine Figure 2 The image processing method described in this application can be executed by an electronic device, specifically a GPU within the electronic device, such as... Figure 2 As shown, the method includes: S201. Obtain the texture and lighting information of the current virtual scene.

[0029] The texture information includes multiple layers of texture information in the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene.

[0030] Texture information can be a cube map simulating the sky environment in a virtual scene, containing multiple MIP layers. The texture information records the sky color as observed from the scene origin in all directions. The MIP layers include texture information ranging from clear to blurry, used for special effects color sampling. For example, for fog effects, the higher the layer, the blurrier the texture, corresponding to the effect of fog in the distance.

[0031] Optionally, camera orientation information includes the direction from the camera to the light source in the virtual scene, and light source orientation information includes the illumination direction of the light source in the virtual scene. Ray length information includes the distance from the camera to the model in the virtual scene. Ray direction information refers to the ray direction vector of each pixel in the virtual scene.

[0032] In one possible implementation, texture information can be obtained by sampling the color information of the skybox at different directions and distances through parallel processing. For example, the texture information can be obtained by acquiring the skybox texture, then capturing the skybox texture using a computer shader to obtain texture data for all MIP levels, and storing it as an array or dictionary.

[0033] For example, the world space direction vector from the camera to the light source can be calculated in the shader as the camera direction information. The world space direction of the main light source can be obtained as the light source direction information. The light length information can be calculated by comparing the world space position of each pixel with the camera position.

[0034] S202. Based on the position information of each entity object in the current virtual scene, determine at least one shadow area of ​​the current virtual scene; and based on the camera direction information and light source direction information of the current virtual scene, determine the directional scattering information of the current virtual scene, which is used to characterize the scattering range under the current light direction.

[0035] In this context, the shadow area can be an area in the virtual scene that is obscured by a physical object and cannot be directly illuminated by a light source. The physical object can be a virtual object in the virtual scene, such as a building, tree, or mountain, that is not in the sky.

[0036] The location information of each entity object can be the world space coordinates of each pixel in the virtual scene.

[0037] In one possible implementation, the scene can be rendered from the light source's perspective. The nearest distance from each pixel to the light source is recorded as the pixel's depth value, resulting in a shadow map. For each entity object in the current scene, the world position coordinates of each object's pixels are transformed to the light source's projection space and compared with the depth value of the corresponding position in the shadow map. If the entity's depth is greater than the shadow map's depth, the pixel is located in the shadow region. By checking all pixels of the entity object, the shadow region of the entity object can be determined.

[0038] Directional scattering information can characterize the scattering range of a special effect on a light source under the current light direction. It is used to characterize the variation of the scattering intensity of a special effect with the angle between the light and the light source. For example, for a fog effect, scattering is strong when facing the light source directly and weak when facing it from the side.

[0039] It is worth noting that the steps for determining the shadow area and determining the directional scattering information can be performed sequentially or in parallel, and the execution order is not restricted here.

[0040] S203. Based on the directional scattering information and the light length information, determine the target sampling level corresponding to the shadow area.

[0041] The target sampling level can be the skybox MIP level selected for the effect on pixels in the shadow area. The level determines the blurriness and brightness of the effect. Based on directional scattering information, the scattering range of the shadow area can be determined, and the MIP level can be reduced for shadow areas with weaker scattering to avoid overly bright shadow areas. Based on light length information, the distance of the shadow area can be determined, and the MIP level can be reduced for shadow areas that are farther away, thus achieving a more blurred effect.

[0042] In one possible implementation, a basic level can be assigned to the pixels in the shadow area first. Then, the range of levels that need to be adjusted can be determined based on directional scattering information and light length information. The level adjustment can be performed on the basis of the basic level to determine the final target sampling level.

[0043] In another possible implementation, the basic level can be determined first based on the light length information, and then the range of levels to be adjusted can be determined based on the directional scattering information. The basic level can be adjusted according to the range of levels to obtain the final target sampling level.

[0044] S204. Sample from texture information according to the target sampling level to render the shadow area and obtain the rendering result of the shadow area.

[0045] Optionally, the target sampling level obtained in step S203 above can be used to sample the color of the corresponding level from the skybox, and the effect of the shadow area can be rendered by combining the degree of superposition of the effect. For example, for the fog effect, the fog effect of the shadow area can be rendered by combining parameters such as the fog concentration in the current virtual scene.

[0046] Specifically, for each pixel in the shadow area of ​​the current virtual scene, its target sampling level can be determined separately, and special effects rendering is performed on each pixel based on its target sampling level. After completing the special effects rendering of all pixels in the shadow area, the rendering result of the shadow area is obtained.

[0047] It is worth noting that the current virtual scene includes both shadowed and non-shadowed areas. The method described in this application can be used for special effects rendering in shadowed areas, while conventional methods can be used for non-shadowed areas. After determining the target sampling level for the shadowed area, the skybox texture can be sampled according to the target level, and the sampled color values ​​can be mixed with the scene pixel colors to obtain the final color value of the pixel.

[0048] After sampling each pixel in the shadow area based on the target sampling level to obtain the color value of each pixel, an additional attenuation coefficient can be multiplied by the effect color of the shadow area to further suppress the brightness of the shadow area and achieve a smooth transition of the effect.

[0049] In this embodiment, by clearly distinguishing between shadow and non-shadow areas and determining the target sampling level for shadow areas based on directional scattering information, the scattering range of light in shadow areas can be processed. This ensures that the scattering effect of the special effects dynamically changes with the light source and viewing angle, making the scattering range, density, and color of the special effects strongly correlated with physical factors such as the direction of the light source, the length of the light rays, the sky environment, and object occlusion. This more closely resembles the optical laws of the real world, thus solving the problem of physical distortion in shadow area special effects. By dynamically adjusting the sampling accuracy of shadow areas through the target sampling level, the performance waste caused by indiscriminate high sampling can be avoided while ensuring the detail of the special effects in shadow areas, balancing realism and device operating efficiency.

[0050] Furthermore, the process of determining at least one shadow region in the current virtual scene based on the position information of each entity object in the current virtual scene includes: Based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, determine at least one shadow pixel.

[0051] The location information of an entity object can be the position coordinates of each pixel of the entity object in the world coordinate system.

[0052] Optionally, by performing coordinate transformation on the pixels in the virtual scene and determining the shadow depth value and actual depth value of each pixel, at least one shadow pixel can be identified. The shadow pixel can be a pixel in the shadow area of ​​the virtual scene.

[0053] It should be noted that since the special effect only affects the pixels in the shadow area near the physical object in the virtual scene, the depth value of the pixels around the physical object can be determined by combining the position information of the physical object, and then the shadow pixels can be determined.

[0054] The area formed by each shadow pixel is defined as the shadow region.

[0055] Alternatively, the continuous region formed by connecting all the shadow pixels can be used as the shadow region.

[0056] The following explains the steps for determining at least one shadow region in the current virtual scene based on the position information of each entity object in the current virtual scene. Figure 3 As shown, the above steps include: S301. Traverse each pixel in the current virtual scene. For the current pixel obtained from the traversal, if the current pixel belongs to an entity object in the current virtual scene, perform coordinate transformation on the world position coordinates of the current pixel to obtain the depth position coordinates of the current pixel in the light source projection space.

[0057] The world position coordinates of the current pixel can be the position coordinates of the current pixel in the world coordinate system.

[0058] Taking fog effect rendering as an example, the sky in the virtual scene is the background. There is no need to calculate the shadow of the fog on the sky. Only the fog around the real objects needs to be rendered. Therefore, for the currently traversed pixel, we can first determine whether the pixel is a non-sky entity object. If so, we can then calculate the shadow area.

[0059] The light source projection space can be a three-dimensional space from the perspective of the light source, including the light source view space and the projection space. When transforming the position coordinates of the current pixel to the light source projection space, the world position coordinates can be transformed to the light source's viewpoint first, and then transformed to the projection space through the light source's projection matrix to obtain the depth position coordinates of the current pixel in the light source projection space.

[0060] It should be understood that the essence of a shadow is that the light source is blocked by an object. Therefore, it is possible to determine from the perspective of the light source whether the image is blocked by other objects. By transforming the world position coordinates of the pixel to the projection space of the light source, the pixel can be mapped into the field of view of the light source in order to determine whether the pixel is blocked.

[0061] S302. Sample the depth position coordinates of the current pixel to obtain the shadow depth value of the current pixel.

[0062] Optionally, the current scene can be rendered from the light source's perspective to obtain a shadow map of the current scene, which records the shadow depth value of each pixel within the visible range of the light source to the light source.

[0063] The corresponding position in the shadow map can be located by using the depth coordinates of the current pixel, and the depth value at that position can be used as the shadow depth value.

[0064] The shadow depth value can be the depth of the nearest object that the current pixel can see from the light source's perspective, i.e., the theoretical depth value when there is no occlusion.

[0065] S303. Determine the actual depth value of the current pixel, and determine whether the current pixel is a shadow pixel based on the actual depth value and the shadow depth value of the current pixel.

[0066] The actual depth value can be the actual depth of the current pixel in the light source projection space, representing the true distance from the current pixel to the light source. A shadow pixel can be a pixel located in a shadow area and obscured by other objects.

[0067] If the actual depth value of the current pixel is greater than the shadow depth value, then the current pixel is determined to be a shadow pixel.

[0068] If, from the perspective of the light source, the actual depth value of the current pixel is greater than the shadow depth value, it means that the current pixel is occluded by an object located between the light source and the current pixel, that is, the current pixel is in shadow, and the current pixel can be regarded as a shadow pixel.

[0069] The following describes the steps for determining the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene. The process of determining the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene includes: Based on the camera orientation information and light source orientation information of each pixel, the light scattering information of each pixel is determined.

[0070] Among them, the light scattering information of a pixel can indicate the scattering intensity of the pixel under the current light direction.

[0071] Taking fog effect rendering as an example, the cosine of the angle between the camera direction information and the light source direction information can be calculated. The closer the value is to 1, the smaller the angle, and the stronger the scattering intensity. The closer the value is to 0, the larger the angle, and the weaker the scattering intensity. This simulates the effect that fog is brighter and more concentrated when facing a light source directly, and darker and more dispersed when facing a light source from the side.

[0072] The light scattering information of each pixel is calculated exponentially based on the preset exponential parameters to obtain the directional scattering information of each pixel in the current virtual scene.

[0073] The preset index parameter can be a manually set parameter used to control the directionality of scattering. The larger the index, the more concentrated the scattering range is in the area where the camera direction and the light source direction are aligned. The smaller the index, the more dispersed the scattering range is.

[0074] By performing exponential calculations on the saturation processing results, the sensitivity to the scattering range can be enhanced. Scattering is strongest when the camera direction is perfectly aligned with the light source direction; when there is an angle between the camera direction and the light source direction, the larger the exponent, the faster the scattering range decays, thus simulating the physical law of how the intensity of scattering by a medium changes with the angle. For example, when rendering fog effects, when sunlight penetrates the fog, the direction directly facing the sunlight scatters the brightest light, while the sides are darker.

[0075] Optionally, the final directional scattering information can describe the range of how the intensity of light scattering varies with direction, such as the range of angles at which the scattering brightness of fog is concentrated relative to the direction of the light source under illumination, i.e., in which directions the fog will be brighter or darker due to illumination by the light source.

[0076] Furthermore, such as Figure 4 As shown, the steps for determining the light scattering information of each pixel based on the camera orientation information and the light source orientation information of each pixel include: S401. Perform dot product calculation on the camera orientation information and light source orientation information of each pixel in the current virtual scene to obtain the dot product result.

[0077] The dot product of the camera orientation information and the light source orientation information can be the cosine of the angle between the camera orientation and the light source orientation. The range of the dot product result can be, for example, between [-1, 1].

[0078] S402. Perform saturation processing on the dot product result to obtain the saturation processing result of each pixel, and use the saturation processing result of each pixel as the illumination scattering information of each pixel.

[0079] Saturation processing can be used to limit the value of the dot product result to the range of [0,1]. If the value is less than 0, it is taken as 0; if it is greater than 1, it is taken as 1; and the intermediate value remains unchanged.

[0080] It should be understood that when the angle between the camera direction and the light source direction is greater than 90°, it means that the camera is looking in the opposite direction of the light source. At this time, the fog effect will hardly be affected by the scattering of the light source. The dot product result is negative. Therefore, saturation processing can filter out negative values ​​and retain the effective range of angles less than 90°.

[0081] After determining the directional scattering information and the shadow region, the most suitable MIP level can be selected for each pixel in the shadow region by combining the light distance, special effects, and directional scattering. The following explains the steps for determining the target sampling level corresponding to the shadow region based on directional scattering information and light length information. Figure 5 As shown, the above step S203 includes: S501. Normalize the light length information of each shadow pixel in the shadow area to obtain the light length of each shadow pixel.

[0082] Among them, the shadow pixel can be any pixel in the shadow area.

[0083] Optionally, the light length information can be the actual distance from the camera to the shadow pixel. By normalizing the light length information, the light length can be converted into a standard value of 0 to 1, eliminating the influence of absolute distance and making the distance unaffected by the scene scale. This facilitates subsequent unified calculations and enhances the versatility of the algorithm.

[0084] S502. Determine the initial sampling level of each shadow pixel based on the light length and the preset maximum sampling level.

[0085] For each shadow pixel, an initial sampling level can be determined based on the light length and the preset maximum sampling level.

[0086] The preset maximum sampling level can be the highest MIP level of the skybox texture, representing the most blurred texture state.

[0087] Taking fog rendering as an example, fog in the distance is blurred because of more complete scattering, while fog closer to the viewer is clearer. Therefore, the longer the light rays are, the higher the MIP level should be used to conform to the visual rule that fog in the distance is blurred and fog closer to the viewer is clear.

[0088] S503. Based on the length of the light rays, determine the effect information of the shadow area on each shadow pixel.

[0089] Special effects impact information can characterize the degree to which shadow areas affect the effects on pixels. The degree of effect on shadow pixels is expressed as the degree of influence on the pixel color of the shadow pixels. Special effects can be fog effects, lighting effects, or cloud effects.

[0090] When the effect is a light effect, the effect impact information can characterize the degree to which the light effect affects the pixel color of the shadow pixel. The larger the value, the brighter the object, that is, the higher the proportion of the object's color covered by light. The smaller the value, the darker the object, that is, the lower the proportion of the object's color covered by light.

[0091] When the effect is a cloud effect, the effect impact information can characterize the degree of influence of the cloud on the pixel color of the shadow pixel. The larger the value, the higher the proportion of the object color covered by the cloud, and the smaller the value, the lower the proportion of the object color covered by the cloud.

[0092] Taking fog effects as an example, the effect impact information can characterize the degree to which fog effects affect the pixel color of shadow pixels. A larger value indicates denser fog, meaning a higher proportion of the object's color is covered by fog; a smaller value indicates thinner fog, meaning a lower proportion of the object's color is covered by fog. It should be understood that the following explanation uses fog effects as an example to illustrate the process, but should not be limited to this.

[0093] S504. Based on the special effects impact information and directional scattering information, the initial sampling level is corrected to obtain the target sampling level of each shadow pixel.

[0094] In one possible implementation, a degradation range can be determined based on the special effects impact information and directional scattering information, and the initial sampling level can be adjusted according to the degradation range to obtain the target sampling level of the shadow pixels.

[0095] In this embodiment, the initial sampling level is corrected by using special effects impact information and directional scattering information. This can take into account the impact of basic blur, special effects density, and light intensity on the special effects in the shadow area, ensuring that the special effects in the shadow area are natural and realistic.

[0096] The following explains the steps for normalizing the ray length information of each shadow pixel in the shadow region to obtain the ray length of each shadow pixel. Figure 6 As shown, the above S501 step includes: S601. The light length information of the shadow pixels is scaled based on the reference distance to obtain the scaling result.

[0097] The reference distance can be a preset reference distance, such as the farthest visible distance in the scene or the upper limit of the light source's influence range, used to unify the length of light rays at different scales to the same dimension. The reference distance can be set to 10, for example.

[0098] Optionally, by scaling the light length information of the shadow pixels, the original light length can be mapped to a relative scale, eliminating the influence of differences in absolute distance values ​​and facilitating subsequent unified processing.

[0099] S602. Perform logarithmic calculation on the scaling result to obtain the range conversion result.

[0100] By performing logarithmic calculations on the scaling results, the linearly distributed values ​​after scaling can be transformed into a non-linear distribution, thereby compressing the large value range and expanding the small value range. The distribution of light lengths in the range transformation result after logarithmic calculation is more in line with the human eye's perception of distance, thus making the rendering result more visually appealing.

[0101] S603. Perform numerical mapping on the range conversion result to obtain the light length of the shadow pixel.

[0102] Optionally, the range transformation result can be mapped to the target numerical range through numerical mapping, and the resulting light length can quantify the impact of the light's propagation distance in the special effect on the rendering effect.

[0103] like Figure 7 As shown, the steps for determining the initial sampling level of each shadow pixel based on the ray length and the preset maximum sampling level include: S701. If the light length is equal to the first preset value, then the maximum sampling level is determined as the initial sampling level.

[0104] The first preset value is used to indicate that the shadow pixel is a distant pixel. The first preset value can be the maximum value of the mapped range in step S603 above, for example, it can be 1.

[0105] For distant pixels, effects have a significant impact on objects; therefore, the maximum sampling level can be used as the initial sampling level. The texture at the maximum sampling level is the most blurred, which saves resources and conforms to visual principles.

[0106] Among them, distant pixels can be pixels whose distance from the camera is within the first distance range.

[0107] S702. If the light length is equal to the second preset value, then the maximum sampling level is downgraded based on the preset downgrade range value to obtain the initial sampling level.

[0108] The second preset value is used to indicate that the shadow pixel is a nearby pixel. The first preset value can be the minimum value of the mapped range in step S603 above, for example, it can be 0.

[0109] For pixels at close range, the effects have little impact on the object. Therefore, the maximum sampling level can be downgraded based on a preset downgrade range value, and a clearer texture at a lower level can be sampled.

[0110] In this context, "near-distance pixels" refers to pixels that are within the second distance range from the camera, where the maximum value of the second distance range is less than the minimum value of the first distance range. For example, near-distance pixels are those 0-500 units away from the camera, while far-distance pixels are those 800 units or more away from the camera.

[0111] The following explains the steps for determining the effect impact information of each shadow pixel based on the length of the light rays, such as... Figure 8 As shown, the above S503 step includes: S801. If the length of the light ray is in the first value range, then the effect information of the shadow area on the shadow pixel is determined to be the full effect.

[0112] S802. If the light length is in the second value range, then the effect of the shadow area on the shadow pixel is determined to decrease linearly.

[0113] S803. If the length of the light ray is within the third value range, then the effect of the shadow area on the shadow pixel is determined to be unaffected.

[0114] Among them, the first value interval, the second value interval, and the third value interval are value intervals that increase sequentially.

[0115] Optionally, the first value range can represent the range of light length values ​​for nearby pixels, the second value range can represent the range of light length values ​​for mid- to far-distance pixels, and the third value range can represent the range of light length values ​​for far-distance pixels.

[0116] Continuing with the fog effect as an example, the human eye is more sensitive to details and differences in brightness of objects at close range. Therefore, if fog at close range is in shadow, a more pronounced darkening effect is needed to meet visual expectations. At medium to long distances, fog becomes increasingly scattering, and the human eye's sensitivity to shadow details decreases. Therefore, to achieve a smooth transition in shadow effects, the effect information in the second value range can be defined as linearly decreasing; that is, the farther the distance, the lower the shadow's impact on the fog. Fog at long distances becomes very blurry due to ample light scattering, and the human eye cannot distinguish subtle shadow differences. Furthermore, shadows at a distance are usually indistinct, so their impact can be ignored, saving computational resources and better conforming to visual principles.

[0117] In this embodiment, by determining the effect information through the length of light rays, a smoother transition can be achieved for effects at different distances, thereby ensuring visual consistency.

[0118] The following explains the steps for correcting the initial sampling level based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel. Figure 9 As shown, the above S504 step includes: S901. Determine the interpolation factor based on the special effects impact information, directional scattering information, and shadow area.

[0119] The interpolation factor can characterize the magnitude of the correction to the initial sampling level; the larger the value of the interpolation factor, the stronger the correction.

[0120] In one possible implementation, the influence weights of special effects, directional scattering, and shadow areas can be calculated separately, and the interpolation factor can be obtained by weighting the influence weights of the three.

[0121] S902. Perform interpolation calculations on the initial sampling level based on the interpolation factor to obtain the target sampling level.

[0122] Optionally, a level range limit can be preset for the target sampling level to avoid excessive blurring and ensure that the target sampling level is not lower than the initial sampling level.

[0123] For example, when the interpolation factor is equal to 0, the initial sampling level can be used as the target sampling level; when the interpolation factor is equal to 1, the initial sampling level can be corrected to the greatest extent; for interpolation factors between 0 and 1, interpolation calculation can be performed based on the interpolation factor to achieve a smooth transition and avoid sudden changes in the level.

[0124] The following is a further explanation of the above-mentioned sampling and rendering of shadow areas in texture information based on the target sampling level, resulting in the rendering result of the shadow area. Figure 10 As shown, step S204 above includes: S1001. Determine the texture information to be sampled in the texture information based on the position of the shadow area in the current virtual scene.

[0125] It should be noted that the skybox can be viewed as a cube map that wraps around the entire virtual scene, including textures in six directions: front, back, left, right, top, and bottom. Taking fog effects as an example, fog in the shadow area will reflect the light in the direction it faces towards the sky. Therefore, the direction from which to sample from the skybox can be determined based on the position of the shadow area in the virtual scene.

[0126] The texture information to be sampled can be a texture selected from the skybox based on the location of the shadow area and corresponding to the viewing direction of that shadow area. For example, if the shadow area faces the eastern sky, the eastward texture of the skybox can be used as the texture information to be sampled.

[0127] S1002. Based on the target sampling level, sample and render the texture information to be sampled to obtain the rendering result of the shadow area.

[0128] The texture information to be sampled includes multi-level textures in one direction. Based on the target sampling level, sampling and rendering are performed from the corresponding level of the texture information to be sampled to obtain the rendering result of the shadow area.

[0129] like Figure 11 As shown, the process of sampling and rendering the texture information to be sampled according to the target sampling level to obtain the rendering result of the shadow area specifically includes: S1101. Obtain the color value to be processed by sampling the texture information to be sampled based on the target sampling level.

[0130] S1102. Rendering is performed based on the color value to be processed and the original color values ​​of each shadow pixel in the shadow area to obtain the rendering result of the shadow pixel.

[0131] In one possible implementation, the color value to be processed can be sampled at the target sampling level of the texture information to be sampled. For each shadow pixel, the color value to be processed of each shadow pixel can be mixed with the effect color to obtain the rendering result of each shadow pixel. After the effect rendering of all shadow pixels is completed, the rendering result of the shadow area is obtained.

[0132] like Figure 12 The image shown is a rendering result obtained after performing fog effect rendering based on the method of this application. See also... Figure 12 This application can solve the problems of overly bright shadow areas and physical distortion, and ensure visual consistency between shadow areas and non-shadow areas.

[0133] Based on the same inventive concept, this application also provides an image processing apparatus corresponding to the image processing method. Since the principle of the apparatus in this application to solve the problem is similar to that of the image processing method described above in this application, the implementation of the apparatus can refer to the implementation of the method, and the repeated parts will not be described again.

[0134] Figure 13 A schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application is shown.

[0135] The acquisition module 1301 is used to acquire the texture information and lighting information of the current virtual scene. The texture information includes: texture information of multiple layers of the current virtual scene, and the lighting information includes: camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene. The information determination module 1302 is used to determine at least one shadow area of ​​the current virtual scene based on the position information of each entity object in the current virtual scene; and to determine the directional scattering information of the current virtual scene based on the camera direction information and light source direction information of the current virtual scene, wherein the directional scattering information is used to characterize the scattering range under the current light direction. The layer determination module 1303 is used to determine the target sampling layer corresponding to the shadow area based on the directional scattering information and the light length information; The rendering module 1304 is used to sample from the texture information according to the target sampling level to render the shadow area and obtain the rendering result of the shadow area.

[0136] Optionally, the information determination module 1302 is specifically used for: Based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, determine at least one shadow pixel; The area formed by each shadow pixel is defined as the shadow region.

[0137] Optionally, the information determination module 1302 is specifically used for: Iterate through each pixel in the current virtual scene. For the current pixel obtained from the iteration, if the current pixel belongs to an entity object in the current virtual scene, perform coordinate transformation on the world position coordinates of the current pixel to obtain the depth position coordinates of the current pixel in the light source projection space. Sample the depth coordinates of the current pixel to obtain the shadow depth value of the current pixel; Determine the actual depth value of the current pixel, and based on the actual depth value and the shadow depth value of the current pixel, determine whether the current pixel is a shadow pixel.

[0138] Optionally, the information determination module 1302 is specifically used for: If the actual depth value of the current pixel is greater than the shadow depth value, then the current pixel is determined to be a shadow pixel.

[0139] Optionally, the information determination module 1302 is specifically used for: Based on the camera orientation information and light source orientation information of each pixel, determine the light scattering information of each pixel; The light scattering information of each pixel is calculated exponentially based on the preset exponential parameters to obtain the directional scattering information of each pixel in the current virtual scene.

[0140] Optionally, the information determination module 1302 is specifically used for: Perform dot product calculation on the camera orientation information and light source orientation information of each pixel in the current virtual scene to obtain the dot product result; The dot product result is saturated to obtain the saturation result of each pixel, and the saturation result of each pixel is used as the illumination scattering information of each pixel.

[0141] Optionally, the hierarchy determination module 1303 is specifically used for: The light length information of each shadow pixel in the shadow region is normalized to obtain the light length of each shadow pixel; The initial sampling level of each shadow pixel is determined based on the light length and the preset maximum sampling level. Based on the length of the light rays, determine the effect information of the shadow area on each shadow pixel; The initial sampling level is corrected based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel.

[0142] Optionally, the hierarchy determination module 1303 is specifically used for: The ray length information of the shadow pixels is scaled based on the reference distance to obtain the scaling result; Perform logarithmic calculations on the scaling results to obtain the range transformation result; The range transformation result is numerically mapped to obtain the ray length of the shadow pixel.

[0143] Optionally, the hierarchy determination module 1303 is specifically used for: If the light length is equal to the first preset value, then the maximum sampling level is determined as the initial sampling level. The first preset value is used to indicate that the current pixel is a distant pixel. If the light length is equal to the second preset value, the maximum sampling level is downgraded based on the preset downgrade range value to obtain the initial sampling level. The second preset value is used to indicate that the current pixel is a nearby pixel.

[0144] Optionally, the hierarchy determination module 1303 is specifically used for: If the length of the light ray is in the first value range, then the effect of the shadow area on the current pixel is determined to be the full effect. If the ray length is in the second value range, then the effect of the shadow area on the current pixel is determined to decrease linearly. If the length of the light ray is within the third value range, then the shadow area is determined to have no effect on the special effects of the current pixel. Among them, the first value interval, the second value interval, and the third value interval are value intervals that increase sequentially.

[0145] Optionally, the hierarchy determination module 1303 is specifically used for: The interpolation factor is determined based on the special effects impact information, directional scattering information, and shadow areas; The initial sampling level is interpolated based on the interpolation factor to obtain the target sampling level.

[0146] Optionally, the rendering module 1304 is specifically used for: Based on the location of the shadow area in the current virtual scene, determine the texture information to be sampled in the texture information; Based on the target sampling level, the texture information to be sampled is sampled and rendered to obtain the rendering result of the shadow area.

[0147] Optionally, the rendering module 1304 is specifically used for: The color value to be processed is obtained by sampling the texture information to be sampled based on the target sampling level. The rendering process is performed based on the color value to be processed and the original color values ​​of each shadow pixel in the shadow area to obtain the rendering result of the current pixel.

[0148] This application's embodiments, by clearly distinguishing between shadowed and non-shadowed areas and determining the target sampling level for shadowed areas based on directional scattering information, can process the scattering range of light in shadowed areas. This ensures that the fog's scattering effect dynamically changes with the light source and viewing angle, making the fog's scattering range, concentration, and color strongly correlated with physical factors such as light source direction, light length, sky environment, and object obstruction. This more closely resembles the optical laws of the real world, thus solving the problem of physical distortion in shadowed fog effects. By dynamically adjusting the sampling accuracy of shadowed areas through the target sampling level, it is possible to maintain the detail of fog effects in shadowed areas while avoiding performance waste caused by indiscriminate high sampling, balancing realism and device operating efficiency.

[0149] Figure 14 This illustration shows a schematic diagram of an electronic device according to an embodiment of the present application, including: a processor 1401, a storage medium 1402, and a bus 1403. The storage medium 1402 stores machine-readable instructions executable by the processor 1401. When the electronic device runs an image processing method as described in the embodiment, the processor 1401 communicates with the storage medium 1402 via the bus 1403. The processor 1401 executes the machine-readable instructions. The preamble of the method item in the processor 1401 performs the following steps: Obtain the texture and lighting information of the current virtual scene. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information in the current virtual scene includes camera orientation information, light source orientation information, light length information, and light direction information. Based on the position information of each entity object in the current virtual scene, at least one shadow area of ​​the current virtual scene is determined; and based on the camera orientation information and light source orientation information of the current virtual scene, the directional scattering information of the current virtual scene is determined, which is used to characterize the scattering range under the current light direction. Based on directional scattering information and light length information, determine the target sampling level corresponding to the shadow area; The shadow area is rendered by sampling from the texture information according to the target sampling level.

[0150] Optionally, when the processor 1401 performs the task of determining at least one shadow region in the current virtual scene based on the position information of each entity object in the current virtual scene, it is specifically used for: Based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, determine at least one shadow pixel; The area formed by each of the shadow pixels is defined as the shadow region.

[0151] Optionally, when the processor 1401 determines at least one shadow pixel based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, it is specifically used for: Iterate through each pixel in the current virtual scene. For the current pixel obtained from the iteration, if the current pixel belongs to an entity object in the current virtual scene, perform coordinate transformation on the world position coordinates of the current pixel to obtain the depth position coordinates of the current pixel in the light source projection space. Sample the depth coordinates of the current pixel to obtain the shadow depth value of the current pixel; Determine the actual depth value of the current pixel, and based on the actual depth value and the shadow depth value of the current pixel, determine whether the current pixel is a shadow pixel.

[0152] Optionally, when the processor 1401 determines whether the current pixel is a shadow pixel based on the actual depth value and shadow depth value of the current pixel, it is specifically used for: If the actual depth value of the current pixel is greater than the shadow depth value, then the current pixel is determined to be a shadow pixel.

[0153] Optionally, when the processor 1401 determines the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene, it is specifically used for: Based on the camera orientation information and light source orientation information of each pixel, determine the light scattering information of each pixel; The light scattering information of each pixel is calculated exponentially based on the preset exponential parameters to obtain the directional scattering information of each pixel in the current virtual scene.

[0154] Optionally, when the processor 1401 determines the illumination scattering information of each pixel based on the camera orientation information and light source orientation information of each pixel, it is specifically used for: Perform dot product calculation on the camera orientation information and light source orientation information of each pixel in the current virtual scene to obtain the dot product result; The dot product result is saturated to obtain the saturation result of each pixel, and the saturation result of each pixel is used as the illumination scattering information of each pixel.

[0155] Optionally, when the processor 1401 determines the target sampling level corresponding to the shadow region based on directional scattering information and light length information, it is specifically used for: The light length information of each shadow pixel in the shadow region is normalized to obtain the light length of each shadow pixel; The initial sampling level of each shadow pixel is determined based on the light length and the preset maximum sampling level. Based on the length of the light rays, determine the effect information of the shadow area on each shadow pixel; The initial sampling level is corrected based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel.

[0156] Optionally, when the processor 1401 performs normalization processing on the light length information of each shadow pixel in the shadow region to obtain the light length of each shadow pixel, it specifically performs the following: The ray length information of the shadow pixels is scaled based on the reference distance to obtain the scaling result; Perform logarithmic calculations on the scaling results to obtain the range transformation result; The range transformation result is numerically mapped to obtain the ray length of the shadow pixel.

[0157] Optionally, when the processor 1401 performs the task of determining the initial sampling level of each shadow pixel based on the light length and the preset maximum sampling level, it is specifically used for: If the light length is equal to the first preset value, then the maximum sampling level is determined as the initial sampling level. The first preset value is used to indicate that the current pixel is a distant pixel. If the light length is equal to the second preset value, the maximum sampling level is downgraded based on the preset downgrade range value to obtain the initial sampling level. The second preset value is used to indicate that the current pixel is a nearby pixel.

[0158] Optionally, when the processor 1401 executes the process of determining the effect impact information of each shadow pixel based on the light length, it is specifically used for: If the length of the light ray is in the first value range, then the effect of the shadow area on the current pixel is determined to be the full effect. If the ray length is in the second value range, then the effect of the shadow area on the current pixel is determined to decrease linearly. If the length of the light ray is within the third value range, then the shadow area is determined to have no effect on the special effects of the current pixel. Among them, the first value interval, the second value interval, and the third value interval are value intervals that increase sequentially.

[0159] Optionally, when the processor 1401 corrects the initial sampling level based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel, it is specifically used for: The interpolation factor is determined based on the special effects impact information, directional scattering information, and shadow areas; The initial sampling level is interpolated based on the interpolation factor to obtain the target sampling level.

[0160] Optionally, when the processor 1401 performs sampling and rendering of the shadow region in the texture information according to the target sampling level to obtain the rendering result of the shadow region, it is specifically used for: Based on the location of the shadow area in the current virtual scene, determine the texture information to be sampled in the texture information; Based on the target sampling level, the texture information to be sampled is sampled and rendered to obtain the rendering result of the shadow area.

[0161] Optionally, when the processor 1401 performs sampling and rendering of the texture information to be sampled according to the target sampling level to obtain the rendering result of the shadow area, it is specifically used for: The color value to be processed is obtained by sampling the texture information to be sampled based on the target sampling level. The rendering process is performed based on the color value to be processed and the original color values ​​of each shadow pixel in the shadow area to obtain the rendering result of the current pixel.

[0162] This application's embodiments, by clearly distinguishing between shadowed and non-shadowed areas and determining the target sampling level for shadowed areas based on directional scattering information, can process the scattering range of light in shadowed areas. This ensures that the fog's scattering effect dynamically changes with the light source and viewing angle, making the fog's scattering range, concentration, and color strongly correlated with physical factors such as light source direction, light length, sky environment, and object obstruction. This more closely resembles the optical laws of the real world, thus solving the problem of physical distortion in shadowed fog effects. By dynamically adjusting the sampling accuracy of shadowed areas through the target sampling level, it is possible to maintain the detail of fog effects in shadowed areas while avoiding performance waste caused by indiscriminate high sampling, balancing realism and device operating efficiency.

[0163] This application embodiment also provides a computer-readable storage medium storing a computer program, which is executed by a processor, wherein the processor performs the following steps: Obtain the texture and lighting information of the current virtual scene. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, and light length information. Based on the position information of each entity object in the current virtual scene, at least one shadow area of ​​the current virtual scene is determined; and based on the camera orientation information and light source orientation information of the current virtual scene, the directional scattering information of the current virtual scene is determined, which is used to characterize the scattering range under the current light direction. Based on directional scattering information and light length information, determine the target sampling level corresponding to the shadow area; The shadow area is rendered by sampling from the texture information according to the target sampling level.

[0164] Optionally, when the processor determines at least one shadow region of the current virtual scene based on the position information of each entity object in the current virtual scene, it is specifically used for: Based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, determine at least one shadow pixel; The area formed by each of the shadow pixels is defined as the shadow region.

[0165] Optionally, when the processor determines at least one shadow pixel based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, it specifically performs the following: Iterate through each pixel in the current virtual scene. For the current pixel obtained from the iteration, if the current pixel belongs to an entity object in the current virtual scene, perform coordinate transformation on the world position coordinates of the current pixel to obtain the depth position coordinates of the current pixel in the light source projection space. Sample the depth coordinates of the current pixel to obtain the shadow depth value of the current pixel; Determine the actual depth value of the current pixel, and based on the actual depth value and the shadow depth value of the current pixel, determine whether the current pixel is a shadow pixel.

[0166] Optionally, when the processor determines whether the current pixel is a shadow pixel based on the actual depth value and shadow depth value of the current pixel, it specifically performs the following operations: If the actual depth value of the current pixel is greater than the shadow depth value, then the current pixel is determined to be a shadow pixel.

[0167] Optionally, when the processor determines the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene, it is specifically used for: Based on the camera orientation information and light source orientation information of each pixel, determine the light scattering information of each pixel; The light scattering information of each pixel is calculated exponentially based on the preset exponential parameters to obtain the directional scattering information of each pixel in the current virtual scene.

[0168] Optionally, when the processor determines the illumination scattering information of each pixel based on the camera orientation information and light source orientation information of each pixel, it is specifically used for: Perform dot product calculation on the camera orientation information and light source orientation information of each pixel in the current virtual scene to obtain the dot product result; The dot product result is saturated to obtain the saturation result of each pixel, and the saturation result of each pixel is used as the illumination scattering information of each pixel.

[0169] Optionally, when the processor determines the target sampling level corresponding to the shadow region based on directional scattering information and light length information, it is specifically used for: The light length information of each shadow pixel in the shadow region is normalized to obtain the light length of each shadow pixel; The initial sampling level of each shadow pixel is determined based on the light length and the preset maximum sampling level. Based on the length of the light rays, determine the effect information of the shadow area on each shadow pixel; The initial sampling level is corrected based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel.

[0170] Optionally, when the processor performs normalization processing on the light length information of each shadow pixel in the shadow region to obtain the light length of each shadow pixel, it specifically performs the following: The ray length information of the shadow pixels is scaled based on the reference distance to obtain the scaling result; Perform logarithmic calculations on the scaling results to obtain the range transformation result; The range transformation result is numerically mapped to obtain the ray length of the shadow pixel.

[0171] Optionally, when the processor determines the initial sampling level of each shadow pixel based on the light length and the preset maximum sampling level, it is specifically used for: If the light length is equal to the first preset value, then the maximum sampling level is determined as the initial sampling level. The first preset value is used to indicate that the current pixel is a distant pixel. If the light length is equal to the second preset value, the maximum sampling level is downgraded based on the preset downgrade range value to obtain the initial sampling level. The second preset value is used to indicate that the current pixel is a nearby pixel.

[0172] Optionally, when the processor performs the task of determining the effect impact information of each shadow pixel based on the light length, it is specifically used for: If the length of the light ray is in the first value range, then the effect of the shadow area on the current pixel is determined to be the full effect. If the ray length is in the second value range, then the effect of the shadow area on the current pixel is determined to decrease linearly. If the length of the light ray is within the third value range, then the shadow area is determined to have no effect on the special effects of the current pixel. Among them, the first value interval, the second value interval, and the third value interval are value intervals that increase sequentially.

[0173] Optionally, when the processor corrects the initial sampling level based on the special effects impact information and directional scattering information to obtain the target sampling level for each shadow pixel, it specifically performs the following: The interpolation factor is determined based on the special effects impact information, directional scattering information, and shadow areas; The initial sampling level is interpolated based on the interpolation factor to obtain the target sampling level.

[0174] Optionally, when the processor performs sampling and rendering of the shadow region in the texture information according to the target sampling level to obtain the rendering result of the shadow region, it is specifically used for: Based on the location of the shadow area in the current virtual scene, determine the texture information to be sampled in the texture information; Based on the target sampling level, the texture information to be sampled is sampled and rendered to obtain the rendering result of the shadow area.

[0175] Optionally, when the processor performs sampling and rendering of the texture information to be sampled according to the target sampling level to obtain the rendering result of the shadow area, it is specifically used for: The color value to be processed is obtained by sampling the texture information to be sampled based on the target sampling level. The rendering process is performed based on the color value to be processed and the original color values ​​of each shadow pixel in the shadow area to obtain the rendering result of the current pixel.

[0176] This application's embodiments, by clearly distinguishing between shadowed and non-shadowed areas and determining the target sampling level for shadowed areas based on directional scattering information, can process the scattering range of light in shadowed areas. This ensures that the fog's scattering effect dynamically changes with the light source and viewing angle, making the fog's scattering range, concentration, and color strongly correlated with physical factors such as light source direction, light length, sky environment, and object obstruction. This more closely resembles the optical laws of the real world, thus solving the problem of physical distortion in shadowed fog effects. By dynamically adjusting the sampling accuracy of shadowed areas through the target sampling level, it is possible to maintain the detail of fog effects in shadowed areas while avoiding performance waste caused by indiscriminate high sampling, balancing realism and device operating efficiency.

[0177] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.

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

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

[0180] In addition, the functional units in the embodiments provided in 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.

[0181] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion 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, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0182] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0183] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. An image processing method, characterized in that, include: The texture information and lighting information of the current virtual scene are obtained. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene. Based on the position information of each entity object in the current virtual scene, at least one shadow area of ​​the current virtual scene is determined; and based on the camera orientation information and light source orientation information of the current virtual scene, the directional scattering information of the current virtual scene is determined, wherein the directional scattering information is used to characterize the scattering range under the current light direction. Based on the directional scattering information and the light length information, the target sampling level corresponding to the shadow region is determined; The shadow region is rendered by sampling from the texture information according to the target sampling level, thereby obtaining the rendering result of the shadow region.

2. The method according to claim 1, characterized in that, The step of determining at least one shadow region in the current virtual scene based on the position information of each entity object in the current virtual scene includes: Based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object, determine at least one shadow pixel; The area formed by each of the shadow pixels is defined as the shadow region.

3. The method according to claim 2, characterized in that, The step of determining at least one shadow pixel based on the world position coordinates of each pixel in the current virtual scene and the position information of the entity object includes: Traverse each pixel in the current virtual scene. For the current pixel obtained by traversal, if the current pixel belongs to an entity object in the current virtual scene, perform coordinate transformation on the world position coordinates of the current pixel to obtain the depth position coordinates of the current pixel in the light source projection space. The depth position coordinates of the current pixel are sampled to obtain the shadow depth value of the current pixel; Determine the actual depth value of the current pixel, and determine whether the current pixel is a shadow pixel based on the actual depth value of the current pixel and the shadow depth value.

4. The method according to claim 3, characterized in that, The step of determining whether the current pixel is a shadow pixel based on the actual depth value of the current pixel and the shadow depth value includes: If the actual depth value of the current pixel is greater than the shadow depth value, then the current pixel is determined to be a shadow pixel.

5. The method according to claim 1, characterized in that, The step of determining the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene includes: Based on the camera orientation information and light source orientation information of each pixel, determine the light scattering information of each pixel; The light scattering information of each pixel is calculated exponentially based on the preset exponential parameters to obtain the directional scattering information of each pixel in the current virtual scene.

6. The method according to claim 5, characterized in that, The step of determining the illumination scattering information of each pixel based on the camera orientation information and light source orientation information of each pixel includes: The dot product is calculated on the camera orientation information and light source orientation information of each pixel in the current virtual scene to obtain the dot product result. The dot product result is saturated to obtain the saturation result of each pixel, and the saturation result of each pixel is used as the illumination scattering information of each pixel.

7. The method according to claim 1, characterized in that, Determining the target sampling level corresponding to the shadow region based on the directional scattering information and the light length information includes: The light length information of each shadow pixel in the shadow region is normalized to obtain the light length of each shadow pixel; The initial sampling level of each shadow pixel is determined based on the light length and the preset maximum sampling level. Based on the length of the light rays, the effect impact information of the shadow region on each shadow pixel is determined, and the effect impact information is used to characterize the degree of influence of the shadow region on the pixel color; The initial sampling level is corrected based on the special effects impact information and the directional scattering information to obtain the target sampling level for each shadow pixel.

8. The method according to claim 7, characterized in that, The normalization process for the ray length information of each shadow pixel in the shadow region to obtain the ray length of each shadow pixel includes: The ray length information of the shadow pixels is scaled based on a reference distance to obtain a scaling result; Perform a logarithmic calculation on the scaling result to obtain the range conversion result; The range conversion result is numerically mapped to obtain the ray length of the shadow pixel.

9. The method according to claim 7, characterized in that, The step of determining the initial sampling level of each shadow pixel based on the light length and the preset maximum sampling level includes: If the length of the light ray is equal to the first preset value, then the maximum sampling level is determined to be the initial sampling level. The first preset value is used to indicate that the shadow pixel is a distant pixel. The distant pixel is a pixel whose distance from the camera is located in the first distance range. If the light length is equal to the second preset value, the maximum sampling level is downgraded based on the preset downgrade range value to obtain the initial sampling level. The second preset value is used to indicate that the shadow pixel is a close-range pixel. The close-range pixel is a pixel whose distance from the camera is located in the second distance interval. The maximum value of the second distance interval is less than the minimum value of the first distance interval.

10. The method according to claim 7, characterized in that, The step of determining the influence information of each shadow pixel based on the light length includes: If the length of the light ray is in the first value range, then the effect information of the shadow region on the shadow pixel is determined to be the full effect; If the length of the light ray is in the second value range, then the effect of the shadow region on the shadow pixel is determined to decrease linearly. If the length of the light ray is within the third value range, then the effect of the shadow area on the shadow pixel is determined to be unaffected. The first value interval, the second value interval, and the third value interval are value intervals that increase sequentially.

11. The method according to claim 8, characterized in that, The step of correcting the initial sampling level based on the special effects impact information and the directional scattering information to obtain the target sampling level for each shadow pixel includes: The interpolation factor is determined based on the special effects impact information, the directional scattering information, and the shadow region; The initial sampling level is interpolated based on the interpolation factor to obtain the target sampling level.

12. The method according to claim 1, characterized in that, The step of sampling and rendering the shadow region in the texture information according to the target sampling level to obtain the rendering result of the shadow region includes: Based on the position of the shadow region in the current virtual scene, determine the texture information to be sampled in the texture information; Based on the target sampling level, the texture information to be sampled is sampled and rendered to obtain the rendering result of the shadow area.

13. The method according to claim 12, characterized in that, The step of sampling and rendering the texture information to be sampled according to the target sampling level to obtain the rendering result of the shadow area includes: The color value to be processed is obtained by sampling the texture information to be sampled based on the target sampling level. The rendering process is performed based on the color value to be processed and the original color values ​​of each shadow pixel in the shadow area to obtain the rendering result of the shadow pixel.

14. An image processing apparatus, characterized in that, include: The acquisition module is used to acquire texture information and lighting information of the current virtual scene. The texture information includes multiple layers of texture information of the current virtual scene, and the lighting information includes camera orientation information, light source orientation information, light length information, and light direction information in the current virtual scene. The information determination module is used to determine at least one shadow area of ​​the current virtual scene based on the position information of each entity object in the current virtual scene; and to determine the directional scattering information of the current virtual scene based on the camera orientation information and light source orientation information of the current virtual scene, wherein the directional scattering information is used to characterize the scattering range under the current light direction. The layer determination module is used to determine the target sampling layer corresponding to the shadow area based on the directional scattering information and the light length information; The rendering module is used to sample from the texture information according to the target sampling level to render the shadow area and obtain the rendering result of the shadow area.

15. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of an image processing method as described in any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of an image processing method as described in any one of claims 1 to 13.