Light supplement rendering method and device for virtual character and electronic equipment
By adjusting the fill light intensity based on the shadow area of the detection point and the character's orientation in the virtual scene, the problem of unstable fill light for virtual characters facing the light source in the shadow area was solved, thus improving the visual effect of the virtual characters.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2026-01-06
- Publication Date
- 2026-05-12
AI Technical Summary
In existing technologies, when a virtual character is in a shadow area and facing the scene's light source, the fill light effect is unstable, resulting in poor visual effects.
By determining detection points in the virtual scene and checking whether the detection points are located in shadow areas, and combining the orientation of the virtual character and the light direction of the scene light source, the intensity of the fill light is dynamically adjusted to generate the final fill light intensity, including the first fill light intensity and the preset second fill light intensity, and then fill light rendering is performed.
It improves the stability of the lighting effect for virtual characters, enhances their visual appeal, and ensures that virtual characters maintain good lighting performance under different lighting conditions.
Smart Images

Figure CN122023635A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of virtual rendering technology, and in particular to a method, apparatus, and electronic device for supplementary lighting rendering of virtual characters. Background Technology
[0002] To ensure the visual effect of virtual characters, supplemental lighting is needed when the virtual character is under weak illumination. In related technologies, the intensity of supplemental lighting is typically determined based on the angle between the virtual character's orientation and the direction of the scene's light. For example, a larger angle indicates that the virtual character is backlit, thus requiring increased supplemental lighting intensity to compensate for the character appearing dark due to backlighting.
[0003] However, when a virtual character enters the shadow area of a virtual scene and faces the scene's light source, the angle between the character's orientation and the direction of the scene's light is small, making it impossible to provide additional lighting using the methods described above. As a result, the virtual character remains dark, and the lighting effect is unstable. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for rendering supplementary lighting for virtual characters, so as to improve the stability of the supplementary lighting effect of the characters and improve the visual effect of the virtual characters.
[0005] In a first aspect, embodiments of the present invention provide a method for supplementary lighting rendering of a virtual character, wherein the virtual character is located in a virtual scene, and the virtual scene also includes a virtual camera; the method includes: determining a detection point in the virtual scene based on the view target position of the virtual camera; detecting whether the detection point is located in the shadow area of the virtual scene, and obtaining a detection result; wherein the shadow area is generated by illuminating a specified model by scene light source in the virtual scene; determining a first supplementary lighting intensity based on the character orientation of the virtual character and the light direction of the scene light source; generating a final supplementary lighting intensity based on the detection result, the first supplementary lighting intensity and a preset second supplementary lighting intensity, and performing supplementary lighting rendering on the virtual character according to the final supplementary lighting intensity.
[0006] Secondly, embodiments of the present invention provide a lighting rendering device for a virtual character, wherein the virtual character is located in a virtual scene, and the virtual scene also includes a virtual camera; the device includes: a detection point determination module, used to determine a detection point in the virtual scene based on the target position of the virtual camera's gaze; a detection module, used to detect whether the detection point is located in the shadow area of the virtual scene, and obtain a detection result; wherein the shadow area is generated by illuminating a specified model by scene light source in the virtual scene; an intensity determination module, used to determine a first lighting intensity based on the character orientation of the virtual character and the light direction of the scene light source; and a lighting rendering module, used to generate a final lighting intensity based on the detection result, the first lighting intensity, and a preset second lighting intensity, and to perform lighting rendering on the virtual character according to the final lighting intensity.
[0007] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the above-mentioned virtual character fill light rendering method.
[0008] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are invoked and executed by a processor, the computer-executable instructions cause the processor to perform the aforementioned virtual character lighting rendering method.
[0009] The embodiments of the present invention bring the following beneficial effects: The aforementioned method, apparatus, and electronic device for supplemental lighting rendering of virtual characters involve a virtual character located in a virtual scene, which also includes a virtual camera. Based on the target position of the virtual camera's gaze, a detection point is determined in the virtual scene. The detection point is then checked to determine if it is located in a shadow area of the virtual scene, yielding a detection result. The shadow area is generated by illuminating a specified model with scene light sources in the virtual scene. A first supplemental lighting intensity is determined based on the virtual character's orientation and the direction of the scene light source. A final supplemental lighting intensity is generated based on the detection result, the first supplemental lighting intensity, and a preset second supplemental lighting intensity, and supplemental lighting rendering is performed on the virtual character according to the final supplemental lighting intensity.
[0010] In the above method, the first fill light intensity is based on the orientation of the virtual character. On this basis, the virtual character is detected by a detection point to see if it is in a shadow area. Then, based on the detection result, the first fill light intensity and the preset second fill light intensity are used to jointly determine the final fill light intensity. When the virtual character is in a shadow area and is facing the scene light source, the second fill light intensity can also be used to fill light, which improves the stability of the character fill light effect and improves the visual effect of the virtual character.
[0011] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0012] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0013] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0014] Figure 1 This is a schematic diagram illustrating the lighting effects of a virtual character in a shadow area in related technologies. Figure 2 A flowchart illustrating a method for supplementary lighting rendering of a virtual character, as provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the detection points set around the virtual character according to an embodiment of the present invention; Figure 4 This is a schematic diagram of detection points set around the target position in an embodiment of the present invention; Figure 5 A schematic diagram illustrating the fill light effect of a virtual character facing away from and towards the scene light source within a shadow area, as provided in an embodiment of the present invention. Figure 6 A lighting rendering device for a virtual character is provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0016] Lighting effects are a crucial factor in rendering virtual characters, affecting the final rendering of all materials. To ensure that virtual characters consistently perform well in virtual scenes, character lighting and scene lighting are typically separated, and multiple light sources with different parameters are placed around the virtual character to create a comprehensive lighting atmosphere.
[0017] In order to achieve realism, texture and visual impact for virtual characters, the light source of the virtual character has a high light ratio effect when the virtual character is illuminated. However, when the virtual character is in a shadow area or backlit, the brightness of the virtual character decreases and the visual effect becomes dark.
[0018] To address the aforementioned issues, related technologies adjust the fill light intensity for the virtual character based on the angle between the virtual character's orientation and the direction of light from the scene's light source. When the angle is large, it indicates that the virtual character is backlit, requiring an appropriate increase in the illumination intensity of the light source surrounding the virtual character to compensate for the visual darkening caused by the reduced illumination intensity of the scene's light source.
[0019] The above-mentioned lighting methods work well when the light ratio is low or the lighting intensity is low. However, when the light ratio is high, the lighting intensity of the backlight of the virtual character is set higher to illuminate the darker areas. When the virtual character enters a shadow area of the virtual scene and faces the scene light source, the above-mentioned lighting methods will not produce a lighting effect. Figure 1 As shown in (a), the virtual character remains relatively dark. However, when the virtual character is backlit, the aforementioned supplementary lighting method produces a supplementary lighting effect, making the virtual character brighter, as shown in (a). Figure 1 As shown in (b) of the diagram.
[0020] Therefore, the above-mentioned lighting methods cannot provide supplemental lighting for virtual characters when they are facing the scene's light source, resulting in the virtual characters remaining dark and the lighting effect being unstable.
[0021] Based on this, the virtual character fill light rendering method, apparatus and electronic device provided by the embodiments of the present invention can be applied to various virtual scenes, such as game scenes, virtual experience scenes, etc.
[0022] In one possible implementation, this invention provides a method for supplemental lighting rendering of a virtual character located in a virtual scene, which also includes a virtual camera. The virtual scene may also include scene models, such as models of buildings, mountains, plants, and animals, and may also include other virtual characters besides the aforementioned virtual characters. The virtual camera is used to capture images of the virtual scene and render the scene image. The virtual camera can be bound to the virtual character, in which case the virtual camera moves with the virtual character. Alternatively, the virtual camera may not be bound to the virtual character, and may remain at a fixed position in the virtual scene, move along a preset path, or move under the control of a terminal device.
[0023] like Figure 2 As shown, the lighting rendering method for this virtual character includes the following steps: Step S202: Determine detection points in the virtual scene based on the target position of the virtual camera's line of sight; The location of the visual target can be determined based on factors such as the orientation of the virtual camera and the focal distance. For example, the location 2 meters in front of the virtual camera can be used as the target location. When the virtual camera follows the virtual character, the location of the virtual character can be used as the visual target location. For example, the virtual character's head or chest can be used as the visual target location.
[0024] The detection point can include one or more. After determining the position of the target, the detection point can be determined based on the preset relative position parameters. For example, the detection point is located 10 cm above the target, 20 cm to the right, 20 cm to the left, etc. In actual implementation, when there are multiple detection points, they are usually distributed around the target position. When the target position is a virtual character, the multiple detection points are distributed around the virtual character.
[0025] Step S204: Detect whether the above detection point is located in the shadow area of the virtual scene, and obtain the detection result; wherein, the shadow area is generated by the scene light source in the virtual scene illuminating the specified model; Scene light sources in a virtual scene are typically positioned at a specific location within the scene or move along a preset path. For example, the scene light source might be a 'sun' model within the virtual scene. The scene light source emits parallel light, and when it illuminates the virtual scene, a designated model within the scene will create a shadow area. This designated model can be understood as an opaque model, i.e., a model that blocks light, such as a static object model, a dynamic object model, or a plant model.
[0026] In actual implementation, the specific location range of the shadow area can be calculated in advance. If the detection point is located within the location range of the engine area, then the detection point is located in the shadow area. Alternatively, the first distance between the detection point and the scene light source, and the second distance between the specified model and the scene light source can be calculated. If the first distance is greater than the second distance, it means that the detection point is blocked by the specified model, and then the detection point is located in the shadow area.
[0027] When a detection point is set around a virtual character, the virtual character can be detected as being in a shadow area by detecting whether the detection point is located in the shadow area.
[0028] Step S206: Determine the first supplementary light intensity based on the virtual character's orientation and the light direction of the scene light source; Understandably, when the angle between the character and the direction of the light is small, for example, less than 90 degrees, the virtual character faces the scene light source, and the brightness of the virtual character is usually high, so the first fill light intensity is usually low; if the angle between the character and the direction of the light is large, for example, greater than 90 degrees, the virtual character faces away from the scene light source, and the brightness of the virtual character is usually low, so the first fill light intensity is usually high.
[0029] Step S208: Based on the detection results, the first fill light intensity and the preset second fill light intensity, generate the final fill light intensity, and perform fill light rendering on the virtual character according to the final fill light intensity.
[0030] Since the first fill light intensity is determined based on the virtual character's orientation and the direction of the scene light source, the fill light effect is poor when the virtual character is facing the scene light source but is located in a shadow area. Therefore, in this embodiment, a second fill light intensity is also set. The second fill light intensity and the first fill light intensity work together to fill light on the virtual character, thereby avoiding the aforementioned fill light problem when the virtual character is facing the scene light source but is located in a shadow area.
[0031] Specifically, the second fill light intensity can be a fixed value or a variable value. For example, the second fill light intensity can be determined based on the position of the virtual character in the scene. The closer the virtual character is to the center of the scene, the greater the second fill light intensity.
[0032] The aforementioned detection results include whether the detection point is located in the shadow area of the virtual scene. When there are multiple detection points, the detection results include whether each detection point is located in the shadow area of the virtual scene. Specifically, based on whether the detection point is located in the shadow area of the virtual scene, or based on the number of detection points located in the shadow area of the virtual scene, the first supplementary light intensity and the preset second supplementary light intensity are calculated to obtain the final supplementary light intensity. This final supplementary light intensity can adjust the illumination generated by a specified light source, thereby adjusting the lighting effect of the virtual character. The specified light source can be an ambient light source of the virtual scene, an image-based lighting source, or a spherical harmonic light source, etc.
[0033] The above-mentioned method for supplemental lighting rendering of virtual characters involves the virtual character being located in a virtual scene, which also includes a virtual camera. Based on the target position of the virtual camera's gaze, a detection point is determined in the virtual scene. The detection point is then checked to see if it is located in a shadow area of the virtual scene, and a detection result is obtained. The shadow area is generated by illuminating a specified model with scene light sources in the virtual scene. A first supplemental lighting intensity is determined based on the virtual character's orientation and the direction of the scene light source. Based on the detection result, the first supplemental lighting intensity, and a preset second supplemental lighting intensity, a final supplemental lighting intensity is generated, and the virtual character is then supplemented with lighting rendering according to the final supplemental lighting intensity.
[0034] In the above method, the first fill light intensity is based on the orientation of the virtual character. On this basis, the virtual character is detected by a detection point to see if it is in a shadow area. Then, based on the detection result, the first fill light intensity and the preset second fill light intensity are used to jointly determine the final fill light intensity. When the virtual character is in a shadow area and is facing the scene light source, the second fill light intensity can also be used to fill light, which improves the stability of the character fill light effect and improves the visual effect of the virtual character.
[0035] In one implementation, in response to a virtual camera following a virtual character to take pictures, the position of the virtual character is determined as the target position of the virtual camera's line of sight. When the virtual camera follows the virtual character to take pictures, the virtual camera is usually bound to the virtual character, and the virtual camera moves with the virtual character. In this case, the scene captured by the virtual camera includes the virtual character, and the virtual character is located in an area near the center of the scene.
[0036] Since the character model of a virtual character occupies a certain space, a specific location on the character model can be designated as the viewing target location of the virtual camera. For example, the chest or head of the virtual character can be designated as the viewing target location of the virtual camera.
[0037] Alternatively, in response to the virtual camera not following the virtual character, the system determines the position of the viewing target in the virtual scene based on the virtual camera's preset focus parameters. When the virtual camera is not following the virtual character, it remains in a fixed position within the virtual scene, either moving along a preset trajectory or under the control of commands from the terminal device.
[0038] In this situation, the scene captured by the virtual camera does not contain the virtual character, or the virtual character is not located in the center of the scene. For example, the virtual character is located at the edge of the scene and occupies a small area of the screen.
[0039] The aforementioned focus parameter is an inherent parameter of the virtual camera, used to control the shooting focus position of the virtual camera. The focus parameter can be preset. For example, if the focus parameter determines that the shooting focus is located 2 meters in front of the virtual camera, then the shooting focus 2 meters in front of the virtual camera is the aforementioned target position.
[0040] Furthermore, from the virtual scene, determine the scene position that satisfies the preset relative position condition with respect to the virtual camera's line-of-sight target position; the determined scene position is then designated as the detection point. Once the line-of-sight target position is determined, the detection point can be determined based on this relative position condition; this relative position condition is used to indicate the relative position between the detection point and the line-of-sight target position, for example, the relative position condition includes 10 centimeters above the line-of-sight target position, 10 centimeters to the right of the line-of-sight target position, etc.
[0041] exist Figure 3 In the example, the target location is a virtual character, and the detection points are set around this virtual character, with the endpoints of each red line serving as detection points. In most cases, the detection points are located around the virtual character and are generally not placed on the surface of the virtual character's model, thus avoiding the problem of the virtual character itself obscuring the detection points.
[0042] exist Figure 4 In the example, the virtual camera does not follow the virtual character to take pictures. The target position is located in the center of the screen, and the detection points are set around the target position. The endpoints of each red line are detection points.
[0043] By setting up the detection points in the above manner, it is possible to detect whether the virtual character is in the shadow area using a small number of detection points, without needing to detect whether the virtual character itself is in the shadow area, which helps to improve computational and rendering efficiency.
[0044] In one implementation, starting from the scene light source, the scene depth of a specified model in the virtual scene and the scene depth of the detection point are obtained, and the screen space position corresponding to the detection point is obtained; wherein, the screen space position is located in the screen space corresponding to the scene image captured from the scene light source; the scene depth corresponding to the screen space position is obtained from the scene depth of the specified model; based on the scene depth corresponding to the screen space position and the scene depth of the detection point, it is determined whether the detection point is located in the shadow area of the virtual scene.
[0045] Specifically, a ray-emitting device can be placed at the location of the scene light source to emit a ray into the virtual scene. The length between the interception point and the scene light source after the ray is intercepted by the scene model represents the scene depth of that scene model. Similarly, the length between the interception point and the scene light source after the ray is intercepted by a detection point represents the scene depth of that detection point. The scene depth of a specified model can be saved using a depth map.
[0046] A virtual camera can also be placed at the scene light source to capture the scene image. The scene image includes the aforementioned detection point, and the position of the detection point in the scene image is the screen space position corresponding to the aforementioned detection point.
[0047] For each detection point, assuming the screen space position corresponding to the detection point is (x, y), the depth data at position (x, y) is found from the depth map that stores the scene depth of the specified model, i.e., the scene depth corresponding to the screen space position. The scene depth corresponding to the screen space position is compared with the scene depth of the detection point to obtain the comparison result. Based on the comparison result, it is determined whether the detection point is located in the shadow area of the virtual scene.
[0048] Specifically, in response to the scene depth corresponding to the screen space position being greater than or equal to the scene depth of the detection point, it is determined that the detection point is not located in the shadow area of the virtual scene; and / or, in response to the scene depth corresponding to the screen space position being less than the scene depth of the detection point, it is determined that the detection point is located in the shadow area of the virtual scene.
[0049] If the scene depth corresponding to the screen space location is greater than or equal to the scene depth of the detection point, it means that the specified model is farther from the scene light source than the detection point, or the detection point is located on the surface of the specified model, and the specified model does not occlude the detection point, i.e., the detection point is not located in the shadow area of the virtual scene. If the scene depth corresponding to the screen space location is less than the scene depth of the detection point, it means that the specified model is closer to the scene light source than the detection point, and the specified model occludes the detection point, i.e., the detection point is located in the shadow area of the virtual scene.
[0050] In actual implementation, the detection results can be recorded in UAV (Unordered Access View) or other graph data. When there are multiple detection points, each detection point corresponds to a pixel position in the UAV. For example, if the detection point is located in the shadow area of the virtual scene, the pixel position corresponding to the detection point is recorded as 1. If the detection point is not located in the shadow area of the virtual scene, the pixel position corresponding to the detection point is recorded as 0.
[0051] When the detection results are recorded in the above UAV, the corresponding SRV (Shader Resource View) is generated. The SRV is input into the light pass and the forward rendering material, and the subsequent lighting steps are performed through the pixel shader in the light pass or the forward rendering material.
[0052] In one implementation, the directional angle between the character's facing direction and the light direction of the scene light source is obtained; based on the directional angle, a first supplementary light intensity is determined within a preset supplementary light intensity range. This supplementary light intensity range includes a minimum value and a maximum value; for example, the minimum value is 1, meaning no supplementary light is applied. A mapping relationship is formed between the directional angle and the supplementary light intensity within the supplementary light intensity range. Generally, the larger the directional angle, the greater the first supplementary light intensity mapped from the supplementary light intensity range.
[0053] In practical implementation, the first supplementary light intensity can be calculated using the following formula: I cameraLightInten =lerp(1, I maxInten , abs(D player ·D sunlight )); Among them, I cameraLightInten I is the first fill light intensity, lerp is the linear interpolation function, 1 is the minimum fill light intensity, and I maxInten It is the maximum supplemental light intensity, abs is the absolute value function, D playe It's the character's orientation, D sunlight It refers to the direction of light from the scene's light source.
[0054] In another approach, if the response direction angle is within a first angle range, the preset front and side fill light intensities of the virtual character are obtained; based on the direction angle, the front and side fill light intensities are linearly interpolated to obtain a first fill light intensity; or, if the response direction angle is within a second angle range, the preset back and side fill light intensities of the virtual character are obtained; based on the direction angle, the back and side fill light intensities are linearly interpolated to obtain a first fill light intensity; wherein, the maximum value in the first angle range is less than or equal to the minimum value in the second angle range; the front fill light intensity is less than or equal to the side fill light intensity, and the side fill light intensity is less than or equal to the back fill light intensity.
[0055] Specifically, the aforementioned front fill light intensity, side fill light intensity, and back fill light intensity can be preset. The values of these three fill light intensities need to meet the following conditions: the front fill light intensity is less than or equal to the side fill light intensity, and the side fill light intensity is less than or equal to the back fill light intensity. The values of these three fill light intensities are all different from each other.
[0056] The total range of the directional angle between the character's orientation and the direction of the scene light source is -180 degrees to 180 degrees; the aforementioned first angle range can be -90 to 90 degrees, representing the virtual character facing the scene light source, and the aforementioned second angle range can be the union of -90 to -180 degrees and 90 to 180 degrees, representing the virtual character facing away from the scene light source.
[0057] The angle between the above directions is represented by Angle, where Angle = abs(D player ·D sunlight ).
[0058] When the directional angle Angle is within the aforementioned first angle range, the first supplementary light intensity is calculated using the following formula: I cameraLightInten =lerp(I front ,I side ,abs(D player ·D sunlight )); where I front It is the intensity of the front fill light, I side It refers to the intensity of side fill light.
[0059] When the directional angle Angle is within the aforementioned second angle range, the first supplementary light intensity is calculated using the following formula: I cameraLightInten =lerp(I side ,I back ,abs(D player ·D sunlight )); where I side It is the intensity of side fill light, I back It refers to the intensity of the backlight.
[0060] When the virtual character moves or turns, the aforementioned directional angle Angle is a value with a smooth transition. Therefore, the first fill light intensity calculated by the two formulas for calculating the first fill light intensity is also a smooth transition.
[0061] By calculating the first supplementary light intensity in the above manner, the high light ratio effect of the virtual character being illuminated by the scene light source can be stably maintained when the virtual character is facing the scene light source, and the virtual character can also be naturally illuminated when it is facing away from the scene light source.
[0062] As can be seen from the foregoing embodiments, by setting a second fill light intensity, when the virtual character is located in a shadow area and facing the scene light source, the second fill light intensity can be used to provide fill light, thereby improving the stability of the fill light effect and enhancing the visual effect of the virtual character.
[0063] However, the supplementary lighting method in this embodiment does not distinguish between virtual characters. When the second supplementary lighting intensity is a fixed value, if a virtual character located in the center of the scene enters the shadow area, the aforementioned first supplementary lighting intensity will be reduced to 1, that is, the first supplementary lighting intensity will not produce a supplementary lighting effect. However, virtual characters in the scene that are not located in the shadow area will be supplemented by the second supplementary lighting intensity, causing these virtual characters to be abnormally bright, resulting in distorted lighting effects and affecting the visual effect of the scene.
[0064] Based on the above problems, this embodiment also provides an implementation method: for the current pixel to be rendered in the scene image to be rendered, the fill light attenuation parameter of the current pixel to be rendered is determined based on the distance between the current pixel to be rendered and the center pixel of the scene image; and the second fill light intensity is determined based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character.
[0065] When rendering a scene, the closer the pixel to be rendered is to the center pixel of the image, the smaller the fill light attenuation parameter, and the stronger the second fill light intensity. For the pixel to be rendered that is far from the center pixel of the image, the larger the fill light attenuation parameter, the lower the second fill light intensity can be reduced to 1, that is, the second fill light intensity does not produce fill light, so that the lighting effect of the virtual character at the edge of the image does not change significantly.
[0066] When determining the fill light attenuation parameter, if the distance between the current pixel to be rendered and the center pixel of the scene is less than a preset distance threshold, the fill light attenuation parameter of the current pixel to be rendered is controlled to increase as the distance increases; if the distance between the current pixel to be rendered and the center pixel of the scene is greater than or equal to the preset distance threshold, the fill light attenuation parameter of the current pixel to be rendered is controlled to the preset maximum value.
[0067] This preset distance threshold can be set in advance. Assuming the length and width of the scene are 1, and the center pixel of the scene is represented as (0.5, 0.5), the preset distance threshold can be set to 0.3, 0.5, etc. When the distance between the currently rendered pixel and the center pixel of the scene is less than the preset distance threshold, the closer the currently rendered pixel is to the center pixel, the smaller the fill light attenuation parameter and the greater the second fill light intensity. Conversely, the farther the currently rendered pixel is from the center pixel, the greater the fill light attenuation parameter and the smaller the second fill light intensity.
[0068] When the distance between the currently rendered pixel and the center pixel of the scene is greater than or equal to a preset distance threshold, the fill light attenuation parameter is the preset maximum value, and correspondingly, the second fill light intensity is the preset minimum value, and the second fill light intensity does not produce a fill light effect.
[0069] The above-mentioned supplementary lighting attenuation parameters can be calculated using the following formula: UV Factor =saturate(length(tex-0.5)-S) Among them, UV Factor This is the supplementary light attenuation parameter. The `saturate` function is used to limit the value of `length(tex-0.5)-S` to the range of 0-1. When `length(tex-0.5)-S` is less than 0, the `saturate` function outputs 0; when `length(tex-0.5)-S` is greater than 1, the `saturate` function outputs 1; when `length(tex-0.5)-S` is between 0 and 1, the `saturate` function outputs the value of `length(tex-0.5)-S`.
[0070] The `length` function is used to calculate the length of the input value, which is `tex-0.5`. `Tex` is the current pixel to be rendered, `0.5` is the center pixel of the image, and `S` is the preset distance threshold mentioned above.
[0071] Furthermore, based on the fill light attenuation parameter, a second fill light intensity is obtained by linear interpolation of the preset back fill light intensity and the reference fill light intensity of the virtual character; wherein, the back fill light intensity is greater than the reference fill light intensity. The reference fill light intensity can be set to 1, that is, the reference fill light intensity does not produce a fill light effect.
[0072] The specific intensity of the second supplementary light mentioned above can be calculated using the following formula: I non-directional =lerp(I back 1.0f, UV Factor ); Among them, I non-directional It is the second supplementary light intensity, I backThis refers to the backlight intensity; 1.0f is the baseline intensity, meaning no additional lighting is applied. (UV) Factor It is the supplementary light attenuation parameter.
[0073] In the above method, the second supplementary light intensity is related to the position of the pixel in the scene. For positions far from the center of the scene, the second supplementary light intensity does not produce a supplementary light effect. The brightness of the virtual character in the shadow area does not change visually, and there will be no abnormal brightness of the character in the scene. The lighting effect is more realistic and improves the visual effect of the scene.
[0074] In one implementation, the above-mentioned detection points include multiple points; the ratio of the first number of detection points in the shadow area of the virtual scene to the total number of detection points is obtained; based on the ratio, the first supplementary light intensity and the preset second supplementary light intensity are linearly interpolated to obtain the final supplementary light intensity.
[0075] Understandably, when the total number remains constant, the larger the first number, i.e. the larger the ratio of the number, the more parts of the virtual character will be located in the shadow area. When the virtual character moves from the shadow area to outside the shadow area, or from outside the shadow area to inside the shadow area, the ratio of the number gradually changes, and the final fill light intensity also changes linearly between the first fill light intensity and the second fill light intensity. The fill light effect of the virtual character is also a linear and smooth transition effect.
[0076] The final supplemental light intensity mentioned above can be calculated using the following formula: Result=lerp(I directional ,I non-directional (,n / N); Where Result is the final fill light intensity, I directional It is the first fill light intensity, I non-directional It is the second supplementary light intensity, n represents the first quantity, and N represents the total quantity.
[0077] Furthermore, based on the final fill light intensity, the specified illumination intensity in the virtual scene is adjusted; wherein, the specified illumination intensity includes at least one of the following: ambient light intensity of the virtual scene, image-based illumination intensity, and spherical harmonic illumination intensity; the adjusted specified illumination intensity, the illumination intensity of the scene light source, and the lens illumination intensity of the virtual camera are superimposed to obtain the superimposed illumination intensity; based on the superimposed illumination intensity, the virtual character is rendered to obtain the rendering effect of the virtual character after fill light.
[0078] The final fill light intensity mentioned above can be adjusted by adjusting only a portion of the specified lighting intensity, or by adjusting all of the specified lighting intensity. The image-based lighting intensity is also called IBL (Image Based Lighting) intensity, and the spherical harmonic lighting intensity is also called SH (Spherical Harmonics Lighting) intensity. The lighting intensity of the scene light source and the lens lighting intensity of the virtual camera are direct light intensities. The lens lighting of the virtual camera is a lens light source located in a virtual location, directed towards the virtual character being illuminated by the virtual camera, used to fill light for the virtual character. After adjusting the specified lighting intensity, the direct light intensity is superimposed to form the superimposed lighting intensity, which is then used to render the virtual character, resulting in a rendering effect with the added lighting.
[0079] like Figure 5 (a) shows the fill light effect on a virtual character in a shadow area, facing away from the scene light source; as shown in Figure (a). Figure 5 (b) shows the fill light effect of a virtual character in a shadow area facing away from the scene light source. It can be seen that with the fill light method of this embodiment, the virtual character has a stable fill light effect in any orientation.
[0080] In this embodiment, the above-mentioned virtual character lighting rendering method uses a first lighting intensity that is directional lighting intensity and a second lighting intensity that is non-directional lighting intensity. The non-directional lighting intensity and the directional lighting intensity are automatically blended, and the problem that directional lighting intensity cannot provide lighting when the virtual character is in shadow and facing a certain direction is addressed. When the virtual character gradually moves from a non-shadow area to a shadow area, the lighting intensity gradually transitions from directional lighting intensity to non-directional lighting intensity. When the virtual character is in a shadow area, the lighting intensity intensity can be kept stable regardless of the virtual character's orientation.
[0081] See Figure 6 The illustration shows a lighting and rendering device for a virtual character, where the virtual character is located in a virtual scene, which also includes a virtual camera; the device includes: The detection point determination module 60 is used to determine detection points in the virtual scene based on the line-of-sight target position of the virtual camera; The detection module 62 is used to detect whether the detection point is located in the shadow area of the virtual scene and obtain the detection result; wherein, the shadow area is generated by the scene light source in the virtual scene illuminating the specified model; The intensity determination module 64 is used to determine the first supplementary light intensity based on the virtual character's orientation and the light direction of the scene light source; The fill light rendering module 66 is used to generate the final fill light intensity based on the detection results, the first fill light intensity and the preset second fill light intensity, and to perform fill light rendering on the virtual character according to the final fill light intensity.
[0082] The aforementioned virtual character lighting rendering device includes a virtual character located in a virtual scene, which also includes a virtual camera. Based on the target position of the virtual camera's viewpoint, a detection point is determined in the virtual scene. The device detects whether the detection point is located in a shadow area of the virtual scene, obtaining a detection result. The shadow area is generated by illuminating a specified model with scene light sources in the virtual scene. A first lighting intensity is determined based on the virtual character's orientation and the direction of the scene light source. Based on the detection result, the first lighting intensity, and a preset second lighting intensity, a final lighting intensity is generated, and the virtual character is rendered with lighting according to the final lighting intensity.
[0083] In the above method, the first fill light intensity is based on the orientation of the virtual character. On this basis, the virtual character is detected by a detection point to see if it is in a shadow area. Then, based on the detection result, the first fill light intensity and the preset second fill light intensity are used to jointly determine the final fill light intensity. When the virtual character is in a shadow area and is facing the scene light source, the second fill light intensity can also be used to fill light, which improves the stability of the character fill light effect and improves the visual effect of the virtual character.
[0084] The aforementioned device also includes a position determination module, used to: in response to the virtual camera following the virtual character to take a picture, determine the position of the virtual character as the target position of the virtual camera's line of sight; or, in response to the virtual camera not following the virtual character to take a picture, determine the target position of the line of sight in the virtual scene based on the preset focus parameters of the virtual camera.
[0085] The aforementioned detection point determination module is used to: determine the scene position in the virtual scene that satisfies the preset relative position condition with respect to the line-of-sight target position of the virtual camera; and determine the determined scene position as the detection point.
[0086] The aforementioned detection module is used to: obtain the scene depth of a specified model in the virtual scene and the scene depth of the detection point, starting from the scene light source, and obtain the screen space position corresponding to the detection point; wherein, the screen space position is located in the screen space corresponding to the scene image captured from the scene light source; obtain the scene depth corresponding to the screen space position from the scene depth of the specified model; and determine whether the detection point is located in the shadow area of the virtual scene based on the scene depth corresponding to the screen space position and the scene depth of the detection point.
[0087] The detection module described above is used to: determine that the detection point is not located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space position being greater than or equal to the scene depth of the detection point; and / or, determine that the detection point is located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space position being less than the scene depth of the detection point.
[0088] The intensity determination module described above is used to: obtain the directional angle between the character's orientation and the light direction of the scene light source; and determine the first supplementary light intensity within the preset supplementary light intensity range based on the directional angle.
[0089] The intensity determination module described above is used to: respond to a direction angle within a first angle range, obtain the preset front and side fill light intensities of the virtual character; perform linear interpolation on the front and side fill light intensities based on the direction angle to obtain a first fill light intensity; or, respond to a direction angle within a second angle range, obtain the preset back and side fill light intensities of the virtual character; perform linear interpolation on the back and side fill light intensities based on the direction angle to obtain a first fill light intensity; wherein, the maximum value in the first angle range is less than or equal to the minimum value in the second angle range; the front fill light intensity is less than or equal to the side fill light intensity, and the side fill light intensity is less than or equal to the back fill light intensity.
[0090] The aforementioned device also includes a fill light determination module, used to: determine the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene; and determine the second fill light intensity based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character.
[0091] The aforementioned fill light determination module is used to: control the fill light attenuation parameter of the current pixel to be rendered to increase as the distance increases when the distance between the current pixel to be rendered and the center pixel of the scene is less than a preset distance threshold; and control the fill light attenuation parameter of the current pixel to be rendered to a preset maximum value when the distance between the current pixel to be rendered and the center pixel of the scene is greater than or equal to the preset distance threshold.
[0092] The aforementioned supplementary lighting determination module is used to: perform linear interpolation processing on the preset back supplementary lighting intensity and the reference supplementary lighting intensity of the virtual character based on the supplementary lighting attenuation parameter to obtain a second supplementary lighting intensity; wherein, the back supplementary lighting intensity is greater than the reference supplementary lighting intensity.
[0093] The aforementioned detection points include multiple points; the aforementioned supplementary lighting rendering module is used to: obtain the ratio of the first number of detection points in the shadow area of the virtual scene to the total number of detection points; based on the ratio, perform linear interpolation processing on the first supplementary lighting intensity and the preset second supplementary lighting intensity to obtain the final supplementary lighting intensity.
[0094] The aforementioned fill light rendering module is used to: adjust the specified illumination intensity in the virtual scene based on the final fill light intensity; wherein, the specified illumination intensity includes at least one of the following: ambient light intensity of the virtual scene, image-based illumination intensity, and spherical harmonic illumination intensity; superimpose the adjusted specified illumination intensity, the illumination intensity of the scene light source, and the lens illumination intensity of the virtual camera to obtain the superimposed illumination intensity; and render the virtual character based on the superimposed illumination intensity to obtain the rendering effect of the virtual character after fill light.
[0095] This embodiment also provides an electronic device, including a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor. The processor executes the computer-executable instructions to implement the aforementioned method for rendering supplementary lighting for virtual characters. This electronic device can be a server or a terminal device.
[0096] See Figure 7 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores computer-executable instructions that can be executed by the processor 100. The processor 100 executes the computer-executable instructions to implement the above-mentioned virtual character fill light rendering method.
[0097] Furthermore, Figure 7 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.
[0098] The memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0099] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0100] The processor in the aforementioned electronic device, by executing computer-executable instructions, can perform the following operations in the aforementioned virtual character fill light rendering method: A method for supplemental lighting rendering of a virtual character, wherein the virtual character is located in a virtual scene, and the virtual scene also includes a virtual camera; the method includes: determining a detection point in the virtual scene based on the target position of the virtual camera's gaze; detecting whether the detection point is located in the shadow area of the virtual scene, and obtaining a detection result; wherein the shadow area is generated by illuminating a specified model with scene light sources in the virtual scene; determining a first supplemental lighting intensity based on the character orientation of the virtual character and the light direction of the scene light source; generating a final supplemental lighting intensity based on the detection result, the first supplemental lighting intensity, and a preset second supplemental lighting intensity, and performing supplemental lighting rendering on the virtual character according to the final supplemental lighting intensity.
[0101] Before the step of determining the detection point in the virtual scene based on the virtual camera's gaze target position, the method further includes: responding to the virtual camera following the virtual character to take pictures, and determining the character position where the virtual character is located as the virtual camera's gaze target position; or, responding to the virtual camera not following the virtual character to take pictures, determining the gaze target position in the virtual scene based on the virtual camera's preset focus parameters.
[0102] The steps for determining detection points in a virtual scene based on the line-of-sight target position of a virtual camera include: determining a scene position in the virtual scene that satisfies a preset relative position condition with respect to the line-of-sight target position of the virtual camera; and determining the determined scene position as the detection point.
[0103] The steps for detecting whether a detection point is located in the shadow area of a virtual scene include: taking the scene light source as the starting point, obtaining the scene depth of a specified model in the virtual scene and the scene depth of the detection point, and obtaining the screen space position corresponding to the detection point; wherein, the screen space position is located in the screen space corresponding to the scene image captured from the perspective of the scene light source; obtaining the scene depth corresponding to the screen space position from the scene depth of the specified model; and determining whether the detection point is located in the shadow area of the virtual scene based on the scene depth corresponding to the screen space position and the scene depth of the detection point.
[0104] The above-mentioned step of determining whether a detection point is located in the shadow area of a virtual scene based on the scene depth corresponding to the screen space location and the scene depth of the detection point includes: determining that the detection point is not located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space location being greater than or equal to the scene depth of the detection point; and / or determining that the detection point is located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space location being less than the scene depth of the detection point.
[0105] The above-mentioned step of determining the first supplementary light intensity based on the character's orientation and the light direction of the scene light source includes: obtaining the directional angle between the character's orientation and the light direction of the scene light source; and determining the first supplementary light intensity within a preset supplementary light intensity range based on the directional angle.
[0106] The above-mentioned step of determining the first supplementary light intensity within a preset supplementary light intensity range based on the directional angle includes: in response to the directional angle being within a first directional angle range, obtaining the preset front supplementary light intensity and side supplementary light intensity of the virtual character; performing linear interpolation on the front supplementary light intensity and side supplementary light intensity based on the directional angle to obtain the first supplementary light intensity; or, in response to the directional angle being within a second directional angle range, obtaining the preset back supplementary light intensity and side supplementary light intensity of the virtual character; performing linear interpolation on the back supplementary light intensity and side supplementary light intensity based on the directional angle to obtain the first supplementary light intensity; wherein, the maximum value in the first directional angle range is less than or equal to the minimum value in the second directional angle range; the front supplementary light intensity is less than or equal to the side supplementary light intensity, and the side supplementary light intensity is less than or equal to the back supplementary light intensity.
[0107] Before the step of generating the final fill light intensity based on the detection results, the first fill light intensity, and the preset second fill light intensity, the method further includes: for the current pixel to be rendered in the scene image to be rendered, determining the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene image; and determining the second fill light intensity based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character.
[0108] The above-mentioned step of determining the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene image includes: in response to the distance between the current pixel to be rendered and the center pixel of the scene image being less than a preset distance threshold, controlling the fill light attenuation parameter of the current pixel to be rendered to increase as the distance increases; in response to the distance between the current pixel to be rendered and the center pixel of the scene image being greater than or equal to the preset distance threshold, controlling the fill light attenuation parameter of the current pixel to be rendered to a preset maximum value.
[0109] The above-mentioned step of determining the second supplementary light intensity based on the supplementary light attenuation parameter and the preset back supplementary light intensity of the virtual character includes: performing linear interpolation processing on the preset back supplementary light intensity and the reference supplementary light intensity of the virtual character based on the supplementary light attenuation parameter to obtain the second supplementary light intensity; wherein, the back supplementary light intensity is greater than the reference supplementary light intensity.
[0110] The above-mentioned detection points include multiple points; the step of generating the final supplementary light intensity based on the detection results, the first supplementary light intensity, and the preset second supplementary light intensity includes: obtaining the ratio of the first number of detection points in the shadow area of the virtual scene to the total number of detection points; and performing linear interpolation processing on the first supplementary light intensity and the preset second supplementary light intensity based on the ratio to obtain the final supplementary light intensity.
[0111] The steps for rendering the virtual character with fill light according to the final fill light intensity include: adjusting the specified light intensity in the virtual scene based on the final fill light intensity; wherein, the specified light intensity includes at least one of the ambient light intensity of the virtual scene, image-based light intensity, and spherical harmonic light intensity; superimposing the adjusted specified light intensity, the light intensity of the scene light source, and the lens light intensity of the virtual camera to obtain the superimposed light intensity; and rendering the virtual character based on the superimposed light intensity to obtain the rendering effect of the virtual character after fill light.
[0112] In the above method, the first fill light intensity is based on the orientation of the virtual character. On this basis, the virtual character is detected by a detection point to see if it is in a shadow area. Then, based on the detection result, the first fill light intensity and the preset second fill light intensity are used to jointly determine the final fill light intensity. When the virtual character is in a shadow area and is facing the scene light source, the second fill light intensity can also be used to fill light, which improves the stability of the character fill light effect and improves the visual effect of the virtual character.
[0113] This embodiment also provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above-mentioned virtual character lighting rendering method.
[0114] The computer-executable instructions stored in the aforementioned computer-readable storage medium can, by executing the aforementioned computer-executable instructions, perform the following operations in the aforementioned virtual character fill light rendering method: A method for supplemental lighting rendering of a virtual character, wherein the virtual character is located in a virtual scene, and the virtual scene also includes a virtual camera; the method includes: determining a detection point in the virtual scene based on the target position of the virtual camera's gaze; detecting whether the detection point is located in the shadow area of the virtual scene, and obtaining a detection result; wherein the shadow area is generated by illuminating a specified model with scene light sources in the virtual scene; determining a first supplemental lighting intensity based on the character orientation of the virtual character and the light direction of the scene light source; generating a final supplemental lighting intensity based on the detection result, the first supplemental lighting intensity, and a preset second supplemental lighting intensity, and performing supplemental lighting rendering on the virtual character according to the final supplemental lighting intensity.
[0115] Before the step of determining the detection point in the virtual scene based on the virtual camera's gaze target position, the method further includes: responding to the virtual camera following the virtual character to take pictures, and determining the character position where the virtual character is located as the virtual camera's gaze target position; or, responding to the virtual camera not following the virtual character to take pictures, determining the gaze target position in the virtual scene based on the virtual camera's preset focus parameters.
[0116] The steps for determining detection points in a virtual scene based on the line-of-sight target position of a virtual camera include: determining a scene position in the virtual scene that satisfies a preset relative position condition with respect to the line-of-sight target position of the virtual camera; and determining the determined scene position as the detection point.
[0117] The steps for detecting whether a detection point is located in the shadow area of a virtual scene include: taking the scene light source as the starting point, obtaining the scene depth of a specified model in the virtual scene and the scene depth of the detection point, and obtaining the screen space position corresponding to the detection point; wherein, the screen space position is located in the screen space corresponding to the scene image captured from the perspective of the scene light source; obtaining the scene depth corresponding to the screen space position from the scene depth of the specified model; and determining whether the detection point is located in the shadow area of the virtual scene based on the scene depth corresponding to the screen space position and the scene depth of the detection point.
[0118] The above-mentioned step of determining whether a detection point is located in the shadow area of a virtual scene based on the scene depth corresponding to the screen space location and the scene depth of the detection point includes: determining that the detection point is not located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space location being greater than or equal to the scene depth of the detection point; and / or determining that the detection point is located in the shadow area of the virtual scene in response to the scene depth corresponding to the screen space location being less than the scene depth of the detection point.
[0119] The above-mentioned step of determining the first supplementary light intensity based on the character's orientation and the light direction of the scene light source includes: obtaining the directional angle between the character's orientation and the light direction of the scene light source; and determining the first supplementary light intensity within a preset supplementary light intensity range based on the directional angle.
[0120] The above-mentioned step of determining the first supplementary light intensity within a preset supplementary light intensity range based on the directional angle includes: in response to the directional angle being within a first directional angle range, obtaining the preset front supplementary light intensity and side supplementary light intensity of the virtual character; performing linear interpolation on the front supplementary light intensity and side supplementary light intensity based on the directional angle to obtain the first supplementary light intensity; or, in response to the directional angle being within a second directional angle range, obtaining the preset back supplementary light intensity and side supplementary light intensity of the virtual character; performing linear interpolation on the back supplementary light intensity and side supplementary light intensity based on the directional angle to obtain the first supplementary light intensity; wherein, the maximum value in the first directional angle range is less than or equal to the minimum value in the second directional angle range; the front supplementary light intensity is less than or equal to the side supplementary light intensity, and the side supplementary light intensity is less than or equal to the back supplementary light intensity.
[0121] Before the step of generating the final fill light intensity based on the detection results, the first fill light intensity, and the preset second fill light intensity, the method further includes: for the current pixel to be rendered in the scene image to be rendered, determining the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene image; and determining the second fill light intensity based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character.
[0122] The above-mentioned step of determining the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene image includes: in response to the distance between the current pixel to be rendered and the center pixel of the scene image being less than a preset distance threshold, controlling the fill light attenuation parameter of the current pixel to be rendered to increase as the distance increases; in response to the distance between the current pixel to be rendered and the center pixel of the scene image being greater than or equal to the preset distance threshold, controlling the fill light attenuation parameter of the current pixel to be rendered to a preset maximum value.
[0123] The above-mentioned step of determining the second supplementary light intensity based on the supplementary light attenuation parameter and the preset back supplementary light intensity of the virtual character includes: performing linear interpolation processing on the preset back supplementary light intensity and the reference supplementary light intensity of the virtual character based on the supplementary light attenuation parameter to obtain the second supplementary light intensity; wherein, the back supplementary light intensity is greater than the reference supplementary light intensity.
[0124] The above-mentioned detection points include multiple points; the step of generating the final supplementary light intensity based on the detection results, the first supplementary light intensity, and the preset second supplementary light intensity includes: obtaining the ratio of the first number of detection points in the shadow area of the virtual scene to the total number of detection points; and performing linear interpolation processing on the first supplementary light intensity and the preset second supplementary light intensity based on the ratio to obtain the final supplementary light intensity.
[0125] The steps for rendering the virtual character with fill light according to the final fill light intensity include: adjusting the specified light intensity in the virtual scene based on the final fill light intensity; wherein, the specified light intensity includes at least one of the ambient light intensity of the virtual scene, image-based light intensity, and spherical harmonic light intensity; superimposing the adjusted specified light intensity, the light intensity of the scene light source, and the lens light intensity of the virtual camera to obtain the superimposed light intensity; and rendering the virtual character based on the superimposed light intensity to obtain the rendering effect of the virtual character after fill light.
[0126] In the above method, the first fill light intensity is based on the orientation of the virtual character. On this basis, the virtual character is detected by a detection point to see if it is in a shadow area. Then, based on the detection result, the first fill light intensity and the preset second fill light intensity are used to jointly determine the final fill light intensity. When the virtual character is in a shadow area and is facing the scene light source, the second fill light intensity can also be used to fill light, which improves the stability of the character fill light effect and improves the visual effect of the virtual character.
[0127] The computer program products of the virtual character fill light rendering method, apparatus and electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.
[0128] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0129] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0130] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0131] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0132] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for rendering fill light for virtual characters, characterized in that, The virtual character is located in a virtual scene, which also includes a virtual camera; the method includes: Based on the position of the target in the line of sight of the virtual camera, a detection point is determined in the virtual scene; The detection point is determined to be located in the shadow area of the virtual scene, and a detection result is obtained; wherein the shadow area is generated by the scene light source in the virtual scene illuminating the specified model; The first supplementary light intensity is determined based on the character orientation of the virtual character and the light direction of the scene light source; Based on the detection results, the first fill light intensity, and the preset second fill light intensity, a final fill light intensity is generated, and the virtual character is filled with light rendering according to the final fill light intensity.
2. The method according to claim 1, characterized in that, Before the step of determining the detection point in the virtual scene based on the gaze target position of the virtual camera, the method further includes: In response to the virtual camera following the virtual character to take pictures, the position of the virtual character is determined as the target position of the virtual camera's line of sight; Alternatively, in response to the virtual camera not following the virtual character to take pictures, the position of the line-of-sight target in the virtual scene is determined based on the preset focus parameters of the virtual camera.
3. The method according to claim 1, characterized in that, The step of determining detection points in the virtual scene based on the gaze target position of the virtual camera includes: From the virtual scene, determine the scene position that satisfies the preset relative position condition with respect to the line-of-sight target position of the virtual camera; and determine the scene position as the detection point.
4. The method according to claim 1, characterized in that, The step of detecting whether the detection point is located in the shadow area of the virtual scene includes: Starting from the scene light source, the scene depth of the specified model in the virtual scene and the scene depth of the detection point are obtained, and the screen space position corresponding to the detection point is obtained; wherein, the screen space position is located in the screen space corresponding to the scene image captured from the perspective of the scene light source. Obtain the scene depth corresponding to the screen space position from the scene depth of the specified model; Based on the scene depth corresponding to the screen space location and the scene depth of the detection point, it is determined whether the detection point is located in the shadow area of the virtual scene.
5. The method according to claim 4, characterized in that, The step of determining whether the detection point is located in the shadow area of the virtual scene based on the scene depth corresponding to the screen space location and the scene depth of the detection point includes: In response to the scene depth corresponding to the screen space location being greater than or equal to the scene depth of the detection point, it is determined that the detection point is not located in the shadow area of the virtual scene; And / or, in response to the scene depth corresponding to the screen space location being less than the scene depth of the detection point, it is determined that the detection point is located in the shadow area of the virtual scene.
6. The method according to claim 1, characterized in that, The step of determining the first supplementary lighting intensity based on the virtual character's orientation and the light direction of the scene light source includes: Obtain the directional angle between the character's facing direction and the direction of the light from the scene light source; Based on the directional angle, a first supplementary light intensity is determined within a preset supplementary light intensity range.
7. The method according to claim 6, characterized in that, The step of determining the first supplementary light intensity within a preset supplementary light intensity range based on the directional angle includes: In response to the directional angle being within the first directional angle range, the preset front fill light intensity and side fill light intensity of the virtual character are obtained; based on the directional angle, the front fill light intensity and side fill light intensity are linearly interpolated to obtain the first fill light intensity; Alternatively, in response to the directional angle being within the range of the second angle, the preset backlight intensity and sidelight intensity of the virtual character are obtained; based on the directional angle, the backlight intensity and sidelight intensity are linearly interpolated to obtain the first light intensity; Wherein, the maximum value in the first included angle range is less than or equal to the minimum value in the second included angle range; the front supplementary light intensity is less than or equal to the side supplementary light intensity, and the side supplementary light intensity is less than or equal to the back supplementary light intensity.
8. The method according to claim 1, characterized in that, Before the step of generating the final supplementary light intensity based on the detection result, the first supplementary light intensity, and the preset second supplementary light intensity, the method further includes: For the current pixel to be rendered in the scene image, the fill light attenuation parameter of the current pixel to be rendered is determined based on the distance between the current pixel to be rendered and the center pixel of the scene image; The second fill light intensity is determined based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character.
9. The method according to claim 8, characterized in that, The step of determining the fill light attenuation parameter of the current pixel to be rendered based on the distance between the current pixel to be rendered and the center pixel of the scene image includes: In response to the distance between the current pixel to be rendered and the center pixel of the scene being less than a preset distance threshold, the fill light attenuation parameter of the current pixel to be rendered is controlled to increase as the distance increases; In response to the distance between the current pixel to be rendered and the center pixel of the scene being greater than or equal to a preset distance threshold, the fill light attenuation parameter of the current pixel to be rendered is controlled to a preset maximum value.
10. The method according to claim 8, characterized in that, The step of determining the second fill light intensity based on the fill light attenuation parameter and the preset back fill light intensity of the virtual character includes: Based on the fill light attenuation parameter, the preset back fill light intensity and the reference fill light intensity of the virtual character are linearly interpolated to obtain the second fill light intensity; wherein, the back fill light intensity is greater than the reference fill light intensity.
11. The method according to claim 1, characterized in that, The detection points include multiple points; the step of generating the final supplementary light intensity based on the detection results, the first supplementary light intensity, and the preset second supplementary light intensity includes: Obtain the ratio of the first number of detection points within the shadow area of the virtual scene to the total number of detection points; Based on the ratio, the first supplementary light intensity and the preset second supplementary light intensity are linearly interpolated to obtain the final supplementary light intensity.
12. The method according to claim 1, characterized in that, The steps of applying fill light to the virtual character according to the final fill light intensity include: Based on the final supplementary lighting intensity, the specified lighting intensity in the virtual scene is adjusted; wherein, the specified lighting intensity includes at least one of: the ambient light intensity of the virtual scene, the image-based lighting intensity, and the spherical harmonic lighting intensity; The adjusted specified light intensity, the light intensity of the scene light source, and the lens light intensity of the virtual camera are superimposed to obtain the superimposed light intensity. Based on the superimposed light intensity, the virtual character is rendered to obtain the rendering effect of the virtual character after supplemental lighting.
13. A lighting and rendering device for a virtual character, characterized in that, The virtual character is located in a virtual scene, which also includes a virtual camera; the device includes: The detection point determination module is used to determine detection points in the virtual scene based on the position of the line-of-sight target of the virtual camera; The detection module is used to detect whether the detection point is located in the shadow area of the virtual scene and obtain the detection result; wherein, the shadow area is generated by the scene light source in the virtual scene illuminating the specified model; An intensity determination module is used to determine a first supplementary light intensity based on the character orientation of the virtual character and the light direction of the scene light source; The fill light rendering module is used to generate a final fill light intensity based on the detection results, the first fill light intensity and the preset second fill light intensity, and to perform fill light rendering on the virtual character according to the final fill light intensity.
14. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the fill light rendering method for a virtual character according to any one of claims 1-12.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the fill light rendering method for virtual characters as described in any one of claims 1-12.