Illumination processing method and device in game, electronic equipment and storage medium

By setting up a virtual light source in the game and limiting its lighting area, the light leakage problem when turning off dynamic light source projection calculations is solved, achieving more realistic lighting effects and lower rendering overhead.

CN119792916APending Publication Date: 2025-04-11NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411874554.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art turns off projection calculation of dynamic light sources in mobile games or VR games, although reducing rendering overhead, it will cause unreal light leakage problems.

Method used

By setting a virtual light source in the game and determining its pre-configured first light range and light source material parameters when the shadow cast of the virtual light source is in the off state. Then, a spatial volume function is constructed based on the scene range of the target scene, combined with the light source material parameters, and the second lighting range corresponding to the virtual light source in the target scene is calculated, thereby limiting the lighting area of ​​the virtual light source to the scene range of the target scene.

Benefits of technology

It realizes the reduction of rendering overhead while avoiding the light leakage problem of virtual light sources, ensuring the correctness of the lighting effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119792916A_ABST
    Figure CN119792916A_ABST
Patent Text Reader

Abstract

The invention provides an illumination processing method and device in a game, electronic equipment and a storage medium, and the method comprises the steps: responding to a target event for a target scene, and determining a preset virtual light source in the target scene; in response to the fact that shadow projection of the virtual light source is in a closed state, determining a first illumination range and light source material parameters pre-configured for the virtual light source; in response to the fact that the first illumination range is larger than the scene range of the target scene, determining a space volume function based on the scene range; and determining a second illumination range corresponding to the virtual light source in the target scene according to the space volume function and the light source material parameters, and rendering the illumination effect in the target scene based on the second illumination range. According to the scheme, the actual illumination range of the virtual light source is limited in the cubic space described by the space volume function, a correct illumination effect is achieved, rendering overhead is reduced, and meanwhile the problem that light leakage cannot be caused when shadow projection of the virtual light source is closed is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of game technology, and in particular to a method, device, electronic device and storage medium for processing lighting in a game. Background Art

[0002] Usually, in a game scene, the lighting range of the light in the game engine or renderer is determined according to the light source in the real scene. Among them, the light source includes: point light in a spherical range, spotlight in a conical range, and directional light simulating the sun. To simulate the real light source in the game, it is necessary to calculate the projection data generated by the light in real time to achieve a more realistic lighting effect.

[0003] In the related technology, considering that the real-time projection calculation overhead of dynamic light sources is large and will affect the game frame rate, in the production of mobile games or VR games, it is usually chosen to turn off the calculation of dynamic light source projection.

[0004] However, turning off the projection calculation of dynamic light sources, although reducing rendering overhead, will produce unrealistic light leakage problems. Summary of the invention

[0005] The purpose of the present invention is to provide a method, device, electronic device and storage medium for lighting processing in games to address the deficiencies in the above-mentioned prior art, so as to solve the problem of unrealistic light leakage when the projection calculation of dynamic light sources is turned off in the prior art.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, an embodiment of the present application provides a method for lighting processing in a game, the method comprising:

[0008] In response to a target event for a target scene, determining a virtual light source pre-set in the target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene;

[0009] In response to the shadow projection of the virtual light source being in an off state, determining a first illumination range and light source material parameters preconfigured for the virtual light source;

[0010] In response to the first illumination range being larger than a scene range of the target scene, determining a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume region determined from the target scene and not larger than the scene range;

[0011] A second illumination range corresponding to the virtual light source in the target scene is determined according to the spatial volume function and the light source material parameter, and the illumination effect in the target scene is rendered based on the second illumination range.

[0012] In a second aspect, an embodiment of the present application further provides a lighting processing device in a game, the device comprising:

[0013] A determination module, configured to determine a virtual light source pre-set in a target scene in response to a target event for a target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene; in response to shadow projection of the virtual light source being in an off state, determine a first illumination range and light source material parameters pre-configured for the virtual light source; in response to the first illumination range being larger than a scene range of the target scene, determine a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume area determined from the target scene that is not larger than the scene range; and determine a second illumination range corresponding to the virtual light source in the target scene according to the spatial volume function and the light source material parameters;

[0014] A rendering module is used to render the lighting effect in the target scene based on the second lighting range.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the in-game lighting processing method provided in the first aspect.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the lighting processing method for the game provided in the first aspect is executed.

