Method and device for generating virtual natural phenomena in game scenes

By collecting and comparing depth maps and vertex data, the generation area of ​​virtual natural phenomena can be accurately controlled, solving the problem of large storage and computing resources in game scenes, achieving efficient and realistic generation of virtual natural phenomena, and improving the gaming experience.

CN114307139BActive Publication Date: 2025-09-23NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111639811.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2025-09-23
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

Existing technologies require a large number of textures when generating virtual natural phenomena in game scenes, resulting in large storage space and computational complexity. In addition, existing methods cannot accurately control the generation area of ​​natural phenomena, affecting the realism and efficiency of the game scenes.

Method used

By collecting the depth map and vertex data of the target element objects in the game scene, using the depth information of different acquisition angles to determine the coverage range of the virtual natural phenomenon, and using the comparison method of the depth map and depth data, the generation area of ​​the virtual natural phenomenon is accurately controlled, and dynamic refresh is achieved through fuzzy processing and collision box technology.

Benefits of technology

It reduces storage resource usage and computing power, improves the generation efficiency and realism of virtual natural phenomena in game scenes, and can update virtual natural phenomena in real time according to the position changes of player characters, thereby enhancing the player's experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114307139B_ABST
    Figure CN114307139B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for generating virtual natural phenomena in a game scene. The generation method includes: collecting a depth map of a target element object in the game scene from a first acquisition angle, using the perspective from which the virtual natural phenomenon occurs; determining the depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene collected from a second acquisition angle using the player character's perspective; determining the virtual natural phenomenon masking range of the virtual natural phenomenon based on the target element object based on the depth map and the depth data; and generating a game scene including the virtual natural phenomenon based on the virtual natural phenomenon masking range. This allows precise control of the virtual natural phenomena of the target element object in the game scene without generating a texture for each target element object, thereby reducing the amount of texture usage and computation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and more particularly to a method and device for generating virtual natural phenomena in a game scene. The present application also relates to a computer storage medium and an electronic device. Background Art

[0002] To enhance the realism of game scenes and improve the player's visual experience, existing game applications can use weather systems to simulate various natural phenomena in game scenes, such as rain, snow, wind, and the changing seasons, allowing players to experience the same natural phenomena in the game as they would in real life. Summary of the Invention

[0003] The present application provides a method for generating virtual natural phenomena in a game scene to solve the problem in the prior art that a large number of textures are needed in the process of generating virtual natural phenomena in a game scene, resulting in large storage space occupation and large amount of calculation.

[0004] This application provides a method for generating virtual natural phenomena in a game scene, comprising:

[0005] Using the perspective of the virtual natural phenomenon as the first acquisition angle, the depth map of the target element object in the game scene is collected;

[0006] Determining depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle;

[0007] determining, according to the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object;

[0008] A game scene including the virtual natural phenomenon is generated according to the covering range of the virtual natural phenomenon.

[0009] In some embodiments, determining the depth data of the target element object at the first acquisition angle based on the vertex data of the target element object in the game scene acquired from the player character's perspective as the second acquisition angle includes:

[0010] Acquire vertex data of the target element object in the game scene from the perspective of the player character;

[0011] Converting the vertex data from the world space of the game scene to the lighting space of the game scene; wherein the light source illumination angle of the lighting space is the same as the first acquisition angle;

[0012] determining a projection matrix for the vertex data in the lighting space;

[0013] The depth data is determined according to the projection matrix.

[0014] In some embodiments, determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes:

[0015] The depth information of the depth map is compared with the depth information of the depth data to determine a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object.

[0016] In some embodiments, comparing the depth information of the depth map with the depth information of the depth data to determine a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes:

[0017] Comparing the depth value of the depth map with the value of the depth data, and obtaining a target value where the depth value of the depth map is smaller than the value of the depth data;

[0018] The coverage range of the virtual natural phenomenon is determined according to the target value.

[0019] In some embodiments, the process of capturing a depth map of a target element object in a game scene from a perspective at which a virtual natural phenomenon occurs as a first capture angle includes:

[0020] Taking the perspective of the virtual natural phenomenon as the first acquisition angle, at least two depth maps of the target element object in the game scene are collected according to the set acquisition range; wherein, the at least two depth maps include: a first acquisition range depth map and a second acquisition range depth map; the acquisition range includes at least the first acquisition range and the second acquisition range.

[0021] In some embodiments, determining the depth data of the target element object at the first acquisition angle based on the vertex data of the target element object in the game scene acquired from the player character's perspective as the second acquisition angle includes:

[0022] Based on the player character's perspective as a second acquisition angle and based on the acquisition range, at least two sets of vertex data of the target element object in the game scene are collected; wherein the at least two sets of vertex data include: vertex data in the first acquisition range and vertex data in the second acquisition range;

[0023] Converting the vertex data of the first acquisition range and the vertex data of the second acquisition range from the world space of the game scene to the illumination space of the game scene; wherein the light source illumination angle of the illumination space is the same as the first acquisition angle;

