Differentiable rendering method, apparatus, electronic device, and storage medium

By acquiring and stitching pixel information from the initial and target images to form a point set and matching the loss function, scene parameters are optimized. This solves the problem that existing differentiable rendering methods cannot converge when the initial and target scenes differ significantly, achieving more efficient scene optimization and convergence.

CN115375816BActive Publication Date: 2026-11-27TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211086064.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-06
Publication Date
2026-11-27
Estimated Expiration
2042-09-06

AI Technical Summary

Technical Problem

Existing differentiable rendering methods cannot converge when there is a large difference between the initial scene and the target scene, and the gradient is sparse and limited to the object boundary.

Method used

By acquiring the initial scene and target images, rendering and stitching them together to form a set of rendering points and a set of target points, a loss function is obtained based on distance matching, and scene parameters are optimized through gradient descent. By utilizing global information and stable gradient calculation, the problems of function discontinuity and gradient sparsity in traditional methods are avoided.

Benefits of technology

It improves the convergence of the rendering method, effectively minimizing the difference between the initial scene and the target scene, and achieving stable gradient calculation and optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115375816B_ABST
    Figure CN115375816B_ABST
Patent Text Reader

Abstract

The application provides a micro-rendering method, device, electronic equipment and storage medium, wherein the micro-rendering method comprises: obtaining an initial scene and a target picture; rendering the initial scene to obtain a rendered picture; obtaining second color information and second position information based on the target picture; splicing first color information and first position information in the rendered picture to obtain a rendering point set; splicing the second color information and the second position information to obtain a target point set; matching each rendering point in the rendering point set based on the target point set to obtain a matching point; obtaining a loss function based on the distance between the rendering point and the matching point; optimizing scene parameters of the initial scene based on the loss function to obtain optimized scene parameters, and obtaining a target scene corresponding to the target picture based on the optimized scene parameters. Through the application, the difference between the initial scene and the target scene can be minimized, and the convergence can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of differentiable rendering technology, and more particularly to a differentiable rendering method, apparatus, electronic device, and storage medium. Background Technology

[0002] Rendering can be viewed as a function that takes a 3D scene as input and outputs a 2D image; its theory and methods are increasingly mature. In recent years, with the development of deep learning technology, the inverse function of rendering—inverse rendering—has begun to receive more and more attention. Inverse rendering takes a 2D image as input and outputs 3D scene information. Inverse rendering is an ill-posed problem, far more difficult than traditional forward rendering.

[0003] According to relevant technologies, differentiable rendering is a method to solve the problem of inverse rendering. In traditional rendering functions, the rendering result is not differentiable with respect to certain input scene parameters, such as vertex positions. However, differentiable rendering makes the rendering result differentiable with respect to any input parameters. This allows differentiable rendering to overcome the limitation of traditional methods that cannot incorporate rendering into deep learning-based inverse rendering methods.

[0004] However, the gradients of the object's geometric parameters obtained by current differentiable rendering are sparse and limited to the object's boundaries, and often fail to converge when the initial scene and the target are significantly different. Summary of the Invention

[0005] This invention provides a differentiable rendering method, apparatus, electronic device, and storage medium to address the shortcomings of existing technologies that often fail to converge when faced with a large difference between the initial scene and the target scene. It can minimize the difference between the initial scene and the target scene and improve convergence.

[0006] This invention provides a differentiable rendering method, the differentiable rendering method comprising:

[0007] S1: Obtain the initial scene and target image;

[0008] S2: Render the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes the first color information and the first position information of each first pixel.

[0009] S3: Based on the target image, obtain the second color information and second position information of each second pixel in the target image;

[0010] S4: The first color information and the first position information of each first pixel in the rendered image are concatenated to obtain a set of rendered points;

[0011] S5: The second color information and the second position information of each second pixel in the target image are concatenated to obtain a target point set;

[0012] S6: Based on the target point set, match each rendering point in the rendering point set to obtain the matching point;

[0013] S7: Based on the distance between the rendering point and the matching point, obtain the loss function;

