Method and device for rendering weather objects in games, storage medium, and electronic device

By generating depth maps and shadow maps of weather occluders and combining them with the texture and normal information of snow weather objects, the snow in the game scene is rendered, which solves the problem of complex weather rendering operations in the game scene and achieves efficient snow scene simulation and cost reduction.

CN116351066BActive Publication Date: 2025-09-12BEIJING PERFECT WORLD SOFTWARE TECH DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the existing technology, the weather rendering operation in the game scene is complicated, resulting in low development efficiency, unable to meet the needs of rapid version updates, and affecting the user experience.

Method used

Generate a depth map of the weather occluder in the 3D game scene, generate a shadow map based on the depth map, and use the shadow map, the basic color map of the snow weather object, the normal map, the roughness map and the world normal to render the snow, providing a universal snow rendering solution.

Benefits of technology

It achieves the simulation of more realistic snow scene landscapes without developing snow scenes for different maps, reduces development workload and investment costs, and improves the game's rendering efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116351066B_ABST
    Figure CN116351066B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for rendering weather objects in a game, a storage medium, and an electronic device. The method includes: generating a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the represented location, and the three-dimensional game scene is a game scene rendered on a smart terminal; generating a shadow map of the display interface of the smart terminal based on the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location; and rendering the snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal. The present application solves the technical problem that the operation of weather rendering in the related art is relatively complex.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image rendering, and more specifically, to a method and device for rendering weather objects in a game, a storage medium, and an electronic device. Background Art

[0002] In applications related to electronic games, such as massively multiplayer online role-playing games, it is usually necessary to simulate various parts of the real world in a three-dimensional game scene, such as the environment, buildings, machinery, props, weather, etc. in the game, so that users can have a more realistic experience when playing the game.

[0003] Game scene design often involves building different scene models for various weather environments to improve the expressiveness of the game screen and the simulation realism. For example, snow scenes required for snowfall are built for different maps. This method of targeted development of each map is too inefficient, and due to the rapid iteration of game version updates (such as new maps, map updates, etc.), this method often cannot meet development needs, thereby affecting product quality and reducing user experience.

[0004] Currently, no effective solution has been proposed to the problem that weather rendering requires targeted development of required scenes, which causes complex rendering operations. Summary of the Invention

[0005] The embodiments of the present application provide a method and device for rendering weather objects in a game, a storage medium, and an electronic device, so as to at least solve the technical problem that the operation of weather rendering in the related art is relatively complicated.

[0006] According to one aspect of an embodiment of the present application, a method for rendering weather objects in a game is provided, including: generating a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the represented position, and the three-dimensional game scene is a game scene rendered on a smart terminal; generating a shadow map of a display interface of the smart terminal based on the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented position; and rendering snow in the three-dimensional game scene using the shadow map, a basic color map of the snow weather object, a normal map of the snow weather object, a roughness map of the snow weather object, and a world normal.

[0007] Optionally, a depth map of a weather obstruction in a three-dimensional game scene is generated, comprising: when a trigger condition is met, determining a target area in the three-dimensional game scene based on a game character in the three-dimensional game scene; when the weather obstruction attribute of the static scene model in the target area indicates that the static scene model is a weather obstruction, rendering the depth information of the static scene model to a first depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the first depth map; and / or, when there is a water body model in the target area, rendering the depth information of the water body model to a second depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the second depth map.

[0008] Optionally, before rendering the depth information of the static scene model to the first depth map with a top-down orthogonal camera, the method also includes: when creating the original model object of the static scene model, adding a weather obstruction attribute to the original model object; when the original model object needs to be configured in a three-dimensional game scene, displaying the configuration items of the original model object, wherein the configuration items of the original model object include the weather obstruction attribute; when the configuration of the configuration items of the original model object is completed, configuring the original model object carrying the configured configuration items in the three-dimensional game scene.

[0009] Optionally, before determining the target area in the three-dimensional game scene based on the game character in the three-dimensional game scene, the method also includes: obtaining the moving distance of the game character in the three-dimensional game scene, wherein the moving distance is the distance between the position of the game character in the three-dimensional game scene when the target area was determined in the three-dimensional game scene last time and the current position of the game character in the three-dimensional game scene; when the moving distance reaches a specified threshold, it is determined that the trigger condition is met; when the moving distance does not reach the specified threshold, it is determined that the trigger condition is not met.

[0010] Optionally, a shadow map of the display interface of the smart terminal is generated based on the depth map of the weather obstruction, including: converting the spatial coordinates of the screen pixels of the display interface into world coordinates of the screen pixels, and then converting the world coordinates of the screen pixels into NDC coordinates in the NDC space where the top-down orthogonal camera is located; comparing the coordinate values ​​of the Z axis in the NDC coordinates of the screen pixels of the display interface with the depth values ​​at the same positions in the depth map of the weather obstruction, and marking the screen pixels of the display interface with a first marker or a second marker based on the comparison result, wherein the direction of the Z axis in the NDC coordinates is the same as the direction of the axis where the depth value is located, the first marker is used to indicate the presence of snow, and the second marker is used to indicate the absence of snow; according to the marks of each screen pixel of the display interface, the map representing the snow weather object is sampled to obtain a shadow map of the display interface.