[0024] Acquire, in the illumination space, a first projection matrix corresponding to the vertex data of the first acquisition range and a second projection matrix corresponding to the vertex data of the second acquisition range;

[0025] determining the first acquisition range depth data according to the first projection matrix;

[0026] Determine the second acquisition range depth data according to the second projection matrix.

[0027] In some embodiments, determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes:

[0028] determining, according to the first acquisition range depth map and the first acquisition range depth data, a first virtual natural phenomenon covering range within the first acquisition range, the virtual natural phenomenon being based on the target element object;

[0029] A second virtual natural phenomenon covering range within the second acquisition range of the virtual natural phenomenon based on the target element object is determined according to the second acquisition range depth map and the second acquisition range depth data.

[0030] In some embodiments, the acquisition range is automatically adjusted according to the activity area of ​​the player character.

[0031] In some embodiments, further comprising:

[0032] Blurring is performed on a covered edge area of ​​the virtual natural phenomenon covered range according to the depth map and the square of the depth map, and the depth data and the square of the depth data.

[0033] In some embodiments, further comprising:

[0034] In the game scene, setting a collision box for the player character;

[0035] Determining a positional relationship between the player character and the collision box;

[0036] When the player character is outside the collision box area, the depth map and the depth data are refreshed.

[0037] In some embodiments, determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes:

[0038] The virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object is re-determined according to the refreshed depth map and the refreshed depth data.

[0039] In some embodiments, the virtual natural phenomenon is rain and / or snow natural phenomenon.

[0040] In some embodiments, further comprising:

[0041] According to the adjustment of the set control parameters, the amount of rain and / or snow in the generated game scene including the natural phenomenon of rain and / or snow is controlled.

[0042] The present application also provides a device for generating virtual natural phenomena in a game scene, comprising:

[0043] A collection unit, configured to collect a depth map of a target element object in a game scene from a perspective of a virtual natural phenomenon as a first collection angle;

[0044] A first determining unit is configured to determine depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle;

[0045] a second determining unit, configured to determine, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object;

[0046] A generating unit is used to generate a game scene including the virtual natural phenomenon according to the covering range of the virtual natural phenomenon.

[0047] The present application also provides a computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform;

[0048] When the program is read and executed by the processor, it executes the method for generating virtual natural phenomena in the game scene as described above.

[0049] The present application also provides an electronic device, comprising:

[0050] processor;

[0051] The memory is used to store a program for processing data generated by the network platform. When the program is read and executed by the processor, it executes the method for generating virtual natural phenomena in the game scene as described above.

[0052] Compared with the prior art, this application has the following advantages:

[0053] The present application provides a method for generating virtual natural phenomena in a game scene. The method can determine the virtual natural phenomenon covering range covering the virtual natural phenomenon on the target element object through a depth map captured at a first capture angle using the perspective of the virtual natural phenomenon as the occurrence angle, and the depth data determined based on the vertex data of the target element object in the game scene captured at a second capture angle using the player character's perspective, and generate the virtual natural phenomenon in the area of ​​the virtual natural phenomenon covering range. This can distinguish which areas of the target element object generate the virtual natural phenomenon and which areas do not, thereby accurately controlling the virtual natural phenomena of the target element object in the game scene on the one hand; and on the other hand, there is no need to generate a texture for each target element object in the generation of the virtual natural phenomenon, thereby reducing the usage of textures, the occupation of storage resources, and the amount of calculation required for generating the virtual natural phenomenon.

[0054] The present application provides a method for generating virtual natural phenomena in a game scene, in which the depth map and depth data can be for a long-distance scene and a close-up scene, respectively. Therefore, when generating virtual natural phenomena for target element objects in a long-distance scene, the generation accuracy can be controlled to be lower, and when generating virtual natural phenomena for target element objects in a close-up scene, the generation accuracy can be controlled to be higher; thereby achieving a balance between generation performance and generation effect in the process of generating virtual natural phenomena in the game scene.

[0055] The present application provides a method for generating virtual natural phenomena in a game scene. The method can obtain the position change information of the player character in the game scene in real time by setting a collision box for the player character, and then update the depth map and depth data according to the position change information, so as to determine the virtual natural phenomenon covering range of the target element object in real time, and dynamically refresh the generated virtual natural phenomenon to ensure that the visualization scene of the virtual natural phenomenon of the player character in the game changes according to the change of its perspective, thereby improving the realism and player experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 This is a flow chart of an embodiment of a method for generating virtual natural phenomena in a game scene provided by the present application;

[0057] Figure 2 This is a schematic diagram of a depth map captured by a target element object at a first capture angle in an embodiment of a method for generating a virtual natural phenomenon in a game scene provided by the present application;

[0058] Figure 3This is a schematic diagram of collecting vertex data of a target element object at a second collection angle in an embodiment of a method for generating a virtual natural phenomenon in a game scene provided by the present application;

