Indoor shadow rendering method, device and electronic equipment

By calculating the intersection points of the window model and the interior plane, as well as the light occlusion, indoor shadows are rendered, solving the problem of insufficient shadow effects in virtual scenes and improving the realism and immersion of virtual scenes.

CN116363289BActive Publication Date: 2026-06-02NETEASE (HANGZHOU) NETWORK CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETEASE (HANGZHOU) NETWORK CO LTD
Filing Date
2023-02-03
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In existing technologies, indoor shadow rendering in virtual scenes lacks lighting and shadow effects, especially when the virtual character is outside the window, which reduces the immersion and experience of the virtual scene.

Method used

By determining the intersection points of target pixels on the window model and the interior plane, and combining the direction of light, the light transmittance of the window, and the occlusion of external objects, the shadow value is calculated and the interior plane is rendered to form changes in brightness and darkness, thereby improving the realism of the shadows.

Benefits of technology

It enhances indoor lighting and shadow effects in virtual scenes, improving the realism and immersion of virtual scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116363289B_ABST
    Figure CN116363289B_ABST
Patent Text Reader

Abstract

The application provides a rendering method and device of indoor shadow and electronic equipment, determines a first intersection point of a target pixel point on a window model along a viewing angle direction and an indoor plane; determines a second intersection point of the first intersection point along a light direction and the window model; determines a first shadow value and a second shadow value of the first intersection point according to the second intersection point and a preset window map; determines a third shadow value of the first intersection point according to the occlusion of an outdoor object and the first intersection point in the light direction; and renders the indoor plane based on the first shadow value, the second shadow value and the third shadow value. In this way, the light transmittance of the window and the light occlusion of the outdoor object are used to determine the wall shadow of the indoor plane, the window frame shadow and the shadow of the outdoor object in the indoor plane, so that the light and shadow effects in the virtual scene are more realistic, and the virtual scene is more realistic, immersive and experienced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, and electronic device for rendering indoor shadows. Background Technology

[0002] In some virtual scenes, it is often necessary to render indoor shadows. Related technologies typically use parallax mapping to map the texture corresponding to the indoor plane onto the indoor plane along the viewpoint direction at the window location. However, this rendering result lacks indoor lighting and shadow effects, especially when the virtual character is outside the window; the virtual character's shadow is not rendered indoors, resulting in a significant difference from realistic indoor lighting and shadow effects, thus reducing the immersion and experience of the virtual scene. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for rendering indoor shadows, which determines the shadows of the walls, window frames and objects outside the window in the interior by the light transmittance of the window and the light blocking of objects outside the window, thus forming changes in the brightness of the interior, so as to make the indoor lighting and shadow effects in the virtual scene more realistic, and improve the realism, immersion and experience of the virtual scene.

[0004] In a first aspect, embodiments of the present invention provide a method for rendering indoor shadows. The method includes: determining a first intersection point of a target pixel on a window model with an indoor plane along a viewing direction; wherein the viewing direction is the shooting direction of a first virtual camera corresponding to a virtual character in a virtual scene; determining a second intersection point of the first intersection point with the window model along a lighting direction; determining a first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate a wall shadow on the first intersection point; determining a second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate a window shadow on the first intersection point; determining a third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the lighting direction; wherein the third shadow value is used to indicate a dynamic shadow on the first intersection point; determining a target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and rendering the indoor plane based on the target color value.

[0005] Secondly, embodiments of the present invention provide an indoor shadow rendering apparatus, the apparatus comprising: a first intersection point determination module, configured to determine a first intersection point of a target pixel on a window model with an indoor plane along a viewing direction; wherein the viewing direction is the shooting direction of a first virtual camera corresponding to a virtual character in a virtual scene; a second intersection point determination module, configured to determine a second intersection point of the first intersection point with the window model along a lighting direction; and a first shadow value determination module, configured to determine a first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow at the first intersection point; The second shadow value determination module is used to determine the second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate the window shadow on the first intersection point; the third shadow value determination module is used to determine the third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the direction of illumination; wherein the third shadow value is used to indicate the dynamic shadow on the first intersection point; the rendering module is used to determine the target color value of the first intersection point based on the first shadow value, the second shadow value and the third shadow value; and render the interior plane based on the target color value.

[0006] 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 indoor shadow rendering method of the first aspect.

[0007] 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 implement the indoor shadow rendering method of the first aspect.

[0008] The embodiments of the present invention bring the following beneficial effects:

[0009] This invention provides a method, apparatus, and electronic device for rendering indoor shadows. The method involves determining a first intersection point between a target pixel on a window model and an indoor plane along the viewing direction; determining a second intersection point between the first intersection point and the window model along the lighting direction; determining a first shadow value and a second shadow value for the first intersection point based on the second intersection point and a preset window texture; determining a third shadow value for the first intersection point based on the occlusion of objects outside the window with the first intersection point in the lighting direction; and rendering the indoor plane based on the first, second, and third shadow values. This method determines the wall shadows, window frame shadows, and shadows cast by objects outside the window within the indoor plane by utilizing the light transmission of the window and the light occlusion of objects outside the window, thus creating variations in indoor brightness. This makes the indoor lighting and shadow effects in the virtual scene more realistic, improving the realism, immersion, and overall experience of the virtual scene.

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

[0011] 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

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

[0013] Figure 1 A flowchart illustrating an indoor shadow rendering method provided in an embodiment of the present invention;

[0014] Figure 2 A schematic diagram illustrating a method for generating a first intersection point according to an embodiment of the present invention;

[0015] Figure 3 A schematic diagram illustrating a method for generating a second intersection point according to an embodiment of the present invention;

[0016] Figure 4 A schematic diagram illustrating another method for generating a second intersection point according to an embodiment of the present invention;

[0017] Figure 5 A schematic diagram of a shadow comparison function provided in an embodiment of the present invention;

[0018] Figure 6 A schematic diagram of a wall shadow provided in an embodiment of the present invention;

[0019] Figure 7 A schematic diagram of a preset window texture provided in an embodiment of the present invention;

[0020] Figure 8 A schematic diagram of a window shadow provided for an embodiment of the present invention;

[0021] Figure 9 This is a schematic diagram illustrating a light blocking situation provided in an embodiment of the present invention;

[0022] Figure 10 This is a schematic diagram illustrating another light-blocking scenario provided by an embodiment of the present invention;

[0023] Figure 11 A schematic diagram of a dynamic shadow provided in an embodiment of the present invention;

[0024] Figure 12 A schematic diagram of the structure of an indoor shadow rendering method provided in an embodiment of the present invention;

[0025] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

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

[0027] In some virtual scenes, it is often necessary to render indoor shadows. Related technologies typically use parallax mapping to map the texture corresponding to the indoor plane onto the indoor plane along the viewing direction at the window location. However, this rendering result lacks indoor lighting and shadow effects, especially when the virtual character is outside the window; the virtual character's shadow is not rendered indoors, resulting in a significant difference from realistic indoor lighting and shadow effects, reducing the immersion and experience of the virtual scene. Therefore, this invention provides a method, apparatus, and electronic device for rendering indoor shadows. This technology can be applied to terminal devices such as mobile phones, tablets, and computers, and is particularly applicable to devices with indoor shadow rendering capabilities.

[0028] To facilitate understanding of this embodiment, a method for rendering indoor shadows disclosed in this invention will first be described in detail, such as... Figure 1 As shown, the method includes:

[0029] Step S102: Determine the first intersection point of the target pixel on the window model with the indoor plane along the viewing direction; wherein, the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene;

[0030] The aforementioned window model typically refers to a square planar model with four vertices. However, it can also be any other planar model of arbitrary shape, which is not limited here. Each pixel in the window model stores its UV coordinates. The aforementioned interior plane typically refers to the six inner surfaces of an interior cube (also called interior walls). The aforementioned first intersection point typically refers to a point within the interior as seen by the virtual character. The aforementioned window model usually has multiple pixels. The aforementioned virtual character typically refers to a virtual character located outside the window model (i.e., outdoors), and the aforementioned viewing direction typically refers to the viewing direction of the virtual character looking into the interior through the window model. When the virtual character looks into the interior through the window model, the virtual character's viewing direction intersects the window model at a target pixel. The point where this target pixel intersects one of the six interior planes along the viewing direction is the aforementioned first intersection point. The aforementioned virtual scene can be a virtual scene in a game, which typically includes virtual buildings, virtual characters, etc., such as a virtual house, which usually includes a window model.

