Shadow drawing method and device, terminal and storage medium

By generating a high-resolution first shadow map and a low-resolution second shadow map, the problem of insufficient detail of virtual objects in the virtual environment is solved, and a more detailed shadow effect is achieved.

CN119672202APending Publication Date: 2025-03-21TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311229232.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-21
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

The prior art causes the shadow effect of a specific virtual object to be less detailed when rendering shadows in a large-scale virtual environment, such as the shadow effect caused by clothing and hair is not detailed enough.

Method used

High-quality and low-quality shadows are drawn respectively by generating the high-resolution first shadow map corresponding to the target virtual object and the second shadow map of other elements in the virtual environment to enhance the shadow performance of the virtual object.

Benefits of technology

It improves the degree of shadow details on the surface of the virtual object and enhances the expression effect of shadows, especially in areas such as clothing and clothing of the virtual object.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672202A_ABST
    Figure CN119672202A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a shadow drawing method and device, equipment and a storage medium, and relates to the field of virtual environments. Comprising the following steps: determining a target virtual object in a virtual environment; a first shadow map and a second shadow map corresponding to the target virtual object are generated, the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environment elements except the target virtual object in the virtual environment; the resolution of the first shadow map is higher than that of the second shadow map; a first shadow is drawn on the surface of the target virtual object based on the first shadow map, a second shadow is drawn on the surface of the target virtual object based on the second shadow map, and the shadow quality of the first shadow is higher than that of the second shadow. The shadow of the target virtual object is composed of the first shadow and the second shadow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of virtual environments, and in particular to a shadow drawing method, device, terminal, and storage medium. Background Art

[0002] At present, many applications have the function of building a three-dimensional virtual environment. In the process of drawing the virtual environment, in order to make the drawn three-dimensional virtual environment closer to the real effect, the shadow of the virtual object is usually drawn into the picture when drawing the virtual object, thereby reflecting the lighting effect of the three-dimensional virtual environment.

[0003] In the related art, cascade shadow technology is usually used when rendering shadows in virtual scenes. In a large-scale virtual scene, the view cone of the virtual camera is divided into multiple cascade areas through the cascade shadow technology, and different cascade areas correspond to shadow maps with different levels of detail, thereby improving the quality of the drawn shadows.

[0004] However, when the solutions provided by the relevant technologies are used to render shadows in a large-scale virtual environment, the shadow effects for specific virtual objects have a low level of detail. For example, the shadows caused by the virtual object's clothing, hair, etc. are rendered poorly through the solutions provided by the relevant technologies, resulting in poor shadow rendering effects for important virtual objects in the virtual environment. Summary of the invention

[0005] The embodiments of the present application provide a shadow drawing method, device, terminal and storage medium, which can enhance the shadow effect drawn on the surface of a target virtual object in a virtual environment. The technical solution is as follows:

[0006] On the one hand, an embodiment of the present application provides a shadow drawing method, the method comprising:

[0007] determining a target virtual object in a virtual environment;

[0008] Generate a first shadow map and a second shadow map corresponding to the target virtual object, wherein the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map;

[0009] A first shadow is drawn on the surface of the target virtual object based on the first shadow map, and a second shadow is drawn on the surface of the target virtual object based on the second shadow map, wherein the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

[0010] On the other hand, an embodiment of the present application provides a shadow drawing device, the device comprising:

[0011] A determination module, used for determining a target virtual object in a virtual environment;

[0012] a generating module, configured to generate a first shadow map and a second shadow map corresponding to the target virtual object, wherein the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map;

[0013] A drawing module is used to draw a first shadow on the surface of the target virtual object based on the first shadow map, and to draw a second shadow on the surface of the target virtual object based on the second shadow map, wherein the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

[0014] On the other hand, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the shadow drawing method described in the above aspects.

[0015] On the other hand, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the shadow drawing method as described in the above aspects.

[0016] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the shadow drawing method provided in the above aspect.

[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0018] In an embodiment of the present application, during the shadow drawing process, the target virtual object in the virtual environment is first determined, and then a first shadow map corresponding to the surface of the target virtual object and a second shadow map of other environmental elements in the virtual environment except the target virtual object are generated, so that a first shadow with high shadow quality is drawn on the surface of the virtual object based on the high-resolution first shadow map, and a second map with lower shadow quality is drawn based on the second shadow map, which is beneficial to enhancing the shadow performance of the target virtual object, and can draw the shadow effect of the target virtual object's clothing, etc. on the surface of the target virtual object. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A schematic diagram of an implementation environment provided by an exemplary embodiment of the present application is shown;

[0020] Figure 2 A flowchart of a shadow drawing method provided by an exemplary embodiment of the present application is shown;

[0021] Figure 3 A schematic diagram of a virtual environment and a shadow map provided by an exemplary embodiment of the present application is shown;

[0022] Figure 4 A comparison diagram of the shadow drawing effect provided by an exemplary embodiment of the present application is shown;

[0023] Figure 5 A flowchart of a shadow drawing process provided by an exemplary embodiment of the present application is shown;

[0024] Figure 6 A schematic diagram of a first shadow map provided by an exemplary embodiment of the present application is shown;

[0025] Figure 7 A schematic diagram showing a principle of determining an occlusion situation provided by an exemplary embodiment of the present application is shown;

[0026] Figure 8 A schematic diagram of an occlusion situation shown in an exemplary embodiment of the present application is shown;

[0027] Fig. 9 An effect diagram of shadow drawing based on transparency provided by an exemplary embodiment of the present application is shown;

[0028] Fig.10 A schematic diagram showing different voxel regions provided by an exemplary embodiment of the present application is shown;

[0029] Fig.11 A flowchart of a shadow drawing process of a target virtual object provided by an exemplary embodiment of the present application is shown;

[0030] Fig.12 A schematic diagram of a virtual object creation interface provided by an exemplary embodiment of the present application is shown;

[0031] Fig.13 A structural block diagram of a shadow drawing device provided by an exemplary embodiment of the present application is shown;

[0032] Fig.14 A schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION

[0033] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0034] First, a brief introduction is given to the terms involved in the embodiments of the present application:

[0035] Virtual environment: is a virtual environment displayed (or provided) when an application is running on a terminal. The virtual environment can be a simulation of the real world, a semi-simulation and semi-fictitious environment, or a purely fictitious environment. The virtual environment can be any one of a two-dimensional virtual environment, a 2.5-dimensional virtual environment, and a three-dimensional virtual environment, and this application does not limit this. The following embodiments are illustrated by taking the virtual environment as a three-dimensional virtual environment.

[0036] Virtual object: refers to an object that can be moved in a virtual environment. The movable object can be at least one of a virtual object, a virtual animal, and a cartoon character. Optionally, when the virtual environment is a three-dimensional virtual environment, the virtual object can be a three-dimensional virtual model. Each virtual object has its own shape and volume in the three-dimensional virtual environment and occupies a part of the space in the three-dimensional virtual environment. Optionally, the virtual object is a three-dimensional character built based on three-dimensional human skeleton technology, and the virtual object achieves different external images by wearing different skins.

[0037] Rendering (drawing): refers to the process of generating images from models through algorithms. The model uses language or data structure to describe a defined three-dimensional object or virtual scene, including geometry, viewpoint, texture, lighting and shadow information. The generated image is a digital image or bitmap image that can be displayed on the screen.

[0038] Texture: refers to the image resources used in the game, which can be stored on the hard disk, added to the memory, or generated and resident in the memory during the rendering process. During the rendering process, the information of the texture may be read for further rendering operations.

