Illumination baking method and device for virtual scene, computer equipment and storage medium

By segmenting and traversing the virtual scenes and determining and baking the element set, the problem of poor lighting baking stability in large virtual scenes is solved, and the effect of reducing video memory usage and improving stability is achieved.

CN120204727APending Publication Date: 2025-06-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311811741.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-25
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

When the prior art light baking of large virtual scenes, the data amount and calculation amount are too large, resulting in poor lighting baking stability.

Method used

By scene division of the virtual scene, a scene tree structure is generated, and the target nodes are traversed in the scene tree structure, the baking element set is determined according to the number of elements of the target node and its ancestor nodes and descendants nodes, and the baking element set is illuminated and baked.

Benefits of technology

Reduces the video memory usage during lighting baking and improves the stability of lighting baking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120204727A_ABST
    Figure CN120204727A_ABST
Patent Text Reader

Abstract

The invention relates to an illumination baking method and device for a virtual scene, computer equipment, a storage medium and a computer program product. The method can be applied to the fields of artificial intelligence, image processing, games and the like, and comprises the steps of obtaining scene elements in a virtual scene, and performing scene division on the virtual scene to obtain a scene tree structure; traversing the target node in the scene tree structure; when the target node satisfies a baking condition, determining a baking element set according to the scene element of the target node and the scene elements of the ancestor node and the descendant node of the target node; and performing illumination baking on the baking element set to obtain illumination information of the baking element set. By adopting the method, the video memory occupancy rate in the illumination baking process can be reduced, and the illumination baking stability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular, to a method, device, computer device, storage medium, and computer program product for light baking of a virtual scene. Background Art

[0002] With the development of computer technology, users have higher and higher requirements for the display effect of game pictures.

[0003] In the process of game development, since real-time light rendering takes a long time, the light information of direct light sources and indirect light sources in the scene is usually calculated offline and saved, and this process is called light baking; in the related art, for light baking of a game's virtual scene, most of the time it is to perform light baking on the entire virtual scene. However, the related art can only be used for light baking of relatively small virtual scenes. When the virtual scene is large, the amount of data and the amount of calculation involved in light baking are large, and limited by hardware resources, the stability of light baking is poor. Summary of the Invention

[0004] Based on this, in view of the above technical problems, it is necessary to provide a method, device, computer device, computer-readable storage medium, and computer program product for light baking of a virtual scene, which can reduce the video memory occupancy rate during the light baking process and improve the stability of light baking.

[0005] In a first aspect, the present application provides a method for light baking of a virtual scene. The method includes:

[0006] Obtain the scene elements in the virtual scene; divide the virtual scene according to the scene elements to obtain a scene tree structure; traverse to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, determine the baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; perform light baking on the baking element set to obtain the light information of the baking element set.

[0007] In a second aspect, the present application also provides a device for light baking of a virtual scene. The device includes:

[0008] A scene element acquisition module, configured to obtain the scene elements in the virtual scene;

[0009] A scene division module, configured to divide the virtual scene according to the scene elements to obtain a scene tree structure;

[0010] A node traversal module, configured to traverse to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship;

[0011] A baking element set acquisition module, which is used for a baking element set determination module to determine a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes when it is determined that the target node meets the baking condition based on the number of elements of the target node and the number of elements of the descendant nodes of the target node;

[0012] A lighting baking module, which is used to perform lighting baking on the baking element set to obtain the lighting information of the baking element set.

[0013] In some embodiments, the lighting baking device for the virtual scene further includes: a baking condition determination module, which is used to obtain the number of elements of the target node and the number of elements of the descendant nodes of the target node; perform a summation process on the number of elements of the target node and the number of elements of the descendant nodes to obtain the total number of elements; when the total number of elements belongs to a preset number interval, determine that the target node meets the baking condition.

[0014] In some embodiments, the baking element set acquisition module is further used to obtain the position information corresponding to the scene elements of the ancestor nodes of the target node; select the scene elements to be baked from the scene elements of the ancestor nodes according to the position information; determine the baking element set according to the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes.

[0015] In some embodiments, the baking element set acquisition module is further used to traverse the scene elements of the ancestor nodes of the target node to obtain the target scene elements; obtain the position information of the center point of the target scene elements in the virtual scene; when the position information belongs to the node space of the target node, use the target scene elements as the scene elements to be baked.

[0016] In some embodiments, the baking element set acquisition module is further used to obtain the position information corresponding to the scene elements of the ancestor nodes of the target node; when no scene elements to be baked are selected from the scene elements of the ancestor nodes according to the position information, determine the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes.

[0017] In some embodiments, the scene division module is further configured to generate an initial scene tree structure; traverse the scene elements to obtain the scene elements to be added, and use the root node in the initial scene tree structure as the initial node; obtain the node type of the initial node; in the case where the node type is a leaf node type, when the scene elements to be added do not meet the element addition condition, split the initial node to obtain child nodes to update the initial scene tree structure, select the child node corresponding to the scene elements to be added from the split child nodes as the initial node, and return to execute the step of obtaining the node type of the initial node; when the scene elements to be added meet the element addition condition, add the scene elements to be added to the initial node to update the initial scene tree structure, and return to execute the step of traversing the scene elements to obtain the scene elements to be added; after completing the traversal of the scene elements, use the updated initial scene tree structure as the scene tree structure.

[0018] In some embodiments, the element addition condition includes a first element addition condition or a second element addition condition; the scene division module is further configured to, in the case where the node type is a leaf node type, obtain the node space of the target node, the element type of the scene elements to be added, and the element space; when the element type is an object type and the node space meets the first space division condition, determine that the scene elements to be added do not meet the first element addition condition; or, when the element type is a lighting task type and the element space and the node space meet the second space division condition, determine that the scene elements to be added do not meet the second element addition condition.

[0019] In some embodiments, the element addition condition includes a first element addition condition or a second element addition condition; the scene division module is further configured to, in the case where the node type is a leaf node type, obtain the node space of the target node, the element type of the scene elements to be added, and the element space; when the element type is an object type and the node space does not meet the first space division condition, determine that the scene elements to be added meet the first element addition condition; or, when the element type is a lighting task type and the element space and the node space do not meet the second space division condition, determine that the scene elements to be added meet the second element addition condition.

[0020] In some embodiments, the scene division module is further configured to, in the case where the node type is not a leaf node type, obtain the target child node corresponding to the scene elements to be added from each child node of the target node; when the number of target child nodes does not meet the intersection condition, use the target child node as the initial node obtained by traversal, and return to execute the step of obtaining the node type of the initial node.

[0021] In some embodiments, the scene division module is further configured to, when the number of target child nodes meets the intersection condition, add the scene elements to be added to the initial node to update the initial scene tree structure, and return to execute the step of traversing the scene elements to obtain the scene elements to be added.

[0022] In some embodiments, the light baking device for virtual scenes further includes: a light information storage module, configured to obtain the light information of all scene elements in the preset sub-scenes of the virtual scene based on the light information of the baking element set; and store the light information of all scene elements in the preset sub-scenes.

[0023] In some embodiments, the number of preset sub-scenes is at least two; the light information storage module is further configured to obtain the sub-scene identifiers of the scene elements in the baking element set; in the light information of the scene elements in the baking element set, obtain the light information of the scene elements in each preset sub-scene according to the sub-scene identifiers; and when the light information of all scene elements in any one of the preset sub-scenes is obtained, store the light information of all scene elements in any one of the preset sub-scenes.

[0024] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0025] Obtain the scene elements in the virtual scene; perform scene division on the virtual scene according to the scene elements to obtain a scene tree structure; traverse to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, determine a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; perform light baking on the baking element set to obtain the light information of the baking element set.

[0026] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0027] Obtain the scene elements in the virtual scene; perform scene division on the virtual scene according to the scene elements to obtain a scene tree structure; traverse to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, determine a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; perform light baking on the baking element set to obtain the light information of the baking element set.

[0028] In a fifth aspect, the present application also provides a computer program product. The computer program product includes a computer program which, when executed by a processor, implements the following steps:

[0029] Obtain scene elements in a virtual scene; perform scene partitioning on the virtual scene based on the scene elements to obtain a scene tree structure; traverse to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; when it is determined that the target node meets the baking condition based on the number of elements of the target node and the number of elements of the descendant nodes of the target node, determine a baking element set based on the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; perform light baking on the baking element set to obtain the light information of the baking element set.

[0030] The above light baking method, device, computer device, storage medium, and computer program product for a virtual scene perform scene partitioning on the scene elements in the virtual scene to obtain a scene tree structure, traverse the target node in the scene tree structure, and when the number of elements of the target node and the descendant nodes of the target node meet the baking condition, determine a baking element set according to the baking elements included in the target node, the ancestor nodes of the target node, and the descendant nodes respectively, so that the number of scene elements in the baking element set is small, and perform light baking on the baking element set, so that the number of scene elements participating in one light baking is small, which can reduce the video memory occupancy rate during the light baking process and can improve the stability of the light baking. Description of the Drawings

[0031] Figure 1 It is an application environment diagram of the light baking method for a virtual scene in an embodiment;

[0032] Figure 2 It is a flowchart of the light baking method for a virtual scene in an embodiment;

[0033] Figure 3 It is a schematic diagram of scene elements in a virtual scene in an embodiment;

[0034] Figure 4 It is a schematic diagram of a scene structure tree in an embodiment;

[0035] Figure 5 It is a flowchart of determining a baking element set in an embodiment;

[0036] Figure 6 It is a schematic diagram of obtaining a baking element set according to the position information of the scene elements of the ancestor nodes in an embodiment;

[0037] Figure 7Schematic diagram of obtaining a baking element set according to the position information of a scene element of an ancestor node in another embodiment;

[0038] Figure 8 Schematic flow chart of obtaining a scene tree structure in an embodiment;

[0039] Figure 9 Schematic diagram of a configuration interface for light baking in an embodiment;

[0040] Figure 10 Schematic diagram of updating an initial scene tree structure in an embodiment;

[0041] Figure 11 Schematic diagram of saving light information according to preset sub - scenes in an embodiment;

[0042] Figure 12 Schematic diagram of a scene for light baking of a virtual scene of an open - world game in an embodiment;

[0043] Figure 13 Schematic diagram of the effect comparison between performing light baking on the entire virtual scene and performing light baking using the method provided in the embodiments of the present application;

[0044] Figure 14 Schematic flow chart of a method for light baking of a virtual scene in another embodiment;

[0045] Figure 15 Block diagram of a structure of a device for light baking of a virtual scene in an embodiment;

[0046] Figure 16 Internal structure diagram of a computer device in an embodiment. Detailed implementation manners

[0047] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0048] Computer Vision Technology (CV) Computer vision is a science that studies how to enable machines to "see". More specifically, it refers to machine vision that uses cameras and computers to replace human eyes for object recognition, measurement, etc., and further performs graphics processing to make the computer-processed images more suitable for human eyes to observe or be transmitted to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies and attempts to build artificial intelligence systems that can obtain information from images or multi-dimensional data. Large model technology has brought important changes to the development of computer vision technology. Pretrained models in the visual field such as swin-transformer, ViT, V-MOE, MAE, etc. can be quickly and widely applied to specific downstream tasks after fine-tuning. Computer vision technology usually includes technologies such as image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, etc., and also includes common biometric recognition technologies such as face recognition and fingerprint recognition.

[0049] It should be noted that in the following description, the terms "first, second, and third" only distinguish similar objects and do not represent a specific order for the objects. Understandably, "first, second, and third" can be interchanged in a specific order or sequence when permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0050] The method for baking light in a virtual scene provided by the embodiments of the present application can be applied to an application environment as Figure 1 shown.

[0051] Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed in the cloud or other network servers; the method for baking light in the virtual scene can be executed by the terminal 102 or the server 104, or can be executed collaboratively by the terminal 102 and the server 104.

