Method, device and storage medium for rendering a halo

By determining whether the light source and the camera are facing each other, and performing halo rendering when they are facing each other, the problem that the camera's viewpoint is difficult to encompass the screen's field of view in existing technologies is solved, and normal rendering of the light source within the camera's screen space is achieved.

CN115131436BActive Publication Date: 2025-11-07SIKELI CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210812478.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-11
Publication Date
2025-11-07
Estimated Expiration
2042-07-11

AI Technical Summary

Technical Problem

In existing rendering methods, the camera's perspective makes it difficult to encompass the actual light source within the screen's field of view, resulting in the inability to render lens flares.

Method used

By acquiring the position information of the light source and camera in the virtual scene, it is determined whether they are facing each other, and if they are facing each other, halo rendering is performed. The halo rendering is performed using the position information of the light source in the screen space and the screen space range of the camera.

Benefits of technology

It solves the problem that the camera's viewpoint is difficult to encompass the screen's field of view, ensuring that the light source is rendered correctly within the camera's screen space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115131436B_ABST
    Figure CN115131436B_ABST
Patent Text Reader

Abstract

The application relates to a halo rendering method and device and a storage medium, wherein the method comprises the following steps: acquiring first position information of a current light source in a current virtual scene, and acquiring second position information of a camera in the current virtual scene; determining whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information; acquiring third position information of the current light source in a screen space in the case of determining that the direction of the current light source and the direction of the camera are opposite; and rendering the halo generated by the light source in the imaging of the camera according to the third position information and the camera screen space position range. Through the application, the problem that the rendering mode in the prior art is difficult to put the actual light source into the screen visual field in some scenes is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of light source rendering, in particular to a halo rendering method and device and storage medium. BACKGROUND

[0002] The existing rendering scheme is a lens halo scheme or a post-processing halo scheme based on 2D patch rendering, and in some scenes, lens halo is needed to improve the scene rendering effect, but in the rendering mode in the prior art, in some scenes, the camera view angle is difficult to wrap the actual light source into the screen view, for example: in the project, a large number of scenes use third-person follow-overview, but most of the time, the light source cannot be included in the view, resulting in that the standard lens halo cannot be rendered.

[0003] For the above problems in the related art, there is no effective solution at present. SUMMARY

[0004] The present application provides a halo rendering method, device and storage medium to solve the problem that the rendering mode in the prior art is difficult to wrap the actual light source into the screen view in some scenes.

[0005] In a first aspect, the present application provides a halo rendering method, comprising: obtaining first position information of a current light source in a current virtual scene, and obtaining second position information of a camera in the current virtual scene; determining whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information; obtaining third position information of the current light source in the screen space in the case of determining that the direction of the current light source and the direction of the camera are opposite; and rendering the halo generated by the light source in the imaging of the camera according to the third position information and the camera screen space position range.

[0006] In a second aspect, the present application provides a halo rendering device, comprising: a first obtaining module, configured to obtain first position information of a current light source in a current virtual scene, and obtain second position information of a camera in the current virtual scene; a first determining module, configured to determine whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information; a second obtaining module, configured to obtain third position information of the current light source in the screen space in the case of determining that the direction of the current light source and the direction of the camera are opposite; and a rendering module, configured to render the halo generated by the light source in the imaging of the camera according to the third position information and the camera screen space position range.

[0007] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus.

[0008] The memory is configured to store a computer program.

[0009] The processor is configured to execute the program stored in the memory, so as to implement the method steps of any one of the embodiments of the first aspect.

[0010] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the method steps of any one of the embodiments of the first aspect.

[0011] Compared with the prior art, the above technical solutions provided by the embodiments of the present application have the following advantages:

[0012] The method provided by the embodiments of the present application first determines whether the orientations of the current light source and the camera are opposite according to the respective position information of the current light source and the camera in the current virtual scene. In the case that the orientations of the current light source and the camera are opposite, the light halo generated by the light source is rendered in the imaging of the camera according to the position information of the current light source in the screen space and the camera screen space position range. That is, in the embodiments of the present application, the light source can be rendered according to the position information of the current light source in the screen space and the camera screen space position range, so as to ensure that the current light source is in the camera screen space position range and then the light halo is rendered, thereby solving the problem that the rendering mode in the prior art is difficult to put the actual light source into the screen field of view in the camera visual angle in some scenes. BRIEF DESCRIPTION OF DRAWINGS

[0013] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.

[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0015] Figure 1 One of the flowcharts of the rendering method of the halo provided by the embodiments of the present application;

[0016] Figure 2 The second flowchart of the rendering method of the halo provided by the embodiments of the present application;

[0017] Figure 3A third flowchart of a method for rendering a halo according to an embodiment of the present application;

