Image rendering method, device, electronic device and storage medium

By calculating the projection matrix of the virtual object under the spherical light source view cone, and generating and rendering the target shadow map, the problem of breakage in the virtual object projection calculation is solved, and the rendering effect is improved.

CN112215936BActive Publication Date: 2025-04-22GUANGZHOU HUYA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011112255.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-16
Publication Date
2025-04-22
Estimated Expiration
2040-10-16

AI Technical Summary

Technical Problem

During the projection calculation process of virtual objects, the calculation strategy may cause fault phenomena, resulting in poor rendering effect.

Method used

By computing the target projection matrix of the virtual object under the spherical light source view cone, a target shadow map is generated and rendered to the target image to avoid faults between adjacent view cones.

Benefits of technology

Improve the rendering effect of shadow maps, avoid fault phenomena, and make the projection of virtual objects more realistic and continuous.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112215936B_ABST
    Figure CN112215936B_ABST
Patent Text Reader

Abstract

The present application proposes an image rendering method, device, electronic device and storage medium, which relate to the field of image processing technology. For a virtual object in a target image, a target projection matrix of the virtual object under a spherical light source cone is calculated, and then a target shadow map corresponding to the virtual object is generated according to the target projection matrix, so that the target shadow map is rendered to the target image; in this way, the same shadow map can be located in the same cone during the projection generation process, so as to avoid a fault between two adjacent cones and improve the rendering effect of the shadow map.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image rendering method, device, electronic device and storage medium. Background Art

[0002] In scenarios such as live webcasting, some virtual objects may be rendered in the live broadcast image using technologies such as AR (Augmented Reality) to enrich the live broadcast content in the live broadcast image and improve the live broadcast effect.

[0003] In order to enhance the realism of virtual objects, shadows of virtual objects and other effects may be rendered in live images to simulate object projections in real scenes.

[0004] However, in the process of calculating the projection of virtual objects, some calculation strategies may cause some fault phenomena in the process of calculating the projection, resulting in poor rendering effect. Summary of the invention

[0005] The purpose of the present application is to provide an image rendering method, device, electronic device and storage medium, which can improve the rendering effect of shadow maps.

[0006] In order to achieve the above purpose, the technical solution adopted in this application is as follows:

[0007] In a first aspect, the present application provides an image rendering method, the method comprising:

[0008] For a virtual object of a target image, a target projection matrix of the virtual object under a spherical light source viewing cone is calculated;

[0009] Generating a target shadow map corresponding to the virtual object according to the target projection matrix;

[0010] The target shadow map is rendered to the target image.

[0011] In a second aspect, the present application provides an image rendering device, the device comprising:

[0012] A calculation module, for calculating, for a virtual object of a target image, a target projection matrix of the virtual object under a spherical light source viewing cone;

[0013] A processing module, configured to generate a target shadow map corresponding to the virtual object according to the target projection matrix;

[0014] A rendering module is used to render the target shadow map to the target image.

[0015] In a third aspect, the present application provides an electronic device, including a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit);

[0016] The CPU is used to calculate a target projection matrix of a virtual object in a target image under a spherical light source viewing cone;

[0017] The GPU is used to generate a target shadow map corresponding to the virtual object according to the target projection matrix;

[0018] The GPU is further configured to render the target shadow map to the target image.

[0019] In a fourth aspect, the present application provides an electronic device, comprising a memory for storing one or more programs; a processor; and when the one or more programs are executed by the processor, the above-mentioned image rendering method is implemented.

[0020] In a fifth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned image rendering method when executed by a processor.

[0021] The present application provides an image rendering method, device, electronic device and storage medium. For a virtual object in a target image, a target projection matrix of the virtual object under a spherical light source cone is calculated, and then a target shadow map corresponding to the virtual object is generated according to the target projection matrix, so that the target shadow map is rendered to the target image. In this way, during the process of generating the projection, the same shadow map can be located in the same cone, thereby avoiding the occurrence of faults between two adjacent cones and improving the rendering effect of the shadow map.