[0052] Taking the execution of the light baking method for a virtual scene by the terminal 102 as an example, the terminal 102 can obtain the scene elements in the virtual scene; the scene elements include scene objects, light mapping tasks, and light probe tasks; the terminal 102 can divide the virtual scene according to the scene elements to obtain a scene tree structure; the terminal 102 can traverse to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, the terminal 102 can determine the baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; the terminal 102 can perform light baking on the baking element set to obtain the light information of the baking element set; the terminal 102 can also obtain the light information of all scene elements in the preset sub-scene of the virtual scene based on the light information of the baking element set, and save the light information of all scene elements in the preset sub-scene.

[0053] Among them, the terminal 102 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, an Internet of Things device, and a portable wearable device. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart in-vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc.

[0054] The server 104 can be an independent physical server or a service node in a blockchain system, and a peer-to-peer network is formed among the service nodes in the blockchain system.

[0055] In addition, the server 104 can also be a server cluster composed of multiple physical servers, and can be 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 Network (CDN), and big data and artificial intelligence platforms.

[0056] The terminal 102 and the server 104 can be connected through communication connection methods such as Bluetooth, USB (Universal Serial Bus), or network, and this application does not limit this here.

[0057] In some embodiments, as Figure 2 shown, a light baking method for a virtual scene is provided. Taking the example that this method is executed by a computer device, the computer device can be Figure 1 the server or terminal in

[0058] Step 202, obtain the scene elements in the virtual scene.

[0059] Among them, the virtual scene is a scene in a game application. When a computer device runs the game application, the virtual scene can be displayed, and virtual characters in the game can move in the virtual scene; the virtual scene is a scene virtualized by simulating the real environment. For example, the virtual scene can include a virtual sky, river, mountains, plants and animals, buildings, etc.

[0060] The game application can be an application that runs a linear game or an application that runs an open-world game; among them, the game levels of a linear game are unfolded sequentially, and players can complete the game levels according to the task line; the game levels of an open-world game can be unfolded under the player's choice, and players can move freely in the virtual scene.

[0061] The scene element is an element required for light baking of the virtual scene; as Figure 3 shown, the scene elements in the virtual scene include: scene objects and lighting tasks. Among them, the scene objects can be static virtual objects and static light sources in the virtual scene, and the lighting tasks can be light mapping tasks and light probe tasks.

[0062] The virtual object is different from the real object. The virtual object is virtualized by simulating the real object. The static virtual object is a virtual object with a fixed position in the virtual scene. For example, the static virtual object can be a house, a rock, a road sign, etc.; the static light source is a light source with a fixed position in the virtual scene. For example, street lights, candles, etc. in the virtual scene.

[0063] The light mapping task can be understood as a task of determining the lighting information corresponding to the blank light map; the blank light map can be associated with the scene object, indicating that the light mapping task is used to determine the lighting information on the surface of the scene object; the light mapping task is bound to the blank light map, and the spatial position of the blank light map in the virtual scene is the spatial position of the light mapping task in the virtual scene.

[0064] It should be noted that the lighting information on the surface of the scene object can be obtained through light baking, and the lighting information on the surface of the scene object is saved in the blank light map to obtain the light map of the scene object in the virtual scene.

[0065] The light probe task can be understood as a task of calculating the light information corresponding to a blank light probe; the blank light probe can be set at any spatial position in the virtual scene, indicating that the light probe task is used to determine the light information of the spatial position where the blank light probe is located; the light probe task is bound to the blank light probe, and the spatial position of the blank light probe in the virtual scene is the spatial position of the light probe task in the virtual scene; exemplarily, the light probe task can be set around a scene object, or set on a scene object, or evenly set in the virtual scene. For example, the light probe tasks can be evenly set in the virtual scene at a preset interval, or the light probe tasks can be evenly set in some sub-scenes in the virtual scene at a preset interval.

[0066] It should be noted that the light information of the spatial position where the light probe task is located can be obtained through light baking, and the light information of the spatial position where the light probe task is located is saved in the blank light probe to obtain the light probe in the virtual scene.

[0067] In some embodiments, the scene objects, light mapping tasks, and light probe tasks included in the scene elements are all preset in the virtual scene during game design. When setting the scene elements, the spatial position information of the scene elements in the virtual scene is recorded, and the computer device obtains the spatial position information of the scene elements in the virtual scene, and obtains the scene elements in the virtual scene according to the spatial position information of the scene elements; through the preset spatial position information of the scene elements, the scene elements in the virtual scene can be accurately obtained.

[0068] Step 204, perform scene division on the virtual scene according to the scene elements to obtain a scene tree structure.

[0069] Among them, the scene tree structure is a tree structure, including a root node, intermediate nodes, and leaf nodes. Each node in the scene tree structure corresponds to a spatial region in the virtual scene, and at least one node in the scene tree structure includes scene elements.

[0070] The scene tree structure can be a quadtree structure, an octree structure, or a hierarchical bounding box tree structure.

[0071] In some embodiments, the scene tree structure is a quadtree structure; the root node of the scene tree structure is generated according to the virtual scene, that is, the spatial region corresponding to the root node is the entire virtual scene. For each scene element in the virtual scene, the spatial position information of the scene element is obtained, and the volume of the scene element is determined according to the spatial position information of the scene element. When the volume of the scene element is less than one-fourth of the volume of the spatial region corresponding to the root node, the root node is split into four child nodes; according to the spatial position information of the scene element, the child node to be processed is determined among the four child nodes; when the volume of the scene element is less than one-fourth of the volume of the spatial region corresponding to the child node to be processed, the child node to be processed is split continuously; when the volume of the scene element is not less than one-fourth of the volume of the spatial region corresponding to the child node to be processed, the child node to be processed is used as the child node corresponding to the scene element, and the scene element is added to its corresponding child node to be processed; the above process of adding the scene element to the corresponding child node to be processed is performed for each scene element. After all the scene elements of the virtual scene are added to their respective corresponding child nodes to be processed, the scene tree structure is obtained; performing scene division according to the form of the quadtree structure can improve the efficiency of constructing the scene tree structure, and also improve the efficiency of obtaining the baking element set in the scene tree structure of the quadtree structure subsequently.

[0072] It should be noted that the process of performing scene division on the virtual scene according to the scene elements to obtain the scene tree structure is a process of splitting nodes layer by layer based on the root node, and in the process of splitting nodes layer by layer, the scene elements are added to their corresponding nodes to gradually generate the scene tree structure of the virtual scene.

[0073] In some embodiments, the scene tree structure is an octree structure. The process of performing scene division on the virtual scene according to the scene elements to obtain the scene tree structure of the octree structure is similar to the above process of obtaining the scene tree structures of the binary tree structure and the quadtree structure, except that it is judged whether the volume of the scene element is less than one-eighth of the volume of the spatial region corresponding to the node, and when the volume of the scene element is less than one-eighth of the volume of the spatial region corresponding to the node, the node is split into eight child nodes; therefore, the process of performing scene division on the virtual scene according to the scene elements to obtain the scene tree structure of the octree structure can refer to the above process of obtaining the scene tree structure of the quadtree structure; performing scene division according to the form of the octree structure can divide the scene elements into the subspace of the virtual scene in a fine manner, and when obtaining the baking element set in the scene tree structure of the octree structure subsequently, the situation of repeatedly dividing the same scene element into different baking element sets can be avoided, and the accuracy of obtaining the baking element set is improved.

[0074] In some embodiments, the scene tree structure is a hierarchical bounding box tree structure; the bounding boxes of each scene element in the virtual scene are determined, and the root node of the scene tree structure is generated. The root node represents the bounding box that encloses the entire virtual scene. The center of the bounding box corresponding to the root node is used as the dividing boundary. The bounding boxes of the scene elements on one side of the center are divided into one child node of the root node, and the bounding boxes of the scene elements on the other side of the center are divided into another child node of the root node. For each child node of the root node, the center of the bounding box corresponding to the child node is used as the dividing boundary, and the bounding boxes of the scene elements included in the bounding box corresponding to the child node are divided into nodes until the bounding box corresponding to the obtained child node is the bounding box corresponding to the scene element, thus obtaining the scene tree structure; performing scene division according to the form of the hierarchical bounding box tree structure can quickly establish the scene tree structure, improving the efficiency of constructing the scene tree structure. Subsequently, when obtaining the baking element set in the scene tree structure of the hierarchical bounding box tree, the amount of computation involved is small, which can improve the efficiency of obtaining the baking element set.

[0075] Step 206, traverse to the target node in the spatial nodes of the scene tree structure according to the structural hierarchical relationship.

[0076] Among them, the structural hierarchical relationship is the hierarchical relationship between the spatial nodes in the scene tree structure; exemplarily, in the scene tree structure, the hierarchical level of the ancestor node is higher than that of the child node; it can be understood that the child node is obtained by splitting the ancestor node.

[0077] Traversing according to the structural hierarchical relationship can be traversing in the order from high to low in terms of hierarchy; exemplarily, the root node is at the first level, and the child nodes of the root node are at the second level. Traversing according to the structural hierarchical relationship means traversing the root node first and then the child nodes.

[0078] Among them, the target node is a spatial node in the scene tree structure, and the currently traversed spatial node is used as the target node.

[0079] In some embodiments, the computer device traverses to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship, starting from the root node and traversing layer by layer downward according to the structural hierarchy; that is, in the first traversal round, the root node is used as the traversed target node. For other traversal rounds except the first traversal round, when there are spatial nodes that belong to the same level as the target node obtained in the previous traversal round and have not been traversed, the target node is traversed and obtained from the non-traversed spatial nodes. When there are no spatial nodes that belong to the same level as the target node obtained in the previous traversal round and have not been traversed, the target node is traversed and obtained from the child nodes of the target node obtained in the previous traversal round. In this way, the target node is obtained by traversing layer by layer downward according to the structural hierarchy relationship, so that the number of elements in the target node and its descendant nodes traversed subsequently also decreases layer by layer downward, facilitating the rapid acquisition of a baking element set that conforms to the hardware processing capacity.

[0080] Exemplarily, taking the scene tree structure as a quadtree structure as an example for illustration; in the first traversal round, the root node of the scene tree structure is used as the traversed target node; in the second traversal round, since there are no spatial nodes that belong to the same level as the root node and have not been traversed, the target node is traversed and obtained from the child nodes of each node. For example, the first child node of the root node of the scene tree structure is used as the traversed target node; in the third traversal round, since there are still spatial nodes that belong to the same level as the target node in the second traversal round and have not been traversed, the target node is traversed and obtained from the non-traversed spatial nodes, and the second child node of the root node of the scene tree structure is used as the traversed target node.

[0081] In some embodiments, the computer device obtains the current traversal round and traverses to a target node in the spatial nodes of the scene tree structure according to the current traversal round; specifically, each spatial node of the scene tree structure has its own corresponding node number, and the node number is determined according to the structural hierarchy relationship. When the computer device traverses in each spatial node according to the structural hierarchy relationship, the spatial node with the node number consistent with the current traversal round can be used as the target node; traversing the target node according to the corresponding relationship between the current traversal round and the node number improves the efficiency of traversing to the target node.

[0082] Exemplarily, the scene tree structure is taken as a quadtree structure for illustration; the node number of the root node is 1, and the node numbers of the 4 child nodes of the root node are 2, 3, 4, and 5 respectively. The node codes of the 4 child nodes of the spatial node with node number 2 are 6, 7, 8, and 9 respectively, and so on. The node numbers of each spatial node in the scene tree structure can be determined; in the first traversal round (the current traversal round is 1), the root node is the target node traversed. In the second traversal round (the current traversal round is 2), the spatial node with node code 2 is the target node traversed.

[0083] Step 208, when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, determine the baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes.

[0084] Among them, the number of elements of the target node refers to the total number of scene elements included in the target node; for example, if the target node includes two scene elements, the number of elements of the target node is 2.

[0085] The descendant nodes of the target node include all spatial nodes in the subtree structure of the target node. The subtree structure of the target node is a tree structure composed of spatial nodes obtained by splitting nodes based on the target node in the scene tree structure; Exemplarily, when the target node is the root node in the scene tree structure, the descendant nodes of the root node include all spatial nodes in the scene tree structure except the root node, and all spatial nodes in the scene tree structure except the root node form the subtree structure of the target node.