[0011] Optionally, the coordinate value of the Z axis in the NDC coordinate of the screen pixel of the display interface is compared with the depth value of the same position in the depth map of the weather obstruction body, and the screen pixel of the display interface is marked with a first mark or a second mark according to the comparison result, including: when the coordinate value of the Z axis in the NDC coordinate of the screen pixel is less than the depth value of the same position in the first depth map, and the coordinate value of the Z axis in the NDC coordinate of the screen pixel is less than the depth value of the same position in the second depth map, the screen pixel of the display interface is marked with a first mark; when the coordinate value of the Z axis in the NDC coordinate of the screen pixel is not less than the depth value of the same position in the first depth map, and / or the coordinate value of the Z axis in the NDC coordinate of the screen pixel is not less than the depth value of the same position in the second depth map, the screen pixel of the display interface is marked with a second mark.

[0012] Optionally, the snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal, including: fusing the normal in the normal map of the snow weather object with the world normal in the GPU cache and saving them to the GPU cache; linearly interpolating the pixel values ​​in the shadow map with the basic colors in the basic color map of the snow weather object, and saving them to the GPU cache; linearly interpolating the pixel values ​​in the shadow map with the roughness in the roughness map of the snow weather object, and saving them to the GPU cache.

[0013] According to another aspect of an embodiment of the present application, a rendering device for weather objects in a game is also provided, including: an occlusion generation unit, for generating a depth map of a weather occluder in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather occluder at the represented position, and the three-dimensional game scene is a game scene rendered on a smart terminal; a shadow generation unit, for generating a shadow map of a display interface of a smart terminal based on the depth map of the weather occluder, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented position; a weather rendering unit, for rendering snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal.

[0014] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.

[0015] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.

[0016] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of any of the above-described method embodiments.

[0017] In an embodiment of the present application, a depth map of a weather obstruction in a three-dimensional game scene is generated, and a shadow map of a display interface of a smart terminal is generated based on the depth map of the weather obstruction, and the degree of snow coverage is represented by the shadow map; the snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal, thereby providing a general snow rendering solution for game scenes. The snow weather simulation of this solution is mainly the interactive effect of the object model on the snow, such as which buildings can be covered by snow and the transition of the covered edge (rather than the process of snowing). The numerous interactive effects between objects and snow can simulate a more realistic snow scene landscape without developing snow scenes for different maps. This can solve the technical problem of the more complex operation of weather rendering in related technologies, thereby avoiding unnecessary development, reducing development workload, and reducing development investment costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 is a schematic diagram of a hardware environment for a method for rendering weather objects in a game according to an embodiment of the present application;

[0020] Figure 2 is a flowchart of an optional method for rendering weather objects in a game according to an embodiment of the present application;

[0021] Figure 3 is a schematic diagram of a depth map of an optional weather obstruction according to an embodiment of the present application;

[0022] Figure 4 is a schematic diagram of an optional offset texture of a weather shield according to an embodiment of the present application;

[0023] Figure 5 is a schematic diagram of a shadow diagram of an optional weather shield according to an embodiment of the present application;

[0024] Figure 6is a schematic diagram of an optional device for rendering weather objects in a game according to an embodiment of the present application; and

[0025] Figure 7 This is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] According to one aspect of the embodiments of the present application, a method embodiment of a method for rendering a weather object in a game is provided.

[0029] Optionally, in this embodiment, the rendering method of the weather object in the game can be applied to Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1 As shown, the server 103 is connected to the terminal 101 via a network, and can be used to provide game services for the terminal or a client installed on the terminal. A database 105 can be set on the server or independently of the server to provide storage services for game data for the server 103. The above-mentioned network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 is not limited to a local game terminal such as a PC, a mobile phone, or a tablet computer.

[0030] The method for rendering weather objects in the game of the embodiment of the present application can be executed by server 103, that is, the rendering operation is completed on server 103, and then the screen is transmitted to the terminal for display. It can also be executed by terminal 101, that is, terminal 101 independently completes the rendering and display of the game screen. The method for rendering weather objects in the game of the embodiment of the present application can also be executed by a client installed on terminal 101. The following description takes the case where the rendering operation is performed by terminal 101 as an example.

[0031] Figure 2 is a flowchart of an optional method for rendering weather objects in a game according to an embodiment of the present application. Figure 2 As shown, the method may include the following steps:

[0032] In step S22, the terminal generates a depth map of the weather obstruction in the three-dimensional game scene. Each pixel in the depth map is used to record the depth of the weather obstruction at the represented position. The three-dimensional game scene is a game scene rendered on the smart terminal.