[0039] Depth: refers to the distance between a virtual object and a virtual camera. The depth of the same virtual object observed from different directions in a virtual environment may be different.

[0040] Shadow map: refers to the process of generating real-time shadows of virtual objects during the rendering process. Shadow maps record the depth of the object sampled by each pixel in the map from the virtual light source in the direction of the light source. Shadow maps are used to further calculate the shadow conditions of various objects in the virtual environment.

[0041] Cascade shadow technology: It is a shadow map-based technology that records multiple shadow maps at different depth levels and uses different shadow maps according to the depth of the virtual object when drawing shadows. Among them, higher-resolution shadow maps are used at positions closer to the virtual camera, and lower-resolution shadow maps are used at positions farther from the virtual camera to solve the problem of shadow aliasing and improve shadow quality.

[0042] Frame: The rendering process of computer equipment is discrete. Each time an image of the scene from the current virtual camera's perspective is generated and displayed on the screen, the process of generating an image is a frame. Usually, a frame also includes many rendering operations. In order to ensure the smoothness of the user's viewing experience, at least thirty or sixty frames need to be rendered in one second.

[0043] The method provided in the present application can be applied to virtual reality applications, three-dimensional map programs, first-person shooting games (First-Person Shooting game, FPS), third-person shooting games (Third-Person Shooting game, TPS), multiplayer online tactical competitive games (Multiplayer Online Battle Arena Games, MOBA), etc. The following embodiments are illustrated by using applications in games.

[0044] Figure 1 A schematic diagram of an implementation environment provided by an exemplary embodiment of the present application is shown, and the implementation environment includes a terminal 110 and a server 120. The terminal 110 and the server 120 perform data communication via a communication network, and optionally, the communication network may be a wired network or a wireless network, and the communication network may be at least one of a local area network, a metropolitan area network, and a wide area network.

[0045] Terminal 110 is an electronic device with a function of drawing shadows of virtual objects. The electronic device may be a mobile terminal such as a smart phone, a tablet computer, a laptop computer, or a desktop computer, or a projection computer, etc., which is not limited in the embodiments of the present application. The terminal may provide a shadow drawing function through, for example, a virtual reality application, a three-dimensional map program, a TPS game, a FPS game, a MOBA game, etc., which is not limited in the present application. Optionally, the application may be a stand-alone application, such as a stand-alone 3D game program, or a network-connected application.

[0046] The server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The server 120 is used to provide background services for applications that support shadow drawing of virtual objects. Optionally, the server 120 undertakes the main computing work and the terminal 110 undertakes the secondary computing work; or, the server 120 undertakes the secondary computing work and the terminal undertakes the main computing work; or, a distributed computing architecture is used between the server 120 and the terminal for collaborative computing.

[0047] like Figure 1 As shown, when there is a need to draw a shadow of a virtual object, the terminal 110 determines the target virtual object in the virtual environment, and generates a first shadow map and a second shadow map corresponding to the target virtual object, and then draws a first shadow on the surface of the target virtual object based on the first shadow map, and draws a second shadow on the target virtual object based on the second shadow map.

[0048] In a possible implementation, when there is a need to draw a shadow of a virtual object, the terminal 110 determines a target virtual object in the virtual environment and sends the target virtual object to the server 120. The server 120 generates a first shadow map and a second shadow map corresponding to the target virtual object based on the data of the current virtual environment, and sends the first shadow map and the second shadow map to the terminal 110. The terminal 110 draws a second shadow on the target virtual object based on the first shadow map and the second shadow map.

[0049] For the convenience of description, the following embodiments are described by taking the shadow drawing method executed by a computer device as an example.

[0050] Please refer to Figure 2, which shows a flowchart of a shadow drawing method provided by an exemplary embodiment of the present application. The method comprises the following steps:

[0051] Step 201: determine a target virtual object in a virtual environment.

[0052] A virtual object refers to an object controlled by a user in a three-dimensional virtual environment. For example, a virtual object may be at least one of a virtual person, a virtual animal, a cartoon person, a virtual vehicle, and a virtual animal.

[0053] The virtual environment refers to the three-dimensional environment in which the virtual objects are located in the virtual world during the running of the application in the terminal. Optionally, in the embodiment of the present application, the virtual environment is observed by a virtual camera.

[0054] Optionally, the virtual camera automatically follows the master virtual object in the virtual world, that is, when the position of the virtual object in the virtual world changes, the virtual camera follows the position of the virtual object in the virtual world and changes simultaneously, and the virtual camera is always within a preset distance range of the virtual object in the virtual world. Optionally, during the automatic following process, the relative position of the virtual camera and the virtual object does not change.

[0055] A virtual camera refers to a three-dimensional model located around a virtual object in a virtual world. When the first-person perspective is adopted, the virtual camera is located near the head of the virtual object or at the head of the virtual object; when the third-person perspective is adopted, the virtual camera can be located behind the virtual object and bound to the virtual object, or can be located at any position at a preset distance from the virtual object. Through the virtual camera, the virtual object located in the virtual world can be observed from different angles. Optionally, when the third-person perspective is a first-person over-the-shoulder perspective, the virtual camera is located behind the virtual object (such as the head and shoulders of the virtual object). Optionally, in addition to the first-person perspective and the third-person perspective, the perspective also includes other perspectives, such as a bird's-eye view; when a bird's-eye view is adopted, the virtual camera can be located above the head of the virtual object, and the bird's-eye view is a perspective of observing the virtual world from an aerial perspective. Optionally, the virtual camera will not be actually displayed in the virtual world, that is, the virtual camera is not displayed in the virtual world displayed in the user interface.

[0056] Optionally, there is a virtual light source in the virtual environment, which emits virtual light in all directions from the virtual light source as a starting point. The surfaces of virtual objects in the virtual environment illuminated by the virtual light have their colors, and shadows are generated on the surfaces of virtual objects that are not illuminated by the virtual light.

[0057] Step 202: Generate a first shadow map and a second shadow map corresponding to the target virtual object.

[0058] Among them, the first shadow map is a shadow map including the target virtual object, the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map.

[0059] The shadow quality of the shadow is positively correlated with the resolution of the shadow map, that is, the higher the resolution of the shadow map, the higher the shadow quality of the shadow drawn based on the shadow map, and the lower the resolution of the shadow map, the lower the shadow quality of the shadow drawn based on the shadow map.

[0060] Optionally, when generating the first shadow map, first observe the target virtual object in the virtual environment from the position of the virtual light source, and save the information of the depth buffer to the texture to obtain a first shadow map. The information in the depth buffer refers to the depth information (i.e., depth value) of the target virtual object under the observation angle of the virtual light source, and the depth information of the target virtual object is saved to the texture to obtain a depth texture (i.e., shadow map). When generating the second shadow map, similarly observe other environmental elements in the virtual environment except the target virtual object from the position of the virtual light source, save the information of the depth buffer to the texture, and obtain the second shadow map.

[0061] The resolution of the first shadow map is higher than that of the second shadow map, that is, the sampling points of the pixels in the first shadow map are more than the sampling points of the pixels in the second shadow map.

[0062] Optionally, when cascaded shadow maps are used for shadow drawing, there are multiple second shadow maps with different resolutions. The virtual environment is divided into different depth areas, and the resolutions of the shadow maps corresponding to different depth areas are negatively correlated with the depth of the depth area, that is, the resolution of the shadow map corresponding to the area closest to the camera should be higher, and the resolution of the shadow map corresponding to the area farthest from the camera should be lower.