[0022] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A schematic diagram of an interactive scenario of the live broadcast system provided in this application is shown.

[0025] Figure 2 A schematic diagram showing a virtual object in an image.

[0026] Figure 3 A schematic diagram showing a frustum of a cone.

[0027] Figure 4 A schematic structural block diagram of an electronic device provided in the present application is shown.

[0028] Figure 5 A schematic flowchart of the image rendering method provided by the present application is shown.

[0029] Figure 6 Show Figure 5 A schematic flowchart of the sub-steps of step 201 in FIG.

[0030] Fig. 7A A schematic diagram showing a shadow map.

[0031] Figure 7B Another diagram showing a shadow map.

[0032] Figure 8 A schematic structural block diagram of the image rendering device provided by the present application is shown.

[0033] In the figure: 100 - electronic device; 101 - memory; 102 - processor; 103 - communication interface; 300 - image rendering device; 301 - computing module; 302 - processing module; 303 - rendering module. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be clearly and completely described below in conjunction with the drawings in some embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Generally, the components of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0035] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents some selected embodiments of the present application. All other embodiments obtained by ordinary technicians in the field without creative work based on some embodiments in the present application are within the scope of protection of the present application.

[0036] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0037] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0038] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0039] See also Figure 1 , Figure 1 A schematic diagram of an interactive scenario of the live broadcast system provided by the present application is shown. In some embodiments, the live broadcast system may be a live broadcast platform for, for example, Internet live broadcast. The live broadcast system may include a server, a live broadcast initiator, and a live broadcast receiver. The server may establish communication with the live broadcast receiver and the live broadcast initiator, respectively, and the server may provide live broadcast services to the live broadcast receiver and the live broadcast initiator. For example, the anchor may provide a real-time online live broadcast stream to the audience through the live broadcast initiator and transmit it to the server, and the live broadcast receiver may pull the live broadcast stream from the server for online viewing or playback.

[0040] In some implementation scenarios, the live broadcast receiving end and the live broadcast initiating end can be used interchangeably. For example, the anchor of the live broadcast initiating end can use the live broadcast initiating end to provide live video services to the audience, or watch the live videos provided by other anchors as an audience. For another example, the audience of the live broadcast receiving end can also use the live broadcast receiving end to watch the live videos provided by the anchor they follow, or provide live video services to other audiences as an anchor.

[0041] In some embodiments, the live broadcast receiving end and the live broadcast initiating end may include but are not limited to mobile devices, tablet computers, laptop computers, or any combination of two or more thereof. In some embodiments, the mobile device may include but are not limited to wearable devices, smart mobile devices, augmented reality devices, etc., or any combination thereof. In some embodiments, the smart mobile device may include but are not limited to smart phones, personal digital assistants (PDAs), gaming devices, navigation devices, or point of sale (POS) devices, etc., or any combination thereof.

[0042] In addition, in some possible implementations, there may be zero, one or more live broadcast receiving terminals and live broadcast initiating terminals accessing the server. Figure 1 Among them, the live broadcast receiving end and the live broadcast initiating end can be installed with an Internet product for providing Internet live broadcast services. For example, the Internet product can be an application APP, a Web page, a small program, etc. related to the Internet live broadcast service used in a computer or a smart phone.

[0043] In some embodiments, the server may be a single physical server or a server group consisting of multiple physical servers for performing different data processing functions. The server group may be centralized or distributed (for example, the server may be a distributed system). In some possible implementations, if the server uses a single physical server, different logical server components may be assigned to the physical server based on different live broadcast service functions.

[0044] Understandably, Figure 1 The live broadcast system shown is only a possible example. In some other possible embodiments of the present application, the live broadcast system may also include only Figure 1 Some of the components shown may also include other components.

[0045] In e.g. Figure 1 In the live broadcast scene shown in the figure, some images such as Figure 2 The virtual object shown in the figure is displayed, and the shadow effect of the virtual object is rendered in the live image to simulate the projection of the virtual object in the real scene, thereby improving the authenticity of the virtual object and further improving the live broadcast effect.

