Lighting rendering method, device, electronic device and storage medium

By determining the scene shading points in the dynamic scene, emitting virtual step rays, and controlling the step length according to the updated directed distance field information, the problem of poor dynamic model rendering is solved and efficient indirect lighting rendering is achieved.

CN115115747BActive Publication Date: 2025-01-21NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110258473.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-09
Publication Date
2025-01-21
Estimated Expiration
2041-03-09

AI Technical Summary

Technical Problem

The existing technology cannot effectively render dynamic models, resulting in poor rendering effects.

Method used

By determining the current scene shading point, emit virtual step rays, determine the step length based on the updated scene directional distance field information, control the rays to extend to the scene to determine the intersection point, and perform indirect lighting calculations.

Benefits of technology

It achieves the acquisition of accurate directional distance field information in dynamic scenes, improves the accuracy of virtual stepping rays, and enhances the indirect lighting rendering effect in dynamic scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115115747B_ABST
    Figure CN115115747B_ABST
Patent Text Reader

Abstract

The present application provides a lighting rendering method, device, electronic device and storage medium, and relates to the field of rendering technology. The method includes: determining the current scene shading point; emitting a virtual stepping ray according to the current scene shading point; determining the step length corresponding to the virtual stepping ray according to the scene directed distance field information corresponding to the updated current frame; controlling the virtual stepping ray to extend into the scene according to the step length to determine at least one scene intersection; determining the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation. This solution can improve the accuracy of the obtained directed distance field information, so that the accurate stepping of the virtual stepping ray can be controlled based on the obtained more accurate directed distance field information, so that the obtained scene intersection is more accurate, and accurate indirect lighting is obtained, thereby improving the rendering effect of indirect lighting in dynamic scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of rendering technology, and in particular to a lighting rendering method, device, electronic device and storage medium. Background Art

[0002] Some advanced rendering effects in games, such as diffuse global illumination, specular reflection, soft shadows, ambient occlusion and other indirect lighting rendering, can be achieved through raymarching technology. In raymarching technology, the length of ray marching depends on the shortest distance from the current position to the virtual model in the scene, that is, the SDF (Signed-distance-field) value.

[0003] In the prior art, the SDF data of each model is calculated offline and stored in a small 3D texture. During real-time rendering, the 3D texture containing the model's SDF data is applied to the actual position of the model in the scene through translation, rotation and scaling to obtain the model's real SDF information, which is then updated to the SDF data of the entire scene.

[0004] However, the above method is not applicable to the rendering of dynamic models. Summary of the invention

[0005] The purpose of this application is to provide a lighting rendering method, device, electronic device and storage medium to address the deficiencies in the above-mentioned prior art, so as to solve the problem of poor dynamic model rendering effect in the prior art.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, an embodiment of the present application provides a lighting rendering method, comprising:

[0008] Determine the current scene shading point;

[0009] emitting a virtual stepping ray according to the current scene shading point;

[0010] Determine the step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame;

[0011] Controlling the virtual stepping ray to extend into the scene according to the stepping length to determine at least one scene intersection point;

[0012] Color information of the scene intersection is determined according to incident light information and material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

[0013] Optionally, the scene signed distance field information corresponding to the updated current frame is information obtained by reading a signed distance field texture map corresponding to the updated current frame, wherein different map pixels in the signed distance field texture map correspond to different spatial ranges in the game world space determined according to the position of the virtual camera, and the scene signed distance field information of the corresponding spatial range is stored in the map pixels.

[0014] Optionally, the signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same pixel size to store scene signed distance field information of a corresponding spatial range, and the spatial range corresponding to each layer of texture maps is determined according to the spatial range of the game world space and the distance from the virtual camera.

[0015] Optionally, the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map is calculated in the following manner:

[0016] Obtaining the current position information of the virtual camera;

[0017] Generate multi-layer scene depth information according to the current position information of the virtual camera;

[0018] The scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame is determined according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, or according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame.

[0019] Optionally, generating multi-layer scene depth information according to the current position information of the virtual camera includes:

[0020] Determine each scene captured by the virtual camera according to the current position information;

[0021] Determine a first depth layer and a second depth layer of each scene respectively, wherein the first depth layer is used to indicate depth information of the scene close to the virtual camera, and the second depth layer is used to indicate depth information of the scene far from the virtual camera;

[0022] Determine a first distance and a second distance of a first depth layer and a second depth layer of each scene from the virtual camera, respectively;

[0023] The multi-layer scene depth information is generated according to the first distance and the second distance of each scene.

[0024] Optionally, generating the multi-layer scene depth information according to the first distance and the second distance of each scene includes:

[0025] Sort the first distances of the scenes in order from near to far, and determine first depth information of the multi-layer scene depth information, where the first depth information is used to indicate the front layer depth information of the scenes facing the virtual camera;

[0026] The second distances of the scenes are sorted in order from near to far to determine the second depth information of the multi-layer scene depth information, where the second depth information is used to indicate the depth information of the back layer of the scenes facing away from the virtual camera.

[0027] Optionally, determining the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel includes:

[0028] Determine that the spatial range corresponding to the current map pixel is within the field of view of the virtual camera;

[0029] Compare the depth value of the spatial range corresponding to the current map pixel with the first depth information and the second depth information of the multi-layer scene depth information, the current map pixel being any one of the map pixels;

[0030] According to the comparison result, the scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined.

[0031] Optionally, determining the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the comparison result includes:

[0032] The scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined according to the comparison result, the depth value of the spatial range corresponding to the current map pixel, and the first depth information and the second depth information.

[0033] Optionally, determining the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame includes:

[0034] Determining that a spatial range corresponding to a current map pixel is not within the field of view of the virtual camera;

[0035] The scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the previous frame is determined as the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the current frame, and the current map pixel is any map pixel among the map pixels.

[0036] Optionally, the method further comprises:

[0037] Determining a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel;

[0038] According to the correction parameters, the scene signed distance field information of the corresponding spatial range stored in the current map pixel is corrected.

[0039] Optionally, determining, according to the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel comprises:

[0040] If there is a neighboring map pixel whose sign of the scene signed distance field information of the corresponding spatial range stored is opposite to the sign of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, a correction parameter of the scene signed distance field information of the corresponding spatial range stored by the current map pixel is determined to be half the size of the spatial range.

[0041] Optionally, determining, according to the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel comprises:

[0042] If the signs of the scene signed distance field information of the corresponding spatial range stored by all the neighboring map pixels are the same as the sign of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, then traverse each of the neighboring map pixels, respectively calculate the sum of the distance from each of the neighboring map pixels to the current map pixel and the absolute value of the scene signed distance field information of the corresponding spatial range stored by each of the neighboring map pixels, and determine the minimum sum value from the sum values ​​corresponding to each of the neighboring map pixels;

[0043] If the minimum sum is smaller than the absolute value of the scene signed distance field information of the corresponding spatial range stored in the current map pixel, the correction parameter of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined to be the minimum sum.

[0044] In a second aspect, an embodiment of the present application further provides a lighting rendering device, including: a determination module, a transmission module;

[0045] The determination module is used to determine the current scene shading point;

[0046] The emission module is used to emit a virtual stepping ray according to the current scene shading point;

[0047] The determining module is used to determine the step length corresponding to the virtual stepping ray according to the scene directed distance field information corresponding to the updated current frame;

[0048] The determining module is used to control the virtual stepping light to extend into the scene according to the stepping length to determine at least one scene intersection point;

[0049] The determination module is used to determine the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

[0050] Optionally, the scene signed distance field information corresponding to the updated current frame is information obtained by reading a signed distance field texture map corresponding to the updated current frame, wherein different map pixels in the signed distance field texture map correspond to different spatial ranges in the game world space determined according to the position of the virtual camera, and the scene signed distance field information of the corresponding spatial range is stored in the map pixels.

[0051] Optionally, the signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same pixel size to store scene signed distance field information of a corresponding spatial range, and the spatial range corresponding to each layer of texture maps is determined according to the spatial range of the game world space and the distance from the virtual camera.

[0052] Optionally, the device further comprises: an acquisition module and a generation module;

[0053] The acquisition module is used to acquire the current position information of the virtual camera;

[0054] The generating module is used to generate multi-layer scene depth information according to the current position information of the virtual camera;

[0055] The determination module is further configured to determine the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, or according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame.

[0056] Optionally, the generation module is specifically used to determine the scenes captured by the virtual camera based on the current position information; respectively determine a first depth layer and a second depth layer of the scenes, the first depth layer being used to indicate the depth information of the scenes close to the virtual camera, and the second depth layer being used to indicate the depth information of the scenes far away from the virtual camera; determine a first distance and a second distance of the first depth layer and the second depth layer of the scenes from the virtual camera, respectively; and generate the multi-layer scene depth information based on the first distance and the second distance of the scenes.

[0057] Optionally, the generation module is specifically used to sort the first distances of the scenes in order from near to far to determine the first depth information of the multi-layer scene depth information, the first depth information being used to indicate the front layer depth information of the scenes facing the virtual camera; and sort the second distances of the scenes in order from near to far to determine the second depth information of the multi-layer scene depth information, the second depth information being used to indicate the back layer depth information of the scenes facing away from the virtual camera.

[0058] Optionally, the determination module is specifically used to determine whether the spatial range corresponding to the current map pixel is within the field of view of the virtual camera; compare the depth value of the spatial range corresponding to the current map pixel with the first depth information and the second depth information of the multi-layer scene depth information, and the current map pixel is any map pixel among the map pixels; based on the comparison result, determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel.

[0059] Optionally, the determination module is specifically used to determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the comparison result, the depth value of the spatial range corresponding to the current map pixel, and the first depth information and the second depth information.

[0060] Optionally, the determination module is specifically used to determine that the spatial range corresponding to the current map pixel is not within the field of view of the virtual camera; determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the previous frame as the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the current frame, and the current map pixel is any map pixel among the map pixels.

[0061] Optionally, the device further comprises: a correction module;

[0062] The determination module is further configured to determine a correction parameter for the scene directed distance field information of the corresponding spatial range stored by the current map pixel according to the scene directed distance field information of the corresponding spatial range stored by the current map pixel and the scene directed distance field information of the corresponding spatial range stored by neighboring map pixels of the current map pixel;

[0063] The correction module is used to correct the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the correction parameter.

[0064] Optionally, the determination module is specifically used to determine that the correction parameter of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is half the size of the spatial range if there is a neighbor map pixel whose sign of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is opposite to the sign of the scene signed distance field information of the corresponding spatial range stored in the current map pixel.

[0065] Optionally, the determination module is specifically configured to, if the signs of the scene directed distance field information of the corresponding spatial range stored in all the neighboring map pixels are the same as the sign of the scene directed distance field information of the corresponding spatial range stored in the current map pixel, traverse each of the neighboring map pixels, respectively calculate the sum of the distance from each of the neighboring map pixels to the current map pixel and the absolute value of the scene directed distance field information of the corresponding spatial range stored in each of the neighboring map pixels, and determine the minimum sum value from the sum values ​​corresponding to each of the neighboring map pixels; if the minimum sum value is less than the absolute value of the scene directed distance field information of the corresponding spatial range stored in the current map pixel, determine that the correction parameter of the scene directed distance field information of the corresponding spatial range stored in the current map pixel is the minimum sum value.

[0066] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the method provided in the first aspect.

[0067] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method provided in the first aspect are executed.

[0068] The beneficial effects of this application are:

[0069] The present application provides a lighting rendering method, device, electronic device and storage medium, the method comprising: determining the current scene shading point; emitting a virtual stepping ray according to the current scene shading point; determining the step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame; controlling the virtual stepping ray to extend into the scene according to the step length to determine at least one scene intersection; determining the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation. In this solution, the scene directed distance field information corresponding to the current frame obtained is the information updated in real time, which can improve the accuracy of the obtained directed distance field information, and realize the acquisition of accurate directed distance field information in dynamic scenes, so that the accurate stepping of the virtual stepping ray can be controlled based on the obtained more accurate directed distance field information, so that the obtained scene intersection is more accurate, and accurate indirect lighting is obtained, thereby improving the rendering effect of indirect lighting in dynamic scenes.

[0070] Secondly, this application uses multi-layer SDF texture maps to store signed distance field information, and different spatial ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids the excessive video memory occupancy caused by storing uniform SDF texture maps for the entire scene (the same spatial range is mapped both near and far), while covering a longer distance, and the difference between the calculation results of indirect lighting and the detailed signed distance field information of the entire scene will not be too large.

[0071] In addition, the depthpeeling technology is used to generate multi-layer scene depth information at the current virtual camera position, so that we can accurately know whether any spatial point in the current virtual camera field of view is inside or outside the scene, that is, the positive and negative signs of the calculated scene signed distance field information are reliable. The positive and negative signs of each scene's signed distance field information are calculated based on multi-layer scene depth information, so that the deviation of the signed distance field information caused by the parallax problem can be avoided.