[0063] Optionally, in the process of generating cascaded shadow maps, the visible virtual environment range of the virtual camera is first divided based on the depth, and then the bounding box of each divided area is calculated, and then a shadow map is generated for each area.

[0064] For illustration, please refer to Figure 3, which shows a schematic diagram of a virtual environment and shadow map provided by an exemplary embodiment of the present application. The left side of the figure is a schematic diagram of a virtual environment, which includes multiple environmental elements. The right figure is a cascaded shadow map corresponding to the virtual environment. The shadow map is a depth map of the environmental elements in the virtual environment compared to the virtual light source in the direction of the light source. The virtual environment corresponds to multiple cascaded shadow maps, each of which records the depth information of a voxel area from the perspective of the light source. Shadows in the virtual environment can be drawn based on this depth information.

[0065] Step 203: Draw a first shadow on the surface of the target virtual object based on the first shadow map, and draw a second shadow on the surface of the target virtual object based on the second shadow map.

[0066] Among them, since the resolution of the first shadow map is higher than the resolution of the second shadow map, the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

[0067] The shadow generated on the surface of the target virtual object is caused by the virtual light irradiating to the target virtual object being blocked.

[0068] The first shadow map is a shadow map containing the target virtual object, and the first shadow drawn based on the first shadow map is a shadow caused by the virtual light being blocked by the environment-related element corresponding to the target virtual object. The object-related element may be an ornament, clothing, scarf, hat, etc. worn by the virtual object, or the object-related element may be a body part such as the hair, nose bridge, arm, etc. of the target virtual object.

[0069] Optionally, the first shadow is caused by a body part of the target virtual object blocking the virtual light, thereby casting a shadow on the surface of the target virtual object. For example, the bridge of the target virtual object's nose blocks the virtual light, causing a shadow on the target virtual object's face, or the target virtual object's arm may block the light, causing a shadow to be cast on the surface of other parts of the target virtual object.

[0070] The second shadow map is a shadow map containing other environmental elements in the virtual environment except the target virtual object, and the second shadow drawn based on the second shadow map is a shadow caused by the target virtual object being blocked by other environmental elements in the virtual environment. For example, there is a tree in the virtual environment, and the tree blocks the light projected toward the target virtual object, thereby causing a shadow to be generated on the surface of the target virtual object.

[0071] Optionally, before shadow drawing is performed on the surface of the target virtual object based on the first shadow map and the second shadow map, the computer device obtains a panoramic shadow map containing all environmental elements in the virtual environment captured by the virtual camera. Subsequently, shadow drawing is performed on all environmental elements in the virtual environment based on the panoramic shadow map, and then shadow drawing is performed on the target virtual object based on the first shadow map and the second shadow map, respectively. Shadow drawing of all environmental elements in the virtual environment based on the panoramic shadow map can draw shadows in the virtual environment caused by light blocking by the target virtual object.

[0072] To summarize, in the process of shadow drawing, the target virtual object in the virtual environment is first determined, and then a first shadow map corresponding to the surface of the target virtual object and a second shadow map of other environmental elements in the virtual environment except the target virtual object are generated, so that a first shadow with high shadow quality is drawn on the surface of the virtual object based on the high-resolution first shadow map, and a second map with lower shadow quality is drawn based on the second shadow map, which is beneficial to enhancing the shadow performance of the target virtual object, and can draw the shadow effect of the target virtual object's clothing, etc. on the surface of the target virtual object.

[0073] Please refer to Figure 4 , which shows a comparison diagram of the shadow drawing effect provided by an exemplary embodiment of the present application. When the shadow of a virtual object is drawn by the solution provided by the related art, the shadow of the virtual object after drawing is not detailed enough, and the details in the shadow drawn only by cascading shadow maps are easily lost, such as the details of the virtual object's clothing, wrinkles and texture. For example, Figure 4 In the left image, the virtual object's hair and scarf occluded area are not drawn with shadows. However, the method provided in the embodiment of the present application can draw a more detailed shadow effect on the surface of the target virtual object. For example, Figure 4 In the middle right image, the first shadow is caused by the hair and scarf of the target virtual object blocking the virtual light.

[0074] In the embodiment of the present application, the first shadow map and the second shadow map generated are respectively a shadow map containing only the target virtual object and a shadow map containing other environmental elements except the target virtual object. In the process of generating the shadow map, it is necessary to generate the shadow map based on the depth of the target virtual object relative to the virtual light source in the illumination direction, and then draw it. The process of drawing the shadow will be described below through an exemplary embodiment.

[0075] Please refer to Figure 5 , which shows the flow of the shadow drawing process provided by an exemplary embodiment of the present application, the process includes:

[0076] Step 501: Generate a first shadow map based on the depth of the target virtual object relative to the virtual light source in the illumination direction.

[0077] The process of generating a shadow map is the process of rendering a depth map from the perspective of the light source. The depth map records the minimum depth from the virtual light source to the virtual scene. During rendering, the recorded minimum depth is used to determine whether the current pixel is in the shadow.

[0078] Optionally, a light source camera is set at the position of the virtual light source, and the target virtual object in the virtual environment is observed with the lighting direction as the observation angle, and a first shadow map is used to record the pixel depth of the target virtual object observed by the light source camera (that is, the nearest depth observed at each pixel position in the shadow map) as the occlusion depth.

[0079] Please refer to Figure 6 , which shows a schematic diagram of a first shadow map provided by an exemplary embodiment of the present application, which is a depth map of the target virtual object relative to the light source position obtained by placing the virtual camera at the light source position. Among them, the closer the position is to the virtual light source, the darker the color of the corresponding pixel in the first shadow map. Similarly, when generating shadow maps corresponding to other environmental elements other than the target virtual object in the virtual environment, the computer device generates a second shadow map based on the depth of other environmental elements other than the target virtual object relative to the virtual light source in the lighting direction. This process is the same as the steps of generating the first shadow map, and will not be repeated in this embodiment.

[0080] In a possible implementation, the object-associated element can transmit light, that is, the object-associated element has a certain degree of transparency. When the object-associated element has transparency, the light will not be completely blocked, and no shadow will be generated on the surface of the target virtual object due to the light blocking by the object-associated element, or the generated shadow will be lighter in color. Therefore, when generating the first shadow map, the first shadow map can be generated based on the depth of the target virtual object relative to the virtual light source in the illumination direction and the transparency information of the voxels on the surface of the target virtual object.

[0081] First, the computer device obtains transparency information of the object-associated element corresponding to the target virtual object, wherein the transparency information is used to characterize the transparency of the object-associated element, and the object-associated element refers to an element that affects the shadow drawing of the surface of the target virtual object.

[0082] Subsequently, in the process of generating the shadow map, since the shadow map records the minimum depth from the virtual light source to the virtual scene (the voxel with the minimum depth is the sampling voxel), if the sampling voxel on the surface of the target virtual object in the virtual environment corresponding to the pixel point in the first shadow map can transmit light, then the object-associated element to which the sampling voxel belongs will not produce a shadow on the surface of the target virtual object, or the degree of shadow shading produced will be small. In the game scene, if the transparency of the object-associated element to which the sampling voxel belongs is high, it can be regarded that the object-associated element to which the sampling point belongs will not produce a shadow on the surface of the target virtual object.

