Dynamic Shadow Generation Method, Device, Electronic Device and Storage Medium

By generating multiple geometric models and shadow functions, the problem of insufficient dynamic shadowing effect on mobile devices is solved, and the simulation of multiple light types is realized, which reduces hardware resource consumption and improves the authenticity and complexity of three-dimensional scenes.

CN114399572BActive Publication Date: 2025-07-29NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111590964.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-07-29
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

In three-dimensional projects, especially on mobile devices, it is difficult to effectively simulate complex dynamic shadow effects, the hardware resource consumption is high, and it only supports a single light source type, which cannot meet the needs of multiple lighting environments.

Method used

By obtaining the rendering target map of the target virtual object, multiple geometric models are generated, and shadow functions are determined based on the light source information, combined with the shadow functions to generate dynamic shadows, increase the light type and number, and reduce hardware resource consumption.

Benefits of technology

It realizes the dynamic shadow effect of simulating multiple lights on mobile devices, reduces hardware resource consumption, improves simulation efficiency, supports multiple light source types, and enhances the authenticity and complexity of the scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114399572B_ABST
    Figure CN114399572B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of three-dimensional image technology, and discloses a method, device, electronic device and storage medium for generating dynamic shadows, which are used to simulate the dynamic shadows of multiple dynamic lights, increase the types and quantities of supported lights, reduce the hardware resources consumed by simulating multiple dynamic shadows, and improve the simulation efficiency. The method includes: obtaining multiple rendering target texture maps of a target virtual object, where the rendering target texture maps are used to indicate the slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data; generating multiple geometry models corresponding to the target virtual object according to the multiple rendering target texture maps; determining a shadow function corresponding to the target virtual object based on the multiple geometry models and preset light source information, where the preset light source information includes light source types and at least one light source direction; and generating dynamic shadows based on the shadow function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of three-dimensional animation technology, and particularly to a method, device, electronic device and storage medium for generating dynamic shadows. Background Art

[0002] In most current three-dimensional projects, the dynamic shadows of scene objects mainly come from various types of dynamic lights placed. In order to show complex dynamic shadow effects, it is necessary to increase the number of dynamic lights, but the hardware resources consumed by rendering also increase exponentially.

[0003] With the application of mobile devices in the three-dimensional field, such complex dynamic shadow scenes consume too much hardware resources on mobile devices, and mobile devices cannot meet the hardware requirements. Moreover, mobile devices currently only support one dynamic directional light and cannot generate the required complex dynamic shadows. Summary of the Invention

[0004] The present invention provides a method, device, electronic device and storage medium for generating dynamic shadows, which are used to simulate the dynamic shadows of multiple lights, increase the supported light types and quantities, reduce the hardware resources consumed by simulating multiple dynamic shadows, and improve the simulation efficiency.

[0005] In a first aspect of an embodiment of the present invention, a method for generating dynamic shadows is provided, including: obtaining a plurality of rendering target textures of a target virtual object, where the rendering target textures are used to indicate the slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data; generating a plurality of geometry models corresponding to the target virtual object according to the plurality of rendering target textures; determining a shadow function corresponding to the target virtual object based on the plurality of geometry models and preset light source information, where the preset light source information includes light source types and at least one light source direction; and generating dynamic shadows based on the shadow function.

[0006] In a feasible implementation manner, the determining a shadow function corresponding to the target virtual object based on the plurality of geometry models and preset light source information, where the preset light source information includes light source types and at least one light source direction, includes: determining a light source vector based on the light source type; determining an initial shadow area corresponding to the target virtual object according to the vertex positions corresponding to each geometry model and at least one light source direction; and generating a shadow function corresponding to the target virtual object according to the initial shadow area and the light source vector.

[0007] In a feasible implementation manner, determining the initial shadow region corresponding to the target virtual object according to the vertex positions corresponding to each geometric model and at least one light source direction includes: determining the radius information corresponding to each geometric model according to the vertex positions corresponding to each geometric model; determining multiple extended light source directions corresponding to the at least one light source direction on each geometric model according to the vertex positions and the corresponding radius information; and determining the intersection points of the multiple extended light source directions on a preset plane as shadow points, so as to obtain the initial shadow region corresponding to the target virtual object.

[0008] In a feasible implementation manner, generating a dynamic shadow based on the shadow function includes: calling the shadow function for calculation to obtain an initial shadow; adjusting the intensity of the initial shadow according to a preset shadow attenuation parameter to obtain the target shadow corresponding to the target virtual object; and using a preset mask to perform virtual object deduction on the target shadow to obtain the dynamic shadow of the target virtual object.

[0009] In a feasible implementation manner, before obtaining multiple render target textures of the target virtual object, the dynamic shadow generation method further includes: generating multiple render target textures of the target virtual object.

[0010] In a feasible implementation manner, generating multiple render target textures of the target virtual object includes: setting multiple virtual geometric bodies of the target virtual object; and generating multiple render target textures of the target virtual object according to the multiple virtual geometric bodies.

[0011] In a feasible implementation manner, setting multiple virtual geometric bodies of the target virtual object includes: determining multiple bones corresponding to the target virtual object; setting a bone slot corresponding to each bone in a bone tree, and generating a corresponding virtual geometric body according to the bone slot corresponding to each bone to obtain multiple virtual geometric bodies, where the bones corresponding to each virtual geometric body are different; and storing the radius information of each virtual geometric body into the scaling data of the corresponding bone slot.

[0012] In a feasible implementation manner, generating multiple render target textures of the target virtual object according to the multiple virtual geometric bodies includes: obtaining the slot information of each virtual geometric body in the multiple virtual geometric bodies to obtain multiple slot coordinates and corresponding multiple scaling data, where the scaling data is used to indicate the radius information of the virtual geometric body; and calling a preset rendering component to render each slot coordinate and the corresponding scaling data onto the corresponding render target texture to obtain multiple render target textures of the target virtual object, where the RGB channels of the render target texture are used to store the slot coordinates, and the A channel of the render target texture is used to store the radius information of the virtual geometric body.