[0014] S8: Based on the loss function, optimize the scene parameters of the initial scene using gradient descent;

[0015] S9: By optimizing the scene parameters of the initial scene, optimized scene parameters are obtained, and based on the optimized scene parameters, a target scene corresponding to the target image is obtained.

[0016] According to a differentiable rendering method provided by the present invention, the first position information of the first pixel in the rendered image is determined in the following manner:

[0017] When performing rasterization on the first pixel in the rendered image, if the first pixel has a shading point, the first position information of the first pixel is determined based on the projection coordinates of the shading point.

[0018] When performing rasterization on the first pixel in the rendered image, if the first pixel does not have a shading point, the first position information of the first pixel is determined based on the pixel center coordinates of the first pixel.

[0019] According to a differentiable rendering method provided by the present invention, the second position information of the second pixel in the target image is determined in the following manner:

[0020] Based on the pixel center coordinates of the second pixel in the target image, the second position information of the second pixel is determined.

[0021] According to a differentiable rendering method provided by the present invention, the loss function is obtained based on the distance between the rendering point and the matching point, and is determined using the following formula:

[0022]

[0023] Where L(P) represents the loss function; P represents the set of rendering points; |P| represents the number of rendering points in the set of rendering points; p i This represents the i-th rendering point in the set of rendering points; Represents the rendering point p i matching points; Represents the rendering point pi and matching points The distance.

[0024] According to a differentiable rendering method provided by the present invention, the optimization of scene parameters of the initial scene based on the loss function using gradient descent specifically includes:

[0025] Based on the loss function, the scene parameters of the initial scene are optimized by gradient descent to obtain the initial optimized scene parameters;

[0026] Based on the initial optimized parameters, an optimized initial scene is obtained, and the optimized initial scene is used as the initial scene to be repeatedly executed for a preset number of times S2 to S8.

[0027] The present invention also provides a differentiable rendering apparatus, the differentiable rendering apparatus comprising:

[0028] The first module is used to acquire the initial scene and target image;

[0029] The second module is used to render the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes the first color information and the first position information of each first pixel.

[0030] The third module is used to obtain the second color information and second position information of each second pixel in the target image based on the target image;

[0031] The fourth module is used to concatenate the first color information and the first position information of each first pixel in the rendered image to obtain a set of rendered points;

[0032] The fifth module is used to concatenate the second color information and the second position information of each second pixel in the target image to obtain a target point set;

[0033] The sixth module is used to match each rendering point in the rendering point set based on the target point set to obtain matching points;

[0034] The seventh module is used to obtain a loss function based on the distance between the rendering point and the matching point;

[0035] The eighth module is used to optimize the scene parameters of the initial scene based on the loss function using gradient descent.

[0036] The ninth module is used to obtain optimized scene parameters by optimizing the scene parameters of the initial scene, and to obtain the target scene corresponding to the target image based on the optimized scene parameters.

[0037] According to a differentiable rendering apparatus provided by the present invention, the second module determines the first position information of the first pixel in the rendered image in the following manner:

[0038] When performing rasterization on the first pixel in the rendered image, if the first pixel has a shading point, the first position information of the first pixel is determined based on the projection coordinates of the shading point.

[0039] When rasterizing the first pixel in the rendered image, if the first pixel does not have a shading point, the first position information of the first pixel is determined based on the pixel center coordinates of the first pixel.

[0040] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the differentiable rendering method as described above.

[0041] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the differentiable rendering method as described above.

[0042] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the differentiable rendering method as described above.

[0043] The differentiable rendering method, apparatus, electronic device, and storage medium provided by this invention renders an initial scene to obtain a rendered image. A set of rendered points is obtained by concatenating the first color information and first position information of each first pixel in the rendered image. A target set of points is obtained by concatenating the second color information and second position information of each second pixel in the target image. This avoids the discontinuity of pixel color as a function of vertex positions in the scene, as well as gradient limitations and sparsity problems in traditional methods. Based on the target set, matching points are obtained by matching each rendered point in the set. A loss function is derived based on the distance between the rendered points and the matching points. Scene parameters are then optimized based on the loss function to obtain optimized scene parameters, ultimately yielding a target scene corresponding to the target image. This minimizes the difference between the initial and target scenes and improves convergence. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0045] Figure 1 This is one of the flowcharts of the differentiable rendering method provided by the present invention;

