Video generation method, apparatus, medium, device, and product
By acquiring the object material properties of 2D video and recalculating the lighting information based on the light source of 3D object, the problem of inconsistent lighting of virtual objects in 3D scene is solved, and more realistic and coherent video generation is achieved.
Patent Information
- Application Number
- CN202611508263.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-24
- Publication Date
- 2026-11-27
AI Technical Summary
When existing technologies fuse 2D video into 3D objects, the virtual objects cannot respond to dynamic lighting changes in the scene, resulting in inconsistent lighting information and affecting the realism and visual effects of the video.
By acquiring the material properties of objects in the 2D video, recalculating the lighting information based on the light source of the 3D object, and rendering it, the lighting consistency between the 2D video and the 3D object is ensured. The lighting information is updated using a material analysis model and lighting calculation technology.
It improves the realism and visual effects of merging 2D video and 3D objects, ensures the consistency of lighting information, and enhances the accuracy and visual coherence of the generated video.
Smart Images

Figure CN123185433A_ABST
Abstract
Description
Technical Field
[0001] This article relates to the field of computer technology, specifically to a video generation method, apparatus, medium, device, and product. Background Technology
[0002] With the development of AI (Artificial Intelligence) video generation technology, it is possible to generate character videos with rich movements, performances, and stylized rendering based on AI video generation technology. When applying AI-generated character videos to interactive 3D game scenes, the character foreground can be extracted from the character video and composited into the 3D game scene. Summary of the Invention
[0003] This content section is provided to briefly introduce the ideas, which will be described in detail in the examples section later. This content section is not intended to identify key or essential features of the claimed content, nor is it intended to limit the scope of the claimed content.
[0004] Firstly, a video generation method is provided, including: Acquire a first video and a 3D object, wherein the first video includes the first object; Based on the video frames in the first video, obtain the material properties of the first object; Based on the first light source and the material properties of the first object, first lighting information is generated, and the three-dimensional object is rendered based on the first light source; The first video is updated using the first illumination information to obtain the second video; A third video is obtained based on the rendered 3D object and the second video.
[0005] Secondly, a video generation apparatus is provided, comprising: The first acquisition module is used to acquire a first video and a three-dimensional object, wherein the first video includes the first object; The second acquisition module is used to acquire the material properties of the first object based on the video frames in the first video; The first generation module is used to generate first lighting information based on the first light source and the material properties of the first object, and to render the three-dimensional object based on the first light source. The first update module is used to update the first video using the first illumination information to obtain the second video; The second generation module is used to obtain the third video based on the rendered 3D object and the second video.
[0006] Thirdly, a computer-readable medium is provided having a computer program stored thereon, wherein the computer program, when executed by a processing device, implements the method described in the first aspect.
[0007] Fourthly, an electronic device is provided, comprising: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the method described in the first aspect.
[0008] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect.
[0009] Therefore, when fusing 2D video into a 3D object, material analysis can be performed to obtain the material properties of the first object. This allows for the recalculation of the first lighting information based on the first light source used by the 3D object, ensuring that both the first and 3D objects receive the same illumination. This allows the 2D video to be fused into the 3D object while simultaneously enabling the first object in the 2D video to change according to the first light source, guaranteeing consistency in lighting information between the first and 3D objects in the resulting third video. This enhances the realism of the fusion and improves the visual effect and accuracy of the generated video. Furthermore, the lighting information in the first video obtained under different models or generation conditions may vary. Therefore, when switching the first video of the first object, the consistency of the lighting information of the first object before and after the video switch can also be guaranteed, improving the visual coherence of the generated third video.
[0010] Other features and advantages will be described in detail in the following examples section. Attached Figure Description
[0011] The above and other features, advantages, and aspects of this document will become more apparent when taken in conjunction with the accompanying drawings and the following examples. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale. In the drawings: Figure 1 These are schematic diagrams illustrating implementation scenarios based on certain situations.
[0012] Figure 2 This is a flowchart illustrating video generation methods under certain circumstances.
[0013] Figure 3 This is a flowchart illustrating a video generation method under other scenarios.
[0014] Figure 4 This is a flowchart illustrating a video generation method under other scenarios.
[0015] Figure 5 This is a schematic diagram of the second shadow texture shown according to some scenarios.
[0016] Figure 6 This is a block diagram of a video generation device shown under certain circumstances.
[0017] Figure 7 These are schematic diagrams of the structure of electronic devices shown in various scenarios. Detailed Implementation
[0018] The following description will be given in more detail with reference to the accompanying drawings. While certain scenarios are shown in the drawings, it should be understood that this document can be implemented in various forms and should not be construed as limited to the scenarios described herein. Rather, these scenarios are provided to provide a more thorough and complete understanding of this document. It should be understood that the accompanying drawings and the scenarios depicted are for illustrative purposes only and are not intended to limit the scope of this document.
[0019] It should be understood that the steps described in the method may be performed in different orders and / or in parallel. Furthermore, the method may include additional steps and / or omit the steps shown. The scope of this document is not limited in this respect.
[0020] The term "comprising" and its variations can be open-ended, meaning "including but not limited to". The term "based on" can mean "at least partially based on". The term "one case" means "at least one case"; the term "another case" means "at least one additional case"; the term "some cases" means "at least some cases". Definitions of other terms will be given in the following description.
[0021] It should be noted that the concepts of "first" and "second" are only used to distinguish different devices, modules or units, and are not used to limit the order of the functions performed by these devices, modules or units or their interdependencies.
[0022] It should be noted that the modifiers “one” and “multiple” can be illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as “one or more”.
[0023] The names of messages or information exchanged between multiple devices are for illustrative purposes only and are not intended to limit the scope of these messages or information.
[0024] It is understandable that the data involved in the technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of relevant regulations.
[0025] Figure 1The diagram illustrates an implementation scenario based on various conditions. The scenario may include a terminal 101 and a rendering engine 102, which runs on the terminal 101. The terminal 101 may include, but is not limited to, mobile terminals such as mobile phones, laptops, and tablet computers, as well as fixed terminals such as digital TVs and desktop computers. The terminal 101 receives input and carries the rendering results from the rendering engine 102, outputting these results to its screen. The rendering engine 102 manages scenes, materials, textures, animations, etc., to generate rendering results and obtain corresponding display images. For example, a user can perform interactive operations on the terminal 101 (such as triggering an attack). The rendering engine 102 receives these interactive operations, converts them into corresponding behaviors, and generates each frame of image data as a rendering result based on the converted behavior. This data is then sent back to the terminal 101 for display, completing the interactive loop.
[0026] Displaying virtual objects in a game scene using a rendering engine typically requires pre-processing such as character modeling, rigging, facial animation, cloth analysis, dynamics analysis, and stylized rendering. This results in high scene production costs and long development cycles, requiring significant manual labor and data computation. Therefore, to reduce rendering costs and latency, videos of virtual objects can be merged into 3D objects. However, the lighting information in the video of a virtual object is fixed. When the video is merged into a 3D object with different lighting conditions, the virtual object in the video cannot respond to dynamic lighting changes in the scene. Based on this, a video generation method, apparatus, medium, device, and product can be provided. Figure 2 The diagram shown is a flowchart illustrating video generation methods under various scenarios, such as... Figure 2 As shown, the method may include: In step 21, a first video and a 3D object are acquired, wherein the first video includes the first object.
[0027] The first object can be a candidate object to be placed within a 3D object, and the first video can be a video obtained by extracting the object frame by frame from a video containing the first object. In some cases, videos of each first object can be pre-generated based on AI video generation technology. During video generation, the video can be generated against a pure green background. After obtaining the generated video, it can be processed using common keying methods in the field, such as generating a mask based on color difference or image difference to extract the portion corresponding to the first object in the video, and setting the portion outside the first object in the video to transparent to obtain the first video, which facilitates video compositing.
[0028] A 3D object can represent an object used for rendering a virtual scene. A 3D object can include scene elements that need to be rendered, such as terrain, rivers, and rocks. For example, the virtual scene rendered by a 3D object can include a game scene.
[0029] When fusing the first video and the 3D object, the position of the first object in the 3D object can be pre-configured based on the actual application scenario so that the first video of the first object can be fused into the 3D object.
[0030] In step 22, the material properties of the first object are obtained based on the video frames in the first video.
[0031] The material properties of the first object may include, but are not limited to, at least one of the following: Albedo represents the intrinsic surface color of an object, which does not change with illumination and represents the diffuse reflectance under uniform white light; Normal represents the surface orientation of a pixel, used for calculating shading and highlights; Depth represents the distance from the camera to the pixel, supporting the implementation of fog effects, depth of field, and occlusion effects with geometry; Roughness represents the surface roughness of a pixel, used to control the degree of specular reflection diffusion; Metallic represents the material classification of metallic and dielectric surfaces, used to determine the reflection model used during shading; Mask represents the mask used to distinguish objects from their background.
[0032] In some cases, obtaining the material properties of the first object based on video frames in the first video may include: The video frames are input into the material parsing model to obtain the material attributes of the first object. For example, the material parsing model can be used to parse each video frame one by one to obtain the object material attributes of each pixel in each video frame. Accordingly, the material parsing model can be implemented based on a large language model or a deep learning model, and the material parsing model can be obtained in the following way: The training video is used as input to the model to obtain predicted material properties and predicted lighting information.
[0033] Training videos can be pre-built. For example, lighting calculations and rendering can be performed based on the training lighting information applied to the training 3D objects and the 3D objects to generate training videos in batches through the rendering engine. Alternatively, videos containing real objects captured by a camera can be obtained.
[0034] A first loss is generated based on the training video and the predicted material properties; a second loss is generated based on the predicted illumination information of adjacent video frames; and a third loss is generated based on the predicted material properties of adjacent video frames. The material analysis model is then trained based on the first loss, the second loss, and the third loss.
[0035] In some cases, for each training video frame in the training video, a reconstructed video frame can be obtained by rendering through a rendering engine based on predicted material properties and predicted lighting information. The loss of each training video frame is obtained based on the difference between the training video frame and the reconstructed video frame, and the sum of the losses of each training video frame is used as the first loss. The loss of the training video frame can be calculated based on the image reconstruction loss in this field.
[0036] Furthermore, to ensure the stability and consistency of the generated material property estimates, additional supervisory signals can be added through the temporal consistency of the video. For example, the material properties corresponding to adjacent video frames remain unchanged, while the illumination information corresponding to adjacent video frames changes smoothly. Therefore, a second loss can be generated based on the predicted illumination information of the adjacent video frames, and a third loss can be generated based on the predicted material properties of the adjacent video frames, based on the above constraints. The loss functions used to calculate the second and third losses can be configured based on the actual application scenario and are not limited here.
[0037] The first loss, second loss, and third loss can be pre-set with corresponding weights, so that the fusion weight can be obtained by weighted summation based on each loss and its weight, and the parameters of the material analysis model can be updated by the fusion weight. The parameter update method can be implemented based on the training method commonly used in this field.
[0038] Therefore, the material analysis model can be obtained by training on a large-scale synthetic dataset. During the training process, the reconstruction loss of a single video frame and the temporal consistency constraint of the video can be combined as additional supervision signals to improve the training efficiency and accuracy of the material analysis model. This will enable the material analysis model to output stable and coherent material properties, providing accurate data support for subsequent lighting calculations on the first object and improving the realism of the video obtained by fusing the first video and the 3D object.
[0039] Turn back Figure 2 In step 23, first lighting information is generated based on the first light source and the material properties of the first object, and the three-dimensional object is rendered based on the first light source.
[0040] The first light source can be a light source used for lighting calculations on a 3D object. Alternatively, it can be an ambient light source in the environment where the 3D object is located. In this case, the first lighting information can be obtained by combining the first light source and the material properties of the first object with the lighting calculations performed by the rendering engine.
[0041] In some cases, this step may include: performing lighting calculations based on the first light source and the material properties of the first object through rendering relationships to obtain first lighting information, wherein the first lighting information corresponds to each pixel in the video frame, and the first lighting information includes at least one of diffuse reflection value, specular value, and directional response value.
[0042] For example, lighting calculations can be performed using a shader based on the first video that obtains the material properties of the first object. The first light source can include one or more light sources. During the lighting calculation process, each first light source in the 3D object can be calculated pixel-by-pixel through PBR (Physically-Based Rendering) rendering relationships to illuminate the first object through the first light source.
[0043] The diffuse reflection value is obtained by multiplying the light source direction by the normal direction and then by the albedo, ensuring the same object transitions correctly from warm sunlight to cool moonlight. The specular value is calculated by controlling the specular diffusion range using roughness and controlling Fresnel behavior using metallicity, thus determining the specular highlight of each pixel. The directional response value is determined by using the normal to define the angle of each pixel relative to the first light source, controlling the correct shading gradient with brighter areas facing the light source and darker areas away from it. The calculation of both the specular and directional response values can be based on rendering shading methods commonly used in this field.
[0044] In this way, the first lighting information in the first video can be recalculated based on the first light source used by the 3D object. At the same time, the 3D object can be rendered using the rendering engine and the first light source, so that the 3D object and the first object in the first video can be illuminated based on the same first light source, ensuring the consistency between the first lighting information and the lighting information in the 3D object.
[0045] In step 24, the first video is updated using the first illumination information to obtain the second video.
[0046] For example, the first video can be played as a video texture on a polygonal patch, which is attached to the top layer of a 3D object to achieve the fusion of the 2D video and the 3D object, thus creating the effect of the first object moving within the 3D object. In this way, the pixels in each video frame can be updated based on the first lighting information of each video frame. For instance, the pixel values of each pixel can be determined and replaced using shading techniques and the first lighting information, as described in the art, to obtain the second video.
[0047] In step 25, a third video is obtained based on the rendered 3D object and the second video.
[0048] In this way, the second video can be displayed in a polygonal patch, and the polygonal patch can be placed on top of the rendered 3D object for fusion to obtain the third video.
[0049] Therefore, when fusing 2D video into a 3D object, material analysis can be performed to obtain the material properties of the first object. This allows for the recalculation of the first lighting information based on the first light source used by the 3D object, ensuring that both the first and 3D objects receive the same illumination. This allows the 2D video to be fused into the 3D object while simultaneously enabling the first object in the 2D video to change according to the first light source, guaranteeing consistency in lighting information between the first and 3D objects in the resulting third video. This enhances the realism of the fusion and improves the visual effect and accuracy of the generated video. Furthermore, the lighting information in the first video obtained under different models or generation conditions may vary. Therefore, when switching the first video of the first object, the consistency of the lighting information of the first object before and after the video switch can also be guaranteed, improving the visual coherence of the generated third video.
[0050] In some cases, the method may further include: At least one material region is obtained from each video frame in the first video. Specifically, the first video frame in the first video can be segmented based on video description information to obtain at least one material region.
[0051] The video description information can be a description input by the designer for processing the first video, such as "crystals on the animal's back." This description information can be combined with other information to perform region segmentation and obtain the material region corresponding to the crystal. For example, semantic recognition can be performed based on a visual language model, combining the video description information and the first video frame, to determine the semantic identifier for each pixel in the first video frame. The semantic identifier represents the material region to which that pixel belongs; for example, semantic identifier 1 represents crystals, semantic identifier 2 represents the head, semantic identifier 3 represents the back, and semantic identifier 4 represents limbs. Then, the corresponding material region can be quickly obtained based on the semantic identifier. For instance, based on the aforementioned video description information, pixels with semantic identifier 1 can be segmented to obtain the material region to be processed. For example, the generated semantic identifiers can be stored using RGB (Red, Green, Blue) channel information. For instance, the semantic identifiers can be packaged into the B channel, the R channel can be used to store metallicity, and the G channel can store roughness, so that the corresponding material properties and semantic identifiers can be obtained during a single texture sampling.
[0052] In some cases, the first video frame may be the first video frame in the first video. Subsequent video frames may track the corresponding semantically labeled pixels in the first video based on the region segmentation result of the first video frame through the mask propagation method in the art, so as to maintain the temporally consistent segmentation result even when the limb is deformed, rotated, moved significantly or partially occluded. At the same time, it can also effectively reduce the amount of data computation required for region segmentation.
[0053] Based on the attribute information corresponding to the material region, second lighting information is generated, and the second lighting information corresponds to each pixel in the video frame.
[0054] Specifically, corresponding attribute information can be pre-set for various material regions based on actual application scenarios. After obtaining the material region, the corresponding attribute information can be queried based on the semantic identifier of the material region, enabling illumination calculations to be performed based on the attribute information and generating second illumination information for each pixel. For example, the second illumination information of each pixel in the material region can be calculated.
[0055] In some cases, the attribute information may include second object material attributes, such as albedo, metallicity, and roughness, so that the selected material area can be recolored based on the second object material attributes to achieve part-level material editing.
[0056] For example, to improve the smoothness of the edges of a material region, a smoothing region can be generated based on the material region. Specifically, after obtaining the material region, the screen space partial derivative can be calculated based on the semantic identifier of the material region to obtain the pixel gradient. The edge width is determined based on the pixel gradient, and the smoothing region is determined by combining the edge width and the semantic identifier. For example, pixels with a semantic identifier greater than a first value and less than a second value can be used as smoothing regions. The first value is the difference between the semantic identifier and the edge width, and the second value is the sum of the semantic identifier and the edge width. For each pixel in the smoothing region, smoothing can be performed using a smoothing step function to obtain smoothing parameters. Based on the smoothing parameters, the first object material attribute and the second object material attribute corresponding to the pixel are interpolated and fused to obtain a fused material attribute. In this way, illumination calculations can be performed on each pixel in the material region and the smoothing region to obtain the second illumination information of the pixel. Furthermore, for pixels in the smoothing region, the second illumination information is calculated based on the fused material attribute and the first light source. For pixels belonging to the material region but not to the smoothing region, the second illumination information is calculated based on the second object material attribute and the first light source. This allows for the smoothing of material region edges determined based on discrete semantic identifiers to generate soft masks. These soft masks are then used to create smooth transitions in the smoothed regions by combining the original material properties of the first object with the new material properties of the second object. This enables material editing of certain areas in the video while eliminating flickering artifacts at material boundaries.
[0057] In some cases, the shading attributes include self-illumination attributes. These attributes can include features such as Rim (contour enhancement), Fresnel (view-dependent intensity), Dissolve (animation appearance / disappearance), Gradient (color transition), and Channel (semantic identifier). After obtaining the material region, the corresponding self-illumination attributes can be determined using the semantic identifier of the material region. Custom shaders can be pre-configured to render the self-illumination attributes. For example, a custom shader can calculate the illumination information of each pixel in the material region based on the self-illumination attributes to obtain the self-illumination value corresponding to that pixel, which serves as the second illumination information.
[0058] Accordingly, updating the first video using the first illumination information to obtain the second video may include: The first illumination information and the second illumination information are fused to obtain the third illumination information; the first video is updated using the third illumination information to obtain the second video.
[0059] In some cases, the attribute information corresponding to the material region includes the material attributes of a second object. The step of fusing the first lighting information and the second lighting information to obtain the third lighting information includes: If the first pixel belongs to the material region, then the second illumination information of the first pixel is used as the third illumination information; if the first pixel does not belong to the material region, then the first illumination information of the first pixel is used as the third illumination information. The first pixel is each pixel in the video frame.
[0060] Figure 3 The diagram illustrates the processing flow when the attribute information includes the material attributes of the second object. M1 represents the first video. By segmenting the first video frame in M1, a material region is obtained, which can be represented by a mask M2. Then, for each first pixel in mask M2, the second lighting information of the first pixel is used as the third lighting information M3 for the corresponding pixel in the material region. For each first pixel outside mask M2, the first lighting information of the first pixel is used as the third lighting information. Finally, the material region and non-material regions in the first video are rendered based on their respective third lighting information to obtain video frame M4 in the second video. The example portion within the dashed box in M4 represents the rendering effect after updating the material region based on the material attributes of the second object, thus re-editing the material attributes of a portion of the first object and improving the processing accuracy of fusing 2D video and 3D objects.
[0061] In some cases, the attribute information corresponding to the material region includes self-illumination attributes. The step of fusing the first illumination information and the second illumination information to obtain the third illumination information includes: if the second pixel belongs to the material region, then the first illumination information and the second illumination information of the second pixel are superimposed to obtain the third illumination information; if the second pixel does not belong to the material region, then the first illumination information of the second pixel is used as the third illumination information, and the second pixel is each pixel in the video frame.
[0062] Figure 4The diagram illustrates the processing flow when attribute information includes self-illumination attributes. N1 represents the first video. By segmenting the first video frame in N1, a material region is obtained, which can be represented by a mask N2. Then, for each second pixel in mask N2, second lighting information N3 is generated based on the self-illumination attribute. For each second pixel in the material region, the first lighting information and the second lighting information N3 are superimposed to obtain the third lighting information for the material region. For each second pixel outside the material region, the first lighting information of the second pixel is used as the third lighting information. Next, the material region and non-material regions in the first video are rendered based on their respective third lighting information to obtain video frames N4 in the second video. The example portion within the dashed box in N4 represents the rendering effect of updating the first video after superimposing the second lighting information based on the self-illumination attribute on the material region. This allows for the superimposition of self-illumination effects on specific areas of the first object, supporting the re-editing of content in the first video and improving the fusion display effect of 2D video and 3D objects.
[0063] Therefore, by obtaining the material regions of each video frame in the first video, individual processing can be performed on certain regions of the first object, allowing different material parameters or custom coloring effects to be applied to specific parts of the first object. This enables component-level material editing and the overlay of self-illumination effects, further improving the processing accuracy of video generation and enhancing the realism of the generated video materials.
[0064] In some cases, the method may further include: Multiple edge light sources are acquired, each with a different incident direction.
[0065] Among them, the edge light source can be preset based on the actual application scenario. It can provide illumination from different incident modes, improving the lighting realism of the first object in contour processing.
[0066] A fourth illumination information is generated based on each of the aforementioned edge light sources and each pixel in the video frame.
[0067] Specifically, the pixel illuminated by each edge light source can be determined based on the incident direction and intensity of each edge light source, and the fourth illumination information of that pixel can be determined.
[0068] In some cases, generating fourth illumination information based on each of the edge light sources and each pixel in the video frame may include: Based on each edge light source and each pixel in the video frame, a first mask and a second mask are determined, wherein the first mask is determined based on the viewing direction and the normal direction corresponding to the pixel, and the second mask is determined based on the incident direction of the edge light source.
[0069] When calculating the first mask, for each pixel, the dot product can be calculated based on the viewing direction and the normal direction corresponding to that pixel. If the difference between the dot product and the first mask is less than the first threshold, the first mask is 1. If the difference between the dot product and the first mask is greater than or equal to the first threshold, the first mask is 0. Thus, pixels whose normal is almost perpendicular to the viewing direction can be selected based on the first mask.
[0070] When calculating the second mask, the center of the fan-shaped region corresponding to each edge light source can be determined based on the video texture corresponding to the video frame. The fan-shaped region represents the area illuminated by the edge light source. The center of the fan-shaped region can be determined by the texture center, a first offset, and a second offset. The first offset can be preset based on the actual application scenario, and the second offset can be determined based on the incident direction of the edge light source. Then, for each pixel, the dot product can be calculated between the vector pointing from the center of the fan-shaped region to the current pixel and the opposite direction of the incident direction of the edge light source. If the difference between the first and the dot product is less than a second threshold, the second mask is 1; if the difference between the first and the dot product is greater than or equal to the second threshold, the second mask is 0. Thus, pixels belonging to the fan-shaped region illuminated by the edge light source can be filtered out based on the second mask.
[0071] The fourth illumination information is obtained based on the first mask, the second mask, and the illumination intensity of the edge light source.
[0072] For each pixel, the product of the first mask, the second mask, and the illumination intensity of the edge light source can be used as the sub-edge light of that pixel. Then, the sub-edge lights corresponding to each edge light source can be weighted and summed to obtain the fourth illumination information of that pixel. The weights of each edge light source can be preset.
[0073] Accordingly, updating the first video using the first illumination information to obtain the second video includes: updating the first video using the first illumination information and the fourth illumination information to obtain the second video.
[0074] Specifically, for each video frame in the first video, the first and fourth lighting information of each pixel in the video frame can be superimposed to obtain new lighting information. During rendering, the pixels of each video frame can be updated based on the new lighting information to obtain the second video, which is then displayed in a polygonal patch. Simultaneously, the polygonal patch can be placed on top of the rendered 3D object for fusion to obtain the third video.
[0075] Therefore, by adding multiple edge light sources to create halos around the outline of the first object, the depth perception of the first object in the generated third video can be further enhanced, thereby improving the realism of the generated video.
[0076] In some cases, video generation can simultaneously include processing of material areas and edge lighting. In such cases, the second and fourth lighting information for each pixel can be determined using the methods described above. Then, in each video frame, the first and second lighting information can be fused to obtain third lighting information. The third and fourth lighting information are then fused to obtain new lighting information. This new lighting information is used to update the first video to obtain the second video. Finally, the second video is fused with the 3D object to obtain the third video.
[0077] In some cases, the method may further include: A first shadow texture is generated based on a virtual light source, and the first shadow texture corresponds to the first object.
[0078] Since the first object is displayed as a two-dimensional polygonal patch in the 3D object, it lacks geometric thickness and is difficult to generate shadows. Therefore, a virtual light source can be set in the 3D object. This virtual light source is an auxiliary light source for generating shadow textures and is independent of the lighting information of the pixels in the first video; that is, this virtual light source is only used to calculate shadow textures.
[0079] In some cases, to improve the quality of the first shadow texture, the incident angle of the virtual light source can be set based on the planar orientation of the polygonal facet corresponding to the first video. For example, the incident angle of the virtual light source can be perpendicular to or approximately perpendicular to the plane to which the polygonal facet belongs, such as the absolute value of the difference between the included angle and 90 degrees being less than a third threshold. Thus, shadow calculations performed on the first object illuminated by the virtual light source can be based on shadow shaders in this field, using the mask in the object's material properties of the first video to generate the first shadow texture.
[0080] Based on the light source direction of the first light source and the normal direction corresponding to the first video, the first shadow texture is updated to obtain the second shadow texture.
[0081] Specifically, when the direction of the first light source changes, the shadow of the first object needs to change accordingly to match the shadow generation logic of a real scene. Accordingly, the projection stretching factor can be calculated based on the angle between the normal direction of the plane to which the first video belongs and the direction of the light source; the projection stretching factor is the reciprocal of the cosine of the angle. For example... Figure 5 The diagram shows a second shadow texture obtained by stretching a first shadow texture based on the direction of the light source. When the direction of the light source is perpendicular to the plane to which the first video belongs, the first shadow texture can retain its original outline, as shown in this scene. Figure 5The character's shadow (i.e., the white part) can be vertical. As the incident angle of the light source increases, the first shadow texture can be gradually stretched along the light source direction to simulate the shadow texture under the light from that direction, thus updating the first shadow texture. During the stretching process of the first shadow texture, it can be achieved based on texture resampling and edge filling to ensure the accuracy of the second shadow texture obtained after stretching the first shadow texture.
[0082] Accordingly, obtaining a third video based on the rendered 3D object and the second video may include: The second shadow texture is projected onto the surface of the rendered 3D object to obtain a shadow projection; based on the shadow projection, the second video, and the rendered 3D object, the third video is obtained.
[0083] For example, the pixels of each video frame in the first video can be updated based on the calculated lighting information obtained by the method described above to obtain the second video. Furthermore, the second shadow texture can be projected onto the surface of the rendered 3D object to obtain a shadow projection. For example, projection can be performed using a decal projection method in this field, so that the projected shadow texture can match the surface of the rendered 3D object, such as matching and fitting with the terrain and platforms of the rendered 3D object surface. In some cases, the video texture corresponding to the second video is mapped onto a polygonal patch, and the polygonal patch is attached to the upper layer of the rendered 3D object, while the shadow projection is attached to the surface of the rendered 3D object, so that the shadow projection, the second video, and the rendered 3D object are blended to obtain the third video.
[0084] Therefore, when merging 2D video into 3D objects, virtual light sources, angle-aware stretching, and shadow texture projection can be used to generate shadow projections in the third video that fit the terrain of the 3D object. This further enhances the realism and visual effects of the video obtained by merging 2D video and 3D objects, and improves the user's interactive experience based on the generated video.
[0085] In some cases, the three-dimensional object is a game scene, and the method further includes: The system receives an operation command and obtains a first video based on the command. Specifically, it can pre-generate and store videos corresponding to each operation command for each object in the game scene, including the actions performed by the object in response to the command. Thus, upon receiving an operation command, the first video can be directly obtained from the stored videos. The first video can then be merged with the game scene to obtain a third video.
[0086] The operation command is responded to based on the third video. For example, the third video can be displayed to show the action of the first object in response to the operation command in the game scene.
[0087] This decouples real-time rendering performance from the game flow. The physically based rendering pipeline can run in real time on the GPU (Graphics Processing Unit), and object material properties can be streamed as video textures. This eliminates the need to rely on offline generation of the first object's motion video when responding to operation commands, ensuring real-time response in the game scene and improving the user interaction experience.
[0088] Figure 6 The diagram shown is a block diagram of a video generation apparatus based on some scenarios. The apparatus 10 includes: The first acquisition module 100 is used to acquire a first video and a three-dimensional object, wherein the first video includes the first object; The second acquisition module 200 is used to acquire the material properties of the first object based on the video frames in the first video; The first generation module 300 is used to generate first lighting information based on the first light source and the material properties of the first object, and to render the three-dimensional object based on the first light source. The first update module 400 is used to update the first video using the first illumination information to obtain the second video; The second generation module 500 is used to obtain a third video based on the rendered 3D object and the second video.
[0089] Therefore, when fusing 2D video into a 3D object, material analysis can be performed to obtain the material properties of the first object. This allows for the recalculation of the first lighting information based on the first light source used by the 3D object, ensuring that both the first and 3D objects receive the same illumination. This allows the 2D video to be fused into the 3D object while simultaneously enabling the first object in the 2D video to change according to the first light source, guaranteeing consistency in lighting information between the first and 3D objects in the resulting third video. This enhances the realism of the fusion and improves the visual effect and accuracy of the generated video. Furthermore, the lighting information in the first video obtained under different models or generation conditions may vary. Therefore, when switching the first video of the first object, the consistency of the lighting information of the first object before and after the video switch can also be guaranteed, improving the visual coherence of the generated third video.
[0090] Optionally, the device 10 further includes: The third acquisition module is used to acquire at least one material region of each video frame in the first video; The third generation module is used to generate second lighting information for each pixel in the video frame based on the attribute information corresponding to the material region. The first update module 400 includes: The fusion submodule is used to fuse the first illumination information and the second illumination information to obtain the third illumination information; The first update submodule is used to update the first video using the third illumination information to obtain the second video.
[0091] Optionally, the attribute information corresponding to the material region includes the material attributes of the second object, and the fusion submodule is used for: For each pixel in the video frame, if the pixel belongs to the material region, the second illumination information of the pixel is used as the third illumination information; if the pixel does not belong to the material region, the first illumination information of the pixel is used as the third illumination information.
[0092] Optionally, the attribute information corresponding to the material region includes a self-illuminating attribute, and the fusion submodule is used for: For each pixel in the video frame, if the pixel belongs to the material region, the first illumination information and the second illumination information of the pixel are superimposed to obtain the third illumination information; if the pixel does not belong to the material region, the first illumination information of the pixel is used as the third illumination information.
[0093] Optionally, the device 10 further includes: The fourth acquisition module is used to acquire multiple edge light sources, each of which has a different incident direction; The fourth generation module is used to generate fourth illumination information based on each of the edge light sources and each pixel in the video frame; The first update module 400 includes: The second update submodule is used to update the first video using the first illumination information and the fourth illumination information to obtain the second video.
[0094] Optionally, the fourth generation module is used for: Based on each edge light source and each pixel in the video frame, a first mask and a second mask are determined, wherein the first mask is determined based on the viewing direction and the normal direction of the pixel, and the second mask is determined based on the incident direction of the edge light source; based on the first mask, the second mask, and the illumination intensity of the edge light source, the fourth illumination information is obtained.
[0095] Optionally, the device 10 further includes: The fifth generation module is used to generate a first shadow texture based on a virtual light source, and the first shadow texture corresponds to the first object; The second update module is used to update the first shadow texture based on the light source direction of the first light source and the normal direction corresponding to the first video, so as to obtain the second shadow texture. The second generation module 500 is used for: The second shadow texture is projected onto the surface of the rendered 3D object to obtain a shadow projection. The third video is obtained based on the shadow projection, the second video, and the rendered 3D object.
[0096] Optionally, the second acquisition module 200 is used for: The video frame is input into the material parsing model to obtain the material properties of the first object. The material parsing model is obtained in the following way: The training video is used as input to the model to obtain predicted material properties and predicted lighting information; A first loss is generated based on the training video and the predicted material properties; a second loss is generated based on the predicted illumination information of adjacent video frames; and a third loss is generated based on the predicted material properties of adjacent video frames. The material analysis model is trained based on the first loss, the second loss, and the third loss.
[0097] The following is for reference. Figure 7 It shows an electronic device suitable for implementing the above method (e.g. Figure 1 The diagram below shows the structure of the terminal device 600. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Personal Computers), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs (Televisions), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not be construed as limiting its functionality or scope of use.
[0098] like Figure 7As shown, electronic device 600 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. The random access memory 603 also stores various programs and data required for the operation of electronic device 600. The processing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. An input / output (I / O) interface 605 is also connected to bus 604.
[0099] Typically, the following devices can be connected to the input / output interface 605: input devices 606 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 608 including, for example, magnetic tape, hard disk, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0100] In particular, depending on certain circumstances, the processes described in the flowchart above can be implemented as computer software programs. For example, a computer program product is provided, comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. This computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from read-only memory 602. When the computer program is executed by processing device 601, it performs the functions defined in the above-described methods.
[0101] It should be noted that the aforementioned computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM, or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In one case, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In another case, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (Radio Frequency), etc., or any suitable combination thereof.
[0102] In some scenarios, clients and servers can communicate using any currently known or future-developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad-hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0103] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0104] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: acquire a first video and a three-dimensional object, the first video including the first object; acquire the material properties of the first object based on video frames in the first video; generate first lighting information based on a first light source and the material properties of the first object, and render the three-dimensional object based on the first light source; update the first video using the first lighting information to obtain a second video; and obtain a third video based on the rendered three-dimensional object and the second video.
[0105] Computer program code for performing the above operations can be written in one or more programming languages or a combination thereof. These programming languages include, but are not limited to, object-oriented programming languages, as well as conventional procedural programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0106] The flowcharts and block diagrams in the accompanying figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products under various scenarios. Each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that, in some alternative cases, the functions indicated in the blocks may occur in a different order than those indicated in the figures. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0107] The modules mentioned above can be implemented in software or hardware. In some cases, the name of a module does not necessarily limit the module itself; for example, the first acquisition module can also be described as "a module for acquiring the first video and the 3D object".
[0108] The functions described above can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field-Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application-Specific Standard Parts (ASSPs), Systems on Chips (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0109] In this context, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0110] The above description is merely illustrative and explains the technical principles employed. Those skilled in the art should understand that the scope of this document is not limited to the specific combinations of the above-described technical features, but should also cover any combination of the above-described technical features or their equivalents without departing from the above concept.
[0111] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. Multitasking and parallel processing may be advantageous in certain environments. Similarly, while some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of this paper. Certain features described in the context of a single example can also be implemented in combination in a single example. Conversely, various features described in the context of a single example can also be implemented individually or in any suitable sub-combination in multiple examples.
[0112] Although this document has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims. Regarding the aforementioned apparatus, the specific manner in which the various modules perform their operations has already been described in detail in the section concerning the method, and will not be elaborated upon here.
Claims
1. A video generation method, comprising: Acquire a first video and a 3D object, wherein the first video includes the first object; Based on the video frames in the first video, obtain the material properties of the first object; Based on the first light source and the material properties of the first object, first lighting information is generated, and the three-dimensional object is rendered based on the first light source; The first video is updated using the first illumination information to obtain the second video; A third video is obtained based on the rendered 3D object and the second video.
2. The method according to claim 1, further comprising: Obtain at least one material region for each video frame in the first video; Based on the attribute information corresponding to the material region, second lighting information is generated, and the second lighting information corresponds to each pixel in the video frame. The first video is updated using the first illumination information to obtain a second video, including: The first illumination information and the second illumination information are fused to obtain the third illumination information; The first video is updated using the third illumination information to obtain the second video.
3. The method according to claim 2, wherein the attribute information corresponding to the material region includes the second object material attribute, and the step of fusing the first lighting information and the second lighting information to obtain the third lighting information includes: If the first pixel belongs to the material region, then the second illumination information of the first pixel is used as the third illumination information; if the first pixel does not belong to the material region, then the first illumination information of the first pixel is used as the third illumination information. The first pixel is each pixel in the video frame.
4. The method according to claim 2, wherein the attribute information corresponding to the material region includes self-illumination attributes, and the step of fusing the first illumination information and the second illumination information to obtain the third illumination information includes: If the second pixel belongs to the material region, the first illumination information and the second illumination information of the second pixel are superimposed to obtain the third illumination information. If the second pixel does not belong to the material region, the first illumination information of the second pixel is used as the third illumination information. The second pixel is each pixel in the video frame.
5. The method according to claim 1, further comprising: Multiple edge light sources are acquired, each with a different incident direction; A fourth illumination information is generated based on each of the aforementioned edge light sources and each pixel in the video frame; The step of updating the first video using the first illumination information to obtain the second video includes: The first video is updated using the first illumination information and the fourth illumination information to obtain the second video.
6. The method according to claim 5, wherein generating fourth illumination information based on each of the edge light sources and each pixel in the video frame comprises: Based on each edge light source and each pixel in the video frame, a first mask and a second mask are determined, wherein the first mask is determined based on the viewing direction and the normal direction of the pixel, and the second mask is determined based on the incident direction of the edge light source. The fourth illumination information is obtained based on the first mask, the second mask, and the illumination intensity of the edge light source.
7. The method according to any one of claims 1-6, further comprising: Based on a virtual light source, a first shadow texture is generated, and the first shadow texture corresponds to the first object; Based on the light source direction of the first light source and the normal direction corresponding to the first video, the first shadow texture is updated to obtain the second shadow texture; Based on the rendered 3D object and the second video, a third video is obtained, including: The second shadow texture is projected onto the surface of the rendered 3D object to obtain a shadow projection. The third video is obtained based on the shadow projection, the second video, and the rendered 3D object.
8. The method according to any one of claims 1-6, wherein obtaining the material attribute of the first object based on the video frames in the first video includes: The video frame is input into the material parsing model to obtain the material properties of the first object. The material parsing model is obtained in the following way: The training video is used as input to the model to obtain predicted material properties and predicted lighting information; A first loss is generated based on the training video and the predicted material properties; a second loss is generated based on the predicted illumination information of adjacent video frames; and a third loss is generated based on the predicted material properties of adjacent video frames. The material analysis model is trained based on the first loss, the second loss, and the third loss.
9. A video generation apparatus, comprising: The first acquisition module is used to acquire a first video and a three-dimensional object, wherein the first video includes the first object; The second acquisition module is used to acquire the material properties of the first object based on the video frames in the first video; The first generation module is used to generate first lighting information based on the first light source and the material properties of the first object, and to render the three-dimensional object based on the first light source. The first update module is used to update the first video using the first illumination information to obtain the second video; The second generation module is used to obtain the third video based on the rendered 3D object and the second video.
10. A computer-readable medium having a computer program stored thereon, wherein, When executed by a processing device, the computer program implements the method described in any one of claims 1-8.
11. An electronic device, comprising: A storage device on which computer programs are stored; A processing apparatus for executing the computer program in the storage device to implement the method of any one of claims 1-8.
12. A computer program product comprising a computer program, wherein, When executed by a processor, the computer program implements the method described in any one of claims 1-8.