[0059] Figure 4 This is a schematic diagram of converting vertex data into depth data at a first acquisition angle in an embodiment of a method for generating a virtual natural phenomenon in a game scene provided by the present application;

[0060] Figure 5 This is a schematic structural diagram of an embodiment of a device for generating virtual natural phenomena in a game scene provided by the present application;

[0061] Figure 6 It is a structural diagram of an electronic device embodiment provided by this application. DETAILED DESCRIPTION

[0062] The following description sets forth many specific details to facilitate a thorough understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present application. Therefore, the present application is not limited to the specific implementations disclosed below.

[0063] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. Descriptive terms such as "a," "a," "a first," and "a second," etc., used in this application and the appended claims, are not intended to limit quantity or sequence, but are used to distinguish information of the same type from one another.

[0064] As can be seen from the above description of the background technology, the inventive concept of this application is based on how to achieve the effect of not displaying the weather status indoors but displaying the weather status outdoors when the weather status needs to be reflected in the game scene, that is, how to achieve the weather mask effect. In the prior art, at least two methods are generally used to achieve the effect of covering or masking the weather status in the game scene. One is to use the shader to distinguish the area with the normal facing upward as the part that needs to be masked to reflect the weather effect; the other is to add a separate mask map to the area in the game scene that needs to have the weather effect to reflect the weather effect.

[0065] The defects of the above two prior arts are:

[0066] The first method is to use the upward normal distinction in the shader to achieve the overlay weather effect. It will form weather under all the areas in the game scene that need to be masked by the weather effect. Weather effects exist both indoors and outdoors, because indoor objects also have upward normal areas. Therefore, a layer of weather effects will still be rendered indoors, which is obviously inconsistent with the actual weather effect.

[0067] The second method is to use a separate mask map to divide and control the area in the game scene that needs to be covered by the weather effect. Although it can accurately control the weather effect of each object, a unique weather mask map needs to be stored for each object. This has a great impact on the game package, that is, it takes up a lot of storage space. At the same time, each weather mask requires a lot of computing resources and material resources when rendering.

[0068] Based on the above defects in the prior art, this application provides a method for generating virtual natural phenomena in a game scene, such as Figure 1 As shown, Figure 1 This is a flowchart of an embodiment of a method for generating a virtual natural phenomenon in a game scene provided by the present application, the generating method comprising:

[0069] Step S101: capturing a depth map of a target element object in a game scene from a perspective where a virtual natural phenomenon occurs as a first capturing angle;

[0070] First, the technical terms in step S101 are explained:

[0071] Virtual natural phenomena may include: virtual weather natural phenomena set in the game scene, such as rainy and snowy weather and other natural phenomena; that is, weather phenomena occurring in the real life environment can be produced in the game scene through computer technology to create a virtual natural phenomenon, thereby enhancing the realism of the game scene and the player's experience.

[0072] The perspective from which the virtual natural phenomenon occurs can be understood as the direction from which rain, snow, and the like occur, such as the angle from which rain and snow fall from the sky.

[0073] The target element object can be any object element in the game scene, which can be multiple or a single one. In the world space of the game scene, as the direction and position of the player character changes, the direction angle of the target element object observed by the player's perspective can also change.

[0074] In the embodiment, the depth map can be understood as a grayscale image. The grayscale information of the pixels in the grayscale image can be used to represent the distance of the target element object from the camera. The closer the distance to the camera, the darker the corresponding area on the depth map (the depth value is close to 0), and the farther away, the whiter (the depth value is close to 1).

[0075] In this embodiment, the depth map is collected by a collection tool, such as a camera, which is set in the viewing angle direction of the virtual natural phenomenon.

[0076] The purpose of step S101 is to collect a depth map, and there are requirements for the angle at which the depth map is collected.

[0077] like Figure 2 As shown, the virtual natural phenomenon of snow in this embodiment is taken as an example. The specific implementation process of step S101 can be to set a camera at the direction angle of snow in the game scene and collect a depth map through the camera.

[0078] It is understandable that when collecting the depth map, the collection may be performed according to a set collection range. Therefore, step S101 may include:

[0079] Step S101-1: Taking the perspective of the virtual natural phenomenon as the first acquisition angle, according to the set acquisition range, collect at least two depth maps of the target element object in the game scene; wherein, the at least two depth maps include: a first acquisition range depth map and a second acquisition range depth map; the acquisition range includes at least the first acquisition range and the second acquisition range.

[0080] In an embodiment, the acquisition range can be set according to the acquisition accuracy, for example: long-distance acquisition and close-range acquisition. The at least two depth maps may include: a long-distance depth map of the target element object in a long-distance scene (low-precision scene) in the game scene and a close-range depth map of the target element object in a close-range scene (high-precision scene), and the long-distance depth map and the close-range depth map are used as the depth map. The first acquisition range can be a close-range acquisition range, and the second acquisition range can be a long-distance acquisition range; or the first acquisition range can be a long-distance acquisition range, and the second acquisition range can be a close-range acquisition range.