[0046] In the process of rendering the shadow effect of the virtual object, some calculation strategies may be: based on the camera perspective, a shadow map of the virtual object is generated using a frustum, so as to render the shadow effect of the virtual object in the live image based on the generated shadow map.

[0047] Combination Figure 3 As shown, in the process of using frustum to generate shadow map of virtual object, in order to be applicable to the object area of ​​each depth value range, multiple continuous cones can be used for segmentation; wherein, in order to simulate the process that the shadow background gradually becomes smaller from near to far, in the area with smaller depth value, a larger frustum can be used for segmentation, while in the area with larger depth value, a smaller frustum can be used for segmentation; however, for example Figure 3 For example, multiple shadow maps may be rendered at the intersection of adjacent frustums, and some faults may appear during the switching transition, such as different parts of a shadow map being located in different frustums, resulting in poor rendering effects.

[0048] To this end, based on some defects of the above-mentioned calculation strategy, a possible implementation method provided by the present application is: for the virtual object in the target image, by calculating the target projection matrix of the virtual object under the spherical light source cone, and then generating a target shadow map corresponding to the virtual object according to the target projection matrix, so as to render the target shadow map to the target image; in this way, it is possible to avoid the occurrence of faults between two adjacent cones in the process of generating the projection, so as to improve the rendering effect of the shadow map.

[0049] See also Figure 4 , Figure 4 A schematic structural block diagram of an electronic device 100 provided by the present application is shown. In some embodiments, the electronic device 100 may include a memory 101, a processor 102, and a communication interface 103. The memory 101, the processor 102, and the communication interface 103 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these elements may be electrically connected to each other via one or more communication buses or signal lines.

[0050] The memory 101 can be used to store software programs and modules, such as program instructions / modules corresponding to the image rendering device provided in this application, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 101, thereby executing the steps of the image rendering method provided in this application. The communication interface 103 can be used to communicate signaling or data with other node devices.

[0051] Among them, the memory 101 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable programmable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0052] The processor 102 may be an integrated circuit chip with signal processing capability. The processor 102 may be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0053] Understandably, Figure 4 The structure shown is for illustration only. The electronic device 100 may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0054] Below Figure 4 The electronic device shown is used as an exemplary execution entity to schematically illustrate the image rendering method provided in the present application.

[0055] It is understandable that in some possible scenarios of the present application, the electronic device 100 may be used as Figure 1 The live broadcast initiator in the live broadcast initiator interacts with the live broadcast initiator, so that the live broadcast initiator executes the image rendering method provided by the present application and sends the generated live broadcast code stream to the server, so that the live broadcast receiving end can pull the live broadcast code stream from the server, and play the rendered live broadcast image after decoding.

[0056] Alternatively, in some other possible scenarios of the present application, the electronic device 100 may also be used as Figure 1 The server in the embodiment of the present invention receives a rendering request sent by a live broadcast initiator or a live broadcast receiving end, executes the image rendering method provided by the present application, obtains a rendered live broadcast image, and can also send the rendered live broadcast image to at least one of the live broadcast receiving end and the live broadcast initiator, so that at least one of the live broadcast receiving end and the live broadcast initiator can display the rendered live broadcast image.

[0057] Alternatively, in some other possible scenarios of the present application, the electronic device 100 may also be used as Figure 1 The live broadcast receiving end in the embodiment of the present invention pulls the live broadcast code stream from the server and decodes it to obtain the live broadcast image. In the process of displaying the live broadcast image on the display interface of the live broadcast receiving end, the image rendering method provided by the present application can be executed by receiving the user's instruction information to render the live broadcast image, and the rendered live broadcast image is displayed on the display interface of the live broadcast receiving end.

[0058] See also Figure 5 , Figure 5 A schematic flowchart of the image rendering method provided by the present application is shown. As a possible implementation, the image rendering method may include the following steps:

[0059] Step 201 : For a virtual object in a target image, a target projection matrix of the virtual object under a spherical light source viewing cone is calculated.

[0060] Step 203: Generate a target shadow map corresponding to the virtual object according to the target projection matrix.

[0061] Step 205, rendering the target shadow map to the target image.

[0062] Combination Figure 2 as well as Figure 3 As shown, in some embodiments, when an electronic device is executing the image rendering method provided by the present application, for a virtual object in a target image, the electronic device may not use a frustum based on the camera perspective to generate shadows, but instead calculate the target projection matrix of the virtual object under the spherical light source cone based on a spherical light source cone.

[0063] Among them, compared with the frustum based on the camera viewing cone, the target projection matrix generated by using the spherical light source cone can avoid the occurrence of faults between two adjacent cones during the projection generation process.

[0064] Next, the electronic device may generate a target shadow map corresponding to the virtual object based on the target projection matrix, where the target shadow map is a shadow map under the spherical light source cone.

[0065] The electronic device can then render the target shadow map to the target image to form a Figure 1 The rendering effect of the example is used to simulate the projection effect of the virtual object in the real scene and enhance the authenticity of the virtual object.

[0066] It can be seen that based on the above design, the image rendering method provided by the present application, for the virtual object in the target image, calculates the target projection matrix of the virtual object under the spherical light source cone, and then generates a target shadow map corresponding to the virtual object according to the target projection matrix, thereby rendering the target shadow map to the target image; in this way, in the process of generating the projection, the same shadow map can be located in the same cone, thereby avoiding the occurrence of faults between two adjacent cones, so as to improve the rendering effect of the shadow map.

[0067] Among them, in some possible application scenarios, for the target projection matrix of the virtual object under the spherical light source cone, the electronic device can first construct a spherical light source cone, and then calculate the target projection matrix based on the parameters of the constructed spherical light source cone.

[0068] For example, in Figure 5 Based on Figure 6 , Figure 6 Show Figure 5 A schematic flow chart of the sub-steps of step 201 in FIG. 2 is provided. As a possible implementation, step 201 may include the following sub-steps:

[0069] Step 201 - 1 : for a pre-constructed camera view frustum, a spherical light source view frustum corresponding to the camera view frustum is constructed according to a pre-acquired segmentation and matching strategy.

[0070] Step 201 - 3 , generating a target projection matrix corresponding to the virtual object according to the constructed spherical light source frustum.

[0071] In some embodiments, when constructing a spherical light source cone, the electronic device may construct the spherical light source cone based on a pre-constructed camera view cone.

[0072] Among them, the electronic device can also pre-acquire a segmentation matching strategy, which can be used to indicate the corresponding relationship between the depth value and the segmentation radius; for example, in some possible application scenarios, the depth value and the segmentation radius can be a linear relationship, and as the depth value increases, the segmentation radius can be reduced according to a certain proportional coefficient.

[0073] Based on this, when constructing a spherical light source cone, the electronic device can construct a spherical light source cone corresponding to the camera viewing angle cone according to the segmentation matching strategy and the segmentation radius corresponding to each depth value in the segmentation matching strategy.

[0074] For example, in some embodiments, in combination Figure 3 In the example given, the electronic device can construct a sphere with the minimum radius surrounding the camera's field of view cone according to the segmentation radius corresponding to the depth value of each point in the camera's field of view cone in the segmentation matching strategy as the spherical light source cone to reduce the amount of data processed.

[0075] Of course, it can be understood that the above-mentioned method of constructing a spherical light source cone is only an example. In some other possible implementations of the present application, the electronic device can also adopt other methods to construct the spherical light source cone. For example, on the basis of the segmentation radius determined by the above-mentioned segmentation matching strategy, a pre-configured redundant radius can be superimposed, so as to construct the spherical light source cone with the superimposed redundant radius.

[0076] Next, the electronic device can generate a target projection matrix corresponding to the virtual object based on the constructed spherical light source cone; for example, based on the spherical radius corresponding to the spherical light source cone, a camera matrix based on the viewing angle of the spherical light source cone is obtained, and the camera matrix is ​​used as the target projection matrix.