[0072] Finally, the direct lighting information of the scene is also stored in the SDF texture map, which can efficiently realize the global light calculation of the scene. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0074] Figure 1 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 1 ;

[0075] Figure 2 A schematic diagram of a signed distance field texture map provided in an embodiment of the present application;

[0076] Figure 3 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 2 ;

[0077] Figure 4 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 3 ;

[0078] Figure 5 A multi-layer scene depth diagram provided in an embodiment of the present application;

[0079] Figure 6 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 4 ;

[0080] Figure 7 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 5 ;

[0081] Figure 8 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 6 ;

[0082] Fig. 9A schematic diagram of a lighting rendering device provided in an embodiment of the present application;

[0083] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0084] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0085] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

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

[0087] First, some terms that may be involved in this application are explained:

[0088] 1. SDF: Signed Distance Field, a signed distance field. Given a position point in any space, it returns the closest distance between this position point and the scene object. If the position point is outside the object, it returns a positive value, and if it is inside the object, it returns a negative value.

[0089] 2. Ray Marching: Ray marching. Rays are emitted from the camera to each pixel on the screen. The rays intersect with the scene by advancing step by step. The distance of each step is determined by the current position of the ray. If the step length is too large, thinner objects may be skipped and the actual intersection point may be missed. After obtaining the intersection point, the material, texture and other information of the scene surface can be obtained according to the intersection point position, and the lighting can be calculated in combination with the light source information.

[0090] 3. Scene: The virtual models in the game scene space constitute the scene.

[0091] 4. SDF texture map's texture pixels: refers to the pixel grid in the texture map, each pixel grid corresponds to a certain range of game scene space.

[0092] 5. Direct lighting: The lighting information generated when the light from the light source directly shines on the scene.

[0093] 6. Indirect lighting: The lighting information generated by one or more reflected light sources shining on the scene.

[0094] Figure 1 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 1 ; The execution subject of this method can be a terminal or a server. Figure 1 As shown, the method may include:

[0095] S101, determine the current scene shading point.

[0096] The current scene may refer to a target rendering model in the game scene to be rendered. Generally, the game scene to be rendered may include multiple models to be rendered, and the models to be rendered may be virtual buildings, virtual characters, virtual terrain, etc. in the game scene to be rendered.

[0097] Optionally, a virtual camera can emit a virtual stepping ray to the current scene to determine that the point on the current scene hit by the virtual stepping ray is the shading point of the current scene. The shading point is the point that needs to be rendered by lighting. After lighting rendering all the shading points of the current scene, the rendering of the current scene can be completed. It should be noted that the shading point can be an area in the scene or a specific point, which is determined based on the actual situation.

[0098] S102: Issue a virtual stepping ray according to the current scene shading point.

[0099] Some advanced rendering effects of the game, such as diffuse global illumination, specular reflection, soft shadow, ambient occlusion, etc., can be achieved by rendering the scene with indirect lighting. In this embodiment, the method is mainly used to calculate the indirect lighting of the scene, while the calculation of direct lighting can be calculated based on known direct lighting information.

[0100] The calculation of indirect lighting of the current scene needs to be combined with the lighting information generated by the reflection of other scenes in the game scene to the current scene. The lighting information generated by other scenes reflecting to the current scene can be calculated based on the scene surface material texture and other information obtained at the intersection position of the stepping ray and other scenes.

[0101] Optionally, virtual stepping rays can be randomly emitted from the current scene shading point into the scene according to the current scene shading point, so that the virtual stepping rays finally determine the intersection with other scenes through stepping. In an optional implementation example, virtual stepping rays are randomly emitted within a spherical range with the current scene shading point as the center. Some of the randomly emitted rays may intersect with the scene, all of them may intersect with the scene, or none of them may intersect with the scene. When the virtual ray intersects with the scene, it means that the light emitted by the light source in the game scene is reflected from the scene to the current scene shading point.

[0102] S103: Determine a step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame.

[0103] Optionally, when the virtual stepper ray is emitted forward from the current scene shading point, it can be advanced step by step according to the step length, and the step length depends on the shortest distance between the current position of the virtual stepper ray and the scene, that is, the signed distance field information of the current position of the virtual stepper ray. Since the virtual stepper ray advances step by step, each frame corresponds to one step, and the travel length of each step can be determined according to the signed distance field information of the current frame scene until the virtual stepper ray intersects with the scene. It should be noted that in the present application, the intersection of the virtual stepper ray and the scene means that the distance between the current position of the ray and the scene meets the preset distance or is on the surface of the scene, that is, as long as the position of the ray step is close enough to the scene, or the spacing is acceptable, the virtual stepper ray is considered to intersect with the scene.

[0104] In some embodiments, due to changes in the scene position, for example, if the scene is a virtual vehicle, its position may change in real time. In this case, the scene signed distance field information corresponding to the current frame also changes. In this case, the scene signed distance field information corresponding to the current frame can be updated in real time, and the step length corresponding to the virtual stepping ray is determined according to the updated scene signed distance field information corresponding to the current frame, thereby ensuring the accuracy of the acquired step length.

[0105] S104 , controlling the virtual stepping ray to extend into the scene according to the stepping length to determine at least one scene intersection point.

[0106] Optionally, as mentioned above, the step length of the virtual stepping ray of the current frame can be determined for each frame, so that the virtual stepping ray can be controlled to extend forward according to the step length determined for each frame, so that the virtual stepping ray intersects with at least one scene to determine the intersection point. The at least one scene is a scene other than the current scene (target scene).

[0107] S105. Determine color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

[0108] Optionally, the incident light information may include: light color, intensity, angle, material, attenuation, etc. The material information of the scene intersection may include information such as the material and texture of the scene surface at the scene intersection position. Optionally, the color information of each scene intersection may be determined based on the incident light information and the material information of each scene intersection.

[0109] In one achievable manner, an indirect lighting rendering algorithm may be used to perform indirect lighting rendering on the current scene according to the color information of the intersections of each scene and the color information of the current scene. The indirect lighting rendering algorithm may be executed with reference to an existing lighting rendering algorithm.

[0110] In summary, the lighting rendering method provided by the present embodiment includes: determining the current scene shading point; emitting a virtual stepping ray according to the current scene shading point; determining the step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame; controlling the virtual stepping ray to extend into the scene according to the step length to determine at least one scene intersection; determining the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation. In this solution, the scene directed distance field information corresponding to the current frame obtained is the information updated in real time, which can improve the accuracy of the obtained directed distance field information, and realize the acquisition of accurate directed distance field information in dynamic scenes, so that the accurate stepping of the virtual stepping ray can be controlled based on the obtained more accurate directed distance field information, so that the obtained scene intersection is more accurate, and accurate indirect lighting is obtained, thereby improving the rendering effect of indirect lighting in dynamic scenes.