[0081] In this embodiment, the first collection range and the second collection range can be automatically generated according to the activity area of ​​the player character; or, the collection range can be automatically adjusted according to the activity area of ​​the player character.

[0082] Step S102: Determine depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle.

[0083] The purpose of step S102 is to determine the depth data of the target element object in the player character's viewing direction at the first acquisition angle.

[0084] The specific implementation process of step S102 may include:

[0085] Step S102-11: acquiring vertex data of the target element object in the game scene from the perspective of the player character;

[0086] Step S102-12: converting the vertex data from the world space of the game scene to the lighting space of the game scene; wherein the light source illumination angle of the lighting space is the same as the first acquisition angle;

[0087] Step S102-13: Determine the projection matrix of the vertex data in the illumination space;

[0088] Step S102-14: Determine the depth data according to the projection matrix.

[0089] like Figure 3 As shown, step S102-11 can specifically obtain the vertex data of the target element object in the game scene from the player character's perspective. The vertex data can be understood as the vertex coordinates of the target element object in the world space of the game scene. Specifically, the target element object can be an element object pre-set in the model space, that is, the target element object can be regarded as a target model. Typically, in a game scene, each model (target element object) has its own independent coordinate space. When a model is moved, rotated, or scaled relative to the world center of the game level, the model undergoes a change in world space. This can be understood as, for example, the game level is the entire office, and the world center of the game level is a point on the desktop, such as the upper left corner of the desktop. A normal model, such as a cup, is placed in the upper left corner of the desktop when it is brought into the game scene. If the cup is placed on a chair, it needs to be moved and rotated, so the cup undergoes a spatial transformation relative to the original upper left corner of the desktop (this is only an example and is not intended to limit the game scene). The origin and coordinates of the model space are determined by the artist in the modeling software, but when the model is placed in the game scene, there is a change relative to the center of the game scene. That is to say, the model is transformed from the model space to the world space. The vertex data obtained is actually the coordinate data of the vertex position of the model in the world space.

[0090] like Figure 4 As shown, the specific implementation process of step S102-2 can be to convert the vertex data from the world space to the lighting space through matrix conversion. Specifically, the vertex coordinates are converted from the world space to the observation space; and then the vertex coordinates are converted from the observation space to the projection space. Specifically, the projection matrix can be constructed based on parameters such as the size of the camera shooting plane and the near and far clipping planes of the camera frustum. The projection matrix is ​​used to convert the vertex data from the lighting space to the projection space, thereby converting the vertex data obtained from the player character's perspective into the projection space to obtain depth data.

[0091] Based on the fact that the depth map involved in the collection in step S101-1 includes at least two depth maps, namely, the first collection range depth map and the second collection range first depth map, the collection of vertex data in step S102-11 may collect vertex data according to the first collection range and the second collection range, respectively, that is, vertex data for a close-range scene and vertex data for a long-range scene may be collected. The specific implementation process of step S102-11 may include:

[0092] Steps S102-111: Based on the player character's perspective as a second acquisition angle and based on the acquisition range, at least two sets of vertex data of the target element object in the game scene are acquired; wherein the at least two sets of vertex data include: vertex data of the first acquisition range and vertex data of the second acquisition range;

[0093] The specific implementation process of step S102-12 may include:

[0094] Step S102-121: Converting the vertex data of the first acquisition range and the vertex data of the second acquisition range from the world space of the game scene to the lighting space of the game scene; wherein the light source illumination angle of the lighting space is the same as the first acquisition angle;

[0095] The specific implementation process of step S102-13 may include:

[0096] Step S102-131: acquiring, in the illumination space, a first projection matrix corresponding to the vertex data in the first acquisition range and a second projection matrix corresponding to the vertex data in the second acquisition range;

[0097] The specific implementation process of step S102-14 may include:

[0098] Step S102-141: Determine the first acquisition range depth data according to the first projection matrix; and determine the second acquisition range depth data according to the second projection matrix.

[0099] The first acquisition range depth map and the second acquisition range depth map, as well as the first acquisition range depth data and the second acquisition range depth data involved in the above steps, can be determined based on the distance of the target element object in the game scene. For example, a high-precision acquisition range can be used for target element objects in a close-range game scene, a low-precision acquisition range can be used for target element objects in a medium- and long-range game scene, and element objects in game scenes with farther acquisition ranges do not participate in the generation of virtual natural phenomena. By setting at least two acquisition ranges, the coverage range of the virtual natural phenomenon can be determined by mixing two different depth maps for long and short distances, which can save computing and storage.

[0100] In this embodiment, the target element object can be at least one or a combination of buildings, plants, vehicles, and environmental elements. In other words, the target element object can be any object in the game scene that can have a relationship with the virtual natural phenomenon. This relationship can include covering or contacting the virtual natural phenomenon, such as a game scene with snow-covered houses or a scene with water on the ground. In this embodiment, the virtual natural phenomenon is primarily described using snow as an example.