[0013] In a feasible implementation manner, generating a plurality of geometric models corresponding to the target virtual object according to the plurality of rendered target texture maps includes: sampling and decoding the plurality of rendered target texture maps to obtain a plurality of slot coordinates and corresponding plurality of radius information; constructing a plurality of geometric models corresponding to the target virtual object according to the plurality of slot coordinates and the corresponding plurality of radius information.

[0014] In a feasible implementation manner, sampling and decoding the plurality of rendered target texture maps to obtain a plurality of slot coordinates and corresponding plurality of radius information includes: calculating identifiers corresponding to the plurality of rendered target texture maps to obtain a plurality of texture map identifiers; reading target pixel values of the rendered target texture maps corresponding to each texture map identifier to obtain at least two slot coordinates and corresponding radius information for each rendered target texture map.

[0015] In a feasible implementation manner, constructing a plurality of geometric models corresponding to the target virtual object according to the plurality of slot coordinates and the corresponding plurality of radius information includes: calling a preset formula to calculate based on at least two slot coordinates and corresponding radius information for each rendered target texture map to obtain geometric contour information corresponding to each rendered target texture map; generating a corresponding geometric model according to the geometric contour information corresponding to each rendered target texture map to obtain a plurality of geometric models of the target virtual object.

[0016] In a feasible implementation manner, after generating the dynamic shadow based on the shadow function, the dynamic shadow generation method further includes: setting the color of the dynamic shadow.

[0017] In a feasible implementation manner, after generating the dynamic shadow based on the shadow function, the dynamic shadow generation method further includes: obtaining the main light of the scene and generating a main shadow of the target virtual object based on the main light, and the main shadow does not overlap with the dynamic shadow.

[0018] A second aspect of the embodiments of the present invention provides a dynamic shadow generation device, including: a texture map acquisition module, configured to acquire a plurality of rendered target texture maps of a target virtual object, where the rendered target texture maps are used to indicate slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data; a geometric body generation module, configured to generate a plurality of geometric models corresponding to the target virtual object according to the plurality of rendered target texture maps; a shadow function determination module, configured to determine a shadow function corresponding to the target virtual object based on the plurality of geometric models and preset light source information, where the preset light source information includes a light source type and at least one light source direction; a shadow generation module, configured to generate a dynamic shadow based on the shadow function.

[0019] In a feasible implementation manner, the shadow function determination module includes: a light source vector determination unit for determining a light source vector based on the light source type; a shadow area determination unit for determining an initial shadow area corresponding to the target virtual object according to the vertex positions corresponding to each geometric model and at least one light source direction; and a function generation unit for generating a shadow function corresponding to the target virtual object according to the initial shadow area and the light source vector.

[0020] In a feasible implementation manner, the shadow area determination unit is specifically configured to: determine the radius information corresponding to each geometric model according to the vertex positions corresponding to each geometric model; determine multiple extended lines of the light source direction corresponding to the at least one light source direction on each geometric model according to the vertex positions and the corresponding radius information; and determine the intersection points of the multiple extended lines of the light source direction on a preset plane as the shadow points in the shadow area, so as to obtain the initial shadow area corresponding to the target virtual object.

[0021] In a feasible implementation manner, the shadow generation module is specifically configured to: call the shadow function for calculation to obtain an initial shadow; adjust the intensity of the initial shadow according to a preset shadow attenuation parameter to obtain a target shadow corresponding to the target virtual object; and use a preset mask to perform virtual object deduction on the target shadow to obtain the dynamic shadow of the target virtual object.

[0022] In a feasible implementation manner, the dynamic shadow generation device further includes: a texture generation module for generating multiple rendering target textures of the target virtual object.

[0023] In a feasible implementation manner, the texture generation module includes: a geometry setting unit for setting multiple virtual geometries of the target virtual object; and a texture generation unit for generating multiple rendering target textures of the target virtual object according to the multiple virtual geometries.

[0024] In a feasible implementation manner, the geometry setting unit is specifically configured to: determine multiple bones corresponding to the target virtual object; set a bone slot corresponding to each bone in the bone tree, and generate corresponding virtual geometries according to the bone slots corresponding to each bone to obtain multiple virtual geometries, where the bones corresponding to each virtual geometry are different; and store the radius information of each virtual geometry into the scaling data of the corresponding bone slot.

[0025] In a feasible implementation manner, the texture mapping generation unit is specifically configured to: obtain the slot information of each virtual geometric body among a plurality of virtual geometric bodies, so as to obtain a plurality of slot coordinates and corresponding plurality of scaling data, where the scaling data is used to indicate the radius information of the virtual geometric body; call a preset rendering component to render each slot coordinate and the corresponding scaling data onto a corresponding rendering target texture map, so as to obtain a plurality of rendering target texture maps of the target virtual object, where the RGB channels of the rendering target texture map are used to store the slot coordinates, and the A channel of the rendering target texture map is used to store the radius information of the virtual geometric body.

[0026] In a feasible implementation manner, the geometric body generation module includes: a sampling and decoding unit, configured to perform sampling and decoding on the plurality of rendering target texture maps to obtain a plurality of slot coordinates and corresponding plurality of radius information; a model construction unit, configured to construct a plurality of geometric body models corresponding to the target virtual object according to the plurality of slot coordinates and the corresponding plurality of radius information.

[0027] In a feasible implementation manner, the sampling and decoding unit is specifically configured to: calculate the identifiers corresponding to the plurality of rendering target texture maps to obtain a plurality of texture map identifiers; read the target pixel values of the rendering target texture maps corresponding to each texture map identifier to obtain at least two slot coordinates and corresponding radius information corresponding to each rendering target texture map.

[0028] In a feasible implementation manner, the model construction unit is specifically configured to: call a preset formula to calculate based on at least two slot coordinates and corresponding radius information corresponding to each rendering target texture map to obtain the geometric body contour information corresponding to each rendering target texture map; generate a corresponding geometric body model according to the geometric body contour information corresponding to each rendering target texture map to obtain a plurality of geometric body models of the target virtual object.

[0029] In a feasible implementation manner, the dynamic shadow generation device further includes: a color setting module, configured to set the color of the dynamic shadow.