[0018] Figure 4 A structure diagram of a device for rendering a halo according to an embodiment of the present application;

[0019] Figure 5 A structure diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0021] Figure 1 A flowchart of a method for rendering a halo according to an embodiment of the present application is shown in FIG. 1, and steps of the method include: Figure 1

[0022] In step 102, first position information of a current light source in a current virtual scene is acquired, and second position information of a camera in the current virtual scene is acquired.

[0023] It should be noted that the current virtual scene can be a virtual scene in various animations, such as a virtual scene in a Japanese animation, a virtual scene in an American animation, etc.

[0024] In step 104, whether the orientation of the current light source and the orientation of the camera are opposite is determined according to the first position information and the second position information.

[0025] In step 106, third position information of the current light source in a screen space is acquired in a case where the orientation of the current light source and the orientation of the camera are opposite.

[0026] It should be noted that the orientation of the current light source and the orientation of the camera being opposite indicates that the two are in the same direction, i.e., light source rendering can be performed. If the orientation of the current light source and the orientation of the camera are not opposite, it indicates that the two are not in the same direction, i.e., the camera is backlit, and thus light source rendering cannot be performed.

[0027] In step 108, a halo generated by the light source is rendered in imaging of the camera according to the third position information and a camera screen space position range.

[0028] ​Through the steps 102 to 108, firstly, whether the orientations of the current light source and the camera are opposite is determined according to the respective position information of the current light source and the camera in the current virtual scene, and in the case that the orientations of the current light source and the camera are opposite, the light halo generated by the light source is rendered in the imaging of the camera according to the position information of the current light source in the screen space and the camera screen space position range, that is, in the embodiment of the present application, the light source can be rendered according to the position information of the current light source in the screen space and the camera screen space position range, so as to ensure that the current light source is in the camera screen space position range and then the light halo is rendered, thereby solving the problem that the rendering manner in the prior art is difficult to put the actual light source into the screen field of view in the camera view in some scenes.

[0029] In the embodiment of the present application, the position information types of the first position information and the second position information correspond to the light source type of the current light source; wherein in the case that the light source type of the current light source is parallel light, the position information type is coordinate orientation; and in the case that the light source type of the current light source is point light, the position information type is coordinate position.

[0030] In this regard, in a specific example, if the light source type of the current light source is parallel light, the first position information and the second position information respectively represent the coordinate orientation of the current light source in the world coordinate and the coordinate orientation of the camera in the world coordinate; and if the light source type of the current light source is point light, the first position information and the second position information respectively represent the vector from the coordinate position of the current light source in the world coordinate to the coordinate position of the camera in the world coordinate and the vector from the coordinate position of the camera in the world coordinate to the coordinate position of the current light source in the world coordinate.

[0031] In the embodiment of the present application, for the manner of determining whether the orientation of the current light source and the orientation of the camera are opposite according to the first position information and the second position information in the step 104, further can include:

[0032] Step 11, determining a light source orientation vector of the current light source in the virtual scene according to the first position information;

[0033] Step 12, determining a camera orientation vector of the camera in the virtual scene according to the second position information;

[0034] Step 13, determining the dot product result of the target orientation vector and the camera orientation vector;

[0035] In the case that the light source type of the current light source is point light, the first position information can be The second position information can be Then through and The dot product of the two light sources is used to determine whether the current light source's orientation is opposite to the camera's orientation. If the current light source is a parallel light source, the first position information can be a = (x1, y1, z1), and the second position information can be b = (x2, y2, z2). The vector between a and b is determined, and the dot product of these vectors is then used to determine whether the current light source's orientation is opposite to the camera's orientation.

[0036] Step 14: If the dot product result is less than 0, determine that the current light source orientation and the camera orientation are opposite.

[0037] Step 15: If the dot product result is greater than or equal to 0, determine that the current light source orientation and the camera orientation are not opposite.

[0038] Through steps 11 to 15 above, the dot product of the orientation vectors represented by the first and second position information is used to determine whether the two are facing each other. If the orientation of the current light source and the orientation of the camera are facing each other, it indicates that they are in the same direction, meaning that light source rendering can be performed. If the orientation of the current light source and the orientation of the camera are not facing each other, it indicates that they are not in the same direction, meaning that the camera is backlit, and light source rendering cannot be performed. Therefore, in this application, halo rendering is only performed after determining that the camera and light source are facing each other, to ensure that light source rendering can proceed normally.

[0039] Based on this, such as Figure 2 As shown, the method steps in this application embodiment may further include:

[0040] Step 107: If the current light source orientation and the camera orientation are not opposite, prevent rendering of the halo produced by the light source in the camera's image.