[0101] Step S103: determining a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object according to the depth map and the depth data.

[0102] The specific implementation process of step S103 may include:

[0103] Step S103 - 1 : comparing the depth information of the depth map with the depth information of the depth data to determine a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object.

[0104] That is, the distance values ​​are compared, specifically including:

[0105] Step S103-11: Compare the depth value of the depth map with the numerical value of the depth data, and obtain a target value where the depth value of the depth map is less than the numerical value of the depth data. In this embodiment, the depth value of the depth map can be the distance value from the camera to each point of the target element object; the numerical value of the depth data can be the distance value from the light source camera to each vertex of the target element object. Compare the two distance values. If the distance value of the depth map is less than the numerical value of the depth data, it means that the comparison point in the depth data is blocked by the depth map, and the surface of the target element object should be set to black, that is, 0. Otherwise, the surface of the target element object should be set to white, that is, 1, indicating that the comparison point in the depth data is not blocked by the depth map. The target value can be obtained through comparison. In this embodiment, the target value is the depth information of the unblocked element, that is, the target value is 1.

[0106] Step S103-12: Determine the coverage range of the virtual natural phenomenon according to the target value.

[0107] Based on the first acquisition range depth map and the second acquisition range depth map, the first acquisition range depth data and the second acquisition range depth data in step S101, the specific implementation process of step S103-1 may include:

[0108] Step S103-21: Compare the depth value of the first acquisition range depth map with the value of the first acquisition range depth data, and obtain a first target value where the depth value of the first acquisition range depth map is smaller than the value of the first acquisition range depth data;

[0109] Step S103-22: comparing the depth value of the second acquisition range depth map with the value of the second acquisition range depth data, and obtaining a second target value where the depth value of the second acquisition range depth map is smaller than the value of the second acquisition range depth data;

[0110] Step S103-23: determining a first virtual natural phenomenon covering range according to the first target value;

[0111] Step S103-24: Determine a second virtual natural phenomenon covering range according to the second target value.

[0112] In this embodiment, two layers of depth maps with different precision and two layers of depth data with different precision are used, and the first virtual natural phenomenon covering range and the second virtual natural phenomenon covering range are determined according to the depth data of the depth map with the same precision and the depth data of the depth data, so that the corresponding virtual natural phenomenon covering range can be determined for different precision ranges in the game scene, that is, the high-precision virtual natural phenomenon covering range and the low-precision virtual natural phenomenon covering range.

[0113] It should be noted that the depth data of the second acquisition range depth map can be the depth data obtained by removing the first acquisition range depth map; the depth data of the second acquisition range depth data can be the depth data obtained by removing the first acquisition range depth data. Alternatively, when acquiring depth maps, the first acquisition range is a close-range range, and the second acquisition range is a long-range range. The target elements captured by the two acquisition ranges can be different. For example, the first acquisition range captures the house and its surroundings, while the second acquisition range captures the area outside the house, such as trees and other elements. Of course, areas with low visibility from the player's perspective can be omitted, meaning that there is no need to generate virtual natural phenomena.

[0114] Step S104: generating a game scene including the virtual natural phenomenon according to the covering range of the virtual natural phenomenon.

[0115] The step S104 can render the virtual natural phenomenon on the target element object according to the virtual natural phenomenon covering range. For example, when the target element object is a house, the virtual natural phenomenon covering range determined for the house is used to render the snow effect or the effect of rain colliding with the house. Usually, the snow effect is rendered on the roof. Of course, the thickness of the snow on the house and whether there is snow on the wall of the house can be set according to the direction of the falling snow.

[0116] Based on the two layers of depth maps with different precision and the two layers of depth data with different precision described in the above step S103, the step S104 can render a virtual natural phenomenon on the target element object according to the first virtual natural phenomenon covering range, and render a virtual natural phenomenon on the target element object according to the second virtual natural phenomenon covering range, that is, render two layers of virtual natural phenomenon covering ranges with different precision.

[0117] To improve the generation or rendering of a more realistic snow effect within the determined snow coverage range (coverage range of the virtual natural phenomenon) of the target element object, this embodiment can also process the edges of the snow-covered area to avoid the appearance of jagged hard lines that would cause the visual effect of snow to be unrealistic. Therefore, it can also include:

[0118] Blurring is performed on a covered edge area of ​​the virtual natural phenomenon covered range according to the depth map and the square of the depth map, and the depth data and the square of the depth data.