[0030] In a feasible implementation manner, the dynamic shadow generation device further includes: a main light shadow generation module, configured to obtain the main light of the scene and generate a main shadow of the target virtual object based on the main light, where the main shadow does not overlap with the dynamic shadow.

[0031] A third aspect of the embodiments of the present invention provides an electronic device, including: a memory and at least one processor, where instructions are stored in the memory; the at least one processor calls the instructions in the memory so that the electronic device executes the above-mentioned dynamic shadow generation method.

[0032] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to execute the above-described dynamic shadow generation method.

[0033] In the technical solution provided by the embodiments of the present invention, multiple rendering target texture maps of a target virtual object are obtained. The rendering target texture maps are used to indicate the slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data. Multiple geometry models corresponding to the target virtual object are generated based on the multiple rendering target texture maps. A shadow function corresponding to the target virtual object is determined based on the multiple geometry models and preset light source information. The preset light source information includes a light source type and at least one light source direction. A dynamic shadow is generated based on the shadow function. In the embodiments of the present invention, geometry models are generated through the slot information carried in the rendering target texture maps of the target virtual object, and then the geometry models are combined with the light source information to determine the dynamic shadow area, and corresponding dynamic shadows are generated in the dynamic shadow area, simulating the dynamic shadows of multiple lights, increasing the types and quantities of supported lights, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a schematic diagram of an embodiment of the dynamic shadow generation method in the embodiments of the present invention;

[0035] Figure 2 It is a schematic diagram of another embodiment of the dynamic shadow generation method in the embodiments of the present invention;

[0036] Figure 3 It is a schematic diagram of the generation principle of the shadow in the embodiments of the present invention;

[0037] Figure 4 It is a schematic diagram of another embodiment of the dynamic shadow generation method in the embodiments of the present invention;

[0038] Figure 5 It is a schematic diagram of an embodiment of the dynamic shadow generation device in the embodiments of the present invention;

[0039] Figure 6 It is a schematic diagram of an embodiment of the electronic device in the embodiments of the present invention. DETAILED DESCRIPTION

[0040] The present invention provides a dynamic shadow generation method, device, electronic device, and storage medium for simulating the dynamic shadows of multiple lights, increasing the types and quantities of supported lights, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency.

[0041] It can be understood that the present invention can be applied to electronic devices. By way of example and not limitation, the electronic device can be a server or a terminal. This application will be described by taking the terminal as an example.

[0042] In the description and claims of the present invention and the above-mentioned drawings, the terms "first", "second", "third", "fourth", etc. (if any) are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0043] The existing solution uses the UE4 engine to add a capsule to the character and project dynamic shadows. The number of shadows depends on the number of dynamic lights, which can only solve part of the problem of insufficient dynamic shadows. However, the existing solution still has the following defects: 1. In the face of a complex and multi-light environment, especially on mobile devices, it is impossible to simulate the shadow effect of multiple dynamic lights; 2. High hardware requirements: The capsule shadows provided by the engine require DirectX11 to be equipped, and they cannot be used on devices without DirectX11; 3. Single type of supported light source: It can only simulate parallel light shadows and cannot simulate point light and spotlight shadows; 4. Single type of supported geometry: It can only project capsule-type shadows and cannot project shadows of other geometry types.

[0044] Please refer to Figure 1 , a flowchart of a method for generating dynamic shadows provided by an embodiment of the present invention, specifically including:

[0045] 101. Obtain multiple render target textures of a target virtual object. The render target texture is used to indicate the slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data.

[0046] It should be noted that the terminal will collect multiple virtual objects in advance. Specifically: first, the array situation of the stored skeletal model will be stored, then the texture data of the socket positions stored in the slots will be cleared, and then each object in the scene will be searched cyclically to determine whether the current object is a virtual object. If it is a virtual object, the virtual object will be stored in the corresponding array. Among them, the virtual object can be a game character, such as a biological object such as a person or a pet, or a non-biological object such as a tank or a firearm. Specifically, it is not limited here.

[0047] It can be understood that to determine whether an object is a virtual object, it is mainly by judging whether there is a specific socket on the object. When there is a special socket position on the object, it can be determined that the object belongs to a virtual object and can be used for projection.

[0048] It should be noted that in the field of computer communication, socket is usually translated as "socket", while in this embodiment and subsequent embodiments, since socket is actually used to represent the coordinates of a point in the present invention, it is more accurate to take its original meaning, and in the present invention, it is translated as "slot".

[0049] 102. Generate multiple geometry models corresponding to the target virtual object according to multiple rendering target textures.

[0050] Among them, the terminal generates multiple geometry models corresponding to the target virtual object according to multiple rendering target textures. The geometry models can include various types. For example, they can be capsule models, cube models, and cuboid models, or any other geometric models with arbitrary shapes. Specifically, it is not limited here. For the convenience of description, in this embodiment and subsequent embodiments, the capsule is taken as an example for illustration.

[0051] It should be noted that each target virtual object corresponds to multiple target rendering textures, that is, multiple slot information. For example, bone sockets in areas such as the body, feet, and arms can be set on the character according to requirements. The specific number added is determined according to requirements. The more added, the more detailed the projected shadow. Among them, the socket is the only identifier for generating the geometry model, and any shape of the geometry model can be customized according to the Socket.

[0052] 103. Determine the shadow function corresponding to the target virtual object based on multiple geometry models and preset light source information. The preset light source information includes the light source type and at least one light source direction.

[0053] Specifically, the terminal determines the shadow function corresponding to the target virtual object according to the basic lighting principle and the vertex positions of the geometry models, and then through the defined light source information.

[0054] It should be noted that the light source types include parallel light, point light, and spotlight. Different light source types correspond to different algorithms, which are not limited here specifically. For the convenience of description and understanding, in this embodiment and subsequent embodiments, the parallel light is taken as an example for illustration. Different light source types can be selected for shadow generation according to actual needs, which is not limited here.

[0055] It can be understood that when the light source type is parallel light, in the embodiments of the present invention, it can be represented by the unit vector float3 LightDir, or other representation forms can also be used. There is no limitation here, and it is not necessary to actually set a light in the scene like in traditional 3D production, which reduces the consumption of hardware resources and improves efficiency.