[0111] Optionally, the scene signed distance field information corresponding to the updated current frame is information obtained by reading a signed distance field texture map corresponding to the updated current frame, wherein different map pixels in the signed distance field texture map correspond to different spatial ranges in the game world space determined according to the position of the virtual camera, and the scene signed distance field information of the corresponding spatial range is stored in the map pixels.

[0112] In one practicable manner, the scene signed distance field information may be stored in a signed distance field texture map, that is, an SDF texture map, so that the scene signed distance field information may be read more efficiently from the SDF texture map during game operation to perform ray stepping.

[0113] Generally, an SDF texture map is composed of multiple map pixels, one map pixel is also a pixel grid, and each map pixel is used to map different spatial ranges of the game world space, so that each map pixel stores the scene signed distance field information of the corresponding spatial range. Among them, the signed distance field information of any point in the spatial range can be represented by the scene signed distance field information of the spatial range. That is, the signed distance field information of all points in a small spatial range is uniformly represented.

[0114] Optionally, the signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same pixel size to store scene signed distance field information of a corresponding spatial range, and the spatial range corresponding to each layer of texture maps is determined according to the spatial range of the game world space and the distance from the virtual camera.

[0115] Figure 2 A schematic diagram of a signed distance field texture map provided in an embodiment of the present application. In the present application, the SDF texture map established may be a multi-layer texture map. In one achievable method, for example Figure 2 As shown, the SDF texture map can be a three-layer 3D texture map established around the virtual camera, which respectively maps the spatial range of the game world space at different distances from the virtual camera.

[0116] like Figure 2 As shown, each layer is the spatial range mapped by the SDF texture map. The spatial range to which the scene signed distance field information stored in each layer of texture maps belongs is determined by the virtual camera position. When the virtual camera position changes, the spatial range corresponding to the texture map also changes accordingly. Among them, the number of texture maps in each layer does not change, and each layer of texture maps uses the same pixel size to store the scene signed distance field information of the corresponding spatial range, that is, each layer of texture maps is a texture map with equal length, width and height, so the video memory occupied by the SDF texture map is always fixed. In this embodiment, three layers of texture maps use the same pixel size to save scenes corresponding to different densities to achieve.

[0117] Optionally, different spatial ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer you are to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther you are from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids excessive video memory usage caused by storing SDF texture maps uniformly for the entire scene (the same spatial range is mapped both near and far), while covering a longer distance, and the difference between the calculation results of indirect lighting and the detailed directed distance field information of the entire scene will not be too large.

[0118] Optionally, during the virtual stepping ray marching process, the stepping length may be determined by reading the signed distance field information corresponding to the target space range from the SDF texture map.

[0119] In an achievable way, in order to access the signed distance field information of a certain position in a certain spatial range in the game world space through the SDF texture map, the coverage box range (AABB: axis-aligned bounding box) of the SDF texture map in the game world space is now defined, the minimum bounding box coordinate value is BBMin, and the maximum bounding box coordinate value is BBMax. Then, each texture pixel (texture coordinate UVW) of the SDF texture map can be accurately mapped to a spatial range (WorldPos), and vice versa. The mapping formula can be as follows:

[0120] WorldPos=BBMin+(BBMax-BBMin)*UVW

[0121] UVW=(WorldPos-BBMin) / (BBMax-BBMin)

[0122] Figure 3 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 2 ; Optionally, in the above steps, the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map is calculated by the following method:

[0123] S301, obtaining the current position information of the virtual camera.

[0124] Optionally, the current position information of the virtual camera can be obtained in real time, and the combination of the virtual camera and the light source can be equivalent to the eyes of the observer.

[0125] The virtual stepping ray emitted by the virtual camera to the current scene can pass through the near clipping plane of the screen and hit the scene, wherein the near clipping plane can be composed of multiple pixels, and the size of the near clipping plane can be the same as the size of the display area of ​​the terminal, or it can be different from the size of the display area. The picture displayed on the near clipping plane can be equivalent to the picture displayed on the mobile phone.

[0126] S302: Generate multi-layer scene depth information according to the current position information of the virtual camera.

[0127] Optionally, based on the current position information of the virtual camera determined above, multi-layer scene depth information of the virtual camera at the current position can be generated. The generation method can adopt depth peeling technology to generate front layer depth information and back layer depth information according to the scene distance from the virtual camera from near to far. The specific implementation can refer to the following embodiment.

[0128] S303. Determine the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, or according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame.

[0129] As described in the above-mentioned embodiments, the scene signed distance field information of the corresponding spatial range stored in each map pixel in the SDF texture map may change due to the movement of the scene or the movement of the virtual camera, that is, the scene signed distance field information of the corresponding spatial range stored in each map pixel of each frame is not fixed. If the stored scene signed distance field information is not updated in time, the read scene signed distance field information will be inaccurate, so that the scene intersection point finally obtained will be wrong.

[0130] In some cases, when the spatial range corresponding to the map pixels to be calculated is not within the field of view of the current virtual camera, the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame can be determined based on the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame.

[0131] In other cases, when the spatial range corresponding to the map pixel to be calculated is within the field of view of the current virtual camera, the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame can be determined based on the multi-layer scene depth information generated above and the depth value of the spatial range corresponding to each map pixel. The depth value of the spatial range corresponding to each map pixel can be determined based on the distance between the spatial range and the current position of the virtual camera.

[0132] Figure 4 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 3 ; Figure 5 A schematic diagram of a multi-layer scene depth provided by an embodiment of the present application. Optionally, in step S302, generating multi-layer scene depth information according to the current position information of the virtual camera may include:

[0133] S401. Determine each scene captured by the virtual camera according to current position information.

[0134] Optionally, due to the performance of the virtual camera, the lens capture range of the virtual camera is limited and cannot capture all scenes in the game world space. For example, it can only capture scenes within 100 meters from the current position of the virtual camera. Based on the current position of the virtual camera, the scenes captured by the virtual camera can be determined.

[0135] S402 , respectively determining a first depth layer and a second depth layer of each scene, wherein the first depth layer is used to indicate depth information of the scene close to the virtual camera, and the second depth layer is used to indicate depth information of the scene far from the virtual camera.