[0046] Figure 2 This is the second flowchart of the differentiable rendering method provided by the present invention;

[0047] Figure 3 This is a schematic diagram of the structure of the differentiable rendering method apparatus provided by the present invention;

[0048] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0050] According to relevant technologies, the gradients obtained by traditional differentiable rendering methods regarding the geometric changes of objects are sparse and limited to the object boundaries. When faced with a large difference between the initial scene and the target, they often fail to converge.

[0051] To overcome this limitation, we can draw inspiration from the Lagrange perspective in fluid simulation to arrive at the differentiable rendering method provided in this invention. Traditional differentiable rendering methods can be viewed as the Eulerian perspective in fluid simulation: they observe a fixed part of the scene through fixed pixels, similar to observing fluid through a fixed mesh, and optimize scene parameters by ensuring the consistency of the pixels (mesh) of the rendered result and the target image.

[0052] However, in the differentiable rendering method provided by this invention, the scene can be regarded as a series of movable particles, similar to tracking each fluid particle in fluid simulation. By finding the target position of each particle and calculating the derivative of the rendering result with respect to the particle position and color, the problem of discontinuity of pixel color with respect to vertex position in the scene and the locality and sparsity of gradient in traditional methods are avoided.

[0053] To further introduce the differentiable rendering method provided by this invention, the following will be combined with... Figure 1 Please provide an explanation.

[0054] Figure 1 This is one of the flowcharts of the differentiable rendering method provided by the present invention.

[0055] In an exemplary embodiment of the present invention, combined with Figure 1 As can be seen, the differentiable rendering method may include steps 110 to 190, and each step will be described below.

[0056] It should be noted that steps 110 to 190 described below correspond to S1 to S9 in the preceding text, respectively.

[0057] In step 110, the initial scene and target image are obtained.

[0058] In one embodiment, any initial scene can be acquired. The initial scene may include information such as models, materials, lighting, and viewpoint (also known as camera). The target image can be a rendered image or a real photograph of one or more viewpoints of the final output target scene.

[0059] In the context of human pose prediction, the initial scene can be a standardized human model. The target image can be a human pose image obtained from any viewpoint. The target scene can be a human pose. Based on the human pose of the target scene, information such as the human body's position (or joint position) can be obtained.

[0060] In the context of human expression prediction, the initial scene can be any expressionless face model. The target image can be a face image obtained from any viewpoint. The target scene can be a facial expression. Furthermore, based on the facial expression within the target scene, information such as facial expression details from various viewpoints can be obtained.

[0061] In the context of home furnishings, the initial scene can be any cluttered arrangement of furniture. The target image can be an image of a specific home furnishing scene taken from any perspective. The target scene can be a home furnishing scene related to the target image.

[0062] In step 120, the initial scene is rendered to obtain a rendered image corresponding to the initial scene. The rendered image includes the first color information and the first position information of each first pixel.

[0063] In one embodiment, a differentiable renderer can be used to render the initial scene and output a rendered image corresponding to the initial scene. The rendered image is composed of multiple first pixels, and may further include first color information and first position information for each first pixel.

[0064] In one example, during the acquisition of the first color information, the triangle covering the first pixel and the points on the triangle corresponding to the actual sampling point of the first pixel can be found (oversampling is not considered). Specifically, for each first pixel p, the triangle formed by the three vertices v0, v1, and v2 in the scene can be found, as well as the centroid coordinates w = (w0, w1, w2) used to calculate the shading point. It can be understood that the centroid coordinates are three-dimensional coordinates. Among them, the shading point can be expressed as formula (1):

[0065] v=w0*v0+w1*v1+w2*v2 (1)