[0086] The number of elements of the descendant nodes of the target node refers to the total number of scene elements included in each spatial node in the subtree structure of the target node. For example, if the target node has four child nodes, and two of the four child nodes each have four grandchild nodes, then the descendant nodes of the target node include 12 nodes. The total number of scene elements included in each of these 12 nodes, that is, the number of elements of the descendant nodes of the target node.

[0087] Among them, the baking condition can be that the total number of the number of elements of the target node and the number of elements of the descendant nodes belongs to a preset number interval, and the total number belonging to the preset number interval is less than the total number not belonging to the preset number interval.

[0088] The baking condition can also be that the total number of the number of elements of the target node, the number of elements of the descendant nodes of the target node, and the number of elements of the ancestor nodes of the target node belongs to a preset number interval.

[0089] The ancestor nodes of the target node, including the parent node of the target node and the ancestor nodes of the parent node; when the target node is not the root node in the scene tree structure, the ancestor nodes of the target node include the root node; for example, if the target node is a spatial node at the third level in the scene tree structure, the ancestor nodes of the target node include: the parent node of the target node at the second level and the root node at the first level.

[0090] The baking element set may include the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes of the target node, or may include the scene elements of the target node, some of the scene elements of the ancestor nodes, and the scene elements of the descendant nodes.

[0091] It should be noted that step 208 is applicable to the case where the scene tree structure is a quadtree structure or an octree structure; when the scene tree structure is a quadtree structure or an octree structure, the scene elements included in each spatial node in the scene tree structure together constitute all the scene elements in the virtual scene, that is, each spatial node in the scene tree structure includes some of the scene elements in the virtual scene; therefore, the sum of the scene elements of the target node, the ancestor nodes of the target node, and the descendant nodes may be some of the scene elements in the virtual scene; traversing the target node according to the structural hierarchy relationship, when the level of the target node is lower, the number of descendant nodes of the target node is less, and thus the sum of the element numbers of the target node and the descendant nodes of the target node is smaller, and further the number of scene elements in the baking element set is less. Therefore, traversing the target node according to the structural hierarchy relationship is to reduce the number of scene elements in the obtained baking element set, so that the number of scene elements participating in one light baking is less, which can reduce the video memory occupancy rate during the light baking process.

[0092] The computer device obtains the number of elements of the target node and the number of elements of the descendant nodes of the target node. When it is determined that the target node meets the baking condition based on the number of elements of the target node and the number of elements of the descendant nodes of the target node, it obtains the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes of the target node, and the baking element set is composed of the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes of the target node.

[0093] When the target node meets the baking condition, it obtains the scene elements of the ancestor nodes of the target node. Among the scene elements of the ancestor nodes, it obtains the partial scene elements whose center points belong to the spatial region corresponding to the target node. The baking element set is composed of the partial scene elements obtained from the scene elements of the ancestor nodes, the scene elements of the target node, and the scene elements of the descendant nodes of the target node.

[0094] When the target node has no ancestor nodes, that is, when the target node is the root node of the scene tree structure, determine the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes of the target node.

[0095] When it is determined that the target node does not meet the baking condition based on the number of elements of the target node and the number of elements of the descendant nodes of the target node, return to the step of traversing to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship until the traversed target node meets the baking condition, and determine the baking element set based on the target node.

[0096] It should be noted that when the target node meets the baking condition, perform light baking on the baking element set composed of the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes, so that the number of scene elements participating in one light baking belongs to a preset number range, that is, the number of scene elements participating in one light baking is small, which can reduce the video memory occupancy rate during the light baking process.

[0097] In some embodiments, when the scene structure tree is a hierarchical bounding box tree structure, after traversing to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship, determine whether the number of elements of the target node belongs to a preset number range. If it belongs, determine that the target node meets the baking condition, and determine the baking element set according to the scene elements included in the target node; when the scene structure tree is a hierarchical bounding box tree structure, it is not necessary to jointly determine whether the target node meets the baking condition with the descendant nodes of the target node, nor is it necessary to determine the baking element set according to the scene elements of the descendant nodes and ancestor nodes of the target node, which improves the efficiency of obtaining the baking element set.

[0098] It should be noted that when the scene structure tree is a hierarchical bounding box tree structure, the root node includes all the scene elements in the virtual scene, the sum of the scene elements included in each child node of the root node is all the scene elements in the virtual scene, and the sum of the scene elements included in all the leaf nodes is also all the scene elements in the virtual scene; traversing the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship, the lower the level of the traversed target node, the fewer the number of elements of the target node, and thus the fewer the number of scene elements in the baking element set. Therefore, traversing the target node according to the structural hierarchy relationship can reduce the number of scene elements in the obtained baking element set, so that the number of scene elements participating in one light baking is small, which can reduce the video memory occupancy rate during the light baking process.

[0099] When the baking condition is met at the target node, the baking element set obtained based on the target node corresponds to the target node; after step 206 is executed, step 204 is returned for execution until all scene elements in the scene tree structure tree exist in the baking element set. In this way, the baking element sets corresponding to each target node that meets the baking condition can be obtained.

[0100] Exemplarily, all scene elements in the scene tree structure tree are respectively: scene element e1, scene element e2,..., scene element en. When the traversed target node d1 meets the baking condition, the baking element set corresponding to the target node d1 includes: scene element e1, scene element e2,..., scene element ei; when the traversed target node d2 meets the baking condition, the baking element set corresponding to the target node d2 includes: scene element ei + 1, scene element ei + 2,..., scene element ej; when the traversed target node d3 meets the baking condition, the baking element set corresponding to the target node d3 includes: scene element ej + 1, scene element ej + 2,..., scene element en. Among them, the union of the scene elements included in the baking element set corresponding to the target node d1, the baking element set corresponding to the target node d2, and the baking element set corresponding to the target node d3 is all scene elements in the virtual scene.

[0101] Step 210, perform light baking on the baking element set to obtain the light information of the baking element set.

[0102] Among them, the baking element set includes at least one scene element. The scene element can be a scene object, a light mapping task, and a light probe task. The light information of the baking element set includes the light information corresponding to the light mapping task and the light information corresponding to the light probe task in the baking element set. Among them, the light information corresponding to the light mapping task is the light information on the surface of the scene object in the baking element set, that is, obtaining the light information corresponding to the light mapping task can be understood as obtaining the light map. The light information corresponding to the light probe task is the light information at the spatial position where the light probe task is located in the virtual scene, that is, obtaining the light information corresponding to the light probe task can be understood as obtaining the light probe.

[0103] When the number of target nodes that meet the baking condition is multiple, correspondingly, multiple baking element sets can be obtained according to the multiple target nodes.

[0104] In some embodiments, for the baking element sets corresponding to each target node that meets the baking condition, perform light baking on each baking element set in sequence to obtain the light information corresponding to the light mapping task and the light information corresponding to the light probe task in each baking element set in sequence; the computer device performs light baking on one baking element set each time, which can reduce the video memory occupancy rate during the light baking process.

[0105] After the computer device completes light baking to obtain light information, it can save the light information. In a possible implementation, when the computer device obtains the light information of all baking element sets, that is, when it obtains the light information of the entire virtual scene, it can save the light information of all baking element sets to the local memory, so that when the light information of scene elements needs to be used subsequently, the light information can be obtained from the local memory. This method can ensure the integrity of the light information of the virtual scene.

[0106] In another possible implementation, since the computer device performs light baking on one baking element set each time, the computer device can save the light information of each baking element set to the local memory when it obtains the light information of each baking element set. After saving the light information of all baking element sets to the local memory, the light information of the virtual scene is stored in the local memory, and the required light information can be obtained from the local memory. This method can perform light information saving while performing light baking, enabling parallel processing of light information and improving the efficiency of saving the light information of the virtual scene.

[0107] In another possible implementation, when the computer device obtains the light information of each baking element set, it obtains the light information of each preset sub-scene in the virtual scene from the light information of the baking element set. The virtual scene includes multiple preset sub-scenes, and the virtual scene is a scene in a game application. The preset sub-scene can be understood as the scene corresponding to a level in the game.

[0108] When the light information of all scene elements in a certain preset sub-scene is obtained, the light information of the preset sub-scene is saved. In this way, after saving the light information of all preset sub-scenes in the virtual scene to the local memory, the light information of the virtual scene is stored in the local memory, and the required light information can be obtained from the local memory. This method can perform light information saving while performing light baking, enabling parallel processing of light information and improving the efficiency of saving the light information of the virtual scene. In addition, the light information saved in the local memory is saved according to the preset sub-scenes in the virtual scene elements, and when the light information of the preset sub-scene needs to be used, the light information of the preset sub-scene can be quickly obtained from the local memory. In the related art, light baking is mostly used for relatively small virtual scenes. When the virtual scene is large, the amount of data and calculation involved in light baking is large, and the hardware resources of the computer device performing light baking are required to be high, making it difficult to ensure the stability of light baking.

[0109] In the above method for light baking of a virtual scene, the scene elements in the virtual scene are divided to obtain a scene tree structure. The target nodes are traversed in the scene tree structure. When the number of elements of the target node and the descendant nodes of the target node meet the baking condition, a baking element set is determined according to the baking elements included in the target node, the ancestor nodes of the target node, and the descendant nodes respectively, so that the number of scene elements in the baking element set is small. The baking element set is subjected to light baking, so that the number of scene elements participating in one light baking is small, the video memory occupancy rate during the light baking process can be reduced, and the stability of the light baking can be improved.

[0110] In some embodiments, after traversing to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship, it further includes: obtaining the number of elements of the target node and the number of elements of the descendant nodes of the target node; performing a summation process on the number of elements of the target node and the number of elements of the descendant nodes to obtain the total number of elements; when the total number of elements belongs to a preset number interval, it is determined that the target node meets the baking condition. The number of object elements in the baking element set can be limited by setting the preset number interval, that is, the number of scene elements participating in one light baking is limited, so that the light baking can be applied to computer devices with different hardware resources and the stability of the light baking is ensured.

[0111] Among them, the total number of elements belonging to the preset number interval is less than the total number of elements not belonging to the preset number interval; when performing light baking, the more the total number of elements, the higher the hardware resources required for light baking. Since the total number of elements belonging to the preset number interval is small, the number of scene elements participating in the light baking can be limited by the baking condition, thereby reducing the hardware resources required for the light baking.

[0112] The preset number interval can be determined according to the hardware resource situation of the computer device performing the light baking. For example, when the hardware computing power of the computer device is low, the number in the preset number interval can be set small, and when the hardware computing power of the computer device is high, the number in the preset number interval can be set large; in this way, the baking element set can be adaptively divided according to the hardware resources of the computer device, and then the light baking can be applied to computer devices with different hardware resources.

[0113] For the traversed target node, the computer device obtains the number of elements of the scene elements in the target node, obtains the number of elements of the scene elements of each descendant node of the target node, takes the sum of the number of elements of the scene elements of each descendant node as the number of elements of the descendant nodes of the target node, sums the number of elements of the scene elements in the target node and the number of elements of the descendant nodes to obtain the total number of elements, and when the total number of elements belongs to the preset number interval, it is determined that the target node meets the baking condition.

[0114] Exemplarily, the preset quantity range is [1, 20], and the scene structure tree is as Figure 4 shown. When the obtained target node is d1, the descendant nodes of the target node d1 include: spatial node d2, spatial node d3, spatial node d4, spatial node d5, spatial node d6, spatial node d7, spatial node d8, spatial node d9, spatial node d10, spatial node d11, spatial node d12, and spatial node d13; the number of elements of the target node d1 is 5, the number of elements of the descendant nodes of the target node d1 is 30, and the total number of elements is 35. Since the total number of elements 35 does not belong to the preset quantity range: [1, 20], the target node d1 does not meet the baking condition.

[0115] When the obtained target node is d2, the descendant nodes of the target node d2 include: spatial node d6, spatial node d7, spatial node d8, and spatial node d9. The number of elements of the target node d2 is 5, the number of elements of the descendant nodes of the target node d2 is 10, and the total number of elements is 15. Since the total number of elements 15 belongs to the preset quantity range: [1, 20], the target node d2 meets the baking condition.