[0136] like Figure 5 As shown, assuming that the scenes captured by the virtual camera F include scene A, scene B, and scene C, each of which is a three-dimensional scene, a layer of each scene close to the virtual camera can be determined as the first depth layer, and a layer far from the virtual camera can be determined as the second depth layer. As shown in the figure, the first depth layers of scene A, scene B, and scene C are D1, D2, and D3 respectively, and the second depth layers are D11, D22, and D33 respectively.

[0137] S403: Determine a first distance and a second distance of a first depth layer and a second depth layer of each scene from the virtual camera, respectively.

[0138] Optionally, since the current position of the virtual camera and the positions of the first depth layer and the second depth layer of each scene have been determined, the first distance of each scene can be obtained based on the distance of the first depth layer of each scene from the current position of the virtual camera. Similarly, the second distance of each scene can be obtained based on the distance of the second depth layer of each scene from the current position of the virtual camera.

[0139] S404: Generate multi-layer scene depth information according to the first distance and the second distance of each scene.

[0140] Optionally, multiple layers of scene depth information may be generated comprehensively from the first distance and the second distance of each scene.

[0141] Figure 6 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 4 Optionally, in step S404, generating multi-layer scene depth information according to the first distance and the second distance of each scene may include:

[0142] S601. Sort the first distances of the scenes in order from near to far to determine first depth information of multiple layers of scene depth information, where the first depth information is used to indicate the front layer depth information of each scene facing the virtual camera.

[0143] Optionally, the multi-layer scene depth information may include first depth information and second depth information. The first depth information may be obtained by sorting the first distances of the scenes in order from near to far according to the distances of the scenes from the virtual camera. Figure 5 It can be seen that scenes A, B, and C are arranged from near to far from the virtual camera. Assuming that the first distances of scenes A, B, and C are D1, D2, and D3 respectively, the first depth information of the multi-layer scene depth information is: D1, D2, and D3.

[0144] S602 , sort the second distances of the scenes in order from near to far, and determine second depth information of multiple layers of scene depth information, where the second depth information is used to indicate the depth information of the back layer of each scene facing away from the virtual camera.

[0145] Similarly, assuming that the second distances of scene A, scene B, and scene C are D11, D22, and D33 respectively, the second depth information of the multi-layer scene depth information is: D11, D22, and D33.

[0146] The first depth information represents the front layer depth information of the multi-layer scene depth information, and the second depth information represents the back layer depth information of the multi-layer scene depth information.

[0147] In this embodiment, the depthpeeling technology is used to generate multiple layers of scene depth information at the current virtual camera position, so that it can be accurately known whether any spatial point in the current virtual camera field of view is inside or outside the scene, that is, the positive and negative signs of the calculated scene signed distance field information are reliable, and the positive and negative signs of each scene signed distance field information are calculated based on the multiple layers of scene depth information, so that the deviation of the signed distance field information caused by the parallax problem can be avoided.

[0148] Figure 7 Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 5 Optionally, in S303, according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, determining the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame may include:

[0149] S701: Determine that the spatial range corresponding to the current map pixel is within the field of view of the virtual camera.

[0150] First, the current texture pixel is mapped back to the game world space, the spatial range corresponding to the current texture pixel is determined, and the depth value of the spatial range is calculated. According to the depth value, it is determined that the spatial range corresponding to the current texture pixel is within the field of view of the virtual camera.

[0151] Optionally, when the depth value of the spatial range is less than or equal to the capture distance of the virtual camera, the spatial range can be considered to be within the field of view of the virtual camera. Conversely, when the depth value of the spatial range is greater than the capture distance of the virtual camera, the spatial range can be considered to be outside the field of view of the virtual camera. The depth value of the spatial range may refer to the straight-line distance of the spatial range from the virtual camera.

[0152] S702: Compare the depth value of the spatial range corresponding to the current map pixel with the first depth information and the second depth information of the multi-layer scene depth information, the current map pixel being any map pixel among the map pixels.

[0153] When it is determined that the spatial range corresponding to the current map pixel is within the field of view of the virtual camera, the depth value of the spatial range may be compared with the first depth information and the second depth information of the multi-layer scene depth information obtained above to obtain a comparison result.

[0154] It should be noted that the current map pixel mentioned above refers to the map pixel currently being calculated, which can be any map pixel among the map pixels of the SDF texture map.

[0155] S703: Determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the comparison result.

[0156] In some embodiments, different comparison results may correspond to different scene signed distance field information calculation methods, and the scene signed distance field information of the corresponding spatial range stored in the current map pixel may be calculated using a corresponding method according to the comparison result.

[0157] Optionally, in step S703, according to the comparison result, determining the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel may include: determining the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel according to the comparison result, the depth value of the spatial range corresponding to the current patch pixel, and the first depth information and the second depth information.

[0158] Assume that the depth value of the spatial range corresponding to the current patch pixel is depth, the first depth information is: D1, D2, D3... Dn, and the second depth information is: D11, D22, D33... Dm.

[0159] If depth < min(D1, D11), then this spatial range is in front of the scene surface closest to the virtual camera. Then, according to the formula: min(D1, D11) - depth, that is, subtracting the depth value of this spatial range from the minimum value of D1 and D11, calculate the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel, and mark that the current patch pixel of the current frame has been assigned a value.

[0160] If depth > max(Dn, Dm), then this spatial range is behind the scene surface farthest from the virtual camera. Then, the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel in the previous frame can be reused, that is, determining the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel in the previous frame as the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel of the current frame, and marking that the current patch pixel of the current frame has not been assigned a value.

[0161] In one case, the spatial range may be between two scenes. First, the layer closest to the spatial range can be determined from the first depth information and the second depth information, and let its depth be Zn.

[0162] If there exists an i such that Di < depth < Dii, for example: there exists D1 < depth < D11, or D2 < depth < D22, then it proves that this spatial range is inside the scene. Then, according to the formula: max(Di - depth, depth - Dii), taking Di as D1 and Dii as D11 as an example, that is, assuming the spatial range is processed inside scene A, then the first distance of scene A can be subtracted from the depth value of the spatial range to obtain a first result, and the depth value of the spatial range can be subtracted from the second distance of scene A to obtain a second result. Take the maximum value from the first result and the second result as the scene oriented distance field information of the corresponding spatial range stored by the current patch pixel, and mark that the current patch pixel of the current frame has been assigned a value.

[0163] If there is no i such that Di < depth < Dii, it is proved that the spatial range is outside the scene. Then, according to the formula: abs(depth - Zn), the scene signed distance field information of the corresponding spatial range stored in the current texture pixel can be calculated. Here, abs means taking the absolute value.

