Method and device for rendering weather in game scenes, storage medium, and electronic device
By obtaining the depth map of the weather occluder and generating a shadow map in the game scene, combined with the effect map of the rain weather object, efficient rendering of rain in the game scene is achieved, solving the problem of complex operation and improving the realism and user experience of the game.
Patent Information
- Application Number
- CN202111629422.1
- 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
In the existing technology, weather rendering operations in game scenes are complex, which makes it difficult to meet the needs of rapid version updates and affects user experience.
By obtaining the depth map of the weather occluder in the three-dimensional game scene, a shadow map is generated, and the shadow map and the effect map of the rain weather object are used to render the rain weather object in the display interface, including the raindrop surface, ripples and flowing water effects, to simulate a real rain scene landscape.
It provides a universal rain rendering solution for game scenes, reducing development workload and investment costs, avoiding the need to develop rain-related scenes for different maps, and improving the game's realism and user experience.
Smart Images

Figure CN116351067B_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 scene, 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, additional rain scenes 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 scene, 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 scene 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; 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 rain coverage at the represented position; and rendering the rain weather object in the three-dimensional game scene in the display interface using the shadow map and an effect map of the rain weather object.
[0007] Optionally, a rainy weather object in a three-dimensional game scene is rendered in a display interface using a shadow map and an effect map of a rainy weather object, including: using a shadow map to determine a target area where a rainy weather object exists in the display interface; and using at least one of a raindrop surface effect map, a raindrop dynamic effect map, and a raindrop reflection effect map to render a rainy weather object in the three-dimensional game scene in the display interface.
[0008] Optionally, a rainy weather object within a three-dimensional game scene is rendered in a display interface using a raindrop dynamic effect map, including: driving the normal map to change through a sine function, and using the changed normal map to sample the ripple effect map to render a rainy weather object with a ripple effect within the three-dimensional game scene in the display interface, wherein the normal map is used to express the ups and downs of the ripple effect, and the raindrop dynamic effect map includes the ripple effect map.
[0009] Optionally, a rainy weather object within a three-dimensional game scene is rendered in a display interface using a raindrop dynamic effect map, including: sampling along a first direction in a shaking effect map at specified time intervals using the world coordinates of the pixel points on the surface of the rainy weather object, and multiplying the world coordinates of the pixel points on the surface of the rainy weather object by a scaling factor, and then sampling along a second direction in the shaking effect map at specified time intervals, rendering a rainy weather object with a shaking effect in the three-dimensional game scene in the display interface, wherein the raindrop dynamic effect map includes a shaking effect map, the scaling factor is less than 1, and the first direction is opposite to the second direction.
[0010] Optionally, in the process of rendering a rainy weather object in a three-dimensional game scene in a display interface using a raindrop dynamic effect map, the method further includes: using interpolation processing of the model normal and the rain flow normal to achieve a disturbance effect of side water flow.
[0011] Optionally, using a raindrop dynamic effect map to render a rain weather object in a three-dimensional game scene in the display interface also includes: using the surface normal of the rain weather object to calculate the transparency coefficient of the side water flow according to the following formula to achieve a water flow effect only on the side:
[0012]
[0013] Opacity represents the transparency coefficient of the side water flow, Normal.y represents the component of the surface normal of the rain weather object on the Y-axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, sin() represents the sine function, and saturate() is used to directly return the value in the brackets as the transparency coefficient when the value in the brackets is between 0 and 1, directly return 1 as the transparency coefficient when the value in the brackets is greater than 1, and directly return 0 as the transparency coefficient when the value in the brackets is less than 0.
[0014] Optionally, in the process of rendering a rainy weather object in a three-dimensional game scene in a display interface using a raindrop surface effect map, the method further includes: using the surface normal of the rainy weather object to calculate the transparency coefficient of the raindrops according to the following formula to achieve a raindrop effect on only the upper surface of the rainy weather object:
[0015]
[0016] Opacity represents the transparency coefficient of raindrops, Normal.y represents the component of the surface normal of the rain weather object on the Y axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, and saturate() is used to directly return the value in the brackets as the transparency coefficient when it is between 0 and 1. When the value in the brackets is greater than 1, it directly returns 1 as the transparency coefficient. When the value in the brackets is less than 0, it directly returns 0 as the transparency coefficient.
[0017] Optionally, a raindrop reflection effect map is used to render a rainy weather object in a three-dimensional game scene in a display interface, including: using the surface normal of the disturbed rainy weather object to sample the raindrop reflection effect map, and rendering the rainy weather object in the three-dimensional game scene in the display interface according to the sampled reflection color.
[0018] According to another aspect of an embodiment of the present application, a device for rendering weather in a game scene 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 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 rain coverage at the represented position; a rendering unit for using the shadow map and the effect map of the rain weather object to render the rain weather object in the three-dimensional game scene in the display interface.
[0019] 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.
[0020] 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.
[0021] 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.
[0022] In an embodiment of the present application, a depth map of a weather obstruction in a three-dimensional game scene is obtained, and a shadow map of a display interface of a smart terminal is generated based on the depth map of the weather obstruction. The shadow map and the effect map of the rain weather object are used to render the rain weather object in the three-dimensional game scene in the display interface, thereby providing a general rain rendering solution for a game scene. The rain weather simulation of this solution is mainly the interactive effect of the object model on rain (rather than the rain effect when it rains), such as ripples on the water surface, raindrop effects on the upper surface of the model, and water flowing effects on the side of the model. By utilizing the numerous interactive effects between objects and rain, a more realistic rain scene landscape can be simulated without developing rain-related 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
[0023] 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:
[0024] Figure 1 is a schematic diagram of a hardware environment for a method for rendering weather in a game scene according to an embodiment of the present application;
[0025] Figure 2 is a flowchart of an optional method for rendering weather in a game scene according to an embodiment of the present application;
[0026] Figure 3 is a schematic diagram of an optional raindrop according to an embodiment of the present application;
[0027] Figure 4 is a schematic diagram of an optional transparency curve according to an embodiment of the present application;
[0028] Figure 5 is a schematic diagram of an optional transparency curve according to an embodiment of the present application;
[0029] Figure 6 is a schematic diagram of an optional device for rendering weather in a game scene according to an embodiment of the present application; and
[0030] Figure 7 This is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] 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.
[0032] 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.
[0033] According to one aspect of the embodiments of the present application, a method embodiment of a method for rendering weather in a game scene is provided.
[0034] Optionally, in this embodiment, the above-mentioned method for rendering weather in the game scene 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 services (such as game services, application services, etc.) 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.
[0035] The method for rendering weather in a game scene according to an embodiment of the present application can be executed by server 103, i.e., the rendering operation is completed on server 103, and then the screen is transmitted to the terminal for display. Alternatively, it can be executed by terminal 101, i.e., terminal 101 independently renders and displays the game screen. The method for rendering weather in a game scene according to an embodiment of the present application can also be executed by a client installed thereon. The following description will take the case where the rendering operation is performed by terminal 101 as an example.
[0036] Figure 2This is a flow chart of an optional method for rendering weather in a game scene according to an embodiment of the present application. Figure 2 As shown, the method may include the following steps:
[0037] 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.
[0038] 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 rain coverage at the indicated location.
[0039] In step S26 , the terminal uses the shadow map and the effect map of the rainy weather object to render the rainy weather object in the three-dimensional game scene in the display interface.
[0040] Through the above steps, a depth map of the weather obstruction in the three-dimensional game scene is obtained, and a shadow map of the display interface of the smart terminal is generated according to the depth map of the weather obstruction. The shadow map and the effect map of the rain weather object are used to render the rain weather object in the three-dimensional game scene in the display interface, thereby providing a universal rain rendering solution in the game scene without developing rain-related 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.
[0041] The rainy weather simulation of this solution does not simulate the raining process, but rather the interactive effects of the object model on the rain, such as ripples on the water surface, raindrop effects on the upper surface of the model, and water flowing on the side of the model. By utilizing the numerous interactive effects between objects and weather (rain), a more realistic rainy scene can be simulated. The following is a detailed description of the technical solution of this application in conjunction with specific steps:
[0042] In the technical solution provided in step S22, the terminal generates a depth map of weather obstructions (such as buildings, building eaves, umbrellas, water surfaces, etc.) in the three-dimensional game scene.
[0043] 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.
[0044] Optionally, generating a depth map of a weather obstruction in a three-dimensional game scene includes steps S222 to S224:
[0045] 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.
[0046] 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:
[0047] 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;
[0048] 2) When the moving distance reaches a specified threshold (e.g., 10 meters), the trigger condition is determined to be satisfied;
[0049] 3) If the moving distance does not reach the specified threshold, it is determined that the trigger condition is not met.
[0050] 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:
[0051] 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.
[0052] 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.
[0053] 2) When there are other models besides static scene models in the target area (such as rivers, seas, ponds, flowing leaves, etc.), 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 occlusion body includes the second depth map.
[0054] As an optional implementation, the above solution is equivalent to WeatherOccluderDepthPass, whose 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.
[0055] 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 one is the depth texture of the static occluder (corresponding to the first depth map), and the other one is the other depth texture (corresponding to the second depth map.
[0056] This pass is used to determine where in the scene to receive rain. It is a top-down rendered image. 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 of WeatherOccluderDepthPass is as follows:
[0057] 1) Use a top-down orthographic camera to render the scene depth map to the first block depth texture in the texture array. This approach requires low precision and covers a large area. 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 rain rendering update rule, which is selected by the client based on actual conditions. Every time the player moves a certain distance, a rain rendering update is triggered. Here, distance is used as the judgment condition; for example, if the player moves beyond a certain distance, a rain update is triggered.
[0058] 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 property 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 rain rendering process, so they are not the default occluders and are optional for artists.
[0059] 3) Render the depth of the water surface to the depth texture of the second block in the texture array.
[0060] 4) The ViewProjection matrix of the orthographic camera during rendering needs to be saved for use in subsequent passes. Ordinary cameras are perspective cameras. Orthographic cameras render from top to bottom and have no perspective effect where things get bigger when they are near and smaller when they are far away. They are used in the first step to render depth and determine the depth values of occluders and occluded objects.
[0061] 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 shield, and each pixel in the shadow map is used to record the degree of rain coverage at the represented location.
[0062] 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 rain coverage at the represented location.
[0063] 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:
[0064] 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.
[0065] 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.
[0066] Step S244: Compare the coordinate value of the Z axis in the NDC coordinates 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 coordinates is the same as the direction of the axis where the depth value is located. The first mark is used to indicate rain, and the second mark is used to indicate no rain.
[0067] Step S246: Sample the texture representing the rainy weather object based on the labels of each screen pixel of the display interface to obtain the shadow map of the display interface. This includes the following two parts:
[0068] 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 other models, the screen pixel of the display interface is marked with a first mark;
[0069] 2) 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, that is, it is blocked by a static weather obstruction, blocked by other models, or blocked by both at the same time, the screen pixel of the display interface is marked with a second mark.
[0070] As an optional implementation, the above solution is equivalent to WeatherOccluderMaskPass. Its main function is to output a rain shadow map (or RainShadow) after BasePass and before RainBasePass and other passes that depend on WeatherOccluderMask, marking the degree of rain coverage of each pixel. The output format is R8G8B8A8_Unorm, and the size is equal to the screen size ScreenSize.
[0071] WeatherOccluderMaskPass is used to determine where there is rain on the current screen. It is necessary 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 rain, and if it is smaller, there is rain.
[0072] The implementation of WeatherOccluderMaskPass is as follows:
[0073] 1) By transforming the screen pixel's world coordinates into the orthographic camera's NDC space used by the WeatherDepthPass, the z coordinate is compared with the depth value sampled from WeatherDepth (1 or 0, 1 for rain, 0 for no rain, 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.
[0074] 2) The above result will be very harsh at the junction. You can sample the surrounding pixels multiple times and average the results to get a result with a gradual transition.
[0075] 3) To add randomness to the intersection to achieve a more natural effect, you can do the following:
[0076] a) Traverse the surrounding n*n pixels, sampling an offset texture with the offset UV. The resulting offset is used as the UV offset for 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 raining; if all points are greater than the depth of the surrounding points, it means it is not raining; if some points are less than the depth of the surrounding points, it means it is at the edge.
[0077] 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 rain.
[0078] 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 rain to make the edge transition more natural.
[0079] b) During the traversal, the uv+uvOffset of the current pixel is used as the new uv to sample from the depth map and compare to obtain the result, 1 or 0, recorded as result.
[0080] c) In the traversal, the uv+uvOffset of the current pixel is used as the uv to sample from another weighted 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.
[0081] In the technical solution provided in step S26, the terminal uses the shadow map and the effect map of the rainy weather object to render the rainy weather object in the three-dimensional game scene in the display interface.
[0082] Optionally, in the technical solution of step S26, the shadow map can be used to first determine the target area where the rainy weather object exists in the display interface (i.e., the spatial area where it is required to rain), and the raindrop surface effect map (hereinafter referred to as the map) can be used to determine the target area where the rainy weather object exists in the display interface (i.e., the spatial area where it is required to rain). Figure 1 , RainDrop_mk.dds), raindrop dynamic effect map (hereinafter referred to as the map Figure 2 , RainFlow_n.dds) and raindrop reflection effect map (hereinafter referred to as the map Figure 3 , Reflection.dds), rendering the rain weather object in the three-dimensional game scene in the display interface.
[0083] In the above solution, the rain weather object in the three-dimensional game scene is rendered in the display interface using the raindrop dynamic effect map, including at least one of the following:
[0084] 1) Using a sine function to drive the normal map to change, the changed normal map is used to sample the ripple effect map to render a rain weather object with a ripple effect in the 3D game scene on the display interface. The normal map is used to express the fluctuations of the ripple effect. The raindrop dynamic effect map includes the ripple effect map;
[0085] 2) sampling the world coordinates of the pixels on the surface of the rainy weather object in a first direction in a shaking effect map at a specified time interval, and multiplying the world coordinates of the pixels on the surface of the rainy weather object by a scaling factor, and sampling the second direction in the shaking effect map at a specified time interval, rendering a rainy weather object with a shaking effect in a three-dimensional game scene on a display interface. The raindrop dynamic effect map includes a shaking effect map. The shaking effect map and the ripple effect map can be integrated into one map, namely, the raindrop dynamic effect map. The scaling factor is less than 1, and the first direction is opposite to the second direction.
[0086] 3) Using the interpolation between the model normal and the rain flow normal to achieve the disturbance effect of the side water flow;
[0087] 4) Using the surface normal of the rain weather object, calculate the transparency coefficient of the side water flow according to the following formula to achieve the effect of water flow only on the side:
[0088]
[0089] Opacity represents the transparency coefficient of the side water flow, Normal.y represents the component of the surface normal of the rain weather object on the Y-axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, sin() represents the sine function, and saturate() is used to directly return the value in the brackets as the transparency coefficient when the value in the brackets is between 0 and 1, directly return 1 as the transparency coefficient when the value in the brackets is greater than 1, and directly return 0 as the transparency coefficient when the value in the brackets is less than 0.
[0090] In the above solution, when rendering the rain weather object in the 3D game scene in the display interface using the raindrop surface effect map, the surface normal of the rain weather object can be used to calculate the transparency coefficient of the raindrops according to the following formula to achieve the raindrop effect of only the upper surface of the rain weather object:
[0091]
[0092] Opacity represents the transparency coefficient of raindrops, Normal.y represents the component of the surface normal of the rain weather object on the Y axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, and saturate() is used to directly return the value in the brackets as the transparency coefficient when it is between 0 and 1. When the value in the brackets is greater than 1, it directly returns 1 as the transparency coefficient. When the value in the brackets is less than 0, it directly returns 0 as the transparency coefficient.
[0093] In the above scheme, when using the raindrop reflection effect map to render the rainy weather object in the three-dimensional game scene in the display interface, the surface normal of the disturbed rainy weather object can be used to sample the raindrop reflection effect map, and the rainy weather object in the three-dimensional game scene can be rendered in the display interface according to the sampled reflection color.
[0094] As an optional embodiment, the technical solution of the present application is further described below in conjunction with specific implementation methods:
[0095] In this solution, the mapping files involved include: Figure 1 (RainDrop_mk.dds), used to simulate the raindrop effect on the surface of the model; Figure 2 (RainFlow_n.dds), rain ripple normal map, used to simulate the water sloshing on the model surface and the side water flow effect; Figure 3 (Reflection.dds), used to simulate the reflection effect of rain.
[0096] In specific implementation, the following mixed modes can be used:
[0097] ResultColor=DestColor*SrcAlpha+SrcColor*1.
[0098] ResultColor represents the final color, DestColor represents the color in the frame buffer (ie, the scene color), SrcAlpha represents the transparency of the current drawing patch (ie, the transparency of the accumulated water layer), and SrcColor represents the color of the current drawing patch (ie, the accumulated water color).
[0099] 1) Use stickers Figure 2 Achieve raindrop ripple effect (calculating lighting and reflection vectors requires considering this normal value)
[0100] The normal map of rain ripples can be generated using 3Dmax to show the ups and downs of the ripple effect. The calculation of lighting (PBR) and reflection vector (part of the lighting algorithm, the normal map is required to calculate the reflection vector of the line of sight) can be completed using a general method.
[0101] Since the Mask map of raindrops has Mipmap, direct sampling using the Sample function will sample low-level Mipmaps on some model surfaces parallel to the line of sight, and the raindrops will become grids at this time. Therefore, SampleLevel is used when sampling the transparency value of the raindrop color and the ra channel (the ra channel stores the data for generating ripple animation) on the Mask map. Practice has shown that when all data are sampled using SampleLevel, since SampleLevel always samples the 0th level of the mipmap, the farther the drawn pixel is from the camera, the different pixels will be skipped when the camera moves, causing mutations and causing more serious scene flickering. Therefore, the gb channel on the Mask map (gb stores normal data) continues to use Sample for sampling.
[0102] The ripple effect is generated by driving the normal map change through time changes, the change of the Z axis (-1 and 1, indicating the disappearance and appearance of raindrops), and the sin value can generate a wave effect.
[0103] 2) Achieve the water surface shaking effect on the upper surface (this normal value is not considered when calculating the lighting, only when calculating the emission vector), refraction effect, and see the objects in the scene twisting effect through the water surface (simple refraction effect).
[0104] Use the world coordinates (X, Z) + game time, and world coordinates (X, Z) * 0.8 – game time (the symbols + and - point to two opposite directions for sampling at a time interval. For example, adding game time generates animation, and time data exceeding 1 is truncated, such as ≤ 1s, to generate a loop) of the model surface pixel as texture coordinates to sample the RainFlow_n.dds map once respectively, and use the superposition result of the two normals to perturb the world normal of the model.
[0105] The reason for the world coordinate (X, Z)*0.8 is as follows: if the UV Tiling (UV coordinate scaling factor, such as 1) is the same for both samples, then Figure 3 As shown, when the offset of UV0 and UV1 is less than 0, the red position (i.e., the dark gray box) and the blue position (i.e., the light gray box) are seen moving close to each other; when the offset of UV0 and UV1 exceeds 1, the positions of blue and red are swapped, but the naked eye cannot distinguish them, thinking that the red and blue have changed their moving directions; after adjusting the tiling of UV1 from 1 to 0.8, the blue and red positions can be distinguished, and it is found that they have not changed their moving directions.
[0106] 3) Achieve side water flow effect (calculate illumination and reflection vectors taking this normal value into account)
[0107] The effect of water flowing on scene objects after being rained on is the randomness of water flowing on the object's surface due to disturbances in various directions. Since this is a side-flow effect, only the X and Y coordinates are considered. The world coordinates (X, -Y - game time) and (Z, -Y - game time) of the model surface pixels are used as the texture coordinates of the rain flow map (RainFlow_n.dds). RainFlow_n.dds is sampled twice with different UV and time scales. The resulting normal is interpolated according to the intensity value of the model normal deflected to the YZ plane (interpolation is the fusion of the model normal YZ plane and the rain flow normal to produce flow). The resulting normal value XY of the rain flow map (RainFlow_n.dds) is used to perturb the model surface normal.
[0108] The model surface is concave and convex, and the water flow normal is superimposed on the model, that is, the disturbance effect of the side water flow is achieved through interpolation processing. The normal value of the side water flow is mixed with the model performance normal to achieve the disturbance effect on the model surface.
[0109] 4) Achieve reflection effect
[0110] The disturbed model surface normal is used to sample the environment sphere map Reflection.dds (a darker map) as the reflection color to achieve the cloudy effect of a rainy day.
[0111] 5) Control that only the upper surface has raindrop effect (the model surface has raindrop effect, and the bottom surface has no raindrop effect)
[0112] Use the Y value of the model surface normal as the threshold and calculate the transparency coefficient of the raindrop according to the following formula (the transparency curve is as follows Figure 4 shown):
[0113] Normal.y is the Y value of the normal of the current pixel of the model (indicating the up and down direction), RAIN_DROP_RANGE_MIN is the minimum range of raindrops, and RAIN_DROP_RANGE_MAX is the maximum range of raindrops.
[0114] 6) Realize the water flow effect only on the side
[0115] Use the Y value of the model surface normal to calculate the transparency coefficient of the flowing water according to the following formula (the transparency curve is as follows Figure 5 shown):
[0116]
[0117] PI is π. When you want to standardize the color value to between 0 and 1, you can use the saturate function (the function of saturate(x) is that if the value of x is less than 0, the return value is 0. If the value of x is greater than 1, the return value is 1. If x is between 0 and 1, it directly returns the value of x).
[0118] This solution uses transparency to determine whether a raindrop effect is produced on the model surface. If both transparency values are 0 (the plane rain surface is completely parallel), it means that there is no raindrop effect on the upper and side surfaces, indicating that it is the lower surface of the model, and it can be excluded from the calculation or the calculation result is 0, eliminating the previous effects (raindrop ripples, disturbances). If it is not 0, these two values are used as a coefficient and multiplied by the rain flow normal result. The actual effect is to reduce the intensity of the rain flow normal and reduce the actual effect of the rain flow.
[0119] 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.
[0120] 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.
[0121] According to another aspect of an embodiment of the present application, a device for rendering weather in a game scene for implementing the above-mentioned method for rendering weather in a game scene is also provided. Figure 6 FIG. 1 is a schematic diagram of an optional device for rendering weather in a game scene according to an embodiment of the present application. Figure 6 As shown, the device may include:
[0122] An acquisition unit 61 is used to obtain 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 63 is used to generate a shadow map of a display interface of a 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 rain coverage at the represented position; a rendering unit 65 is used to render the rain weather object in the three-dimensional game scene in the display interface using the shadow map and the effect map of the rain weather object.
[0123] It should be noted that the acquisition unit 61 in this embodiment can be used to execute step S22 in the embodiment of the present application, the generation unit 63 in this embodiment can be used to execute step S24 in the embodiment of the present application, and the rendering unit 65 in this embodiment can be used to execute step S26 in the embodiment of the present application.
[0124] 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.
[0125] Through the above module, a depth map of the weather obstruction in the three-dimensional game scene is obtained, and a shadow map of the display interface of the smart terminal is generated according to the depth map of the weather obstruction. The shadow map and the effect map of the rain weather object are used to render the rain weather object in the three-dimensional game scene in the display interface, thereby providing a universal rain rendering solution in the game scene without having to develop rain-related scenes for different maps. It 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.
[0126] Optionally, the rendering unit is also used to: use the shadow map to determine the target area where the rainy weather object exists in the display interface; use at least one of the raindrop surface effect map, the raindrop dynamic effect map and the raindrop reflection effect map to render the rainy weather object in the three-dimensional game scene in the display interface.
[0127] Optionally, the rendering unit is also used to: drive the normal map to change through a sine function, and use the changed normal map to sample the ripple effect map to render a rainy weather object with a ripple effect in the three-dimensional game scene in the display interface, wherein the normal map is used to express the ups and downs of the ripple effect, and the raindrop dynamic effect map includes the ripple effect map.
[0128] Optionally, the rendering unit is also used to: sample the world coordinates of the pixel points on the surface of the rainy weather object in the shaking effect map along a first direction at a specified time interval, and multiply the world coordinates of the pixel points on the surface of the rainy weather object by a scaling factor, and then sample the world coordinates of the pixel points on the surface of the rainy weather object in a second direction at a specified time interval, and render a rainy weather object with a shaking effect in the three-dimensional game scene in the display interface, wherein the raindrop dynamic effect map includes a shaking effect map, the scaling factor is less than 1, and the first direction is opposite to the second direction.
[0129] Optionally, the rendering unit is also used to achieve the disturbance effect of side water flow by interpolating the model normal and the rain flow normal in the process of rendering the rain weather object in the three-dimensional game scene in the display interface using the raindrop dynamic effect map.
[0130] Optionally, the rendering unit is further configured to: use the surface normal of the rain weather object to calculate the transparency coefficient of the side flowing water according to the following formula, so as to achieve a water flowing effect only on the side:
[0131]
[0132] Opacity represents the transparency coefficient of the side water flow, Normal.y represents the component of the surface normal of the rain weather object on the Y-axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, sin() represents the sine function, and saturate() is used to directly return the value in the brackets as the transparency coefficient when the value in the brackets is between 0 and 1, directly return 1 as the transparency coefficient when the value in the brackets is greater than 1, and directly return 0 as the transparency coefficient when the value in the brackets is less than 0.
[0133] Optionally, the rendering unit is further configured to use the raindrop surface effect map to render a rain weather object in the three-dimensional game scene in the display interface, and calculate the transparency coefficient of the raindrops according to the following formula using the surface normal of the rain weather object to achieve a raindrop effect on only the upper surface of the rain weather object:
[0134]
[0135] Opacity represents the transparency coefficient of raindrops, Normal.y represents the component of the surface normal of the rain weather object on the Y axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, and saturate() is used to directly return the value in the brackets as the transparency coefficient when it is between 0 and 1. When the value in the brackets is greater than 1, it directly returns 1 as the transparency coefficient. When the value in the brackets is less than 0, it directly returns 0 as the transparency coefficient.
[0136] Optionally, the rendering unit is further used to: use the surface normal of the disturbed rain weather object to sample the raindrop reflection effect map, and render the rain weather object in the three-dimensional game scene in the display interface according to the sampled reflection color.
[0137] 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.
[0138] 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 a game scene is also provided.
[0139] 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 .
[0140] 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 in the game scene 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 in the above-mentioned game scene. 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.
[0141] 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.
[0142] Specifically, the memory 703 is used to store application programs.
[0143] The processor 701 may call the application stored in the memory 703 through the transmission device 705 to perform the following steps:
[0144] 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;
[0145] 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 rain coverage at the represented location;
[0146] The rainy weather object in the three-dimensional game scene is rendered in the display interface using the shadow map and the effect map of the rainy weather object.
[0147] The processor 701 is further configured to perform the following steps:
[0148] The world coordinates of the pixel points on the surface of the rainy weather object are sampled in the shaking effect map along a first direction at a specified time interval, and the world coordinates of the pixel points on the surface of the rainy weather object are multiplied by a scaling factor, and then sampled in the second direction in the shaking effect map at the specified time interval, and a rainy weather object with a shaking effect in the three-dimensional game scene is rendered in the display interface, wherein the raindrop dynamic effect map includes the shaking effect map, the scaling factor is less than 1, and the first direction is opposite to the second direction.
[0149] 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.
[0150] 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.
[0151] 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.
[0152] 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 a game scene.
[0153] 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.
[0154] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:
[0155] 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;
[0156] 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 rain coverage at the represented location;
[0157] The rainy weather object in the three-dimensional game scene is rendered in the display interface using the shadow map and the effect map of the rainy weather object.
[0158] Optionally, the storage medium is further configured to store program codes for executing the following steps:
[0159] The world coordinates of the pixel points on the surface of the rainy weather object are sampled in the shaking effect map along a first direction at a specified time interval, and the world coordinates of the pixel points on the surface of the rainy weather object are multiplied by a scaling factor, and then sampled in the second direction in the shaking effect map at the specified time interval, and a rainy weather object with a shaking effect in the three-dimensional game scene is rendered in the display interface, wherein the raindrop dynamic effect map includes the shaking effect map, the scaling factor is less than 1, and the first direction is opposite to the second direction.
[0160] 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.
[0161] 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.
[0162] 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.
[0163] 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.
[0164] 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.
[0165] 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.
[0166] 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.
[0167] 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.
[0168] 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 scene, 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; 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 rain coverage at the represented location; Rendering the rainy weather object in the three-dimensional game scene in the display interface using the shadow map and the effect map of the rainy weather object, including: determining a target area in the display interface where the rainy weather object exists using the shadow map; rendering the rainy weather object in the three-dimensional game scene in the display interface using at least one of a raindrop surface effect map, a raindrop dynamic effect map, and a raindrop reflection effect map; 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 Rendering a rainy weather object in the three-dimensional game scene in the display interface using a raindrop dynamic effect map includes: A sine function is used to drive the normal map to change, and the changed normal map is used to sample the ripple effect map to render a rainy weather object with a ripple effect in the three-dimensional game scene in the display interface, wherein the normal map is used to express the ups and downs of the ripple effect, and the raindrop dynamic effect map includes the ripple effect map.
3. The method according to claim 1, characterized in that Rendering a rainy weather object in the three-dimensional game scene in the display interface using a raindrop dynamic effect map includes: The world coordinates of the pixel points on the surface of the rainy weather object are sampled in the shaking effect map along a first direction at a specified time interval, and the world coordinates of the pixel points on the surface of the rainy weather object are multiplied by a scaling factor, and then sampled in the second direction in the shaking effect map at the specified time interval, and a rainy weather object with a shaking effect in the three-dimensional game scene is rendered in the display interface, wherein the raindrop dynamic effect map includes the shaking effect map, the scaling factor is less than 1, and the first direction is opposite to the second direction.
4. The method according to claim 1, wherein In the process of rendering the rain weather object in the three-dimensional game scene in the display interface using the raindrop dynamic effect map, the method further includes: The disturbance effect of lateral water flow is achieved by interpolating the model normal and the rain flow normal.
5. The method according to claim 4, characterized in that Rendering a rainy weather object in the three-dimensional game scene in the display interface using a raindrop dynamic effect map also includes: Using the surface normal of the rain weather object, the transparency coefficient of the side water flow is calculated according to the following formula to achieve the effect of water flow only on the side: Opacity represents the transparency coefficient of the side water flow, Normal.y represents the component of the surface normal of the rain weather object on the Y axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX indicates the maximum value of the raindrop falling range, sin() indicates the sine function, and saturate() is used to directly return the value in the brackets as the transparency coefficient when it is between 0 and 1, directly return 1 as the transparency coefficient when the value in the brackets is greater than 1, and directly return 0 as the transparency coefficient when the value in the brackets is less than 0.
6. The method according to claim 1, characterized in that In the process of rendering the rain weather object in the three-dimensional game scene in the display interface using the raindrop surface effect map, the method further includes: Using the surface normal of the rain weather object, the transparency coefficient of the raindrops is calculated according to the following formula to achieve the raindrop effect of only the upper surface of the rain weather object: Opacity represents the transparency coefficient of raindrops, Normal.y represents the component of the surface normal of the rain weather object on the Y-axis, RAIN_FLOW_RANGE_MIN represents the minimum value of the raindrop falling range, RAIN_FLOW_RANGE_MAX represents the maximum value of the raindrop falling range, and saturate() is used to directly return the value in the brackets as the transparency coefficient when it is between 0 and 1, directly return 1 as the transparency coefficient when the value in the brackets is greater than 1, and directly return 0 as the transparency coefficient when the value in the brackets is less than 0.
7. The method according to claim 1, characterized in that Rendering a rainy weather object in the three-dimensional game scene in the display interface using a raindrop reflection effect map includes: The disturbed surface normal of the rainy weather object is used to sample the raindrop reflection effect map, and the rainy weather object in the three-dimensional game scene is rendered in the display interface according to the sampled reflection color.
8. A device for rendering weather in a game scene, used to implement the method for rendering weather in a game scene 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 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 rain coverage at the represented location; A rendering unit is used to render the rainy weather object in the three-dimensional game scene in the display interface by using the shadow map and the effect map of the rainy weather object.
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
Fluid rendering method and device, storage medium and terminal equipment
CN111986303A
System and method for rendering shadows for a virtual environment
US20180276878A1