[0031] For example, such as Figure 2 As shown, along the virtual character's viewpoint, it intersects the window model at the target pixel and intersects the interior plane at the first intersection point.

[0032] In practice, the coordinates of the target pixel can be subtracted from the coordinates of the virtual character's eye to obtain the direction vector of the viewing direction. Then, the intersection point of this direction vector with the indoor plane can be calculated to obtain the first intersection point. When the virtual character's position remains unchanged but the viewing direction moves, or when the virtual character's position changes and the viewing direction also moves, multiple first intersection points with the indoor plane can be obtained based on the coordinates of multiple target pixels obtained from the window model and the position coordinates of the virtual character's eye.

[0033] Step S104: Determine the second intersection point of the first intersection point with the window model along the lighting direction;

[0034] For example, such as Figure 3 As shown, the second intersection point is located on the window model. Additionally, as... Figure 4 As shown, the first intersection point mentioned above may intersect not only with the window model along the direction of illumination, but also with the interior plane.

[0035] In practice, the vector of the first intersection point in the lighting direction can be calculated based on the direction vector of the lighting direction and the coordinates of the first intersection point. This vector takes the first intersection point as its starting point. The intersection point of this vector with the window model can then be calculated to obtain the second intersection point mentioned above.

[0036] Step S106: Determine the first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow on the first intersection point;

[0037] In practice, if the second intersection point is located on an indoor plane, there will be a wall shadow on the first intersection point. If the second intersection point is not located on an indoor plane (e.g., on a window model), there will be no wall shadow on the first intersection point. The first shadow value can be determined based on the location of the second intersection point. For example, if the second intersection point is located on an indoor plane and there is a wall shadow on the first intersection point, the first shadow value can be set to 0. Conversely, if the second intersection point is not located on an indoor plane (e.g., on a window model) and there is no wall shadow on the first intersection point, the first shadow value can be set to 1.

[0038] Step S108: Determine the second shadow value of the first intersection point based on the second intersection point and the preset window texture; wherein, the second shadow value is used to indicate the window shadow on the first intersection point;

[0039] The aforementioned preset window texture is typically used to indicate the light transmittance of a window plane. Specifically, the pixel value of each pixel in the window texture can be preset according to the light transmittance of the window model. For example, if the first position point in the window model is light-transmitting, the pixel value of the corresponding pixel in the window texture can be set to 1; conversely, if the second position point in the window model is not light-transmitting, the pixel value of the corresponding pixel in the window texture can be set to 0.

[0040] In another approach, since the window model may be semi-transparent and have a certain degree of light transmission, if the third position point in the window model is semi-transparent, then the pixel value of the pixel corresponding to the third position point in the window texture can be set to 0.5.

[0041] Specifically, the UV coordinates of the pixel corresponding to the second intersection point can be determined based on the position coordinates of the second intersection point. The preset window texture is then sampled based on the UV coordinates, and the second shadow value at the first intersection point is determined based on the sampling result. The second shadow value can be 0 or 1; 0 indicates that there is a window frame shadow at the first intersection point, and 1 indicates that there is no window frame shadow at the first intersection point.

[0042] For example, by sampling the preset window texture based on the UV coordinates stored in the pixel of the window model where the second intersection point is located, the light transmission information of that pixel can be obtained. If the second intersection point is located on the window glass, there is no window shadow at the first intersection point, and the pixel value of the pixel at the second intersection point is 1, meaning the second shadow value is 1. Conversely, if the second intersection point is located on an opaque object (such as a window frame, window decals, or stains), there is a window shadow at the first intersection point, and the pixel value of the pixel at the second intersection point is 0, meaning the second shadow value is 0.

[0043] In one possible approach, the second shadow value could be determined based on the transparency of the window texture, such as the semi-transparency of glass.

[0044] Step S110: Determine the third shadow value of the first intersection point based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination; wherein, the third shadow value is used to indicate the dynamic shadow on the first intersection point.

[0045] The objects outside the window model can be virtual characters in the virtual scene, or they can be houses, trees, fallen leaves, or semi-transparent or opaque objects in the virtual scene; there are no restrictions here. Based on the occlusion of the objects outside the window model and the first intersection point in the direction of illumination, it can be determined whether there is a dynamic shadow at the first intersection point, and thus the third shadow value at the first intersection point can be determined.

[0046] For example, when the second intersection point is translucent, objects moving outside the window model will typically cause dynamic occlusion of the first intersection point. By transforming the world space of the virtual scene to a specified space, the occlusion of light by objects can be obtained from the depth image captured by the virtual camera corresponding to the light source. This light ray, with the light source as the starting point of the vector and the first intersection point as the ending point, intersects the window model at the second intersection point. When the second intersection point is a pixel in the window model that is not translucent, the first intersection point is always in an occluded state.

[0047] Specifically, the target image in the direction of the light source at the first intersection point is acquired. The target image is then sampled using a depth buffer to obtain the depth to which the light can reach. In other words, the coordinates (or distance from the light source) of the object outside the window represent its depth value. Then, based on the coordinates of the first intersection point, the depth value of that first intersection point is determined, which is the distance from the first intersection point to the light source. By comparing the depth value of the object outside the window with the depth value of the first intersection point, the third shadow value of the first intersection point is determined.

[0048] For example, if an object outside the window model blocks the light illuminating the first intersection point, and the depth value of the object outside the window is less than the depth value of the first intersection point, then the third shadow value is 0. If the object outside the window model does not block the light illuminating the first intersection point, then the third shadow value is 1.

[0049] One possible approach is to determine the third shadow value, which is between 0 and 1, based on the transparency of the object outside the window model that blocks the light illuminating the first intersection point.

[0050] Step S112: Based on the first shadow value, the second shadow value, and the third shadow value, determine the target color value of the first intersection point; render the interior plane according to the target color value.

[0051] The target color value mentioned above can usually be 0 (indicating shadow) or 1 (indicating no shadow), or it can be a color value obtained by superimposing the values ​​of the red, green and blue channels in the RGB color mode.

[0052] In practice, the first shadow value, the second shadow value, and the third shadow value can be calculated to obtain a mixed shadow value of the first shadow value, the second shadow value, and the third shadow value. This mixed shadow value can be determined as the target color value of the first intersection point. Alternatively, the first shadow value, the second shadow value, and the third shadow value can be combined with other parameter values ​​to calculate the target color value of the first intersection point.

[0053] The target color value of the first intersection point can be determined by calculating the average of the first, second, and third shadow values. Alternatively, it can be determined by calculating the minimum of the first, second, and third shadow values. It can also be determined by calculating the maximum of the first, second, and third shadow values. Furthermore, the target color value of the first intersection point can be calculated based on the initial wall color value of the interior plane, combined with the first, second, and third shadow values. It can also be calculated based on environmental constants, such as ambient light constant and ambient light color value, combined with the first, second, and third shadow values. Finally, it can be calculated based on light intensity, combined with the first, second, and third shadow values.

[0054] After obtaining the target color value of each first intersection point in the interior plane, the target color value is drawn onto the corresponding first intersection point to give the interior a light and dark variation effect.

[0055] The above-described method for rendering indoor shadows involves: determining the first intersection point of the target pixel on the window model with the indoor plane along the viewing direction; wherein the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; determining the second intersection point of the first intersection point with the window model along the lighting direction; determining the first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow on the first intersection point; determining the second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate the window shadow on the first intersection point; determining the third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the lighting direction; wherein the third shadow value is used to indicate the dynamic shadow on the first intersection point; determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and rendering the indoor plane based on the target color value. In this method, by observing the light transmission through the window and the light obstruction by objects outside the window, the shadows on the walls, window frames, and objects outside the window are determined, creating changes in light and dark within the room. This makes the indoor lighting and shadow effects in the virtual scene more realistic, improving the realism, immersion, and overall experience of the virtual scene.

[0056] Based on step S102 above, the step of determining the first intersection point of the target pixel on the window model with the interior plane along the viewing direction is implemented as follows:

[0057] Step 1: Determine the first coordinates of the target pixel on the window model, and the first direction vector of the view direction;

[0058] Step 2: Based on the first coordinates and the first direction vector, determine the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction;

[0059] Step 3: Determine the second coordinates of the first intersection point based on the first distance, the first coordinates, and the first direction vector.