[0164] The above describes several calculation methods for the scene signed distance field information of the corresponding spatial range stored in the current texture pixel when the corresponding spatial range of the current texture pixel is within the field of view of the virtual camera.

[0165] Optionally, in step S703, according to the scene signed distance field information of the corresponding spatial range stored in each texture pixel in the signed distance field texture map of the previous frame, determining the scene signed distance field information of the corresponding spatial range stored in each texture pixel in the signed distance field texture map of the current frame may include: determining that the spatial range corresponding to the current texture pixel is not within the field of view of the virtual camera; determining the scene signed distance field information of the corresponding spatial range stored in the current texture pixel in the signed distance field texture map of the previous frame as the scene signed distance field information of the corresponding spatial range stored in the current texture pixel in the signed distance field texture map of the current frame, where the current texture pixel is any one of the texture pixels.

[0166] In some cases, when it is determined that the spatial range corresponding to the current texture pixel is not within the field of view of the virtual camera, the scene signed distance field information of the corresponding spatial range stored in the current texture pixel of the previous frame can be directly reused.

[0167] Optionally, in the case where the current texture pixel has been assigned a value and the positive and negative signs of the value of the current texture pixel in the previous frame are the same as those in the current frame:

[0168] If the absolute value of the value in the previous frame is less than the value in the current frame, assign the value in the previous frame to the current frame; if the absolute value of the value in the current frame is less than the size of the spatial range, inject the screen illumination information (the diffuse part of the direct illumination color result calculated using the G - Buffer and the scene light information) into the SDF texture map at the same time, and finally update the calculated value of the current frame to the SDF texture map. For each texture pixel in the SDF texture map, the same method can be used to calculate the scene signed distance field information of the corresponding spatial range stored in each texture pixel of the current frame, so as to obtain the updated SDF texture map. Here, the size of the texture pixel grid can refer to the size of the corresponding spatial range after the texture pixel is mapped back to the game world space. Assuming the spatial range is 100x100x100, then the size of the pixel grid is 100x100x100.

[0169] Figure 8Schematic diagram of the lighting rendering method provided in the embodiment of the present application Figure 6 ; Optionally, the method of the present application may further include:

[0170] S801. Determine a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current texture pixel according to the scene signed distance field information of the corresponding spatial range stored in the current texture pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring texture pixels of the current texture pixel.

[0171] S802: Correct the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the correction parameter.

[0172] Optionally, the scene signed distance field information of the corresponding spatial range stored in the current map pixel of the current frame calculated above may have a parallax problem, thereby affecting the step size value when the virtual stepping ray performs ray stepping, thereby causing the error of skipping the actual surface of the scene.

[0173] In this embodiment, by calculating the correction parameters of the scene signed distance field information of the corresponding spatial range stored in each map pixel, the scene signed distance field information of the corresponding spatial range stored in each map pixel calculated above can be corrected to improve the accuracy of the scene signed distance field information of the corresponding spatial range stored in each map pixel.

[0174] Optionally, the scene signed distance field information of the corresponding spatial range stored in the current map pixel may be compared with the positive and negative signs of the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, so as to determine the correction parameter corresponding to the current map pixel. The neighboring map pixels may refer to all map pixels adjacent to the current map pixel.

[0175] Optionally, in step S801, determining, based on the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel may include:

[0176] If there is a neighboring map pixel whose sign of the scene signed distance field information corresponding to the spatial range stored is opposite to the sign of the scene signed distance field information corresponding to the spatial range stored by the current map pixel, then the correction parameter of the scene signed distance field information corresponding to the spatial range stored by the current map pixel is determined to be half the size of the spatial range.

[0177] In some embodiments, if there is a neighboring map pixel whose sign of the scene signed distance field information of the corresponding spatial range stored is opposite to the sign of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, it means that the neighboring map pixel and the current map pixel are respectively located inside and outside a scene. At this time, the correction parameter can be determined as: the scene signed distance field information of the corresponding spatial range stored by the current map pixel multiplied by 0.5 times the map pixel length, where the map pixel length can refer to the size of the spatial range corresponding to the map pixel, such as the above-mentioned 100x100x100.

[0178] Optionally, in step S801, determining, based on the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel may include:

[0179] If the signs of the scene signed distance field information of the corresponding spatial range stored by all neighboring map pixels are the same as the signs of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, then traverse each neighboring map pixel, respectively calculate the sum of the distance from each neighboring map pixel to the current map pixel and the absolute value of the scene signed distance field information of the corresponding spatial range stored by each neighboring map pixel, and determine the minimum sum value from the sum values ​​corresponding to each neighboring map pixel. Among them, the distance from the neighboring map pixel to the current map pixel can be the map pixel length.

[0180] If the minimum sum is smaller than the absolute value of the scene signed distance field information of the corresponding spatial range stored in the current map pixel, the correction parameter of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined to be the minimum sum.

[0181] That is, if the sum of the distance from the neighboring texture pixel to the current texture pixel plus the distance from the current texture pixel to the scene is less than the distance from the current texture pixel directly to the scene, the scene directed distance field information of the corresponding spatial range stored by the current texture pixel can be corrected to the minimum sum value. Among them, the distance from the texture pixel to the scene is also the scene directed distance field information of the corresponding spatial range stored by the texture pixel. In this way, the scene directed distance field information of the corresponding spatial range stored by the texture pixel can be minimized, satisfying the conditions of the directed distance field information.

[0182] Optionally, in some embodiments, the SDF texture map of the present application may also store direct lighting information corresponding to each scene. For example, the direct lighting information of the scene is directly stored in the RGB channels of the SDF texture map, and the A channel stores the scene signed distance field information of the spatial range corresponding to each map pixel. Therefore, when the scene is rendered with global illumination, the indirect lighting information and direct lighting information can be read separately from the SDF texture map to complete the calculation of global light.

[0183] In summary, the lighting rendering method provided by the embodiment of the present application includes: determining the current scene shading point; emitting a virtual stepping ray according to the current scene shading point; determining the step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame; controlling the virtual stepping ray to extend into the scene according to the step length to determine at least one scene intersection; determining the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation. In this solution, the scene directed distance field information corresponding to the current frame obtained is the real-time updated information, which can improve the accuracy of the obtained directed distance field information, and realize the acquisition of accurate directed distance field information in dynamic scenes, so that the accurate stepping of the virtual stepping ray can be controlled based on the obtained more accurate directed distance field information, so that the obtained scene intersection is more accurate, and accurate indirect lighting is obtained, thereby improving the rendering effect of indirect lighting in dynamic scenes.