[0116] In the above embodiment, the sum of the number of elements of the target node and the number of elements of the descendant nodes is processed to obtain the total number of elements. When the total number of elements belongs to the preset quantity range, it is determined that the target node meets the baking condition. The number of object elements in the baking element set can be restricted by setting the preset quantity range, that is, the number of scene elements participating in the sequential light baking is restricted, so that the light baking can be applied to computer devices with different hardware resources and the stability of the light baking is ensured.

[0117] In some embodiments, as Figure 5 shown, according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes, the baking element set is determined, including: Step 501, obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node; Step 502, selecting the scene elements to be baked from the scene elements of the ancestor nodes according to the position information; Step 503, determining the baking element set according to the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes. In this way, the scene elements of the ancestor nodes can be divided into different baking element sets, the number of scene elements in the baking element set is restricted, so that the light baking can be applied to computer devices with different hardware resources and the stability of the light baking is ensured.

[0118] Among them, the position information corresponding to the scene element can represent the position of the scene element in the virtual scene; in one implementation, the position information is the position information of the center point of the scene element in the virtual scene; in another implementation, the position information may include the position coordinates of each vertex of the bounding box of the scene element in the virtual scene.

[0119] The scene elements to be baked can be part or all of the scene elements of the ancestor node corresponding to the target node; the baking element set includes the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes.

[0120] In some embodiments, the position information is the position information of the center point of the scene element in the virtual scene; for each scene element of the ancestor node, the computer device obtains the position information of the center point of the scene element in the virtual scene. If the position information is within the corresponding spatial region of the target node in the virtual scene, the scene element is used as the scene element to be baked corresponding to the target node; the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes are combined to obtain the baking element set; according to the position relationship between the center point of the scene element and the corresponding spatial region of the target node in the virtual scene, the scene elements to be baked can be quickly determined.

[0121] In some embodiments, the position information includes the position coordinates of each vertex of the bounding box of the scene element in the virtual scene; the computer device obtains each scene element of the ancestor node of the target node. For each scene element of the ancestor node, the computing device obtains the position coordinates of each vertex of the bounding box of the scene element in the virtual scene. If all the position coordinates are within the corresponding spatial region of the target node in the virtual scene, the scene element is used as the scene element to be baked; or if more than half of the position coordinates are within the corresponding spatial region of the target node in the scene element, the scene element is used as the scene element to be baked; the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes are combined to obtain the baking element set; according to the position relationship between the vertices of the bounding box of the scene element and the corresponding spatial region of the target node in the virtual scene, determining the scene elements to be baked can avoid dividing the same scene element into different baking element sets, thereby avoiding duplicate baking of lighting tasks and improving the efficiency of lighting baking.

[0122] Exemplarily, such as Figure 6As shown in the figure, the target node d1 corresponds to the spatial region A in the virtual scene. For the scene element e1 of the ancestor node d2 of the target node d1, if the position coordinates of the vertices of the bounding box of the scene element e1 in the virtual scene are all within the spatial region A, then the scene element e1 is used as the scene element to be baked; for the scene element e2 of the ancestor node d2 of the target node d1, if the position coordinates of the vertices of the bounding box of the scene element e2 in the virtual scene are not all within the spatial region A, then the scene element e2 is not the scene element to be baked; the baking element set includes: the scene element e1, the scene elements of the target node d1, the scene elements of the child nodes d3, d4, d5, and d6 of the target node d1 respectively, where the child nodes d3, d4, d5, and d6 are the descendant nodes of the target node d1.

[0123] In the above embodiment, according to the position information of the scene elements of the ancestor node, among the scene elements of the ancestor node, the scene elements to be baked belonging to the baking element set corresponding to the target node are obtained. In this way, the scene elements of the ancestor node can be divided into the baking element sets corresponding to different target nodes, avoiding dividing all the scene elements of the ancestor node into the same baking element set, restricting the number of scene elements in the baking element set, enabling light baking to be applied to computer devices with different hardware resources, and ensuring the stability of light baking.

[0124] In some embodiments, obtaining the position information corresponding to the scene elements of the ancestor node of the target node includes: traversing in the scene elements of the ancestor node of the target node to obtain the target scene element; obtaining the position information of the center point of the target scene element in the virtual scene; selecting the scene element to be baked from the scene elements of the ancestor node according to the position information, including: when the position information belongs to the node space of the target node, taking the target scene element as the scene element to be baked. Determining whether the target scene element is the scene element to be baked according to the position relationship between the center point of the target scene element and the node space of the target node reduces the number of position information involved in selecting the scene element to be baked and improves the efficiency of selecting the scene element to be baked.

[0125] Among them, the position information is the position coordinates of the center point of the target scene element in the virtual scene; the node space of the target node represents the spatial region corresponding to the target node in the virtual scene.

[0126] The computer device obtains various scene elements of the ancestor nodes of the target node, traverses the various scene elements to obtain the target scene element, the computer device obtains the position information of the center point of the target scene element in the virtual scene, obtains the position information of the node space of the target node in the corresponding spatial area in the virtual scene, and determines whether the center point of the target scene element is within the node space of the target node according to the position information of the center point in the virtual scene and the position information of the node space in the corresponding spatial area in the virtual scene. If the center point of the target scene element is within the node space of the target node, the target scene element is used as the scene element to be baked. It can be understood that when the center point of the target scene element is within the node space of the target node, it means that most of the content of the target scene element is within the node space of the target node. Therefore, the target scene element can be used as the scene element to be baked in the baking element set corresponding to the target node.

[0127] Exemplarily, as Figure 6 shown, the target node d1 corresponds to the spatial area A in the virtual scene. For the scene element e1 of the ancestor node d1 of the target node d1, the position information of the center point of the scene element e1 is within the spatial area A, then the scene element e1 is used as the scene element to be baked; for the scene element e2 of the ancestor node d1 of the target node d1, the position information of the center point of the scene element e2 is not within the spatial area A, then the scene element e2 is not the scene element to be baked; the baking element set includes: the scene element e1, the scene element of the target node d1, the scene elements of the child nodes d3, d4, d5, and d6 of the target node d1 respectively, where the child nodes d3, d4, d5, and d6 are the descendant nodes of the target node d1.

[0128] In the above embodiment, only the position relationship between the center point of the target scene element and the node space of the target node needs to be used to determine whether the target scene element is the scene element to be baked, reducing the number of position information involved in selecting the scene element to be baked, thereby reducing the calculation amount required for selecting the scene element to be baked and improving the efficiency of selecting the scene element to be baked.

[0129] In some embodiments, the method for baking lighting in a virtual scene further includes: obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node; determining a baking element set based on the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes, including: when no scene element to be baked is selected from the scene elements of the ancestor nodes based on the position information, determining the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes. The baking element set does not include the scene elements of the ancestor nodes, which limits the number of scene elements in the baking element set, enables lighting baking to be applied to computer devices with different hardware resources, and ensures the stability of lighting baking.

[0130] Among them, the position information corresponding to the scene elements of the ancestor nodes may include the position coordinates of the center point of the scene element in the virtual scene; or, it may also include the position coordinates of the vertices of the bounding box of the scene element in the virtual scene.

[0131] When no scene element to be baked is selected from the scene elements of the ancestor nodes based on the position information, the baking element set includes the scene elements of the target node and the scene elements of the descendant nodes.

[0132] Among them, the process of obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node is the same as the process of obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node in the previous embodiments. Therefore, reference can be made to the description of obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node in the previous embodiments.

[0133] The position information may be the position information of the center point of the scene element in the virtual scene; for each scene element of the ancestor node, the computer device obtains the position information of the center point of the scene element in the virtual scene. If the position information does not belong to the node space of the target node, then the scene element is not a baking scene element of the target node; if the position information of the center point of each scene element in the ancestor node does not belong to the node space of the target node, it means that no scene element to be baked is selected from the scene elements of the ancestor nodes based on the position information. Furthermore, the baking element set includes the scene elements of the target node and the scene elements of the descendant nodes.

[0134] The location information may further include the position coordinates of each vertex of the bounding box of the scene element in the virtual scene; for each scene element of the ancestor node, the computing device obtains the position coordinates of each vertex of the bounding box of the scene element in the virtual scene. If none of the position coordinates are within the corresponding spatial region of the target node in the virtual scene, then the scene element is a scene element to be baked that is not the target node; if each scene element in the ancestor node is not a scene element to be baked of the target node, it means that no scene element to be baked is selected from the scene elements of the ancestor node. Furthermore, the baking element set includes the scene elements of the target node and the scene elements of the descendant nodes.

[0135] Exemplarily, as Figure 7 shown, the target node d7 corresponds to the spatial region B in the virtual scene. For the scene element e3 of the ancestor node d8 of the target node d7, the position information of the center point of the scene element e3 is not within the spatial region B, so the scene element e3 is not a scene element to be baked; for the scene element e4 of the ancestor node d8, the position information of the center point of the scene element e4 is not within the spatial region B, so the scene element e4 is not a scene element to be baked. All the scene elements (e3 and e4) of the ancestor node d8 are not scene elements to be baked, so the baking element set includes: the scene elements of the target node d7, the scene elements of the child nodes d9, d10, d11, and d12 of the target node d7 respectively, where the child nodes d9, d10, d11, and d12 are the descendant nodes of the target node d1.

[0136] In the above embodiment, when no scene element to be baked is selected from the scene elements of the ancestor node, the baking element set is determined according to the scene elements of the target node and the scene elements of the descendant nodes, which limits the number of scene elements in the baking element set, enables light baking to be applied to computer devices with different hardware resources, and ensures the stability of light baking.

[0137] In some embodiments, such as Figure 8As shown, the virtual scene is divided into scenes according to scene elements to obtain a scene tree structure, including: Step 801, generating an initial scene tree structure; Step 802, obtaining the scene elements to be added in the scene elements, traversing the initial nodes corresponding to the scene elements to be added in the initial scene tree structure, and obtaining the node types of the initial nodes; Step 803A, when the node type is the leaf node type, when the scene elements to be added do not meet the element addition conditions, the initial nodes are split into child nodes to update the initial scene tree structure, select the child node corresponding to the scene elements to be added from the split child nodes as the initial node, and return to execute the step of obtaining the node type of the initial node; Step 803B, when the node type is the leaf node type, when the scene elements to be added meet the element addition conditions, add the scene elements to be added to the initial node to update the initial scene tree structure, and return to execute the step of traversing to obtain the scene elements to be added in the scene elements; Step 804, after completing the traversal of the scene elements, use the updated initial scene tree structure as the scene tree structure. Through the scene tree structure, the scene elements are finely divided into the sub-spaces of the virtual scene. When obtaining the baking element set for light baking based on the scene tree structure later, the situation of repeatedly dividing the same scene element into different baking element sets can be avoided, thereby reducing the repeated baking tasks in light baking, saving hardware resources, and improving the light baking efficiency.

[0138] Among them, the generated initial scene tree structure includes a root node, which can be understood as generating the root node corresponding to the virtual scene, and using this root node as the initial scene tree structure; the scene elements to be added are one of the various scene elements of the virtual scene.

[0139] It should be noted that dividing the virtual scene into scenes according to scene elements to obtain a scene tree structure means splitting the nodes in the initial scene tree structure, and during the node splitting process, adding the scene elements to the nodes of the initial scene tree structure to obtain the scene tree structure; adding a scene element to the nodes of the initial scene tree structure may involve multiple node splits, multiple updates of the initial nodes, and multiple updates of the initial scene tree structure.

[0140] The node type of the initial node refers to the node type of the initial node in the current initial scene tree structure. The node type is the leaf node type or not the leaf node type; when the node type of the initial node is the leaf node type, it means that the initial node is a leaf node in the current initial scene tree structure, or it means that there are no child nodes for the initial node in the current initial scene tree structure.

[0141] When adding the first scene element to be added to the initial scene tree structure, the initial node obtained for the first time is the root node. Since the root node included in the current initial scene tree structure has no child nodes, the node type of the initial node is the leaf node type.