[0060] The first coordinate mentioned above typically refers to the position coordinates of the target pixel on the window model, and this coordinate can be a normalized coordinate. The second coordinate mentioned above typically refers to the UV coordinates of the first intersection point located on the interior plane.

[0061] In practice, the coordinates of the target pixel in world space are converted into normalized coordinates to determine the first coordinates of the target pixel. Then, based on the position coordinates of the virtual character's eyes and the first coordinates of the target pixel, a first direction vector along the viewpoint is determined. For example, the first direction vector can be obtained by calculating the difference between the position coordinates of the virtual character's eyes and the first coordinates, with the virtual character's eyes as the starting point.

[0062] Based on the first coordinates of the target pixel, the first direction vector of the viewpoint, and the indoor plane, the first distance between the target pixel and the first intersection point on the indoor plane can be calculated. For example, the Ray-AABB cross-detection algorithm can be used to calculate the first distance between the first coordinates and the first intersection point on the indoor plane along the first direction vector.

[0063] Then, based on the first distance, the first coordinates, and the first direction vector, the second coordinates of the first intersection point between the viewing direction and the indoor plane can be calculated.

[0064] In the above method, the coordinates of the indoor cube map are calculated by determining the first coordinates of the target pixel, the distance between the target pixel and the first intersection point, and the first direction vector of the viewing direction, which facilitates sampling.

[0065] Based on step 1 above, which determines the first coordinates of the target pixel on the window model and the first direction vector of the view direction, one possible implementation is as follows:

[0066] A first coordinate space is constructed with the indoor center as the origin; the coordinates of the first coordinate space are within a first preset range; the UV coordinates of the target pixel are obtained, and the UV coordinates of the target pixel are converted into the first coordinates of the target pixel in the first coordinate space; the direction vector of the viewing direction is converted into the first direction vector in the first coordinate space.

[0067] The aforementioned first coordinate space typically refers to a spatial coordinate system with coordinates within a first preset range. This first preset range typically means that the values ​​in the x, y, and z directions of the first coordinate space are all between -1 and 1. The aforementioned UV coordinates typically refer to two-dimensional U and V texture map coordinates.

[0068] In actual implementation, a first coordinate space is constructed with the interior center as the origin. For example, this first coordinate space can be constructed in the shader, and then the interior plane where the window model is located can be set. For instance, the window model can be set in the plane with z = -1 in the first coordinate space. Based on the position of the target pixel on the window model, after obtaining the UV coordinates stored in the pixel, these UV coordinates can be converted into first coordinates in the first coordinate space by substituting them into a specified calculation formula. Furthermore, the direction vector of the view direction is converted into the first direction vector in the first coordinate space.

[0069] Furthermore, one possible implementation of the step of converting the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space is as follows:

[0070] The first coordinate is calculated as follows:

[0071] P = (UV - 0.5) * 2;

[0072] Where P is the first coordinate; UV is the UV coordinate.

[0073] Based on step 2 above, which involves determining the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction, using the first coordinates and the first direction vector, one possible implementation is as follows:

[0074] The first distance is calculated as follows:

[0075] T = abs(1 / V) - P / V;

[0076] t1 = min(Tx, Ty, Tz);

[0077] Where V is the first direction vector; P is the first coordinate; t1 is the first distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0078] In actual implementation, based on the first coordinate P and the first direction vector V, the intermediate variable T is calculated as follows: T = abs(1 / V) - P / V. Then, the minimum value of T in the three directions of x, y, and z is determined as the first distance t1, as follows: t1 = min(Tx, Ty, Tz).

[0079] Based on step 3 above, the step of determining the second coordinates of the first intersection point using the first coordinates and the first direction vector is implemented in one possible way:

[0080] The second coordinate is calculated as follows:

[0081] P1 = P + t1 * V

[0082] Where P1 is the second coordinate; P is the first coordinate; t1 is the first distance; and V is the first direction vector.

[0083] Based on step S104 above, the step of determining the second intersection point of the first intersection point along the lighting direction and the window model is implemented in one possible way:

[0084] The direction vector of the illumination direction is converted into a second direction vector in the first coordinate space; based on the second coordinates and the second direction vector of the first intersection point, the second distance between the first intersection point and the second intersection point of the window model along the illumination direction is determined; based on the second distance, the second coordinates of the first intersection point, and the second direction vector, the third coordinates of the second intersection point are determined.

[0085] The aforementioned third coordinate usually refers to the UV coordinate of the intersection point of the second direction vector and the window plane in the first coordinate space, which is used to sample the preset window texture.

[0086] In actual implementation, the direction vector of the illumination direction can take any value in the x, y, and z directions. Through the conversion formula, the direction vector of the illumination direction can be converted into a second direction vector in the first coordinate space. The values ​​of this second direction vector in the x, y, and z directions are all in the range of -1 to 1.

[0087] Based on the second coordinates and second direction vector of the first intersection point, the second distance between the first intersection point and the second intersection point of the window model along the lighting direction is calculated. For example, the Ray-AABB cross-detection algorithm can be used to calculate the second distance between the second coordinates of the first intersection point and the second intersection point of the window plane along the second direction vector.

[0088] Based on the second distance, the second coordinates of the first intersection point, and the second direction vector, the third coordinates of the second intersection point are calculated, thereby determining the UV coordinates of the second intersection point in the preset window texture.

[0089] In the above method, the third coordinate is determined by the second coordinate, the second distance, and the second direction vector, thereby determining the coordinates of the intersection point with the window plane, which facilitates the determination of the window shadow.

[0090] Furthermore, regarding the step of determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction based on the second coordinates and the second direction vector of the first intersection point, one possible implementation is as follows:

[0091] The second distance is calculated as follows:

[0092] W = abs(1 / L) - P1 / L;

[0093] t2 = min(Wx, Wy, Wz);

[0094] Where P1 is the second coordinate; L is the second direction vector; t2 is the second distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0095] Furthermore, regarding the step of determining the third coordinates of the second intersection point based on the second distance, the second coordinates of the first intersection point, and the second direction vector, one possible implementation is as follows:

[0096] The third coordinate is calculated as follows:

[0097] P2 = (P1 + t2 * L) * 0.5 + 0.5;

[0098] Where P1 is the second coordinate; t2 is the second distance; L is the second direction vector; and P2 is the third coordinate.

[0099] According to step S106 above, the step of determining the first shadow value of the first intersection point based on the second intersection point, one possible implementation is as follows:

[0100] Based on the third coordinate of the second intersection point, determine the coordinate value of the second intersection point; if the coordinate value is within the second preset range, determine the first shadow value of the first intersection point as the first value; the first value indicates that the first intersection point has no shadow; if the coordinate value is not within the second preset range, determine the first shadow value of the first intersection point as the second value; the second value indicates that the first intersection point has a shadow.

[0101] The aforementioned second preset range typically refers to coordinate values ​​ranging from 0 to 1 or from -1 to 1. The aforementioned first value is typically represented as 1. The aforementioned second value is typically represented as 0.

[0102] In actual implementation, based on the third coordinate of the second intersection point, the coordinate value of this third coordinate in any direction can be determined. For example, the third coordinate has coordinate values ​​in the u and v directions. If both u and v coordinate values ​​are within the range of 0 to 1, then the first intersection point is determined to have no shadow, and the first shadow value of the first intersection point is 1. If at least one of the u and v coordinate values ​​is not within the range of 0 to 1, then the first intersection point is determined to have a shadow, and the first shadow value of the first intersection point is 0.

[0103] Specifically, such as Figure 5 As shown, this represents the shadow comparison function. Based on the third coordinate of the second intersection point and the shadow comparison function, the first shadow value for each first intersection point is calculated. This is then used to draw and render the interior plane, obtaining the shadow of the interior wall. The effect of this wall shadow is as follows: Figure 6 As shown, the areas where the light is blocked by the wall have shadows, while the areas where the light is not blocked by the wall do not have shadows.

[0104] According to step S108 above, the step of determining the second shadow value of the first intersection point based on the second intersection point and the preset window texture, one possible implementation is as follows:

[0105] The second shadow value of the first intersection point is obtained by sampling the preset window texture based on the third coordinate of the second intersection point; wherein, the preset window texture is used to store the light transmission information of the window model.