[0041] In other words, in this application, if the current light source and the camera are not facing each other, halo rendering is prohibited, because if the current light source and the camera are not facing each other, it means that the camera is backlit and light source rendering is not possible.

[0042] In an optional embodiment of this application, the method of obtaining the third position information of the current light source in the screen space involved in step 106 of this application embodiment may further include: mapping the position of the light source in the world coordinate space to the screen coordinate system corresponding to the screen space;

[0043] Before rendering the halo produced by the light source in the camera's image, such as Figure 3 As shown, the method in this application embodiment may further include: step 302, determining whether the position of the light source in the screen coordinate system is within the initial interval, wherein the initial interval is the interval corresponding to the camera screen in the screen coordinate system.

[0044] It should be noted that the camera screen initial interval is generally covered by the range with the lower left corner of the screen as [0, 0] and the upper right corner as [1, 1].

[0045] In step 304, in the case that the position of the light source in the screen coordinate system is not in the initial interval, the initial interval is adjusted to a target interval so that the position of the light source in the screen coordinate system is in the target interval.

[0046] In this regard, taking the range covered by the initial screen initial interval with the lower left corner as [0, 0] and the upper right corner as [1, 1] as an example, if the x and y of the screen space coordinates of the light source are both in the camera screen coordinate min to max interval, the screen space range can be modified to the range of [-1, 2] (min-1max+1) by the present application to ensure that the light source at the position about to enter the screen can also produce a halo projection on the camera.

[0047] In the embodiment of the present application, the way of rendering the halo generated by the light source in the imaging of the camera involved in step 106 can further include: rendering the halo generated by the light source in the imaging of the camera based on a halo patch, wherein the halo patch is a grid facing the camera generated according to the distance from the center of the screen space.

[0048] Corresponding to the above Figure 1 , the embodiment of the present application provides a halo rendering device, as shown in Figure 4 , the device comprises:

[0049] The first acquisition module 42 is configured to acquire first position information of a current light source in a current virtual scene and acquire second position information of a camera in the current virtual scene.

[0050] The first determination module 44 is configured to determine whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information.

[0051] The second acquisition module 46 is configured to acquire third position information of the current light source in the screen space in the case that the direction of the current light source and the direction of the camera are opposite.

[0052] The rendering module 48 is configured to render the halo generated by the light source in the imaging of the camera according to the third position information and the camera screen space position range.

[0053] By the device of the embodiment of the present application, firstly, whether the orientations of the current light source and the camera are opposite or not is determined according to the respective position information of the current light source and the camera in the current virtual scene, and in the case that the orientations of the current light source and the camera are opposite, the light halo generated by the light source is rendered in the imaging of the camera according to the position information of the current light source in the screen space and the camera screen space position range, that is, in the embodiment of the present application, the light source can be rendered according to the position information of the current light source in the screen space and the camera screen space position range, so as to ensure that the current light source is in the camera screen space position range and then the light halo is rendered, thereby solving the problem that the rendering manner in the prior art is difficult to put the actual light source into the screen field of view in the camera visual angle in some scenes.

[0054] Optionally, the position information types of the first position information and the second position information in the embodiment of the present application correspond to the light source type of the current light source; wherein in the case that the light source type of the current light source is parallel light, the position information type is coordinate orientation; and in the case that the light source type of the current light source is point light, the position information type is coordinate position.

[0055] Optionally, the first determining module 44 in the embodiment of the present application can further include: a first determining unit, configured to determine a light source orientation vector of the current light source in the virtual scene according to the first position information; a third determining unit, configured to determine a camera orientation vector of the camera in the virtual scene according to the second position information; a third determining unit, configured to determine a dot product result of the target orientation vector and the camera orientation vector; and a fourth determining unit, configured to determine that the orientation of the current light source and the orientation of the camera are opposite in the case that the dot product result is less than 0; and a fifth determining unit, configured to determine that the orientation of the current light source and the orientation of the camera are not opposite in the case that the dot product result is greater than or equal to 0.

[0056] Optionally, the second obtaining module 46 in the embodiment of the present application further includes: a mapping unit, configured to map the position of the light source in the world coordinate space to a screen coordinate system corresponding to the screen space.

[0057] Based on this, the device in the embodiment of the present application can further include: a second determining module, configured to determine whether the position of the light source in the screen coordinate system is in an initial interval before the light halo generated by the light source is rendered in the imaging of the camera, wherein the initial interval is an interval corresponding to the camera screen in the screen coordinate system.

[0058] Optionally, the device in the embodiment of the present application can further include: an adjusting module, configured to adjust the initial interval to a target interval in the case that the position of the light source in the screen coordinate system is not in the initial interval, so that the position of the light source in the screen coordinate system is in the target interval.