[0184] Secondly, this application uses multi-layer SDF texture maps to store signed distance field information, and different spatial ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids the excessive video memory occupancy caused by storing uniform SDF texture maps for the entire scene (the same spatial range is mapped both near and far), while covering a longer distance, and the difference between the calculation results of indirect lighting and the detailed signed distance field information of the entire scene will not be too large.

[0185] In addition, the depthpeeling technology is used to generate multi-layer scene depth information at the current virtual camera position, so that we can accurately know whether any spatial point in the current virtual camera field of view is inside or outside the scene, that is, the positive and negative signs of the calculated scene signed distance field information are reliable. The positive and negative signs of each scene's signed distance field information are calculated based on multi-layer scene depth information, so that the deviation of the signed distance field information caused by the parallax problem can be avoided.

[0186] Finally, the direct lighting information of the scene is also stored in the SDF texture map, which can efficiently realize the global light calculation of the scene.

[0187] The following describes the device, electronic device, storage medium, etc. used to execute the lighting rendering method provided by the present application. The specific implementation process and technical effects are described above and will not be repeated below.

[0188] Fig. 9 This is a schematic diagram of a lighting rendering device provided in an embodiment of the present application. The functions implemented by the lighting rendering device correspond to the steps performed by the above method. The device can be understood as the above terminal or server, or the processor of the server, or can also be understood as a component independent of the above server or processor that implements the functions of the present application under the control of the server, such as Fig. 9 As shown, the device may include: a determination module 910, a transmission module 920;

[0189] A determination module 910, used to determine the current scene shading point;

[0190] The emission module 920 is used to emit a virtual stepping ray according to the current scene shading point;

[0191] A determination module 910, configured to determine a step length corresponding to a virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame;

[0192] A determination module 910, configured to control the virtual stepping ray to extend into the scene according to the stepping length to determine at least one scene intersection point;

[0193] The determination module 910 is used to determine the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

[0194] Optionally, the scene signed distance field information corresponding to the updated current frame is information obtained by reading a signed distance field texture map corresponding to the updated current frame, wherein different map pixels in the signed distance field texture map correspond to different spatial ranges in the game world space determined according to the position of the virtual camera, and the scene signed distance field information of the corresponding spatial range is stored in the map pixels.

[0195] Optionally, the signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same pixel size to store scene signed distance field information of a corresponding spatial range, and the spatial range corresponding to each layer of texture maps is determined according to the spatial range of the game world space and the distance from the virtual camera.

[0196] Optionally, the device further includes: an acquisition module and a generation module;

[0197] An acquisition module is used to obtain the current position information of the virtual camera;

[0198] A generation module, used to generate multi-layer scene depth information according to the current position information of the virtual camera;

[0199] The determination module 910 is further used to determine the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, or according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame.

[0200] Optionally, a generation module is specifically used to determine each scene captured by the virtual camera based on the current position information; determine a first depth layer and a second depth layer of each scene respectively, the first depth layer is used to indicate the depth information of the scene close to the virtual camera, and the second depth layer is used to indicate the depth information of the scene far from the virtual camera; determine the first distance and second distance of the first depth layer and the second depth layer of each scene from the virtual camera respectively; generate multi-layer scene depth information according to the first distance and the second distance of each scene.

[0201] Optionally, a generation module is specifically used to sort the first distances of each scene in order from near to far, determine the first depth information of the multi-layer scene depth information, and the first depth information is used to indicate the front layer depth information of each scene facing the virtual camera; sort the second distances of each scene in order from near to far, determine the second depth information of the multi-layer scene depth information, and the second depth information is used to indicate the back layer depth information of each scene facing away from the virtual camera.

[0202] Optionally, determination module 910 is specifically used to determine whether the spatial range corresponding to the current map pixel is within the field of view of the virtual camera; compare the depth value of the spatial range corresponding to the current map pixel with the first depth information and the second depth information of the multi-layer scene depth information, and the current map pixel is any map pixel among the map pixels; based on the comparison result, determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel.

[0203] Optionally, the determination module 910 is specifically configured to determine the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the comparison result, the depth value of the spatial range corresponding to the current map pixel, and the first depth information and the second depth information.

[0204] Optionally, the determination module 910 is specifically used to determine that the spatial range corresponding to the current map pixel is not within the field of view of the virtual camera; the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the previous frame is determined as the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the current frame, and the current map pixel is any map pixel among the map pixels.

[0205] Optionally, the device further comprises: a correction module;

[0206] The determination module 910 is further configured to determine a correction parameter for the scene directed distance field information of the corresponding spatial range stored in the current texture pixel according to the scene directed distance field information of the corresponding spatial range stored in the current texture pixel and the scene directed distance field information of the corresponding spatial range stored in the neighboring texture pixels of the current texture pixel;

[0207] The correction module is used to correct the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the correction parameters.

[0208] Optionally, the determination module 910 is specifically configured to determine that a correction parameter of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is half the size of the spatial range if there is a neighboring map pixel whose sign of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is opposite to the sign of the scene signed distance field information of the corresponding spatial range stored in the current map pixel.

[0209] Optionally, the determination module 910 is specifically used to, if the signs of the scene directed distance field information of the corresponding spatial range stored in all neighboring map pixels are the same as the sign of the scene directed distance field information of the corresponding spatial range stored in the current map pixel, traverse each neighboring map pixel, respectively calculate the sum of the distance from each neighboring map pixel to the current map pixel and the absolute value of the scene directed distance field information of the corresponding spatial range stored in each neighboring map pixel, and determine the minimum sum value from the sum values ​​corresponding to each neighboring map pixel; if the minimum sum value is less than the absolute value of the scene directed distance field information of the corresponding spatial range stored in the current map pixel, determine that the correction parameter of the scene directed distance field information of the corresponding spatial range stored in the current map pixel is the minimum sum value.

[0210] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0211] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0212] The above modules can be connected or communicated with each other via a wired connection or a wireless connection. The wired connection may include a metal cable, an optical cable, a hybrid cable, etc., or any combination thereof. The wireless connection may include a connection in the form of a LAN, a WAN, Bluetooth, a ZigBee, or NFC, or any combination thereof. Two or more modules may be combined into a single module, and any one module may be divided into two or more units. Those skilled in the art will clearly understand that for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application.

[0213] It should be noted that the above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0214] Fig.10A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, which may be a computing device with data processing capabilities.