[0017] The beneficial effects of this application are:

[0018] The present application provides a method, device, electronic device and storage medium for lighting processing in a game. In order to reduce rendering overhead, in response to the shadow projection of a virtual light source being in an off state, the present solution determines a first lighting range and light source material parameters pre-configured for the virtual light source; then, when it is determined that the first lighting range is larger than the scene range of a target scene, a spatial volume function is constructed according to the scene range of the target scene, and according to the spatial volume function and the light source material parameters, a second lighting range corresponding to the virtual light source in the target scene is calculated, that is, the actual lighting range of the virtual light source is limited to the cubic space described by the spatial volume function, thereby achieving the purpose of limiting the illumination area of ​​the virtual light source to the scene range of the target scene, achieving a correct lighting effect, and reducing rendering overhead while effectively solving the problem of light leakage when the shadow projection of the virtual light source is turned off. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention 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 creative work.

[0020] Figure 1 A spherical or conical area defined for a light in a game engine or renderer to represent the illumination range of a virtual light source;

[0021] FIG2( a ) is a schematic diagram of the lighting effect when the shadow projection of the virtual light source is turned on;

[0022] FIG2( b ) is a schematic diagram of the lighting effect when the shadow projection of the virtual light source is turned off;

[0023] Figure 3 A flowchart of a lighting processing method in a game provided by an embodiment of the present application;

[0024] Figure 4 A schematic diagram of the lighting effect in a lighting processing method in a game provided in an embodiment of the present application Figure 1 ;

[0025] Figure 5 A second schematic diagram of lighting effects in a lighting processing method in a game provided by an embodiment of the present application;

[0026] Figure 6 A schematic diagram of a flow chart of another lighting processing method in a game provided by an embodiment of the present application;

[0027] Figure 7 A flowchart of another method for lighting processing in a game provided by an embodiment of the present application;

[0028] Figure 8 A schematic diagram of a flow chart of another lighting processing method in a game provided by an embodiment of the present application;

[0029] Fig. 9 Schematic diagram of the target bounding box provided in the embodiment of the present application Figure 1 ;

[0030] Fig.10 A flowchart of another method for lighting processing in a game provided by an embodiment of the present application;

[0031] Fig.11 Schematic diagram 2 of a target bounding box provided in an embodiment of the present application;

[0032] Fig.12 A structural schematic diagram of a lighting processing device in a game provided by an embodiment of the present application;

[0033] Fig.13 A schematic diagram of the structural interaction of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0035] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0036] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0037] First, the professional terms involved in this application are introduced.

[0038] 1. Point Light: Point light is a light source whose light radiates evenly in all directions from a single point. Point light has no specific direction, and the light spreads outward from the light source and gradually weakens, similar to a light bulb or candle in real life.

[0039] 2. Spotlight: A spotlight is a light source whose light is emitted from a fixed point but spreads only within a specific conical area; the spotlight has a direction, and the light gradually spreads in that direction, similar to a flashlight or stage spotlight in real life.

[0040] 3. Signed distance function: (SDF), also known as oriented distance function (ODF), determines the distance from a point to the boundary of a finite area in space and defines the sign of the distance at the same time. The point is positive inside the boundary of the area, negative outside the boundary of the area, and 0 when the point is on the boundary of the area.

[0041] 4. Volume texture: Volume texture is actually a two-dimensional map, stored in a form similar to a sequence frame. The principle is the same as the CT scan in the hospital. The object is cut horizontally and taken out, and then arranged in a certain order.

[0042] Before the present application is proposed, a spherical or conical area defined by the light of a general game engine or renderer is used to represent the lighting range of a virtual light source, such as Figure 1 shown.

[0043] In the prior art, there are usually two lighting optimization solutions in mobile game development. They are as follows:

[0044] The first method is to use dynamic light sources and turn off the projection of dynamic light sources to reduce rendering overhead;

[0045] The second method is to use static light sources and bake the lighting information into the texture.

[0046] However, the above method has the following disadvantages. Specifically, the first method uses dynamic light sources and turns off the projection of dynamic light sources. Although it reduces the rendering overhead, it will cause obvious light leakage; as shown in Figure 2(a) and Figure 2(b) below, several models can be used to simulate the wall. Among them, Figure 2(a) is the projection turned on, the light produces the correct lighting effect, the inside of the wall is normally illuminated, and the outside is blocked by the model and not illuminated; Figure 2(b) is the projection turned off state. It can be clearly seen that the wall in the right picture cannot produce the correct occlusion effect on the light, and the light shines through the wall to illuminate the outside.