[0106] The third coordinate of the second intersection point mentioned above is the UV coordinate of the window texture. For example, as shown... Figure 7The image shows a preset window texture, where white areas represent transparent glass windows and black areas represent opaque objects (such as window frames). Based on the third coordinate of the second intersection point, the preset window texture is sampled to obtain the second shadow value of the first intersection point. For example, if the second intersection point is located on glass, the pixel value is 1, meaning the second shadow value is 1; if the second intersection point is located on an opaque object (such as a window frame), the pixel value is 0, meaning the second shadow value is 0.

[0107] For example, according to such Figure 7 The preset window texture shown obtains the second shadow value at the first intersection point, which is the indoor window shadow. The window shadow effect is as follows: Figure 8 As shown.

[0108] According to step S110 above, the step of determining the third shadow value of the first intersection point based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination is described in one possible implementation:

[0109] Step (1): Obtain the light source parameters and determine the spatial transformation matrix based on the light source parameters;

[0110] Step (2): Based on the spatial transformation matrix, transform the second virtual camera corresponding to the light source into the light source space;

[0111] Step (3): Capture the virtual scene using the second virtual camera and determine the captured scene image as the target image; wherein, the target image includes the depth value of each pixel; the shooting direction of the second virtual camera is the illumination direction of the light source;

[0112] Step (4): Determine the third shadow value of the first intersection point based on the depth value and the first intersection point.

[0113] Specifically, the system obtains light source parameters, such as the illumination position, light source direction vector, and vertical direction vector of the light source. Based on these parameters, a spatial transformation matrix is ​​constructed to transform the world space containing the light source into the light source space. The second virtual camera corresponding to the light source is then transformed into the light source space, allowing the rendering of the depth buffer and the acquisition of depth information for each pixel in the virtual scene.

[0114] In the light source space, a target image is obtained by capturing a virtual scene using a second virtual camera. This target image includes the depth values ​​of each pixel. These pixels include unoccluded pixels, which can be the first intersection point inside the room, and designated occluded pixels, which can be objects outside the window model or the second intersection point located within the window frame. Based on the illumination direction formed by the light source, the depth values ​​of the first intersection point and the occluded point are obtained from the target image along that illumination direction. This allows the determination of the third shadow value of the first intersection point. For example, if the first intersection point is occluded by an object outside the window model, the third shadow value is set to 1; otherwise, it is set to 0.

[0115] Based on step (4) above, the step of determining the third shadow value of the first intersection point based on the depth value and the first intersection point, one possible implementation is as follows:

[0116] Step 101: Determine the first depth value of the specified pixel corresponding to the first intersection point from the depth values ​​of each pixel in the target image.

[0117] Step 102: In the light source space, calculate the distance between the first intersection point and the light source to obtain the second depth value of the first intersection point;

[0118] Step 103: Determine the third shadow value of the first intersection point based on the first depth value and the second depth value.

[0119] Specifically, according to, for example Figure 9 and Figure 10 The diagram illustrating the shadow algorithm is shown below, where the light source can be a street lamp, such as... Figure 9 As shown, the black dots in boxes (a) and (b) are the first intersection points that are not occluded, as... Figure 10 As shown, the black dot in box (b) is the first intersection point that is not occluded, the black dot in box (c) is the first intersection point that is occluded by a specified pixel, and the black dot in box (d) is the specified pixel corresponding to the first intersection point (that is, the pixel corresponding to the object outside the window model in the target image).

[0120] For example, after the second virtual camera captures an image of the target, such as Figure 10 As shown, based on the direction vector formed by the intersection of the light source and the second intersection point, a specified pixel point on that direction vector is determined in the target image (e.g., ...). Figure 10 The first depth value of the black dot in the square (d) (e.g.) Figure 10 (Middle line segment D). Furthermore, in the light source space, calculate the first unobstructed intersection point (e.g., Figure 10 The distance between the black dot in box (b) and the light source, which is the second depth value (e.g., Figure 10(Middle line segment Lz). Then, based on the first and second depth values ​​mentioned above, the third shaded value of the first intersection point is calculated.

[0121] Based on step 102 above, the step of calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point can be implemented in one possible way:

[0122] The second coordinate of the first intersection point is converted into the fourth coordinate in the light source space; the distance between the first intersection point and the light source is calculated based on the fourth coordinate to obtain the second depth value of the first intersection point.

[0123] In actual implementation, the second coordinate of the first intersection point in the first coordinate space is converted into the fourth coordinate in the light source space through a calculation formula. Based on the fourth coordinate, the distance between the first intersection point and the light source is calculated. For example, the distance between the two points can be calculated using the light source coordinate and the fourth coordinate of the first intersection point to obtain the second depth value of the first intersection point.

[0124] Furthermore, one possible implementation of the step of converting the second coordinates of the first intersection point into the fourth coordinates in the light source space is as follows:

[0125] P3 = (P1 + (0,0,1)) * 0.5;

[0126] Where P3 is the fourth coordinate and P1 is the second coordinate.

[0127] According to step 103 above, the step of determining the third shadow value of the first intersection point based on the first depth value and the second depth value, one possible implementation is as follows:

[0128] If the second depth value is greater than the first depth value, the third shadow value of the first intersection point is determined to be the second value; the second value indicates that the first intersection point has a shadow; otherwise, the third shadow value of the first intersection point is determined to be the first value; the first value indicates that the first intersection point has no shadow.

[0129] In actual implementation, the depth buffer is sampled using the light source space coordinates (LX,LY,0) in the light source space to obtain the following: Figure 9 After the depth information D shown, as Figure 9 As shown, D is compared with the depth information LZ of the first intersection point. If Lz (i.e., the second depth value) is greater than D (i.e., the first depth value), it indicates that the first intersection point has a shadow, and the third shadow value of the first intersection point is determined to be 0. Otherwise, if the second depth value is equal to the first depth value, it indicates that the first intersection point has no shadow, and the third shadow value of the first intersection point is determined to be 1. For example, as... Figure 11 As shown, indoors there are not only wall shadows but also dynamic shadows of objects.

[0130] Based on the above step (1), the steps of obtaining the light source parameters and determining the spatial transformation matrix based on the light source parameters are described in one possible implementation:

[0131] The spatial transformation matrix is ​​calculated as follows:

[0132] ML = [cross(g,h),h,-g];

[0133] Where ML is the spatial transformation matrix; g is the direction vector of the light source direction; h is the direction vector of the light source vertical direction; cross is used to calculate the vector product of g and h.

[0134] In actual implementation, the variables in the above spatial transformation matrix are all located in a three-dimensional coordinate system, with coordinate values ​​in the x, y, and z directions. h is usually represented as (0, 0, 1). Based on the above light source parameters, the world space can be transformed into the light source space, as shown in the following formula: ML = [cross(g,h),h,-g].

[0135] According to step S112 above, the step of determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value, one possible implementation is as follows:

[0136] Step b1: Determine the base color value of the first intersection point based on the preset indoor plane texture; wherein, the preset indoor plane texture is used to store the color information of the indoor plane.

[0137] Step b2: Determine the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity.

[0138] The basic color values ​​mentioned above can usually be 0 or 1, or they can be determined based on the values ​​of the red, green and blue channels in the RGB color mode. The value of each color channel is between 0 and 255.

[0139] In actual implementation, the pixel corresponding to the first intersection point is found in the preset indoor planar texture. The color information stored in the preset indoor planar texture can be obtained, and then the base color value of the first intersection point is determined. Based on this base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant (such as the ambient light constant), and the light intensity (such as sunlight intensity and lamp intensity), a comprehensive calculation is performed to obtain the target color value of the first intersection point.

[0140] Based on step b1 above, which involves determining the base color value of the first intersection point according to a preset indoor floor plan texture, one possible implementation is as follows:

[0141] Based on the second coordinate of the first intersection point, a preset indoor planar texture is sampled to obtain the base color value of the first intersection point.

[0142] Specifically, the second coordinate of the first intersection point is the UV coordinate. Based on the UV coordinate, the corresponding pixel point is found in the preset indoor plane texture and sampled to obtain the basic color value of the first intersection point.

[0143] Based on step b2 above, which involves determining the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity, one possible implementation is as follows:

[0144] The shadow value with the smallest value among the first shadow value, the second shadow value, and the third shadow value is determined as the target shadow value of the first intersection point; the target color value of the first intersection point is determined based on the base color value, the target shadow value, the environmental constant, and the light intensity.

[0145] In practice, the first step is to calculate the minimum shadow value among the first, second, and third shadow values ​​(e.g., S1, S2, S3) to determine the target shadow value (e.g., S) for the first intersection point. The formula can be expressed as: S = min(S1, S2, S3). For example, S1, S2, and S3 can only take values ​​of 0 or 1. If at least one of S1, S2, or S3 is 0, then the first intersection point has a shadow, and the target shadow value for the first intersection point is determined to be 0. Then, based on the base color value, target shadow value, environmental constant, and light intensity of the first intersection point in the indoor floor plan texture, a comprehensive calculation is performed to obtain the target color value for the first intersection point.

[0146] Furthermore, regarding the step of determining the target color value of the first intersection point based on the base color value, target shadow value, environmental constant, and illumination intensity, one possible implementation is as follows:

[0147] The target color value at the first intersection point is calculated using the following formula:

[0148] C = (A + (I*S))*B;

[0149] Where C is the target color value at the first intersection point; A is the environmental constant; I is the light intensity; S is the target shadow value; and B is the base color value.

[0150] In actual implementation, the target shadow value S is calculated by combining the first shadow value, the second shadow value and the third shadow value, as well as the base color value B, the environmental constant A, and the light intensity I. The formula for determining the target color value C is: C=(A+(I*S))*B.

[0151] For the above method embodiments, see Figure 12 An indoor shadow rendering apparatus is shown, the apparatus comprising:

[0152] The first intersection point determination module 121 is used to determine the first intersection point of the target pixel on the window model with the indoor plane along the viewing direction; wherein, the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene;

[0153] The second intersection point determination module 122 is used to determine the second intersection point of the first intersection point and the window model along the lighting direction;

[0154] The first shadow value determination module 123 is used to determine the first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow on the first intersection point;

[0155] The second shadow value determination module 124 is used to determine the second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate the window shadow on the first intersection point;

[0156] The third shadow value determination module 125 is used to determine the third shadow value of the first intersection point based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination; wherein, the third shadow value is used to indicate the dynamic shadow on the first intersection point;

[0157] The rendering module 126 is used to determine the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and to render the interior plane according to the target color value.

[0158] The aforementioned indoor shadow rendering device determines the first intersection point of a target pixel on a window model with the indoor plane along the viewing direction; wherein the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; determines the second intersection point of the first intersection point with the window model along the lighting direction; determines the first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow on the first intersection point; determines the second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate the window shadow on the first intersection point; determines the third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the lighting direction; wherein the third shadow value is used to indicate the dynamic shadow on the first intersection point; determines the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and renders the indoor plane based on the target color value. In this method, by observing the light transmission through the window and the light obstruction by objects outside the window, the shadows on the walls, window frames, and objects outside the window are determined, creating changes in light and dark within the room. This makes the indoor lighting and shadow effects in the virtual scene more realistic, improving the realism, immersion, and overall experience of the virtual scene.

[0159] The aforementioned first intersection point determination module is further configured to: determine the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction; determine the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction based on the first coordinates and the first direction vector; and determine the second coordinates of the first intersection point based on the first distance, the first coordinates, and the first direction vector.

[0160] The aforementioned first intersection point determination module is further configured to: construct a first coordinate space with the indoor center as the origin; wherein the coordinates of the first coordinate space are within a first preset range; obtain the UV coordinates of the target pixel, convert the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space; and convert the direction vector of the viewing direction into the first direction vector in the first coordinate space.

[0161] The aforementioned first intersection point determination module is also used to: calculate the first coordinate in the following manner: P = (UV - 0.5) * 2; where P is the first coordinate and UV is the UV coordinate.

[0162] The aforementioned first intersection point determination module is also used to: calculate the first distance in the following manner: T = abs(1 / V) - P / V; t1 = min(Tx,Ty,Tz); where V is the first direction vector; P is the first coordinate; t1 is the first distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0163] The aforementioned first intersection point determination module is also used to: calculate the second coordinate in the following manner: P1=P+t1*V; where P1 is the second coordinate; P is the first coordinate; t1 is the first distance; and V is the first direction vector.

[0164] The aforementioned second intersection point determination module is further configured to: convert the direction vector of the illumination direction into a second direction vector in the first coordinate space; determine the second distance between the first intersection point and the second intersection point of the window model along the illumination direction based on the second coordinates and the second direction vector of the first intersection point; and determine the third coordinates of the second intersection point based on the second distance, the second coordinates of the first intersection point, and the second direction vector.

[0165] The aforementioned second intersection point determination module is also used to: calculate the second distance in the following manner: W = abs(1 / L) - P1 / L; t2 = min(Wx, Wy, Wz); where P1 is the second coordinate; L is the second direction vector; t2 is the second distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0166] The aforementioned second intersection point determination module is also used to calculate the third coordinate in the following manner: P2=(P1+t2*L)*0.5+0.5; where P1 is the second coordinate; t2 is the second distance; L is the second direction vector; and P2 is the third coordinate.