[0215] The device may include: a processor 801 and a memory 802 .

[0216] The memory 802 is used to store programs, and the processor 801 calls the programs stored in the memory 802 to execute the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.

[0217] The memory 802 stores program codes, and when the program codes are executed by the processor 801, the processor 801 executes various steps of the lighting rendering method according to various exemplary embodiments of the present application described in the above “Exemplary Method” section of this specification.

[0218] Processor 801 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor (DigitalSignal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.

[0219] The memory 802 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 802 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0220] Optionally, the present application also provides a program product, such as a computer-readable storage medium, including a program, which is used to execute the above method embodiment when executed by a processor.

[0221] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0223] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0224] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

Claims

1. A lighting rendering method, characterized in that: include: Determine the current scene shading point; emitting a virtual stepping ray according to the current scene shading point; Determine the step length corresponding to the virtual stepping ray according to the updated scene directed distance field information corresponding to the current frame; Controlling the virtual stepping ray to extend into the scene according to the stepping length to determine at least one scene intersection point; Color information of the scene intersection is determined according to incident light information and material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

2. The method according to claim 1, characterized in that The scene signed distance field information corresponding to the updated current frame is information obtained by reading a signed distance field texture map corresponding to the updated current frame, wherein different map pixels in the signed distance field texture map correspond to different spatial ranges in the game world space determined according to the position of the virtual camera, and the scene signed distance field information of the corresponding spatial range is stored in the map pixels.

3. The method according to claim 2, characterized in that The signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same pixel size to store scene signed distance field information of a corresponding spatial range, and the spatial range corresponding to each layer of texture maps is determined according to the spatial range of the game world space and the distance from the virtual camera.

4. The method according to claim 3, characterized in that: The scene signed distance field information of the corresponding spatial range stored in each pixel of the signed distance field texture map is calculated in the following way: Obtaining the current position information of the virtual camera; Generate multi-layer scene depth information according to the current position information of the virtual camera; The scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame is determined according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel, or according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame.

5. The method according to claim 4, characterized in that The generating multi-layer scene depth information according to the current position information of the virtual camera includes: Determine each scene captured by the virtual camera according to the current position information; Determine a first depth layer and a second depth layer of each scene respectively, wherein the first depth layer is used to indicate depth information of the scene close to the virtual camera, and the second depth layer is used to indicate depth information of the scene far from the virtual camera; Determine a first distance and a second distance of a first depth layer and a second depth layer of each scene from the virtual camera, respectively; The multi-layer scene depth information is generated according to the first distance and the second distance of each scene.

6. The method according to claim 5, characterized in that The generating the multi-layer scene depth information according to the first distance and the second distance of each scene includes: Sort the first distances of the scenes in order from near to far, and determine first depth information of the multi-layer scene depth information, where the first depth information is used to indicate the front layer depth information of the scenes facing the virtual camera; The second distances of the scenes are sorted in order from near to far to determine the second depth information of the multi-layer scene depth information, where the second depth information is used to indicate the depth information of the back layer of the scenes facing away from the virtual camera.

7. The method according to claim 6, characterized in that The step of determining the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the multi-layer scene depth information and the depth value of the spatial range corresponding to each map pixel comprises: Determine that the spatial range corresponding to the current map pixel is within the field of view of the virtual camera; Compare the depth value of the spatial range corresponding to the current map pixel with the first depth information and the second depth information of the multi-layer scene depth information, the current map pixel being any one of the map pixels; According to the comparison result, the scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined.

8. The method according to claim 7, characterized in that The step of determining the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the comparison result includes: The scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined according to the comparison result, the depth value of the spatial range corresponding to the current map pixel, and the first depth information and the second depth information.

9. The method according to claim 4, characterized in that The step of determining the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the current frame according to the scene signed distance field information of the corresponding spatial range stored in each map pixel in the signed distance field texture map of the previous frame comprises: Determining that a spatial range corresponding to a current map pixel is not within the field of view of the virtual camera; The scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the previous frame is determined as the scene signed distance field information of the corresponding spatial range stored in the current map pixel in the signed distance field texture map of the current frame, and the current map pixel is any map pixel among the map pixels.

10. The method according to claim 8, characterized in that The method further comprises: Determining a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel according to the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel; According to the correction parameters, the scene signed distance field information of the corresponding spatial range stored in the current map pixel is corrected.

11. The method according to claim 10, characterized in that The step of determining, based on the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel comprises: If there is a neighboring map pixel whose sign of the scene signed distance field information of the corresponding spatial range stored is opposite to the sign of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, a correction parameter of the scene signed distance field information of the corresponding spatial range stored by the current map pixel is determined to be half the size of the spatial range.

12. The method according to claim 10, characterized in that The step of determining, based on the scene signed distance field information of the corresponding spatial range stored in the current map pixel and the scene signed distance field information of the corresponding spatial range stored in the neighboring map pixels of the current map pixel, a correction parameter for the scene signed distance field information of the corresponding spatial range stored in the current map pixel comprises: If the signs of the scene signed distance field information of the corresponding spatial range stored by all the neighboring map pixels are the same as the sign of the scene signed distance field information of the corresponding spatial range stored by the current map pixel, then traverse each of the neighboring map pixels, respectively calculate the sum of the distance from each of the neighboring map pixels to the current map pixel and the absolute value of the scene signed distance field information of the corresponding spatial range stored by each of the neighboring map pixels, and determine the minimum sum value from the sum values ​​corresponding to each of the neighboring map pixels; If the minimum sum is smaller than the absolute value of the scene signed distance field information of the corresponding spatial range stored in the current map pixel, the correction parameter of the scene signed distance field information of the corresponding spatial range stored in the current map pixel is determined to be the minimum sum.

13. A lighting rendering device, characterized in that: include: Determine the module and launch the module; The determination module is used to determine the current scene shading point; The emission module is used to emit a virtual stepping ray according to the current scene shading point; The determining module is used to determine the step length corresponding to the virtual stepping ray according to the scene directed distance field information corresponding to the updated current frame; The determining module is used to control the virtual stepping light to extend into the scene according to the stepping length to determine at least one scene intersection point; The determination module is used to determine the color information of the scene intersection according to the incident light information and the material information of the scene intersection, wherein the color information is used for indirect lighting calculation.

14. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of any method described in claims 1 to 12.

15. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are executed.

Citation Information

Patent Citations

  • Illumination rendering method and device, computer readable medium and electronic equipment

    CN111915712A

  • Graphical user interface display method and device, terminal and storage medium

    CN112256367A