[0142] The element addition condition is the condition for adding the scene element to be added to the initial node. It can be determined whether the scene element to be added meets the element addition condition based on the initial node. Exemplarily, the element addition condition can be that the space corresponding to the scene element to be added in the virtual scene occupies a preset percentage of the space corresponding to the initial node in the virtual scene; or, the element addition condition can be that when the element type of the scene element to be added is the first type, the space corresponding to the scene element to be added in the virtual scene occupies a first preset percentage of the space corresponding to the initial node in the virtual scene; or, the element addition condition can be that when the element type of the scene element to be added is the second type, the space corresponding to the scene element to be added in the virtual scene occupies a second preset percentage of the space corresponding to the initial node in the virtual scene.

[0143] Among them, when the element type of the scene element to be added is the first type, it means that the scene element to be added is a scene object; when the element type of the scene element to be added is the second type, it means that the scene element to be added is a light map task or a light probe task.

[0144] It should be noted that in the above examples, the specific values of the preset percentage, the first preset percentage, and the second preset percentage can all be set according to requirements, and the embodiments of the present application do not limit this.

[0145] Among them, when the scene tree structure is a quadtree structure, the initial node can be split into four child nodes; when the scene tree structure is an octree structure, the initial node can be split into eight child nodes.

[0146] The computer device generates a root node corresponding to the virtual scene, uses this root node as the initial scene tree structure; traverses the scene elements in the virtual scene to obtain the scene element to be added, uses the root node as the initial node, and obtains that the node type of the initial node is the leaf node type.

[0147] The computer device determines whether the scene element to be added meets the element addition condition based on the initial node. When the scene element to be added does not meet the element addition condition, the initial node is split into child nodes to update the initial scene tree structure. The updated initial scene tree structure includes the initial node and the child nodes obtained by splitting the initial node. Among the split child nodes, the child node corresponding to the scene element to be added is selected as the initial node, that is, the initial node is replaced with the child node corresponding to the scene element to be added. Herein, the child node corresponding to the scene element to be added refers to the child node whose corresponding spatial region in the virtual scene includes the scene element to be added.

[0148] For ease of explanation, the initial node before node splitting is denoted as the first initial node, and the child node corresponding to the scene element is denoted as the second initial node. After obtaining the second initial node, the step of obtaining the node type of the initial node is returned for execution. Since the second initial node is obtained by splitting the first initial node and the second initial node has no child nodes, the type of the second initial node is the leaf node type. The computer device determines whether the scene element to be added meets the element addition condition based on the second initial node. When the scene element to be added meets the element addition condition, the scene element to be added is added to the second initial node to update the initial scene tree structure, and the step of traversing the scene elements to obtain the scene element to be added is returned for execution to add the next scene element to be added obtained by traversing to the initial node. Similarly, adding the next scene element to be added obtained by traversing to the initial node may involve multiple node splits, multiple updates of the initial node, and multiple updates of the initial scene tree structure. After completing the traversal of all scene elements in the virtual scene, that is, after adding all scene elements to the initial node, the updated initial scene tree structure is used as the scene tree structure.

[0149] In some embodiments, since the illumination of a scene element is affected by surrounding scene elements, such as occlusion or reflection, the scene element can be extended to avoid the influence of the illumination of the scene element by surrounding scene elements. The computer device extends the scene element and updates the scene element with the extended scene element.

[0150] Extending the scene element includes extending the scene object, the light mapping task, and the light probe task. Specifically, the computer device can obtain the bounding box of the scene object, extend the bounding box of the scene object according to the light extension coefficient to obtain the extended scene object, obtain the light mapping task, extend the light mapping task according to the light extension coefficient to obtain the extended light mapping task, obtain the light probe task, and extend the light probe task according to the light extension coefficient to obtain the extended light probe task.

[0151] Among them, the lighting expansion coefficient can be the number of lighting expansion grids or the lighting expansion grid multiple; a grid is a unit for measuring the space occupied by scene elements in a virtual scene. Taking the expansion of a scene object as an example, according to the lighting expansion coefficient, the bounding box of the scene object is expanded, which can be to expand the length and width of the bounding box of the scene object according to the number of lighting expansion grids or the lighting expansion grid multiple.

[0152] Expanding the length and width of the bounding box of the scene object according to the number of lighting expansion grids can be to increase both the length and width of the bounding box of the scene object by the number of lighting expansion grids; expanding the length and width of the bounding box of the scene object according to the lighting expansion grid multiple can be to multiply both the length and width of the bounding box of the scene object by the lighting expansion grid multiple.

[0153] Exemplarily, a computer device can set the lighting expansion coefficient through the configuration interface of lighting baking. The configuration interface of lighting baking is as Figure 9 shown, where the lighting expansion grid multiple is 1 and the number of lighting expansion grids is 100; both the length and width of the bounding box of the scene object are 2000 grids, the number of lighting expansion grids is 100, and both the length and width of the bounding box of the expanded scene object are 2100 grids.

[0154] In some embodiments, the scene tree structure is a quadtree structure; the computer device takes the horizontal plane of the virtual scene as the scene division plane and divides the virtual scene according to the scene division plane; the horizontal plane of the virtual scene is the plane formed by the X-axis and Y-axis of the created virtual scene; in the scene division plane, the bounding box of the scene object, the lighting mapping task, and the lighting probe task are determined, and the virtual scene is divided according to the bounding box of the scene object, the lighting mapping task, and the lighting probe task in the scene division plane to obtain the scene tree structure of the quadtree; dividing the scene according to the form of the quadtree structure can improve the efficiency of constructing the scene tree structure, and subsequent efficiency of obtaining the baking element set in the scene tree structure of the quadtree can also be improved.

[0155] In some embodiments, the scene tree structure is an octree structure; the computer device divides the space corresponding to the virtual scene according to the scene elements in the virtual scene; the space corresponding to the virtual scene is the space formed by the X-axis, Y-axis, and Z-axis of the created virtual scene; determine the bounding box, light mapping task, and light probe task of the scene object in the space corresponding to the virtual scene, and divide the bounding box, light mapping task, and light probe task of the scene object in the space corresponding to the virtual scene to obtain the scene tree structure of the octree; according to the form of the octree structure for scene division, the scene elements can be finely divided into the sub-spaces of the virtual scene. Subsequently, when obtaining the baked element set in the scene tree structure of the octree structure, the situation of repeatedly dividing the same scene element into different baked element sets can be avoided, improving the accuracy of obtaining the baked element set.

[0156] Taking the case where the scene tree structure is a quadtree structure and the scene elements to be added obtained from the first traversal are added to the initial node as an example for illustration; as Figure 10 shown, generate the initial scene tree structure t1. The initial scene tree structure t1 includes the root node d1. After traversing to obtain the scene element e1 to be added, use the root node d1 as the initial node; the node type of the initial node d1 is the leaf node type. According to the initial node d1, determine whether the scene element e1 to be added meets the element addition condition. When it does not meet the element addition condition, split the initial node d1 to obtain the child nodes d2, d3, d4, and d5, so as to update the initial scene tree structure t1 to the initial scene tree structure t2; select the corresponding child node d2 of the scene element e1 to be added from the child nodes d2, d3, d4, and d5, use the child node d2 as the initial node, and return to execute the step of obtaining the node type of the initial node; the node type of the initial node d2 is the leaf node type. According to the initial node d2, determine whether the scene element e1 to be added meets the element addition condition. When it meets the element addition condition, add the scene element e1 to the initial node d2, so as to update the initial scene tree structure t2 to the initial scene tree structure t3.

[0157] In the above embodiments, the nodes in the initial scene tree structure are split, and during the node splitting process, the scene elements are added to the nodes of the initial scene tree structure to obtain the scene tree structure, which is convenient for subsequently obtaining the baked element set for light baking based on the scene tree structure. Since the scene tree structure realizes the fine division of the scene elements into the sub-spaces of the virtual scene, when subsequently obtaining the baked element set for light baking based on the scene tree structure, the situation of repeatedly dividing the same scene element into different baked element sets can be avoided, thereby reducing the repeated baking tasks in light baking, saving hardware resources, and improving the light baking efficiency.

[0158] In some embodiments, the element addition conditions include a first element addition condition or a second element addition condition; after obtaining the node type of the initial node, it further includes: when the node type is a leaf node type, obtaining the node space of the target node, the element type of the scene element to be added, and the element space; when the element type is an object type and the node space meets the first space division condition, it is determined that the scene element to be added does not meet the first element addition condition; or, when the element type is a lighting task type and the element space and the node space meet the second space division condition, it is determined that the scene element to be added does not meet the second element addition condition. By using different methods to determine that the scene element to be added does not meet the element addition condition according to the element type of the scene element to be added, it is possible to targetedly add elements to scene objects, light mapping tasks, and light probe tasks, improving the accuracy of scene division.

[0159] Among them, the node space of the target node is the space corresponding to the target node in the virtual scene, and the element space of the scene element to be added is the space occupied by the scene element to be added in the virtual scene; the element type of the scene element to be added can be an object type or a lighting task type; when the element type of the scene element to be added is an object type, it means that the scene element to be added is a scene object, and when the element type of the scene element to be added is a lighting task type, it means that the scene element to be added is a light mapping task or a light probe task.

[0160] The node space meeting the first space division condition can be that the size of the node space does not belong to the preset space size interval, and the size of the node space that does not belong to the preset space size interval is larger than the size of the node space that does not belong to the preset space size interval; exemplarily, the preset space size interval is [0, minimum space size of child nodes], and when the size of the node space is larger than the minimum space size of child nodes, the node space meets the first space division condition; the minimum space size of child nodes can be set according to actual needs.

[0161] The element space and the node space meeting the second space division condition can be that the proportion of the element space occupying the node space does not reach the third preset percentage; among them, the proportion of the element space occupying the node space not reaching the third preset percentage can indicate that the element space occupies a relatively small space in the node space. The third preset percentage can be set according to actual needs, and exemplarily, the third preset percentage can be 80%.

[0162] For the initial node, when the node type of the initial node is the leaf node type, obtain the element type of the scene element to be added. If the element type of the scene element to be added is the object type and the size of the node space of the initial node does not belong to the preset space size range, it is determined that the scene element to be added does not meet the first element addition condition; if the element type of the scene element to be added is the lighting task type and the proportion of the element space of the scene element to be added occupying the node space does not reach the third preset percentage, it is determined that the scene element to be added does not meet the second element addition condition.

[0163] When the scene element to be added does not meet the first element addition condition or does not meet the second element addition condition, perform node splitting on the initial node.

[0164] In the above embodiment, by using different methods to determine that the scene element to be added does not meet the element addition condition according to the element type of the scene element to be added, it is possible to targetedly add elements to the scene object, light mapping task, and light probe task, improving the accuracy of scene division.

[0165] In some embodiments, the element addition condition includes the first element addition condition or the second element addition condition; after obtaining the node type of the initial node, it further includes: when the node type is the leaf node type, obtaining the node space of the target node, the element type and the element space of the scene element to be added; when the element type is the object type and the node space does not meet the first space division condition, it is determined that the scene element to be added meets the first element addition condition; or when the element type is the lighting task type and the element space and the node space do not meet the second space division condition, it is determined that the scene element to be added meets the second element addition condition. By using different methods to determine that the scene element to be added does not meet the element addition condition according to the element type of the scene element to be added, it is possible to targetedly add elements to the scene object, light mapping task, and light probe task, improving the accuracy of scene division.

[0166] Among them, the node space not meeting the first space division condition may be that the size of the node space belongs to the preset space size range, and the size of the node space belonging to the preset space size range is smaller than the size of the node space not belonging to the preset space size range; for example, the preset space size range is [0, minimum space size of the child node], and when the size of the node space is less than or equal to the minimum space size of the child node, the node space does not meet the first space division condition.