[0066] In an exemplary embodiment of the present invention, the first position information of the first pixel in the rendered image can be determined in the following manner:

[0067] When rasterizing the first pixel in the rendered image, if the first pixel has a shading point, the first position information of the first pixel is determined based on the projection coordinates of the shading point.

[0068] When rasterizing the first pixel in the rendered image, if the first pixel does not have a shading point, the first position information of the first pixel is determined based on the pixel center coordinates of the first pixel.

[0069] In other words, if the model in the initial scene covers the first pixel, the first position information of the first pixel can be determined by calculating the projection coordinates of the shading point corresponding to this first pixel during the rasterization process.

[0070] If the model in the initial scene does not cover the first pixel, then the pixel center coordinates of the first pixel can be determined as the first position information of the first pixel.

[0071] In traditional methods, v in formula (1) is only used to calculate color. However, in the differentiable rendering method provided by this invention, v is additionally projected onto the screen space through a projection matrix to obtain the two-dimensional screen coordinates of v (also known as the projected coordinates of the shading point). screen =(v x ,v y )∈[-1,1] 2 Then linearly transform it to [0,1]. 2 This process establishes a connection between pixel position (corresponding to the first position information) and shading point position v in the computation graph, making the pixel position a function of the shading point position v in the actual scene. Therefore, for color calculation, the derivative of the shading point color with respect to the shading point position v is no longer calculated, thus avoiding the discontinuity problem of color change with position in traditional methods.

[0072] In step 130, based on the target image, the second color information and second position information of each second pixel in the target image are obtained.

[0073] In one embodiment, for each second pixel in the target image, the second color information of the second pixel can be directly obtained.

[0074] In another embodiment, the second position information of the second pixel in the target image can be determined in the following manner:

[0075] Based on the pixel center coordinates of the second pixel in the target image, determine the second position information of the second pixel.

[0076] In step 140, the first color information and first position information of each first pixel in the rendered image are concatenated to obtain a set of rendered points.

[0077] In one embodiment, for each first pixel in the rendered image, first color information and first position information are obtained in step 120. It is understood that the first color information is represented by three-dimensional coordinates, and the first position information is represented by two-dimensional coordinates. After concatenating the first color information and first position information of each first pixel in the rendered image, the first pixel can be considered as a point in a five-dimensional space, and this point can be called a rendering point. It is understood that a rendering point set can be obtained based on multiple rendering points.

[0078] In step 150, the second color information and second position information of each second pixel in the target image are concatenated to obtain the target point set.

[0079] In one embodiment, for each second pixel in the target image, second color information and second position information are obtained respectively in step 130. It is understood that the second color information is represented by three-dimensional coordinates, and the second position information is represented by two-dimensional coordinates. After concatenating the second color information and second position information of each second pixel in the target image, the second pixel can be regarded as a point in a five-dimensional space, and this point can be called a target point. It is understood that based on multiple target points, a target point set can be obtained.

[0080] In another embodiment, the example corresponding to formula (1) will continue to be used for explanation. For the first pixel not covered by the triangle in the rendering result (corresponding to the rendered image) and the second pixel in the target image, the first position information can be defined as the coordinates of the pixel center of the first pixel in screen space, and the second position information can be defined as the coordinates of the pixel center of the second pixel in screen space, and both can be normalized to [0,1]. 2The color information of each pixel in the rendered result and the target image (corresponding to the first color information and the second color information) is normalized to [0,1]. 3 The color and position information are concatenated, and each pixel corresponds to a location in [0,1]. 5 The points in the [0,1] range. Therefore, the rendered result and the target image are respectively converted to [0,1]. 5 A set of points (corresponding to the rendering point set and the target point set, respectively).

[0081] In step 160, based on the target point set, each rendering point in the rendering point set is matched to obtain the matching points.

[0082] In step 170, the loss function is obtained based on the distance between the rendering point and the matching point.

[0083] In one embodiment, a match can be found between the target point set and the rendering point set, thus finding a matching point for each rendering point in the rendering point set.