[0047] The second method uses static light sources to bake lighting information into textures, but there is a problem that dynamic lighting interaction cannot be achieved, resulting in the inability to switch the light on and off.

[0048] Based on the above problems, the embodiment of the present application proposes a lighting processing method in the game, firstly determining the virtual light source in the target scene and turning off the shadow projection of the virtual light source to reduce the rendering overhead; then determining the first lighting range and light source material parameters of the virtual light source, wherein the first lighting range refers to the lighting area when the virtual light source is lit, and the light source material parameters refer to the light brightness of the virtual light source at each position point along different lighting directions within the first lighting range; and when the scene range of the target scene is larger than the first lighting range, the space volume function is used to express the scene range, and according to the space volume function and the light source material parameters, the second lighting range corresponding to the virtual light source in the target scene is obtained, that is, the lighting area of ​​the virtual light source is limited to the range of the cube, and the problem of light leakage will not be caused when the shadow projection of the virtual light source is turned off. Therefore, the lighting processing method in the game provided by the present application reduces the rendering overhead by turning off the shadow calculation with large overhead in the dynamic light source lighting calculation, and at the same time solves the light leakage problem in some specific scenes (such as two adjacent spaces) in combination with the light material, and achieves the correct lighting effect.

[0049] In one embodiment of the present application, the lighting processing method in the game can be run on a local terminal device or a server. When the lighting processing method in the game is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0050] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the lighting processing method in the game are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud is used for information processing. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.

[0051] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.

[0052] The specific implementation of the lighting processing method in the game of the present application will be described in detail below through multiple embodiments.

[0053] Figure 3 This is a flow chart of the lighting processing method in the game provided in the embodiment of the present application. It should be noted that the lighting processing method in the game provided in the present application is not based on Figure 3 It should be understood that in other embodiments, the order of some steps in the lighting processing method for games provided by the present application can be interchanged according to actual needs, or some steps can be omitted or deleted. Figure 3 As shown, the method includes:

[0054] S301 : In response to a target event for a target scene, determine a virtual light source preset in the target scene.

[0055] The target event is used to trigger the virtual light source in the target scene to be turned on or off. It can be understood that if the virtual light source in the target scene is turned on, the target scene is illuminated by the virtual light source.

[0056] Exemplarily, a plurality of virtual light sources to be selected are pre-set in the game scene, such as Point Light1, Point Light1, Point Light3, Spotlight1, and Spotlight2. A virtual light source can be selected from the plurality of virtual light sources to be selected, such as selecting Point Light3 as the virtual light source in the target scene.

[0057] The target scene may be a fixed virtual object set in the game scene, such as a room, a wall, a roof, etc.

[0058] In this embodiment, for example, referring to Figure 4As shown in the figure, the target scene can be the left room of the two adjacent rooms. A virtual light source is set in the left room. When the virtual light source in the target scene is turned on, the entire space of the left room will be illuminated, and the right room will not be illuminated due to the wall. However, in order to reduce the rendering overhead, the shadow projection of the virtual light source set in the left room is turned off, that is, the projection calculation of the dynamic light source is turned off. At this time, obvious light leakage will occur, that is, the right room will be illuminated incorrectly (such as Figure 5 shown).

[0059] S302: In response to the shadow projection of the virtual light source being in a closed state, determine a first illumination range and light source material parameters preconfigured for the virtual light source.

[0060] The first illumination range refers to the illumination area when the virtual light source in the target scene is lit; for example, Figure 5 As shown, the first illumination range of the virtual light source Point Light3 is a lighting range obtained according to the light source radius parameter of the virtual light source Point Light3, which is indicated by two circular wireframes.

[0061] Therefore, the light source radius parameter of the virtual light source can be adjusted so that the first illumination range of the virtual light source covers the target scene, that is, the first illumination range is larger than the scene range of the target scene.

[0062] Among them, the light source material parameter refers to the light brightness of the virtual light source at each position point along different lighting directions within the first lighting range. It can be understood that within the first lighting range, along different lighting directions, the closer to the virtual light source, the stronger the light intensity, and the farther away from the virtual light source, the weaker the light intensity, that is, the light intensity of the virtual light source will decay to a certain extent as the distance changes.