[0167] The aforementioned first shadow value determination module is further configured to: determine the coordinate value of the second intersection point based on the third coordinate of the second intersection point; if the coordinate value is within a second preset range, determine the first shadow value of the first intersection point as a first value; the first value indicates that the first intersection point has no shadow; if the coordinate value is not within the second preset range, determine the first shadow value of the first intersection point as a second value; the second value indicates that the first intersection point has a shadow.

[0168] The aforementioned second shadow value determination module is further configured to: sample a preset window texture based on the third coordinate of the second intersection point to obtain the second shadow value of the first intersection point; wherein the preset window texture is used to store the light transmission information of the window model.

[0169] The aforementioned third shadow value determination module is further configured to: acquire light source parameters, determine a spatial transformation matrix based on the light source parameters; transform the second virtual camera corresponding to the light source into the light source space based on the spatial transformation matrix; capture a virtual scene using the second virtual camera, and determine the captured scene image as the target image; wherein the target image includes the depth value of each pixel; the shooting direction of the second virtual camera is the illumination direction of the light source; and determine the third shadow value of the first intersection point based on the depth value.

[0170] The aforementioned third shadow value determination module is further configured to: determine the first depth value of a specified pixel corresponding to the first intersection point from the depth values ​​of each pixel in the target image; calculate the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point; and determine the third shadow value of the first intersection point based on the first depth value and the second depth value.

[0171] The aforementioned third shadow value determination module is also used to: convert the second coordinate of the first intersection point into a fourth coordinate in the light source space; calculate the distance between the first intersection point and the light source based on the fourth coordinate to obtain the second depth value of the first intersection point.

[0172] The aforementioned third shadow value determination module is also used for: P3 = (P1 + (0,0,1)) * 0.5; where P3 is the fourth coordinate and P1 is the second coordinate.

[0173] The aforementioned third shadow value determination module is further configured to: if the second depth value is greater than the first depth value, determine the third shadow value of the first intersection point as the second value; the second value indicates that the first intersection point has a shadow; otherwise, determine the third shadow value of the first intersection point as the first value; the first value indicates that the first intersection point has no shadow.

[0174] The aforementioned third shadow value determination module is also used to: calculate the spatial transformation matrix in the following manner: ML = [cross(g,h),h,-g]; where ML is the spatial transformation matrix; g is the direction vector of the light source direction; h is the direction vector of the light source vertical direction; and cross is used to calculate the vector product of g and h.

[0175] The rendering module described above is also used to: determine the base color value of the first intersection point based on a preset indoor plane texture; wherein the preset indoor plane texture is used to store the color information of the indoor plane; and determine the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity.

[0176] The rendering module described above is also used to: sample a preset indoor planar texture based on the second coordinates of the first intersection point to obtain the base color value of the first intersection point.

[0177] The rendering module described above is also used to: determine the shadow value with the smallest value among the first shadow value, the second shadow value, and the third shadow value as the target shadow value of the first intersection point; and determine the target color value of the first intersection point based on the base color value, the target shadow value, the environment constant, and the light intensity.

[0178] The rendering module described above is also used to: calculate the target color value of the first intersection point using the following formula: C=(A+(I*S))*B; where C is the target color value of the first intersection point; A is the environment constant; I is the light intensity; S is the target shadow value; and B is the base color value.

[0179] The indoor shadow rendering apparatus provided in this embodiment of the invention has the same technical features as the indoor shadow rendering method provided in the above embodiments, so it can also solve the same technical problems and achieve the same technical effects.

[0180] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described model mapping method. This electronic device can be a server or a terminal device.