[0033] In step S24 , the terminal generates a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction body, where each pixel in the shadow map is used to record the degree of snow coverage at the indicated location.

[0034] In step S26 , the terminal renders the snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal.

[0035] Through the above steps, a depth map of the weather obstruction in the three-dimensional game scene is generated, and a shadow map of the display interface of the smart terminal is generated according to the depth map of the weather obstruction, and the degree of snow coverage is represented by the shadow map; the snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal, thereby providing a universal snow rendering solution for the game scene, without having to develop snow scenes for different maps, and can solve the technical problem of the more complicated operation of weather rendering in related technologies, thereby avoiding unnecessary development, reducing the development workload, and reducing the development investment cost.

[0036] The snow weather simulation of this solution does not simulate the process of snowfall, but rather the interaction effect of object models on snow, such as which buildings can be covered by snow and the transition of the covered edge. By utilizing the various interactive effects between objects and weather (snow), a more realistic snow scene can be simulated. The following is a detailed description of the technical solution of this application in conjunction with specific steps:

[0037] In the technical solution provided in step S22, the terminal generates a depth map of weather obstructions (such as buildings, building eaves, umbrellas, water models, etc.) in a three-dimensional game scene. The three-dimensional game scene is a game scene located in a snowy area rendered on a smart terminal.

[0038] A depth map may be created, where each pixel in the depth map corresponds to a position in the three-dimensional game scene, and each pixel in the depth map is used to record the depth of the weather obstruction at the represented position.

[0039] Optionally, generating a depth map of a weather obstruction in a three-dimensional game scene includes steps S222 to S224:

[0040] Step S222: When the trigger condition is met, a target area in the three-dimensional game scene is determined according to a game character in the three-dimensional game scene, where the game character is a game character controlled by the player on the terminal.

[0041] Optionally, the trigger conditions can be set as needed, such as triggering at intervals of a specified duration, triggering according to the moving distance of the game character, etc. Hereinafter, triggering according to the moving distance of the game character is taken as an example:

[0042] 1) Obtaining the movement distance of the game character in the three-dimensional game scene, which is the distance between the position of the game character in the three-dimensional game scene when the target area was previously determined in the three-dimensional game scene (the method of the present application may be executed in a loop) and the current position of the game character in the three-dimensional game scene;

[0043] 2) When the moving distance reaches a specified threshold (e.g., 10 meters), the trigger condition is determined to be satisfied;

[0044] 3) If the moving distance does not reach the specified threshold, it is determined that the trigger condition is not met.

[0045] Step S224: Generate a depth map of the weather obstruction in the target area of ​​the 3D game scene. This may include at least one of the following:

[0046] 1) When the weather occluder attribute of a static scene model (mainly referring to a scene model other than a water body) within the target area indicates that the static scene model is a weather occluder, the depth information of the static scene model is rendered to a first depth map using a top-down orthogonal camera, and the depth map of the weather occluder includes the first depth map.

[0047] Optionally, the weather obstruction properties of the static scene model are configurable. Before rendering the depth information of the static scene model to the first depth map with a top-down orthogonal camera, the weather obstruction properties are added to the original model object when creating the original model object of the static scene model; when the original model object needs to be configured in a three-dimensional game scene, the configuration items of the original model object are displayed, and the configuration items of the original model object include the weather obstruction properties, so that developers or artists can configure them. After completing the configuration of the configuration items of the original model object, the original model object carrying the configured configuration items is configured in the three-dimensional game scene, so that when rendering, the configuration items can be used to see whether it is a weather obstruction.

[0048] 2) When there is a water model (such as a river, sea, pond, etc.) in the target area, the depth information of the water model is rendered into a second depth map using a top-down orthographic camera, and the depth map of the weather occluder includes the second depth map.

[0049] In the technical solution provided in step S24, the terminal generates a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction body.

[0050] The size of the shadow map can be the same as or smaller than the depth map. The shadow map only needs to include the area that currently needs to be rendered. Each pixel in the shadow map is used to record the degree of snow coverage at the represented location.

[0051] Optionally, generating a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction includes the following steps S242 to S246:

[0052] In step S242 , the spatial coordinates of the screen pixels of the display interface are converted into the world coordinates of the screen pixels, and then the world coordinates of the screen pixels are converted into NDC coordinates in the NDC space where the top-down orthographic camera is located.

[0053] When the terminal renders the game scene, the coordinate system used may be different from others, so a coordinate system conversion is required. It can be directly converted to the required coordinate system. Since there is also the world coordinate of the game scene, it can be converted to the world coordinate system first, and then to the required coordinate system, that is, the coordinate system of the NDC space.

[0054] Step S244: Compare the coordinate value of the Z axis in the NDC coordinate of the screen pixel of the display interface with the depth value of the same position in the depth map of the weather obstruction body, and mark the screen pixel of the display interface with a first mark or a second mark according to the comparison result. The direction of the Z axis in the NDC coordinate is the same as the direction of the axis where the depth value is located. The first mark is used to indicate that there is snow, and the second mark is used to indicate that there is no snow.