[0059] Optionally, the device in the embodiments of the present application can further comprise a prohibiting module configured to prohibit rendering of the light halo generated by the light source in the imaging of the camera when the orientation of the current light source is not toward the orientation of the camera.

[0060] Optionally, the rendering module 46 in the embodiments of the present application can further comprise a rendering unit configured to render the light halo generated by the light source in the imaging of the camera based on the halo patch, wherein the halo patch is a grid toward the camera generated based on the distance from the center of the screen space.

[0061] As shown in the Figure 5 embodiments of the present application, an electronic device is provided, comprising a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112 and the memory 113 can communicate with each other through the communication bus 114,

[0062] The memory 113 is configured to store a computer program.

[0063] In an embodiment of the present application, the processor 111 is configured to execute the program stored in the memory 113, so as to implement the light halo rendering method provided by any one of the preceding method embodiments, which has similar effects and will not be described here.

[0064] The embodiments of the present application further provide a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the light halo rendering method provided by any one of the preceding method embodiments.

[0065] It should be noted that, in the present document, the relationship terms such as "first" and "second" are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0066] The foregoing is considered as illustrative only of the principles of the application. Numerous modifications and changes will readily occur to those skilled in the art, and it is intended to embrace all such modifications and changes that fall within the scope of the application. Accordingly, the application is not to be restricted in scope to the specific embodiments disclosed herein but is to be accorded the full scope that the principles and novel features request appropriately granted.

Claims

1. A method of rendering a bloom, characterized by, The method comprises: obtaining first position information of a current light source in a current virtual scene, and obtaining second position information of a camera in the current virtual scene; determining whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information; in the case where it is determined that the direction of the current light source and the direction of the camera are opposite, obtaining third position information of the current light source in a screen space, specifically mapping the position of the light source in a world coordinate space to a screen coordinate system corresponding to the screen space; determining whether the position of the light source in the screen coordinate system is within an initial interval, wherein the initial interval is an interval corresponding to the camera screen in the screen coordinate system; in the case where the position of the light source in the screen coordinate system is not within the initial interval, adjusting the initial interval to a target interval, so that the position of the light source in the screen coordinate system is within the target interval; rendering the halo generated by the light source in the imaging of the camera according to the third position information and the camera screen space position range.

2. The method of claim 1, wherein, The position information types of the first position information and the second position information correspond to the light source type of the current light source; wherein, in the case where the light source type of the current light source is parallel light, the position information type is coordinate direction; in the case where the light source type of the current light source is point light, the position information type is coordinate position.

3. The method of claim 2, wherein, The determination of whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information comprises: determining a light source direction vector of the current light source in the virtual scene according to the first position information; determining a camera direction vector of the camera in the virtual scene according to the second position information; determining the dot product result of the target direction vector and the camera direction vector; in the case where the dot product result is less than 0, determining that the direction of the current light source and the direction of the camera are opposite; in the case where the dot product result is greater than or equal to 0, determining that the direction of the current light source and the direction of the camera are not opposite.

4. The method of claim 3, wherein, The method further comprises: in the case where the direction of the current light source and the direction of the camera are not opposite, prohibiting the rendering of the halo generated by the light source in the imaging of the camera.

5. The method of claim 1, wherein, The rendering of the halo generated by the light source in the imaging of the camera comprises: rendering the halo generated by the light source in the imaging of the camera based on a halo patch, wherein the halo patch is a grid facing the camera generated relative to the distance of the screen space center.

6. An apparatus for rendering a bloom, characterized by The method comprises: a first obtaining module for obtaining first position information of a current light source in a current virtual scene, and obtaining second position information of a camera in the current virtual scene; a first determining module for determining whether the direction of the current light source and the direction of the camera are opposite according to the first position information and the second position information; The second acquisition module is configured to, in a case where the orientation of the current light source and the orientation of the camera are opposite, acquire third position information of the current light source in a screen space, specifically, map the position of the light source in a world coordinate space to a screen coordinate system corresponding to the screen space; determine whether the position of the light source in the screen coordinate system is in an initial interval, wherein the initial interval is an interval corresponding to the camera screen in the screen coordinate system; and in a case where the position of the light source in the screen coordinate system is not in the initial interval, adjust the initial interval to a target interval, so that the position of the light source in the screen coordinate system is in the target interval. The rendering module is configured to render a halo generated by the light source in imaging of the camera according to the third position information and the camera screen space position range.

7. An electronic device, comprising: The device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored on the memory to implement the method steps in any one of claims 1-5.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method steps in any one of claims 1-5.

Citation Information

Patent Citations

  • Method and device for generating lens flare

    CN105976423A

  • Virtual model rendering method and device

    CN112915536A