[0077] In addition, in some possible implementations, when executing step 203, the electronic device may first expand the depth value parameters of the virtual object in the pixel channel, and then process the expanded depth value parameters using the target projection matrix obtained above to obtain a target shadow map corresponding to the virtual object.

[0078] For example, combining Fig. 7A As shown, the electronic device can expand the depth value parameter of the virtual object in the R channel based on a single pixel channel in the RGBA pixel space, such as the R channel, and then encode the expanded depth value parameter using the above-mentioned target projection matrix to obtain the following Fig. 7A The target shadow map shown.

[0079] It should be noted that in the solution of expanding the depth value parameter in a single pixel channel, the texture data used in the process of rendering the shadow map is generally of byte type, and the scene depth is generally saved as a single value; however, the numerical type of the depth value is generally float type. When only one channel is used to generate the shadow map, only the depth value data with a length of 0-255 can be saved, causing the rest to be discarded, which may result in lower accuracy of the target shadow map.

[0080] Therefore, in some embodiments, when the electronic device expands the depth value parameters of the virtual object in the pixel channel, the depth value parameters of the virtual object can be expanded in multiple pixel channels; for example, in the above example scenario, the depth value parameters of the virtual object can be expanded in the R channel, the G channel, the B channel, and the A channel in the RGBA pixel space, so that the electronic device can use the depth value parameters expanded in multiple pixel channels without discarding the data of some parts of the depth value, and obtain the following Figure 7B The target shadow map corresponding to the virtual object shown is used to improve the accuracy of the generated target shadow map.

[0081] In addition, in some possible application scenarios, when executing step 205, the electronic device can, based on the depth value parameters in the physical depth space of the virtual object, cut out the shadow map corresponding to the depth value parameters of the virtual object in the target shadow map, and render the cut shadow map to the target image, thereby improving the generation accuracy of the shadow background.

[0082] It should be noted that, in some embodiments of the present application, the above-mentioned electronic device provided by the present application may be configured with a CPU and a GPU; wherein the above-mentioned step 201 may be executed by the CPU, and the CPU calculates the target projection matrix and sends the target projection matrix to the GPU; then the GPU executes steps 203 and 205, and renders a shadow effect in the target image according to the obtained target projection matrix.

[0083] Furthermore, based on the same inventive concept as the above-mentioned image rendering method provided in this application, please refer to Figure 8 , Figure 8 A schematic structural block diagram of an image rendering device 300 provided in the present application is shown. The rendering device 300 may include a computing module 301 , a processing module 302 and a rendering module 303 .

[0084] A calculation module 301 is used to calculate a target projection matrix of a virtual object in a target image under a spherical light source viewing cone;

[0085] A processing module 302 is used to generate a target shadow map corresponding to the virtual object according to the target projection matrix;

[0086] The rendering module 303 is used to render the target shadow map to the target image.

[0087] Optionally, as a possible implementation, in the process of calculating the target projection matrix of the virtual object under the spherical light source frustum, the calculation module 301 is specifically used to:

[0088] For a pre-constructed camera view cone, a spherical light source view cone corresponding to the camera view cone is constructed according to a pre-acquired segmentation matching strategy; wherein the segmentation matching strategy is used to indicate a corresponding relationship between a depth value and a segmentation radius;

[0089] According to the constructed spherical light source frustum, the target projection matrix corresponding to the virtual object is generated.

[0090] Optionally, as a possible implementation, the calculation module 301, in the process of constructing a spherical light source frustum corresponding to the camera viewing frustum according to the pre-acquired segmentation and matching strategy, is specifically used to:

[0091] According to the segmentation radius corresponding to the depth value of each point in the camera view cone in the segmentation matching strategy, a sphere with the minimum radius surrounding the camera view cone is constructed as a spherical light source cone.

[0092] Optionally, as a possible implementation, in the process of generating a target shadow map corresponding to the virtual object according to the target projection matrix, the processing module 302 is specifically used to:

[0093] Expand the depth value parameters of the virtual object in the pixel channel;

[0094] The expanded depth value parameters are processed using the target projection matrix to obtain a target shadow map corresponding to the virtual object.

[0095] Optionally, as a possible implementation, the processing module 302 is specifically used to:

[0096] Expand the depth value parameters of the virtual object across multiple pixel channels.

[0097] Optionally, as a possible implementation, the rendering module 303, in the process of rendering the target shadow map to the target image, is specifically used to:

[0098] The shadow map corresponding to the depth value parameter of the virtual object is cut out from the target shadow map, and the cut shadow map is rendered to the target image.

[0099] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to some embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and the module, program segment or a part of a code includes one or more executable instructions for implementing a specified logical function.

[0100] It should also be noted that in some alternative implementations, the functions marked in the blocks may also occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved.

[0101] It should also be noted that each box in the block diagram and / or flowchart, and combinations of boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0102] In addition, in some embodiments of the present application, the functional modules may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0103] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in some embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories, random access memories, magnetic disks or optical disks.

[0104] The above description is only a partial embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0105] It will be apparent to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present application. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

Claims

1. An image rendering method, characterized in that: The method comprises: For a virtual object of a target image, a target projection matrix of the virtual object under a spherical light source viewing cone is calculated; Generating a target shadow map corresponding to the virtual object according to the target projection matrix; Rendering the target shadow map to the target image; The process of constructing the spherical light source viewing cone includes: For a pre-constructed camera view cone, a sphere with a minimum radius surrounding the camera view cone is constructed according to the segmentation radius corresponding to the depth value of each point of the camera view cone in a pre-acquired segmentation matching strategy, as the spherical light source cone; wherein the segmentation matching strategy is used to indicate the correspondence between the depth value and the segmentation radius.

2. The method according to claim 1, characterized in that Generating a target shadow map corresponding to the virtual object according to the target projection matrix includes: Expanding the depth value parameters of the virtual object in the pixel channel; The expanded depth value parameters are processed using the target projection matrix to obtain a target shadow map corresponding to the virtual object.

3. The method according to claim 2, characterized in that The step of expanding the depth value parameter of the virtual object in the pixel channel includes: The depth value parameters of the virtual object are expanded in multiple pixel channels.

4. The method according to claim 1, characterized in that The rendering of the target shadow map to the target image comprises: The shadow map corresponding to the depth value parameter of the virtual object is cut out from the target shadow map, and the cut shadow map is rendered to the target image.

5. An image rendering device, characterized in that: The device comprises: A calculation module is used to construct a sphere with a minimum radius surrounding a pre-constructed camera view cone according to a segmentation radius corresponding to a depth value of each point of the camera view cone in a pre-acquired segmentation matching strategy, as a spherical light source cone; wherein the segmentation matching strategy is used to indicate a corresponding relationship between a depth value and a segmentation radius; and to calculate a target projection matrix of a virtual object in a target image under the spherical light source cone; A processing module, configured to generate a target shadow map corresponding to the virtual object according to the target projection matrix; A rendering module is used to render the target shadow map to the target image.

6. An electronic device, characterized in that: Including central processing unit CPU and image processing unit GPU; The CPU is used to construct a sphere with a minimum radius surrounding the camera view cone as a spherical light source cone according to the segmentation radius corresponding to the depth value of each point of the camera view cone in the pre-acquired segmentation matching strategy, with respect to the pre-constructed camera view cone; wherein the segmentation matching strategy is used to indicate the corresponding relationship between the depth value and the segmentation radius; and is used to calculate a target projection matrix of the virtual object under the spherical light source cone for the virtual object of the target image; The GPU is used to generate a target shadow map corresponding to the virtual object according to the target projection matrix; The GPU is further configured to render the target shadow map to the target image.

7. An electronic device, characterized in that: include: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 4 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Shadow map generating method and device

    CN107274476A

  • Shadow map generation method and device

    CN111724313A