[0055] Step S246: Sample the texture representing the snow weather object based on the labels of each screen pixel of the display interface to obtain a shadow map of the display interface. This includes the following two parts:

[0056] 1) If the Z-axis coordinate value of the screen pixel in the NDC coordinate is less than the depth value of the same position in the first depth map, and the Z-axis coordinate value of the screen pixel in the NDC coordinate is less than the depth value of the same position in the second depth map, that is, it is neither blocked by a static weather obstruction nor blocked by a water body, the screen pixel of the display interface is marked with a first mark;

[0057] 2) When the Z-axis coordinate value of the screen pixel in the NDC coordinate is not less than the depth value of the same position in the first depth map, and / or the Z-axis coordinate value of the screen pixel in the NDC coordinate is not less than the depth value of the same position in the second depth map, that is, it is blocked by a static weather obstruction, blocked by a water body, or blocked by both at the same time, the screen pixel of the display interface is marked with a second mark.

[0058] In the technical solution provided in step S26, the terminal uses the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object and the world normal to render the snow in the three-dimensional game scene.

[0059] Optionally, rendering snow in a three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal includes the following steps S262 to S266:

[0060] Step S262: The normals in the normal map of the snow weather object are merged with the world normals in the GPU cache and then saved in the GPU cache.

[0061] Step S264 , performing linear interpolation on the pixel values ​​in the shadow map and the basic colors in the basic color map of the snow weather object, and then saving the result to the GPU cache.

[0062] Step S266 , performing linear interpolation on the pixel values ​​in the shadow map and the roughness in the roughness map of the snow weather object, and then saving the result to the GPU cache.

[0063] In the above scheme, the screen space weather rendering scheme is divided into three channels Pass (a pass is a process of completing a rendering process at the bottom layer of graphics rendering, from vertex calculation, shading, rasterization, etc., to obtain a frame of data): WeatherOccluderDepthPass (corresponding to the depth map of the weather occluder), WeatherOccluderMaskPass (corresponding to the shadow map of the weather occluder), SnowBasePass (corresponding to the final rendering image).

[0064] As an optional embodiment, the technical solution of the present application is further described in detail below in conjunction with specific implementation methods:

[0065] WeatherOccluderDepthPass: The main function is to output the depth map of the weather occluder in the scene before WeatherOccluderMaskPass (such as Figure 3 As shown), coverage range, the coverage range can be set as needed, such as 200m*200m.

[0066] The output format of WeatherOccluderDepthPass can be a floating-point format texture of R32Float (FLOAT data type is used to store single-precision floating-point numbers or double-precision floating-point numbers), such as a texture array of size 1024*1024. The texture array has two textures, the first is the depth texture of the occluder (corresponding to the first depth map), and the other is the depth texture of the water surface (corresponding to the second depth map). In order to achieve no snow under the water surface and on the surface, there is no snow below the occluder, that is, there will be snow only when the depth is less than the occluder and less than the depth of the water surface.

[0067] This pass is used to determine where in the scene to receive snow. It is a top-down rendering. This rendering can be updated in real time with each frame, or not (i.e., non-real time). The specific update is determined by the client, such as first determining the movement distance, determining the occluder and the occluding object, and determining the depth, etc., to measure whether to update. The implementation steps of WeatherOccluderDepthPass are as follows:

[0068] Step 1: Use a top-down orthographic camera to render the scene depth map to the first block depth texture in the texture array. This requires low precision and wide coverage. Every time the player moves a certain distance, the orthographic camera renders from directly above the player's camera toward the bottom. This is the update rule for snow rendering, which is selected by the client based on actual conditions. Every time the player moves a certain distance, a snow rendering update is triggered. Here, distance is used as the judgment condition; for example, a snow update is triggered when the player exceeds a certain distance.

[0069] Step 2: This Pass can only render weather occluders (such as buildings, building eaves, umbrellas, and water surfaces). Add the value APLM_WEATHER_OCCLUDER = ABit (19) to AprimitiveLayerMask, and add the weather occluder attribute to the static model in the map editor. Pass it to LitMesh and append APLM_WEATHER_OCCLUDER to A3DlitMesh::CalcLayerMask. The purpose is to determine which objects are occluders. It is an occluder setting parameter. Set trees, buildings, etc. in the game as occluders. Tree models will cause problems in the snow rendering process, so they are not the default occluders and are optional for artists.

[0070] Step 3: Render the depth of the water surface to the depth texture of the second block in the texture array.

[0071] In step 4, you need to save the ViewProjection matrix of the orthographic camera during rendering for use in subsequent passes. Ordinary cameras are perspective cameras. Orthographic cameras render from top to bottom and have no perspective effect where objects appear larger near and smaller far away. They are used in the first step to render depth and determine the depth values ​​of occluders and occluded objects.