[0083] Therefore, in the process of generating the shadow map, it can be determined whether to record the depth of the sampled voxel in the shadow map according to the set shadow threshold, that is, whether the pixel of the generated first shadow map corresponds to the voxel on the surface of the target virtual object. In the case where the transparency indicated by the transparency information of the voxel on the surface of the target virtual object is lower than the transparency threshold, the first shadow map includes the pixel corresponding to the voxel; in the case where the transparency indicated by the transparency information of the voxel on the surface of the target virtual object is higher than the transparency threshold, the first shadow map includes the pixel corresponding to the voxel.

[0084] Optionally, during the shadow drawing process, the shadow map can be generated by changing the transparency threshold to control the shadow drawing effect, so as to make the shadow drawing effect in the virtual environment better fit the shadow situation produced by real lighting. When the transparency threshold is low, the shadow can be generated on the surface of the virtual character only when the transparency of the object-associated element is also low. For example, if the transparency threshold is 20%, the object-associated element with a transparency of 30% cannot generate a shadow on the surface of the virtual character. There may be multiple layers of object-associated elements that will not generate shadows, so that the layered drawing effect of the object-associated elements of the semi-transparent elements on the surface of the virtual character is better. When the transparency threshold is high, when the transparency of the object-associated element is high, most of the semi-transparent object-associated elements will not generate shadows on the surface of the target virtual character. For example, if the transparency threshold is 60%, the object-associated element with a transparency of 80% cannot generate a shadow on the surface of the virtual character.

[0085] Step 502: Draw a first shadow on the surface of the target virtual object based on the first shadow map and the depth map of the target virtual object in the shooting direction of the virtual camera.

[0086] In the shadow drawing process of the virtual environment, there is a virtual light source and a virtual camera in the virtual environment. The shooting direction of the virtual camera is different from the irradiation direction (optical fiber emission direction) of the virtual light source. When generating the first shadow map, the computer device generates it based on the depth of the target virtual object in the irradiation direction of the virtual light source. When drawing the shadow, it is necessary to refer to the generated depth map and the depth map of the target virtual object in the shooting direction of the virtual camera. The depth map is generated based on the depth of the target virtual object in the shooting direction of the virtual camera.

[0087] The shadow area is essentially the voxel position that cannot be illuminated by light. Therefore, after obtaining the first shadow map, the computer device obtains the coordinates of each voxel of the target virtual object in the lighting space, thereby obtaining the depth of each voxel relative to the light source position in the lighting direction, thereby achieving the drawing of the first shadow.

[0088] Specifically, firstly, based on the first shadow map and the depth map, the occlusion conditions of different voxels on the surface of the target virtual object are determined.

[0089] The computer device obtains the shooting space coordinates (x, y, z) of each sampling voxel on the surface of the target virtual object under the shooting perspective of the virtual camera (the shooting space coordinates are the positions of each sampling voxel on the surface of the target virtual object in the space coordinate system with the virtual camera as the origin), and then transforms the coordinates into the lighting space coordinates (x', y', z') with the virtual light source as the origin, and finally compares z' with the depth value z0 of the corresponding pixel point recorded in the first shadow map. When z' is greater than z0, it is determined that the sampling point is blocked.

[0090] Please refer to Figure 7, which shows a schematic diagram of the principle of determining the occlusion situation provided by an exemplary embodiment of the present application. In the image on the left side of the figure, the virtual object is a sphere, and the virtual light source is used as the light source camera to render the entire scene. During the rendering process, the depth information of the depth buffer is saved in the texture to generate a shadow map. In the image part on the right side of the figure, the shooting angle of the virtual camera is different from the illumination direction. The shooting space coordinates of the sampling voxel a and the sampling voxel b in the image generated by the shooting angle of the virtual camera are (x1, y1, z1) and (x2, y2, z2), respectively. When determining the occlusion situation of the sampling voxel a and the sampling voxel b, the coordinates of the sampling voxel a and the sampling voxel b are first converted into illumination space coordinates, corresponding to a'(x1', y1', z1') and b'(x2', y2', z2'), respectively. In the shadow map, pixel A and pixel B correspond to sampling voxel a and sampling voxel b respectively. Finally, the computer device compares the depth information stored in pixel A and pixel B at z1' and z2' respectively. When z1' is less than the depth information stored in pixel A, it is determined that sampling voxel a is not obscured. When z2' is greater than the depth information stored in pixel B, it is determined that sampling voxel b is obscured.

[0091] Based on the occlusion condition of voxels on the surface of the target virtual object, a first shadow is drawn on the surface of the target virtual object.

[0092] When a voxel on the surface of the target virtual object is blocked, the voxel is not illuminated by light, and a shadow needs to be drawn for the voxel.

[0093] In the case where a voxel on the surface of the target virtual object is not blocked, the voxel can be illuminated by light, and thus the voxel does not need to be shadowed.

[0094] Please refer to Figure 8 , which shows a schematic diagram of an occlusion situation shown in an exemplary embodiment of the present application. In the figure, a virtual light source 803 projects a virtual light to a target virtual object, wherein the hair of the target virtual object blocks the light, resulting in a first shadow area 801 on the forehead of the virtual object. The scarf carried by the target virtual object blocks the light, resulting in a second shadow area 802. In addition, under the current lighting direction, the body of the target virtual object blocks the light to produce a third shadow area 804, and the layers of the virtual object's clothes block the light to produce a fourth shadow area 805.

[0095] Similarly, in the process of drawing the second shadow, the computer device draws the second shadow on the surface of the target virtual object based on the second shadow map and the depth map of other environmental elements outside the target virtual object in the shooting direction of the virtual camera. This process is similar to the above-mentioned process of drawing the first shadow, and this embodiment will not be repeated here.

[0096] In a possible implementation, the object-associated element corresponding to the target virtual object may be transparent to light, that is, the object-associated element may have a certain degree of transparency. When light is transparent, the light will not be blocked, and no shadow will be generated on the target virtual object. The computer device may draw a first shadow on the surface of the target virtual object according to the transparency of the object-associated element and the occlusion of the surface of the target virtual object.

[0097] First, the transparency information of the object-associated element corresponding to the target virtual object is obtained, wherein the transparency information is used to represent the transparency of the object-associated element.

[0098] Optionally, the computer device requests the server to obtain transparency information of the object-associated element. The transparency information represents that the lower the transparency of the object-associated element, the worse the light transmittance of the object-associated element, and the higher the possibility of generating shadows. The transparency information represents that the higher the transparency of the object-associated element, the stronger the light transmittance of the object-associated element, and the lower the possibility of generating shadows.

[0099] Subsequently, based on the occlusion condition of the voxels on the surface of the target virtual object and the transparency information of the associated element of the object to which the voxels belong, a first shadow is drawn on the surface of the target virtual object.

[0100] When there is occlusion of voxels on the surface of the target virtual object, the light transmittance of the object-associated element can be determined based on the transparency information of the object-associated element, thereby determining whether a shadow will be generated at the occluded voxel.

[0101] Optionally, whether to draw shadows is determined based on a transparency threshold.

[0102] There are a first voxel and a second voxel in the target virtual object surface voxels. When the occlusion condition indicates that the first voxel occludes the second voxel and the transparency information indicates that the transparency of the first voxel is lower than a transparency threshold, a first shadow generated by the first voxel is drawn on the second voxel.

[0103] When the occlusion condition indicates that the first voxel occludes the second voxel, and the transparency information indicates that the transparency of the first voxel is higher than a transparency threshold, the first shadow generated by the first voxel is not drawn on the second voxel.