[0063] S303: In response to the first illumination range being larger than the scene range of the target scene, determine a spatial volume function based on the scene range.

[0064] The spatial volume function is used to refer to a spatial volume area determined from the target scene and not larger than the scene range.

[0065] It can be understood that when the first illumination range is less than or equal to the scene range of the target scene, there will be no light leakage problem, and there is no need to limit the lighting area of ​​the virtual light source to the scene range of the target scene; when the first illumination range is larger than the scene range of the target scene, when the shadow projection of the virtual light source is turned off, there will be light leakage problems. Therefore, it is necessary to adopt the in-game lighting processing method provided in this application to solve the problem of light leakage.

[0066] Optionally, in order to more intuitively observe and control the scene range of the target scene, it is proposed that a spatial volume function can be used to characterize the scene range of the target scene. The scene range of the target scene can be approximated as a cube S, that is, the spatial structure of the cube can be described by the spatial volume function. When inside the cube, the output result of the spatial volume function is 1; outside the cube, the output result of the spatial volume function is 0.

[0067] S304: Determine a second illumination range corresponding to the virtual light source in the target scene according to the spatial volume function and the light source material parameters, and render the illumination effect in the target scene based on the second illumination range.

[0068] In this embodiment, for example, the light source material parameters of the virtual light source can be controlled by the space volume function to obtain the second illumination range corresponding to the virtual light source in the target scene, that is, the actual illumination range of the virtual light source is limited to the cubic space described by the space volume function, so as to achieve the purpose of limiting the illumination area of ​​the virtual light source to the scene range of the target scene, and achieve the correct illumination effect (as shown in the following example). Figure 4 As shown in the figure), while reducing the rendering overhead, it effectively solves the problem of light leakage when the shadow projection of the virtual light source is turned off.

[0069] Optionally, the in-game lighting processing method provided in the present application can be applied to the production of interactive lighting in mobile games or VR games, so that the game can achieve a richer interactive experience.

[0070] Secondly, this application can also provide lighting artists with more freedom in lighting control, realizing more creative light and shadow art.

[0071] In summary, an embodiment of the present application provides a method for lighting processing in a game, the method comprising: in response to a target event for a target scene, determining a virtual light source pre-set in the target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene; in response to the shadow projection of the virtual light source being in an off state, determining a first lighting range and light source material parameters pre-configured for the virtual light source; in response to the first lighting range being larger than the scene range of the target scene, determining a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume area determined from the target scene that is not larger than the scene range; according to the spatial volume function and the light source material parameters, determining a second lighting range corresponding to the virtual light source in the target scene, and rendering the lighting effect in the target scene based on the second lighting range. In this scheme, in order to reduce rendering overhead, in response to the shadow projection of the virtual light source being in an off state, a first illumination range and light source material parameters pre-configured for the virtual light source are determined; then, when it is determined that the first illumination range is larger than the scene range of the target scene, a spatial volume function is constructed according to the scene range of the target scene, and based on the spatial volume function and the light source material parameters, the second illumination range corresponding to the virtual light source in the target scene is calculated, that is, the actual illumination range of the virtual light source is limited to the cubic space described by the spatial volume function, thereby achieving the purpose of limiting the illumination area of ​​the virtual light source within the scene range of the target scene, achieving a correct lighting effect, and reducing the rendering overhead while effectively solving the problem of light leakage when the shadow projection of the virtual light source is turned off.

[0072] Optionally, refer to Figure 6 As shown, the above step S302 includes:

[0073] S601: Obtain lighting parameters of a virtual light source.

[0074] S602: Determine a first illumination range and material parameters of the virtual light source according to illumination parameters of the virtual light source.

[0075] The illumination parameters include: light source type, light source position, illumination radius and illumination intensity. For example, the light source type may be a point light source, a spotlight, a directional light, an area light, etc. The light source position may be any point within the scene range of the target scene, such as the center point O within the scene range, or a position point A near a boundary area within the scene range.

[0076] The illumination radius R refers to the maximum distance that the light can effectively illuminate when the virtual light source is irradiated along different illumination directions. Different light source types have different corresponding illumination radius R.

[0077] Among them, as the distance increases, the light intensity gradually weakens.