[0072] The main function of WeatherOccluderMaskPass is to output a snow shadow map (or SnowShadow) after BasePass and before SnowBasePass and other passes that depend on WeatherOccluderMask, marking the snow coverage of each pixel. The output format is R8G8B8A8_Unorm and the size is equal to the screen size ScreenSize.

[0073] WeatherOccluderMaskPass is used to determine where there is snow on the current screen. It is necessary to convert the depth in the screen space into the depth of the top-down rendering image. If the depth is greater than the depth in the first image, there is no snow, and if it is smaller, there is snow.

[0074] The implementation steps of WeatherOccluderMaskPass are as follows:

[0075] Step 1: Transform the screen pixel's world coordinates to the orthographic camera's NDC space used by the WeatherDepthPass, and compare the z coordinate with the depth value sampled from the WeatherDepth pass (1 or 0, 1 for snow, 0 for no snow, based on the comparison with the depth value from the first pass). First transform the screen space coordinates to world coordinates, then to the orthographic camera's NDC coordinates.

[0076] Step 2: The result obtained above will be very harsh at the junction. It is necessary to sample the surrounding pixels multiple times and average the results to obtain a result with a gradual transition.

[0077] Step 3: To add randomness to the intersection to achieve a more natural effect, follow these steps:

[0078] Step 3.1, traverse the surrounding n*n pixels, and use the offset UV in an offset texture (such as Figure 4 The sample is taken from the UV offset (shown in the figure) to obtain an offset used in the next step, recorded as uvOffset. Similar to the shadow determination method, the depth of a point can be compared with the depth of surrounding points. If the depth of this point is less than the depth of all surrounding points, it means it is in snow, if it is greater than the depth of all surrounding points, it means there is no snow, and if it is partially less than and partially greater than, it means it is at the edge.

[0079] After the offset, the UV coordinates of the adjacent pixels around the sample are offset. The coordinate offsets of the adjacent pixels are used to sample different images (offset texture, depth map, noise map) to determine a new offset. The point under this offset is compared with the depth value to determine whether there is snow.

[0080] Non-uniform sampling, the offset texture is a random offset stored in a certain map, creating a little randomness. The noise map reflects the randomness, and the noise map is mixed with the color of the snow to make the edge transition more natural.

[0081] In step 3.2, the uv+uvOffset of the current pixel is used as the new uv to sample from the depth map and compare to get the result, 1 or 0, recorded as result.

[0082] In step 3.3, the uv+uvOffset of the current pixel is used as the uv to sample from another noise map as the weight, multiplied by the result obtained in the previous step, and the result and weight are accumulated and weighted averaged to obtain the final result.

[0083] Step 4, multiply the (snow) Shadow value by 2 0.8log[1.5*(NormalY-0.2)] , there is no snow on the vertical surface, and the amount of snow on the slope is less. The Y value of the normal of the current screen pixel, Y is the upward component, the smaller the Y, the less snow. The final Shadow image is as follows Figure 5 shown.

[0084] The Shadow value marks where there is snow and where there is no snow on the screen. It is the output of WeatherOccluderMaskPass, which is the snow shadow value of the snow shadow map. It is the interpolation coefficient in order to get the target value.

[0085] SnowBasePass, the final snow rendering, has the function of outputting the base color map BaseColor, normal map Normal, and roughness map Roughness to GBuffer after DecalPass and before LightPass. The output format is the same as GBuffer.

[0086] SnowBasePass can use the Shadow obtained by WeatherOccluderMaskPass to calculate the distribution of snow in screen space, calculate the white color according to the PBR lighting formula, the normal direction of the snow (which can be obtained from the pre-prepared snow normal map), and the roughness to render the snow (the roughness can be obtained from the pre-prepared snow roughness map). The implementation is as follows:

[0087] BaseColor and Roughness are both sampled from the texture, and the SnowShadow value is used as the alpha value to perform linear interpolation (AlphaBlend) with the value in the GBuffer. Normal is sampled from the texture, blended with the world normal in the GBuffer, and then output to the GBuffer. The specific algorithm is:

[0088] BaseColor=Shadow*SnowDiffuse.rgb+(1-Shadow)*GBufferBaseColor.rgb,

[0089] The current snow base color pixel value is a combination of the snow diffuse map pixel value and the base color pixel value stored in the G-Buffer, interpolated using the snow's shadow value. SnowDiffuse.rgb is the diffuse reflection value used by light after it refracts into the object, scatters internally, and then re-emits the surface. This value can be obtained from the pre-prepared snow diffuse map. GBufferBaseColor.rgb is the base color stored in the GBuffer.

[0090] Roughness=Shadow*SnowRoughness+(1-Shadow)*GBufferRoughness,

[0091] The current roughness pixel value = the snow roughness pixel value and the roughness pixel value stored in the G-Buffer, which are interpolated with the shadow value of the snow. SnowRoughness is the roughness of the snow, and GBufferRoughness is the roughness stored in the GBuffer.

[0092] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.

[0093] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0094] According to another aspect of an embodiment of the present application, a device for rendering weather objects in a game is also provided for implementing the above-mentioned method for rendering weather objects in a game. Figure 6 FIG. 1 is a schematic diagram of an optional device for rendering weather objects in a game according to an embodiment of the present application. Figure 6 As shown, the device may include:

[0095] An occlusion generation unit 601 is configured to generate a depth map of weather occluders in a three-dimensional game scene rendered on a smart terminal, wherein each pixel in the depth map records the depth of the weather occluder at the indicated location.

[0096] A shadow generating unit 603 is configured to generate a shadow map of the display interface of the smart terminal based on the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location;

[0097] The weather rendering unit 605 is used to render the snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object and the world normal.

[0098] It should be noted that the occlusion generation unit 601 in this embodiment can be used to execute step S22 in the embodiment of the present application, the shadow generation unit 603 in this embodiment can be used to execute step S24 in the embodiment of the present application, and the weather rendering unit 605 in this embodiment can be used to execute step S26 in the embodiment of the present application.

[0099] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. Figure 1 In the hardware environment shown, it can be implemented by software or by hardware.

[0100] Through the above-mentioned module, a depth map of the weather obstruction in the three-dimensional game scene is generated, and a shadow map of the display interface of the smart terminal is generated according to the depth map of the weather obstruction, and the degree of snow coverage is represented by the shadow map; the snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object and the world normal, thereby providing a universal snow rendering solution in the game scene, without the need to develop snow scenes for different maps, and can solve the technical problem of the more complicated operation of weather rendering in related technologies, thereby avoiding unnecessary development, reducing the development workload, and reducing the development investment cost.

[0101] Optionally, the occlusion generation unit is also used to, when generating a depth map of a weather obstruction in a three-dimensional game scene, determine a target area in the three-dimensional game scene based on a game character in the three-dimensional game scene when a trigger condition is met; when the weather obstruction attribute of the static scene model in the target area indicates that the static scene model is a weather obstruction, render the depth information of the static scene model to a first depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the first depth map; and / or, when there is a water body model in the target area, render the depth information of the water body model to a second depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the second depth map.

[0102] Optionally, the occlusion generation unit is also used to add weather obstruction attributes to the original model object when creating the original model object of the static scene model before rendering the depth information of the static scene model to the first depth map with a top-down orthogonal camera; when the original model object needs to be configured in the three-dimensional game scene, display the configuration items of the original model object, wherein the configuration items of the original model object include weather obstruction attributes; when the configuration of the configuration items of the original model object is completed, the original model object carrying the configured configuration items is configured in the three-dimensional game scene.

[0103] Optionally, the occlusion generation unit is also used to obtain the moving distance of the game character in the three-dimensional game scene before determining the target area in the three-dimensional game scene based on the game character in the three-dimensional game scene, wherein the moving distance is the distance between the position of the game character in the three-dimensional game scene when the target area was last determined in the three-dimensional game scene and the current position of the game character in the three-dimensional game scene; when the moving distance reaches a specified threshold, it is determined that the trigger condition is met; when the moving distance does not reach the specified threshold, it is determined that the trigger condition is not met.

[0104] Optionally, the shadow generation unit is also used to convert the spatial coordinates of the screen pixels of the display interface into the world coordinates of the screen pixels, and then convert the world coordinates of the screen pixels into NDC coordinates in the NDC space where the top-down orthogonal camera is located when generating the shadow map of the display interface of the smart terminal based on the depth map of the weather obstruction body; compare the coordinate value of the Z axis in the NDC coordinates of the screen pixels of the display interface with the depth value at the same position in the depth map of the weather obstruction body, and mark the screen pixels of the display interface with a first marker or a second marker according to the comparison result, wherein the direction of the Z axis in the NDC coordinates is the same as the direction of the axis where the depth value is located, the first marker is used to indicate the presence of snow, and the second marker is used to indicate the absence of snow; according to the mark of each screen pixel of the display interface, the map representing the snow weather object is sampled to obtain the shadow map of the display interface.

[0105] Optionally, the shadow generation unit is also used to compare the Z-axis coordinate value in the NDC coordinate of the screen pixel of the display interface with the depth value of the same position in the depth map of the weather obstruction body, and when the screen pixel of the display interface is marked with the first mark or the second mark according to the comparison result, if the Z-axis coordinate value in the NDC coordinate of the screen pixel is less than the depth value of the same position in the first depth map, and the Z-axis coordinate value in the NDC coordinate of the screen pixel is less than the depth value of the same position in the second depth map, the screen pixel of the display interface is marked with the first mark; if the Z-axis coordinate value in the NDC coordinate of the screen pixel is not less than the depth value of the same position in the first depth map, and / or the Z-axis coordinate value in the NDC coordinate of the screen pixel is not less than the depth value of the same position in the second depth map, the screen pixel of the display interface is marked with the second mark.