[0056] 104. Generate dynamic shadows based on the shadow function.

[0057] The terminal generates dynamic shadows based on the shadow function. It should be noted that the dynamic shadows in this embodiment are the overall shadows obtained by combining multiple shadows. Each simulated light source will have a corresponding shadow. Therefore, when there are multiple light sources, multiple shadows need to be generated, and the overall combination of these shadows is the dynamic shadow required in the embodiments of the present invention.

[0058] In the embodiments of the present invention, a geometric model is generated through the slot information carried in the rendering target texture map of the target virtual object, and then the geometric model is combined with the light source information to determine the dynamic shadow area, and corresponding dynamic shadows are generated in the dynamic shadow area, simulating the dynamic shadows of multiple lights, increasing the supported light types and quantities, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency.

[0059] Please refer to Figure 2 , another flowchart of the dynamic shadow generation method provided by the embodiments of the present invention, specifically including:

[0060] 201. Obtain multiple rendering target texture maps of the target virtual object. The rendering target texture map is used to indicate the slot information corresponding to each slot, and the slot information includes the slot coordinates and the corresponding scaling data.

[0061] It should be noted that the terminal will collect multiple virtual objects in advance. Specifically: first, the array situation of the stored bone model is stored, then the texture data of the socket position of the stored slot is cleared, and then each object in the scene is looped to find, and it is judged whether the current object is a virtual object. If it is a virtual object, the virtual object is stored in the corresponding array. Among them, the virtual object can be a game character, such as a biological object like a person or a pet, or a non-biological object like a tank or a firearm. There is no specific limitation here.

[0062] It can be understood that to judge whether an object is a virtual object, mainly by judging whether there is a specific slot socket on the object. When there is a special slot position on the object, it can be determined that the object belongs to a virtual object and can be used for projection.

[0063] 202. Sample and decode the multiple rendering target texture maps to obtain multiple slot coordinates and the corresponding multiple radius information.

[0064] Specifically, the terminal calculates the identifiers corresponding to multiple render target textures to obtain multiple texture identifiers; then the terminal reads the target pixel values of the render target textures corresponding to each texture identifier to obtain at least two slot coordinates and corresponding radius information for each render target texture.

[0065] It should be noted that during sampling, the RGB values of every two pixels are taken as a pair and used as the coordinates of two slots (sockets) respectively, and the radius value corresponding to each socket is stored in the A channel of the pixel.

[0066] 203. Construct multiple geometry models corresponding to the target virtual object according to the multiple slot coordinates and corresponding multiple radius information.

[0067] It should be noted that each target virtual object corresponds to multiple target render textures, that is, multiple slot information. According to the socket positions on the target virtual object, as well as the identifier and position information of each socket and the corresponding radius information, the terminal can define a geometry model of any shape. When the target virtual object is a person, the bones in the human body are defined by a capsule, that is, the geometry model to be projected of the target virtual object is composed of multiple capsule models.

[0068] It should be noted that when the geometry is a capsule, 2 sockets are required to be the upper and lower vertices of the capsule respectively, and the capsule can be obtained by adding the radius information; when the geometry is a cube, 2 sockets are required to be the center and the vertex respectively, and the cube can be represented by adding the radius information; when the geometry is a cuboid, 3 sockets are required to be the center and 2 vertices respectively, and the cuboid can be represented by adding the radius information. In this embodiment, the capsule is taken as an example for illustration, which does not mean a limitation on the geometry shape and can be determined according to the actual situation.

[0069] 204. Determine the shadow function corresponding to the target virtual object based on the multiple geometry models and the preset light source information, and the preset light source information includes the light source type and at least one light source direction.

[0070] Specifically, the terminal determines the light source vector based on the light source type; the terminal determines the initial shadow area corresponding to the target virtual object according to the vertex positions of each geometry model and at least one light source direction; the terminal generates the shadow function corresponding to the target virtual object according to the initial shadow area and the light source vector.

[0071] It should be noted that the light source types include parallel light, point light source, and spotlight. Different light source types correspond to different algorithms, which are not specifically limited here. For the convenience of description and understanding, parallel light is taken as an example in this embodiment and subsequent embodiments. Different light source types can be selected according to actual needs to generate shadows.

[0072] It can be understood that when the light source type is parallel light, in the embodiment of the present invention, it can be represented by the unit vector float3 LightDir, or other representation forms, which are not limited here. It is not necessary to actually place a light in the scene like traditional 3D production, reducing the consumption of hardware resources and improving efficiency.

[0073] In a feasible implementation manner, the terminal determines the initial shadow area corresponding to the target virtual object according to the vertex positions of each geometry model and at least one light source direction, including:

[0074] The terminal determines the radius information corresponding to each geometry model according to the vertex positions of each geometry model; the terminal determines multiple extended lines of the light source direction corresponding to at least one light source direction on each geometry model according to the vertex positions and the corresponding radius information; the terminal determines the intersection points of the multiple extended lines of the light source direction on the preset plane as the shadow points in the shadow area, and obtains the initial shadow area corresponding to the target virtual object. The preset plane can be a horizontal plane, that is, the target virtual object is perpendicular to the horizontal plane, and the preset plane can also be an inclined plane, that is, the target virtual object is not perpendicular to the horizontal plane. For example, the virtual object stands on a hillside, and the uphill is a plane with a certain angle to the horizontal plane.

[0075] For example, as Figure 3 shown, when parallel light irradiates any one of the capsules of the target virtual object, it is necessary to partially extend the light source direction of the parallel light. When the connection line (extended line of the light source direction) between the target point and the light source in the preset plane has an intersection with the target capsule, it means that the target point is in the shadow of the target capsule, and multiple target points converge to form a shadow area.

[0076] 205. Generate dynamic shadows based on the shadow function.

[0077] Specifically, the terminal calls the shadow function for calculation to obtain the initial shadow; the terminal adjusts the intensity of the initial shadow according to the preset shadow attenuation parameter to obtain the target shadow corresponding to the target virtual object; the terminal uses the preset mask to deduct the virtual object from the target shadow to obtain the dynamic shadow of the target virtual object.