[0078] In this embodiment, the first illumination range of the virtual light source, that is, the area range that the virtual light source can theoretically illuminate, can be calculated based on parameter information such as the light source type, light source position, illumination radius and illumination intensity of the virtual light source; at the same time, the light source material parameters such as the illumination intensity and illumination color at each position point of the virtual light source along different illumination directions can also be calculated.

[0079] The following embodiments will explain in detail how to determine a spatial volume function based on the scene range.

[0080] Optionally, refer to Figure 7 As shown, the above step S302 includes:

[0081] S701: Determine area information of a scene range of a target scene.

[0082] The region information includes at least one of the following: region length L, region width W, region height H, region center position P, and region rotation information. The region rotation information includes a rotation angle.

[0083] Optionally, the size of the area range of the target scene can be determined according to the area length L, area width W, and area height H; then, the position information of the area range of the target scene in three-dimensional space is determined according to the area center position P and area rotation information.

[0084] S702: Determine a spatial volume function according to the area information of the scene range.

[0085] In this embodiment, for example, a function expression of the scene range in three-dimensional space, namely, a space volume function SDF, can be obtained according to the region length L, region width W, region height H, region center position P and rotation angle of the scene range.

[0086] Optionally, refer to Figure 8 As shown, the above step S302 includes:

[0087] S801: Create an initial bounding box.

[0088] Exemplarily, for example, an initial three-dimensional wireframe model may be generated using components provided by a game development engine, or an initial three-dimensional wireframe model, ie, an initial bounding box, may be created in modeling software.

[0089] S802: Adjust the initial bounding box according to the region information to obtain a target bounding box.

[0090] The initial bounding box may be larger than the bounding box corresponding to the scene range of the target scene, or may be smaller than or equal to the bounding box corresponding to the scene range of the target scene.

[0091] In one achievable manner, for example, when the initial bounding box is smaller or larger than the bounding box corresponding to the scene range of the target scene, the initial bounding box needs to be adjusted multiple times according to the area information of the scene range until the adjusted bounding box (e.g. Fig. 9 If the yellow wireframe shown in the figure is completely aligned with the bounding box corresponding to the scene range, the adjusted bounding box can be used as the target bounding box. Fig. 9 The bounding box corresponding to the room shown in .

[0092] S803: Determine a spatial volume function according to parameter information of the target bounding box.

[0093] The parameter information of the target bounding box includes: length, width, height, position and rotation.

[0094] In this embodiment, the function expression of the target bounding box, that is, the function expression of the target scene, that is, the spatial volume function SDF, can be determined according to the length, width, height, position and rotation of the target bounding box.

[0095] Optionally, the region information also includes: occluding surface information and non-occluding surface information.

[0096] refer to Fig.10 As shown, the above step S802 includes:

[0097] S1001: Adjust the initial bounding box according to the region length, region width, region height, region center position and region rotation information to obtain an intermediate bounding box.

[0098] S1002: Expand the intermediate bounding box according to the non-occluded surface information to obtain a target bounding box.

[0099] Optionally, in this solution, it is considered that the target scene may be semi-enclosed. Fig.11 As shown, the target scene is a room, in which the front of the room is in an open state and the other three sides are in a closed state. Therefore, the initial bounding box can be adjusted according to the length, width, height, center position and rotation angle of the room to obtain an intermediate bounding box; then, the intermediate bounding box is expanded in combination with the size and position of the front side (i.e., the non-occluded surface) of the room to obtain an expanded frame, i.e., the target bounding box. The expanded area can be called a transition area, so that when determining the spatial volume function based on the parameter information of the target bounding box, the range control of the edge transition is added, so that there is a section of attenuation area in the illumination range of the virtual light source, making the lighting effect more natural.

[0100] Optionally, determining the light source material parameters according to the lighting parameters of the virtual light source includes:

[0101] According to the illumination parameters of the virtual light source, the illumination intensity of the virtual light source at each position in different directions is determined, and the illumination intensity at each position in different directions is used as the material parameter of the light source.

[0102] In one feasible method, for example, the distance D between the virtual light source's location point O and each position in different directions can be calculated based on the coordinate information of the virtual light source's location point O and each position in different directions; then, the light intensity of the virtual light source at each position in different directions can be calculated based on the attenuation rate of the virtual light source and the distance D between the virtual light source's location point O and each position in different directions, and the light intensity at each position in different directions is used as the light source material parameter.

[0103] Optionally, the above step S304 includes:

[0104] The product result of the spatial volume function and the material parameter of the light source is determined, and the second illumination range corresponding to the virtual light source in the target scene is determined according to the product result.

[0105] It should be noted that if a certain position point P that can be illuminated by the virtual light source is within the scene range of the target scene, the output result of the spatial volume function is 1; if a certain position point P that can be illuminated by the virtual light source is outside the scene range of the target scene, the output result of the spatial volume function is 0.

[0106] Optionally, in this solution, in order to limit the actual illumination range of the virtual light source within the scene range of the target scene, it is proposed that the second illumination range corresponding to the virtual light source in the target scene can be determined based on the product of the spatial volume function and the material parameters of the light source. Specifically, when the position point P1 actually illuminated by the virtual light source is within the scene range of the target scene, the output result of the spatial volume function is 1, that is, the light brightness of the position point P1 can be determined to be the material parameters of the light source at that position; when the position point P2 actually illuminated by the virtual light source is outside the scene range of the target scene, at this time, the output result of the spatial volume function is 0, that is, the light brightness of the position point P2 can also be determined to be 0. Therefore, the illumination range of the virtual light source can be limited to the scene range of the target scene through the spatial volume function, that is, the second illumination range corresponding to the virtual light source in the target scene is obtained, and a more correct lighting effect is achieved. While reducing the rendering overhead, it solves the problem of obvious light leakage in the virtual light source after turning off the projection of dynamic lights.

[0107] Based on the same inventive concept, the embodiment of the present application also provides an in-game lighting processing device corresponding to the in-game lighting processing method. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the in-game lighting processing method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0108] Optionally, refer to Fig.12 As shown, a schematic diagram of the structure of a lighting processing device in a game provided by an embodiment of the present application is shown, and the device includes:

[0109] A determination module 1201 is used to determine a virtual light source pre-set in the target scene in response to a target event for a target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene; in response to the shadow projection of the virtual light source being in an off state, determine a first illumination range and light source material parameters pre-configured for the virtual light source; in response to the first illumination range being larger than a scene range of the target scene, determine a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume area determined from the target scene that is not larger than the scene range; and determine a second illumination range corresponding to the virtual light source in the target scene according to the spatial volume function and the light source material parameters;

[0110] The rendering module 1202 is used to render the lighting effect in the target scene based on the second lighting range.

[0111] Optionally, the determining module 1201 is specifically configured to:

[0112] Obtaining lighting parameters of the virtual light source;

[0113] According to the illumination parameters of the virtual light source, the first illumination range of the virtual light source and the light source material parameters are determined; wherein the illumination parameters include: light source type, light source position, illumination radius and illumination intensity.

[0114] The determining module 1201 is specifically used for:

[0115] Determine the region information of the scene range of the target scene, the region information including at least one of the following: region length, region width, region height, region center position and region rotation information;

[0116] The spatial volume function is determined according to the area information of the scene range.

[0117] The determining module 1201 is specifically used for:

[0118] Create an initial bounding box;

[0119] According to the region information, the initial bounding box is adjusted to obtain a target bounding box;

[0120] The spatial volume function is determined according to parameter information of the target bounding box.

[0121] Optionally, the area information further includes: occluding surface information and non-occluding surface information;

[0122] The determining module 1201 is specifically used for:

[0123] According to the region length, the region width, the region height, the region center position and the region rotation information, the initial bounding box is adjusted to obtain an intermediate bounding box;

[0124] The intermediate bounding box is expanded according to the non-occluded surface information to obtain the target bounding box.

[0125] The determining module 1201 is specifically used for:

[0126] According to the illumination parameters of the virtual light source, the illumination intensity of the virtual light source at each position in different directions is determined, and the illumination intensity at each position in different directions is used as the light source material parameter.

[0127] The determining module 1201 is specifically used for:

[0128] A product result of the spatial volume function and the light source material parameter is determined, and a second illumination range corresponding to the virtual light source in the target scene is determined according to the product result.

[0129] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0130] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0131] See also Fig.13 The embodiment of the present application further provides an electronic device, the electronic device comprising: a processor 1301, a storage medium 1302 and a bus 1303, the storage medium 1302 stores machine-readable instructions executable by the processor 1301, when the electronic device is running, the processor 1301 communicates with the storage medium 1302 through the bus 1303, and the processor 1301 executes the machine-readable instructions to perform the following steps:

[0132] In response to a target event for a target scene, determining a virtual light source pre-set in the target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene;

[0133] In response to the shadow projection of the virtual light source being in an off state, determining a first illumination range and light source material parameters preconfigured for the virtual light source;

[0134] In response to the first illumination range being larger than a scene range of the target scene, determining a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume region determined from the target scene and not larger than the scene range;

[0135] A second illumination range corresponding to the virtual light source in the target scene is determined according to the spatial volume function and the light source material parameter, and the illumination effect in the target scene is rendered based on the second illumination range.

[0136] Optionally, the processor 1301, when executing the determining of the first illumination range and light source material parameter preconfigured for the virtual light source, is specifically configured to:

[0137] Obtaining lighting parameters of the virtual light source;

[0138] According to the illumination parameters of the virtual light source, the first illumination range of the virtual light source and the light source material parameters are determined; wherein the illumination parameters include: light source type, light source position, illumination radius and illumination intensity.

[0139] Optionally, the processor 1301, when executing the determining a spatial volume function based on the scene range, is specifically configured to:

[0140] Determine the region information of the scene range of the target scene, the region information including at least one of the following: region length, region width, region height, region center position and region rotation information;

[0141] The spatial volume function is determined according to the area information of the scene range.

[0142] Optionally, the processor 1301, when executing the determining the spatial volume function according to the area information of the scene range, is specifically configured to:

[0143] Create an initial bounding box;

[0144] According to the region information, the initial bounding box is adjusted to obtain a target bounding box;

[0145] The spatial volume function is determined according to parameter information of the target bounding box.

[0146] Optionally, the area information further includes: occluding surface information and non-occluding surface information;

[0147] The processor 1301 adjusts the initial bounding box according to the region information to obtain a target bounding box, specifically for:

[0148] According to the region length, the region width, the region height, the region center position and the region rotation information, the initial bounding box is adjusted to obtain an intermediate bounding box;

[0149] The intermediate bounding box is expanded according to the non-occluded surface information to obtain the target bounding box.

[0150] Optionally, the processor 1301, when executing the step of determining the light source material parameter according to the illumination parameter of the virtual light source, is specifically configured to:

[0151] According to the illumination parameters of the virtual light source, the illumination intensity of the virtual light source at each position in different directions is determined, and the illumination intensity at each position in different directions is used as the light source material parameter.

[0152] Optionally, the processor 1301, when executing the step of determining the second illumination range corresponding to the virtual light source in the target scene according to the spatial volume function and the light source material parameter, is specifically configured to:

[0153] A product result of the spatial volume function and the light source material parameter is determined, and a second illumination range corresponding to the virtual light source in the target scene is determined according to the product result.

[0154] Optionally, the present invention also provides a program product, such as a computer-readable storage medium, comprising a program, which is used to execute the above method embodiment when executed by a processor.

[0155] In response to a target event for a target scene, determining a virtual light source pre-set in the target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene;

[0156] In response to the shadow projection of the virtual light source being in an off state, determining a first illumination range and light source material parameters preconfigured for the virtual light source;

[0157] In response to the first illumination range being larger than a scene range of the target scene, determining a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume region determined from the target scene and not larger than the scene range;

[0158] A second illumination range corresponding to the virtual light source in the target scene is determined according to the spatial volume function and the light source material parameter, and the illumination effect in the target scene is rendered based on the second illumination range.

[0159] Optionally, the processor, when executing the determining of the first illumination range and light source material parameter preconfigured for the virtual light source, is specifically configured to:

[0160] Obtaining lighting parameters of the virtual light source;

[0161] According to the illumination parameters of the virtual light source, the first illumination range of the virtual light source and the light source material parameters are determined; wherein the illumination parameters include: light source type, light source position, illumination radius and illumination intensity.

[0162] Optionally, the processor, when executing the step of determining a spatial volume function based on the scene range, is specifically configured to:

[0163] Determine the region information of the scene range of the target scene, the region information including at least one of the following: region length, region width, region height, region center position and region rotation information;

[0164] The spatial volume function is determined according to the area information of the scene range.

[0165] Optionally, the processor, when executing the step of determining the spatial volume function according to the area information of the scene range, is specifically configured to:

[0166] Create an initial bounding box;

[0167] According to the region information, the initial bounding box is adjusted to obtain a target bounding box;

[0168] The spatial volume function is determined according to parameter information of the target bounding box.

