Illumination baking method and device, storage medium and electronic equipment
By using only the effective sampling points and their weights of the virtual mesh model in lighting baking, the problem of low lighting baking efficiency is solved, and more efficient lighting calculations and more realistic rendering effects are achieved.
Patent Information
- Application Number
- CN202510554251.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-15
AI Technical Summary
There are problems in the existing lighting baking methods with redundancy and long calculation time, which leads to low lighting baking efficiency.
By obtaining the effective sampling points on the virtual mesh model and their corresponding effective weights, only the sampling points in the effective area are illuminated and baked, invalid data is eliminated, and computing resource allocation is optimized.
It improves the efficiency of lighting baking, reduces data storage requirements and calculation complexity, and improves the quality and efficiency of lighting baking.
Smart Images

Figure CN120495514A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a light baking method, device, storage medium, and electronic device. Background Art
[0002] In lighting baking scenarios, a full baking method is usually used to bake lighting for the virtual mesh model in all directions throughout the entire space. However, this method has data redundancy and requires a long time to support, which leads to low lighting baking efficiency. Therefore, there is a problem of low lighting baking efficiency.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present application provide a light baking method, device, storage medium, and electronic device to at least solve the technical problem of low light baking efficiency.
[0005] According to one aspect of an embodiment of the present application, a lighting baking method is provided, comprising: obtaining at least one valid sampling point on a virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located; obtaining an effective weight corresponding to each of the at least one valid sampling point, wherein the effective weight is used to indicate a degree of proximity between a direction of the valid sampling point and a sampling direction of the valid area; and performing lighting baking on the at least one valid sampling point using the effective weight corresponding to each of the valid sampling points to obtain a baking result.
[0006] According to another aspect of an embodiment of the present application, a lighting baking device is further provided, including: a first acquisition unit, configured to acquire at least one valid sampling point on a virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located; a second acquisition unit, configured to acquire an effective weight corresponding to each of the at least one valid sampling point, wherein the effective weight is used to indicate a degree of proximity between a direction of the valid sampling point and a sampling direction of the valid area; and a first baking unit, configured to perform lighting baking on the at least one valid sampling point using the effective weight corresponding to each of the valid sampling points to obtain a baking result.
[0007] As an optional solution, the above-mentioned device further includes: a reconstruction unit for performing illumination baking on the above-mentioned at least one valid sampling point using the effective weights corresponding to the above-mentioned respective valid sampling points to obtain a baking result, using at least one illumination probe associated with the first sampling point to perform illumination reconstruction on the above-mentioned first sampling point to obtain a reconstructed illumination value corresponding to the above-mentioned first sampling point, wherein the above-mentioned at least one valid sampling point includes the above-mentioned first sampling point; a third acquisition unit for obtaining the above-mentioned reconstructed illumination value and the above-mentioned illumination value in the process of performing illumination baking on the above-mentioned at least one valid sampling point using the effective weights corresponding to the above-mentioned respective valid sampling points to obtain a baking result. an illumination difference between the actual illumination values corresponding to the first sampling point; an integration unit, configured to integrate the illumination difference with the effective weight corresponding to the first sampling point in the process of performing illumination baking on the at least one valid sampling point using the effective weights corresponding to the respective valid sampling points to obtain the illumination loss corresponding to the first sampling point; and a second baking unit, configured to perform illumination baking on the first sampling point using the illumination loss in the process of performing illumination baking on the at least one valid sampling point using the effective weights corresponding to the respective valid sampling points to obtain the illumination result, to obtain the illumination result corresponding to the first sampling point.
[0008] As an optional solution, the above-mentioned reconstruction unit includes: a first acquisition module, used to obtain the lighting information collected by the above-mentioned at least one lighting probe, wherein the above-mentioned lighting information is used to represent the lighting intensity of the above-mentioned first sampling point in various directions; a second acquisition module, used to obtain the objective function based on the above-mentioned lighting information, wherein the above-mentioned objective function is used to represent the relationship between the lighting value at the above-mentioned first sampling point and the spherical harmonic function coefficient; a first optimization module, used to obtain the optimal solution of the above-mentioned spherical harmonic function coefficient by minimizing the above-mentioned objective function; and a reconstruction module, used to use the optimal solution of the above-mentioned spherical harmonic function coefficient to perform lighting reconstruction on the above-mentioned lighting information to obtain the reconstructed lighting value corresponding to the above-mentioned first sampling point.
[0009] As an optional solution, the above-mentioned second baking unit includes: a combination module, which is used to combine the above-mentioned illumination loss and gradient regularization term to obtain a target loss function, wherein the above-mentioned gradient regularization term is used to constrain the smooth transition of illumination; a second optimization module, which is used to obtain the optimal spherical harmonic coefficients by minimizing the above-mentioned target loss function, wherein the above-mentioned baking result includes the above-mentioned optimal spherical harmonic coefficients.
[0010] As an optional solution, the above-mentioned device further includes: a third acquisition module, which is used to obtain the normal direction corresponding to the above-mentioned first sampling point before the target loss function is obtained by combining the above-mentioned illumination loss and the gradient regularization term; a fourth acquisition module, which is used to obtain the illumination matrix corresponding to the above-mentioned first sampling point using the normal direction corresponding to the above-mentioned first sampling point before the target loss function is obtained by combining the above-mentioned illumination loss and the gradient regularization term, wherein the above-mentioned illumination matrix is used to describe the illumination information of the vertex associated with the above-mentioned first sampling point in the above-mentioned virtual grid model; a fifth acquisition module, which is used to obtain the difference matrix corresponding to the adjacent grid before the target loss function is obtained by combining the above-mentioned illumination loss and the gradient regularization term, wherein the adjacent grid is the grid adjacent to the above-mentioned first sampling point in the above-mentioned virtual grid model, and the above-mentioned difference matrix is used to represent the change of the illumination value in the above-mentioned adjacent grid; and a sixth acquisition module, which is used to obtain the above-mentioned gradient regularization term based on the above-mentioned illumination matrix and the above-mentioned difference matrix before the target loss function is obtained by combining the above-mentioned illumination loss and the gradient regularization term.
[0011] As an optional solution, the apparatus further includes: a fourth acquisition unit configured to acquire, during the process of acquiring the effective weight corresponding to each valid sampling point among the at least one valid sampling point, a normal direction corresponding to the second sampling point and a direction of the geometric normal, wherein the at least one valid sampling point includes the second sampling point; and a fifth acquisition unit configured to acquire, during the process of acquiring the effective weight corresponding to each valid sampling point among the at least one valid sampling point, the effective weight corresponding to the second sampling point based on the normal direction corresponding to the second sampling point and the direction of the geometric normal.
[0012] As an optional solution, the fifth acquisition unit includes: a seventh acquisition module, configured to acquire an angle between the normal direction corresponding to the second sampling point and the direction of the geometric normal; and an eighth acquisition module, configured to acquire an effective weight corresponding to the second sampling point based on the angle, wherein the effective weight corresponding to the second sampling point is negatively correlated with the angle.
[0013] As an optional solution, the above-mentioned first baking unit includes: a weighting module, which is used to use the effective weights corresponding to the above-mentioned each effective sampling point to perform weighted averaging on the illumination value of at least one effective sampling point to obtain the overall illumination value of the above-mentioned effective area, wherein the above-mentioned baking result includes the above-mentioned overall illumination value.
[0014] According to another aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the above light baking method.
[0015] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the lighting baking method through the computer program.
[0016] In an embodiment of the present application, at least one valid sampling point on a virtual grid model is obtained, wherein the valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located; an effective weight corresponding to each valid sampling point in the at least one valid sampling point is obtained, wherein the effective weight is used to indicate a degree of proximity between a direction of the valid sampling point and a sampling direction of the valid area; and light baking is performed on the at least one valid sampling point using the effective weight corresponding to each valid sampling point to obtain a baking result.
[0017] This embodiment defines a valid region based on geometric normals and uses only sampling points within this region as valid sampling points, eliminating a large amount of invalid data from all sampling points, reducing data storage requirements and computational complexity. Furthermore, this embodiment assigns a corresponding effective weight to each valid sampling point, with the weight value determined by the sampling point direction and the sampling direction of the valid region. This weight assignment optimizes computing resource allocation and reduces the amount of computation required for sampling points with sampling directions that deviate from the valid region, thereby achieving the goal of optimizing resource allocation and reducing data redundancy during the lighting baking process. This results in the technical effect of improving lighting baking efficiency and solving the technical problem of low lighting baking efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 is a schematic diagram of an application environment of an optional lighting baking method according to an embodiment of the present application;
[0020] Figure 2 is a schematic diagram of a process of an optional light baking method according to an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of an optional light baking method according to an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of another optional light baking method according to an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of another optional light baking method according to an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of another optional light baking method according to an embodiment of the present application;
[0025] Figure 7 is a schematic diagram of an optional light baking device according to an embodiment of the present application;
[0026] Figure 8 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to one aspect of the embodiment of the present application, a light baking method is provided. Optionally, as an optional implementation, the light baking method can be applied to, but is not limited to, Figure 1In the environment shown, the environment may include, but is not limited to, a user device 102 and a server 112 . The user device 102 may include, but is not limited to, a display 104 , a processor 106 , and a memory 108 . The server 112 includes a database 114 and a processing engine 116 .
[0030] The specific process can be as follows:
[0031] Step S102: The user device 102 obtains a lighting baking request triggered for the virtual grid model;
[0032] Step S104 , sending the light baking request to the server 112 via the network 110 ;
[0033] In steps S106-S110, the server 112 responds to the light baking request and obtains at least one valid sampling point on the virtual grid model through the processing engine 116, further obtains the effective weight corresponding to each valid sampling point in the at least one valid sampling point, and uses the effective weight corresponding to each valid sampling point to perform light baking on the at least one valid sampling point to obtain a baking result.
[0034] In step S112 , the baking result is sent to the user device 102 via the network 110 . The user device 102 displays the baking result on the display 104 via the processor 106 and stores the baking result in the memory 108 .
[0035] remove Figure 1 In addition to the examples shown, the above-mentioned user equipment can be a terminal device configured with a target client, which can include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop, a tablet computer, a PDA, an MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, etc. The target client can be a video client, an instant messaging client, a browser client, an education client, etc. The above-mentioned network can include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The above-mentioned server can be a single server, or it can be a server cluster composed of multiple servers, or a cloud server. The above is only an example, and no limitation is made to this in this embodiment.
[0036] As an example, terminal devices may include, but are not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. This embodiment can be applied to various scenarios, including but not limited to digital humans, virtual humans, games, virtual reality, and extended reality (XR).
[0037] For example, the server can also 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, CDN, as well as big data and artificial intelligence platforms.
[0038] Alternatively, as an optional implementation, Figure 2 As shown, the light baking method can be executed by an electronic device, which can be, for example, Figure 1 The user device or server shown in the figure includes the following steps:
[0039] S202, obtaining at least one valid sampling point on the virtual grid model, wherein a valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located;
[0040] In an optional embodiment, the virtual mesh model may be a discretized model used to represent the shape of an object in computer graphics, and is composed of a large number of vertices and patches.
[0041] In an optional embodiment, the valid sampling points may be sampling points located within the valid area of the virtual grid model, and these points have practical significance for subsequent operations such as illumination calculation.
[0042] In an optional embodiment, the valid area may be the area where the geometric normal of the virtual mesh model is located, where the geometric normal is perpendicular to the model surface. The valid area is usually defined around the geometric normal to determine which sampling points can be used for subsequent calculations.
[0043] In an optional embodiment, the geometric normal can be a vector perpendicular to the surface at a certain point on the surface of the virtual grid model. For example, the geometric normal can be perpendicular to the geometric surface on which it is located. For example, for a plane, its geometric normal is perpendicular to any straight line on the plane; for the surface of a sphere, the geometric normal of any point on the sphere is perpendicular to the tangent plane of the point. Furthermore, the geometric normal has a direction. It is a vector that has not only a magnitude (such as 1, that is, a unit vector) but also a direction. This direction can be used to describe the orientation of the surface.
[0044] Specifically, this embodiment first requires a virtual mesh model object for lighting baking. Based on the geometric normals of the virtual mesh model, the scope of the valid area is determined. At least one sampling point within the valid area is selected as a valid sampling point, which will be used for subsequent lighting calculations.
[0045] S204: Obtain an effective weight corresponding to each effective sampling point in the at least one effective sampling point, where the effective weight is used to indicate a degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area;
[0046] In an optional embodiment, the effective weight may be used to indicate the degree of proximity between the direction of the effective sampling point and the sampling direction of the effective area, and is a quantitative indicator, where a larger value indicates closer proximity.
[0047] In an optional embodiment, the effective sampling point direction may be the pointing direction of the effective sampling point in the virtual space.
[0048] In an optional embodiment, the valid area sampling direction may be a representative sampling direction defined by the valid area, such as related to a geometric normal direction.
[0049] Specifically, this embodiment determines the specific direction of each valid sampling point in virtual space. Determining the valid region sampling direction: Based on the definition of the valid region, its sampling direction is determined. Using a specific algorithm or formula, the degree of proximity between the direction of each valid sampling point and the sampling direction of the valid region is calculated to obtain a corresponding effective weight.
[0050] S206 , performing lighting baking on at least one valid sampling point using the valid weight corresponding to each valid sampling point to obtain a baking result.
[0051] In an optional embodiment, lighting baking can be a technology that pre-calculates and stores lighting effects, and calculates lighting information for each sampling point by simulating the propagation and interaction of light in a scene to improve the efficiency and quality of real-time rendering.
[0052] In an optional embodiment, the baking result may be data obtained after lighting baking, including lighting information of each valid sampling point, which can be used in a subsequent rendering process.
[0053] Specifically, this embodiment organizes at least one acquired valid sampling point and its corresponding valid weight as input data for light baking. Using a light baking algorithm, the valid sampling points and valid weights are combined to simulate the propagation and interaction of light in the virtual scene, calculating lighting information for each valid sampling point. The calculated lighting information is stored as a baking result for use in subsequent rendering processes.
[0054] In an optional embodiment, the above-mentioned lighting baking method can be applied to, but is not limited to, multiple scenarios, such as game scenarios, architectural visualization scenarios, product design scenarios, etc.
[0055] To further illustrate, in a game scene, in order to improve the realism and rendering efficiency of the game screen, for example, a large role-playing game has a rich variety of scenes, such as an ancient castle.
[0056] In the castle scene, the walls, towers and other architectural structures are complex, and their virtual mesh models are composed of a large number of fine vertices and faces. When obtaining valid sampling points, we focus on the concave and convex parts of the castle walls, areas around the tower windows, and other areas. The geometric normal directions of these places change significantly, and the valid area can accurately capture the reflection and refraction of light at these locations. Through calculation, the effective weight corresponding to each valid sampling point is determined. For example, if the direction of the sampling point at the spire of the castle is highly consistent with the sampling direction of the valid area, its effective weight is larger, which means that the sampling point contributes more significantly to the lighting calculation.
[0057] These effective weights are used to bake lighting, simulating the effects of sunlight on the castle at different times (e.g., early morning, midday, and evening), as well as the lighting from torches and magical light sources within the castle. The baked results are stored as texture maps, which the real-time rendering engine can quickly access during game runtime, significantly reducing the burden of real-time calculations and ensuring that the castle scene presents realistic visuals under various lighting conditions.
[0058] Optionally, this embodiment can be applied to business scenarios that require model rendering, such as games, movies, animations, and autonomous driving.
[0059] Specifically, using film and television / animation production as an example, dense sampling can be performed along the normal direction of key material areas (such as silk folds and glass edges). Weights are dynamically adjusted based on the direction of the scene's primary light source (such as the main light in a movie) to highlight dramatic lighting effects. High-weight sampling points are used for high-frequency details (such as a character's face), while low-weight points are used for background environments. This can accelerate lighting baking in animated films, improve rendering efficiency, and dynamically adjust probes around character models to enhance realism.
[0060] Taking the business scenario of autonomous driving simulation as an example, sampling points can be generated along the normal direction in key areas such as lane markings and traffic signs. Sampling points in backlit areas (such as tunnel exits) are given higher weights to simulate HDR lighting effects. The weighted results are combined to dynamically generate light maps for real-time use by the simulator. This enhances the realism of the simulated scene, reduces the false detection rate of perception algorithms, and simulates the reflection of light from road materials (such as asphalt and road markings) by LiDAR and cameras.
[0061] It should be noted that this embodiment aims to obtain effective sampling points on the virtual grid model, calculate effective weights, and use these weights to perform lighting baking on the effective sampling points to obtain baking results, so as to achieve simulation and optimization of the lighting effects of the virtual scene.
[0062] To illustrate further, the optional Figure 3 As shown, at least one valid sampling point 304 on the virtual grid model 302 is obtained, wherein the valid sampling point 304 is a sampling point on the virtual grid model 302 located within a valid area 306, and the valid area 306 is an area where the geometric normal of the virtual grid model 302 is located; an effective weight 308 corresponding to each valid sampling point 304 in the at least one valid sampling point 304 is obtained, wherein the effective weight 308 is used to indicate the degree of proximity between the direction of the valid sampling point 304 and the sampling direction of the valid area 306; and light baking is performed on the at least one valid sampling point 304 using the effective weight 308 corresponding to each valid sampling point 304 to obtain a baking result 310.
[0063] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0064] Through the embodiments provided in this application, a valid area is defined based on geometric normals, and only sampling points within this area are used as valid sampling points, eliminating a large amount of invalid data from all sampling points, reducing data storage requirements and computational complexity. Furthermore, this embodiment assigns a corresponding effective weight to each valid sampling point. The weight value is determined by the sampling point direction and the sampling direction of the valid area. Through weight allocation, computing resource allocation is optimized, reducing the amount of computation for sampling points with sampling directions that deviate from the valid area, thereby achieving the purpose of optimizing resource allocation and reducing data redundancy during the lighting baking process, thereby achieving the technical effect of improving lighting baking efficiency.
[0065] As an optional solution, in the process of performing lighting baking on at least one valid sampling point using the effective weight corresponding to each valid sampling point to obtain the baking result, the method further includes:
[0066] S1-1, using at least one illumination probe associated with a first sampling point, performing illumination reconstruction on the first sampling point to obtain a reconstructed illumination value corresponding to the first sampling point, wherein the at least one valid sampling point includes the first sampling point;
[0067] S1-2, obtaining the illumination difference between the reconstructed illumination value and the actual illumination value corresponding to the first sampling point;
[0068] S1-3, integrating the illumination difference and the effective weight corresponding to the first sampling point to obtain the illumination loss corresponding to the first sampling point;
[0069] S1-4, performing lighting baking on the first sampling point using the lighting loss to obtain a baking result corresponding to the first sampling point.
[0070] In an optional embodiment, the lighting probe may be a tool for collecting lighting information in an environment, and may be placed at different locations in a scene to record the lighting conditions at the location.
[0071] In an optional embodiment, the reconstructed illumination value may be information collected by an illumination probe, and the simulated illumination intensity value at the first sampling point may be obtained after being processed by a certain algorithm.
[0072] In an optional embodiment, the actual illumination value may be an illumination intensity value received by the first sampling point in a real illumination environment, which may be obtained by accurate illumination measurement equipment or high-precision simulation calculation.
[0073] In an optional embodiment, the illumination difference value may be the difference between the reconstructed illumination value and the actual illumination value, reflecting the accuracy of the illumination reconstruction.
[0074] In an optional embodiment, the illumination loss may be an indicator obtained by comprehensively considering the illumination difference and the effective weight, and is used to measure the impact of the illumination reconstruction error of the first sampling point on the overall illumination effect.
[0075] It should be noted that this embodiment aims to use light probes to obtain reconstructed lighting values at sampling points, compare them with the actual lighting values to obtain lighting differences, and then calculate the lighting loss based on the effective weights. Finally, the lighting loss is used to perform lighting baking on the sampling points, resulting in more accurate baking results and improved lighting baking quality and effects. The first sampling point is used for illustration purposes only.
[0076] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0077] Through the embodiments provided in the present application, at least one lighting probe associated with a first sampling point is used to perform lighting reconstruction on the first sampling point to obtain a reconstructed lighting value corresponding to the first sampling point, wherein the at least one valid sampling point includes the first sampling point; an lighting difference between the reconstructed lighting value and the actual lighting value corresponding to the first sampling point is obtained; the lighting difference and the effective weight corresponding to the first sampling point are integrated to obtain a lighting loss corresponding to the first sampling point; and lighting baking is performed on the first sampling point using the lighting loss to obtain a baking result corresponding to the first sampling point.
[0078] By introducing the concepts of light probes and light loss, this embodiment can more accurately simulate the lighting conditions at sampling points. Light probes provide rich ambient lighting information, making lighting reconstruction more accurate. Light loss considers the importance of sampling points and lighting reconstruction errors, making targeted adjustments during the lighting baking process. The resulting baking results more realistically reflect the lighting effects in the scene, reducing lighting distortion and errors, improving the quality and realism of rendered images, making virtual scenes more realistic, and enhancing the user's visual experience.
[0079] As an optional solution, at least one illumination probe associated with the first sampling point is used to perform illumination reconstruction on the first sampling point to obtain a reconstructed illumination value corresponding to the first sampling point, including:
[0080] S2-1, obtaining lighting information collected by at least one lighting probe, where the lighting information is used to represent the lighting intensity of a first sampling point in various directions;
[0081] S2-2, obtaining an objective function based on the illumination information, where the objective function is used to represent the relationship between the illumination value at the first sampling point and the spherical harmonic function coefficients;
[0082] S2-3, by minimizing the objective function, the optimal solution of the spherical harmonic coefficients is obtained;
[0083] S2-4, using the optimal solution of the spherical harmonic function coefficients, reconstruct the illumination information to obtain the reconstructed illumination value corresponding to the first sampling point.
[0084] In an optional embodiment, the lighting information may be data collected by a lighting probe, which specifically describes the lighting intensity of the first sampling point in various directions and is the basis for subsequent lighting reconstruction.
[0085] In an optional embodiment, the objective function may be used to describe the relationship between the illumination value at the first sampling point and the spherical harmonic function coefficients, and appropriate spherical harmonic function coefficients may be obtained by solving the function.
[0086] In an optional embodiment, the spherical harmonic function coefficients may be coefficients in a spherical harmonic function expansion. The spherical harmonic function is a mathematical tool for representing function distribution on a sphere and can be used to approximately represent illumination distribution in illumination calculations.
[0087] In an optional embodiment, minimizing the objective function may be adjusting the values of the spherical harmonic function coefficients using a mathematical optimization algorithm so that the value of the objective function is minimized.
[0088] In an optional embodiment, the optimal solution of the spherical harmonic function coefficients may be the spherical harmonic function coefficient values obtained under the condition of satisfying the objective function minimization, and these coefficients can most accurately describe the illumination distribution of the first sampling point.
[0089] In an optional embodiment, illumination reconstruction may be a process of recalculating the illumination value of the first sampling point based on the optimal solution of the spherical harmonic function coefficients and illumination information.
[0090] In an optional embodiment, the reconstructed illumination value may be an illumination intensity value of the first sampling point obtained through illumination reconstruction, which is an approximate simulation of an actual illumination condition.
[0091] It should be noted that this embodiment aims to use the illumination probe associated with the first sampling point to collect illumination information, construct an objective function and solve the optimal solution of the spherical harmonic function coefficients, and then use the optimal solution to reconstruct the illumination information to obtain the reconstructed illumination value corresponding to the first sampling point, so as to more accurately simulate the illumination conditions of the sampling point.
[0092] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0093] Through the embodiments provided in the present application, illumination information collected by at least one illumination probe is obtained, wherein the illumination information is used to represent the illumination intensity of a first sampling point in various directions; based on the illumination information, an objective function is obtained, wherein the objective function is used to represent the relationship between the illumination value at the first sampling point and the spherical harmonic coefficients; by minimizing the objective function, an optimal solution for the spherical harmonic coefficients is obtained; and using the optimal solution for the spherical harmonic coefficients, the illumination information is reconstructed to obtain a reconstructed illumination value corresponding to the first sampling point.
[0094] This example uses illumination probes to collect rich illumination information and achieves accurate reconstruction of the illumination conditions at the first sampling point by optimizing spherical harmonics and an objective function. Spherical harmonics effectively approximate complex illumination distributions, and minimizing the objective function to obtain the optimal solution ensures the accuracy of the reconstruction.
[0095] As an optional solution, use the illumination loss to perform illumination baking on the first sampling point to obtain the baking result corresponding to the first sampling point, including:
[0096] S3-1, combining the illumination loss and the gradient regularization term to obtain the target loss function, where the gradient regularization term is used to constrain the smooth transition of illumination;
[0097] S3-2, obtaining optimal spherical harmonic coefficients by minimizing the target loss function, wherein the baking result includes the optimal spherical harmonic coefficients.
[0098] In an optional embodiment, the illumination loss may be an indicator for measuring the illumination reconstruction error of the first sampling point, reflecting the influence of the difference between the reconstructed illumination value and the actual illumination value on the illumination effect.
[0099] In an optional embodiment, the gradient regularization term can be a term used to constrain lighting changes. In lighting baking, it limits the gradient of lighting so that lighting can smoothly transition between different areas and avoid sudden changes in lighting.
[0100] In an optional embodiment, the objective loss function may be a function formed by combining the illumination loss and the gradient regularization term. By minimizing the function, the accuracy of illumination reconstruction and the smoothness of illumination can be comprehensively considered.
[0101] In an optional embodiment, minimizing the objective loss function may be to use a mathematical optimization algorithm to adjust the values of relevant parameters so that the value of the objective loss function is minimized.
[0102] In an optional embodiment, mathematical optimization algorithms, such as gradient descent method, Newton method, conjugate gradient method, etc., can gradually approach the optimal solution based on the gradient information of the target loss function.
[0103] In an optional embodiment, the optimal spherical harmonic coefficients can be the spherical harmonic coefficient values that can minimize the target loss function in the process of minimizing the target loss function. These coefficients can most accurately describe the illumination distribution of the first sampling point while ensuring a smooth transition of the illumination.
[0104] It should be noted that this embodiment aims to combine the illumination loss and the gradient regularization term to construct a target loss function, and obtain the optimal spherical harmonic coefficients by minimizing the target loss function, which is used as the illumination baking result of the first sampling point. In this way, during the illumination baking process, the accuracy of illumination reconstruction is considered while ensuring a smooth transition of illumination.
[0105] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0106] The embodiments provided herein combine illumination loss and a gradient regularization term to yield a target loss function, where the gradient regularization term is used to constrain smooth illumination transitions. By minimizing the target loss function, optimal spherical harmonic coefficients are obtained, and the baking results include these optimal spherical harmonic coefficients. By introducing the gradient regularization term, the illumination baking process not only focuses on the accuracy of illumination reconstruction but also on smooth illumination transitions.
[0107] As an optional solution, before combining the illumination loss and the gradient regularization term to obtain the target loss function, the method also includes:
[0108] S4-1, obtaining the normal direction corresponding to the first sampling point;
[0109] S4-2, using the normal direction corresponding to the first sampling point, obtaining an illumination matrix corresponding to the first sampling point, where the illumination matrix is used to describe illumination information received by the vertex associated with the first sampling point in the virtual mesh model;
[0110] S4-3, obtaining a difference matrix corresponding to an adjacent grid, wherein the adjacent grid is a grid adjacent to the first sampling point in the virtual grid model, and the difference matrix is used to represent a change in illumination value in the adjacent grid;
[0111] S4-4, obtain the gradient regularization term according to the illumination matrix and the difference matrix.
[0112] In an optional embodiment, the normal direction may be a vector perpendicular to the surface where the first sampling point is located, which describes the orientation information of the surface at the point and plays a key role in lighting calculation.
[0113] In an optional embodiment, the illumination matrix may be a mathematical matrix used to store and describe illumination information received by the vertex associated with the first sampling point, including key data such as illumination intensity and direction.
[0114] In an optional embodiment, the associated vertices may be vertices that are spatially or lighting-calculated associated with the first sampling point in the virtual mesh model, and their lighting conditions are affected by the lighting of the first sampling point.
[0115] In an optional embodiment, the adjacent grids may be grids that are spatially adjacent to the first sampling point in the virtual grid model, and their lighting conditions are correlated with the first sampling point.
[0116] In an optional embodiment, the difference matrix may be a matrix used to represent changes in illumination values in adjacent grids, and is obtained by calculating differences in illumination values of adjacent grids.
[0117] It should be noted that before combining the illumination loss and gradient regularization term to obtain the target loss function, this embodiment first obtains the gradient regularization term by obtaining the normal direction of the first sampling point, the illumination matrix, and the difference matrix of adjacent grids. This process lays the foundation for the subsequent construction of a target loss function that comprehensively considers illumination reconstruction accuracy and smooth illumination transitions, helping to achieve higher-quality lighting baking effects.
[0118] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0119] Through the embodiments provided in the present application, the normal direction corresponding to the first sampling point is obtained; the normal direction corresponding to the first sampling point is used to obtain the illumination matrix corresponding to the first sampling point, wherein the illumination matrix is used to describe the illumination information received by the vertex associated with the first sampling point in the virtual grid model; the difference matrix corresponding to the adjacent grid is obtained, wherein the adjacent grid is the grid adjacent to the first sampling point in the virtual grid model, and the difference matrix is used to represent the change in the illumination value in the adjacent grid; and the gradient regularization term is obtained based on the illumination matrix and the difference matrix.
[0120] By obtaining the normal direction of the first sampling point, the illumination matrix, and the difference matrix of adjacent meshes, and then deriving the gradient regularization term, this embodiment can more comprehensively consider the distribution of illumination in the virtual mesh model. When subsequently combining the illumination loss to construct the target loss function, the gradient regularization term can effectively constrain the smooth transition of illumination, making the lighting baking results more natural and realistic.
[0121] As an optional solution, in the process of obtaining the effective weight corresponding to each effective sampling point in the at least one effective sampling point, the method further includes:
[0122] S5-1, obtaining a normal direction corresponding to a second sampling point and a direction of a geometric normal, wherein at least one valid sampling point includes the second sampling point;
[0123] S5-2: Obtain an effective weight corresponding to the second sampling point according to the normal direction corresponding to the second sampling point and the direction of the geometric normal.
[0124] In an optional embodiment, the normal direction may be a vector perpendicular to the surface where the second sampling point is located, which reflects the orientation information of the surface at that point and is used in lighting calculations to determine how light interacts with the surface.
[0125] In an optional embodiment, the geometric normal direction may refer to the normal direction of the object surface in a geometric sense, which is calculated based on the geometric shape of the object and provides a reference direction for lighting calculation.
[0126] It should be noted that this embodiment, when obtaining the effective weights corresponding to each valid sampling point in at least one valid sampling point, calculates the effective weight corresponding to the second sampling point by obtaining its corresponding normal direction and the direction of the geometric normal. This process is intended to more accurately measure the importance of the sampling point in lighting calculations and improve the quality of lighting baking and reconstruction. The second sampling point is used for illustration only.
[0127] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0128] Through the embodiments provided in the present application, the normal direction corresponding to the second sampling point and the direction of the geometric normal are obtained, wherein at least one effective sampling point includes the second sampling point; and based on the normal direction corresponding to the second sampling point and the direction of the geometric normal, the effective weight corresponding to the second sampling point is obtained.
[0129] By obtaining the normal direction and geometric normal direction of the second sampling point and calculating the effective weight accordingly, this embodiment can more carefully consider the contribution of the sampling point to the lighting calculation. The effective weight reflects the degree of fit between the sampling point direction and the overall geometric lighting distribution, allowing for more reasonable allocation of computing resources and focus during lighting baking and reconstruction.
[0130] As an optional solution, according to the normal direction corresponding to the second sampling point and the direction of the geometric normal, the effective weight corresponding to the second sampling point is obtained, including:
[0131] S6-1, obtaining the angle between the normal direction corresponding to the second sampling point and the direction of the geometric normal;
[0132] S6-2: Obtain an effective weight corresponding to the second sampling point according to the included angle, wherein the effective weight corresponding to the second sampling point is negatively correlated with the included angle.
[0133] In an optional embodiment, the line direction is a vector perpendicular to the surface where the second sampling point is located, which reflects the orientation information of the surface at the point and is a key parameter for lighting calculation.
[0134] In an optional embodiment, the geometric normal direction may be the normal direction of the object surface in a geometric sense, which is calculated based on the geometric shape of the object and provides a reference direction for illumination calculation.
[0135] In an optional embodiment, the included angle may be the angle between the normal direction corresponding to the second sampling point and the geometric normal direction, which is used to measure the degree of difference between the two directions.
[0136] In an optional embodiment, the negative correlation relationship may be that the larger the angle, the smaller the effective weight; and the smaller the angle, the larger the effective weight, that is, the two show an inverse relationship.
[0137] It should be noted that this embodiment determines the effective weight corresponding to the second sampling point based on the angle between the normal direction corresponding to the second sampling point and the geometric normal direction. By clarifying the negative correlation between the angle and the effective weight, the importance of the second sampling point in the lighting calculation can be more accurately measured, thereby improving the quality and effectiveness of the lighting processing.
[0138] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0139] According to the embodiment provided in the present application, the angle between the normal direction corresponding to the second sampling point and the direction of the geometric normal is obtained; and the effective weight corresponding to the second sampling point is obtained based on the angle, wherein the effective weight corresponding to the second sampling point is negatively correlated with the angle.
[0140] By obtaining the angle between the normal direction corresponding to the second sampling point and the geometric normal direction, and determining the effective weight based on the negative correlation between the angle and the effective weight, this embodiment can more reasonably evaluate the importance of the sampling point in the lighting calculation.
[0141] As an optional solution, use the effective weight corresponding to each effective sampling point to perform lighting baking on at least one effective sampling point to obtain the baking result, including:
[0142] Using the effective weights corresponding to the effective sampling points, the illumination values of at least one effective sampling point are weighted averaged to obtain the overall illumination value of the effective area, where the baking result includes the overall illumination value.
[0143] In an optional embodiment, the illumination value may be information indicating illumination intensity or brightness at a valid sampling point, and is basic data for illumination calculation.
[0144] In an optional embodiment, weighted averaging can be a method of calculating an average value in which each data point is multiplied by a corresponding weight, and then all weighted data points are added together and divided by the sum of the weights to obtain a more reasonable average value.
[0145] In an optional embodiment, the overall illumination value may be a value obtained by weighted average calculation, which can reflect the overall illumination condition of the effective area.
[0146] It should be noted that this embodiment uses the effective weights corresponding to each effective sampling point to perform lighting baking on at least one effective sampling point, and obtains the overall lighting value of the effective area through weighted averaging as the baking result. This process is intended to more accurately reflect the lighting conditions of the effective area and improve the quality and effect of lighting baking.
[0147] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0148] Through the embodiments provided in this application, the effective weights corresponding to each valid sampling point are used to perform a weighted average of the illumination values of at least one valid sampling point to obtain the overall illumination value of the valid area, wherein the baking result includes the overall illumination value. By using the effective weights corresponding to each valid sampling point to perform a weighted average of the illumination values of the valid sampling points to obtain the overall illumination value of the valid area, this embodiment can more accurately simulate actual lighting conditions.
[0149] As an optional solution, and for ease of understanding, the aforementioned lighting baking can be applied to lighting rendering scenarios in 3D games to enhance game performance and realism. Specifically, when constructing lighting, high-precision lighting baking can be achieved for the effective direction of the active area simply through matrix multiplication.
[0150] The above-mentioned lighting baking can also be understood as a vertex-based lighting baking method based on spherical harmonic fitting. Through this vertex-based lighting baking method based on spherical harmonic fitting, this embodiment eliminates the need to uniformly sample spherical directions to obtain lighting from different directions and then calculate coefficients using spherical harmonic projection. Instead, the coefficients are directly fitted using information from valid directions, increasing the utilization of valid information and improving baking efficiency. Furthermore, this embodiment directly fits the spherical harmonics based on the effective directional lighting information of the valid area on the object's surface, eliminating the need to consider the spatial position of the lighting probes, thus avoiding visual artifacts caused by sudden changes in ambient lighting.
[0151] Among them, the illumination probe can be a point in space for recording illumination information; in this embodiment, the illumination probe is associated with the vertex, the spherical harmonic function can be used to store spherical illumination in the illumination probe, the vertexization can be used to associate the vertices of the triangle mesh with the illumination probe, and the color in the triangle is obtained by interpolation of the vertex color, and the spherical harmonic function projection can be a spherical uniform sampling and projection to the space of the spherical harmonic function basis function, as shown in the following formula (1):
[0152]
[0153] Where ci represents the coefficient of the i-th spherical harmonic function, N represents the total number of sampling points, L(xj) is the function value at the sampling point xj, and Yi(xj) represents the value of the i-th spherical harmonic function at the sampling point xj.
[0154] It should be noted that due to the influence of the normal map, in order to store the global illumination (GI) of static objects with high quality, it is necessary to store the hemispherical illumination information through spherical harmonics. Since this embodiment is aimed at the GI of static objects, the illumination information that needs to be baked is only the illumination information of the effective direction of the effective area. Therefore, in order to prevent the data redundancy problem of using the traditional spherical harmonic projection method to bake spatial illumination, this embodiment does not choose to bake the illumination information of all directions in the entire space, but instead Figure 4 As shown, the lighting information that needs to be baked is only the lighting information in the valid direction in the valid area.
[0155] Furthermore, when using spherical harmonic projection to bake spatial illumination, ambient illumination is prone to sudden changes, resulting in visual artifacts. Furthermore, if redundant information is baked in, the utilization rate of effective information is reduced. In this regard, this embodiment uses an analytical method to bake effective illumination information on the object surface.
[0156] Optional, such as Figure 5 As shown, the lighting information of the surface of static objects is processed and optimized. The three-dimensional cube and sphere represent that in the three-dimensional scene, the surface of the object needs to bake lighting information. This embodiment transforms the lighting baking problem into a linear regression problem, focusing only on the effective direction (fitting effective direction, which can be understood as the hemisphere space where the geometric normal is located) of the effective area (spherical harmonic function fitting effective area), which is not affected by the spatial position of the lighting probe and improves the utilization rate of effective information.
[0157] The spherical harmonics fitting valid regions represent the areas determined by a method (e.g., analytical methods) as valid regions. These regions are key areas for lighting baking. Fitting valid directions further determines which directions within these valid regions are important for lighting information, known as valid directions. SH represents the spherical harmonics, which is used to fit and store lighting information. p represents the valid points analytically determined during the spherical harmonics fitting process.
[0158] Optionally, the lighting rendering scene includes steps such as generating lighting probes in the model space, associating the lighting probes with vertices, and lighting baking. The above-mentioned lighting baking method can be improved and optimized for the lighting baking step.
[0159] To further illustrate, the optional Figure 5 The scene shown, continue as Figure 6 As shown in the figure, sampling points are evenly distributed across the surface of the object to be baked. These sampling points form the basis for subsequent lighting calculations. Valid sampling points are extracted from all sampling points using analytical methods. Valid sampling points are those that contribute to the final lighting effect.
[0160] For each valid sampling point, the hemispherical space is divided into multiple small areas, each of which corresponds to a specific lighting direction. Spherical harmonics (SH) are used to fit the hemispherical space of each valid sampling point to calculate the lighting information of each small area.
[0161] Spherical harmonics efficiently represent lighting information and can be solved using matrix equations. Solving the matrix equations yields lighting data for each valid sampling point. This data is then used in the subsequent lighting baking process.
[0162] It should be noted that in order to ensure the accuracy of the normal information after the normal map perturbation, it is necessary to bake the hemisphere lighting information where the geometric normal is located. For each instance, the relationship between the vertex and the probe point in the instance Under the given condition, the error between the effective area reconstruction and the real hemispherical illumination information is the smallest, as shown in the following formula (2):
[0163]
[0164] Giving a higher weight to the irradiance in the vertical direction, the final loss calculation function is obtained, as shown in the following formula (3):
[0165]
[0166] Among them, w(d) = max(0, cos(d, n)), where w is a weight function used to adjust the weight of the illumination error in different directions, d is the spherical sampling direction, n is the surface normal, S represents the surface of the model, Ω represents the hemisphere direction of the geometric normal of the corresponding sampling point, and f(p, d) is the actual illumination of the sampling point p in the effective direction d. Is the currently known relationship Bake and rebuild the resulting lighting.
[0167] According to the spherical harmonics formula, the formula for illumination reconstruction can be regarded as the product of the spherical harmonics coefficient SH and the basis function Y, where T is the transfer function, as shown in the following formula (4):
[0168]
[0169] Among them, the sampling points p1, p2, ..., To discretely represent the effective surface area, spherical sampling directions d1, d2, ..., Discretely represent the entire hemisphere space. Since the real lighting information is known, use I(p i ,d j ) represents the illumination of the sampling point p in the sampling direction d, and the objective function is rewritten in discrete form as the following formula (5):
[0170]
[0171] Write the above formula (5) into matrix form. And temporarily regard SH as an unknown variable, through To solve the minimum loss, the following formula (6) can be obtained:
[0172] w·(T(Y)·SH-I)=0 (6)
[0173] According to the illumination reconstruction model, the spherical harmonic function coefficients of the sampling point p are obtained by interpolating the coefficients of the three vertices of the triangle where it is located through barycentric coordinates. The coefficients of the vertex are obtained by the probe point X associated with the vertex. i and weight W i is composed of the following formulas (7) and (8).
[0174]
[0175] Based on this, the unknown variable SH is written as the product B·W·X of the barycentric coordinate matrix, the probe point weight matrix, and the probe point coefficient matrix X (solution target).
[0176] Convert the effective area lighting baking into a matrix solution (classic linear regression problem), such as the following formula (9), formula (10), and formula (11).
[0177] w·(T(Y)·B·W·XI)=0 (9)
[0178] (w·T(Y)·B·W)·X=w·I (10)
[0179] (w·T(Y)·B·W) T (w·T(Y)·B·W)·X=(w·T(Y)·B·W) T ·w·I(11)
[0180] Optionally, considering that global illumination information is low-frequency and smooth, focusing only on numerical fitting errors cannot guarantee that the visual effect meets expectations. Since the pixel value is obtained by interpolation of the vertex according to the barycentric coordinates, it is only necessary to perform gradient constraints on the color of the normal direction n of the vertex v, as shown in the following formula (12):
[0181]
[0182] Furthermore, this embodiment adopts a gradient smoothing method based on adjacent edges, such as the following formula (13):
[0183]
[0184] Among them, (t,u) is a triangle pair with adjacent edges, a t ,a u are the areas of the two triangles, and L is the illumination matrix in the direction of the vertex geometric normal. The triangle gradient calculation formula is as follows (14):
[0185]
[0186] Among them, v is the vertex coordinate, x is the value corresponding to the vertex, and here is the lighting value in the direction of the geometric normal.
[0187] Furthermore, this embodiment uses the difference matrix D to represent As shown in the following formula (15):
[0188] E reg =‖D·Y ′ ·W·X‖ 2 (15)
[0189] Among them, Y ′ It is the spherical harmonic basis function after the vertex is calculated by the convolution function.
[0190] The regularization term E reg Derivative X is taken and the derivative result is substituted into the loss calculation formula, as shown in the following formula (16):
[0191]
[0192] That is, the entire lighting baking is to solve the matrix of the above formula X.
[0193] Optionally, the content of this embodiment is applicable to other embodiments mentioned above, or combined with other embodiments mentioned above.
[0194] The embodiments provided herein eliminate the need to uniformly sample spherical directions to obtain illumination from different directions and then calculate coefficients using spherical harmonic projections. Instead, the coefficients are directly fitted using information from valid directions, increasing the utilization of this information and improving baking efficiency. Furthermore, this embodiment directly fits the spherical harmonics based on the effective directional illumination information for the valid area of the object's surface, eliminating the need to consider the spatial position of illumination probes and avoiding visual artifacts caused by sudden changes in ambient illumination.
[0195] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0196] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0197] According to another aspect of the embodiment of the present application, a light baking device for implementing the above light baking method is also provided. Figure 7 As shown, the device includes:
[0198] A first acquiring unit 702 is configured to acquire at least one valid sampling point on the virtual grid model, wherein a valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located;
[0199] A second acquiring unit 704 is configured to acquire an effective weight corresponding to each effective sampling point of the at least one effective sampling point, wherein the effective weight is used to indicate a degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area;
[0200] The first baking unit 706 is configured to perform lighting baking on at least one valid sampling point using the valid weight corresponding to each valid sampling point to obtain a baking result.
[0201] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0202] As an optional solution, the device further includes:
[0203] a reconstruction unit, configured to, in a process of performing lighting baking on at least one valid sampling point using effective weights corresponding to each valid sampling point to obtain a baking result, perform lighting reconstruction on the first sampling point using at least one lighting probe associated with the first sampling point to obtain a reconstructed lighting value corresponding to the first sampling point, wherein the at least one valid sampling point includes the first sampling point;
[0204] a third obtaining unit, configured to obtain a lighting difference between a reconstructed lighting value and an actual lighting value corresponding to the first sampling point in a process of performing lighting baking on at least one valid sampling point using the effective weights corresponding to the valid sampling points to obtain a baking result;
[0205] an integration unit, configured to integrate the illumination difference value and the effective weight corresponding to the first sampling point in a process of performing illumination baking on at least one effective sampling point using the effective weights corresponding to the effective sampling points to obtain the illumination loss corresponding to the first sampling point;
[0206] The second baking unit is configured to perform lighting baking on the first sampling point using the lighting loss to obtain a baking result corresponding to the first sampling point, while performing lighting baking on the at least one valid sampling point using the effective weight corresponding to each valid sampling point to obtain a baking result.
[0207] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0208] As an optional solution, rebuild the unit, including:
[0209] A first acquisition module is configured to acquire illumination information collected by at least one illumination probe, wherein the illumination information is used to represent illumination intensity of a first sampling point in various directions;
[0210] A second acquisition module is used to acquire an objective function according to the illumination information, wherein the objective function is used to represent the relationship between the illumination value at the first sampling point and the spherical harmonic function coefficients;
[0211] The first optimization module is used to obtain the optimal solution of the spherical harmonic function coefficients by minimizing the objective function;
[0212] The reconstruction module is used to reconstruct the illumination information using the optimal solution of the spherical harmonic function coefficients to obtain a reconstructed illumination value corresponding to the first sampling point.
[0213] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0214] As an optional solution, the second baking unit includes:
[0215] The combination module is used to combine the illumination loss and the gradient regularization term to obtain the target loss function, where the gradient regularization term is used to constrain the smooth transition of illumination;
[0216] The second optimization module is used to obtain optimal spherical harmonic coefficients by minimizing the target loss function, wherein the baking result includes the optimal spherical harmonic coefficients.
[0217] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0218] As an optional solution, the device further includes:
[0219] The third acquisition module is used to obtain the normal direction corresponding to the first sampling point before combining the illumination loss and the gradient regularization term to obtain the target loss function;
[0220] a fourth acquisition module, configured to obtain an illumination matrix corresponding to the first sampling point using the normal direction corresponding to the first sampling point before combining the illumination loss and the gradient regularization term to obtain the target loss function, wherein the illumination matrix is used to describe illumination information received by the vertex associated with the first sampling point in the virtual mesh model;
[0221] A fifth acquisition module is configured to obtain a difference matrix corresponding to adjacent grids before combining the illumination loss and the gradient regularization term to obtain the target loss function, wherein the adjacent grids are grids adjacent to the first sampling point in the virtual grid model, and the difference matrix is used to represent the change in illumination value in the adjacent grids;
[0222] The sixth acquisition module is used to obtain the gradient regularization term according to the illumination matrix and the difference matrix before combining the illumination loss and the gradient regularization term to obtain the target loss function.
[0223] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0224] As an optional solution, the device further includes:
[0225] a fourth acquiring unit, configured to acquire, in a process of acquiring an effective weight corresponding to each effective sampling point of at least one effective sampling point, a normal direction corresponding to the second sampling point and a direction of the geometric normal, wherein the at least one effective sampling point includes the second sampling point;
[0226] The fifth acquiring unit is configured to acquire the effective weight corresponding to the second sampling point according to the normal direction corresponding to the second sampling point and the direction of the geometric normal in the process of acquiring the effective weight corresponding to each effective sampling point of the at least one effective sampling point.
[0227] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0228] As an optional solution, the fifth obtaining unit includes:
[0229] a seventh acquisition module, configured to acquire an angle between a normal direction corresponding to the second sampling point and a direction of a geometric normal;
[0230] An eighth acquisition module is configured to acquire an effective weight corresponding to the second sampling point according to the included angle, wherein the effective weight corresponding to the second sampling point is negatively correlated with the included angle.
[0231] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0232] As an optional solution, the first baking unit 706 includes:
[0233] The weighting module is used to use the effective weight corresponding to each effective sampling point to perform weighted averaging on the illumination value of at least one effective sampling point to obtain the overall illumination value of the effective area, wherein the baking result includes the overall illumination value.
[0234] For specific embodiments, reference can be made to the examples shown in the above-mentioned light baking method, which will not be described in detail in this example.
[0235] According to another aspect of the embodiment of the present application, an electronic device for implementing the above-mentioned light baking method is also provided. The electronic device can be, but is not limited to, Figure 1 The user device 102 or server 112 shown in FIG. 1 is used as an example to illustrate the embodiment. Figure 8 As shown, the electronic device includes a memory 802 and a processor 804. The memory 802 stores a computer program, and the processor 804 is configured to execute the steps in any of the above method embodiments through the computer program.
[0236] In an optional embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0237] In an optional embodiment, the processor may be configured to execute the following steps via a computer program:
[0238] S1, obtaining at least one valid sampling point on the virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located;
[0239] S2, obtaining an effective weight corresponding to each effective sampling point in the at least one effective sampling point, wherein the effective weight is used to indicate the degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area;
[0240] S3: Perform lighting baking on at least one valid sampling point using the valid weight corresponding to each valid sampling point to obtain a baking result.
[0241] Alternatively, those skilled in the art will appreciate that Figure 8 The structure shown is for illustration only. Figure 8 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 8 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 8 Different configurations shown.
[0242] Among them, the memory 802 can be used to store software programs and modules, such as the program instructions / modules corresponding to the lighting baking method and device in the embodiment of the present application. The processor 804 executes various functional applications and data processing by running the software programs and modules stored in the memory 802, that is, to realize the above-mentioned lighting baking method. The memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 802 may further include a memory remotely located relative to the processor 804, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 802 can be used specifically, but not limited to, to store information such as valid sampling points, valid weights, and baking results. As an example, if Figure 8 As shown, the memory 802 may include, but is not limited to, the first acquisition unit 702, the second acquisition unit 704, and the first baking unit 706 in the light baking device. In addition, it may also include, but is not limited to, other module units in the light baking device, which will not be repeated in this example.
[0243] Optionally, the transmission device 806 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 806 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 806 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0244] In addition, the electronic device further includes: a display 808 for displaying information such as the effective sampling points, effective weights, and baking results; and a connection bus 810 for connecting various module components in the electronic device.
[0245] In other embodiments, the user device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes via network communication. The nodes may form a peer-to-peer network, and any computing device, such as a server, user device, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0246] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0247] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0248] It should be noted that the computer system of the electronic device is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0249] A computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from the storage unit into random access memory (RAM). The RAM also stores various programs and data required for system operation. The CPU, the read-only memory, and the RAM are connected to each other via a bus. Input / output interfaces (I / O interfaces) are also connected to the bus.
[0250] The following components are connected to the input / output interface: an input section including a keyboard, mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section including a hard disk; and a communication section including a network interface card such as a local area network card and a modem. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the input / output interface as needed. Removable media such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc. are installed in the drive as needed so that computer programs read from them can be installed into the storage section as needed.
[0251] In particular, according to an embodiment of the present application, the processes described in the various method flow charts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flow charts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication portion, and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions defined in the system of the present application are performed.
[0252] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various optional implementations described above.
[0253] In an optional embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0254] S1, obtaining at least one valid sampling point on the virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located;
[0255] S2, obtaining an effective weight corresponding to each effective sampling point in the at least one effective sampling point, wherein the effective weight is used to indicate the degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area;
[0256] S3: Perform lighting baking on at least one valid sampling point using the valid weight corresponding to each valid sampling point to obtain a baking result.
[0257] Alternatively, in the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0258] In an optional embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the electronic device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0259] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0260] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods of each embodiment of the present application.
[0261] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0262] In the several embodiments provided in this application, it should be understood that the disclosed user equipment can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.
[0263] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0264] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0265] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A light baking method, characterized in that: include: Acquire at least one valid sampling point on the virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located; Obtaining an effective weight corresponding to each effective sampling point in the at least one effective sampling point, wherein the effective weight is used to indicate a degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area; Light baking is performed on the at least one valid sampling point using the valid weights corresponding to the valid sampling points to obtain a baking result.
2. The method according to claim 1, characterized in that In the process of performing lighting baking on the at least one valid sampling point using the valid weights corresponding to the valid sampling points to obtain a baking result, the method further includes: Using at least one illumination probe associated with a first sampling point, reconstruct illumination for the first sampling point to obtain a reconstructed illumination value corresponding to the first sampling point, wherein the at least one valid sampling point includes the first sampling point; Obtaining an illumination difference between the reconstructed illumination value and an actual illumination value corresponding to the first sampling point; Integrating the illumination difference and the effective weight corresponding to the first sampling point to obtain an illumination loss corresponding to the first sampling point; Light baking is performed on the first sampling point using the light loss to obtain a baking result corresponding to the first sampling point.
3. The method according to claim 2, characterized in that The using at least one illumination probe associated with the first sampling point to perform illumination reconstruction on the first sampling point to obtain a reconstructed illumination value corresponding to the first sampling point includes: Acquire lighting information collected by the at least one lighting probe, wherein the lighting information is used to represent the lighting intensity of the first sampling point in various directions; Obtaining an objective function according to the illumination information, wherein the objective function is used to represent a relationship between an illumination value at the first sampling point and a spherical harmonic function coefficient; Obtaining an optimal solution for the spherical harmonic coefficients by minimizing the objective function; The illumination information is reconstructed using the optimal solution of the spherical harmonic function coefficients to obtain a reconstructed illumination value corresponding to the first sampling point.
4. The method according to claim 2, characterized in that The performing lighting baking on the first sampling point by utilizing the lighting loss to obtain a baking result corresponding to the first sampling point includes: Combining the illumination loss and the gradient regularization term to obtain a target loss function, wherein the gradient regularization term is used to constrain the smooth transition of illumination; By minimizing the target loss function, optimal spherical harmonic coefficients are obtained, wherein the baking result includes the optimal spherical harmonic coefficients.
5. The method according to claim 4, characterized in that Before combining the illumination loss and the gradient regularization term to obtain the target loss function, the method further includes: Obtaining the normal direction corresponding to the first sampling point; Obtaining an illumination matrix corresponding to the first sampling point using the normal direction corresponding to the first sampling point, wherein the illumination matrix is used to describe illumination information received by vertices associated with the first sampling point in the virtual mesh model; Obtaining a difference matrix corresponding to an adjacent grid, wherein the adjacent grid is a grid adjacent to the first sampling point in the virtual grid model, and the difference matrix is used to represent a change in illumination value in the adjacent grid; The gradient regularization term is obtained according to the illumination matrix and the difference matrix.
6. The method according to claim 1, characterized in that In the process of obtaining the effective weight corresponding to each effective sampling point in the at least one effective sampling point, the method further includes: Obtaining a normal direction corresponding to a second sampling point and a direction of the geometric normal, wherein the at least one valid sampling point includes the second sampling point; An effective weight corresponding to the second sampling point is obtained according to the normal direction corresponding to the second sampling point and the direction of the geometric normal.
7. The method according to claim 6, characterized in that The obtaining, according to the normal direction corresponding to the second sampling point and the direction of the geometric normal, an effective weight corresponding to the second sampling point includes: Obtaining the angle between the normal direction corresponding to the second sampling point and the direction of the geometric normal; An effective weight corresponding to the second sampling point is acquired according to the angle, wherein there is a negative correlation between the effective weight corresponding to the second sampling point and the angle.
8. The method according to any one of claims 1 to 7, characterized in that The performing lighting baking on the at least one valid sampling point by using the valid weights corresponding to the respective valid sampling points to obtain a baking result includes: Using the effective weights corresponding to the effective sampling points, a weighted average is performed on the illumination value of at least one effective sampling point to obtain an overall illumination value of the effective area, wherein the baking result includes the overall illumination value.
9. A light baking device, characterized in that: include: a first acquiring unit, configured to acquire at least one valid sampling point on the virtual grid model, wherein the valid sampling point is a sampling point on the virtual grid model that is located within a valid area, and the valid area is an area where a geometric normal of the virtual grid model is located; a second acquiring unit, configured to acquire an effective weight corresponding to each effective sampling point of the at least one effective sampling point, wherein the effective weight is used to indicate a degree of proximity between a direction of the effective sampling point and a sampling direction of the effective area; The first baking unit is configured to perform lighting baking on the at least one valid sampling point by using the valid weights corresponding to the valid sampling points to obtain a baking result.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 8 when executed by an electronic device.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 8 through the computer program.