[0106] Optionally, the weather rendering unit is further used to, when rendering the snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object and the world normal, fuse the normal in the normal map of the snow weather object with the world normal in the GPU cache and save them into the GPU cache; linearly interpolate the pixel values ​​in the shadow map with the basic colors in the basic color map of the snow weather object and save them into the GPU cache; linearly interpolate the pixel values ​​in the shadow map with the roughness in the roughness map of the snow weather object and save them into the GPU cache.

[0107] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. Figure 1 The hardware environment shown can be implemented through software or hardware, wherein the hardware environment includes a network environment.

[0108] According to another aspect of an embodiment of the present application, a server or terminal for implementing the above-mentioned method for rendering weather objects in the game is also provided.

[0109] Figure 7 is a structural block diagram of a terminal according to an embodiment of the present application, such as Figure 7 As shown, the terminal may include: one or more ( Figure 7 (only one is shown) processor 701, memory 703, and transmission device 705, as shown in FIG. Figure 7 As shown, the terminal may further include an input and output device 707 .

[0110] Among them, the memory 703 can be used to store software programs and modules, such as the program instructions / modules corresponding to the rendering method and device of the weather object in the game in the embodiment of the present application. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 703, that is, realizing the rendering method of the weather object in the above-mentioned game. The memory 703 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 703 may further include a memory remotely arranged relative to the processor 701, and these remote memories can be connected to the terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, corporate intranet, local area network, mobile communication network and combinations thereof.

[0111] The transmission device 705 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one embodiment, the transmission device 705 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and a router via a network cable so as to communicate with the Internet or a local area network. In one embodiment, the transmission device 705 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0112] Specifically, the memory 703 is used to store application programs.

[0113] The processor 701 may call the application stored in the memory 703 through the transmission device 705 to perform the following steps:

[0114] Generating a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the represented location, and the three-dimensional game scene is a game scene rendered on a smart terminal;

[0115] generating a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location;

[0116] Snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal.

[0117] The processor 701 is further configured to perform the following steps:

[0118] Converting the spatial coordinates of the screen pixels of the display interface into world coordinates of the screen pixels, and then converting the world coordinates of the screen pixels into NDC coordinates in the NDC space where the top-down orthogonal camera is located;

[0119] Comparing the Z-axis coordinate value of the screen pixel of the display interface in the NDC coordinate with the depth value of the same position in the depth map of the weather obstruction, and marking the screen pixel of the display interface with a first identifier or a second identifier according to the comparison result, wherein the direction of the Z-axis in the NDC coordinate is the same as the direction of the axis of the depth value, the first identifier is used to indicate the presence of snow, and the second identifier is used to indicate the absence of snow;

[0120] According to the mark of each screen pixel of the display interface, the texture representing the snow weather object is sampled to obtain the shadow map of the display interface.

[0121] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0122] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the terminal may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 7 It does not limit the structure of the above electronic device. For example, the terminal may also include Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 7 Different configurations shown.

[0123] A person skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0124] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the method for rendering weather objects in the game.

[0125] Optionally, in this embodiment, the above-mentioned storage medium may be located on at least one network device among the multiple network devices in the network shown in the above-mentioned embodiment.

[0126] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0127] Generating a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the represented location, and the three-dimensional game scene is a game scene rendered on a smart terminal;

[0128] generating a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location;

[0129] Snow in the three-dimensional game scene is rendered using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal.

[0130] Optionally, the storage medium is further configured to store program codes for executing the following steps:

[0131] Converting the spatial coordinates of the screen pixels of the display interface into world coordinates of the screen pixels, and then converting the world coordinates of the screen pixels into NDC coordinates in the NDC space where the top-down orthogonal camera is located;

[0132] Comparing the Z-axis coordinate value of the screen pixel of the display interface in the NDC coordinate with the depth value of the same position in the depth map of the weather obstruction, and marking the screen pixel of the display interface with a first identifier or a second identifier according to the comparison result, wherein the direction of the Z-axis in the NDC coordinate is the same as the direction of the axis of the depth value, the first identifier is used to indicate the presence of snow, and the second identifier is used to indicate the absence of snow;

[0133] According to the mark of each screen pixel of the display interface, the texture representing the snow weather object is sampled to obtain the shadow map of the display interface.

[0134] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0135] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0136] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0137] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.

[0138] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0139] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.

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