[0181] See Figure 13 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the aforementioned method for rendering indoor shadows. The method includes the following steps:

[0182] The process involves: determining the first intersection point of the target pixel on the window model with the interior plane along the viewing direction; where the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; determining the second intersection point of the first intersection point with the window model along the lighting direction; determining the first shadow value of the first intersection point based on the second intersection point; where the first shadow value indicates the wall shadow at the first intersection point; determining the second shadow value of the first intersection point based on the second intersection point and a preset window texture; where the second shadow value indicates the window shadow at the first intersection point; determining the third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the lighting direction; where the third shadow value indicates the dynamic shadow at the first intersection point; determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and rendering the interior plane based on the target color value. In this method, by observing the light transmission through the window and the light obstruction by objects outside the window, the shadows on the walls, window frames, and objects outside the window are determined, creating changes in light and dark within the room. This makes the indoor lighting and shadow effects in the virtual scene more realistic, improving the realism, immersion, and overall experience of the virtual scene.

[0183] The steps described above for determining the first intersection point of a target pixel on the window model with the interior plane along the viewing direction include: determining the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction; determining the first distance between the target pixel and the first intersection point of the interior plane along the viewing direction based on the first coordinates and the first direction vector; and determining the second coordinates of the first intersection point based on the first distance, the first coordinates, and the first direction vector. In this method, by determining the first coordinates of the target pixel, the distance between the target pixel and the first intersection point, and the first direction vector of the viewing direction, the coordinates of the interior cube map are calculated, which facilitates sampling.

[0184] The steps of determining the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction include: constructing a first coordinate space with the center of the room as the origin; wherein the coordinates of the first coordinate space are within a first preset range; obtaining the UV coordinates of the target pixel and converting the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space; and converting the direction vector of the viewing direction into the first direction vector in the first coordinate space.

[0185] The steps described above for converting the UV coordinates of a target pixel into its first coordinates in the first coordinate space include: calculating the first coordinates as follows: P = (UV - 0.5) * 2; where P is the first coordinate and UV is the UV coordinate.

[0186] The above-mentioned step of determining the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction based on the first coordinate and the first direction vector includes: calculating the first distance in the following manner: T = abs(1 / V) - P / V; t1 = min(Tx,Ty,Tz); where V is the first direction vector; P is the first coordinate; t1 is the first distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0187] The steps described above for determining the second coordinate of the first intersection point based on the first distance, the first coordinate, and the first direction vector include: calculating the second coordinate as follows: P1 = P + t1 * V; where P1 is the second coordinate; P is the first coordinate; t1 is the first distance; and V is the first direction vector.

[0188] The steps for determining the second intersection point of the first intersection point with the window model along the lighting direction include: converting the direction vector of the lighting direction into a second direction vector in the first coordinate space; determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction based on the second coordinates of the first intersection point and the second direction vector; and determining the third coordinates of the second intersection point based on the second distance, the second coordinates of the first intersection point, and the second direction vector. In this method, the third coordinates are determined using the second coordinates, the second distance, and the second direction vector, thereby determining the coordinates of the intersection point with the window plane, which facilitates the determination of the window shadow.

[0189] The above-mentioned step of determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction based on the second coordinate and the second direction vector of the first intersection point includes: calculating the second distance in the following manner: W = abs(1 / L) - P1 / L; t2 = min(Wx, Wy, Wz); where P1 is the second coordinate; L is the second direction vector; t2 is the second distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0190] The steps described above for determining the third coordinate of the second intersection point based on the second distance, the second coordinate of the first intersection point, and the second direction vector include: calculating the third coordinate as follows: P2 = (P1 + t2 * L) * 0.5 + 0.5; where P1 is the second coordinate; t2 is the second distance; L is the second direction vector; and P2 is the third coordinate.

[0191] The above-mentioned step of determining the first shadow value of the first intersection point based on the second intersection point includes: determining the coordinate value of the second intersection point based on the third coordinate of the second intersection point; if the coordinate value is within a second preset range, determining the first shadow value of the first intersection point as a first value; the first value indicates that the first intersection point has no shadow; if the coordinate value is not within the second preset range, determining the first shadow value of the first intersection point as a second value; the second value indicates that the first intersection point has a shadow.

[0192] The step of determining the second shadow value of the first intersection point based on the second intersection point and the preset window texture includes: sampling the preset window texture based on the third coordinate of the second intersection point to obtain the second shadow value of the first intersection point; wherein, the preset window texture is used to store the light transmission information of the window model.

[0193] The steps described above for determining the third shadow value of the first intersection point based on the occlusion of objects outside the window model and the first intersection point in the direction of illumination include: obtaining light source parameters and determining a spatial transformation matrix based on the light source parameters; transforming the second virtual camera corresponding to the light source into the light source space based on the spatial transformation matrix; capturing a virtual scene using the second virtual camera and determining the captured scene image as the target image; wherein the target image includes the depth value of each pixel; the shooting direction of the second virtual camera is the illumination direction of the light source; and determining the third shadow value of the first intersection point based on the depth value and the first intersection point.

[0194] The above-mentioned step of determining the third shadow value of the first intersection point based on the depth value and the first intersection point includes: determining the first depth value of the specified pixel point corresponding to the first intersection point from the depth values ​​of each pixel point of the target image; calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point; and determining the third shadow value of the first intersection point based on the first depth value and the second depth value.

[0195] The steps described above for calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point include: converting the second coordinate of the first intersection point into a fourth coordinate in the light source space; calculating the distance between the first intersection point and the light source based on the fourth coordinate to obtain the second depth value of the first intersection point.

[0196] The steps described above for converting the second coordinate of the first intersection point into the fourth coordinate in the light source space include: P3 = (P1 + (0,0,1)) * 0.5; where P3 is the fourth coordinate and P1 is the second coordinate.

[0197] The step of determining the third shadow value of the first intersection point based on the first depth value and the second depth value includes: if the second depth value is greater than the first depth value, determining the third shadow value of the first intersection point as a second value; the second value indicates that the first intersection point has a shadow; otherwise, determining the third shadow value of the first intersection point as a first value; the first value indicates that the first intersection point has no shadow.

[0198] The steps described above for obtaining light source parameters and determining the spatial transformation matrix based on the light source parameters include: calculating the spatial transformation matrix in the following manner: ML = [cross(g,h),h,-g]; where ML is the spatial transformation matrix; g is the direction vector of the light source direction; h is the direction vector of the light source vertical direction; and cross is used to calculate the vector product of g and h.

[0199] The steps for determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value include: determining the base color value of the first intersection point according to a preset indoor plane texture; wherein the preset indoor plane texture is used to store the color information of the indoor plane; and determining the target color value of the first intersection point according to the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity.

[0200] The above steps for determining the base color value of the first intersection point based on the preset indoor plane texture include: sampling the preset indoor plane texture based on the second coordinates of the first intersection point to obtain the base color value of the first intersection point.

[0201] The steps described above for determining the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity include: determining the shadow value with the smallest value among the first shadow value, the second shadow value, and the third shadow value as the target shadow value of the first intersection point; and determining the target color value of the first intersection point based on the base color value, the target shadow value, the environmental constant, and the light intensity.

[0202] The steps described above for determining the target color value of the first intersection point based on the base color value, target shadow value, ambient constant, and illumination intensity include: calculating the target color value of the first intersection point using the following formula: C = (A + (I * S)) * B; where C is the target color value of the first intersection point; A is the ambient constant; I is the illumination intensity; S is the target shadow value; and B is the base color value.

[0203] Furthermore, Figure 10 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.

[0204] The memory 101 may include high-speed random access memory (RAM) or 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, or metropolitan area network. 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 10 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.

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

[0206] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When these machine-executable instructions are invoked and executed by a processor, they cause the processor to implement the aforementioned method for rendering indoor shadows. The method includes the following steps:

[0207] The process involves: determining the first intersection point of the target pixel on the window model with the interior plane along the viewing direction; where the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; determining the second intersection point of the first intersection point with the window model along the lighting direction; determining the first shadow value of the first intersection point based on the second intersection point; where the first shadow value indicates the wall shadow at the first intersection point; determining the second shadow value of the first intersection point based on the second intersection point and a preset window texture; where the second shadow value indicates the window shadow at the first intersection point; determining the third shadow value of the first intersection point based on the occlusion of objects outside the window model with the first intersection point in the lighting direction; where the third shadow value indicates the dynamic shadow at the first intersection point; determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and rendering the interior plane based on the target color value. In this method, by observing the light transmission through the window and the light obstruction by objects outside the window, the shadows on the walls, window frames, and objects outside the window are determined, creating changes in light and dark within the room. This makes the indoor lighting and shadow effects in the virtual scene more realistic, improving the realism, immersion, and overall experience of the virtual scene.