[0104] To a certain extent, the transparency threshold can represent the threshold of the degree of occlusion of the first voxel to the light. When the occlusion situation indicates that the first voxel occludes the second voxel, and the degree of occlusion of the first voxel to the light is higher than the occlusion threshold, it is determined that the second voxel cannot be illuminated by the light at all, and the first shadow generated by the first voxel is drawn on the second voxel. When the occlusion situation indicates that the first voxel occludes the second voxel, and the degree of occlusion of the first voxel to the light is lower than the occlusion threshold, it is determined that the second voxel can be illuminated by the light, and the first voxel will not generate a shadow on the second voxel.

[0105] Optionally, when the occlusion condition indicates that the first voxel occludes the second voxel, a first shadow generated by the first voxel is drawn on the second voxel based on transparency information corresponding to the first voxel.

[0106] The coloring degree of the first shadow generated by the first voxel drawn on the second voxel is negatively correlated with the transparency of the first voxel. That is, when the occlusion situation indicates that the first voxel occludes the second voxel, the higher the transparency of the first voxel, the lower the coloring degree of the first shadow drawn on the second voxel, that is, the lighter the first shadow generated. When the occlusion situation indicates that the first voxel occludes the second voxel, the lower the transparency of the first voxel, the higher the coloring degree of the first shadow drawn on the second voxel, that is, the darker the first shadow generated.

[0107] For illustration, please refer to Fig. 9 , which shows an effect diagram of shadow drawing based on transparency provided by an exemplary embodiment of the present application. The left side is a schematic diagram of the shadow generated by the virtual object occluding the surface of the target virtual object without considering the transparency, and the right side is a schematic diagram of the shadow drawn on the surface of the target virtual object based on the occlusion situation and transparency information in an embodiment of the present application. When the transparency of the first object-associated element 901 that generates the occlusion is high, the coloring degree of the generated first shadow area 902 is lighter.

[0108] In another possible implementation, there is a third voxel on the surface of the target virtual object with the first shadow and the second shadow drawn thereon, then when the third voxel is drawn with the first shadow and the second shadow, the shading degree of the shadow drawn on the third voxel is the sum of the shading degree of the first shadow and the shading degree of the second shadow. For example, there is a third voxel with the first shadow drawn thereon, the shading degree of the first shadow is 0.3, and there is a third voxel with the second shadow drawn thereon, the shading degree of the second shadow is 0.5, then the shading area of ​​the shadow at the third voxel is 0.8.

[0109] In the embodiment of the present application, the computer device draws the first shadow and the second shadow on the surface of the target virtual object according to the depth of the target virtual object compared to the virtual light source and the depth map of the shooting direction of the virtual camera, which can enhance the shadow quality of the surface of the target virtual object. In addition, whether to draw a shadow or determine the degree of coloring of the shadow is determined according to the transparency information of the voxel causing the occlusion, and the corresponding shadow drawing is performed according to the transparency of the semi-transparent clothing worn by the target virtual object, so that the shadow on the surface of the target virtual object is more realistic and vivid, and the shadow performance of the target virtual object in the game scene is improved.

[0110] In a possible implementation, when the computer device performs shadow drawing, it also uses a shadow map with a higher resolution for other environmental elements within a certain range of the target virtual object, so as to draw a third shadow and a second shadow with a higher shadow quality on the surface of the environmental element through the shadow map with a higher resolution and the second shadow map. The specific process is as follows:

[0111] Step 1: determine the target environmental elements within the target range, where the target range is centered on the target virtual object.

[0112] Optionally, a distance threshold is set in the computer device. When drawing shadows, the computer device and the environmental element information in the current virtual environment determine the distance between different environmental elements and the target virtual object. When the distance is less than the distance threshold, it is determined that the environmental element is a target environmental element within the target range.

[0113] The environmental element information is used to represent the type, attribute, position coordinates and other information of the environmental elements existing in the virtual environment. The distance between the environmental element and the target virtual object may be a Euclidean distance.

[0114] Optionally, since the position of the target virtual object may be different in different frames, the target environment elements within the target range need to be re-determined before shadow drawing in each frame.

[0115] Optionally, the target range may be a plane range, ie, target environment elements on the ground of the virtual environment and within the target range, or may be target environment elements within the target range in three-dimensional space.

[0116] Step 2: Generate a third shadow map based on the depth of the target environment element relative to the virtual light source in the illumination direction, wherein the resolution of the third shadow map is higher than the resolution of the second shadow map, and the resolution of the third shadow map is lower than or equal to the resolution of the first shadow map.

[0117] Optionally, each pixel in the third shadow map records the nearest depth within the target range.

[0118] The specific implementation of this step can refer to the above step 501, and this embodiment will not be described in detail here.

[0119] Step three: draw a third shadow on the surface of the target environment element based on the third shadow map, and the shadow quality of the third shadow is higher than the shadow quality of the second shadow map.

[0120] The computer device draws a third shadow on the surface of the target environment element based on the third shadow map and the depth map of the target environment element in the shooting direction of the virtual camera.

[0121] After the third shadow is drawn on the surface of the target environment element, the shadow of the target environment element is composed of the second shadow and the third shadow, and the shadow of the target virtual object is composed of the first shadow, the second shadow and the third shadow.

[0122] The specific implementation of this step can refer to the above step 502, and this embodiment will not be described in detail here.

[0123] In the embodiment of the present application, a third shadow is drawn on the surface of a target environmental element within a certain range around the virtual object based on a third shadow map, so that the target environmental elements within a certain range of the target virtual object can also use a higher resolution shadow map for shadow drawing, thereby ensuring that both the environmental elements around the target virtual object and the surface of the target virtual object have shadows with higher shadow quality.

[0124] In another possible implementation, the target virtual object is not fixed, and the target virtual object may be determined in any one of the following two ways.

[0125] 1. Determine the virtual object that is actively controlled in the virtual environment as the target virtual object.

[0126] Optionally, a client that provides a shadow drawing function for a virtual object is installed in the computer device, and the client is logged in with a user account, and the user account corresponds to one or more virtual objects. The user can control one or more virtual objects to move in the virtual environment by logging in to the client with the user account, and the one or more virtual objects are the actively controlled virtual objects. The appearance of the actively controlled virtual object may be changed according to the user settings.

[0127] Usually, the virtual camera is located around the actively controlled virtual object and moves with the actively controlled virtual object. In the picture taken by the virtual camera, the actively controlled virtual object usually occupies the main position. Therefore, the actively controlled virtual object in the virtual environment can be considered to be the target virtual object.

[0128] Optionally, when the computer device detects that the client is started, it obtains the virtual object actively controlled by the user account that has logged in to the client and determines it as the target virtual object.

[0129] Optionally, the computer device may send a request to a server corresponding to the client to obtain a virtual object actively controlled by a user account that has logged in to the client.

[0130] 2. In response to a selection operation on a virtual object in the virtual environment, the selected virtual object is determined as a target virtual object.

[0131] In a virtual environment, there may be virtual objects, and the user may select different virtual objects to view their information or control them. After the user selects a virtual object, the computer device determines the selected virtual object as the target virtual object. After the target virtual object is determined, the shadow of the surface of the target virtual object is drawn based on the first shadow map and the second shadow map.

[0132] Optionally, the selection operation may be a click operation, a slide operation, a long press operation, a pressing operation, etc., which is not limited in this embodiment.

[0133] In the embodiment of the present application, two methods for determining the target virtual object are provided. Automatically determining the actively controlled virtual object as the target virtual object is conducive to the target virtual object, which conforms to the user's observation habits of the virtual environment and improves the user's visual experience. Determining the virtual object selected by the user as the target virtual object enables the user to enhance the shadow drawing effect on the surface of the virtual object when the user selects different virtual objects, which is conducive to improving the user's viewing experience.