[0078] It should be noted that the dynamic shadow in this embodiment is the overall shadow obtained by combining multiple shadows. Each simulated light source will have a corresponding shadow. Therefore, when there are multiple light sources, multiple shadows need to be generated, and the overall combination of these shadows is the dynamic shadow required in the embodiments of the present invention.

[0079] It can be understood that by adjusting the shadow attenuation parameter, the intensity of the shadow is adjusted, the transition and blurring of the shadow edge are realized, and the authenticity of the simulated shadow is improved.

[0080] In the embodiments of the present invention, a geometric model is generated through the slot information carried in the rendering target texture map of the target virtual object, and then the geometric model is combined with the light source information to determine the dynamic shadow area, and a corresponding dynamic shadow is generated in the dynamic shadow area, simulating the dynamic shadows of multiple lights, increasing the supported light types and quantities, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency.

[0081] Please refer to Figure 4 , another flowchart of the dynamic shadow generation method provided by the embodiments of the present invention, specifically including:

[0082] 401. Generate multiple rendering target texture maps of the target virtual object.

[0083] Specifically, the terminal sets multiple virtual geometries of the target virtual object; the terminal generates multiple rendering target texture maps of the target virtual object according to the multiple virtual geometries.

[0084] In a feasible implementation manner, the terminal setting multiple virtual geometries of the target virtual object includes:

[0085] The terminal determines multiple bones corresponding to the target virtual object; the terminal sets a bone slot corresponding to each bone in the bone tree, and generates a corresponding virtual geometry according to the bone slot corresponding to each bone, obtaining multiple virtual geometries, where the bones corresponding to each virtual geometry are different; the terminal stores the radius information of each virtual geometry into the scaling data of the corresponding bone slot.

[0086] For example, open the bone tree of the target virtual object, add sockets in the bone tree, and use every two sockets as the two vertices of a capsule, with the upper vertex and the lower vertex distinguished by the naming suffixes _up and _down. Taking the calf bone as an example, taking the calf bone as the parent node, add two sockets. To save performance, store the radius data of the capsule in the x-axis scaling value of the socket.

[0087] It should be noted that the coordinate values of the two sockets need to be compared, and the socket with the larger z value is used as the upper vertex of the capsule, and the socket with the smaller z value is used as the lower vertex of the capsule.

[0088] In a feasible implementation, the terminal generates multiple rendering target maps for the target virtual object according to multiple virtual geometries, including:

[0089] The terminal obtains the slot information of each virtual geometry in the multiple virtual geometries, obtaining multiple slot coordinates and corresponding multiple scaling data, where the scaling data is used to indicate the radius information of the virtual geometry;

[0090] The terminal calls a preset rendering component to render each slot coordinate and the corresponding scaling data onto the corresponding rendering target map, obtaining multiple rendering target maps of the target virtual object, where the RGB channels of the rendering target map are used to store the slot coordinates, and the A channel of the rendering target map is used to store the radius information of the virtual geometry.

[0091] 402. Obtain multiple rendering target maps of the target virtual object, where the rendering target map is used to indicate the slot information corresponding to each slot, and the slot information includes the slot coordinates and the corresponding scaling data.

[0092] It should be noted that the terminal will collect multiple virtual objects in advance. Specifically: First, the array situation of the stored skeletal model will be stored, then the map data storing the socket positions of the slots will be cleared, and then each object in the scene will be looped through to determine whether the current object is a virtual object. If it is a virtual object, the virtual object will be stored in the corresponding array. Among them, the virtual object can be a game character, such as a biological object like a person or a pet, or a non-biological object like a tank or a firearm. Specifically, it is not limited here.

[0093] It can be understood that to determine whether an object is a virtual object, it is mainly through determining whether there is a specific socket on the object. When there is a special slot position on the object, it can be determined that the object belongs to a virtual object and can be used for projection.

[0094] 403. Sample and decode the multiple rendering target maps to obtain multiple slot coordinates and corresponding multiple radius information.

[0095] Specifically, the terminal calculates the identifiers corresponding to the multiple rendering target maps to obtain multiple map identifiers; then the terminal reads the target pixel values of the rendering target maps corresponding to each map identifier to obtain at least two slot coordinates and corresponding radius information for each rendering target map.

[0096] It should be noted that during sampling, the RGB values of every two pixels are taken as a pair and are respectively used as the coordinates of two sockets, and at the same time, the radius value corresponding to each socket is stored in the A channel of the pixel.

[0097] 404. Construct multiple geometric models corresponding to the target virtual object based on multiple slot coordinates and corresponding multiple radius information.

[0098] It should be noted that each target virtual object will correspond to multiple target rendering texture maps, that is, multiple slot information. According to the socket positions on the target virtual object, as well as the identification and position information of each socket and the corresponding radius information, the terminal can define geometric models of any shape. When the target virtual object is a person, the bones in the human body are defined by a capsule, that is, the geometric model to be projected of the target virtual object is composed of multiple capsule models.

[0099] It should be noted that when the geometric body is a capsule, 2 sockets are required to be the upper and lower vertices of the capsule respectively, and the capsule can be obtained by adding the radius information; when the geometric body is a cube, 2 sockets are required to be the center and the vertex respectively, and the cube can be represented by adding the radius information; when the geometric body is a cuboid, 3 sockets are required to be the center and 2 vertices respectively, and the cube can be represented by adding the radius information. In this embodiment, the capsule is taken as an example for illustration, which does not mean a limitation on the shape of the geometric body and can be determined according to the actual situation.

[0100] 405. Determine the shadow function corresponding to the target virtual object based on multiple geometric models and preset light source information, where the preset light source information includes the light source type and at least one light source direction.

[0101] Specifically, the terminal determines the light source vector based on the light source type; the terminal determines the initial shadow area corresponding to the target virtual object according to the vertex positions corresponding to each geometric model and at least one light source direction; the terminal generates the shadow function corresponding to the target virtual object according to the initial shadow area and the light source vector.