[0084] In one embodiment, [0,1] can be defined. 5 The distance between two points in space. In one example, the Euclidean distance can be used to determine the distance between points. For example, the distance D(a,b) between points a and b can be defined by formula (2):

[0085] D(a,b)=||ab||2 (2)

[0086] Next, consider finding the optimal matching between point sets. Several methods exist, such as bipartite graph matching, optical flow matching, and optimal transmission matching. In one example, a discrete optimal transmission algorithm can be chosen for matching.

[0087] Among them, the discrete optimal transmission algorithm solves the following problem: given two points A and B, the distance D between any two points (A, B, and C) is... i B j ), and the quality of each point. in, The transfer matrix T can be solved to satisfy the following formulas (3) and (4):

[0088] T = argmin T ∑T ij D(A i B j (3)

[0089]

[0090] Among them, A i Let A represent the i-th point in the set of points; B jLet B represent the j-th point in the point set; T is a two-dimensional transfer matrix. In this example, it is assumed that the quality of the entire image is 1, and the quality of each pixel is the same. In the specific implementation, we use the Sinkhorn algorithm to obtain a low-frequency approximation solution for the optimal transfer matrix T: The Sinkhorn algorithm provides a point (corresponding to a matching point). Approximate representation of ∑ j T ij B j It should be noted that A i It can represent a rendering point. A represents i After calculating the matching results for the matching points, the loss function can be calculated based on the matching results, i.e., based on the distance between the rendering point and the matching point.

[0091] In step 180, the scene parameters of the initial scene are optimized using gradient descent based on the loss function.

[0092] In step 190, the scene parameters of the initial scene are optimized to obtain the optimized scene parameters, and the target scene corresponding to the target image is obtained based on the optimized scene parameters.

[0093] In one embodiment, gradient descent can be used to optimize scene parameters and minimize the loss function. Since the entire process is differentiable, automatic differentiation methods can be used to directly solve for the derivative of the loss function with respect to the scene parameters of the initial scene.

[0094] Furthermore, by optimizing the scene parameters of the initial scene, optimized scene parameters are obtained, and based on the optimized scene parameters, the target scene corresponding to the target image is obtained.

[0095] It should be noted that in this embodiment, the gradient used for calculating the gradient is numerically stable and does not exhibit infinity; furthermore, global information is utilized when calculating the gradient, resulting in a better effect on optimizing scene parameters; additionally, the gradient obtained by this invention is dense and not limited to the boundaries of objects; this method is simple and easy to implement, requiring only slight modifications to a traditional differentiable renderer and the addition of a matching algorithm.

[0096] The differentiable rendering method provided by this invention renders an initial scene to obtain a rendered image. It then concatenates the first color and first position information of each first pixel in the rendered image to obtain a set of rendered points, and concatenates the second color and second position information of each second pixel in the target image to obtain a target set of points. This avoids the discontinuity of pixel color as a function of vertex positions in the scene, as well as gradient limitations and sparsity issues, common in traditional methods. Based on the target set of points, it matches the rendered points in the set to obtain matching points, and calculates a loss function based on the distance between the rendered points and the matching points. The scene parameters are then optimized based on the loss function to obtain optimized scene parameters, ultimately yielding a target scene corresponding to the target image. This minimizes the difference between the initial and target scenes and improves convergence.

[0097] In an exemplary embodiment of the present invention, a loss function is obtained based on the distance between the rendering point and the matching point, and is determined using the following formula (5):

[0098]

[0099] Where L(P) represents the loss function; P represents the set of rendering points; |P| represents the number of rendering points in the set; p i This represents the i-th rendering point in the set of rendering points; Represents the rendering point p i matching points; Represents the rendering point p i and matching points The distance.

[0100] In another embodiment, the loss function can also be determined based on a weighted average of the distances between the rendering point and the matching point, or by summing the distances. In this embodiment, the specific process of obtaining the loss function based on the distances between the rendering point and the matching point is not limited.

[0101] To further introduce the differentiable rendering method provided by this invention, the following will be combined with... Figure 2 Please provide an explanation.

[0102] In yet another exemplary embodiment of the present invention, combined with Figure 2 As can be seen, the differentiable rendering method may include steps 201 to 210, wherein steps 201 to 207 are the same as or similar to steps 110 to 170, and step 210 is the same as or similar to step 109. For the specific implementation and beneficial effects, please refer to the previous description. In this embodiment, they will not be repeated. Steps 208 and 209 will be introduced below.

[0103] In step 208, the scene parameters of the initial scene are optimized by gradient descent based on the loss function to obtain the initial optimized scene parameters.

[0104] In step 209, based on the initial optimized parameters, the optimized initial scene is obtained, and the optimized initial scene is used as the initial scene to repeat steps 202 to 208 a preset number of times.

[0105] In one embodiment, the gradient of the loss function with respect to the scene parameters can be calculated, and the scene parameters of the initial scene can be updated by gradient descent to obtain the initial optimized scene parameters. Further, an optimized initial scene can be obtained based on the initial optimized parameters. Then, using the optimized initial scene as the initial scene, steps 202 to 208 are repeated a preset number of times until the final optimized initial scene parameters are obtained, thus obtaining the optimized scene parameters. The preset number of times can be adjusted according to actual conditions; in this embodiment, no specific limitation is made.

[0106] In another embodiment, the optimized initial scene can be used as the initial scene, and steps 202 to 208 can be repeated for a preset time until the scene parameters of the final optimized initial scene are obtained, thereby obtaining the optimized scene parameters. The preset time can be adjusted according to actual conditions, and is not specifically limited in this embodiment.

[0107] As described above, the differentiable rendering method provided by this invention renders an initial scene to obtain a rendered image, and then concatenates the first color information and first position information of each first pixel in the rendered image to obtain a set of rendered points. Similarly, it concatenates the second color information and second position information of each second pixel in the target image to obtain a target set of points. This avoids the discontinuity of pixel color as a function of vertex positions in the scene, as well as gradient limitations and sparsity issues, common in traditional methods. Based on the target set of points, matching points are obtained by matching each rendered point in the set of rendered points. A loss function is derived based on the distance between the rendered points and the matching points, and scene parameters are optimized based on the loss function to obtain optimized scene parameters, thus obtaining the target scene corresponding to the target image. This minimizes the difference between the initial scene and the target scene and improves convergence.

[0108] Based on the same concept, the present invention also provides a differentiable rendering apparatus.

[0109] The differentiable rendering apparatus provided by the present invention is described below. The differentiable rendering apparatus described below can be referred to in correspondence with the differentiable rendering method described above.

[0110] Figure 3 This is a schematic diagram of the structure of the differentiable rendering method device provided by the present invention.

[0111] In an exemplary embodiment of the present invention, combined with Figure 3As can be seen, the differentiable rendering device may include the first module 310 to the ninth module 390, and each module will be described below.

[0112] The first module 310 can be configured to acquire the initial scene and the target image;

[0113] The second module 320 can be configured to render the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes the first color information and the first position information of each first pixel.

[0114] The third module 330 can be configured to obtain the second color information and second position information of each second pixel in the target image based on the target image.

[0115] The fourth module 340 can be configured to concatenate the first color information and first position information of each first pixel in the rendered image to obtain a set of rendered points;

[0116] The fifth module 350 can be configured to stitch together the second color information and second position information of each second pixel in the target image to obtain a target point set;

[0117] The sixth module 360 ​​can be configured to match each rendering point in the rendering point set based on the target point set to obtain the matching point;

[0118] Module 370 can be configured to derive a loss function based on the distance between the rendering point and the matching point;

[0119] Module 8, 380, can be configured to optimize the scene parameters of the initial scene using gradient descent based on a loss function.

[0120] The ninth module 390 can be configured to obtain optimized scene parameters by optimizing the scene parameters of the initial scene, and obtain the target scene corresponding to the target image based on the optimized scene parameters.

[0121] In an exemplary embodiment of the present invention, the second module 320 may determine the first position information of the first pixel in the rendered image in the following manner:

[0122] When rasterizing the first pixel in the rendered image, if the first pixel has a shading point, the first position information of the first pixel is determined based on the projection coordinates of the shading point.

[0123] When rasterizing the first pixel in the rendered image, if the first pixel does not have a shading point, the first position information of the first pixel is determined based on the pixel center coordinates of the first pixel.

[0124] In an exemplary embodiment of the present invention, the third module 330 may determine the second position information of the second pixel in the target image in the following manner:

[0125] The second position information of the second pixel is determined based on the pixel center coordinates of the second pixel in the target image.

[0126] In an exemplary embodiment of the present invention, the seventh module 370 may use the following formula (6) to obtain the loss function based on the distance between the rendering point and the matching point:

[0127]

[0128] Where L(P) represents the loss function; P represents the set of rendering points; |P| represents the number of rendering points in the set; p i This represents the i-th rendering point in the set of rendering points; Represents the rendering point p i matching points; Represents the rendering point p i and matching points The distance.

[0129] In an exemplary embodiment of the present invention, the eighth module 380 may optimize the scene parameters of the initial scene based on the loss function using gradient descent in the following manner:

[0130] Based on the loss function, the scene parameters of the initial scene are optimized by gradient descent to obtain the initial optimized scene parameters;

[0131] Based on the initial optimized parameters, the optimized initial scene is obtained, and the optimized initial scene is used as the initial scene to be repeatedly executed for a preset number of times, from S2 to S8.

[0132] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a differentiable rendering method, which includes: S1: acquiring an initial scene and a target image; S2: rendering the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes the first color information and first position information of each first pixel; S3: acquiring the second color information and second position information of each second pixel in the target image based on the target image; S4: concatenating the first color information and first position information of each first pixel in the rendered image to obtain a set of rendering points; S5: concatenating the second color information and second position information of each second pixel in the target image to obtain a set of target points; S6: matching each rendering point in the set of rendering points based on the set of target points to obtain matching points; S7: obtaining a loss function based on the distance between the rendering points and the matching points; S8: optimizing the scene parameters of the initial scene using gradient descent based on the loss function; S9: obtaining optimized scene parameters by optimizing the scene parameters of the initial scene, and obtaining the target scene corresponding to the target image based on the optimized scene parameters.

[0133] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0134] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the differentiable rendering method provided by the above methods. The method includes: S1: acquiring an initial scene and a target image; S2: rendering the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes first color information and first position information of each first pixel; S3: acquiring second color information and second position information of each second pixel in the target image based on the target image. S4: Concatenate the first color information and first position information of each first pixel in the rendered image to obtain a set of rendered points; S5: Concatenate the second color information and second position information of each second pixel in the target image to obtain a set of target points; S6: Based on the target point set, match each rendered point in the set of rendered points to obtain matching points; S7: Obtain a loss function based on the distance between the rendered points and the matching points; S8: Based on the loss function, optimize the scene parameters of the initial scene using gradient descent; S9: Obtain optimized scene parameters by optimizing the scene parameters of the initial scene, and obtain the target scene corresponding to the target image based on the optimized scene parameters.