[0134] In one possible implementation, it may be necessary to perform more detailed shadow drawing on a certain voxel area of ​​the target virtual object. For example, the face of the target virtual object is located at the center of the image captured by the virtual camera and often occupies the user's visual center. In this case, the face of the target virtual object can be shadow drawn using a higher resolution shadow map to achieve a more detailed shadow drawing effect.

[0135] Therefore, for a target virtual object, there may be multiple corresponding first shadow maps, the resolutions of the multiple first shadow maps are different, and different first shadow maps correspond to different voxel areas on the surface of the target virtual object.

[0136] Optionally, the computer device determines target resolutions corresponding to different voxel regions based on shadow quality requirements of different voxel regions, and then generates first shadow maps corresponding to different voxel regions of the target virtual object based on the target resolutions corresponding to the respective voxel regions.

[0137] The shadow quality requirement of the voxel area is positively correlated with the target resolution corresponding to the voxel area, that is, the higher the shadow quality requirement of the voxel area, the higher the target resolution corresponding to the voxel area needs to be; the lower the shadow quality requirement of the voxel area, the lower the target resolution corresponding to the voxel area can be.

[0138] Optionally, during the development phase, shadow drawing is performed based on shadow maps of different resolutions to obtain the quality of the drawn shadows, thereby determining the correspondence between different shadow quality requirements and target resolutions, and storing the correspondence in a server.

[0139] When generating the first shadow map corresponding to different voxel areas of the target virtual object, the voxel area is sampled in the lighting direction according to the target resolution to obtain the depth of the target virtual object relative to the virtual light source in the lighting direction, and the first shadow map corresponding to the voxel area is generated.

[0140] After generating first shadow maps corresponding to different voxel regions, first shadows are drawn respectively in different voxel regions on the surface of the target virtual object based on the first shadow maps and depth maps of different voxel regions in the shooting direction of the virtual camera.

[0141] Indicative, such as Fig.10 As shown, it shows a schematic diagram of different voxel regions provided by an exemplary embodiment of the present application. In the figure, the shadow quality requirement of the first voxel region 1001 (face) is the highest, so the resolution of the first shadow map corresponding to the face of the target virtual object is the highest, and the shadow quality of the drawn first shadow region 1003 and the second shadow region 1004 is the highest. The shadow quality requirement of the second voxel region 1002 (upper limb part) is lower than that of the first voxel region 1001, so the resolution of the first shadow map corresponding to the upper limb part of the target virtual object is lower than the resolution of the first shadow map corresponding to the face of the target virtual object, and the shadow quality of the drawn third shadow region 1005 and the fourth shadow region 1006 is lower than that of the first shadow region 1003 and the second shadow region 1004.

[0142] In an embodiment of the present application, first shadow maps with different resolutions are used to draw shadows for different voxel areas on the surface of the target virtual object. A first shadow map with a higher resolution can be used in voxel areas on the surface of the target virtual object with high shadow quality requirements, thereby achieving the effect of enhancing the shadow quality of specific voxel areas.

[0143] In some embodiments, different virtual objects may interact with each other in a virtual environment. During the interaction, the interacting virtual objects may block the light projected toward the target virtual object, thereby generating a shadow on the surface of the target virtual object.

[0144] In the case where there is an interactive virtual object interacting with the target virtual object in the virtual environment, the computer device generates a fourth shadow map corresponding to the interactive virtual object.

[0145] The fourth shadow map is a shadow map including the interactive virtual object, and a resolution of the fourth shadow map is higher than a resolution of the second shadow map.

[0146] Optionally, when there is an interactive virtual object interacting with a target virtual object in a virtual environment, a fourth shadow map is generated based on the depth of the interactive virtual object relative to the virtual light source in the illumination direction. In order to make the shadow drawn on the surface of the target virtual object more detailed, when generating the fourth shadow map, more sampling voxels may be sampled on the surface of the interactive virtual object to obtain a fourth shadow map with a higher resolution.

[0147] After generating the fourth shadow map, the computer device draws a fourth shadow on the surface of the target virtual object based on the fourth shadow map, and the target virtual object surface shadow is composed of the first shadow, the second shadow and the fourth shadow.

[0148] Since the resolution of the fourth shadow map is higher than that of the second shadow map, the shadow quality of the fourth shadow is higher than that of the second shadow.

[0149] Optionally, the computer device draws a fifth shadow on the surface of the interactive virtual object based on the first shadow map, the shadow quality of the fifth shadow is higher than the shadow quality of the second shadow, the fifth shadow is the shadow caused by the target virtual object occluding the interactive virtual object, then the shadow on the surface of the interactive virtual object is composed of the second shadow and the fifth shadow.

[0150] In an embodiment of the present application, when there is an interactive virtual object that interacts with the target virtual object, a fourth shadow map including the interactive virtual object is generated, and a shadow is drawn on the surface of the virtual object based on the map, which is conducive to depicting the shadow details of the surface of the target virtual object and enhancing the shadow effect of the surface of the target virtual object.

[0151] Please refer to Fig.11, which shows a flow chart of the shadow drawing process of the target virtual object provided by an exemplary embodiment of the present application. First, the computer device needs to determine the target virtual object that needs to enhance the shadow effect. Subsequently, based on the depth of the target virtual object relative to the virtual light source in the lighting direction, a high-resolution first shadow map is generated, and based on the depth of other environmental elements in the virtual environment except the target virtual object relative to the virtual light source in the lighting direction, a second shadow map containing other environmental elements except the target virtual object is generated. Subsequently, the first shadow generated by the object-associated element on the surface of the target virtual object is rendered based on the first shadow map, and the second shadow generated by the occlusion of other environmental elements in the virtual environment is rendered based on the second shadow map, so as to complete the complete shadow rendering of the target virtual object surface.

[0152] In some embodiments, when developers build virtual objects during the application development phase, they need to start the application to view the shadow drawing effect of the virtual object, which is a cumbersome process. In the embodiment of the present application, a method is provided to enable developers to view the performance effect of the character shadow under different lighting directions during the process of making virtual object resources. The shadow performance effect of the virtual object can be viewed without starting the application, which effectively improves the efficiency of shadow program development.

[0153] Please refer to Fig.12 , which shows a schematic diagram of a virtual object creation interface provided by an exemplary embodiment of the present application. In the figure, developers can change the control of the lighting direction (time of the day) during the development process to view the shadow effect caused by the clothing worn by the virtual object at different times of the day (i.e. different lighting directions).

[0154] Fig.13 is a structural block diagram of a shadow drawing device provided by an exemplary embodiment of the present application. Fig.13 As shown, the device includes the following structure.

[0155] A determination module 1301 is used to determine a target virtual object in a virtual environment;

[0156] A generating module 1302, configured to generate a first shadow map and a second shadow map corresponding to the target virtual object, wherein the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map;

[0157] The drawing module 1303 is used to draw a first shadow on the surface of the target virtual object based on the first shadow map, and to draw a second shadow on the surface of the target virtual object based on the second shadow map, wherein the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

[0158] Optionally, the generating module 1302 is used to generate the first shadow map based on the depth of the target virtual object relative to the virtual light source in the lighting direction; and to generate the second shadow map based on the depth of other environmental elements outside the target virtual object relative to the virtual light source in the lighting direction; the drawing module 1303 is used to draw the first shadow on the surface of the target virtual object based on the first shadow map and the depth map of the target virtual object in the shooting direction of the virtual camera; and to draw the second shadow on the surface of the target virtual object based on the second shadow map and the depth map of other environmental elements outside the target virtual object in the shooting direction of the virtual camera.