[0102] It should be noted that the light source types include parallel light, point light, and spotlight, and the corresponding algorithms for different light source types are different, which are not specifically limited here. For the convenience of description and understanding, parallel light is taken as an example in this embodiment and subsequent embodiments. Different light source types can be selected according to actual needs to generate shadows.

[0103] It can be understood that when the light source type is parallel light, in the embodiments of the present invention, it can be represented by the unit vector float3 LightDir, or other representation forms, which are not limited here. It is not necessary to actually place a light in the scene like traditional 3D production, reducing the consumption of hardware resources and improving efficiency.

[0104] In a feasible implementation, the terminal determines the initial shadow area corresponding to the target virtual object according to the vertex positions corresponding to each geometric model and at least one light source direction, including:

[0105] The terminal determines the radius information corresponding to each geometric model according to the vertex positions corresponding to each geometric model; the terminal determines multiple extended light source directions corresponding to at least one light source direction on each geometric model according to the vertex positions and the corresponding radius information; the terminal determines the intersection points of the multiple extended light source directions on the preset plane as the shadow points in the shadow area, and obtains the initial shadow area corresponding to the target virtual object. Among them, the preset plane can be a horizontal plane, that is, the target virtual object is perpendicular to the horizontal plane, and the preset plane can also be an inclined plane, that is, the target virtual object is not perpendicular to the horizontal plane. For example, the virtual object stands on a hillside, and the uphill is a plane with a certain angle to the horizontal plane.

[0106] For example, as Figure 3 shown, when parallel light shines on any one of the capsules of the target virtual object, part of the light source direction extension line needs to be parallel light. When the connection line (extended light source direction) between the target point and the light source in the preset plane and the target capsule have an intersection point, it means that the target point is in the shadow of the target capsule, and multiple target points converge into a shadow area.

[0107] In the embodiment of the present invention, any number of dynamic shadows (representing the illumination of the light through the shadows) can be defined to achieve the multi-dynamic light shadow effect, reducing the hardware resources consumed by simulating the light. It is also possible to encapsulate various types of lights and projection models according to the project requirements and provide them as options to the staff.

[0108] 406. Generate dynamic shadows based on the shadow function.

[0109] Specifically, the terminal calls the shadow function for calculation to obtain the initial shadow; the terminal adjusts the intensity of the initial shadow according to the preset shadow attenuation parameter to obtain the target shadow corresponding to the target virtual object; the terminal uses the preset mask to subtract the virtual object from the target shadow to obtain the dynamic shadow of the target virtual object. Among them, the target shadow will be projected onto the target virtual object, and it is also necessary to use a custom mask (a function provided by the mainstream engine) to subtract part of the target virtual object from the screen space to avoid the target shadow being projected onto itself, so as to obtain the dynamic shadow.

[0110] It should be noted that the dynamic shadow in this embodiment is the overall shadow obtained by combining multiple shadows. Each simulated light source will have a corresponding shadow. Therefore, when there are multiple light sources, multiple shadows need to be generated, and the overall combination of these shadows is the dynamic shadow required in the embodiment of the present invention.

[0111] It can be understood that by adjusting the shadow attenuation parameter, the intensity of the shadow is adjusted, the transition and blurring of the shadow edge are realized, and the authenticity of the simulated shadow is improved.

[0112] In the embodiment of the present invention, the limitation that only one dynamic parallel light is supported to project shadows on the mobile terminal is broken through, so as to generate a multi-dynamic shadow effect. This greatly enriches the scene effect and improves the authenticity. In addition, it also provides the possibility for making scenes in a complex lighting environment.

[0113] 407. Set the color of the dynamic shadow.

[0114] The terminal sets the color of the dynamic shadow. Specifically, the dynamic shadow is multiplied by the color to obtain the color of the dynamic shadow. It can be understood that the color of the dynamic shadow can be set to be lighter than the color of the main light shadow to enrich the performance effect of the shadow and achieve a more realistic lighting effect.

[0115] In a feasible implementation manner, after step 406, it may further include

[0116] The terminal obtains the main light of the scene, and generates the main shadow of the target virtual object based on the main light, and the main shadow does not overlap with the dynamic shadow.

[0117] In the embodiment of the present invention, a geometry model is generated through the slot information carried in the render target texture map of the target virtual object, and then the geometry model is combined with the light source information to determine the dynamic shadow area, and a corresponding dynamic shadow is generated in the dynamic shadow area, simulating the dynamic shadows of multiple lights, increasing the supported types and quantities of lights, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency. The embodiment of the present invention can be used in any graphics interface platform, can be conveniently used in mainstream engines, has no platform limitation, and reduces the adaptation problems in the development process.

[0118] The method for generating a dynamic shadow in the embodiment of the present invention is described above. Next, the device for generating a dynamic shadow in the embodiment of the present invention will be described. Please refer to Figure 5 An embodiment of the device for generating a dynamic shadow in the embodiment of the present invention includes:

[0119] A texture map acquisition module 501, configured to acquire multiple render target texture maps of a target virtual object, where the render target texture map is used to indicate slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data;

[0120] A geometry generation module 502, configured to generate multiple geometry models corresponding to the target virtual object according to the multiple render target texture maps;

[0121] A shadow function determination module 503, configured to determine a shadow function corresponding to the target virtual object based on the plurality of geometric models and preset light source information, where the preset light source information includes a light source type and at least one light source direction;

[0122] A shadow generation module 504, configured to generate a dynamic shadow based on the shadow function.

[0123] In a feasible implementation manner, the shadow function determination module 503 includes:

[0124] A light source vector determination unit 5031, configured to determine a light source vector based on the light source type;

[0125] A shadow area determination unit 5032, configured to determine an initial shadow area corresponding to the target virtual object according to the vertex positions corresponding to each geometric model and at least one light source direction;

[0126] A function generation unit 5033, configured to generate a shadow function corresponding to the target virtual object according to the initial shadow area and the light source vector.

[0127] In a feasible implementation manner, the shadow area determination unit 5032 is specifically configured to:

[0128] Determine the radius information corresponding to each geometric model according to the vertex positions corresponding to each geometric model; determine multiple extended light source directions corresponding to at least one light source direction on each geometric model according to the vertex positions and the corresponding radius information; determine the intersection points of the multiple extended light source directions on a preset plane as shadow points in the shadow area, so as to obtain an initial shadow area corresponding to the target virtual object.

[0129] In a feasible implementation manner, the shadow generation module 504 is specifically configured to:

[0130] Call the shadow function for calculation to obtain an initial shadow;

[0131] Adjust the intensity of the initial shadow according to a preset shadow attenuation parameter to obtain a target shadow corresponding to the target virtual object;

[0132] Use a preset mask to perform virtual object deduction on the target shadow to obtain a dynamic shadow of the target virtual object.

[0133] In a feasible implementation manner, the dynamic shadow generation device further includes:

[0134] A texture generation module 505, configured to generate multiple rendering target textures of the target virtual object.

[0135] In a feasible implementation manner, the texture generation module 505 includes:

[0136] A geometric body setting unit 5051 for setting a plurality of virtual geometric bodies of a target virtual object;

[0137] A texture generation unit 5052 for generating a plurality of rendering target textures of the target virtual object according to the plurality of virtual geometric bodies.

[0138] In a feasible implementation manner, the geometric body setting unit 5051 is specifically configured to:

[0139] Determine a plurality of bones corresponding to the target virtual object;

[0140] Set a bone slot corresponding to each bone in the bone tree, and generate a corresponding virtual geometric body according to the bone slot corresponding to each bone, so as to obtain a plurality of virtual geometric bodies, wherein the bones corresponding to each virtual geometric body are different;

[0141] Store the radius information of each virtual geometric body into the scaling data of the corresponding bone slot.

[0142] In a feasible implementation manner, the texture generation unit 5052 is specifically configured to:

[0143] Obtain the slot information of each virtual geometric body in the plurality of virtual geometric bodies, so as to obtain a plurality of slot coordinates and corresponding plurality of scaling data, where the scaling data is used to indicate the radius information of the virtual geometric body;

[0144] Call a preset rendering component to render each slot coordinate and the corresponding scaling data onto the corresponding rendering target texture, so as to obtain a plurality of rendering target textures of the target virtual object, wherein the RGB channels of the rendering target texture are used to store the slot coordinates, and the A channel of the rendering target texture is used to store the radius information of the virtual geometric body.

[0145] In a feasible implementation manner, the geometric body generation module 502 includes:

[0146] A sampling and decoding unit 5021 for sampling and decoding the plurality of rendering target textures to obtain a plurality of slot coordinates and corresponding plurality of radius information;

[0147] A model construction unit 5022 for constructing a plurality of geometric body models corresponding to the target virtual object according to the plurality of slot coordinates and the corresponding plurality of radius information.

[0148] In a feasible implementation manner, the sampling and decoding unit 5021 is specifically configured to:

[0149] Calculate the identifiers corresponding to the plurality of rendering target textures to obtain a plurality of texture identifiers;

[0150] Read the target pixel values of the render target textures corresponding to each texture identifier, and obtain at least two slot coordinates and corresponding radius information for each render target texture.

[0151] In a feasible implementation manner, the model construction unit 5022 is specifically configured to:

[0152] Call a preset formula to calculate based on at least two slot coordinates and corresponding radius information for each render target texture, and obtain the geometric contour information corresponding to each render target texture;

[0153] Generate a corresponding geometric model according to the geometric contour information corresponding to each render target texture, and obtain multiple geometric models of the target virtual object.

[0154] In a feasible implementation manner, the dynamic shadow generation device further includes:

[0155] A color setting module 506, configured to set the color of the dynamic shadow.

[0156] In a feasible implementation manner, the dynamic shadow generation device further includes:

[0157] A main shadow generation module 507, configured to obtain the main light of the scene and generate a main shadow of the target virtual object based on the main light, where the main shadow does not overlap with the dynamic shadow.

[0158] In the embodiment of the present invention, a geometric model is generated through the slot information carried in the render target texture of the target virtual object, and then the geometric model is combined with the light source information to determine the dynamic shadow area, and a corresponding dynamic shadow is generated in the dynamic shadow area, simulating the dynamic shadows of multiple lights, increasing the supported light types and quantities, reducing the hardware resources consumed by simulating multiple dynamic shadows, and improving the simulation efficiency. The embodiment of the present invention can be used in any graphics interface platform, can be easily used in mainstream engines, has no platform limitation, and reduces the adaptation problems in the development process.

[0159] Figure 6It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. The electronic device 600 may vary greatly due to different configurations or performances, and may include one or more processors (central processing units, CPUs) 610 (for example, one or more processors) and a memory 620, and one or more storage media 630 (for example, one or more mass storage devices) for storing application programs 633 or data 632. Among them, the memory 620 and the storage media 630 may be transient storage or persistent storage. The program stored in the storage media 630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the electronic device 600. Further, the processor 610 may be set to communicate with the storage media 630 and execute a series of instruction operations in the storage media 630 on the electronic device 600.

[0160] The electronic device 600 may further include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input / output interfaces 660, and / or one or more operating devices 631, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art can understand that Figure 6 The shown structure of the electronic device does not limit the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0161] By way of example and not limitation, the electronic device 600 may be a server or a terminal.

[0162] The present invention also provides a computer-readable storage medium. The computer-readable storage medium may be a non-volatile computer-readable storage medium, or may also be a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions run on a computer, the computer is caused to execute the steps of the dynamic shadow generation method.

[0163] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described systems, devices, and units may refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.

[0164] In addition, in the description of the embodiments of the present invention, unless otherwise clearly defined and limited, the terms "install", "connect", and "couple" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.