[0141] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0142] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for rendering weather objects in a game, characterized in that: include: Generating a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the represented location, and the three-dimensional game scene is a game scene rendered on a smart terminal; generating a shadow map of the display interface of the smart terminal according to the depth map of the weather obstruction, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location; Rendering snow in the three-dimensional game scene using the shadow map, the base color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal; The generating of a depth map of a weather obstruction in a three-dimensional game scene includes: when a trigger condition is met, determining a target area in the three-dimensional game scene based on a game character in the three-dimensional game scene, the game character being a game character controlled by a player on the smart terminal, and the trigger condition including triggering at intervals of a specified duration, or triggering based on a movement distance of the game character; when a weather obstruction attribute of a static scene model in the target area indicates that the static scene model is a weather obstruction, rendering the depth information of the static scene model to a first depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the first depth map; and / or, when a water body model exists in the target area, rendering the depth information of the water body model to a second depth map using a top-down orthogonal camera, wherein the depth map of the weather obstruction includes the second depth map.

2. The method according to claim 1, characterized in that Before rendering the depth information of the static scene model into the first depth map using a top-down orthographic camera, the method further includes: When creating an original model object of the static scene model, adding a weather obstruction attribute to the original model object; In the case where the original model object needs to be configured in the three-dimensional game scene, displaying configuration items of the original model object, wherein the configuration items of the original model object include weather obstruction attributes; When the configuration items of the original model object are configured, the original model object carrying the configured configuration items is configured in the three-dimensional game scene.

3. The method according to claim 2, characterized in that Before determining the target area in the three-dimensional game scene according to the game character in the three-dimensional game scene, the method further includes: Obtaining a movement distance of the game character in the three-dimensional game scene, wherein the movement distance is the distance between the position of the game character in the three-dimensional game scene when the target area was last determined in the three-dimensional game scene and the current position of the game character in the three-dimensional game scene; When the moving distance reaches a specified threshold, determining that the trigger condition is satisfied; In a case where the moving distance does not reach the specified threshold, it is determined that the trigger condition is not satisfied.

4. The method according to claim 2, characterized in that Generating a shadow map of the display interface of the smart terminal according to the depth map of the weather shield includes: Converting the spatial coordinates of the screen pixels of the display interface into world coordinates of the screen pixels, and then converting the world coordinates of the screen pixels into NDC coordinates in the NDC space where the top-down orthogonal camera is located; Comparing the Z-axis coordinate value of the screen pixel of the display interface in the NDC coordinate with the depth value of the same position in the depth map of the weather obstruction, and marking the screen pixel of the display interface with a first identifier or a second identifier according to the comparison result, wherein the direction of the Z-axis in the NDC coordinate is the same as the direction of the axis of the depth value, the first identifier is used to indicate the presence of snow, and the second identifier is used to indicate the absence of snow; According to the mark of each screen pixel of the display interface, the texture representing the snow weather object is sampled to obtain the shadow map of the display interface.

5. The method according to claim 4, characterized in that Comparing the Z-axis coordinate value of the screen pixel of the display interface in the NDC coordinate with the depth value of the same position in the depth map of the weather obstruction body, and marking the screen pixel of the display interface with a first mark or a second mark according to the comparison result, including: When the coordinate value of the Z axis in the NDC coordinate of the screen pixel is less than the depth value of the same position in the first depth map, and the coordinate value of the Z axis in the NDC coordinate of the screen pixel is less than the depth value of the same position in the second depth map, marking the screen pixel of the display interface with the first identifier; When the Z-axis coordinate value of the NDC coordinate of the screen pixel is not less than the depth value of the same position in the first depth map, and / or the Z-axis coordinate value of the NDC coordinate of the screen pixel is not less than the depth value of the same position in the second depth map, the screen pixel of the display interface is marked with the second identifier.

6. The method according to any one of claims 1 to 5, characterized in that Rendering snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal, comprising: Merging the normals in the normal map of the snow weather object with the world normals in the GPU cache and saving the resultant data to the GPU cache; After linear interpolation of pixel values ​​in the shadow map and basic colors in the basic color map of the snow weather object, the pixel values ​​are saved in the GPU cache; After linear interpolation is performed on the pixel values ​​in the shadow map and the roughness in the roughness map of the snow weather object, the values ​​are saved in the GPU cache.

7. A device for rendering weather objects in a game, used to implement the method for rendering weather objects in a game according to any one of claims 1 to 6, characterized in that: include: an occlusion generation unit, configured to generate a depth map of a weather obstruction in a three-dimensional game scene rendered on a smart terminal, wherein each pixel in the depth map is used to record the depth of the weather obstruction at the indicated location; a shadow generating unit, configured to generate a shadow map of the display interface of the smart terminal based on the depth map of the weather obstruction body, wherein each pixel in the shadow map is used to record the degree of snow coverage at the represented location; A weather rendering unit is used to render snow in the three-dimensional game scene using the shadow map, the basic color map of the snow weather object, the normal map of the snow weather object, the roughness map of the snow weather object, and the world normal.

8. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 6 when executed.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the method according to any one of claims 1 to 6 through the computer program.

Citation Information

Patent Citations

  • Shadow rendering method and device, terminal and storage medium

    CN109993823A

  • System and method for rendering shadows for a virtual environment

    US20180276878A1