[0159] Optionally, the drawing module 1303 is used to:

[0160] Determine, based on the first shadow map and the depth map, occlusion conditions of different voxels on the surface of the target virtual object;

[0161] Based on the occlusion condition of the voxels on the surface of the target virtual object, the first shadow is drawn on the surface of the target virtual object.

[0162] Optionally, the drawing module 1303 is used to:

[0163] Obtaining transparency information of an object-associated element corresponding to the target virtual object, wherein the transparency information is used to characterize the transparency of the object-associated element, wherein the object-associated element refers to an element that affects the shadow drawing of the surface of the target virtual object;

[0164] Based on the occlusion condition of the voxels on the surface of the target virtual object and the transparency information of the associated element of the object to which the voxels belong, the first shadow is drawn on the surface of the target virtual object.

[0165] Optionally, the drawing module 1303 is used to:

[0166] For a first voxel and a second voxel among the voxels, when the occlusion condition indicates that the first voxel occludes the second voxel and the transparency information indicates that the transparency of the first voxel is lower than a transparency threshold, drawing the first shadow generated by the first voxel on the second voxel;

[0167] When the occlusion condition indicates that the first voxel occludes the second voxel and the transparency information indicates that the transparency of the first voxel is higher than the transparency threshold, the first shadow generated by the first voxel is not drawn on the second voxel.

[0168] Optionally, the drawing module 1303 is used to:

[0169] When the occlusion situation indicates that a first voxel occludes a second voxel, the first shadow generated by the first voxel is drawn on the second voxel based on the transparency information corresponding to the first voxel, and the coloring degree of the first shadow generated by the first voxel drawn on the second voxel is negatively correlated with the transparency of the first voxel.

[0170] Optionally, the generating module 1302 is used to:

[0171] The first shadow map is generated based on the depth of the target virtual object relative to the virtual light source in the illumination direction and the transparency information of the voxels on the surface of the target virtual object, wherein, when the transparency indicated by the transparency information of the voxels on the surface of the target virtual object is lower than a transparency threshold, the first shadow map includes pixels corresponding to the voxels; and when the transparency indicated by the transparency information of the voxels on the surface of the target virtual object is higher than the transparency threshold, the first shadow map includes pixels corresponding to the voxels.

[0172] Optionally, when there is a third voxel on the surface of the target virtual object and the first shadow and the second shadow are drawn on the third voxel, the shading degree of the shadow drawn on the third voxel is the sum of the shading degree of the first shadow and the shading degree of the second shadow.

[0173] Optionally, the determining module 1301 is further used to determine a target environmental element within a target range, wherein the target range is centered on the target virtual object;

[0174] The generating module 1302 is further configured to generate a third shadow map based on the depth of the target environment element relative to the virtual light source in the illumination direction, wherein the resolution of the third shadow map is higher than the resolution of the second shadow map, and the resolution of the third shadow map is lower than or equal to the resolution of the first shadow map;

[0175] The drawing module 1303 is also used to draw a third shadow on the surface of the target environmental element based on the third shadow map, and the shadow quality of the third shadow is higher than the shadow quality of the second shadow map, wherein the shadow of the target environmental element is composed of the second shadow and the third shadow, and the shadow of the target virtual object is composed of the first shadow, the second shadow and the third shadow.

[0176] Optionally, the generating module 1302 is used to:

[0177] Based on the shadow quality requirements of different voxel areas, determine the target resolutions corresponding to different voxel areas;

[0178] Based on the target resolution corresponding to each voxel area, the first shadow map corresponding to different voxel areas of the target virtual object is generated.

[0179] Optionally, the generating module 1302 is further configured to generate a fourth shadow map corresponding to the interactive virtual object when there is an interactive virtual object interacting with the target virtual object in the virtual environment, wherein the fourth shadow map is a shadow map including the interactive virtual object, and a resolution of the fourth shadow map is higher than a resolution of the second shadow map;

[0180] The drawing module 1303 is further configured to draw a fourth shadow on the surface of the target virtual object based on the fourth shadow map, wherein the shadow quality of the fourth shadow is higher than the shadow quality of the second shadow.

[0181] To summarize, in the embodiment of the present application, during the shadow drawing process, the target virtual object in the virtual environment is first determined, and then a first shadow map corresponding to the surface of the target virtual object and a second shadow map of other environmental elements in the virtual environment except the target virtual object are generated. Subsequently, a first shadow with high shadow quality is drawn on the surface of the virtual object based on the high-resolution first shadow map, and a second map with lower shadow quality is drawn based on the second shadow map, thereby enhancing the shadow performance of the target virtual object and being able to draw the shadow effect of the target virtual object's clothing, etc. on the surface of the target virtual object.

[0182] Please refer to Fig.14, which shows a schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application, and the computer device can be implemented as a terminal or a server in the above-mentioned embodiment. Specifically, the computer device 1400 includes a central processing unit (CPU) 1401, a system memory 1404 including a random access memory 1402 and a read-only memory 1403, and a system bus 1405 connecting the system memory 1404 and the central processing unit 1401. The computer device 1400 also includes a basic input / output system (I / O system) 1406 that helps to transmit information between various devices in the computer, and a large-capacity storage device 1407 for storing an operating system 1413, an application program 1414 and other program modules 1415.

[0183] In some embodiments, the basic input / output system 1406 includes a display 1408 for displaying information and an input device 1409 such as a mouse and a keyboard for user inputting information. The display 1408 and the input device 1409 are connected to the central processing unit 1401 through an input / output controller 1410 connected to the system bus 1405. The basic input / output system 1406 may also include an input / output controller 1410 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1410 also provides output to a display screen, a printer, or other types of output devices.

[0184] The mass storage device 1407 is connected to the central processing unit 1401 through a mass storage controller (not shown) connected to the system bus 1405. The mass storage device 1407 and its associated computer readable media provide non-volatile storage for the computer device 1400. That is, the mass storage device 1407 may include a computer readable medium (not shown) such as a hard disk or drive.

[0185] Without loss of generality, the computer readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer readable instructions, data structures, program modules or other data. Computer storage media include random access memory (Random Access Memory, RAM), read-only memory (Read Only Memory, ROM), flash memory or other solid-state storage technology, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), digital versatile disc (Digital Versatile Disc, DVD) or other optical storage, cassettes, magnetic tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 1404 and mass storage device 1407 can be collectively referred to as memory.

[0186] The memory stores one or more programs, and the one or more programs are configured to be executed by one or more central processing units 1401. The one or more programs contain instructions for implementing the above-mentioned methods. The central processing unit 1401 executes the one or more programs to implement the methods provided by the above-mentioned various method embodiments.

[0187] According to various embodiments of the present application, the computer device 1400 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 1400 can be connected to the network 1412 through the network interface unit 1411 connected to the system bus 1405, or the network interface unit 1411 can be used to connect to other types of networks or remote computer systems (not shown).

[0188] The memory also includes one or more programs, which are stored in the memory and include steps executed by a computer device in the method provided in the embodiment of the present application.

[0189] An embodiment of the present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the shadow drawing method described in any of the above embodiments.

[0190] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the shadow drawing method provided in the above aspect.

[0191] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, which can be a computer-readable storage medium contained in the memory in the above embodiments; or a computer-readable storage medium that exists independently and is not installed in the terminal. The computer-readable storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the processor to implement the shadow drawing method described in any of the above method embodiments.