[0135] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the differentiable rendering method provided by the above methods. The method includes: S1: acquiring an initial scene and a target image; S2: rendering the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes first color information and first position information of each first pixel; S3: based on the target image, acquiring second color information and second position information of each second pixel in the target image; S4: processing each first pixel in the rendered image... S5: Concatenate the first color information and first position information of each point to obtain a set of rendering points; S6: Concatenate the second color information and second position information of each second pixel in the target image to obtain a set of target points; S7: Based on the target point set, match each rendering point in the set of rendering points to obtain matching points; S8: Based on the distance between the rendering points and the matching points, obtain the loss function; S9: Based on the loss function, optimize the scene parameters of the initial scene using gradient descent; S10: By optimizing the scene parameters of the initial scene, obtain the optimized scene parameters, and based on the optimized scene parameters, obtain the target scene corresponding to the target image.

[0136] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The 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 the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0138] It is further understood that although the operations are described in a specific order in the accompanying drawings in the embodiments of the present invention, this should not be construed as requiring these operations to be performed in the specific order or serial order shown, or requiring all the operations shown to be performed to obtain the desired result. In certain environments, multitasking and parallel processing may be advantageous.

[0139] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A differentiable rendering method, characterized in that, The differentiable rendering method includes: S1: Obtain the initial scene and target image; S2: Render the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes first color information and first position information of each first pixel, and the first position information of the first pixel in the rendered image is determined in the following way: When performing rasterization on the first pixel in the rendered image, if the first pixel has a shading point, the first position information of the first pixel is determined based on the projection coordinates of the shading point. When performing rasterization on the first pixel in the rendered image, if the first pixel does not have a shading point, the first position information of the first pixel is determined based on the pixel center coordinates of the first pixel. S3: Based on the target image, obtain the second color information and second position information of each second pixel in the target image; S4: The first color information and the first position information of each first pixel in the rendered image are concatenated to obtain a set of rendered points; S5: The second color information and the second position information of each second pixel in the target image are concatenated to obtain a target point set; S6: Based on the target point set, match each rendering point in the rendering point set to obtain the matching point; S7: Based on the distance between the rendering point and the matching point, obtain the loss function; S8: Based on the loss function, optimize the scene parameters of the initial scene using gradient descent; S9: By optimizing the scene parameters of the initial scene, optimized scene parameters are obtained, and based on the optimized scene parameters, a target scene corresponding to the target image is obtained.