[0119] In this embodiment, the blurred edge area of ​​the virtual natural phenomenon covered range can be blurred by using the Chebyshev inequality to calculate the blurred edge area of ​​the virtual natural phenomenon covered range, and the blurred edge area is processed by filtering to achieve a softening effect on the edge. Specifically, the first blurred result can be determined by blurring the depth map and the square of the depth map; the second blurred result is determined based on the square of the blurred depth map, the first blurred result is subtracted from the second blurred result to obtain edge information, and the edge information is softened according to the Chebyshev inequality. The Chebyshev inequality can be generally understood as the probability that the depth value is greater than the distance from the current coordinate to the light source, that is, the probability of not being in the shadow, so according to the formula, it can be concluded that the closer to the outside of the area edge, the closer the value is to 1.

[0120] In order to achieve the real-time dynamic generation of virtual natural phenomena in the game scene, it can also include:

[0121] In the game scene, setting a collision box for the player character;

[0122] Determining a positional relationship between the player character and the collision box;

[0123] When the player character is outside the collision box area (ie, the alignment state of the collision box and the player character position is determined), the depth map and the depth data are refreshed.

[0124] The specific implementation of step S103 may be: re-determining the virtual natural phenomenon covering range based on the target element object of the virtual natural phenomenon according to the refreshed depth map and the refreshed depth data.

[0125] The step S104 may regenerate the game scene including the virtual natural phenomenon according to the re-determined virtual natural phenomenon covering range.

[0126] To improve the realism of virtual natural phenomena in the game scene, it can also include:

[0127] According to the adjustment of the set control parameters, the amount of rain and / or snow generated by natural phenomena including rain and / or snow in the game scene is controlled. The specific control method can be to increase the target value of the virtual natural phenomenon covering range to achieve an increase in the amount of rain and / or snow, and conversely, to reduce the target value of the virtual natural phenomenon covering range to achieve a decrease in the amount of rain and / or snow. For example: when reducing the amount of snow, the target value 1 can be reduced. When it is reduced to 0, it can be a case where the amount of snow is 0. In this embodiment, the virtual natural phenomenon covering range determined according to the target value is the case where the amount of rain and / or snow is the largest. Therefore, the control of the amount of rain and / or snow can be achieved by reducing the target value.

[0128] The above is a description of an embodiment of a method for generating virtual natural phenomena in a game scene provided by this application. Through the above generation method embodiment, it is only necessary to dynamically obtain the depth map and the depth data converted from the vertex data in real time according to the changes in the position of the player character, and determine the real-time changing virtual natural phenomenon coverage range based on the comparison of the depth values ​​of the two depth maps. Then, based on the virtual natural phenomenon coverage range, the target element object needs to generate a natural phenomenon through the material function of the virtual natural phenomenon, such as a snow-covered natural phenomenon. Therefore, it is possible to accurately distinguish between areas covered by virtual natural phenomena and areas not covered by virtual natural phenomena, and there is no need to produce natural phenomenon maps for each element in the game scene, thereby saving a lot of storage space and computing costs.

[0129] The above is a detailed description of an embodiment of a method for generating virtual natural phenomena in a game scene provided by this application. Corresponding to the embodiment of a method for generating virtual natural phenomena in a game scene provided above, this application also discloses an embodiment of a device for generating virtual natural phenomena in a game scene. Please refer to Figure 5Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. The device embodiment described below is only illustrative.

[0130] like Figure 5 As shown, Figure 5 : This is a schematic diagram of a structure of an embodiment of a device for generating virtual natural phenomena in a game scene provided by the present application, the device embodiment comprising:

[0131] The acquisition unit 501 is configured to acquire a depth map of a target element object in a game scene from a perspective at which a virtual natural phenomenon occurs as a first acquisition angle;

[0132] A first determining unit 502 is configured to determine depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle;

[0133] A second determining unit 503 is configured to determine, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object;

[0134] The generating unit 504 is configured to generate a game scene including the virtual natural phenomenon according to the covering range of the virtual natural phenomenon.

[0135] The acquisition unit 501 can be specifically used to acquire at least two depth maps of the target element object in the game scene based on the set acquisition range, taking the perspective of the virtual natural phenomenon as the first acquisition angle; wherein the at least two depth maps include: a first acquisition range depth map and a second acquisition range depth map; the acquisition range includes at least the first acquisition range and the second acquisition range.

[0136] The first determining unit 502 may include: a vertex obtaining subunit, a conversion subunit, a projection determining subunit, and a depth determining subunit.

[0137] The vertex acquisition subunit is used to collect vertex data of the target element object in the game scene from the perspective of the player character;

[0138] The conversion subunit is configured to convert the vertex data from the world space of the game scene to the illumination space of the game scene; wherein the illumination angle of the light source in the illumination space is the same as the first acquisition angle;

[0139] The projection determination subunit is configured to determine a projection matrix of the vertex data in the illumination space;

[0140] The depth determination subunit is configured to determine the depth data according to the projection matrix.

[0141] When the acquisition unit 501 acquires at least two depth maps of the target element object in the game scene, the vertex acquisition subunit is specifically used to acquire at least two sets of vertex data of the target element object in the game scene based on the player character's perspective as the second acquisition angle and according to the acquisition range; wherein the at least two sets of vertex data include: vertex data of the first acquisition range and vertex data of the second acquisition range.