[0208] The steps described above for determining the first intersection point of a target pixel on the window model with the interior plane along the viewing direction include: determining the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction; determining the first distance between the target pixel and the first intersection point of the interior plane along the viewing direction based on the first coordinates and the first direction vector; and determining the second coordinates of the first intersection point based on the first distance, the first coordinates, and the first direction vector. In this method, by determining the first coordinates of the target pixel, the distance between the target pixel and the first intersection point, and the first direction vector of the viewing direction, the coordinates of the interior cube map are calculated, which facilitates sampling.

[0209] The steps of determining the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction include: constructing a first coordinate space with the center of the room as the origin; wherein the coordinates of the first coordinate space are within a first preset range; obtaining the UV coordinates of the target pixel and converting the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space; and converting the direction vector of the viewing direction into the first direction vector in the first coordinate space.

[0210] The steps described above for converting the UV coordinates of a target pixel into its first coordinates in the first coordinate space include: calculating the first coordinates as follows: P = (UV - 0.5) * 2; where P is the first coordinate and UV is the UV coordinate.

[0211] The above-mentioned step of determining the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction based on the first coordinate and the first direction vector includes: calculating the first distance in the following manner: T = abs(1 / V) - P / V; t1 = min(Tx,Ty,Tz); where V is the first direction vector; P is the first coordinate; t1 is the first distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0212] The steps described above for determining the second coordinate of the first intersection point based on the first distance, the first coordinate, and the first direction vector include: calculating the second coordinate as follows: P1 = P + t1 * V; where P1 is the second coordinate; P is the first coordinate; t1 is the first distance; and V is the first direction vector.

[0213] The steps for determining the second intersection point of the first intersection point with the window model along the lighting direction include: converting the direction vector of the lighting direction into a second direction vector in the first coordinate space; determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction based on the second coordinates of the first intersection point and the second direction vector; and determining the third coordinates of the second intersection point based on the second distance, the second coordinates of the first intersection point, and the second direction vector. In this method, the third coordinates are determined using the second coordinates, the second distance, and the second direction vector, thereby determining the coordinates of the intersection point with the window plane, which facilitates the determination of the window shadow.

[0214] The above-mentioned step of determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction based on the second coordinate and the second direction vector of the first intersection point includes: calculating the second distance in the following manner: W = abs(1 / L) - P1 / L; t2 = min(Wx, Wy, Wz); where P1 is the second coordinate; L is the second direction vector; t2 is the second distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

[0215] The steps described above for determining the third coordinate of the second intersection point based on the second distance, the second coordinate of the first intersection point, and the second direction vector include: calculating the third coordinate as follows: P2 = (P1 + t2 * L) * 0.5 + 0.5; where P1 is the second coordinate; t2 is the second distance; L is the second direction vector; and P2 is the third coordinate.

[0216] The above-mentioned step of determining the first shadow value of the first intersection point based on the second intersection point includes: determining the coordinate value of the second intersection point based on the third coordinate of the second intersection point; if the coordinate value is within a second preset range, determining the first shadow value of the first intersection point as a first value; the first value indicates that the first intersection point has no shadow; if the coordinate value is not within the second preset range, determining the first shadow value of the first intersection point as a second value; the second value indicates that the first intersection point has a shadow.

[0217] The step of determining the second shadow value of the first intersection point based on the second intersection point and the preset window texture includes: sampling the preset window texture based on the third coordinate of the second intersection point to obtain the second shadow value of the first intersection point; wherein, the preset window texture is used to store the light transmission information of the window model.

[0218] The steps described above for determining the third shadow value of the first intersection point based on the occlusion of objects outside the window model and the first intersection point in the direction of illumination include: obtaining light source parameters and determining a spatial transformation matrix based on the light source parameters; transforming the second virtual camera corresponding to the light source into the light source space based on the spatial transformation matrix; capturing a virtual scene using the second virtual camera and determining the captured scene image as the target image; wherein the target image includes the depth value of each pixel; the shooting direction of the second virtual camera is the illumination direction of the light source; and determining the third shadow value of the first intersection point based on the depth value and the first intersection point.

[0219] The above-mentioned step of determining the third shadow value of the first intersection point based on the depth value and the first intersection point includes: determining the first depth value of the specified pixel point corresponding to the first intersection point from the depth values ​​of each pixel point of the target image; calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point; and determining the third shadow value of the first intersection point based on the first depth value and the second depth value.

[0220] The steps described above for calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point include: converting the second coordinate of the first intersection point into a fourth coordinate in the light source space; calculating the distance between the first intersection point and the light source based on the fourth coordinate to obtain the second depth value of the first intersection point.

[0221] The steps described above for converting the second coordinate of the first intersection point into the fourth coordinate in the light source space include: P3 = (P1 + (0,0,1)) * 0.5; where P3 is the fourth coordinate and P1 is the second coordinate.

[0222] The step of determining the third shadow value of the first intersection point based on the first depth value and the second depth value includes: if the second depth value is greater than the first depth value, determining the third shadow value of the first intersection point as a second value; the second value indicates that the first intersection point has a shadow; otherwise, determining the third shadow value of the first intersection point as a first value; the first value indicates that the first intersection point has no shadow.

[0223] The steps described above for obtaining light source parameters and determining the spatial transformation matrix based on the light source parameters include: calculating the spatial transformation matrix in the following manner: ML = [cross(g,h),h,-g]; where ML is the spatial transformation matrix; g is the direction vector of the light source direction; h is the direction vector of the light source vertical direction; and cross is used to calculate the vector product of g and h.

[0224] The steps for determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value include: determining the base color value of the first intersection point according to a preset indoor plane texture; wherein the preset indoor plane texture is used to store the color information of the indoor plane; and determining the target color value of the first intersection point according to the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity.

[0225] The above steps for determining the base color value of the first intersection point based on the preset indoor plane texture include: sampling the preset indoor plane texture based on the second coordinates of the first intersection point to obtain the base color value of the first intersection point.

[0226] The steps described above for determining the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity include: determining the shadow value with the smallest value among the first shadow value, the second shadow value, and the third shadow value as the target shadow value of the first intersection point; and determining the target color value of the first intersection point based on the base color value, the target shadow value, the environmental constant, and the light intensity.

[0227] The steps described above for determining the target color value of the first intersection point based on the base color value, target shadow value, ambient constant, and illumination intensity include: calculating the target color value of the first intersection point using the following formula: C = (A + (I * S)) * B; where C is the target color value of the first intersection point; A is the ambient constant; I is the illumination intensity; S is the target shadow value; and B is the base color value.

[0228] The computer program product of the indoor shadow rendering method, apparatus and electronic device provided in the embodiments of the present invention includes 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.

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

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

[0231] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this 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.

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

[0233] 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 indoor shadows, characterized in that, The method includes: Determine the first intersection point of the target pixel on the window model with the indoor plane along the viewing direction; wherein, the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; Determine the second intersection point of the first intersection point with the window model along the lighting direction; Based on the second intersection point, a first shadow value is determined for the first intersection point; wherein the first shadow value is used to indicate the wall shadow at the first intersection point; Based on the second intersection point and a preset window texture, a second shadow value is determined for the first intersection point; wherein the second shadow value is used to indicate the window shadow on the first intersection point; Based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination, a third shadow value of the first intersection point is determined; wherein, the third shadow value is used to indicate the dynamic shadow on the first intersection point; Based on the first shadow value, the second shadow value, and the third shadow value, the target color value of the first intersection point is determined; the interior plane is rendered according to the target color value.

2. The method according to claim 1, characterized in that, The steps for determining the first intersection point of a target pixel on a window model with the interior plane along the viewing direction include: Determine the first coordinates of the target pixel on the window model, and the first direction vector of the viewing direction; Based on the first coordinates and the first direction vector, determine the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction; Based on the first distance, the first coordinates, and the first direction vector, determine the second coordinates of the first intersection point.