2. The differentiable rendering method according to claim 1, characterized in that, The second position information of the second pixel in the target image is determined in the following way: Based on the pixel center coordinates of the second pixel in the target image, the second position information of the second pixel is determined.

3. The differentiable rendering method according to claim 1, characterized in that, The loss function, derived from the distance between the rendering point and the matching point, is determined using the following formula: in, Represents the loss function; This represents the set of rendering points; This indicates the number of rendering points in the set of rendering points; Represents the first in the set of rendering points i One rendering point; Represents the rendering point matching points; Represents the rendering point and matching points The distance.

4. The differentiable rendering method according to claim 1, characterized in that, The optimization of the scene parameters of the initial scene based on the loss function using gradient descent specifically includes: Based on the loss function, the scene parameters of the initial scene are optimized by gradient descent to obtain the initial optimized scene parameters; Based on the initial optimized scene parameters, an optimized initial scene is obtained, and the optimized initial scene is used as the initial scene to be repeatedly executed for a preset number of times S2 to S8.

5. A differentiable rendering apparatus, characterized in that, The apparatus is used to implement the differentiable rendering method according to any one of claims 1 to 4, the differentiable rendering apparatus comprising: The first module is used to acquire the initial scene and target image; The second module is used to render the initial scene to obtain a rendered image corresponding to the initial scene, wherein the rendered image includes the first color information and the first position information of each first pixel. The third module is used to obtain the second color information and second position information of each second pixel in the target image based on the target image; The fourth module is used to concatenate the first color information and the first position information of each first pixel in the rendered image to obtain a set of rendered points; The fifth module is used to concatenate the second color information and the second position information of each second pixel in the target image to obtain a target point set; The sixth module is used to match each rendering point in the rendering point set based on the target point set to obtain matching points; The seventh module is used to obtain a loss function based on the distance between the rendering point and the matching point; The eighth module is used to optimize the scene parameters of the initial scene based on the loss function using gradient descent. The ninth module is used to obtain optimized scene parameters by optimizing the scene parameters of the initial scene, and to obtain the target scene corresponding to the target image based on the optimized scene parameters.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the differentiable rendering method as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the differentiable rendering method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the differentiable rendering method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Three-dimensional face model edge optimization method and system based on micro rendering

    CN113902768A

  • Special effect follow-up rendering method and device in augmented reality

    CN113920278A