[0167] The element space and the node space do not meet the second space division condition. It can be that the proportion of the element space occupying the node space reaches a third preset percentage. Among them, when the proportion of the element space occupying the node space reaches the third preset percentage, it can indicate that the element space occupies a larger space in the node space. The third preset percentage can be set according to actual needs. Exemplarily, the third preset percentage can be 80%.

[0168] It should be noted that when the element type is a lighting task type, the scene element to be added will be affected by the light bounce of the surrounding elements. If the proportion of the element space of the scene element to be added occupying the node space reaches the third preset percentage, it means that all other elements in the node space except the scene element to be added will cause light bounce effects on the scene element to be added. The initial node does not need to be split, and the scene element to be added can be directly added to the initial node, and the light bounce effects caused by other elements on the scene element to be added can be retained, making the light baking of the scene element to be added more accurate.

[0169] For the initial node, when the node type of the initial node is a leaf node type, obtain the element type of the scene element to be added. If the element type of the scene element to be added is an object type, and the size of the node space of the initial node belongs to a preset space size range, it is determined that the scene element to be added meets the first element addition condition; if the element type of the scene element to be added is a lighting task type, and the proportion of the element space of the scene element to be added occupying the node space reaches the third preset percentage, it is determined that the scene element to be added meets the second element addition condition.

[0170] When the scene element to be added meets the first element addition condition or the second element addition condition, add the scene element to be added to the initial node.

[0171] In the above embodiments, different methods are used to determine that the scene element to be added does not meet the element addition condition according to the element type of the scene element to be added, which can achieve targeted element addition for scene objects, light mapping tasks, and light probe tasks, improving the accuracy of scene division.

[0172] In some embodiments, after obtaining the node type of the initial node, the method further includes: when the node type is not a leaf node type, obtaining a target sub-node corresponding to the scene element to be added from each sub-node of the target node; when the number of target sub-nodes does not meet the intersection condition, using the target sub-node as the initial node obtained by traversal, and returning to execute the step of obtaining the node type of the initial node. It is possible to layer by layer determine the nodes for adding the scene elements to be added in the initial scene tree structure, which realizes the fine division of the scene elements into the sub-spaces of the virtual scene. When subsequently obtaining the baking element set for light baking based on the scene tree structure, it is possible to avoid the situation of repeatedly dividing the same scene element into different baking element sets, thereby reducing the repeated baking tasks in light baking, saving hardware resources, improving the light baking efficiency, and the stability of light baking.

[0173] Among them, when the initial node has sub-nodes, the node type of the initial node is not a leaf node type.

[0174] During the process of adding the first scene element to be added to the initial scene tree structure, the initial scene structure tree may be updated, such as splitting the root node to obtain sub-nodes. Therefore, when adding the second scene element to be added to the initial scene tree structure, the initially obtained initial node is the root node, and the root node included in the current initial scene tree structure may have sub-nodes. Therefore, the node type of the initial node may not be a leaf node type.

[0175] The target sub-node is a sub-node whose node space intersects with the element space of the scene element to be added; that the target sub-node meets the intersection condition means that there are at least two node spaces corresponding to the target sub-nodes that intersect with the element space of the scene element to be added. Therefore, the number of target sub-nodes meeting the intersection condition can be that the number of target sub-nodes is greater than 1. On the contrary, the number of target sub-nodes not meeting the intersection condition can be that the number of target sub-nodes is equal to 1.

[0176] When the initial node has sub-nodes, it is determined that the node type of the target node is not a leaf node type. The computer device obtains the node spaces of each sub-node of the target node, and obtains the element space of the scene element to be added. For the node space of each sub-node, when the node space of the sub-node intersects with the element space of the scene element to be added, the sub-node is used as a target sub-node; the computer device counts the number of target sub-nodes. When the number of target sub-nodes is equal to 1, it is determined that the number of target nodes does not meet the intersection condition, and this one target sub-node is used as the initial node, that is, the initial node is updated, and the step of obtaining the node type of the initial node is returned for execution; it can be understood that after returning to execute the step of obtaining the node type of the initial node, the node type of the initial node may be a leaf node type or not a leaf node type.

[0177] Exemplarily, when traversing the scene elements to obtain the scene element e2 to be added, the initial scene tree structure is as follows Figure 10 shown. Taking the root node d1 of the initial scene tree structure as the initial node, since the initial node d1 has child nodes, the node type of the initial node d1 is not the leaf node type. Obtain the child nodes of the initial node d1, which are: child node d2, child node d3, child node d4, and child node d4. For each child node of the initial node d1, determine whether the node space of the child node intersects with the element space of the scene element e2 to be added. If they intersect, take the child node as the target child node. In this example, the target child node includes child node d2. The computer device counts that the number of target child nodes is 1, determines that the number of target child nodes does not meet the intersection condition, takes the child node d2 as the initial node, and continues to obtain the node type of the initial node d2. In this example, the node type of the initial node d2 is the leaf node type, and the computer device determines whether the scene element e2 to be added meets the element addition condition.

[0178] When the scene element e2 to be added meets the element addition condition, add the scene element e2 to be added to the initial node d2; return to execute the step of traversing the scene elements to obtain the scene element to be added.

[0179] When the scene element e2 to be added does not meet the element addition condition, split the initial node d2. Obtain the child node of the scene element to be added from the split child nodes, and take the obtained child node as the initial node. In this way, through layer-by-layer node splitting, the initial node for adding the scene element e2 to be added can be obtained, and then return to execute the step of traversing the scene elements to obtain the scene element to be added.

[0180] After adding the initial node for adding the scene element e2 to be added, traverse to obtain the scene element e3 to be added, and process the scene element e3 to be added according to the above process, and add the scene element e3 to be added to the initial node.

[0181] In the above embodiment, when the node type is not the leaf node type, and among the child nodes of the initial node, the number of target child nodes of the scene element to be added does not meet the intersection condition, take the target child node as the initial node, and return to execute the step of obtaining the node type of the initial node. It is possible to layer-by-layer determine the node for adding the scene element to be added in the initial scene tree structure, realizing the fine division of the scene element into the sub-space of the virtual scene. When subsequently obtaining the baking element set for light baking based on the scene tree structure, it is possible to avoid the situation of repeatedly dividing the same scene element into different baking element sets, thereby reducing the repeated baking tasks in light baking, saving hardware resources, improving the light baking efficiency, and the stability of light baking.

[0182] In some embodiments, when the node type is not the leaf node type, after obtaining the target child node corresponding to the scene element to be added among the child nodes of the target node, it further includes: when the number of target child nodes meets the intersection condition, adding the scene element to be added to the initial node to update the initial scene tree structure, and returning to execute the step of traversing the scene elements to obtain the scene element to be added. This avoids the scene element to be added being repeatedly added to different child nodes, thereby reducing the repeated baking tasks in light baking, saving hardware resources, and improving the light baking efficiency.

[0183] Among them, the number of target child nodes meeting the intersection condition means that the number of target child nodes is greater than 1.

[0184] In some embodiments, when the initial node has child nodes, it is determined that the node type of the target node is not the leaf node type. The computer device obtains the node spaces of the child nodes of the target node and the element space of the scene element to be added. For the node space of each child node, when the node space of the child node intersects with the element space of the scene element to be added, that child node is used as the target child node; the computer device counts the number of target child nodes. When the number of target child nodes is greater than 1, it is determined that the number of target nodes meets the intersection condition, the scene element to be added is added to the initial node, and the step of traversing the scene elements to obtain the scene element to be added is returned to execute the above process for the next scene element to be added, and the next scene element to be added is added to the node of the initial scene tree structure.

[0185] It should be noted that when the number of child nodes in the initial node whose node spaces intersect with the element space of the scene element to be added is greater than 1, if the scene element to be added is added to the child nodes of the initial node, it will cause the scene element to be added to be repeatedly added to the child nodes, and thus there will be duplicate scene elements in the baking element set, resulting in repeated baking tasks in light baking.

[0186] Exemplarily, when traversing the scene elements to obtain the scene element to be added e2, the initial scene tree structure is as Figure 10As shown by t3 in , the root node d1 of the initial scene tree structure is used as the initial node. Since the initial node d1 has child nodes, the node type of the initial node d1 is not a leaf node type. Obtain the child nodes of the initial node d1, which are: child node d2, child node d3, child node d4, and child node d4. For each child node of the initial node d1, determine whether the node space of the child node intersects with the element space of the scene element e2 to be added. If they intersect, the child node is used as the target child node. In this example, the target child nodes include child node d2 and child node d3. The computer device counts that the number of target child nodes is 2, determines that the number of target child nodes meets the intersection condition, adds the scene element e2 to be added to the initial node d2, and returns to execute the step of traversing the scene elements to obtain the scene element to be added.

[0187] After adding the initial node with the scene element e2 to be added, traverse to obtain the scene element e3 to be added, and process the scene element e3 to be added according to the above process, and add the scene element e3 to be added to the initial node.

[0188] In the above embodiment, when the number of target child nodes meets the intersection condition, the scene element to be added is added to the initial node, which avoids the scene element to be added being repeatedly added to different child nodes, thereby reducing the repeated baking tasks in light baking, saving hardware resources, and improving the light baking efficiency.

[0189] In some embodiments, after obtaining the light information of the baking element set, it further includes: obtaining the light information of all scene elements in the preset sub-scene of the virtual scene based on the light information of the baking element set, and saving the light information of all scene elements in the preset sub-scene. In this way, while performing light baking, the light information is saved, that is, the parallel processing of light information is realized, and the efficiency of saving the light information of the virtual scene is improved. In addition, the light information saved in the local memory is saved according to the preset sub-scene in the virtual scene elements. When the light information of the preset sub-scene is needed, the light information of the preset sub-scene can be quickly obtained from the local memory.

[0190] Among them, the number of preset sub-scenes can be multiple, and each preset sub-scene is a part of the virtual scene. The virtual scene includes multiple preset sub-scenes. In practical applications, the game includes multiple levels, and the virtual scene of the game includes the preset sub-scenes corresponding to each level; or, the game includes multiple sub-maps, and the virtual scene of the game includes the preset sub-scenes corresponding to each sub-map.

[0191] The lighting information of all scene elements in the preset sub-scene, including the lighting information corresponding to the light mapping task in the preset sub-scene and the lighting information corresponding to the light probe task in the preset sub-scene; the lighting information corresponding to the light mapping task in the preset sub-scene is the lighting information on the surface of the scene object associated with the light mapping task in the preset sub-scene, and the lighting information corresponding to the light probe task in the preset sub-scene is the lighting information at the spatial position where the light probe task is located in the preset sub-scene.

[0192] In some embodiments, the computer device performs light baking on each baking element set in sequence to obtain the lighting information of each baking element set in sequence; when obtaining the lighting information of a baking element set, the lighting information belonging to each preset sub-scene is obtained from the lighting information of the baking element set, and after obtaining the complete lighting information of a preset sub-scene, the complete lighting information of the preset sub-scene is saved to the local memory, so that when the lighting information of the scene element needs to be used subsequently, the lighting information can be obtained from the memory; after saving the lighting information of each preset sub-scene, the memory resources required to store the lighting information of the preset sub-scene can be released in a timely manner, so that when saving the lighting information of other preset sub-scenes, there is sufficient available memory space, avoiding the situation of insufficient memory when saving the lighting information of the entire virtual scene.

[0193] Exemplarily, after obtaining the lighting information of the baking element set B1, the first part of the lighting information of the preset sub-scene L1 and the first part of the lighting information of the preset sub-scene L2 can be obtained from the lighting information of the baking element set B1; after obtaining the lighting information of the baking element set B2, the second part of the lighting information of the preset sub-scene L1 and the first part of the lighting information of the preset sub-scene L3 can be obtained from the lighting information of the baking element set B2; according to the first part of the lighting information of the preset sub-scene L1 and the second part of the lighting information of the preset sub-scene L1, the complete lighting information of the preset sub-scene L1 is obtained. It can be understood that the complete lighting information of the preset sub-scene L1 is obtained from the lighting information of the baking element set B1 and the baking element set B2; the computer device saves the complete lighting information of the preset sub-scene L1.