3. The method according to claim 2, characterized in that, The steps of determining the first coordinates of the target pixel on the window model and the first direction vector of the viewing direction include: A first coordinate space is constructed with the center of the room as the origin; wherein the coordinates of the first coordinate space are within a first preset range. Obtain the UV coordinates of the target pixel, and convert the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space; The direction vector of the viewpoint direction is converted into a first direction vector in the first coordinate space.

4. The method according to claim 3, characterized in that, The step of converting the UV coordinates of the target pixel into the first coordinates of the target pixel in the first coordinate space includes: The first coordinate is calculated in the following manner: P = (UV - 0.5) * 2; Where P is the first coordinate; UV is the UV coordinate.

5. The method according to claim 2, characterized in that, The step of determining the first distance between the target pixel and the first intersection point of the indoor plane along the viewing direction, based on the first coordinates and the first direction vector, includes: The first distance is calculated in the following manner: T = abs(1 / V) - P / V; t1 = min(Tx, Ty, Tz); Where V is the first direction vector; P is the first coordinate; t1 is the first distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

6. The method according to claim 2, characterized in that, The step of determining the second coordinates of the first intersection point based on the first distance, the first coordinates, and the first direction vector includes: The second coordinate is calculated as follows: P1 = P + t1 * V; Wherein, P1 is the second coordinate; P is the first coordinate; t1 is the first distance; and V is the first direction vector.

7. The method according to claim 1, characterized in that, The step of determining the second intersection point of the first intersection point along the illumination direction with the window model includes: The direction vector of the illumination direction is converted into a second direction vector in the first coordinate space; Based on the second coordinates of the first intersection point and the second direction vector, determine the second distance between the first intersection point and the second intersection point of the window model along the lighting direction; Based on the second distance, the second coordinates of the first intersection point, and the second direction vector, the third coordinates of the second intersection point are determined.

8. The method according to claim 7, characterized in that, The step of determining the second distance between the first intersection point and the second intersection point of the window model along the lighting direction, based on the second coordinates of the first intersection point and the second direction vector, includes: The second distance is calculated in the following manner: W = abs(1 / L) - P1 / L; t2 = min(Wx, Wy, Wz); Where P1 is the second coordinate; L is the second direction vector; t2 is the second distance; abs is used to calculate the absolute value; min is used to determine the minimum value.

9. The method according to claim 7, characterized in that, The step of determining the third coordinates of the second intersection point based on the second distance, the second coordinates of the first intersection point, and the second direction vector includes: The third coordinate is calculated in the following manner: P2 = (P1 + t2 * L) * 0.5 + 0.5; Wherein, P1 is the second coordinate; t2 is the second distance; L is the second direction vector; and P2 is the third coordinate.

10. The method according to claim 1, characterized in that, The step of determining the first shadow value of the first intersection point based on the second intersection point includes: Based on the third coordinate of the second intersection point, determine the coordinate value of the second intersection point; If the coordinate values ​​are within a second preset range, the first shadow value of the first intersection point is determined to be a first value; the first value indicates that the first intersection point has no shadow. If the coordinate value is not within the second preset range, the first shadow value of the first intersection point is determined to be the second value; the second value indicates that the first intersection point has a shadow.

11. The method according to claim 1, characterized in that, The step of determining the second shadow value of the first intersection point based on the second intersection point and a preset window texture includes: The preset window texture is sampled based on the third coordinate of the second intersection point to obtain the second shadow value of the first intersection point; wherein, the preset window texture is used to store the light transmission information of the window model.

12. The method according to claim 1, characterized in that, The step of determining the third shadow value of the first intersection point based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination includes: Obtain the light source parameters and determine the spatial transformation matrix based on the light source parameters; Based on the spatial transformation matrix, the second virtual camera corresponding to the light source is transformed into the light source space; A virtual scene is captured by the second virtual camera, and the captured scene image is determined as the target image; wherein, the target image includes the depth value of each pixel; the shooting direction of the second virtual camera is the illumination direction of the light source; The third shadow value of the first intersection point is determined based on the depth value and the first intersection point.

13. The method according to claim 12, characterized in that, The step of determining the third shadow value of the first intersection point based on the depth value and the first intersection point includes: From the depth values ​​of each pixel in the target image, determine the first depth value of the specified pixel corresponding to the first intersection point; In the light source space, the distance between the first intersection point and the light source is calculated to obtain the second depth value of the first intersection point; Based on the first depth value and the second depth value, determine the third shadow value of the first intersection point.

14. The method according to claim 13, characterized in that, The step of calculating the distance between the first intersection point and the light source in the light source space to obtain the second depth value of the first intersection point includes: The second coordinates of the first intersection point are converted into the fourth coordinates in the light source space; The distance between the first intersection point and the light source is calculated based on the fourth coordinate, and a second depth value of the first intersection point is obtained.

15. The method according to claim 14, characterized in that, The step of converting the second coordinates of the first intersection point into the fourth coordinates in the light source space includes: P3 = (P1 + (0,0,1)) * 0.5; Wherein, P3 is the fourth coordinate and P1 is the second coordinate.

16. The method according to claim 13, characterized in that, The step of determining the third shadow value of the first intersection point based on the first depth value and the second depth value includes: If the second depth value is greater than the first depth value, the third shadow value of the first intersection point is determined to be the second value; the second value indicates that the first intersection point is shadowed. Otherwise, the third shadow value of the first intersection point is determined to be the first value; the first value indicates that the first intersection point has no shadow.

17. The method according to claim 12, characterized in that, The steps of obtaining light source parameters and determining the spatial transformation matrix based on the light source parameters include: The spatial transformation matrix is ​​calculated in the following manner: ML = [cross(g,h),h,-g]; Where ML is the spatial transformation matrix; g is the direction vector of the light source direction; h is the direction vector of the vertical direction of the light source; cross is used to calculate the vector product of g and h.

18. The method according to claim 1, characterized in that, The step of determining the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value includes: Based on a preset indoor plane texture, the base color value of the first intersection point is determined; wherein, the preset indoor plane texture is used to store the color information of the indoor plane; The target color value of the first intersection point is determined based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity.

19. The method according to claim 18, characterized in that, The step of determining the base color value of the first intersection point based on a preset indoor floor plan texture includes: Based on the second coordinates of the first intersection point, the preset indoor planar texture is sampled to obtain the base color value of the first intersection point.

20. The method according to claim 18, characterized in that, The step of determining the target color value of the first intersection point based on the base color value, the first shadow value, the second shadow value, the third shadow value, the environmental constant, and the light intensity includes: The shadow value with the smallest value among the first shadow value, the second shadow value, and the third shadow value is determined as the target shadow value of the first intersection point; The target color value of the first intersection point is determined based on the base color value, the target shadow value, the environmental constant, and the illumination intensity.

21. The method according to claim 20, characterized in that, The step of determining the target color value of the first intersection point based on the base color value, the target shadow value, the environmental constant, and the illumination intensity includes: The target color value of the first intersection point is calculated using the following formula: C = (A + (I*S))*B; Wherein, C is the target color value of the first intersection point; A is the environmental constant; I is the light intensity; S is the target shadow value; and B is the base color value.

22. A device for rendering indoor shadows, characterized in that, The device includes: The first intersection point determination module is used to determine the first intersection point between the target pixel on the window model and the indoor plane along the viewing direction; wherein, the viewing direction is the shooting direction of the first virtual camera corresponding to the virtual character in the virtual scene; The second intersection point determination module is used to determine the second intersection point of the first intersection point with the window model along the lighting direction; The first shadow value determination module is used to determine the first shadow value of the first intersection point based on the second intersection point; wherein the first shadow value is used to indicate the wall shadow on the first intersection point; The second shadow value determination module is used to determine the second shadow value of the first intersection point based on the second intersection point and a preset window texture; wherein the second shadow value is used to indicate the window shadow on the first intersection point; The third shadow value determination module is used to determine the third shadow value of the first intersection point based on the occlusion of the object outside the window model and the first intersection point in the direction of illumination; wherein, the third shadow value is used to indicate the dynamic shadow on the first intersection point; The rendering module is used to determine the target color value of the first intersection point based on the first shadow value, the second shadow value, and the third shadow value; and to render the interior plane according to the target color value.

23. An electronic device, characterized in that, The system 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 indoor shadow rendering method according to any one of claims 1-21.

24. 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 indoor shadow rendering method according to any one of claims 1-21.