Illumination rendering method and device, equipment and storage medium
By acquiring pixel location occlusion data and performing specular reflection brightness scaling in the virtual environment, the problem of uneven lighting in the virtual environment was solved, achieving high-quality lighting rendering effects and smooth screen performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-27
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, the lighting rendering effect of virtual environments is uneven, with some areas having good lighting effects while others have problems, resulting in poor visual effects and affecting the user experience.
By obtaining the pixel positions within the virtual environment, target occlusion data is obtained based on pixel depth values and view space normals. Specular occlusion information is then determined, and specular reflection brightness is scaled to accurately render lighting effects.
Without increasing the number of light rays emitted, the accuracy and stability of the lighting rendering effect are improved, the problem of uneven lighting is eliminated, and the visual effect and user experience are enhanced.
Smart Images

Figure CN121746572A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to computer graphics, providing a lighting rendering method, apparatus, device, and storage medium. Background Technology
[0002] Global illumination is a crucial visual feature for achieving realistic rendering. It accurately simulates the reflection, refraction, and indirect illumination effects of light in real-world scenes, restoring the light and shadow layers, color transitions, and material textures of the image. This breaks through the limitations of local lighting rendering, enhancing the realism and immersion of the image. Therefore, determining global illumination is currently a core research direction and key challenge in the fields of computer graphics and real-time rendering.
[0003] Among related technologies, Lumen, the default fully dynamic global illumination (GI) and reflection system of Unreal Engine (UE), is proposed. Currently, Lumen determines global illumination based on real-time ray tracing, but due to performance limitations, it cannot emit a large number of rays, resulting in a relatively blurry effect of specular reflections. This further leads to a situation where some lighting effects are good while others are problematic in the virtual environment, thus affecting the visual effect and user experience.
[0004] Therefore, improving the lighting and rendering effects of virtual environments to enhance visual effects and user experience is a technical problem that needs to be solved. Summary of the Invention
[0005] This application provides a lighting rendering method, apparatus, device, and storage medium to improve the lighting rendering effect of virtual environments, thereby enhancing the visual effects and user experience.
[0006] This application provides a lighting rendering method, the method comprising: Obtain the position of at least one pixel to be processed within the virtual environment; For each pixel location, the following steps are performed: Based on the pixel depth value and view space normal associated with the pixel location, target occlusion data for the pixel location is obtained. The target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment. Based on the target occlusion data, the specular reflection brightness associated with the pixel location is scaled to obtain specular occlusion information for the pixel location. The specular occlusion information describes the ability of the pixel location to receive indirect light in the specular reflection direction. Lighting rendering is performed on the current frame content of the virtual environment based on specular occlusion information at at least one pixel location.
[0007] This application provides a lighting rendering apparatus, the apparatus comprising: The acquisition unit is used to acquire the position of at least one pixel to be processed within the virtual environment. The execution unit performs the following actions for each pixel location: Based on the pixel depth value and view space normal associated with the pixel location, it obtains target occlusion data for that pixel location. This target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment. Based on the target occlusion data, it scales the target specular reflection brightness associated with the pixel location to obtain specular occlusion information for that pixel location. This specular occlusion information describes the pixel location's ability to receive indirect light in the specular reflection direction. The rendering unit is used to perform lighting rendering on the current frame content of the virtual environment based on specular occlusion information at at least one pixel location.
[0008] In one possible implementation, the acquisition unit is specifically used for: For each initial position within the virtual environment, the following steps are performed: Based on the basic roughness of the initial position and the detailed information in the screen space, the effective roughness of the initial position is obtained; the detailed information is used to describe the additional surface scattering characteristics of the initial position. From all initial positions within the virtual environment, select at least one initial position whose effective roughness meets the preset roughness conditions, and use it as at least one pixel position to be processed within the virtual environment.
[0009] In one possible implementation, the acquisition unit is specifically used for: Based on a roughness map pre-defined for the two-dimensional texture space, the initial roughness at the initial position is obtained; the roughness map is used to describe the initial roughness at different initial positions. By using texture interpolation, the initial roughness is spatially transformed to obtain the basic roughness of the screen space. Then, based on the detail information, the basic roughness is corrected to obtain the effective roughness of the initial position.
[0010] In one possible implementation, the execution unit is specifically used for: Based on the pixel depth value associated with the pixel position and the view space normal, the initial occlusion data of the pixel position is obtained. Also, based on the historical pixel position of the pixel content in the previous N frames, the historical occlusion data of each of the N historical pixel positions is obtained; N is a positive integer. Based on N historical occlusion data, the initial occlusion data is denoised to obtain the target occlusion data.
[0011] In one possible implementation, the initial occlusion data includes: visibility direction and ambient light occlusion level; the execution unit is specifically used for: The visible sampling area is obtained based on the view space normal and the preset sampling neighborhood radius; Based on a preset number of samples, at least one sampling direction is generated within the visible sampling area, and pixel sampling points corresponding to each of the at least one sampling direction are obtained; Based on the pixel depth value, the occlusion status of at least one pixel sampling point is obtained, and based on the obtained occlusion status, the sampling direction corresponding to the pixel sampling point that meets the occlusion condition is selected from at least one sampling direction. The visibility direction is obtained based on the selected sampling direction, and the ambient occlusion degree is obtained based on the visibility direction and the view space normal.
[0012] In one possible implementation, the execution unit is specifically used for: For each pixel sampling point, the following steps are performed: determine the sampling depth value of the pixel sampling point, determine the depth difference between the sampling depth value and the pixel depth value, and obtain the occlusion status of the pixel sampling point based on the comparison result between the depth difference and the depth threshold. Among them, the comparison result is that the depth difference is less than the depth threshold, and the occlusion status indicates that the pixel sampling point is not occluded.
[0013] In one possible implementation, the execution unit is specifically used for: From at least one sampling direction, filter out the sampling direction corresponding to the unoccluded pixel sampling point that indicates the occlusion situation.
[0014] In one possible implementation, the execution unit is specifically used for: Based on target occlusion data, a visibility cone is obtained; the visibility cone is used to describe the distribution range of effective lighting or reflection directions that are not occluded within the associated hemispherical illumination area of a pixel location. Based on the direction of reflected light rays from the virtual object's viewpoint to the pixel location and the effective roughness of the pixel location, a specular reflection cone is obtained; the specular reflection cone is used to describe the distribution range of the effective specular reflection light ray direction within the associated hemispherical illumination region of the pixel location; Based on the degree of intersection between the visibility cone and the specular reflection cone, the occlusion weight is obtained, and the target specular reflection brightness is scaled based on the occlusion weight to obtain the specular occlusion information at the pixel location.
[0015] In one possible implementation, the direction of the reflected ray is obtained based on the viewpoint direction of the virtual object's perspective and the view space normal.
[0016] In one possible implementation, after the execution unit obtains the target occlusion data of the pixel location, and before scaling the target specular reflection brightness associated with the pixel location based on the target occlusion data, it is further used for: Based on target occlusion data and combined with preset diffuse reflectance brightness associated with the virtual environment, the target diffuse reflectance brightness at the pixel location is obtained; Based on the target diffuse reflectance and the preset diffuse reflectance, and combined with the preset specular reflectance color associated with the virtual environment, the preset specular reflectance associated with the virtual environment is corrected to obtain the target specular reflectance associated with the pixel position.
[0017] In one possible implementation, the execution unit is also used for: Based on the target occlusion data, the visible area of the pixel location is obtained, and the diffuse reflection brightness of the hemispherical illumination area associated with the pixel location is obtained from the preset diffuse reflection brightness associated with the virtual environment. Obtain the overlapping area between the visible region and the hemispherical illumination region, and use the diffuse reflectance of the overlapping area as the target diffuse reflectance.
[0018] An electronic device provided in this application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the above-described lighting rendering methods.
[0019] This application provides a computer-readable storage medium including a computer program. When the computer program is run on an electronic device, the computer program is used to cause the electronic device to perform the steps of any of the above-described lighting rendering methods.
[0020] This application provides a computer program product, which includes a computer program stored in a computer-readable storage medium. When the processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the above-described lighting rendering methods.
[0021] The beneficial effects of this application are as follows: This application provides a lighting rendering method, apparatus, device, and storage medium, relating to the field of computer technology, and particularly to computer graphics. The lighting rendering implementation provided in this application includes: The method acquires at least one pixel location to be processed within the virtual environment and determines specular occlusion information for each pixel location. This embodiment only processes the pixel locations that need to be rendered, avoiding processing non-spectral virtual objects within the virtual environment, thus saving computing resources. Furthermore, it independently calculates specular occlusion information for each pixel location, uniformly improving the lighting accuracy of each area and eliminating situations where some areas have good lighting effects while others have defects, thereby achieving a balanced improvement in the overall image's lighting levels and realism.
[0022] When determining specular occlusion information for each pixel location, target occlusion data is obtained based on the pixel depth value and view space normal associated with the pixel location. This target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment. Based on this target occlusion data, the specular reflection brightness associated with the pixel location is scaled to obtain specular occlusion information for that pixel location. This specular occlusion information describes the pixel location's ability to receive indirect light in the specular reflection direction. By using pixel-level pixel depth values and view space normals, the target occlusion data describing the direction and degree of occlusion of incident light is accurately located, allowing for targeted scaling of specular reflection brightness. This effectively suppresses light leakage and blurring in specular areas, improving the accuracy and stability of specular reflection.
[0023] Based on specular occlusion information at at least one pixel location, the current frame of the virtual environment is used for lighting rendering. This precise specular occlusion information allows for more realistic simulation of light occlusion and reflection effects in real-world scenes within the virtual environment. It restores delicate light and shadow layers, color transitions, and material textures without increasing the number of rays emitted per frame to improve lighting effects. This avoids frame rate drops, stuttering, and jitter caused by performance limitations. While ensuring high-quality lighting rendering, it maintains smooth visual performance, significantly improving the visual effect and thus enhancing the user experience.
[0024] In summary, the lighting rendering method of this application embodiment achieves targeted optimization of the lighting rendering effect in the virtual environment through precise pixel-level specular occlusion information without increasing the number of rays emitted per frame or consuming additional hardware performance. This improves the lighting rendering effect of the virtual environment, thereby enhancing the visual effect and user experience.
[0025] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0026] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application; Figure 2 A schematic diagram illustrating lighting rendering in a game scene, provided as an embodiment of this application; Figure 3A flowchart of a lighting rendering method provided in an embodiment of this application; Figure 4 A schematic diagram illustrating an embodiment of this application for obtaining effective roughness; Figure 5 This is a schematic diagram illustrating how to obtain the position of at least one pixel to be processed, as provided in an embodiment of this application. Figure 6 A flowchart illustrating how to obtain specular occlusion information at a pixel location is provided in an embodiment of this application. Figure 7 A schematic diagram illustrating an embodiment of this application for obtaining a visibility direction; Figure 8 This is a schematic diagram illustrating noise reduction processing of initial occlusion data provided in an embodiment of this application; Figure 9 A schematic diagram illustrating the degree of intersection between a visible cone and a specular reflection cone, provided for an embodiment of this application; Figure 10 A schematic diagram of a pre-baked product provided for an embodiment of this application; Figure 11 This is a schematic diagram illustrating a specific implementation of lighting rendering provided in an embodiment of this application; Figure 12 A schematic diagram comparing the lighting effects of a scene provided in an embodiment of this application; Figure 13 A structural diagram of a lighting rendering apparatus provided in an embodiment of this application; Figure 14 A structural diagram of an electronic device provided in an embodiment of this application; Figure 15 This is another electronic device structure diagram provided for an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.
[0028] The following describes some of the concepts involved in the embodiments of this application.
[0029] 1. Virtual Environment: This is the environment displayed (or provided) by an application when it runs on a terminal device. This environment can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. The virtual environment can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual environment; this application does not limit the dimension of the virtual environment.
[0030] The virtual environment can include virtual scenes such as the sky, land, and ocean. The land can include virtual scenes such as deserts and cities. It can also include virtual items such as weapons, firearms, first-aid kits, and airdrops.
[0031] A virtual environment can also include the images of various people and objects that can be interacted with, or virtual objects such as movable objects within the virtual environment; these movable objects can be virtual characters, virtual animals, cartoon characters, etc., such as people and animals displayed in the virtual environment. For example, a virtual object can be a virtual avatar representing the user within the virtual environment. A virtual environment can include multiple virtual objects, each with its own shape and volume, occupying a portion of the space within the virtual environment.
[0032] 2. View Space Normal: This refers to the unit direction vector obtained by transforming the surface normal vector of an object into the view coordinate system with the camera as the origin. It is mainly used in the graphics pipeline stages such as lighting calculation in view space, screen space environment occlusion, reflection, and deferred rendering to ensure that geometric and lighting data are in the same coordinate system, thereby improving computational efficiency and numerical stability.
[0033] View space, also called camera space or eye space, is a three-dimensional Cartesian coordinate system with the camera as its origin. It serves as an intermediate transition space between the three-dimensional world space and the two-dimensional screen space. All linear depth calculations and direction vector calculations (such as line-of-sight, reflection direction, and sampling direction) are performed in this space. In first-person shooter games, the camera provides the first-person perspective, directly representing the player's viewpoint in the virtual environment. The camera's position is the player character's eye position, and its orientation determines what the player sees on the screen.
[0034] 3. Indirect lighting: This refers to light emitted from a light source that bounces one or more times in the scene before reaching the surface of an object. In contrast to "direct lighting," which comes directly from a light source, indirect lighting is a core element in achieving realistic rendering.
[0035] 4. Visibility direction: refers to the effective direction in which light can be received or emitted within the hemispherical illumination area at a point on the surface, without being obstructed by surrounding geometric structures. In the embodiments of this application, the visibility direction is the optimal visibility direction, i.e., the curvature normal; Bending normals are a core technical concept in computer graphics used for global illumination simulation. Their main function is to optimize the calculation accuracy of indirect lighting and enhance the realism of rendered images. Bending normals are a modification of geometric normals; they are no longer strictly perpendicular to the object's surface. Instead, they are "bent" according to the radiation information of the surrounding environment (such as the direction of surrounding light sources and reflective surfaces) to approximate the main incident direction of indirect lighting received at a point on the object's surface. Simply put, geometric normals describe the orientation of the surface, while bending normals describe the main source direction of indirect lighting.
[0036] 5. Ambient Occlusion (AO): AO is a rendering technique in computer graphics used to simulate the occlusion effect of local geometry on ambient light. Ambient occlusion is not the effect of direct light from a light source, but rather enhances the shadow details in areas such as object contact points, gaps, and recesses. It represents the degree to which "indirect light is blocked by surrounding geometry," making corners darker, contact surfaces more natural, and preventing objects from appearing to "float" in the scene, thereby improving the scene's three-dimensionality, realism, and spatial depth.
[0037] 6. Diffuse Reflection Brightness: Diffuse reflection refers to the optical phenomenon where light is uniformly scattered in all directions after hitting a rough surface. Diffuse reflection brightness is the degree of brightness perceived by the human eye or a camera, and it is mainly determined by the diffuse reflection color of the surface, the intensity of the incident light, the surface normal, and the direction of illumination.
[0038] 7. Specular Reflection Brightness: Specular reflection refers to the directional reflection of light on a smooth surface. Specular reflection brightness, or high light intensity, depends on multiple physical factors such as light source intensity, viewing angle, surface roughness, material properties, and the Fresnel effect.
[0039] In the description of the embodiments in this application, the term "exemplary" is used to mean "serving as an example, embodiment, or illustration." Any embodiment described as "exemplary" is not necessarily to be construed as superior to or better than other embodiments.
[0040] In the description of the embodiments of this application, unless otherwise stated, "a plurality of" means two or more.
[0041] The design concept of the embodiments of this application is briefly introduced below: Among related technologies, Lumen, the default fully dynamic global illumination (GI) and reflection system of Unreal Engine (UE), is proposed. Currently, Lumen determines global illumination based on real-time ray tracing, but due to performance limitations, it cannot emit a large number of rays, resulting in a relatively blurry effect of specular reflections. Consequently, in the virtual environment, some lighting effects are good, while other lighting effects are problematic.
[0042] For example, in the virtual environment of a first-person shooter game, the lighting effects of the virtual scene are relatively good, while the lighting of virtual objects (such as first-person weapons) suffers from problems such as insufficient precision, light leakage, instability, and blurriness. Related technologies have proposed improving the lighting effects of virtual objects by increasing the number of rays emitted per frame; however, due to performance limitations, this leads to a decrease in frame rate, resulting in screen stuttering and jitter, thus affecting the visual effect and user experience.
[0043] For example, when the frame rate is below 30 FPS, motion blur and ghosting are obvious. Virtual objects occupy about 1 / 3 of the screen's pixel space. At this time, blurring and frame skipping can cause aiming and visual problems to collapse, and even rendering errors such as light leakage and accuracy drift may occur, affecting the visual effect of the picture. At the same time, the lower the frame rate, the longer the interval between rendering and input response. In first-person shooter games, problems such as "firing half a beat too late" and "recoil drift" will occur, directly affecting the game experience. There will also be sudden changes in lighting and shadows, loss of material details, and abnormal motion blur, which will disrupt the lighting consistency between virtual objects and virtual scenes, exacerbate the "glitches", and affect the visual effect of the picture.
[0044] Therefore, improving the lighting and rendering effects of virtual environments to enhance visual effects and user experience is a technical problem that needs to be solved.
[0045] In view of this, embodiments of this application provide a lighting rendering method, apparatus, device, and storage medium, relating to the field of computer technology, and in particular to computer graphics, to improve the lighting rendering effect of virtual environments, thereby enhancing the visual effects of the screen and improving the user experience.
[0046] In the lighting rendering implementation provided in this application, at least one pixel position to be processed within the virtual environment is first obtained, and specular occlusion information is determined for each pixel position. This embodiment only processes the pixel positions that need to be rendered, avoiding processing non-spectral virtual objects within the virtual environment, thus saving computing resources. Furthermore, specular occlusion information is calculated independently for each pixel position, uniformly improving the lighting accuracy of each area and eliminating situations where some areas have good lighting effects while others have defects, thereby achieving a balanced improvement in the overall image's lighting levels and realism.
[0047] Determining specular occlusion information for each pixel location involves both Ground Truth Ambient Occlusion (GTAO) and Image-Based Illumination. In the implementation of Lighting (IBL), based on GTAO, the target occlusion data of the pixel position is obtained by combining the pixel depth value in the depth buffer and the view space normal in the normal buffer. The target occlusion data is used to describe the direction of incident light and the degree of occlusion of the unoccluded pixel position in the virtual environment, so as to accurately locate the target occlusion data describing the direction of incident light and the degree of occlusion. Based on IBL, the preset specular reflection brightness of the virtual environment is obtained by sampling from the environment map according to the reflection direction, and the target specular reflection brightness is obtained based on the preset specular reflection brightness. Then, based on the target occlusion data, the target specular reflection brightness associated with the pixel position is scaled to obtain the specular occlusion information of the pixel position. The specular occlusion information is used to describe the ability of the pixel position to receive indirect light in the specular reflection direction. Based on the target occlusion data, the specular reflection brightness is accurately scaled in a targeted manner, effectively suppressing light leakage and blurring in the specular area and improving the accuracy and stability of specular reflection.
[0048] Finally, based on the specular occlusion information at at least one pixel location, the current frame of the virtual environment is rendered with lighting. This precise specular occlusion information allows for a more realistic simulation of light occlusion and reflection effects in the virtual environment, restoring subtle light and shadow layers, color transitions, and material textures. Furthermore, it eliminates the need to increase the number of rays emitted per frame to improve lighting effects, avoiding frame rate drops, stuttering, and jitter caused by performance limitations. While ensuring high-quality lighting rendering, it maintains smooth visual performance, significantly enhancing the visual experience and ultimately improving the user experience.
[0049] In summary, the lighting rendering method of this application embodiment achieves targeted optimization of the lighting rendering effect in the virtual environment through precise pixel-level specular occlusion information without increasing the number of rays emitted per frame or consuming additional hardware performance. This improves the lighting rendering effect of the virtual environment, thereby enhancing the visual effect and user experience.
[0050] The application scenarios described below are briefly explained. It should be noted that these scenarios are for illustrative purposes only and are not intended to limit the scope of this application. In actual implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.
[0051] See Figure 1 , Figure 1This is a schematic diagram of an application scenario in an embodiment of this application. The application scenario diagram includes a terminal device 110 and a server 120. The terminal device 110 and the server 120 can communicate via a communication network; wherein, the communication network is a wired network or a wireless network.
[0052] In one alternative implementation, the terminal device 110 and the server 120 can be connected directly or indirectly via wired or wireless communication. For example, the terminal device 110 can be indirectly connected to the server 120 via a wireless access point, or the terminal device 110 can be directly connected to the server 120 via the Internet; this application does not impose any limitations on this.
[0053] In this embodiment, the terminal device 110 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, in-vehicle terminals, and other devices. The terminal device may have a client installed, which may be software, such as a browser, application software (e.g., social media video software, shopping software, music software, etc.), artificial intelligence (AI) tools, or web pages, mini-programs, etc.
[0054] In this embodiment, server 120 is a backend server corresponding to the client, or a server specifically used for screen rendering; this application does not impose specific limitations. Server 120 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0055] It should be noted that the lighting rendering method in each embodiment of this application can be executed by an electronic device, which can be a terminal device 110 or a server 120. That is, the method can be executed by the terminal device 110 or the server 120 alone, or by the terminal device 110 and the server 120 together.
[0056] It should be noted that, Figure 1 The example shown is merely illustrative; in reality, the number of servers 120 is unlimited and is not specifically limited in this embodiment. In this embodiment, when there are multiple servers 120, the multiple servers 120 can form a blockchain, and the servers 120 are nodes on the blockchain.
[0057] Furthermore, the embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, film and animation production, games, architecture and interior design, virtual reality and augmented reality, medical visualization, and other scenarios. A few examples are listed below: In film and animation production, lighting rendering methods are used to create a sense of realism in virtual scenes and to reproduce the texture of character skin, hair, and fabric.
[0058] In game scenes, dynamic lighting and shadows, global illumination, and environmental reflections are achieved through lighting rendering methods to enhance scene realism; balancing image quality and performance, basic lighting and shadow effects for characters and scenes are realized; for example, see Figure 2 , Figure 2 This is a schematic diagram illustrating lighting rendering in a game scene according to an embodiment of this application. Figure 2 As can be seen, game players enter the virtual environment of the game through a game client installed on their terminal devices, and the game's virtual environment content is displayed in real time on the terminal device's screen. Therefore, when a game player triggers a game command, the terminal device sends the game command to the server. After receiving the game command, the server performs lighting rendering on the virtual environment's content and then returns the generated image to the terminal device for display. When performing lighting rendering on the virtual environment's content, the server first obtains at least one pixel position to be processed within the virtual environment. Then, for each pixel position, it performs the following steps: based on the pixel depth value and view space normal associated with the pixel position, it obtains the target occlusion data of the pixel position, and based on the target occlusion data, it scales the target specular reflection brightness associated with the pixel position to obtain the specular occlusion information of the pixel position. Finally, based on the specular occlusion information of at least one pixel position, it performs lighting rendering on the virtual environment's content.
[0059] In architectural and interior design scenarios, lighting rendering methods are used to render the sunlight effects and light and shadow changes of building exteriors and interior spaces to aid in the presentation.
[0060] In virtual reality tourism, virtual reality games, and virtual reality social interaction, lighting rendering methods can be used to create natural lighting and shadows in the virtual environment in real time, thereby enhancing the user's sense of immersion.
[0061] In augmented reality scenarios, lighting rendering methods are used to match the light and shadow of virtual objects (furniture, makeup) with the real environment, achieving a fusion of virtual and real elements.
[0062] In medical visualization scenarios, lighting rendering methods are used to render the lighting of human organs and tissues, assisting in medical teaching and surgical simulation.
[0063] The lighting rendering method of this application embodiment achieves targeted optimization of the lighting rendering effect in the virtual environment through precise pixel-level specular occlusion information without increasing the number of rays emitted per frame or consuming additional hardware performance. This improves the lighting rendering effect of the virtual environment, thereby enhancing the visual effect of the screen and improving the user experience.
[0064] The application scenarios listed above are just simple examples. Other application scenarios are also applicable to the embodiments of this application, and will not be described in detail here.
[0065] It should be emphasized that the specific embodiments of this application involve user-related data. When the above embodiments of this application are applied to specific products or technologies, permission or consent from the target user is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0066] The lighting rendering method provided by the exemplary embodiments of this application will be described below with reference to the accompanying drawings and the application scenarios described above. It should be noted that the application scenarios described above are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.
[0067] See Figure 3 , Figure 3 A flowchart of a lighting rendering method provided in this application embodiment includes the following steps: Step S300: Obtain at least one pixel position to be processed within the virtual environment.
[0068] In this embodiment, the at least one pixel position to be processed can be any of the initial positions in the virtual environment, or it can be a partial selection of initial positions from all the initial positions in the virtual environment. This mainly depends on the classification parameter information related to pixel position classification in the lighting rendering framework of Unreal Engine. The classification parameter information is used to indicate whether pixel position classification is enabled.
[0069] For example, if the classification parameter information is false or 0, it is determined that pixel position classification is not enabled, and at least one pixel position to be processed is all the initial positions in the virtual environment; if the classification parameter information is true or 1, it is determined that pixel position classification is enabled, and at least one pixel position to be processed is a subset of the initial positions selected from all the initial positions in the virtual environment.
[0070] In one possible implementation, when at least one pixel position to be processed is determined to be a partial initial position selected from all initial positions in the virtual environment based on classification parameter information related to pixel position classification, at least one pixel position to be processed is obtained by filtering from all initial positions based on the effective roughness of each initial position.
[0071] The following steps, A1-A2, will explain in detail how to obtain the position of at least one pixel to be processed within the virtual environment.
[0072] Step A1: For each initial position in the virtual environment, perform the following: Based on the basic roughness of the initial position and the detailed information of the screen space, obtain the effective roughness of the initial position; the detailed information is used to describe the additional surface scattering characteristics of the initial position.
[0073] When obtaining the effective roughness of the initial position based on the basic roughness of the initial position and the detail information of the screen space, the initial roughness of the initial position is first obtained based on the roughness map preset for the two-dimensional texture space. The roughness map is used to describe the initial roughness of different initial positions. Then, the initial roughness is spatially transformed through texture interpolation to obtain the basic roughness of the screen space. Finally, the basic roughness is corrected based on the detail information to obtain the effective roughness of the initial position.
[0074] See Figure 4 , Figure 4 This is a schematic diagram illustrating an embodiment of obtaining effective roughness, from... Figure 4 From this, we can know that: Based on the initial position, roughness is sampled from the roughness map in the 2D texture space. Since the roughness map is stored in gamma space, it needs to be converted back to linear space. Therefore, after obtaining the sampled roughness, inverse gamma correction processing is performed to obtain the initial roughness. Since the initial roughness is obtained based on the roughness map in the 2D texture space, during rendering, texture interpolation (such as bilinear / trilinear filtering) is used to map the initial roughness in the 2D texture space to the screen space to obtain the base roughness in the screen space. Then, in order to improve the realism of the surface roughness, the base roughness is corrected based on the detail information in the screen space to obtain the effective roughness at the initial position. When correcting the base roughness based on detailed information, this includes, but is not limited to: overlaying micro-detail roughness to make slight corrections to the base roughness; and for dynamic rendering, dynamically correcting the base roughness, such as dynamically correcting the base roughness corresponding to pixels with wet surface effects or wear effects.
[0075] It should be noted that the base roughness can also be a pre-set parameter, such as parameter 0 indicating completely smooth and parameter 1 indicating completely rough, which is usually suitable for solid color or textureless surfaces.
[0076] When obtaining the effective roughness at the initial position, the basic material roughness attributes at each initial position can be accurately provided based on the preset roughness map, providing a reliable benchmark for obtaining the effective roughness subsequently and ensuring the consistency of the rendered material. Then, through texture interpolation, the initial roughness obtained from the preset roughness map is spatially transformed to ensure that the roughness smoothly transitions from the two-dimensional texture space to the screen space, avoiding abrupt roughness changes caused by spatial transformation and improving data accuracy. Next, the basic roughness is corrected by combining the screen space information, which can incorporate the surface micro-scattering characteristics, making the effective roughness more consistent with the real material performance and providing accurate input for subsequent pixel selection and lighting rendering.
[0077] Step A2: Select at least one initial position from all initial positions in the virtual environment whose effective roughness meets the preset roughness conditions, and use it as at least one pixel position to be processed in the virtual environment.
[0078] For example, among all initial positions, the initial positions with effective roughness less than the roughness threshold are selected, and the selected initial positions are used as at least one pixel position to be processed within the virtual environment.
[0079] See Figure 5 , Figure 5 This is a schematic diagram illustrating how to obtain the position of at least one pixel to be processed, provided in an embodiment of this application. Figure 5 From this, we can know that: Obtain all initial positions within the virtual environment and determine the effective roughness of each initial position. Among all effective roughnesses, filter out the effective roughnesses with an effective roughness less than a roughness threshold, and then determine the initial position corresponding to the filtered effective roughnesses. Use the initial position corresponding to the filtered effective roughnesses as at least one pixel position to be processed.
[0080] By using effective roughness, pixel positions that meet the preset roughness conditions are selected from all initial positions in the virtual environment for processing. This reduces the number of pixels that need to be processed for complex occlusion calculations and scaling. While ensuring visual effects, this significantly reduces computing power and further improves frame rate and smoothness.
[0081] Step S301: For each pixel location, perform the following steps: Based on the pixel depth value and view space normal associated with the pixel location, obtain the target occlusion data of the pixel location. The target occlusion data is used to describe the direction and degree of occlusion of the incident light that is not occluded at the pixel location in the virtual environment. Based on the target occlusion data, scale the target specular reflection brightness associated with the pixel location to obtain the specular occlusion information of the pixel location. The specular occlusion information is used to describe the ability of the pixel location to receive indirect light in the specular reflection direction.
[0082] In this embodiment, when obtaining specular occlusion information at a pixel location, initial occlusion data for the pixel location is first obtained based on the pixel depth value and view space normal associated with the pixel location. At this point, the basic occlusion information of the pixel location can be accurately captured, providing real and reliable raw data support for specular occlusion calculation and ensuring the accuracy of subsequent processing. Then, based on the historical occlusion data corresponding to the historical pixel locations of the pixel content in the previous N frames, the initial occlusion data is denoised to obtain the target occlusion data of the pixel location. This effectively suppresses the noise of fluctuations in single-frame occlusion data, avoids jitter and instability in specular occlusion information, and improves data stability. Finally, specular occlusion information at the pixel location is obtained based on the target occlusion data. The target occlusion data obtained after denoising is more consistent with the actual occlusion scene, and the specular occlusion information obtained accordingly is more accurate. This can effectively optimize defects such as specular blur and light leakage, and improve the accuracy of lighting rendering.
[0083] See Figure 6 , Figure 6 A flowchart for obtaining specular occlusion information at a pixel location, provided in an embodiment of this application, includes the following steps: Step S600: Based on the pixel depth value associated with the pixel position and the view space normal, obtain the initial occlusion data of the pixel position.
[0084] In one possible implementation, the initial occlusion data includes: visibility direction and ambient light occlusion degree; wherein, the visibility direction is the optimal visibility direction, also known as the curved normal. The curved normal is different from the view space normal, and using the curved normal to determine the lighting can achieve better results.
[0085] Below, based on the view space, we will explain in detail how to obtain the initial occlusion data through steps B1-B7.
[0086] Step B1: Obtain the pixel depth value of the pixel position from the depth buffer, and obtain the view space normal of the pixel position from the normal buffer.
[0087] The pixel depth value is used for visibility detection in the sampling direction, i.e., to determine whether the pixel sampling point corresponding to the sampling direction is occluded; the view space normal is used to constrain the orientation of the visible sampling area. It should be noted that the pixel depth value is a linear depth to avoid depth detection errors.
[0088] Step B2: Obtain the pre-set sampling parameters, including: preset number of samples and sampling neighborhood radius.
[0089] The preset number of samples can be set based on experience, such as 64 or 128, mainly balancing accuracy and performance; the sampling neighborhood radius is in pixels, such as 3 or 5, used to control the neighborhood range.
[0090] Step B3: Obtain the visible sampling area based on the view space normal and the preset sampling neighborhood radius.
[0091] The visible sampling region is the positive hemisphere region of the view space normal, and the radius of this positive hemisphere region is the sampling neighborhood radius.
[0092] Step B4: Based on a preset number of samples, generate at least one sampling direction within the visible sampling area, and obtain the pixel sampling points corresponding to each of the at least one sampling direction.
[0093] In one possible implementation, cosine-weighted importance sampling is used. Based on a preset number of samples, sampling directions consistent with the preset number of samples are generated within the positive hemisphere region of the view space normal. In this case, the distribution of sampling directions within the positive hemisphere region is similar to... Positive correlation, more closely matching the physical distribution of light, enhances the visual effect of curved normals. The angle between the sampling direction and the view space normal.
[0094] In one possible implementation, for each sampling direction, the pixel sampling point corresponding to the sampling direction is obtained based on the pixel position, the sampling neighborhood radius, and the screen resolution; for example, see formula (1):
[0095] in, For pixel position, For three-dimensional sampling direction, For the two-dimensional components in the three-dimensional sampling direction, To sample the neighborhood radius, For screen resolution, The sampling position corresponds to the sampling direction, and the pixel sampling point can be determined based on the sampling position.
[0096] Step B5: Based on the pixel depth value, obtain the occlusion status of at least one pixel sampling point.
[0097] In one possible implementation, when obtaining the occlusion status of at least one pixel sampling point based on the pixel depth value, for each pixel sampling point, the following steps are performed: based on the sampling position of the pixel sampling point, the sampling depth value of the pixel sampling point is obtained from the depth buffer, and the depth difference between the sampling depth value and the pixel depth value is determined. Based on the comparison result between the depth difference and a depth threshold, the occlusion status of the pixel sampling point is obtained. Wherein, if the comparison result is that the depth difference is less than the depth threshold, the occlusion status indicates that the pixel sampling point is not occluded; if the comparison result is that the depth difference is not less than the depth threshold, the occlusion status indicates that the pixel sampling point is occluded. It should be noted that the sampling depth value and the sampling depth value are in the same coordinate system and have the same scale, and both are linear depths.
[0098] By acquiring the sampling depth value of pixel sampling points through a depth buffer, it eliminates the need to emit a large amount of additional light. This efficiently acquires sampling depth data while controlling performance overhead and ensuring stable frame rates, thus avoiding screen stuttering. Furthermore, by determining the depth difference between the sampling depth value and the pixel depth value, and combining this with a depth threshold to determine occlusion, the logic is simple and computationally efficient. This allows for rapid differentiation of pixel sampling point occlusion, improving occlusion detection efficiency. Additionally, based on a clear threshold determination rule—a difference less than the threshold indicates no occlusion, and a difference not less than the threshold indicates occlusion—the determination of occlusion is more accurate and consistent, avoiding subjective judgment bias and reducing issues such as light leakage and misjudgment.
[0099] Step B6: Based on obtaining the occlusion status of at least one pixel sampling point, select the sampling direction corresponding to the pixel sampling point that meets the occlusion condition from at least one sampling direction.
[0100] In one possible implementation, from at least one sampling direction, the sampling directions corresponding to the unoccluded pixel sampling points that indicate occlusion are selected. Only the unoccluded sampling directions are retained, and invalid occlusion directions are directly discarded. This ensures that subsequent calculations focus on the actual incident light path, avoids invalid calculations, and improves the accuracy of specular occlusion information.
[0101] Step B7: Obtain the visibility direction based on the selected sampling direction, and obtain the ambient light occlusion degree based on the visibility direction and the view space normal.
[0102] In one possible implementation, all selected sampling directions are normalized and averaged, and the direction obtained after normalization and averaging is used as the visibility direction.
[0103] In one possible implementation, the degree of ambient light occlusion is obtained based on the cosine similarity between the visibility direction and the view space normal. The cosine similarity ranges from -1 to 1. For example, when the cosine similarity is 1, the visibility direction and the view space normal are completely aligned, thus determining the ambient light occlusion as no occlusion; when the cosine similarity is 0, the visibility direction and the view space normal are perpendicular, thus determining the ambient light occlusion as partial occlusion; and when the cosine similarity is -1, the visibility direction and the view space normal are completely opposite, thus determining the ambient light occlusion as full occlusion.
[0104] See Figure 7 , Figure 7 This is a schematic diagram illustrating an embodiment of the present application for obtaining a visibility direction, from... Figure 7 From this, we can know that: First, based on the view space normals obtained from the normal buffer and a preset sampling neighborhood radius, a positive hemisphere region is obtained. Second, based on a preset number of samples within the positive hemisphere region, at least one sampling direction is generated, and the sampling pixel corresponding to the sampling direction is determined. Then, from the depth buffer, the sampling depth value of the pixel sampling point and the pixel depth value at the pixel position are obtained, and the depth difference between the sampling depth value and the pixel depth value is determined. Next, based on the comparison result between the depth difference and the depth threshold, the occlusion status of the sampling direction is determined. If the comparison result is that the depth difference is less than the depth threshold, the occlusion status indicates that the pixel sampling point is not occluded; if the comparison result is that the depth difference is not less than the depth threshold, the occlusion status indicates that the pixel sampling point is occluded. Then, from at least one sampling direction, the sampling direction corresponding to the pixel sampling point whose occlusion status indicates that it is not occluded is selected. Finally, the direction obtained after normalizing and averaging all the selected sampling directions is used as the visibility direction.
[0105] When generating visibility direction and ambient occlusion level, pixel depth values and view space normals are directly obtained from the depth buffer and normal buffer, eliminating the need for additional ray emission or complex calculations. This efficient acquisition of basic data reduces performance overhead and ensures stable real-time rendering frame rates. Furthermore, the visible sampling area is determined based on the view space normals and a preset sampling neighborhood radius, precisely limiting the effective sampling range, avoiding invalid sampling, reducing redundant calculations, and improving sampling efficiency. Then, sampling directions are generated according to a preset number of samples, and effective directions are selected based on occlusion conditions, eliminating occluded invalid paths. This ensures that subsequent calculations are based on truly visible light paths, improving data accuracy and reducing noise and misjudgments. Finally, the ambient occlusion level is calculated based on the effective visibility direction, resulting in a more realistic understanding of light and shadow occlusion patterns, accurately restoring scene lighting and shadow layers, effectively improving issues such as light leakage and specular blur, enhancing lighting rendering accuracy and image realism, and optimizing the user's visual experience.
[0106] Step S601: Based on the historical pixel positions of the pixel content in the previous N frames, obtain the historical occlusion data of each of the N historical pixel positions; N is a positive integer.
[0107] Step S602: Based on N historical occlusion data, perform noise reduction processing on the initial occlusion data to obtain the target occlusion data.
[0108] Because the virtual object's perspective changes, the pixel position of the same pixel content is different in different frames. Therefore, when performing noise reduction on the initial occlusion data, we first determine the historical pixel position of the pixel content in the previous N frames, then obtain the historical occlusion data of each of the N historical pixel positions, and finally perform weighted processing on the obtained historical occlusion data and the initial occlusion data to obtain the target occlusion data.
[0109] Example: Visibility direction in target occlusion data = W1 Visibility direction in initial occlusion data + W2 Visibility direction in historical occlusion data; Ambient occlusion level in target occlusion data = W3 Ambient occlusion level in initial occlusion data + W4 The degree of ambient light occlusion in historical occlusion data; where W1, W2, W3, and W4 are set according to the actual situation, satisfying W1+W2=1 and W3+W4=1.
[0110] It should be noted that historical occlusion data refers to initial occlusion data or target occlusion data relative to the historical pixel positions in the previous N frames, and historical occlusion data relative to the pixel positions in the current frame.
[0111] See Figure 8 , Figure 8 This is a schematic diagram illustrating noise reduction processing of initial occlusion data provided in an embodiment of this application. Taking N=1 as an example, from... Figure 8 From this, we can know that: The pixel content A at pixel position A is mapped to pixel position B in the previous frame. Then, the historical occlusion data of pixel position B is obtained. The historical occlusion data is the initial occlusion data or target occlusion data of pixel position B in the previous frame. Then, the obtained historical occlusion data and the initial occlusion data are weighted and processed to obtain the target occlusion data. Noise reduction of the initial occlusion data based on the previous N frames of historical occlusion data effectively suppresses random noise and fluctuations in single-frame data, avoiding flickering and jitter issues in lighting rendering, and significantly improving the stability and continuity of occlusion data. Noise reduction is achieved solely through inter-frame data reuse, without increasing the amount of light emitted per frame, thus incurring no additional performance overhead. While addressing defects such as specular blur and light leakage in Lumen, it ensures stable frame rates and avoids stuttering. The denoised target occlusion data more closely resembles realistic occlusion scenes, providing accurate input for subsequent specular occlusion information calculations, effectively improving issues such as insufficient lighting accuracy and blurring in virtual objects (such as first-person weapons), and enhancing the realism of the rendering.
[0112] Step S603: Based on the target occlusion data, obtain the visibility cone; the visibility cone is used to describe the distribution range of the effective illumination or reflection direction of the pixel position within the associated hemispherical illumination area that is not occluded.
[0113] Here, the direction of the visibility cone is the visibility direction of the target occlusion data, and the opening angle of the visibility cone is the degree of ambient light occlusion of the target occlusion data.
[0114] The visibility cone accurately describes the distribution range of effective illumination or reflection directions that are not obstructed within the hemisphere of a pixel location, clearly defining the effective light path, solving the problem of fuzzy direction in traditional occlusion data, and providing a precise range basis for subsequent calculations.
[0115] Step S604: Based on the direction of reflected light from the virtual object's viewpoint to the pixel position and the effective roughness of the pixel position, a specular reflection cone is obtained; the specular reflection cone is used to describe the distribution range of the effective specular reflection light direction within the associated hemispherical illumination area of the pixel position.
[0116] In this model, the direction of the specular reflection cone represents the direction of reflected light from the virtual object's viewpoint to the pixel location. The opening angle of the specular reflection cone represents the effective roughness of the pixel location. Smaller roughness results in a narrower cone and more concentrated highlights; larger roughness results in a wider cone and softer highlights. By combining the effective roughness to generate the specular reflection cone, the model closely matches the microscopic characteristics of the material surface, accurately reproducing the distribution of effective specular reflection directions. This makes the reflection calculation more consistent with real physical laws, improving the fidelity of material texture reproduction.
[0117] In one possible implementation, the direction of the reflected ray is obtained based on the viewpoint direction of the virtual object's perspective and the viewspace normal. For example, it is calculated using a reflection formula based on the viewpoint direction of the virtual object's perspective and the viewspace normal.
[0118] Step S605: Based on the degree of intersection between the visibility cone and the specular reflection cone, the occlusion weight is obtained, and the target specular reflection brightness is scaled based on the occlusion weight to obtain the specular occlusion information at the pixel position.
[0119] See Figure 9 , Figure 9 A schematic diagram illustrating the degree of intersection between a visible cone and a specular reflection cone, provided as an embodiment of this application, is shown below. Figure 9 From this, we can know that: A visibility cone is constructed by using the visibility direction as the direction of the visibility cone and the ambient light occlusion level as the opening angle of the visibility cone; similarly, a specular cone is constructed by using the direction of the reflected light from the virtual object's viewpoint to the pixel position as the direction of the specular reflection cone and the effective roughness of the pixel position as the opening angle of the specular reflection cone; the intersection of the visibility cone and the specular reflection cone is determined, such as... Figure 9 The grid section shown.
[0120] In one possible implementation, the intersecting part is transformed to the [0, 1] interval, thus obtaining the occlusion weight.
[0121] By calculating the occlusion weights based on the intersection of the visibility cone and the specular reflection cone, the actual impact of occlusion on specular reflection can be quantified, avoiding weight determination bias and ensuring that the scaling of the target specular reflection brightness is accurately adapted to the actual occlusion scene. Based on the specular occlusion information obtained with accurate weights, defects such as specular blur, light leakage, and insufficient precision are effectively improved without increasing the amount of light emitted, balancing rendering accuracy and performance, and enhancing the lighting balance and realism of the virtual environment.
[0122] In this embodiment, the target specular reflection brightness can be a preset specular reflection brightness or a preset specular reflection brightness obtained after correction. Since the specular reflection brightness obtained after correction can make the indoor and outdoor specular reflection brightness in the virtual environment more accurate, the target specular reflection brightness is usually obtained after correction. For example, after obtaining the target occlusion data at the pixel location, before scaling the target specular reflection brightness associated with the pixel location based on the target occlusion data, a correction process is performed on the preset specular reflection brightness to obtain the target specular reflection brightness.
[0123] The following steps, C1-C2, will explain in detail how to correct the preset specular reflection brightness.
[0124] Step C1: Based on the target occlusion data and combined with the preset diffuse reflection brightness associated with the virtual environment, obtain the target diffuse reflection brightness at the pixel location.
[0125] In one possible implementation, when obtaining the target diffuse reflectance brightness of a pixel location based on target occlusion data and a preset diffuse reflectance brightness associated with the virtual environment, the visible area of the pixel location is obtained based on the target occlusion data, and the diffuse reflectance brightness of the hemispherical illumination area associated with the pixel location is obtained from the preset diffuse reflectance brightness associated with the virtual environment; the overlapping area between the visible area and the hemispherical illumination area is obtained, and the diffuse reflectance brightness corresponding to the overlapping area is used as the target diffuse reflectance brightness.
[0126] Based on target occlusion data, the visible area is obtained, and the actual range of diffuse light that can be received by a pixel is accurately defined. Then, by the overlap between the visible area and the hemispherical illumination area, the diffuse brightness of the target is determined. The hemisphere of the invisible area is removed, that is, the invalid direction of the occlusion is removed, and only the diffuse brightness of the real visible direction is retained. This is accurately integrated into the actual occlusion scene, corrects the deviation between the preset diffuse brightness and the real scene, improves the realism and accuracy of the diffuse brightness, and thus better conforms to the physical law of lighting. This makes the target diffuse brightness more in line with the actual scene light and shadow, improves the light and shadow layer and realism of the image, and effectively improves problems such as light leakage and over-brightness.
[0127] Step C2: Based on the target diffuse reflection brightness and the preset diffuse reflection brightness, combined with the preset specular reflection color associated with the virtual environment, the preset specular reflection brightness associated with the virtual environment is corrected to obtain the target specular reflection brightness associated with the pixel position.
[0128] In one possible implementation, the target specular reflection brightness equals the preset diffuse reflection brightness. Preset specular reflection diffraction / (target diffuse reflection brightness + preset specular reflection brightness). This system links the target diffuse reflection brightness, the preset diffuse reflection brightness, and the specular reflection brightness with color-corrected specular reflection, creating a physical relationship between diffuse and specular reflection. This aligns with real-world lighting patterns, preventing brightness imbalances and improving overall lighting harmony. Simultaneously, it dynamically adjusts specular reflection brightness based on a formula, adaptively adjusting according to actual diffuse reflection intensity. This effectively suppresses excessively strong or weak highlights or light leakage, accurately reproducing the glossy texture of materials and addressing the insufficient specular reflection accuracy in traditional solutions.
[0129] In this embodiment, the preset diffuse brightness, preset specular brightness, and preset specular color are all determined after region baking based on the built-in baked volume of Unreal Engine.
[0130] See Figure 10 , Figure 10 This is a schematic diagram of a pre-baked product provided in an embodiment of this application. Figure 10 From this, we can know that: In response to the baking command, the visibility information of the light source at each location is generated. After baking is completed, the lighting is switched to the highest level, and then the virtual object (the weapon in the figure) is taken out for inspection. When a good lighting effect is obtained, the pre-baked data is saved, that is, the preset diffuse brightness, preset specular brightness, and preset specular color are saved.
[0131] Step S302: Based on the specular occlusion information at at least one pixel location, perform lighting rendering on the current frame content of the virtual environment.
[0132] See Figure 11 , Figure 11 This is a schematic diagram illustrating a specific implementation of lighting rendering provided in an embodiment of this application. Figure 11 From this, we can know that: Read the classification parameter information and determine to enable pixel position classification based on the classification parameter information. At this time, determine the effective roughness group for the initial position of each pixel in the virtual environment. Then, select the initial position with effective roughness less than the roughness threshold from all the initial positions according to the effective roughness and use the selected initial position as at least one pixel position to be processed in the virtual environment. For each pixel location, the view space normal of the pixel location is obtained from the normal buffer. Based on the view space normal and the preset sampling neighborhood radius, the positive hemisphere region is obtained. Based on the preset number of samples, at least one sampling direction is generated within the positive hemisphere region, and the pixel sampling point of the sampling direction is determined. The pixel depth value of the pixel location and the sampling threshold value of the pixel sampling point are obtained from the depth buffer. Then, the depth difference between the sampling depth value and the pixel depth value is determined. Based on the comparison between the depth difference and the depth threshold, the occlusion status of the pixel sampling point is obtained. Based on the occlusion situation, the sampling direction corresponding to the unoccluded pixel sampling point is selected from at least one sampling direction; All selected sampling directions are normalized and averaged to obtain the visibility direction. Based on the cosine similarity between the visibility direction and the view space normal, the ambient light occlusion degree is obtained. Then, the obtained visible directions and ambient light occlusion degree are denoised to obtain target occlusion data. Based on target occlusion data, a visibility cone is obtained, and a specular reflection cone is obtained based on the direction of reflected light from the virtual object's viewpoint to the pixel position and the effective roughness of the pixel position. Based on target occlusion data, combined with the virtual environment associated with preset diffuse reflectance brightness, the target diffuse reflectance brightness at the pixel position is obtained. Based on the target diffuse reflectance brightness, preset diffuse reflectance brightness, and the virtual environment associated with preset specular reflectance color, the virtual environment associated with preset specular reflectance brightness is corrected to obtain the target specular reflectance brightness. Based on the degree of intersection between the visibility cone and the specular reflection cone, the occlusion weight is obtained, and the target specular reflection brightness is scaled based on the occlusion weight to obtain the specular occlusion information at the pixel position. Lighting rendering is performed on the current frame content of the virtual environment based on specular occlusion information at at least one pixel location.
[0133] It should be noted that when reading classification parameter information and determining that pixel position classification is not enabled based on the classification parameter information, all initial positions in the virtual environment are taken as at least one pixel position to be processed. At this time, the entire image will be processed. However, processing the entire image consumes a lot of computing power. Therefore, during the processing, blurring along the X-axis and blurring along the Y-axis will also be performed to avoid insufficient sampling.
[0134] See Figure 12 , Figure 12 This application provides a comparative illustration of screen lighting effects, wherein... Figure 12 (a) in the image is a first-person game screenshot obtained using Lumen lighting rendering. Figure 12 (b) is a first-person game screen image obtained based on the lighting rendering method provided in the embodiments of this application. By comparison, it can be seen that the lighting rendering method provided in the embodiments of this application greatly improves the texture of first-person weapons compared with Lumen lighting rendering. In particular, the occlusion of the left palm and the occlusion relationship between the gun and the hand are more accurate, and the highlight reflection on the gun body also has a better effect.
[0135] In this embodiment, the pixel positions to be rendered are processed to avoid processing non-spectral virtual objects in the virtual environment, thus saving computing resources. Furthermore, specular occlusion information is calculated independently for each pixel position, uniformly improving the lighting accuracy of each area and eliminating the situation where some areas have good lighting effects while others have defects, thereby achieving a balanced improvement in the overall image's lighting and shadow levels and realism. When determining specular occlusion information for each pixel position, the target occlusion data describing the incident light direction and occlusion degree is accurately located based on the pixel depth value and view space normal associated with the pixel position. Then, based on the target occlusion data, the target specular reflection brightness associated with the pixel position is scaled to obtain specular occlusion information describing the pixel position's ability to receive indirect light in the specular reflection direction. By specifically scaling the specular reflection brightness, light leakage and blurring in specular areas are effectively suppressed, improving the accuracy and stability of specular reflection. Furthermore, it performs lighting rendering based on accurate specular occlusion information, more realistically simulating the occlusion and reflection effects of light in real-world scenes within a virtual environment. This restores delicate light and shadow layers, color transitions, and material textures without increasing the number of rays emitted per frame to improve lighting effects. It avoids frame rate drops, stuttering, and jitter caused by performance limitations, ensuring high-quality lighting rendering while maintaining smooth visual performance, significantly improving the visual effects and enhancing the user experience.
[0136] Based on the same inventive concept, embodiments of this application also provide a lighting rendering apparatus. See also Figure 13 , Figure 13 A schematic diagram of the structure of the lighting rendering device 1300 may include: The acquisition unit 1301 is used to acquire the position of at least one pixel to be processed within the virtual environment; The execution unit 1302 is configured to perform the following operations for each pixel location: obtain target occlusion data for the pixel location based on the pixel depth value and view space normal associated with the pixel location; the target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment; and scale the target specular reflection brightness associated with the pixel location based on the target occlusion data to obtain specular occlusion information for the pixel location; the specular occlusion information describes the ability of the pixel location to receive indirect light in the specular reflection direction. The rendering unit 1303 is used to perform lighting rendering on the current frame content of the virtual environment based on specular occlusion information at at least one pixel location.
[0137] In one possible implementation, the acquisition unit 1301 is specifically used for: For each initial position within the virtual environment, the following steps are performed: Based on the basic roughness of the initial position and the detailed information in the screen space, the effective roughness of the initial position is obtained; the detailed information is used to describe the additional surface scattering characteristics of the initial position. From all initial positions within the virtual environment, select at least one initial position whose effective roughness meets the preset roughness conditions, and use it as at least one pixel position to be processed within the virtual environment.
[0138] In one possible implementation, the acquisition unit 1301 is specifically used for: Based on a roughness map pre-defined for the two-dimensional texture space, the initial roughness at the initial position is obtained; the roughness map is used to describe the initial roughness at different initial positions. By using texture interpolation, the initial roughness is spatially transformed to obtain the basic roughness of the screen space. Then, based on the detail information, the basic roughness is corrected to obtain the effective roughness of the initial position.
[0139] In one possible implementation, execution unit 1302 is specifically used for: Based on the pixel depth value associated with the pixel position and the view space normal, the initial occlusion data of the pixel position is obtained. Also, based on the historical pixel position of the pixel content in the previous N frames, the historical occlusion data of each of the N historical pixel positions is obtained; N is a positive integer. Based on N historical occlusion data, the initial occlusion data is denoised to obtain the target occlusion data.
[0140] In one possible implementation, the initial occlusion data includes: visibility direction and ambient light occlusion degree; execution unit 1302 is specifically used for: The visible sampling area is obtained based on the view space normal and the preset sampling neighborhood radius; Based on a preset number of samples, at least one sampling direction is generated within the visible sampling area, and pixel sampling points corresponding to each of the at least one sampling direction are obtained; Based on the pixel depth value, the occlusion status of at least one pixel sampling point is obtained, and based on the obtained occlusion status, the sampling direction corresponding to the pixel sampling point that meets the occlusion condition is selected from at least one sampling direction. The visibility direction is obtained based on the selected sampling direction, and the ambient occlusion degree is obtained based on the visibility direction and the view space normal.
[0141] In one possible implementation, execution unit 1302 is specifically used for: For each pixel sampling point, the following steps are performed: determine the sampling depth value of the pixel sampling point, determine the depth difference between the sampling depth value and the pixel depth value, and obtain the occlusion status of the pixel sampling point based on the comparison result between the depth difference and the depth threshold. Among them, the comparison result is that the depth difference is less than the depth threshold, and the occlusion status indicates that the pixel sampling point is not occluded.
[0142] In one possible implementation, execution unit 1302 is specifically used for: From at least one sampling direction, filter out the sampling direction corresponding to the unoccluded pixel sampling point that indicates the occlusion situation.
[0143] In one possible implementation, execution unit 1302 is specifically used for: Based on target occlusion data, a visibility cone is obtained; the visibility cone is used to describe the distribution range of effective lighting or reflection directions that are not occluded within the associated hemispherical illumination area of a pixel location. Based on the direction of reflected light rays from the virtual object's viewpoint to the pixel location and the effective roughness of the pixel location, a specular reflection cone is obtained; the specular reflection cone is used to describe the distribution range of the effective specular reflection light ray direction within the associated hemispherical illumination region of the pixel location; Based on the degree of intersection between the visibility cone and the specular reflection cone, the occlusion weight is obtained, and the target specular reflection brightness is scaled based on the occlusion weight to obtain the specular occlusion information at the pixel location.
[0144] In one possible implementation, the direction of the reflected ray is obtained based on the viewpoint direction of the virtual object's perspective and the view space normal.
[0145] In one possible implementation, after the execution unit 1302 obtains the target occlusion data at the pixel location, and before scaling the target specular reflection brightness associated with the pixel location based on the target occlusion data, it is further used for: Based on target occlusion data and combined with preset diffuse reflectance brightness associated with the virtual environment, the target diffuse reflectance brightness at the pixel location is obtained; Based on the target diffuse reflectance and the preset diffuse reflectance, and combined with the preset specular reflectance color associated with the virtual environment, the preset specular reflectance associated with the virtual environment is corrected to obtain the target specular reflectance associated with the pixel position.
[0146] In one possible implementation, execution unit 1302 is further configured to: Based on the target occlusion data, the visible area of the pixel location is obtained, and the diffuse reflection brightness of the hemispherical illumination area associated with the pixel location is obtained from the preset diffuse reflection brightness associated with the virtual environment. Obtain the overlapping area between the visible region and the hemispherical illumination region, and use the diffuse reflectance of the overlapping area as the target diffuse reflectance.
[0147] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.
[0148] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0149] Those skilled in the art will understand that various aspects of this application can be implemented as systems, methods, or computer program products. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0150] Having introduced the lighting rendering method and apparatus according to exemplary embodiments of this application, we will now introduce an electronic device according to another exemplary embodiment of this application.
[0151] In one embodiment, the electronic device may be a server, such as... Figure 1 The server 120 is shown. In this embodiment, the structure of the electronic device can be as follows: Figure 14 As shown, it includes a memory 1401, a communication module 1403, and one or more processors 1402.
[0152] The memory 1401 is used to store computer programs executed by the processor 1402. The memory 1401 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0153] Memory 1401 may be volatile memory, such as random-access memory (RAM); memory 1401 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1401 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1401 may be a combination of the above-described memories.
[0154] The processor 1402 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1402 is used to implement the above-described lighting rendering method when it calls the computer program stored in the memory 1401.
[0155] The communication module 1403 is used to communicate with terminal devices and other servers.
[0156] This application embodiment does not limit the specific connection medium between the memory 1401, communication module 1403, and processor 1402. This application embodiment... Figure 14 The memory 1401 and the processor 1402 are connected via a bus 1404, and the bus 1404 is in Figure 14 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1404 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 14 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.
[0157] In some possible implementations, memory 1401 stores a computer storage medium, which in turn stores a computer program for implementing the steps of the lighting rendering method of this application embodiment. When the computer program is executed by processor 1402, the processor performs the following process: Obtain the position of at least one pixel to be processed within the virtual environment; For each pixel location, the following steps are performed: Based on the pixel depth value and view space normal associated with the pixel location, target occlusion data for the pixel location is obtained. The target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment. Based on the target occlusion data, the specular reflection brightness associated with the pixel location is scaled to obtain specular occlusion information for the pixel location. The specular occlusion information describes the ability of the pixel location to receive indirect light in the specular reflection direction. Lighting rendering is performed on the current frame content of the virtual environment based on specular occlusion information at at least one pixel location.
[0158] In another embodiment, the electronic device may be a terminal device, such as... Figure 1 The terminal device 110 is shown. In this embodiment, the electronic device can be structured as follows: Figure 15 As shown, it includes, but is not limited to: radio frequency (RF) circuit 151, memory 152, display unit 153, camera 154, audio circuit 155, wireless Fidelity (Wi-Fi) module 156, processor 157, Bluetooth module 158, and power supply 159, etc.
[0159] RF circuit 151 can be used for receiving and transmitting data during communication. It can receive downlink data from the base station and hand it over to processor 157 for processing; it can also send uplink data to the base station. Typically, RF circuits include, but are not limited to, antennas, at least one amplifier, transceiver, coupler, low-noise amplifier, duplexer, and other devices.
[0160] The memory 152 can be used to store software programs and data. The processor 157 executes various functions of the terminal device and performs data processing by running the software programs or data stored in the memory 152. The memory 152 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 152 stores an operating system that enables the terminal device to run. In this application, the memory 152 may store the operating system and various application programs, and may also store code that executes the methods of the embodiments of this application.
[0161] The display unit 153 can be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device. Specifically, the display unit 153 may include a touch screen 1531 disposed on the front of the terminal device, which can collect touch operations of the user on or near it.
[0162] The display unit 153 can also be used to display information input by the user or information provided to the user, as well as various menus of the terminal device, in a graphical user interface (GUI). Specifically, the display unit 153 may include a display screen 1532 disposed on the front of the terminal device. The display screen 1532 may be configured as a liquid crystal display, a light-emitting diode, or the like. The display unit 153 can be used to display screen content, etc., as shown in the embodiments of this application.
[0163] The touch screen 1531 can be placed on top of the display screen 1532, or the touch screen 1531 and the display screen 1532 can be integrated to realize the input and output functions of the terminal device. After integration, it can be referred to as a touch display screen.
[0164] Camera 154 can be used to capture still images or videos. An object passes through the lens to generate an optical image that is projected onto a photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to processor 157 to be converted into a digital image signal.
[0165] The audio circuit 155 includes a speaker 1551 and a microphone 1552; the audio circuit 155 provides an audio interface between the user and the terminal device. The audio circuit 155 converts received audio data into electrical signals and transmits them to the speaker 1551, where the speaker 1551 converts them into sound signals for output. The terminal device can also be equipped with volume buttons for adjusting the volume of the sound signal. On the other hand, the microphone 1552 converts the collected sound signals into electrical signals, which are received by the audio circuit 155, converted into audio data, and then output to the RF circuit 151 for transmission to, for example, another terminal device, or to the memory 152 for further processing.
[0166] Wi-Fi is a short-range wireless transmission technology. Terminal devices can use Wi-Fi modules to help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access.
[0167] The processor 157 is the control center of the terminal device, connecting various parts of the terminal device through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 152 and calling data stored in the memory 152. In some embodiments, the processor 157 may include one or more processing units; the processor 157 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 157. In this application, the processor 157 can run the operating system, applications, user interface display and touch response, and the lighting rendering method of this embodiment. Furthermore, the processor 157 is coupled to the display unit 153.
[0168] Bluetooth module 158 is used to interact with other Bluetooth devices that also have Bluetooth modules via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a Bluetooth headset) that also has a Bluetooth module through Bluetooth module 158, thereby exchanging data.
[0169] The terminal device also includes a power supply 159 (such as a battery) to power various components. The power supply can be logically connected to the processor 157 via a power management system, which can then manage functions such as charging, discharging, and power consumption. The terminal device may also be equipped with a power button for powering on and off, as well as screen locking.
[0170] In some possible implementations, various aspects of the lighting rendering method provided in this application can also be implemented in the form of a computer program product, which includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps in the lighting rendering method according to the various exemplary embodiments of this application described above.
[0171] Computer program products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0172] The computer program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the computer program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.
[0173] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.
[0174] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0175] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The computer program can execute entirely on the user's electronic device, partially on the user's electronic device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).
[0176] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0177] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0178] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A lighting rendering method, characterized in that, The method includes: Obtain the position of at least one pixel to be processed within the virtual environment; For each pixel location, the following steps are performed: Based on the pixel depth value and view space normal associated with the pixel location, target occlusion data for the pixel location is obtained. The target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment. Based on the target occlusion data, the target specular reflection brightness associated with the pixel location is scaled to obtain specular occlusion information for the pixel location. The specular occlusion information describes the ability of the pixel location to receive indirect light in the specular reflection direction. Based on the specular occlusion information at at least one pixel location, the current frame content of the virtual environment is rendered with illumination.
2. The method as described in claim 1, characterized in that, The step of obtaining at least one pixel position to be processed within the virtual environment includes: For each initial position within the virtual environment, the following steps are performed: based on the basic roughness of the initial position and the detailed information of the screen space, the effective roughness of the initial position is obtained; the detailed information is used to describe the additional surface scattering characteristics of the initial position. From all initial positions within the virtual environment, at least one initial position whose effective roughness meets the preset roughness condition is selected and used as at least one pixel position to be processed within the virtual environment.
3. The method as described in claim 2, characterized in that, The process of obtaining the effective roughness of the initial position based on the basic roughness of the initial position and the detail information of the screen space includes: Based on a roughness map preset for a two-dimensional texture space, the initial roughness at the initial position is obtained; the roughness map is used to describe the initial roughness at different initial positions. By using texture interpolation, the initial roughness is spatially transformed to obtain the basic roughness of the screen space. Based on the detailed information, the basic roughness is then corrected to obtain the effective roughness of the initial position.
4. The method as described in claim 1, characterized in that, The process of obtaining target occlusion data for the pixel location based on the pixel depth value and view space normal associated with the pixel location includes: Based on the pixel depth value and view space normal associated with the pixel position, the initial occlusion data of the pixel position is obtained, and based on the historical pixel positions of the pixel content of the pixel position in the previous N frames, the historical occlusion data of each of the N historical pixel positions is obtained; where N is a positive integer. Based on N historical occlusion data, the initial occlusion data is denoised to obtain the target occlusion data.
5. The method as described in claim 4, characterized in that, The initial occlusion data includes: visibility direction and ambient light occlusion degree; Based on the pixel depth value associated with the pixel location and the view space normal, initial occlusion data for the pixel location is obtained, including: The visible sampling area is obtained based on the view space normal and the preset sampling neighborhood radius; Based on a preset number of samples, at least one sampling direction is generated within the visible sampling area, and pixel sampling points corresponding to each of the at least one sampling direction are obtained; Based on the pixel depth value, the occlusion status of at least one pixel sampling point is obtained respectively, and based on the obtained occlusion status, the sampling direction corresponding to the pixel sampling point that meets the occlusion condition is selected from the at least one sampling direction; The visibility direction is obtained based on the selected sampling direction, and the ambient light occlusion degree is obtained based on the visibility direction and the view space normal.
6. The method as described in claim 5, characterized in that, The step of obtaining the occlusion status of at least one pixel sampling point based on the pixel depth value includes: For each pixel sampling point, the following steps are performed: determine the sampling depth value of the pixel sampling point, determine the depth difference between the sampling depth value and the pixel depth value, and obtain the occlusion status of the pixel sampling point based on the comparison result between the depth difference and the depth threshold. The comparison result is that the depth difference is less than the depth threshold, and the occlusion condition indicates that the pixel sampling point is not occluded.
7. The method as described in claim 6, characterized in that, The step of selecting the sampling direction corresponding to the pixel sampling point that meets the occlusion condition from the at least one sampling direction based on the obtained occlusion situation includes: From the at least one sampling direction, the sampling direction corresponding to the unoccluded pixel sampling point is selected as the occlusion indication.
8. The method according to any one of claims 1-7, characterized in that, The step of scaling the specular reflection brightness associated with the pixel location based on the target occlusion data to obtain the specular occlusion information at the pixel location includes: Based on the target occlusion data, a visibility cone is obtained; the visibility cone is used to describe the distribution range of the effective illumination or reflection direction that is not occluded within the associated hemispherical illumination area of the pixel position. A specular reflection cone is obtained based on the direction of reflected light from the virtual object's viewpoint to the pixel location and the effective roughness of the pixel location; the specular reflection cone is used to describe the distribution range of the effective specular reflection light direction of the pixel location within the associated hemispherical illumination area; Based on the degree of intersection between the visibility cone and the specular reflection cone, an occlusion weight is obtained, and the target specular reflection brightness is scaled based on the occlusion weight to obtain the specular occlusion information at the pixel location.
9. The method as described in claim 8, characterized in that, The direction of the reflected light is obtained based on the viewpoint direction of the virtual object's perspective and the view space normal.
10. The method according to any one of claims 1-7, characterized in that, After obtaining the target occlusion data at the pixel location, and before scaling the target specular reflection brightness associated with the pixel location based on the target occlusion data, the method further includes: Based on the target occlusion data and combined with the preset diffuse reflectance brightness associated with the virtual environment, the target diffuse reflectance brightness at the pixel location is obtained; Based on the target diffuse reflectance and the preset diffuse reflectance, and combined with the preset specular reflectance color associated with the virtual environment, the preset specular reflectance associated with the virtual environment is corrected to obtain the target specular reflectance associated with the pixel position.
11. The method as described in claim 10, characterized in that, The step of obtaining the target diffuse reflectance brightness at the pixel location based on the target occlusion data and in conjunction with the preset diffuse reflectance brightness associated with the virtual environment includes: Based on the target occlusion data, the visible area of the pixel location is obtained, and the diffuse reflection brightness of the hemispherical illumination area associated with the pixel location is obtained from the preset diffuse reflection brightness associated with the virtual environment. Obtain the overlapping area between the visible area and the hemispherical illumination area, and use the diffuse reflection brightness corresponding to the overlapping area as the target diffuse reflection brightness.
12. A lighting rendering apparatus, characterized in that, The device includes: The acquisition unit is used to acquire the position of at least one pixel to be processed within the virtual environment. The execution unit is configured to perform the following operations for each pixel location: obtain target occlusion data for the pixel location based on the pixel depth value and view space normal associated with the pixel location; the target occlusion data describes the direction and degree of occlusion of unoccluded incident light at the pixel location in the virtual environment; and scale the target specular reflection brightness associated with the pixel location based on the target occlusion data to obtain specular occlusion information for the pixel location; the specular occlusion information describes the ability of the pixel location to receive indirect light in the specular reflection direction. The rendering unit is used to perform lighting rendering on the current frame content of the virtual environment based on the specular occlusion information of the at least one pixel position.
13. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1-11.
14. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1-11.
15. A computer program product, characterized in that, The method includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the methods described in claims 1-11.
Citation Information
Patent Citations
Illumination rendering method and device, computer readable medium and electronic equipment
CN111915712A
Illumination scene rendering method and device, computer readable storage medium and computer program product
CN121505132A