[0194] In the above embodiments, while performing light baking, the lighting information is saved, that is, the parallel processing of the lighting information is realized, and the efficiency of saving the lighting information of the virtual scene is improved. In addition, the lighting information saved in the local memory is saved according to the preset sub-scenes in the virtual scene elements. When the lighting information of the preset sub-scene needs to be used, the lighting information of the preset sub-scene can be quickly obtained from the local memory.

[0195] In some embodiments, the number of preset sub - scenes is at least two; obtaining the lighting information of all scene elements in the preset sub - scenes of the virtual scene based on the lighting information of the baking element set, and saving the lighting information of all scene elements in the preset sub - scenes, including: obtaining the sub - scene identifier of each scene element in the baking element set; in the lighting information of each scene element in the baking element set, obtaining the lighting information of the scene elements in each preset sub - scene according to each sub - scene identifier; when obtaining the lighting information of all scene elements in any preset sub - scene, saving the lighting information of all scene elements in any preset sub - scene. Saving the lighting information of the preset sub - scenes while performing lighting baking, compared with saving the lighting information of the entire virtual scene after obtaining the lighting information of the entire virtual scene, avoids the situation of insufficient memory when saving the lighting information of the entire virtual scene, and solves the problem that the lighting baking of the virtual scene is restricted by hardware resources.

[0196] Among them, the sub - scene identifier is used to reflect the preset sub - scene to which the scene element belongs; for example, when the scene element e1 belongs to the preset sub - scene level1, the sub - scene identifier of the scene element e1 can be level1; when the scene element e2 belongs to the preset sub - scene level2, the sub - scene identifier of the scene element e2 can be level2; it should be noted that level can represent the level in the game, and the preset sub - scene level1 can be the sub - scene of the first level in the virtual scene of the game.

[0197] The computer device can pre - add sub - scene identifiers to each scene element and generate a lighting information set for each preset sub - scene. The lighting information set of the preset sub - scene includes the sub - scene identifiers of the scene elements in the preset sub - scene. It should be noted that in the lighting information set of the preset sub - scene, the sub - scene identifier of the scene element is specifically the sub - scene identifier of the light mapping task and the light probe task in the preset sub - scene.

[0198] The lighting information of the baking element set includes the lighting information of the light mapping task and the lighting information of the light probe task. The computer device obtains the sub - scene identifiers of the light mapping task and the light probe task, and divides the lighting information of the light mapping task and the lighting information of the light probe task into the lighting information sets of each preset sub - scene according to the sub - scene identifiers in the lighting information sets of each preset sub - scene. When the lighting information set of a certain preset sub - scene includes the lighting information of all light mapping tasks and light probe tasks in the preset sub - scene, save the lighting information set of a certain preset sub - scene to the memory.

[0199] In some embodiments, after saving the lighting information of all scene elements in any preset sub-scene, the memory resources used to store the lighting information of the preset sub-scene are released; wherein, releasing the memory resources used to store the lighting information of the preset sub-scene may be that the computer device transfers the lighting information of the preset sub-scene to a storage server or an external storage device, so that the computer device has sufficient memory resources to save the lighting information of other preset sub-scenes, avoiding the situation of insufficient memory when saving the lighting information, and solving the problem that the lighting baking of the virtual scene is restricted by hardware resources.

[0200] Exemplarily, in the related art, usually after all lighting baking tasks of the virtual scene are completed, all the lighting information of the obtained virtual scene is exported to the local memory. However, in the embodiments of the present application, as Figure 11 shown, the number of baking element sets determined according to the scene tree structure can be multiple: baking element set H1, baking element set H2,..., baking element set Hn; the multiple baking element sets are sequentially subjected to lighting baking. When the lighting baking of each baking element set is completed, the lighting information of the baking element set is divided into the lighting information sets of each preset sub-scene. During the sequential lighting baking of each baking element set, the complete lighting information of each preset sub-scene can be gradually obtained. Whenever the complete lighting information of a preset sub-scene is obtained, first save the complete lighting information of the preset sub-scene and release the memory resources used to store the complete lighting information of the preset sub-scene; for example, when all the lighting information of the preset sub-scene level1 is obtained, save all the lighting information of the preset sub-scene level1 to the local memory and release the memory resources used to store the lighting information of the preset sub-scene level1. When all the lighting information of the preset sub-scene level2 is obtained, save all the lighting information of the preset sub-scene level2 to the local memory.

[0201] In the above embodiments, the lighting information of the preset sub-scene can be saved while performing lighting baking. Compared with saving the lighting information of the entire virtual scene after obtaining the lighting information of the entire virtual scene, it avoids the situation of insufficient memory when saving the lighting information of the entire virtual scene, and solves the problem that the lighting baking of the virtual scene is restricted by hardware resources.

[0202] In some embodiments, as Figure 12 shown, the lighting baking method of the virtual scene can be applied to the scene of lighting baking of the virtual scene of an open-world game.

[0203] Obtain various scene elements in the virtual scene of the open-world game, including scene objects, light baking tasks, and light probe tasks in the virtual scene. Divide the virtual scene of the open-world game according to the scene elements to obtain a scene tree structure in a quadtree structure. The scene tree structure includes multiple spatial nodes, and some or all of the multiple spatial nodes include at least one scene element. The scene tree structure can be referred to Figure 4 。

[0204] Traverse the spatial nodes of the scene tree structure to obtain the target node d2. When it is determined that the target node d2 meets the baking condition based on the number of elements in the target node d2 and the number of elements in the descendant nodes of the target node d2, determine the baking element set H1 according to the scene elements of the target node d2, the scene elements of the ancestor nodes of the target node d2, and the scene elements of the descendant nodes. In this example, the ancestor node of the target node d2 is the node d1, and the descendant nodes of the target node d2 are the nodes d6, d7, d8, and d9. The baking element set H1 includes: scene element e1, scene element e2, scene element e3, and scene element e4.

[0205] In the same way, it can be determined that the baking element set H2 of the target node d3 includes: scene element e5, scene element e6, scene element e7, and scene element e8.

[0206] Perform light baking on the baking element set H1 and the baking element set H2 in sequence. After obtaining the light information of the baking element set H1, obtain the light information of the scene elements in the preset sub-scene level1 and the light information of the scene elements in the preset sub-scene level2 from the light information of the baking element set H1;

[0207] In this example, the scene elements in the preset sub-scene level1 include scene element e1 and scene element e2; the scene elements in the preset sub-scene level2 include scene element e3, scene element e4, scene element e5, scene element e6, scene element e7, and scene element e8.

[0208] All the light information of the preset sub-scene level1 can be obtained according to the light information of the baking element set H1. Save the light information of the preset sub-scene level1 and release the memory resources used to store the light information of the preset sub-scene level1.

[0209] According to the lighting information of the baking element set H1, the lighting information of the scene elements e3 and e4 in the preset sub-scene level2 can be obtained. After completing the lighting baking of the baking element set H2, the lighting information of the baking element set H2 can be obtained, and the lighting information of the scene elements e5, e6, e7, and e8 in the preset sub-scene level2 can be obtained. Furthermore, all the lighting information of the preset sub-scene level2 can be obtained, and the lighting information of the preset sub-scene level2 is saved.

[0210] In practical applications, for a virtual scene design of an open game with 520,000 lighting map tasks and 2.7 million scene objects, the effects of directly performing lighting baking on the entire virtual scene and using the method provided in the embodiments of the present application for lighting baking are compared as Figure 13 shown. Figure 13 In each dashed box in, on the left is the situation of performing lighting baking on all scene elements of the virtual scene, and on the right is the situation of performing lighting baking using the method provided in the embodiments of the present application. Obviously, using the method provided in the embodiments of the present application can significantly reduce the video memory occupancy and memory occupancy. The occupancy of video memory and memory by the method provided in the embodiments of the present application enables the method provided in the embodiments of the present application to be applicable to low-end graphics cards (graphics cards with lower processing capabilities). In addition, using the method provided in the embodiments of the present application can also significantly reduce the time-consuming of lighting baking and saving lighting information, improving the lighting baking efficiency.

[0211] In some embodiments, as Figure 14 shown, the lighting baking method for a virtual scene includes:

[0212] Step 1401: Obtain the scene elements in the virtual scene and generate an initial scene tree structure;

[0213] Step 1402: Traverse the scene elements to obtain the scene elements to be added, and use the root node in the initial scene tree structure as the initial node;

[0214] Step 1403: Obtain the node type of the initial node;

[0215] Step 1404A1, in the case where the node type is a leaf node type, obtain the node space of the target node, the element type of the scene element to be added, and the element space; when the element type is an object type and the node space satisfies the first space division condition, determine that the scene element to be added does not satisfy the first element addition condition; or, when the element type is a lighting task type and the element space and the node space satisfy the second space division condition, determine that the scene element to be added does not satisfy the second element addition condition; perform node splitting on the initial node to obtain child nodes, so as to update the initial scene tree structure, select the child node corresponding to the scene element to be added from the split child nodes as the initial node, and return to execute Step 1403;

[0216] Step 1404A2, in the case where the node type is a leaf node type, obtain the node space of the target node, the element type of the scene element to be added, and the element space; when the element type is an object type and the node space does not satisfy the first space division condition, determine that the scene element to be added satisfies the first element addition condition; or, when the element type is a lighting task type and the element space and the node space do not satisfy the second space division condition, determine that the scene element to be added satisfies the second element addition condition; add the scene element to be added to the initial node to update the initial scene tree structure, and return to execute Step 1402;

[0217] Step 1404B1, in the case where the node type is not a leaf node type, obtain the target child node corresponding to the scene element to be added among the child nodes of the target node; when the number of target child nodes does not satisfy the intersection condition, use the target child node as the initial node obtained by traversal, and return to execute Step 1403;

[0218] Step 1404B2, when the number of target child nodes satisfies the intersection condition, add the scene element to be added to the initial node to update the initial scene tree structure, and return to execute Step 1402;

[0219] Step 1405, after completing the traversal of the scene elements, use the updated initial scene tree structure as the scene tree structure; traverse to the target node in the space nodes of the scene tree structure according to the structural hierarchy relationship; obtain the number of elements of the target node and the number of elements of the descendant nodes of the target node; perform a summation process on the number of elements of the target node and the number of descendant nodes to obtain the total number of elements;

[0220] Step 1406, when the total number of elements belongs to the preset number interval, determine that the target node satisfies the baking condition; traverse to obtain the target scene element among the scene elements of the ancestor nodes of the target node; obtain the position information of the center point of the target scene element in the virtual scene;

[0221] Step 1407A: When the location information belongs to the node space of the target node, use the target scene element as the scene element to be baked; determine the baking element set according to the scene element to be baked, the scene elements of the target node, and the scene elements of the descendant nodes.

[0222] Step 1407B: When no scene element to be baked is selected from the scene elements of the ancestor nodes based on the location information, determine the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes.

[0223] Step 1408: Perform light baking on the baking element set to obtain the light information of the baking element set; obtain the sub-scene identifiers of each scene element in the baking element set; in the light information of each scene element in the baking element set, obtain the light information of the scene elements in each preset sub-scene according to each sub-scene identifier; when the light information of all scene elements in any preset sub-scene is obtained, save the light information of all scene elements in any preset sub-scene.

[0224] In the above light baking method for virtual scenes, the scene elements in the virtual scene are divided into scenes to obtain a scene tree structure, the target node is traversed in the scene tree structure, and when the number of elements of the target node and the descendant nodes of the target node meets the baking conditions, the baking element set is determined according to the baking elements included in the target node, the ancestor nodes of the target node, and the descendant nodes, so that the number of scene elements in the baking element set is small. Perform light baking on the baking element set, so that the number of scene elements participating in one light baking is small, which can reduce the video memory occupancy rate during the light baking process and improve the stability of the light baking.

[0225] It should be understood that although each step in the flowcharts involved in the above embodiments is displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.

[0226] Based on the same inventive concept, an embodiment of the present application further provides a virtual scene light baking device for implementing the virtual scene light baking method involved above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the virtual scene light baking device provided below can refer to the limitations on the virtual scene light baking method in the above text, and will not be repeated here.