[0169] Optionally, the area information further includes: occluding surface information and non-occluding surface information;

[0170] The processor adjusts the initial bounding box according to the region information to obtain a target bounding box, specifically for:

[0171] According to the region length, the region width, the region height, the region center position and the region rotation information, the initial bounding box is adjusted to obtain an intermediate bounding box;

[0172] The intermediate bounding box is expanded according to the non-occluded surface information to obtain the target bounding box.

[0173] Optionally, the processor, when executing the step of determining the light source material parameter according to the illumination parameter of the virtual light source, is specifically configured to:

[0174] According to the illumination parameters of the virtual light source, the illumination intensity of the virtual light source at each position in different directions is determined, and the illumination intensity at each position in different directions is used as the light source material parameter.

[0175] Optionally, when the processor performs the step of determining, according to the spatial volume function and the light source material parameter, a second illumination range corresponding to the virtual light source in the target scene, specifically:

[0176] A product result of the spatial volume function and the light source material parameter is determined, and a second illumination range corresponding to the virtual light source in the target scene is determined according to the product result.

[0177] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0178] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0180] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

Claims

1. A method for lighting processing in a game, characterized in that: The method comprises: In response to a target event for a target scene, determining a virtual light source pre-set in the target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene; In response to the shadow projection of the virtual light source being in an off state, determining a first illumination range and light source material parameters preconfigured for the virtual light source; In response to the first illumination range being larger than a scene range of the target scene, determining a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume region determined from the target scene and not larger than the scene range; A second illumination range corresponding to the virtual light source in the target scene is determined according to the spatial volume function and the light source material parameter, and the illumination effect in the target scene is rendered based on the second illumination range.

2. The method according to claim 1, characterized in that: The determining of a first illumination range and a light source material parameter preconfigured for the virtual light source includes: Obtaining lighting parameters of the virtual light source; According to the illumination parameters of the virtual light source, the first illumination range of the virtual light source and the light source material parameters are determined; wherein the illumination parameters include: light source type, light source position, illumination radius and illumination intensity.

3. The method according to claim 1, characterized in that The determining a spatial volume function based on the scene range includes: Determine the region information of the scene range of the target scene, the region information including at least one of the following: region length, region width, region height, region center position and region rotation information; The spatial volume function is determined according to the area information of the scene range.

4. The method according to claim 3, characterized in that The determining the spatial volume function according to the area information of the scene range includes: Create an initial bounding box; According to the region information, the initial bounding box is adjusted to obtain a target bounding box; The spatial volume function is determined according to parameter information of the target bounding box.

5. The method according to claim 4, characterized in that The area information also includes: occluded surface information and non-occluded surface information; The step of adjusting the initial bounding box according to the region information to obtain a target bounding box includes: According to the region length, the region width, the region height, the region center position and the region rotation information, the initial bounding box is adjusted to obtain an intermediate bounding box; The intermediate bounding box is expanded according to the non-occluded surface information to obtain the target bounding box.

6. The method according to claim 3, characterized in that The step of determining the light source material parameter according to the illumination parameter of the virtual light source includes: According to the illumination parameters of the virtual light source, the illumination intensity of the virtual light source at each position in different directions is determined, and the illumination intensity at each position in different directions is used as the light source material parameter.

7. The method according to any one of claims 1 to 6, characterized in that: The step of determining, according to the spatial volume function and the light source material parameter, a second illumination range corresponding to the virtual light source in the target scene comprises: A product result of the spatial volume function and the light source material parameter is determined, and a second illumination range corresponding to the virtual light source in the target scene is determined according to the product result.

8. A lighting processing device in a game, characterized in that: The device comprises: A determination module, configured to determine a virtual light source pre-set in a target scene in response to a target event for a target scene, wherein the target event is used to trigger turning on the virtual light source in the target scene; in response to shadow projection of the virtual light source being in an off state, determine a first illumination range and light source material parameters pre-configured for the virtual light source; in response to the first illumination range being larger than a scene range of the target scene, determine a spatial volume function based on the scene range, wherein the spatial volume function is used to refer to a spatial volume area determined from the target scene that is not larger than the scene range; and determine a second illumination range corresponding to the virtual light source in the target scene according to the spatial volume function and the light source material parameters; A rendering module is used to render the lighting effect in the target scene based on the second lighting range.

9. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of any method as described in claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.