[0192] Optionally, the computer readable storage medium may include: ROM, RAM, solid state drives (SSD) or optical disks, etc. Among them, RAM may include resistance random access memory (ReRAM) and dynamic random access memory (DRAM). The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0193] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0194] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0195] Moreover, before collecting relevant data of the user and during the process of collecting relevant data of the user, the present application may display a prompt interface, pop-up window or output voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that the present application starts executing the relevant steps of obtaining relevant data of the user only after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of the user are terminated, that is, the relevant data of the user is not obtained.

[0196] It should be understood that the "multiple" mentioned in this article refers to two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated with each other are in an "or" relationship. And the "first", "second", etc. mentioned in this article are used to distinguish similar objects, and are not used to limit a specific order or sequence. In addition, the step numbers described in this article only exemplify a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application do not limit this.

[0197] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A shadow drawing method, characterized in that: The method comprises: determining a target virtual object in a virtual environment; Generate a first shadow map and a second shadow map corresponding to the target virtual object, wherein the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map; A first shadow is drawn on the surface of the target virtual object based on the first shadow map, and a second shadow is drawn on the surface of the target virtual object based on the second shadow map, wherein the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

2. The method according to claim 1, characterized in that The generating a first shadow map and a second shadow map corresponding to the target virtual object includes: Generate the first shadow map based on the depth of the target virtual object relative to the virtual light source in the illumination direction; Generate the second shadow map based on the depth of other environmental elements outside the target virtual object relative to the virtual light source in the illumination direction; Drawing a first shadow on the surface of the target virtual object based on the first shadow map, and drawing a second shadow on the surface of the target virtual object based on the second shadow map, comprises: Drawing the first shadow on the surface of the target virtual object based on the first shadow map and the depth map of the target virtual object in the shooting direction of the virtual camera; Based on the second shadow map and the depth map of other environmental elements outside the target virtual object in the shooting direction of the virtual camera, the second shadow is drawn on the surface of the target virtual object.

3. The method according to claim 2, characterized in that Drawing the first shadow on the surface of the target virtual object based on the first shadow map and the depth map of the target virtual object in the shooting direction of the virtual camera includes: Determine, based on the first shadow map and the depth map, occlusion conditions of different voxels on the surface of the target virtual object; Based on the occlusion condition of the voxels on the surface of the target virtual object, the first shadow is drawn on the surface of the target virtual object.

4. The method according to claim 3, characterized in that Drawing the first shadow on the surface of the target virtual object based on the occlusion condition of the voxels on the surface of the target virtual object includes: Obtaining transparency information of an object-associated element corresponding to the target virtual object, where the transparency information is used to characterize the transparency of the object-associated element, wherein the object-associated element refers to an element that affects the shadow drawing of the surface of the target virtual object; Based on the occlusion condition of the voxels on the surface of the target virtual object and the transparency information of the associated element of the object to which the voxels belong, the first shadow is drawn on the surface of the target virtual object.

5. The method according to claim 4, characterized in that Drawing the first shadow on the surface of the target virtual object based on the occlusion condition of the voxel on the surface of the target virtual object and the transparency information of the element associated with the object to which the voxel belongs includes: For a first voxel and a second voxel among the voxels, when the occlusion condition indicates that the first voxel occludes the second voxel and the transparency information indicates that the transparency of the first voxel is lower than a transparency threshold, drawing the first shadow generated by the first voxel on the second voxel; When the occlusion condition indicates that the first voxel occludes the second voxel and the transparency information indicates that the transparency of the first voxel is higher than the transparency threshold, the first shadow generated by the first voxel is not drawn on the second voxel.

6. The method according to claim 4, characterized in that Drawing the first shadow on the surface of the target virtual object based on the occlusion condition of the voxel on the surface of the target virtual object and the transparency information of the element associated with the object to which the voxel belongs includes: When the occlusion situation indicates that a first voxel occludes a second voxel, the first shadow generated by the first voxel is drawn on the second voxel based on the transparency information corresponding to the first voxel, and the coloring degree of the first shadow generated by the first voxel drawn on the second voxel is negatively correlated with the transparency of the first voxel.

7. The method according to claim 2, characterized in that The generating the first shadow map based on the depth of the target virtual object relative to the virtual light source in the illumination direction includes: The first shadow map is generated based on the depth of the target virtual object relative to the virtual light source in the illumination direction and the transparency information of the voxels on the surface of the target virtual object, wherein, when the transparency indicated by the transparency information of the voxels on the surface of the target virtual object is lower than a transparency threshold, the first shadow map includes pixels corresponding to the voxels; and when the transparency indicated by the transparency information of the voxels on the surface of the target virtual object is higher than the transparency threshold, the first shadow map includes pixels corresponding to the voxels.

8. The method according to claim 1, characterized in that When there is a third voxel on the surface of the target virtual object and the first shadow and the second shadow are drawn on the third voxel, the coloring degree of the shadow drawn on the third voxel is the sum of the coloring degree of the first shadow and the coloring degree of the second shadow.

9. The method according to claim 1, characterized in that: The method further comprises: Determine a target environmental element within a target range, wherein the target range is centered on the target virtual object; Generate a third shadow map based on the depth of the target environment element relative to the virtual light source in the illumination direction, wherein the resolution of the third shadow map is higher than the resolution of the second shadow map, and the resolution of the third shadow map is lower than or equal to the resolution of the first shadow map; A third shadow is drawn on the surface of the target environmental element based on the third shadow map, wherein a shadow quality of the third shadow is higher than a shadow quality of the second shadow map, wherein the shadow of the target environmental element is composed of the second shadow and the third shadow, and the shadow of the target virtual object is composed of the first shadow, the second shadow and the third shadow.

10. The method according to claim 1, characterized in that The generating a first shadow map corresponding to the target virtual object includes: Based on the shadow quality requirements of different voxel areas, determine the target resolutions corresponding to different voxel areas; Based on the target resolution corresponding to each voxel area, the first shadow map corresponding to different voxel areas of the target virtual object is generated.

11. The method according to claim 1, characterized in that: The method further comprises: In a case where an interactive virtual object interacts with the target virtual object in the virtual environment, generating a fourth shadow map corresponding to the interactive virtual object, wherein the fourth shadow map is a shadow map including the interactive virtual object, and a resolution of the fourth shadow map is higher than a resolution of the second shadow map; A fourth shadow is drawn on the surface of the target virtual object based on the fourth shadow map, and a shadow quality of the fourth shadow is higher than a shadow quality of the second shadow.

12. A shadow drawing device, characterized in that: The device comprises: A determination module, used for determining a target virtual object in a virtual environment; a generating module, configured to generate a first shadow map and a second shadow map corresponding to the target virtual object, wherein the first shadow map is a shadow map including the target virtual object, and the second shadow map is a shadow map including other environmental elements in the virtual environment except the target virtual object, and the resolution of the first shadow map is higher than the resolution of the second shadow map; A drawing module is used to draw a first shadow on the surface of the target virtual object based on the first shadow map, and to draw a second shadow on the surface of the target virtual object based on the second shadow map, wherein the shadow quality of the first shadow is higher than the shadow quality of the second shadow, and the shadow of the target virtual object is composed of the first shadow and the second shadow.

13. A computer device, characterized in that: The computer device includes a processor and a memory, wherein at least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the shadow drawing method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The readable storage medium stores at least one program, and the at least one program is loaded and executed by a processor to implement the shadow drawing method according to any one of claims 1 to 11.

15. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the shadow drawing method as described in any one of claims 1 to 11.