Method and device for rendering weather in games, storage medium, and electronic device
By generating shadow maps of snow coverage and natural transitions at edges, combined with basic color, normal and roughness maps, efficient rendering of snow in game scenes is achieved, solving the problem of complex weather rendering operations, and reducing development costs and workload.
Patent Information
- Application Number
- CN202111626302.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In the prior art, the weather rendering operation in game scenes is complicated, resulting in low development efficiency and cannot meet the needs of fast version updates, affecting the user experience.
By obtaining the depth map of the weather occlusion in the three-dimensional game scene, a shadow map represents the degree of snow coverage and natural transition of snow edges, and rendering snow on the smart terminal using shadow maps, basic color maps, normal maps and roughness maps of snow weather objects.
It provides a general rendering solution for snow in game scenes, which reduces the development workload and investment cost, simulates a more realistic snow scene landscape, and avoids the need to develop snow scenes for different maps.
Smart Images

Figure CN116351065B_ABST
Abstract
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 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 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 in a game is provided, including: obtaining 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; using the depth map of the weather obstruction, generating a shadow map representing the degree of snow coverage and with a natural transition of the snow edge; 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, rendering the snow in the three-dimensional game scene on the display interface of the smart terminal.
[0007] Optionally, a depth map of the weather obstruction is used to generate a shadow map representing the degree of snow coverage and with a natural transition of the snow edge, including: determining the edge pixel points representing the snow edge in the display interface by comparing the pixel points in the depth map of the weather obstruction with the pixel points representing the corresponding positions in the three-dimensional game scene in the display interface; and performing edge transition processing on the edge pixel points representing the snow edge using an edge transition processing method to obtain a shadow map.
[0008] Optionally, an edge transition processing method is used to perform edge transition processing on edge pixels representing the edge of snow to obtain a shadow map, including: obtaining the UV value and UV offset value of the target pixel point, wherein the target pixel point is an unprocessed pixel point among all edge pixels in the shadow map, and there are edge pixels with different UV offset values in the shadow map; according to multiple comparison results and multiple weights between the target pixel point and multiple first depth values, a pixel value is set for the target pixel point in the shadow map to confirm the degree of snow coverage at the target pixel point through the pixel value, wherein the multiple first depth values are sampled from the depth map using the UV value and UV offset value of the target pixel point, and the multiple weights are sampled from the weight map using the UV value and UV offset value of the target pixel point, and the weight map is used to provide preset weights.
[0009] Optionally, based on multiple comparison results and multiple weights between the target pixel and multiple first depth values, a pixel value is set for the target pixel in the shadow map, including: sampling multiple first depth values from the depth map according to the UV value and UV offset value of the target pixel, and sampling multiple weights from the weight map according to the UV value and UV offset value of the target pixel, wherein the positions of the multiple first depth values in the depth map are the same as the positions of the multiple weights in the weight map; comparing the multiple first depth values with the target pixel respectively to obtain multiple comparison results, wherein each comparison result is obtained by comparing a first depth value with the target pixel; performing weighted summation on the multiple comparison results and the multiple weights to obtain a weighted result, wherein, when performing the weighted summation, for each comparison result, the position of the first depth value used to determine the comparison result in the depth map is the same as the position of the weight used in the weight map; and using the weighted result to set the pixel value for the target pixel in the shadow map.
[0010] Optionally, according to multiple comparison results and multiple weights between the target pixel and the multiple first depth values, setting a pixel value for the target pixel in the shadow map includes: converting the spatial coordinates of the target pixel in the display interface into the world coordinates of the target pixel, and then converting the world coordinates of the target pixel into the NDC coordinates in the NDC space where the top-down orthogonal camera is located, wherein the direction of the Z axis in the NDC coordinates is the same as the direction of the axis where the first depth value is located; comparing the coordinate value of the Z axis in the NDC coordinates of the target pixel with each first depth value in the multiple first depth values; When the coordinate value of the Z axis in the NDC coordinates of the point is less than the first depth value, and the coordinate value of the Z axis in the NDC coordinates of the target pixel point is less than the second depth value of the water body at the same position, the comparison result between the target pixel point and the first depth value is determined to be a first value, wherein the first value is used to indicate that there is snow; when the coordinate value of the Z axis in the NDC coordinates of the target pixel point is not less than the first depth value, and / or the coordinate value of the Z axis in the NDC coordinates of the target pixel point is not less than the second depth value, the comparison result between the target pixel point and the first depth value is determined to be a second value, wherein the second value is used to indicate that there is no snow.
[0011] Optionally, setting a pixel value for the target pixel point in the shadow map using the weighted result includes setting a pixel value Value for the target pixel point in the shadow map using the weighted result according to the following formula:
[0012] Value=Shadow*20.8log[1.5*(NormalY-0.2)],
[0013] Among them, Shadow is the weighted result, log() is the logarithmic function, and NormalY represents the component of the normal vector of the target pixel on the Y axis.
[0014] Optionally, before setting the pixel value for the target pixel in the shadow map based on multiple comparison results and multiple weights between the target pixel and multiple first depth values, the method also includes: obtaining the coordinate offset between the target pixel and adjacent pixels; using the UV value and coordinate offset value of the target pixel to sample in the offset texture to obtain a UV offset value, wherein the offset texture is used to provide random UV offset values.
[0015] According to another aspect of an embodiment of the present application, a device for rendering weather in a game is also provided, including: an acquisition unit for acquiring 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; a generation unit for using the depth map of the weather obstruction to generate a shadow map representing the degree of snow coverage and with a natural transition of the snow edge; a rendering unit for 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 to render the snow in the three-dimensional game scene on the display interface of the smart terminal.
[0016] 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.
[0017] 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.
[0018] 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.
[0019] In an embodiment of the present application, a depth map of a weather obstruction in a three-dimensional game scene is obtained, and the depth map of the weather obstruction is used to generate a shadow map representing the degree of snow coverage and the natural transition of the snow edge. 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 are used to render the snow in the three-dimensional game scene on the display interface of the smart terminal, thereby providing a general snow rendering solution for game scenes. The snow weather simulation of this solution is mainly the interaction effect of the object model on the snow, such as which buildings can be covered by snow and the transition of the coverage edge (rather than the process of snowing). The numerous interaction 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
[0020] 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:
[0021] Figure 1 is a schematic diagram of the hardware environment of a method for rendering weather in a game according to an embodiment of the present application;
[0022] Figure 2 is a flowchart of an optional method for rendering weather in a game according to an embodiment of the present application;
[0023] Figure 3 is a schematic diagram of a depth map of an optional weather obstruction according to an embodiment of the present application;
[0024] Figure 4 is a schematic diagram of an optional offset texture of a weather shield according to an embodiment of the present application;
[0025] Figure 5 is a schematic diagram of a shadow diagram of an optional weather shield according to an embodiment of the present application;
[0026] Figure 6 is a schematic diagram of an optional device for rendering weather in a game according to an embodiment of the present application; and
[0027] Figure 7 This is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] 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.
[0029] 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.
[0030] According to one aspect of the embodiments of the present application, a method embodiment of a method for rendering weather in a game is provided.
[0031] Optionally, in this embodiment, the above-mentioned weather rendering method 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 data storage services 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 PC, a mobile phone, a tablet computer, etc.
[0032] The weather rendering method for 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 terminal 101 can also execute the weather rendering method for the game of the embodiment of the present application by a client installed thereon. The following description takes the rendering operation performed by terminal 101 as an example.
[0033] Figure 2 This is a flow chart of an optional method for rendering weather in a game according to an embodiment of the present application. Figure 2 As shown, the method may include the following steps:
[0034] In step S22, the terminal obtains 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 indicated position. The three-dimensional game scene is a game scene rendered on the smart terminal.
[0035] In step S24, the terminal uses the depth map of the weather obstruction to generate a shadow map representing the degree of snow coverage with a natural transition of the snow edge. The pixels in the shadow map are used to represent the degree of snow coverage at the corresponding position on the screen.
[0036] 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 on the display interface of the smart terminal.
[0037] Through the above steps, a depth map of the weather occluder in the three-dimensional game scene is obtained, and the depth map of the weather occluder is used to generate a shadow map representing the degree of snow coverage and with a natural transition of the snow edge. 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 are used to render the snow in the three-dimensional game scene on the display interface of the smart terminal, thereby providing a universal snow rendering solution in the game scene without developing snow scenes for different maps. It can solve the technical problem of the more complicated operation of weather rendering in related technologies, thereby avoiding unnecessary development, reducing development workload and reducing development investment costs.
[0038] 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:
[0039] 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.
[0040] 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.
[0041] Optionally, generating a depth map of a weather obstruction in a three-dimensional game scene includes steps S222 to S224:
[0042] 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.
[0043] 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:
[0044] 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;
[0045] 2) When the moving distance reaches a specified threshold (e.g., 10 meters), the trigger condition is determined to be satisfied;
[0046] 3) If the moving distance does not reach the specified threshold, it is determined that the trigger condition is not met.
[0047] 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:
[0048] 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.
[0049] 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.
[0050] 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.
[0051] In the technical solution provided in step S24, the depth map of the weather obstruction body is used to generate a shadow map representing the degree of snow coverage and having a natural transition of the snow edge.
[0052] 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.
[0053] Optionally, using the depth map of the weather obstruction body, a shadow map representing the snow coverage and having a natural transition of the snow edge is generated, including steps S242 to S244:
[0054] Step S242 , by comparing the pixel points in the depth map of the weather obstruction body with the pixel points representing the corresponding positions in the three-dimensional game scene in the display interface, the edge pixel points representing the edge of the snow in the display interface are determined.
[0055] Compare the Z-axis coordinate value of the screen pixel in the NDC coordinate with the depth value of the same position in the depth map of the weather obstruction. Depending on the comparison result, mark the first or second mark. The direction of the Z axis in the NDC coordinate is the same as the direction of the depth value axis. The first mark is used to indicate snow, and the second mark is used to indicate no snow. For all pixels, you can mark them as follows (specifically, you can use numerical marks):
[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] If a pixel (with the first mark) is adjacent to another pixel with the first mark and also adjacent to a pixel with the second mark, it means that it is an edge pixel.
[0059] In step S242, edge transition processing is performed on the edge pixels representing the snow edge using an edge transition processing method to obtain a shadow map. Specifically, the processing of each edge pixel can be achieved by following the following steps (it should be noted that the following steps can be performed multiple times to achieve a more random and natural edge effect):
[0060] 1) Obtain the UV value and UV offset value of the target pixel point. The target pixel point is an unprocessed pixel point among all edge pixels in the shadow map. There are edge pixels with different UV offset values in the shadow map.
[0061] For example, the coordinate offset between the target pixel and the adjacent pixel can be obtained, and the UV value and coordinate offset value of the target pixel (the coordinate offset value can be used as the UV offset value used when adopting) are used to sample in the offset texture to obtain a new UV offset value. The offset texture provides a random UV offset value to facilitate the subsequent natural edge transition effect.
[0062] 2) According to the UV value and UV offset value of the target pixel point, n first depth values (i.e., d1 to dn) are sampled from the depth map of the occluder, and n weights (i.e., k1 to kn) are sampled from the weight map according to the UV value and UV offset value of the target pixel point. n ), the positions of the n first depth values in the depth map of the occluder are the same as the positions of the n weights in the weight map, for example, for any di and k i , if d i The position coordinates in the depth map are (x, y), so the coordinates of ki in the weight map are also (x, y), the value of i is between 1 and n, and the values of x and y are positive integers (the size can be determined according to the number of pixel rows and columns in the image).
[0063] 3) Compare the n first depth values with the target pixel points respectively to obtain n comparison results, each comparison result is obtained by comparing a first depth value with the target pixel point, that is, n Corresponding to p1 to p n .
[0064] 4) Perform a weighted summation on the n comparison results and n weights (i.e., i=1n(pi*ki)) to obtain a weighted result. When performing the weighted summation, for each comparison result, the position of the first depth value used to determine the comparison result in the depth map of the occluder is the same as the position of the weight used in the weight map, for example, both are the third pixel in the second row.
[0065] Similar to the above marking process, the spatial coordinates of the target pixel point in the display interface can be first converted into the world coordinates of the target pixel point, and then the world coordinates of the target pixel point are converted into the NDC coordinates in the NDC space where the top-down orthogonal camera is located; the Z-axis coordinate value of the NDC coordinate of the target pixel point is compared with each first depth value of the n first depth values.
[0066] When the Z-axis coordinate value in the NDC coordinate of the target pixel point is less than the first depth value, and the Z-axis coordinate value in the NDC coordinate of the target pixel point is less than the second depth value of the water body at the same position, the comparison result between the target pixel point and the first depth value is determined to be a first value (such as 1), and the first value is used to indicate that there is snow.
[0067] When the Z-axis coordinate value in the NDC coordinate of the target pixel point is not less than the first depth value, and / or the Z-axis coordinate value in the NDC coordinate of the target pixel point is not less than the second depth value, the comparison result between the target pixel point and the first depth value is determined to be a second value (such as 0), and the second value is used to indicate that there is no snow.
[0068] 5) Use the weighted result to set the pixel value for the target pixel in the shadow map. Use the weighted result to set the pixel value for the target pixel in the shadow map according to the following formula:
[0069] Value=Shadow*2 0.[ .*(.)],
[0070] Shadow is the weighted result, log() is the logarithmic function, NormalY represents the component of the normal vector of the target pixel on the Y-axis. The coordinate system used can be: taking the user facing the screen as an example, the user's right hand side is the X-axis, the facing direction is the Y-axis, and the Z-axis is perpendicular to the XY plane and pointing upward.
[0071] 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 on the display interface of the smart terminal.
[0072] The process includes the following steps S262 to S266:
[0073] 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.
[0074] Step S264 , 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 the results to the GPU cache.
[0075] 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.
[0076] 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).
[0077] As an optional embodiment, the technical solution of the present application is further described in detail below in conjunction with specific implementation methods:
[0078] 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.
[0079] 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.
[0080] 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:
[0081] 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.
[0082] 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.
[0083] Step 3: Render the depth of the water surface to the depth texture of the second block in the texture array.
[0084] 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.
[0085] 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.
[0086] WeatherOccluderMaskPass is used to determine where there is snow on the current screen. It needs to convert the depth in screen space to 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. The implementation steps of WeatherOccluderMaskPass are as follows:
[0087] 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.
[0088] 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.
[0089] Step 3: To add randomness to the intersection to achieve a more natural effect, follow these steps:
[0090] 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.
[0091] 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.
[0092] 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.
[0093] 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.
[0094] 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.
[0095] Step 4, multiply the (snow) Shadow value by 20.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.
[0096] 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.
[0097] 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.
[0098] 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:
[0099] 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:
[0100] BaseColor=Shadow*SnowDiffuse.rgb+(1-Shadow)*GBufferBaseColor.rgb,
[0101] 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.
[0102] Roughness=Shadow*SnowRoughness+(1-Shadow)*GBufferRoughness,
[0103] 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.
[0104] 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.
[0105] 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.
[0106] According to another aspect of an embodiment of the present application, a device for rendering weather in a game for implementing the above-mentioned method for rendering weather in a game is also provided. Figure 6 is a schematic diagram of an optional device for rendering weather in a game according to an embodiment of the present application, such as Figure 6 As shown, the device may include:
[0107] An acquisition unit 601 is configured to acquire a depth map of a weather obstruction in a three-dimensional game scene, wherein each pixel in the depth map records the depth of the weather obstruction at the indicated location. The three-dimensional game scene is a game scene rendered on a smart terminal.
[0108] A generating unit 603 is configured to generate a shadow map representing the extent of snow coverage and having a natural transition of snow edges using the depth map of the weather obstruction body;
[0109] The rendering unit 605 is used to render the snow in the three-dimensional game scene on the display interface of the smart terminal 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.
[0110] It should be noted that the acquisition unit 601 in this embodiment can be used to execute step S22 in the embodiment of the present application, the generation unit 603 in this embodiment can be used to execute step S24 in the embodiment of the present application, and the rendering unit 605 in this embodiment can be used to execute step S26 in the embodiment of the present application.
[0111] 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.
[0112] Through the above module, a depth map of the weather obstruction in the three-dimensional game scene is obtained, and the depth map of the weather obstruction is used to generate a shadow map representing the degree of snow coverage and with a natural transition of the snow edge. 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 are used to render the snow in the three-dimensional game scene on the display interface of the smart terminal, thereby providing a universal snow rendering solution in the game scene without developing snow scenes for different maps. It can solve the technical problem of the more complicated weather rendering operation in the related technology, thereby avoiding unnecessary development, reducing the development workload and reducing the development investment cost.
[0113] Optionally, the generation unit 603 is also used to: determine the edge pixel points representing the edge of snow in the display interface by comparing the pixel points in the depth map of the weather obstruction body and the pixel points representing the corresponding positions in the three-dimensional game scene in the display interface; and use an edge transition processing method to perform edge transition processing on the edge pixel points representing the edge of snow to obtain the shadow map.
[0114] Optionally, the generation unit 603 is also used to: obtain the UV value and UV offset value of the target pixel point, wherein the target pixel point is an unprocessed pixel point among all edge pixel points in the shadow map, and there are edge pixel points with different UV offset values in the shadow map; set a pixel value for the target pixel point in the shadow map according to multiple comparison results and multiple weights between the target pixel point and multiple first depth values, so as to confirm the degree of snow coverage at the target pixel point through the pixel value, wherein the multiple first depth values are sampled from the depth map using the UV value and UV offset value of the target pixel point, and the multiple weights are sampled from the weight map using the UV value and UV offset value of the target pixel point, and the weight map is used to provide preset weights.
[0115] Optionally, the generation unit 603 is also used to: sample the multiple first depth values from the depth map according to the UV value and UV offset value of the target pixel point, and sample the multiple weights from the weight map according to the UV value and UV offset value of the target pixel point, wherein the positions of the multiple first depth values in the depth map are the same as the positions of the multiple weights in the weight map; compare the multiple first depth values with the target pixel point respectively to obtain the multiple comparison results, wherein each comparison result is obtained by comparing a first depth value with the target pixel point; perform weighted summation on the multiple comparison results and the multiple weights to obtain a weighted result, wherein, when performing the weighted summation, for each comparison result, the position of the first depth value used to determine the comparison result in the depth map is the same as the position of the weight used in the weight map; and use the weighted result to set the pixel value for the target pixel point in the shadow map.
[0116] Optionally, the generating unit 603 is further configured to: convert the spatial coordinates of the target pixel point in the display interface into the world coordinates of the target pixel point, and then convert the world coordinates of the target pixel point into NDC coordinates in the NDC space where the top-down orthogonal camera is located, wherein the direction of the Z axis in the NDC coordinates is the same as the direction of the axis where the first depth value is located; compare the Z axis coordinate value in the NDC coordinates of the target pixel point with each first depth value in the multiple first depth values; if the Z axis coordinate value in the NDC coordinates of the target pixel point is less than the first depth value and the Z axis coordinate value in the NDC coordinates of the target pixel point is less than the second depth value of the water body at the same location, determine that the comparison result between the target pixel point and the first depth value is a first value, wherein the first value is used to indicate the presence of snow; if the Z axis coordinate value in the NDC coordinates of the target pixel point is not less than the first depth value and / or the Z axis coordinate value in the NDC coordinates of the target pixel point is not less than the second depth value, determine that the comparison result between the target pixel point and the first depth value is a second value, wherein the second value is used to indicate the absence of snow.
[0117] Optionally, the generating unit 603 is further configured to set a pixel value Value for the target pixel point in the shadow map using the weighted result according to the following formula:
[0118] Value=Shadow*2 0.8log[1.5*(NormalY-0.2)] ,
[0119] Among them, Shadow is the weighted result, log() is the logarithmic function, and NormalY represents the component of the normal vector of the target pixel point on the Y axis.
[0120] Optionally, the generation unit 603 is also used to: obtain the coordinate offset between the target pixel point and the adjacent pixel points before setting the pixel value for the target pixel point in the shadow map based on multiple comparison results and multiple weights between the target pixel point and multiple first depth values; and use the UV value and coordinate offset value of the target pixel point to sample in the offset texture to obtain the UV offset value, wherein the offset texture is used to provide random UV offset values.
[0121] 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.
[0122] According to another aspect of an embodiment of the present application, a server or terminal for implementing the above-mentioned method for rendering weather in the game is also provided.
[0123] 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 .
[0124] Among them, the memory 703 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for rendering weather 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 above-mentioned method for rendering weather in the 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 located relative to the processor 701, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0125] 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.
[0126] Specifically, the memory 703 is used to store application programs.
[0127] The processor 701 may call the application stored in the memory 703 through the transmission device 705 to perform the following steps:
[0128] A depth map of a weather obstruction in a three-dimensional game scene is obtained, 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; using the depth map of the weather obstruction, a shadow map is generated that represents the degree of snow coverage and has a natural transition of the snow edge; 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, the snow in the three-dimensional game scene is rendered on the display interface of the smart terminal.
[0129] The processor 701 is further configured to perform the following steps:
[0130] The multiple first depth values are sampled from the depth map according to the UV value and UV offset value of the target pixel point, and the multiple weights are sampled from the weight map according to the UV value and UV offset value of the target pixel point, wherein the positions of the multiple first depth values in the depth map are the same as the positions of the multiple weights in the weight map; the multiple first depth values are respectively compared with the target pixel point to obtain the multiple comparison results, wherein each comparison result is obtained by comparing a first depth value with the target pixel point; the multiple comparison results are weightedly summed with the multiple weights to obtain a weighted result, wherein when performing the weighted summation, for each comparison result, the position of the first depth value used to determine the comparison result in the depth map is the same as the position of the weight used in the weight map; and the weighted result is used to set the pixel value for the target pixel point in the shadow map.
[0131] 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.
[0132] 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.
[0133] 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.
[0134] 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 in the game.
[0135] 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.
[0136] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:
[0137] A depth map of a weather obstruction in a three-dimensional game scene is obtained, 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; using the depth map of the weather obstruction, a shadow map is generated that represents the degree of snow coverage and has a natural transition of the snow edge; 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, the snow in the three-dimensional game scene is rendered on the display interface of the smart terminal.
[0138] Optionally, the storage medium is further configured to store program codes for executing the following steps:
[0139] The multiple first depth values are sampled from the depth map according to the UV value and UV offset value of the target pixel point, and the multiple weights are sampled from the weight map according to the UV value and UV offset value of the target pixel point, wherein the positions of the multiple first depth values in the depth map are the same as the positions of the multiple weights in the weight map; the multiple first depth values are respectively compared with the target pixel point to obtain the multiple comparison results, wherein each comparison result is obtained by comparing a first depth value with the target pixel point; the multiple comparison results are weightedly summed with the multiple weights to obtain a weighted result, wherein when performing the weighted summation, for each comparison result, the position of the first depth value used to determine the comparison result in the depth map is the same as the position of the weight used in the weight map; and the weighted result is used to set the pixel value for the target pixel point in the shadow map.
[0140] 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.
[0141] 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.
[0142] 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.
[0143] 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.
[0144] 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.
[0145] 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.
[0146] 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.
[0147] 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.
[0148] 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 in a game, characterized in that: include: Obtaining 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; Using the depth map of the weather obstruction, a shadow map is generated that indicates the extent of snow coverage and has a natural transition of snow edges; Rendering snow in the three-dimensional game scene on a display interface of the smart terminal 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 method of obtaining 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 being triggered at intervals of a specified duration, or being triggered based on a movement distance of the game character; generating a depth map of a weather obstruction in the target area in the three-dimensional game scene, specifically including, when a static scene model in the target area is pre-configured as a weather obstruction, rendering the depth information of the static scene model to a first depth map using a top-down orthogonal camera, the depth map of the weather obstruction including 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, the depth map of the weather obstruction including the second depth map.
2. The method according to claim 1, characterized in that Generating a shadow map representing the extent of snow coverage and having a natural transition of snow edges using the depth map of the weather obstruction body includes: Determining edge pixels representing snow edges in the display interface by comparing pixels in the depth map of the weather obstruction with pixels representing corresponding positions in the three-dimensional game scene in the display interface; An edge transition processing method is used to perform edge transition processing on edge pixel points representing the snow edge to obtain the shadow map.
3. The method according to claim 2, characterized in that An edge transition processing method is used to perform edge transition processing on edge pixels representing the edge of snow to obtain the shadow map, including: Obtaining a UV value and a UV offset value of a target pixel, wherein the target pixel is an unprocessed pixel among all edge pixels of the shadow map, and there are edge pixels with different UV offset values in the shadow map; Based on multiple comparison results and multiple weights between the target pixel point and multiple first depth values, a pixel value is set for the target pixel point in the shadow map to confirm the degree of snow coverage at the target pixel point through the pixel value, wherein the multiple first depth values are sampled from the depth map using the UV value and UV offset value of the target pixel point, and the multiple weights are sampled from a weight map using the UV value and UV offset value of the target pixel point, and the weight map is used to provide preset weights.
4. The method according to claim 3, characterized in that Setting a pixel value for the target pixel in the shadow map according to a plurality of comparison results between the target pixel and a plurality of first depth values and a plurality of weights includes: Sampling the plurality of first depth values from the depth map according to the UV value and the UV offset value of the target pixel point, and sampling the plurality of weights from the weight map according to the UV value and the UV offset value of the target pixel point, wherein positions of the plurality of first depth values in the depth map are the same as positions of the plurality of weights in the weight map; Comparing the plurality of first depth values with the target pixel point respectively to obtain the plurality of comparison results, wherein each comparison result is obtained by comparing a first depth value with the target pixel point; Performing a weighted summation on the multiple comparison results and the multiple weights to obtain a weighted result, wherein, when performing the weighted summation, for each comparison result, a position of a first depth value used to determine the comparison result in the depth map is the same as a position of a weight used in the weight map; The weighted result is used to set a pixel value for the target pixel in the shadow map.
5. The method according to claim 4, characterized in that Comparing the plurality of first depth values with the target pixel points respectively to obtain the plurality of comparison results includes: Converting the spatial coordinates of the target pixel point in the display interface into the world coordinates of the target pixel point, and then converting the world coordinates of the target pixel point into NDC coordinates in an NDC space where a top-down orthogonal camera is located, wherein a direction of a Z axis in the NDC coordinates is the same as a direction of an axis where the first depth value is located; Comparing the Z-axis coordinate value of the target pixel point in the NDC coordinate with each first depth value of the plurality of first depth values; When the Z-axis coordinate value of the target pixel point in the NDC coordinates is less than the first depth value, and the Z-axis coordinate value of the target pixel point in the NDC coordinates is less than a second depth value of a water body at the same position, determining that a comparison result between the target pixel point and the first depth value is a first value, wherein the first value is used to indicate the presence of snow; When the coordinate value of the Z axis in the NDC coordinates of the target pixel point is not less than the first depth value, and / or the coordinate value of the Z axis in the NDC coordinates of the target pixel point is not less than the second depth value, the comparison result of the target pixel point and the first depth value is determined to be a second value, wherein the second value is used to indicate that there is no snow.
6. The method according to claim 4, characterized in that Setting a pixel value for the target pixel in the shadow map using the weighted result includes: According to the following formula, the pixel value Value is set for the target pixel point in the shadow map using the weighted result: Value=Shadow*2 0.8log[1.5*(NormalY-0.2)] , Among them, Shadow is the weighted result, log() is the logarithmic function, and NormalY represents the component of the normal vector of the target pixel point on the Y axis.
7. The method according to claim 3, characterized in that Before setting a pixel value for the target pixel in the shadow map based on multiple comparison results and multiple weights between the target pixel and the multiple first depth values, the method further includes: Obtaining the coordinate offset between the target pixel and adjacent pixel points; The UV value and the coordinate offset value of the target pixel point are used to perform sampling in an offset texture to obtain the UV offset value, wherein the offset texture is used to provide a random UV offset value.
8. A device for rendering weather in a game, used to implement the method for rendering weather in a game as claimed in any one of claims 1 to 7, characterized in that: include: an acquisition unit, configured to acquire 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 indicated location, and the three-dimensional game scene is a game scene rendered on a smart terminal; a generating unit, configured to generate a shadow map representing the extent of snow coverage and having a natural transition of snow edges, using the depth map of the weather obstruction body; A rendering unit is used to render the snow in the three-dimensional game scene on the display interface of the smart terminal 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.
9. 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 7 when executed.
10. 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 7 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
Cited By
Geometric enhancement method and 4D weather simulation and editing method based on environment reconstruction
CN120707736A