[0142] The conversion subunit is specifically used to convert the vertex data of the first acquisition range and the vertex data of the second acquisition range from the world space of the game scene to the lighting space of the game scene; wherein the light source illumination angle of the lighting space is the same as the first acquisition angle.

[0143] The projection determination subunit is specifically configured to respectively obtain, in the illumination space, a first projection matrix corresponding to the vertex data of the first acquisition range and a second projection matrix corresponding to the vertex data of the second acquisition range.

[0144] The depth determination subunit is specifically configured to determine the first acquisition range depth data according to the first projection matrix; and determine the second acquisition range depth data according to the second projection matrix.

[0145] The second determination unit 503 is specifically configured to compare the depth information of the depth map with the depth information of the depth data to determine the virtual natural phenomenon covering range based on the virtual natural phenomenon of the target element object. Specifically, it may include: a target acquisition subunit and a range determination subunit;

[0146] The target acquisition subunit is configured to compare the depth value of the depth map with the value of the depth data, and acquire a target value in which the depth value of the depth map is smaller than the value of the depth data;

[0147] The range determination subunit is used to determine the covering range of the virtual natural phenomenon according to the target value.

[0148] When the acquisition unit acquires at least two depth maps and the first determination unit determines two depth data, the second determination unit 503 may specifically include: a first range determination subunit and a second range determination subunit; the first range determination subunit is used to determine the first virtual natural phenomenon coverage range of the virtual natural phenomenon based on the target element object within the first acquisition range according to the first acquisition range depth map and the first acquisition range depth data; the second determination subunit is used to determine the second virtual natural phenomenon coverage range of the virtual natural phenomenon based on the target element object within the second acquisition range according to the second acquisition range depth map and the second acquisition range depth data.

[0149] In this embodiment, the acquisition range can be automatically adjusted according to the activity area of ​​the player character.

[0150] To improve the realism of virtual natural phenomena in the game scene, this embodiment may further include:

[0151] A blur processing unit is configured to blur the covered edge area of ​​the virtual natural phenomenon covered range based on the depth map and the square of the depth map, as well as the depth data and the square of the depth data, so as to make the edge of the target element object covered by snow softer and more realistic.

[0152] In order to enable the real-time dynamic generation of virtual natural phenomena in the game scene according to the position changes of the player character, this embodiment may further include:

[0153] A setting unit, configured to set a collision box for the player character in the game scene;

[0154] a position relationship determining unit, configured to determine a position relationship between the player character and the collision box;

[0155] A refresh unit is configured to refresh the depth map and the depth data when the player character is outside the collision box area.

[0156] Based on the above, the second determining unit 503 is specifically configured to re-determine the virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object according to the refreshed depth map and the refreshed depth data.

[0157] In this embodiment, the virtual natural phenomenon can be a rain and / or snow phenomenon. The virtual natural phenomenon covers a snowy weather effect. In this embodiment, the virtual natural phenomenon in the game scene can be controlled, for example, the amount of rain and / or snow can be controlled. This can be achieved by a control adjustment unit, specifically by adjusting the set control parameters to control the amount of rain and / or snow in the generated game scene including the rain and / or snow phenomenon. Of course, the thickness of the snow covered by the virtual natural phenomenon coverage can be adjusted according to the amount of rain and snow, and / or the depth of the rain covered by the virtual natural phenomenon coverage can also be adjusted.

[0158] The above is a description of an embodiment of a device for generating virtual natural phenomena in a game scene provided by this application. For the specific content of the embodiment of the generation device, please refer to the detailed description of steps S101 to S104 in the above-mentioned generation method embodiment, which will not be repeated here.

[0159] Based on the above content, the present application also provides a computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform;

[0160] When the program is read and executed by the processor, the steps involved in the embodiment of the method for generating virtual natural phenomena in the game scene are executed.

[0161] Based on the above content, the present application also provides an electronic device, such as Figure 6 As shown, Figure 6 : is a schematic structural diagram of an electronic device embodiment provided by the present application, the embodiment comprising:

[0162] Processor 601;

[0163] The memory 602 is used to store a program for processing data generated by the network platform. When the program is read and executed by the processor, it executes the steps involved in the embodiment of the method for generating virtual natural phenomena in the game scene as described above.

[0164] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0165] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0166] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0167] 2. Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0168] Although the present application is disclosed as above with the preferred embodiments, it is not intended to limit the present application. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

Claims

1. A method for generating virtual natural phenomena in a game scene, characterized in that: include: Using the perspective of the virtual natural phenomenon as the first acquisition angle, the depth map of the target element object in the game scene is collected; Determining depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle; Determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object; comprising: comparing a depth value of the depth map with a value of the depth data, obtaining a target value in which the depth value of the depth map is less than the value of the depth data; and determining, based on the target value, the covering range of the virtual natural phenomenon; A game scene including the virtual natural phenomenon is generated according to the covering range of the virtual natural phenomenon.

2. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: The determining, based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle, depth data of the target element object at the first acquisition angle includes: Acquire vertex data of the target element object in the game scene from the perspective of the player character; Converting the vertex data from the world space of the game scene to the lighting space of the game scene; wherein the light source illumination angle of the lighting space is the same as the first acquisition angle; determining a projection matrix for the vertex data in the lighting space; The depth data is determined according to the projection matrix.

3. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: The determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes: The depth information of the depth map is compared with the depth information of the depth data to determine a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object.

4. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: The method of collecting a depth map of a target element object in a game scene from a perspective of a virtual natural phenomenon as a first collection angle includes: Taking the perspective of the virtual natural phenomenon as the first acquisition angle, at least two depth maps of the target element object in the game scene are collected according to the set acquisition range; wherein, the at least two depth maps include: a first acquisition range depth map and a second acquisition range depth map; the acquisition range includes at least the first acquisition range and the second acquisition range.

5. The method for generating virtual natural phenomena in a game scene according to claim 4, characterized in that: The determining, based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle, depth data of the target element object at the first acquisition angle includes: Based on the player character's perspective as a second acquisition angle and based on the acquisition range, at least two sets of vertex data of the target element object in the game scene are collected; wherein the at least two sets of vertex data include: vertex data in the first acquisition range and vertex data in the second acquisition range; Converting the vertex data of the first acquisition range and the vertex data of the second acquisition range from the world space of the game scene to the illumination space of the game scene; wherein the light source illumination angle of the illumination space is the same as the first acquisition angle; Acquire, in the illumination space, a first projection matrix corresponding to the vertex data of the first acquisition range and a second projection matrix corresponding to the vertex data of the second acquisition range; determining the first acquisition range depth data according to the first projection matrix; Determine the second acquisition range depth data according to the second projection matrix.

6. The method for generating virtual natural phenomena in a game scene according to claim 4, characterized in that: The determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes: determining, according to the first acquisition range depth map and the first acquisition range depth data, a first virtual natural phenomenon covering range within the first acquisition range, the virtual natural phenomenon being based on the target element object; A second virtual natural phenomenon covering range within the second acquisition range of the virtual natural phenomenon based on the target element object is determined according to the second acquisition range depth map and the second acquisition range depth data.

7. The method for generating virtual natural phenomena in a game scene according to claim 4, characterized in that: The acquisition range is automatically adjusted according to the activity area of ​​the player character.

8. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: Also includes: Blurring is performed on a covered edge area of ​​the virtual natural phenomenon covered range according to the depth map and the square of the depth map, and the depth data and the square of the depth data.

9. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: Also includes: In the game scene, setting a collision box for the player character; Determining a positional relationship between the player character and the collision box; When the player character is outside the collision box area, the depth map and the depth data are refreshed.

10. The method for generating virtual natural phenomena in a game scene according to claim 9, characterized in that: The determining, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object includes: The virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object is re-determined according to the refreshed depth map and the refreshed depth data.

11. The method for generating virtual natural phenomena in a game scene according to claim 1, characterized in that: The virtual natural phenomenon is rain and / or snow.

12. The method for generating virtual natural phenomena in a game scene according to claim 11, characterized in that: Also includes: According to the adjustment of the set control parameters, the amount of rain and / or snow in the generated game scene including the natural phenomenon of rain and / or snow is controlled.

13. A device for generating virtual natural phenomena in a game scene, characterized in that: include: A collection unit, configured to collect a depth map of a target element object in a game scene from a perspective of a virtual natural phenomenon as a first collection angle; A first determining unit is configured to determine depth data of the target element object at the first acquisition angle based on vertex data of the target element object in the game scene acquired from a player character's perspective as a second acquisition angle; A second determining unit is configured to determine, based on the depth map and the depth data, a virtual natural phenomenon covering range of the virtual natural phenomenon based on the target element object; the unit comprising: comparing a depth value of the depth map with a value of the depth data, obtaining a target value at which the depth value of the depth map is less than the value of the depth data; and determining the covering range of the virtual natural phenomenon based on the target value; A generating unit is used to generate a game scene including the virtual natural phenomenon according to the covering range of the virtual natural phenomenon.

14. A computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform; When the program is read and executed by the processor, it executes the method for generating virtual natural phenomena in the game scene according to any one of claims 1 to 12.

15. An electronic device comprising: processor; A memory for storing a program for processing data generated by a network platform, wherein when the program is read and executed by the processor, the method for generating virtual natural phenomena in a game scene according to any one of claims 1 to 12 is executed.

Citation Information

Patent Citations

  • Method and system for drawing ambient occlusion images based on GPU (graphic processing unit) acceleration

    CN102254340A

  • Occlusion culling and acceleration method for drawing outdoor ground surface in real time based on depth map

    CN104331918A