[0165] If the above-mentioned functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0166] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0167] Finally, it should be noted that the above embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, and are not intended to limit it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for generating dynamic shadows, characterized in that, include: Determine multiple bones corresponding to the target virtual object; A bone slot corresponding to each bone is set in the bone tree, and a corresponding virtual geometric body is generated according to the bone slot corresponding to each bone, thereby obtaining multiple virtual geometric bodies, wherein each virtual geometric body corresponds to a different bone; Store the radius information of each virtual geometry into the scaling data of the corresponding bone slot; generating a plurality of rendering target maps for the target virtual object based on the plurality of virtual geometries; Acquire multiple rendering target maps of the target virtual object, where the rendering target maps are used to indicate slot information corresponding to each slot, where the slot information includes slot coordinates and corresponding scaling data; Generating a plurality of geometric models corresponding to the target virtual object according to the plurality of rendering target maps; Determining a shadow function corresponding to the target virtual object based on the multiple geometric models and preset light source information, wherein the preset light source information includes a light source type and at least one light source direction; Dynamic shadows are generated based on the shadow function.

2. The dynamic shadow generation method according to claim 1, wherein The determining of a shadow function corresponding to the target virtual object based on the multiple geometric models and preset light source information, wherein the preset light source information includes a light source type and at least one light source direction, comprises: Determine the light source vector based on the light source type; Determine an initial shadow area corresponding to the target virtual object according to the vertex position corresponding to each geometric model and at least one light source direction; A shadow function corresponding to the target virtual object is generated according to the initial shadow area and the light source vector.

3. The dynamic shadow generation method according to claim 2, characterized in that: The determining of an initial shadow area corresponding to the target virtual object according to the vertex position corresponding to each geometric model and at least one light source direction includes: Determine the radius information corresponding to each geometric model according to the vertex position corresponding to each geometric model; Determine, according to the vertex position and the corresponding radius information, a plurality of light source direction extension lines corresponding to the at least one light source direction on each geometric model; An intersection point of the multiple light source direction extension lines on the preset plane is determined as a shadow point in the shadow area to obtain an initial shadow area corresponding to the target virtual object.

4. The dynamic shadow generation method according to claim 1, wherein Generating a dynamic shadow based on the shadow function includes: Call the shadow function to perform calculations to obtain an initial shadow; Adjusting the intensity of the initial shadow according to a preset shadow attenuation parameter to obtain a target shadow corresponding to the target virtual object; The target shadow is subjected to virtual object subtraction using a preset mask to obtain a dynamic shadow of the target virtual object.

5. The dynamic shadow generation method according to claim 1, wherein Generating a plurality of rendering target maps of the target virtual object according to the plurality of virtual geometric bodies includes: Obtaining slot information of each virtual geometric body among the multiple virtual geometric bodies, obtaining multiple slot coordinates and corresponding multiple scaling data, wherein the scaling data is used to indicate radius information of the virtual geometric body; Call a preset rendering component to render each slot coordinate and corresponding scaling data onto a corresponding rendering target map, to obtain multiple rendering target maps of the target virtual object, wherein the RGB channels of the rendering target map are used to store the slot coordinates, and the A channel of the rendering target map is used to store the radius information of the virtual geometry.

6. The dynamic shadow generation method according to claim 1, wherein Generating the multiple geometric models corresponding to the target virtual object according to the multiple rendered target textures includes: Sampling and decoding the multiple rendered target textures to obtain multiple slot coordinates and corresponding multiple radius information; Constructing the multiple geometric models corresponding to the target virtual object according to the multiple slot coordinates and the corresponding multiple radius information.

7. The dynamic shadow generation method according to claim 6, wherein The sampling and decoding the multiple rendered target textures to obtain multiple slot coordinates and corresponding multiple radius information includes: Calculating the identifiers corresponding to the multiple rendered target textures to obtain multiple texture identifiers; Reading the target pixel values of the rendered target textures corresponding to each texture identifier to obtain at least two slot coordinates and corresponding radius information for each rendered target texture.

8. The dynamic shadow generation method according to claim 7, wherein The constructing the multiple geometric models corresponding to the target virtual object according to the multiple slot coordinates and the corresponding multiple radius information includes: Invoking a preset formula to calculate based on at least two slot coordinates and corresponding radius information for each rendered target texture to obtain the geometric contour information corresponding to each rendered target texture; Generating corresponding geometric models according to the geometric contour information corresponding to each rendered target texture to obtain the multiple geometric models of the target virtual object.

9. The dynamic shadow generation method according to any one of claims 1-8, characterized in that, After generating the dynamic shadow based on the shadow function, the dynamic shadow generation method further includes: Setting the color of the dynamic shadow.

10. The dynamic shadow generation method according to any one of claims 1-8, characterized in that, After generating the dynamic shadow based on the shadow function, the dynamic shadow generation method further includes: Obtaining the main light of the scene and generating the main shadow of the target virtual object based on the main light, where the main shadow does not overlap with the dynamic shadow.

11. A dynamic shadow generating device, characterized in that: Includes: A texture generation module for determining multiple bones corresponding to the target virtual object; Setting the bone slots corresponding to each bone in the bone tree, and generating corresponding virtual geometries according to the bone slots corresponding to each bone to obtain multiple virtual geometries, where the bones corresponding to each virtual geometry are different; storing the radius information of each virtual geometry into the scaling data of the corresponding bone slot; generating the multiple rendered target textures of the target virtual object according to the multiple virtual geometries; A texture acquisition module for acquiring the multiple rendered target textures of the target virtual object, where the rendered target textures are used to indicate the slot information corresponding to each slot, and the slot information includes slot coordinates and corresponding scaling data; A geometry generation module for generating the multiple geometric models corresponding to the target virtual object according to the multiple rendered target textures; A shadow function determination module for determining the shadow function corresponding to the target virtual object based on the multiple geometric models and the preset light source information, where the preset light source information includes the light source type and at least one light source direction; A shadow generation module for generating a dynamic shadow based on the shadow function.

12. An electronic device, characterized in that, The electronic device includes: a memory and at least one processor, where instructions are stored in the memory, and the memory and the at least one processor are interconnected by a line; The at least one processor calls the instructions in the memory to enable the electronic device to execute the dynamic shadow generation method as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions, and when the instructions are executed by a processor, the dynamic shadow generation method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • A picture rendering method and device, a storage medium and an electronic device.

    CN109448099A

  • Method and device for shade processing

    JP1997035087A