[0227] In some embodiments, as Figure 15 shown, a virtual scene light baking device is provided, including: a scene element acquisition module 1501, a scene division module 1502, a node traversal module 1503, a baking element set acquisition module 1504, and a light baking module 1505, where:

[0228] The scene element acquisition module 1501 is used to acquire scene elements in the virtual scene;

[0229] The scene division module 1502 is used to divide the virtual scene according to the scene elements to obtain a scene tree structure;

[0230] The node traversal module 1503 is used to traverse to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship;

[0231] The baking element set acquisition module 1504, which is used as a baking element set determination module, is used to determine a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes when it is determined that the target node meets the baking condition based on the number of elements of the target node and the number of elements of the descendant nodes of the target node;

[0232] The light baking module 1505 is used to perform light baking on the baking element set to obtain the light information of the baking element set.

[0233] In the above virtual scene light baking device, the scene elements in the virtual scene are divided to obtain a scene tree structure, the target node is traversed in the scene tree structure, and when the number of elements of the target node and the descendant nodes of the target node meet the baking condition, the baking element set is determined according to the baking elements included in the target node, the ancestor nodes of the target node, and the descendant nodes, so that the number of scene elements in the baking element set is small, and light baking is performed on the baking element set, so that the number of scene elements participating in one light baking is small, which can reduce the video memory occupancy rate during the light baking process and can improve the stability of the light baking.

[0234] In some embodiments, the lighting baking device for the virtual scene further includes: a baking condition determination module, configured to obtain the number of elements of a target node and the number of elements of the descendant nodes of the target node; perform a summation process on the number of elements of the target node and the number of elements of the descendant nodes to obtain the total number of elements; and when the total number of elements belongs to a preset number range, determine that the target node meets the baking condition.

[0235] In some embodiments, the baking element set acquisition module 1504 is further configured to obtain the position information corresponding to the scene elements of the ancestor nodes of the target node; select the scene elements to be baked from the scene elements of the ancestor nodes according to the position information; and determine the baking element set according to the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes.

[0236] In some embodiments, the baking element set acquisition module 1504 is further configured to traverse the scene elements of the ancestor nodes of the target node to obtain the target scene elements; obtain the position information of the center point of the target scene elements in the virtual scene; and when the position information belongs to the node space of the target node, use the target scene elements as the scene elements to be baked.

[0237] In some embodiments, the baking element set acquisition module 1504 is further configured to obtain the position information corresponding to the scene elements of the ancestor nodes of the target node;

[0238] When no scene elements to be baked are selected from the scene elements of the ancestor nodes according to the position information, determine the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes.

[0239] In some embodiments, the scene division module 1502 is further configured to generate an initial scene tree structure; traverse the scene elements to obtain the scene elements to be added, and use the root node in the initial scene tree structure as the initial node; obtain the node type of the initial node; in the case where the node type is a leaf node type, when the scene elements to be added do not meet the element addition condition, split the initial node into child nodes to update the initial scene tree structure, select the child node corresponding to the scene elements to be added from the split child nodes as the initial node, and return to execute the step of obtaining the node type of the initial node; when the scene elements to be added meet the element addition condition, add the scene elements to be added to the initial node to update the initial scene tree structure, and return to execute the step of traversing the scene elements to obtain the scene elements to be added; after completing the traversal of the scene elements, use the updated initial scene tree structure as the scene tree structure.

[0240] In some embodiments, the element addition condition includes a first element addition condition or a second element addition condition; the scene division module 1502 is further configured to, when the node type is a leaf node type, obtain the node space of the target node, the element type of the scene element to be added, and the element space; when the element type is an object type and the node space satisfies the first space division condition, determine that the scene element to be added does not satisfy the first element addition condition; or, when the element type is a lighting task type and the element space and the node space satisfy the second space division condition, determine that the scene element to be added does not satisfy the second element addition condition.

[0241] In some embodiments, the element addition condition includes a first element addition condition or a second element addition condition; the scene division module 1502 is further configured to, when the node type is a leaf node type, obtain the node space of the target node, the element type of the scene element to be added, and the element space; when the element type is an object type and the node space does not satisfy the first space division condition, determine that the scene element to be added satisfies the first element addition condition; or, when the element type is a lighting task type and the element space and the node space do not satisfy the second space division condition, determine that the scene element to be added satisfies the second element addition condition.

[0242] In some embodiments, the scene division module 1502 is further configured to, when the node type is not a leaf node type, obtain the target child node corresponding to the scene element to be added among the child nodes of the target node; when the number of target child nodes does not satisfy the intersection condition, use the target child node as the initial node obtained by traversal, and return to execute the step of obtaining the node type of the initial node.

[0243] In some embodiments, the scene division module 1502 is further configured to, when the number of target child nodes satisfies the intersection condition, add the scene element to be added to the initial node to update the initial scene tree structure, and return to execute the step of traversing the scene elements to obtain the scene element to be added.

[0244] In some embodiments, the lighting baking device for a virtual scene further includes: a lighting information storage module, configured to obtain the lighting information of all scene elements in a preset sub-scene of the virtual scene based on the lighting information of the baking element set, and store the lighting information of all scene elements in the preset sub-scene.

[0245] In some embodiments, the number of preset sub-scenes is at least two; the lighting information storage module is further configured to obtain the sub-scene identifier of each scene element in the baking element set; among the lighting information of each scene element in the baking element set, obtain the lighting information of the scene elements in each preset sub-scene according to each sub-scene identifier; when the lighting information of all scene elements in any one preset sub-scene is obtained, store the lighting information of all scene elements in any one preset sub-scene.

[0246] Each module in the above light baking device for virtual scenes can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above modules can be embedded in the processor of a computer device in hardware form or independent of the processor, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.

[0247] In some embodiments, a computer device is provided. The computer device can be a server or a terminal. Taking the computer device as a server for illustration, its internal structure diagram can be as Figure 16 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the light baking method for virtual scenes. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a light baking method for virtual scenes.

[0248] Those skilled in the art can understand that Figure 16 the structure shown in

[0249] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0250] In some embodiments, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, it implements the steps of the above light baking method for virtual scenes.

[0251] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it implements the steps of the above light baking method for virtual scenes.

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

[0253] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., and are not limited thereto.

[0254] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0255] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A method for light baking of a virtual scene, characterized in that The method includes: Obtaining scene elements in a virtual scene; Performing scene division on the virtual scene according to the scene elements to obtain a scene tree structure; Traversing to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; When it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node, determining a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes; Performing light baking on the baking element set to obtain the light information of the baking element set.

2. The method according to claim 1, wherein After traversing to the target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship, it further includes: Obtaining the number of elements of the target node and the number of elements of the descendant nodes of the target node; Performing a summation process on the number of elements of the target node and the number of elements of the descendant nodes to obtain the total number of elements; When the total number of elements belongs to a preset number range, determining that the target node meets the baking condition.

3. The method according to claim 1, wherein Determining the baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes, includes: Obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node; Selecting the scene elements to be baked from the scene elements of the ancestor nodes according to the position information; Determining the baking element set according to the scene elements to be baked, the scene elements of the target node, and the scene elements of the descendant nodes.

4. The method according to claim 3, characterized in that, Obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node, includes: Traversing in the scene elements of the ancestor nodes of the target node to obtain target scene elements; Obtaining the position information of the center point of the target scene element in the virtual scene; Selecting the scene elements to be baked from the scene elements of the ancestor nodes according to the position information, includes: When the position information belongs to the node space of the target node, using the target scene element as the scene element to be baked.

5. The method according to claim 1, wherein The method further includes: Obtaining the position information corresponding to the scene elements of the ancestor nodes of the target node; Determining the baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes, includes: When no scene elements to be baked are selected from the scene elements of the ancestor nodes according to the position information, determining the baking element set according to the scene elements of the target node and the scene elements of the descendant nodes.

6. The method according to claim 1, wherein Performing scene division on the virtual scene according to the scene elements to obtain a scene tree structure, includes: Generating an initial scene tree structure; Traversing in the scene elements to obtain the scene elements to be added, and using the root node in the initial scene tree structure as the initial node; Obtaining the node type of the initial node; When the node type is the leaf node type, when the to-be-added scene element does not meet the element addition condition, the initial node is split into child nodes to update the initial scene tree structure. Among the split child nodes, the child node corresponding to the to-be-added scene element is selected as the initial node, and the step of obtaining the node type of the initial node is returned for execution; When the to-be-added scene element meets the element addition condition, the to-be-added scene element is added to the initial node to update the initial scene tree structure, and the step of traversing the scene elements to obtain the to-be-added scene element is returned for execution; After completing the traversal of the scene elements, the updated initial scene tree structure is used as the scene tree structure.

7. The method according to claim 6, characterized in that The element addition condition includes the first element addition condition or the second element addition condition; after obtaining the node type of the initial node, it further includes: When the node type is the leaf node type, obtain the node space of the target node, the element type and the element space of the to-be-added scene element; When the element type is the object type and the node space meets the first space division condition, it is determined that the to-be-added scene element does not meet the first element addition condition; or, When the element type is the lighting task type and the element space and the node space meet the second space division condition, it is determined that the to-be-added scene element does not meet the second element addition condition.

8. The method according to claim 6, characterized in that, The element addition condition includes the first element addition condition or the second element addition condition; after obtaining the node type of the initial node, it further includes: When the node type is the leaf node type, obtain the node space of the target node, the element type and the element space of the to-be-added scene element; When the element type is the object type and the node space does not meet the first space division condition, it is determined that the to-be-added scene element meets the first element addition condition; or, When the element type is the lighting task type and the element space and the node space do not meet the second space division condition, it is determined that the to-be-added scene element meets the second element addition condition.

9. The method according to claim 6, wherein After obtaining the node type of the initial node, it further includes: When the node type is not the leaf node type, obtain the target child node corresponding to the to-be-added scene element among the child nodes of the target node; When the number of the target child nodes does not meet the intersection condition, the target child node is used as the initial node obtained by traversal, and the step of obtaining the node type of the initial node is returned for execution.

10. The method according to claim 9, wherein After obtaining the target child node corresponding to the to-be-added scene element among the child nodes of the target node when the node type is not the leaf node type, it further includes: When the number of the target child nodes meets the intersection condition, the to-be-added scene element is added to the initial node to update the initial scene tree structure, and the step of traversing the scene elements to obtain the to-be-added scene element is returned for execution.

11. The method according to any one of claims 1 to 10, characterized in that, After obtaining the lighting information of the baking element set, it further includes: Obtaining the lighting information of all scene elements in the preset sub-scenes of the virtual scene based on the lighting information of the baking element set; Saving the lighting information of all scene elements in the preset sub-scenes.

12. The method according to claim 11, wherein The number of the preset sub-scenes is at least two; The obtaining the lighting information of all scene elements in the preset sub-scenes of the virtual scene based on the lighting information of the baking element set and saving the lighting information of all scene elements in the preset sub-scenes includes: Obtaining the sub-scene identifiers of the scene elements in the baking element set; In the lighting information of each scene element in the baking element set, obtaining the lighting information of the scene elements in each preset sub-scene according to each sub-scene identifier; When obtaining the lighting information of all scene elements in any one of the preset sub-scenes, saving the lighting information of all scene elements in any one of the preset sub-scenes.

13. A lighting baking device for a virtual scene, characterized in that, The device includes: A scene element obtaining module, configured to obtain scene elements in a virtual scene; A scene division module, configured to divide the virtual scene according to the scene elements to obtain a scene tree structure; A node traversal module, configured to traverse to a target node in the spatial nodes of the scene tree structure according to the structural hierarchy relationship; A baking element set obtaining module, a baking element set determining module, configured to determine a baking element set according to the scene elements of the target node, the scene elements of the ancestor nodes of the target node, and the scene elements of the descendant nodes when it is determined that the target node meets the baking condition according to the number of elements of the target node and the number of elements of the descendant nodes of the target node; A lighting baking module, configured to perform lighting baking on the baking element set to obtain the lighting information of the baking element set.

14. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 12.

16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 12.