Snow rendering method, device, electronic device and storage medium in game scene
By combining parallax mapping and interpolation techniques to obtain the target edge information and target color information of snow in game scenes, the problem of low snow rendering performance in the prior art is solved, and efficient snow rendering effect is achieved.
Patent Information
- Application Number
- CN202310276525.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2043-03-15
AI Technical Summary
The prior art requires real-time changes in the model and a large number of calculations in the rendering of snow in game scenes, resulting in poor real-time performance of the game.
By combining parallax mapping, interpolation of target edge information and target color information obtained based on target depth, the need to change the model in real time and large-scale computing is avoided.
It realizes snow rendering without real-time changes to the model, reduces the amount of calculation during the rendering process, and improves the real-time performance of the game.
Smart Images

Figure CN116370956B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer graphics, and in particular to a method, device, electronic device and storage medium for rendering snow in a game scene. Background Art
[0002] The performance effect of the game scene can enhance the user experience and increase the player's sense of immersion. Therefore, the demand for picture details in the game also increases accordingly. Snow rendering in the game scene is one of them. The main role of snow rendering in the game is to create an atmosphere. Snow can greatly increase the richness of the game scene and can greatly increase the immersion of the game.
[0003] Currently, the snow model is generally modified dynamically through tessellation and parallel computing of a graphics processing unit (GPU).
[0004] However, the above method requires real-time changes to the model and requires large amounts of computational operations during rendering, which results in poor real-time performance of the game. Summary of the invention
[0005] In view of this, an object of the present invention is to provide a method, device, electronic device and storage medium for rendering snow in a game scene. Snow is rendered by combining parallax mapping, target edge information obtained by interpolation and target color information obtained based on target depth, thereby achieving an effect of not having to change the model in real time and without large computational operations in rendering, thereby improving the real-time performance of the game.
[0006] In a first aspect, an embodiment of the present invention provides a method for rendering snow in a game scene, the method for rendering snow in a game scene comprising:
[0007] Obtaining target world coordinate data of each to-be-rendered point in the to-be-rendered area, and sampling a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal;
[0008] Determine target color information and perform parallax mapping processing respectively through the target world coordinate data to obtain target color information and mapping results;
[0009] Interpolating the mapping result, the target depth, the target normal and preset ground normal information to obtain edge normal information;
[0010] Determine target edge information according to the edge normal information and preset snow edge normal component parameters;
[0011] The current area to be rendered is rendered based on the target color information and the target edge information.
[0012] In a second aspect, an embodiment of the present invention provides a device for rendering snow in a game scene, wherein the device for rendering snow in a game scene comprises:
[0013] A sampling module, used to obtain target world coordinate data of each to-be-rendered point in the to-be-rendered area, and sample a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal;
[0014] A mapping module, used to perform target color information determination and parallax mapping processing respectively through the target world coordinate data to obtain target color information and a mapping result;
[0015] An interpolation module, used for interpolating the mapping result, the target depth, the target normal and preset ground normal information to obtain edge normal information;
[0016] A determination module, used to determine target edge information according to the edge normal information and preset snow edge normal component parameters;
[0017] A rendering module is used to render the current area to be rendered based on the target color information and the target edge information.
[0018] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for rendering snow in the above-mentioned game scene.
[0019] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for rendering snow in the above-mentioned game scene.
[0020] The embodiments of the present invention bring the following beneficial effects:
[0021] The method, device, electronic device and storage medium for rendering snow in the above-mentioned game scene obtain the target world coordinate data of each point to be rendered in the area to be rendered, and sample the preset snow depth normal map through the target world coordinate data to obtain the target depth and target normal; determine the target color information and perform parallax mapping processing through the target world coordinate data to obtain the target color information and mapping result; interpolate the mapping result, the target depth, the target normal and the preset ground normal information to obtain the edge normal information; determine the target edge information according to the edge normal information and the preset snow edge normal component parameters; render the current area to be rendered based on the target color information and the target edge information. In this method, by combining parallax mapping, the target edge information obtained by interpolation and the target color information obtained based on the target depth to render the snow, the effect of not having to change the model in real time and not having a large amount of calculation in the rendering is achieved, thereby improving the real-time performance of the game.
[0022] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0023] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 A schematic diagram of an embodiment of a method for rendering snow in a game scene provided by an embodiment of the present invention;
[0026] Figure 2 A schematic diagram of an embodiment of a snow field effect map for storing snow depth through a channel in a snow depth normal map provided by an embodiment of the present invention;
[0027] Figure 3 A schematic diagram of another embodiment of a method for rendering snow in a game scene provided by an embodiment of the present invention;
[0028] Figure 4A schematic diagram of an embodiment of a snow effect image for sampling a preset snow depth normal map through at least one texture coordinate provided by an embodiment of the present invention;
[0029] Figure 5 A schematic diagram of an embodiment of a preset normal map provided by an embodiment of the present invention;
[0030] Figure 6 A schematic diagram of an embodiment of a snow effect image that mixes mapping results, target normals and preset ground normal information provided by an embodiment of the present invention;
[0031] Figure 7 A schematic diagram of an embodiment of a normal map with preset ground normal information provided by an embodiment of the present invention;
[0032] Figure 8 A schematic diagram of an embodiment of a snow effect image after linear interpolation processing of target depth, preset ground normal information and target fused normal information provided by an embodiment of the present invention;
[0033] Fig. 9 A schematic diagram of an embodiment of a processed ground normal map provided by an embodiment of the present invention;
[0034] Fig.10 A schematic diagram of an embodiment of a snow effect diagram of snow edge information provided by an embodiment of the present invention;
[0035] Fig.11 A schematic diagram of an embodiment of a snow field effect diagram of target edge information provided by an embodiment of the present invention;
[0036] Fig.12 A schematic diagram of a snow rendering device in a game scene provided by an embodiment of the present invention;
[0037] Fig.13 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0039] Whether it is a client game or a mobile game, the performance effect of the game scene can enhance the user experience and increase the player's sense of immersion. Therefore, the requirements for the details of the pictures in the game are getting higher and higher, and the requirements for the rendering technology of snow in the game scene are also getting higher and higher, for example, the rendering of cartoon snow. The main role of snow rendering in the game is to create an atmosphere. Snow can greatly increase the richness of the game scene. Game planners can greatly increase the immersion of the game by coordinating the design of snow gameplay. In the prior art, for some realistic-style games with high requirements for snow, the snow model is generally modified dynamically through the Tessellation method and the parallel calculation of the Graphics Processing Unit (GPU). Among them, for games with lower requirements for snow, the snow rendering is achieved only through the more conventional lighting model of color and normal maps. The following problems exist in the snow rendering methods in the prior art: Although some high-demand snow rendering solutions have good effects, they consume a lot of gameplay and are not applicable to current mobile games. Some large client games are applicable, but there may be some lag; the above snow rendering solutions are more suitable for realistic games; for some low-demand snow rendering solutions, although there are no performance problems, the effects can no longer meet the expectations of many games. In summary, the snow rendering solutions in the game scenes in the prior art require real-time changes to the model and require large amounts of computational operations during rendering, resulting in poor real-time performance of the game.
[0040] Based on the above, the embodiments of the present invention provide a method, device, electronic device and storage medium for rendering snow in a game scene, which are mainly used in games and can be, but not limited to, suitable for rendering snow in a cartoon style.
[0041] In one embodiment of the present invention, the method for rendering snow in a game scene can be run on a terminal device or a server. The terminal device can be a local terminal device. When the method for rendering snow in a game scene is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0042] In an optional real-time mode, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated, the storage and operation of the information interaction method are completed on the cloud game server, and the role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the terminal device for information processing is a cloud game server in the cloud. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0043] In an optional embodiment, the terminal device may be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.
[0044] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 An embodiment of a method for rendering snow in a game scene in an embodiment of the present invention comprises the following steps:
[0045] Step 101 , obtaining target world coordinate data of each point to be rendered in the area to be rendered, and sampling a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal.
[0046] Among them, the area to be rendered is used to indicate the area where the snow is located in the game scene. The area to be rendered corresponds to the snow model. The area to be rendered is composed of a grid. The smallest unit of the grid is not specifically limited here. As an example but not a limitation, the smallest unit of the grid is a triangular grid, that is, each point to be rendered in the above-mentioned area to be rendered can correspond to each vertex in each triangular grid. The target world coordinate data of each point to be rendered is the target world coordinate data corresponding to the position of each vertex in each triangular grid. The above-mentioned target world coordinate data is used to indicate the target component coordinates in the world coordinates. For example, the target component is the x-axis component and the y-axis component, and the target world coordinate data is the x-axis component coordinate and the y-axis component coordinate in the world coordinates. The above-mentioned snow depth normal map includes the depth information and normal information of the object surface of the model corresponding to the snow. The depth information is used to indicate the depth of the color of the snow. Further, the depth information can be understood as the thickness information of the snow; the depth of the snow is stored through a channel in the snow depth normal map, which can be understood as where the snow appears first and where it appears later on the ground. Please refer to Figure 2 ,in, Figure 2 Figure (1) in the figure represents the ground, Figure 2 Figures (2) and (3) in the figure show where snow falls first and where it falls later on the ground until the ground is completely covered with snow.
[0047] The target world coordinate data is converted to obtain converted coordinates, i.e., at least one texture coordinate, and a preset snow depth normal map is sampled through the converted coordinates (i.e., at least one texture coordinate) to obtain a target depth and a target normal, wherein the target depth is depth information obtained by sampling the preset snow depth normal map through the target texture coordinates, and the target normal is normal information obtained by sampling the preset snow depth normal map through the target texture coordinates.
[0048] It should be noted that when the number of the at least one texture coordinate is one, the target texture coordinate is the texture coordinate; when the number of the at least one texture coordinate is more than one, the target texture coordinate is one of the at least one texture coordinates that meets the preset conditions. The preset conditions are not limited here and are set according to specific needs.
[0049] Step 102, target color information determination and parallax mapping processing are performed respectively through the target world coordinate data to obtain target color information and mapping results.
[0050] In the above step 101, the target world coordinate data can be converted to obtain at least one texture coordinate, and the preset snow basic color map can be sampled through the at least one texture coordinate to obtain the sampled basic color information, and the target color information is obtained by combining the sampled basic color information and the target depth. The height map corresponding to the preset snow basic color map is sampled through at least one texture coordinate to obtain the sampled height information, and the sampled height information and the at least one texture coordinate are subjected to parallax mapping to obtain a mapping result.
[0051] In one implementation, when the number of the at least one texture coordinate is more than one, a preset snow basic color map can be sampled through at least one texture coordinate to obtain the sampled basic color information, and then the sampled basic color information is subjected to smooth transition processing to obtain the processed basic color information, and the target color information is obtained by combining the processed basic color information and the target depth. The repetition of the target color information is avoided by sampling multiple texture coordinates, and the accuracy of the target color information is improved. After the sampled height information is obtained by sampling a height map corresponding to the preset snow basic color map through at least one texture coordinate, the sampled height information is subjected to mean processing (or smooth transition processing) to obtain height mean information, so as to achieve diversity of height information, avoid repetition of height information and improve the accuracy of height information, and perform parallax mapping processing on the height mean information and the target texture coordinates in at least one texture coordinate to obtain a mapping result.
[0052] Step 103 , interpolating the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information.
[0053] Determine candidate fused normal information based on the mapping result and the target normal, perform linear interpolation processing and mixing based on the preset ground normal information and the candidate fused normal information to obtain the target fused normal information; obtain the smooth transition value of the target depth, and calculate the smooth transition value of the target depth, the preset ground normal information and the target fused normal information through a preset linear interpolation function to obtain the edge normal information.
[0054] Step 104: determining target edge information according to the edge normal information and preset snow edge normal component parameters.
[0055] Snow edge information is obtained based on the target depth and the target preset parameters, wherein the target preset parameters may include a preset snow amount control parameter and a preset edge tolerance parameter, and the preset snow amount control parameter is used to control the amount of snow. The target edge information is determined based on the edge normal information, the snow edge information, and the preset snow edge normal component parameter. In one implementation, the target edge information is determined based on the edge normal information, the snow edge information, the preset snow edge normal component parameter, and the preset snow edge normal component parameter, and the preset snow edge normal component parameter is used to indicate a reduction in a target component of the normal at the edge.
[0056] Step 105 , rendering the current area to be rendered based on the target color information and the target edge information.
[0057] The corresponding shader and bidirectional reflectance distribution function are called to perform physically based rendering (PBR) of the current area to be rendered based on the target color information and the target edge information.
[0058] The snow rendering method in the above-mentioned game scene combines parallax mapping, target edge information obtained by interpolation, and target color information obtained based on target depth to render snow, thereby achieving the effect of not having to change the model in real time and without large computational operations in rendering, thereby improving the real-time performance of the game.
[0059] See also Figure 3 A schematic diagram of another embodiment of a method for rendering snow in a game scene is shown, wherein the rendering of snow in the game scene comprises the following steps:
[0060] Step 301 , obtaining target world coordinate data of each point to be rendered in the area to be rendered, and sampling a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal.
[0061] In one implementation, the above-mentioned step 301 specifically includes: obtaining world coordinate information of each to-be-rendered point in the to-be-rendered area, and extracting a target component of the world coordinate information of each to-be-rendered point to obtain target world coordinate data; converting the target world coordinate data by presetting user control parameters and at least one preset coefficient to obtain at least one texture coordinate; sampling a preset snow depth normal map by at least one texture coordinate to obtain at least one depth and at least one normal; extracting at least one depth and at least one normal respectively to obtain a target depth and a target normal, wherein the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling a target texture coordinate.
[0062] The above target components are used to indicate the x-axis component and the y-axis component. The above target world coordinate data includes the x-axis component and the y-axis component of the world coordinates. The above preset user control parameters are parameters controlled by the user, that is, parameters that the user can edit. The above preset user control parameters are used to reduce the target world coordinate data. It can be understood that the target world coordinate data is too large and a parameter is needed to make the target world coordinate data smaller. The number of the above at least one depth corresponds to the number of the above at least one normal. The above target depth is used to indicate the depth information obtained by sampling the snow depth normal map based on the target texture coordinates in at least one texture coordinate. The above target normal is used to indicate the normal information obtained by sampling the snow depth normal map based on the target texture coordinates. The above target texture coordinates are texture coordinates obtained by performing transformation processing on the target world coordinate data through a target preset coefficient. The above at least one preset coefficient includes the target preset coefficient.
[0063] It should be noted that when the number of the above at least one preset coefficient is one, this preset coefficient is determined as the target preset coefficient. When the number of the above at least one preset coefficient is more than one, the preset coefficient with the at least one preset coefficient being the target value is determined as the target preset coefficient. When the number of both the above at least one depth and the above at least one normal is one, this depth is determined as the target depth and this normal is determined as the target normal. When the number of both the above at least one depth and the above at least one normal is more than one, the depth obtained by sampling the target texture coordinates is extracted from at least one depth to obtain the target depth, and the normal obtained by sampling the target texture coordinates is extracted from at least one normal to obtain the target normal. By way of example and not limitation, preferably in the embodiments of the present invention, the number of at least one texture coordinate is three, and correspondingly, the number of at least one depth is three.
[0064] By sampling the depth of snow through different texture coordinates (that is, sampling the preset snow depth normal map through at least one texture coordinate), the sense of repetition displayed on the snow ground is eliminated, and the effect is shown in Figure 4 ; Sampling the target depth and the target normal through the transformed texture coordinates lays a foundation for better display effects in the subsequent snow rendering.
[0065] In one implementation manner, the step of performing transformation processing on the target world coordinate data through the above preset user control parameters and at least one preset coefficient to obtain at least one texture coordinate includes: performing reduction processing on the target world coordinate data through the preset user control parameters to obtain the initially transformed target world coordinate data; multiplying each of the at least one preset coefficient by the target world coordinate data to obtain at least one texture coordinate. The number of the at least one preset coefficient is more than one, and the number of at least one texture coordinate corresponds to the number of the at least one preset coefficient.
[0066] As an example but not limitation, the reduction processing of the target world coordinate data by the preset user control parameter can be achieved by dividing the target world coordinate data by the preset user control parameter, thereby obtaining the target world coordinate data after the initial conversion. As an example but not limitation, in the embodiment of the present invention, preferably, the number of at least one preset coefficient is three, the number of at least one texture coordinate is three, and one of the three preset coefficients is 1, that is, the above-mentioned target preset coefficient, that is, the above-mentioned target value is 1, wherein setting the preset coefficient to 1 can be understood as not performing any processing on the target world coordinate data. For the convenience of subsequent marking, the value ranges of the other two preset coefficients other than 1 are not clearly limited and can be adjusted according to the effect. In the embodiment of the present invention, preferably, the other two preset coefficients other than 1 are 1.5 and 6 respectively.
[0067] Sampling the depth of the snow with different texture coordinates eliminates the sense of repetition of snow on the snow, and can present a better display effect than the snow rendered by sampling with a single texture coordinate.
[0068] Step 302 , target color information determination and parallax mapping processing are performed respectively through the target world coordinate data to obtain target color information and mapping results.
[0069] In one implementation, the above step 302 specifically includes: sampling a preset snow base color map through a target texture coordinate in at least one texture coordinate to obtain initial color information; obtaining a smooth transition value of a target depth, and multiplying the initial color information and the smooth transition value of the target depth to obtain target color information; sampling a preset height map to obtain snow height information, the preset height map being a height map corresponding to the preset snow base color map; performing parallax mapping on the snow height information and the target texture coordinates to obtain a mapping result.
[0070] As an example but not limitation, in an embodiment of the present invention, preferably, based on the target preset coefficient described in the above step 301, the target texture coordinate in at least one texture coordinate is a texture coordinate obtained by multiplying the target world coordinate data by the target preset coefficient of 1, that is, the texture coordinate after the target world coordinate data is converted based on the target preset coefficient in the above step 301.
[0071] Wherein, based on the fact that the number of at least one depth described in step 301 is three, i.e., three depths, the depth mean is obtained by averaging the three depths, and the depth mean, the preset snow amount control parameter, and the preset snow transition control parameter are smoothly transitioned to obtain a smooth transition value of the target depth, the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground. The target color information is used to indicate the base color of the final material.
[0072] In one implementation, the preset height map may be sampled through the target texture coordinates to obtain snow height information.
[0073] The snow height information and the target texture coordinates are subjected to parallax mapping processing through a preset parallax mapping function to obtain a mapping result, wherein, as an example but not a limitation, in the embodiment of the present invention, the above-mentioned parallax mapping function is preferably BumpOffset, and the snow height information and the target texture coordinates are subjected to parallax mapping processing (i.e., parallax mapping processing) through the parallax mapping function BumpOffset to render the parallax effect on the snow, so that the snow has a certain sense of thickness, allowing the material to produce an illusion of depth without the need for an additional model, thereby making the snow look thicker without the need for model changes.
[0074] Step 303 , the mapping result, the target normal and the preset ground normal information are mixed to obtain the target fused normal information.
[0075] In one implementation, the above step 303 specifically includes: sampling the preset normal map through the mapping result to obtain snow height normal information; mixing the snow height normal information and the target normal to obtain candidate fused normal information; linearly interpolating the preset ground normal information and the preset geometric normal information to obtain interpolated normal information; mixing the candidate fused normal information and the interpolated normal information to obtain target fused normal information.
[0076] After sampling the preset normal map through the mapping result to obtain the snow height normal information, the snow height normal information and the target normal are mixed through the preset blending function to obtain the candidate fused normal information. The preset blending function is used to indicate the function of mixing two normals. As an example but not a limitation, in the embodiment of the present invention, the preset blending function is preferably BlendAngleCorrectedNormals. The above-mentioned preset normal map is a pure normal map, which is different from the above-mentioned snow depth normal map. The preset normal map can be found in Figure 5 .
[0077] The preset ground normal information and the preset geometric normal information are linearly interpolated by the target linear interpolation function. As an example but not a limitation, in the embodiment of the present invention, the target linear interpolation function is preferably Lerp, Lerp1(x,y 1 ,alpha)=(1-alpha)*x+y 1 *alpha, where Lerp1(x,y 1 ,alpha) represents the interpolated normal information, x represents the preset ground normal information, y 1Indicates the preset geometric normal information, alpha indicates the smooth transition value of the target depth, and the value range of alpha is between [0,1]. The above preset ground normal information is used to indicate the value of sampling the preset ground normal map, and the above preset geometric normal information is used to indicate the normal perpendicular to the triangular surface, which can be the triangular surface of the snow model.
[0078] The candidate fused normal information and the interpolated normal information are mixed by the preset mixing function to obtain the target fused normal information. The preset mixing function is the preset mixing function mentioned above. The effect of mixing the mapping result, the target normal and the preset ground normal information can be seen in Figure 6 .
[0079] By interpolating and blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, and details are added to normals with fewer details, which conforms to the two-dimensional art style and enhances the rendering effect of snow.
[0080] Step 304 , linear interpolation processing is performed on the target depth, the preset ground normal information and the target fused normal information to obtain edge normal information.
[0081] By blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, which can conform to the two-dimensional art style. By performing linear interpolation on the target depth, preset ground normal information and target fused normal information, the snow-covered ground will not reveal the original normal of the ground, thereby enhancing the rendering effect of the snow.
[0082] In one implementation, the above step 304 specifically includes: obtaining a depth mean based on the target depth; performing smooth transition on the depth mean, a preset snow amount control parameter, and a preset snow transition control parameter to obtain a smooth transition value of the target depth, the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground; through a preset linear interpolation function, the smooth transition value of the target depth, the preset ground normal information, and the target fusion normal information are calculated to obtain edge normal information.
[0083] Based on the above step 301, by sampling the pre-set snow depth normal map with the target world coordinate data, three depths (i.e., at least one depth) including the target depth can be obtained. Then, calculate the average value of the three depths to obtain the depth average value. Through the pre-set first smooth transition function, perform smooth transition on the depth average value, the pre-set snow amount control parameter, and the pre-set snow transition control parameter to obtain the smooth transition value of the target depth. The above first smooth transition function is a function that generates a value in [0,1] from the depth average value, the pre-set snow amount control parameter, and the pre-set snow transition control parameter. As an example but not a limitation, in the embodiments of the present invention, preferably, the above first smooth transition function is smoothstep1(a,b,c). If a < c < b, it returns a value between [0,1]. If c < a < b, it returns 0. If a < b < c, it returns 1. a represents the difference between 1 and the pre-set snow amount control parameter, that is, 1 - the pre-set snow amount control parameter. b represents the sum value of a and the pre-set snow transition control parameter, that is, 1 - the pre-set snow amount control parameter + the pre-set snow transition control parameter. c represents the depth average value.
[0084] Among them, the above pre-set snow transition control parameter can be understood as a parameter for controlling the transition range between snow and the original ground. The smooth transition value of the target depth can be used to distinguish the snow-covered part and the transition part. Generally speaking, it can be understood which part has snow, which part has no snow, and which part is the transition.
[0085] The pre-set linear interpolation function is Lerp2(x,y 2 ,alpha)=(1-alpha)*x + y 2 *alpha, where Lerp2(x,y 2 ,alpha) represents the edge normal information, x represents the pre-set ground normal information, y 2 represents the target fusion normal information, alpha represents the smooth transition value of the target depth, and the value range of alpha is between [0,1].
[0086] The pre-set ground normal information can be referred to Figure 7 . The effect after performing linear interpolation processing on the target depth, the pre-set ground normal information, and the target fusion normal information can be referred to Figure 8 , where, through the interpolation processing of the depth of the snow and the normal of the original ground (i.e., the smooth transition value of the target depth, the target fusion normal information, and the pre-set ground normal information), it is realized that the ground covered with snow will not reveal the original normal of the ground. Among them, it can be referred to Fig. 9 , Fig. 9 is the processed ground normal map. From Fig. 9 it can be seen that the normal at the snow-free position is the ground, and the normal at the snow-covered position is the snow.
[0087] Through the interpolation processing of the snow depth (i.e., the target depth) and the preset snow volume control parameters, a better effect of the snow covering the ground from scratch is achieved. Through the interpolation processing of the snow depth and the normal line of the original ground (i.e., the smooth transition value of the target depth, the target fusion normal line information and the preset ground normal line information), the original normal line of the ground will not be revealed on the snow-covered ground, which can not only conform to the two-dimensional art style but also have a good snow rendering effect.
[0088] Step 305: Determine the target edge information according to the edge normal line information and the preset snow edge normal line component parameters.
[0089] In one implementation, the above step 305 specifically includes: performing smooth transition processing on the target depth, the preset snow volume control parameters and the preset edge tolerance parameters to obtain snow edge information; extracting components from the edge normal line information to obtain edge normal line component information; performing operations on the edge normal line component information, the snow edge information, the smooth transition value of the target depth and the preset snow edge normal line component parameters according to a preset rule to obtain the target edge information, and the preset snow edge normal line component parameters are used to indicate the reduction of the target component of the normal line at the edge.
[0090] Through the preset second smooth transition function, perform smooth transition processing on the target depth, the preset snow volume control parameters and the preset edge tolerance parameters to obtain snow edge information. The snow edge information can be seen in Fig.10 , and the second smooth transition function is smoothstep2(e,f,g). If e < g < f, it returns a value between [0,1]; if g < e < f, it returns 0; if e < f < g, it returns 1. e represents the sum value of f and the preset edge tolerance parameter, that is, the difference between 1 and the preset snow volume control parameter plus the preset snow volume control parameter; f represents the difference between 1 and the preset snow volume control parameter, that is, the difference between 1 and the preset snow volume control parameter; g represents the difference between the target depth and 1 and the preset snow volume control parameter, that is, the target depth - 1 - the preset snow volume control parameter.
[0091] The above edge normal line component information is used to indicate the y component of the edge normal line information, and the y component is used to indicate the component in the upward direction. The above edge normal line information is a three-dimensional vector corresponding to color, and the xyz components of the above edge normal line information can also be called the three primary color (Red Green Blue, RGB) components. It should be noted that the xyz components in the snow rendering method of the game scene provided by all embodiments of the present invention can be RGB components. The above preset snow edge normal line component parameter can be understood as a parameter that subtracts a preset value (i.e., the reduction amount) from the z component (i.e., the target component) of the normal line at the edge.
[0092] The above preset rules can be specifically as follows: calculate the product of the snow edge information, the smooth transition value of the target depth and the preset snow edge normal component parameter to obtain the edge depth product, and subtract the edge depth product from the edge normal component information to obtain the target edge information, that is, edge normal component information - snow edge information * preset snow edge normal component parameter * smooth transition value of target depth. Target edge information can be found in Fig.11 ,Depend on Fig.11 contrast Fig.10 It can be seen that the color of a part of the snow has become "darker", which can be understood as creating a visually thicker effect by modifying some normals, that is, the normals of the edge of the snow are offset downward to achieve the effect of a certain thickness at the edge.
[0093] By processing the edge normal component information, snow edge information, the smooth transition value of the target depth and the preset snow edge normal component parameters, the normal at the snow edge is offset downward so that the snow at the edge has a stronger sense of thickness, that is, the normal of the edge of the snow is offset downward to achieve the effect of a certain thickness at the edge.
[0094] Step 306 , rendering the current area to be rendered based on the target color information and the target edge information.
[0095] The corresponding shader and bidirectional reflectance distribution function are called to perform physically based rendering (PBR) of the current area to be rendered based on the target color information and the target edge information.
[0096] The method for rendering snow in the above-mentioned game scene performs snow rendering by combining parallax mapping, target edge information obtained by interpolation, and target color information obtained based on target depth. In addition, the characteristics of multiple normals are retained by mixing mapping results, target normals, and preset ground normal information, which can conform to the two-dimensional art style. By performing linear interpolation processing on target depth, preset ground normal information, and target fused normal information, the snow-covered ground will not reveal the original normal of the ground, thereby enhancing the rendering effect of snow, achieving the effect of not having to change the model in real time and without large computational operations in rendering, thereby improving the real-time performance of the game.
[0097] Corresponding to the above method embodiment, see Fig.12 A schematic diagram of a snow rendering device in a game scene is shown, the device comprising:
[0098] The sampling module 1201 is used to obtain the target world coordinate data of each point to be rendered in the area to be rendered, and to sample the preset snow depth normal map through the target world coordinate data to obtain the target depth and target normal;
[0099] A mapping module 1202 is used to perform target color information determination and parallax mapping processing respectively through target world coordinate data to obtain target color information and mapping results;
[0100] An interpolation module 1203 is used to interpolate the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information;
[0101] A determination module 1204 is used to determine target edge information according to edge normal information and preset snow edge normal component parameters;
[0102] The rendering module 1205 is used to render the current area to be rendered based on the target color information and the target edge information.
[0103] The snow rendering device in the above-mentioned game scene renders snow by combining parallax mapping, target edge information obtained by interpolation, and target color information obtained based on target depth, thereby achieving the effect of not having to change the model in real time and without large computational operations in rendering, thereby improving the real-time performance of the game.
[0104] The interpolation module 1203 includes:
[0105] A mixing unit 12031 is used to mix the mapping result, the target normal and the preset ground normal information to obtain the target fused normal information;
[0106] The interpolation unit 12032 is used to perform linear interpolation processing on the target depth, preset ground normal information and target fused normal information to obtain edge normal information.
[0107] The mixing unit 12031 is specifically used for:
[0108] The preset normal map is sampled through the mapping result to obtain the snow height normal information;
[0109] Mix the snow height normal information and the target normal to obtain candidate fused normal information;
[0110] Performing linear interpolation processing on preset ground normal information and preset geometric normal information to obtain interpolated normal information;
[0111] The candidate fused normal information and the interpolated normal information are mixed to obtain the target fused normal information.
[0112] The interpolation unit 12032 is specifically used for:
[0113] Get the depth mean based on the target depth;
[0114] Performing a smooth transition on the depth mean, a preset snow amount control parameter and a preset snow transition control parameter to obtain a smooth transition value of a target depth, wherein the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground;
[0115] By using a preset linear interpolation function, the smooth transition value of the target depth, the preset ground normal information and the target fused normal information are calculated to obtain the edge normal information.
[0116] The determination module 1204 is specifically used for:
[0117] Performing smooth transition processing on the target depth, the preset snow volume control parameter and the preset edge tolerance parameter to obtain snow edge information;
[0118] Extracting components of edge normal information to obtain edge normal component information;
[0119] According to preset rules, edge normal component information, snow edge information, a smooth transition value of a target depth and preset snow edge normal component parameters are calculated to obtain target edge information. The preset snow edge normal component parameters are used to indicate a reduction in a target component of the normal at the edge.
[0120] The sampling module 1201 includes:
[0121] The first extraction unit 12011 is used to obtain the world coordinate information of each to-be-rendered point in the to-be-rendered area, and perform target component extraction on the world coordinate information of each to-be-rendered point to obtain target world coordinate data;
[0122] The conversion unit 12012 is used to convert the target world coordinate data by presetting the user control parameter and at least one preset coefficient to obtain at least one texture coordinate;
[0123] The sampling unit 12013 is used to sample the preset snow depth normal map through at least one texture coordinate to obtain at least one depth and at least one normal;
[0124] The second extraction unit 12014 is used to extract at least one depth and at least one normal respectively to obtain a target depth and a target normal, wherein the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling a target texture coordinate.
[0125] The above conversion unit 12012 is specifically used for:
[0126] By presetting user control parameters, the target world coordinate data is reduced to obtain the target world coordinate data after initial conversion;
[0127] At least one preset coefficient is multiplied by the target world coordinate data to obtain at least one texture coordinate, the number of the at least one preset coefficient is more than one, and the number of the at least one texture coordinate corresponds to the number of the at least one preset coefficient.
[0128] The mapping module 1202 is specifically used for:
[0129] Sampling a preset snow base color map through a target texture coordinate in at least one texture coordinate to obtain initial color information;
[0130] Obtain a smooth transition value of the target depth, and multiply the initial color information and the smooth transition value of the target depth to obtain the target color information;
[0131] The preset height map is sampled to obtain snow height information, where the preset height map is a height map corresponding to a preset snow base color map;
[0132] Parallax mapping is performed on the snow height information and the target texture coordinates to obtain a mapping result.
[0133] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned snow rendering method in the game scene. The electronic device can be a server or a terminal device.
[0134] See also Fig.13 As shown, the electronic device includes a processor 1300 and a memory 1301, wherein the memory 1301 stores machine executable instructions that can be executed by the processor 1300, and the processor 1300 executes the machine executable instructions to implement the snow rendering method in the above-mentioned game scene.
[0135] Further, Fig.13 The electronic device shown further includes a bus 1302 and a communication interface 1303 , and the processor 1300 , the communication interface 1303 and the memory 1301 are connected via the bus 1302 .
[0136] Among them, the memory 1301 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 1303 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 1302 can be an ISA bus, a PCI bus or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.13 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0137] The processor 1300 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1300. The above processor 1300 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, register, or other mature storage media in the art. The storage medium is located in the memory 1301, and the processor 1300 reads the information in the memory 1301 and completes the following steps in combination with its hardware:
[0138] Obtain target world coordinate data of each point to be rendered in the area to be rendered, and sample a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal;
[0139] Target color information determination and parallax mapping processing are performed respectively through target world coordinate data to obtain target color information and mapping results;
[0140] Interpolate the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information;
[0141] Determine target edge information according to edge normal information and preset snow edge normal component parameters;
[0142] The current area to be rendered is rendered based on the target color information and the target edge information.
[0143] By combining parallax mapping, interpolated target edge information, and target color information based on target depth to render snow, the effect of not having to change the model in real time and not having to perform large computational operations during rendering is achieved, thereby improving the real-time performance of the game.
[0144] The above step of interpolating the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information includes:
[0145] The mapping result, the target normal and the preset ground normal information are mixed to obtain the target fused normal information;
[0146] Linear interpolation is performed on the target depth, preset ground normal information and target fused normal information to obtain edge normal information.
[0147] By blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, which can conform to the two-dimensional art style. By performing linear interpolation on the target depth, preset ground normal information and target fused normal information, the snow-covered ground will not reveal the original normal of the ground, thereby enhancing the rendering effect of the snow.
[0148] The above step of mixing the mapping result, the target normal and the preset ground normal information to obtain the target fused normal information includes:
[0149] The preset normal map is sampled through the mapping result to obtain the snow height normal information;
[0150] Mix the snow height normal information and the target normal to obtain candidate fused normal information;
[0151] Performing linear interpolation processing on preset ground normal information and preset geometric normal information to obtain interpolated normal information;
[0152] The candidate fused normal information and the interpolated normal information are mixed to obtain the target fused normal information.
[0153] By interpolating and blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, and details are added to normals with fewer details, which conforms to the two-dimensional art style and enhances the rendering effect of snow.
[0154] The above step of performing linear interpolation processing on the target depth, the preset ground normal information and the target fused normal information to obtain the edge normal information includes:
[0155] Get the depth mean based on the target depth;
[0156] Performing a smooth transition on the depth mean, a preset snow amount control parameter and a preset snow transition control parameter to obtain a smooth transition value of a target depth, wherein the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground;
[0157] By using a preset linear interpolation function, the smooth transition value of the target depth, the preset ground normal information and the target fused normal information are calculated to obtain the edge normal information.
[0158] Through the interpolation processing of the snow depth (i.e. the target depth) and the preset snow amount control parameters, a better effect of turning the ground from no snow to covering the ground is achieved. Through the interpolation processing of the snow depth and the original ground normal (i.e. the smooth transition value of the target depth, the target fusion normal information and the preset ground normal information), it is achieved that the snow-covered ground will not reveal the original normal of the ground, which is in line with the two-dimensional art style and has a better snow rendering effect.
[0159] The step of determining target edge information according to edge normal information and preset snow edge normal component parameters includes:
[0160] Performing smooth transition processing on the target depth, the preset snow volume control parameter and the preset edge tolerance parameter to obtain snow edge information;
[0161] Extracting components of edge normal information to obtain edge normal component information;
[0162] According to preset rules, edge normal component information, snow edge information, a smooth transition value of a target depth and preset snow edge normal component parameters are calculated to obtain target edge information. The preset snow edge normal component parameters are used to indicate a reduction in a target component of the normal at the edge.
[0163] By processing the edge normal component information, snow edge information, the smooth transition value of the target depth and the preset snow edge normal component parameters, the normal at the snow edge is offset downward so that the snow at the edge has a stronger sense of thickness, that is, the normal of the edge of the snow is offset downward to achieve the effect of a certain thickness at the edge.
[0164] The above step of obtaining the target world coordinate data of each point to be rendered in the area to be rendered, and sampling the preset snow depth normal map through the target world coordinate data to obtain the target depth and target normal includes:
[0165] Obtaining world coordinate information of each point to be rendered in the area to be rendered, and extracting target components from the world coordinate information of each point to be rendered to obtain target world coordinate data;
[0166] By presetting user control parameters and at least one preset coefficient, the target world coordinate data is converted to obtain at least one texture coordinate;
[0167] Sampling a preset snow depth normal map through at least one texture coordinate to obtain at least one depth and at least one normal;
[0168] At least one depth and at least one normal are extracted respectively to obtain a target depth and a target normal, wherein the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling the target texture coordinate.
[0169] By sampling the depth of the snow through different texture coordinates, the repetitive feeling displayed on the snow is eliminated; by sampling the target depth and target normal through the converted texture coordinates, a better display effect is laid for the subsequent snow rendering.
[0170] The step of converting the target world coordinate data by presetting the user control parameter and at least one preset coefficient to obtain at least one texture coordinate comprises:
[0171] By presetting user control parameters, the target world coordinate data is reduced to obtain the target world coordinate data after initial conversion;
[0172] At least one preset coefficient is multiplied by the target world coordinate data to obtain at least one texture coordinate, the number of the at least one preset coefficient is more than one, and the number of the at least one texture coordinate corresponds to the number of the at least one preset coefficient.
[0173] Sampling the depth of the snow with different texture coordinates eliminates the sense of repetition of snow on the snow, and can present a better display effect than the snow rendered by sampling with a single texture coordinate.
[0174] The above steps of respectively performing target color information determination and parallax mapping processing through target world coordinate data to obtain target color information and mapping results include:
[0175] Sampling a preset snow base color map through a target texture coordinate in at least one texture coordinate to obtain initial color information;
[0176] Obtain a smooth transition value of the target depth, and multiply the initial color information and the smooth transition value of the target depth to obtain the target color information;
[0177] The preset height map is sampled to obtain snow height information, where the preset height map is a height map corresponding to a preset snow base color map;
[0178] Parallax mapping is performed on the snow height information and the target texture coordinates to obtain a mapping result.
[0179] By performing parallax mapping on the snow height information and the target texture coordinates to render the parallax effect on the snow, the snow has a certain sense of thickness, allowing the material to produce an illusion of depth without the need for an additional model, making the snow look thicker without the need for model changes.
[0180] This embodiment further provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the following steps of the method for rendering snow in the game scene:
[0181] Obtain target world coordinate data of each point to be rendered in the area to be rendered, and sample a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal;
[0182] Target color information determination and parallax mapping processing are performed respectively through target world coordinate data to obtain target color information and mapping results;
[0183] Interpolate the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information;
[0184] Determine target edge information according to edge normal information and preset snow edge normal component parameters;
[0185] The current area to be rendered is rendered based on the target color information and the target edge information.
[0186] By combining parallax mapping, interpolated target edge information, and target color information based on target depth to render snow, the effect of not having to change the model in real time and not having to perform large computational operations during rendering is achieved, thereby improving the real-time performance of the game.
[0187] The above step of interpolating the mapping result, target depth, target normal and preset ground normal information to obtain edge normal information includes:
[0188] The mapping result, the target normal and the preset ground normal information are mixed to obtain the target fused normal information;
[0189] Linear interpolation is performed on the target depth, preset ground normal information and target fused normal information to obtain edge normal information.
[0190] By blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, which can conform to the two-dimensional art style. By performing linear interpolation on the target depth, preset ground normal information and target fused normal information, the snow-covered ground will not reveal the original normal of the ground, thereby enhancing the rendering effect of the snow.
[0191] The above step of mixing the mapping result, the target normal and the preset ground normal information to obtain the target fused normal information includes:
[0192] The preset normal map is sampled through the mapping result to obtain the snow height normal information;
[0193] Mix the snow height normal information and the target normal to obtain candidate fused normal information;
[0194] Performing linear interpolation processing on preset ground normal information and preset geometric normal information to obtain interpolated normal information;
[0195] The candidate fused normal information and the interpolated normal information are mixed to obtain the target fused normal information.
[0196] By interpolating and blending the mapping results, target normals and preset ground normal information, the characteristics of multiple different normals are retained, and details are added to normals with fewer details, which conforms to the two-dimensional art style and enhances the rendering effect of snow.
[0197] The above step of performing linear interpolation processing on the target depth, the preset ground normal information and the target fused normal information to obtain the edge normal information includes:
[0198] Get the depth mean based on the target depth;
[0199] Performing a smooth transition on the depth mean, a preset snow amount control parameter and a preset snow transition control parameter to obtain a smooth transition value of a target depth, wherein the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground;
[0200] By using a preset linear interpolation function, the smooth transition value of the target depth, the preset ground normal information and the target fused normal information are calculated to obtain the edge normal information.
[0201] Through the interpolation processing of the snow depth (i.e. the target depth) and the preset snow amount control parameters, a better effect of turning the ground from no snow to covering the ground is achieved. Through the interpolation processing of the snow depth and the original ground normal (i.e. the smooth transition value of the target depth, the target fusion normal information and the preset ground normal information), it is achieved that the snow-covered ground will not reveal the original normal of the ground, which is in line with the two-dimensional art style and has a better snow rendering effect.
[0202] The step of determining target edge information according to edge normal information and preset snow edge normal component parameters includes:
[0203] Performing smooth transition processing on the target depth, the preset snow volume control parameter and the preset edge tolerance parameter to obtain snow edge information;
[0204] Extracting components of edge normal information to obtain edge normal component information;
[0205] According to preset rules, edge normal component information, snow edge information, a smooth transition value of a target depth and preset snow edge normal component parameters are calculated to obtain target edge information. The preset snow edge normal component parameters are used to indicate a reduction in a target component of the normal at the edge.
[0206] By processing the edge normal component information, snow edge information, the smooth transition value of the target depth and the preset snow edge normal component parameters, the normal at the snow edge is offset downward so that the snow at the edge has a stronger sense of thickness, that is, the normal of the edge of the snow is offset downward to achieve the effect of a certain thickness at the edge.
[0207] The above step of obtaining the target world coordinate data of each point to be rendered in the area to be rendered, and sampling the preset snow depth normal map through the target world coordinate data to obtain the target depth and target normal includes:
[0208] Obtaining world coordinate information of each point to be rendered in the area to be rendered, and extracting target components from the world coordinate information of each point to be rendered to obtain target world coordinate data;
[0209] By presetting user control parameters and at least one preset coefficient, the target world coordinate data is converted to obtain at least one texture coordinate;
[0210] Sampling a preset snow depth normal map through at least one texture coordinate to obtain at least one depth and at least one normal;
[0211] At least one depth and at least one normal are extracted respectively to obtain a target depth and a target normal, wherein the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling the target texture coordinate.
[0212] By sampling the depth of the snow through different texture coordinates, the repetitive feeling displayed on the snow is eliminated; by sampling the target depth and target normal through the converted texture coordinates, a better display effect is laid for the subsequent snow rendering.
[0213] The step of converting the target world coordinate data by presetting the user control parameter and at least one preset coefficient to obtain at least one texture coordinate comprises:
[0214] By presetting user control parameters, the target world coordinate data is reduced to obtain the target world coordinate data after initial conversion;
[0215] At least one preset coefficient is multiplied by the target world coordinate data to obtain at least one texture coordinate, the number of the at least one preset coefficient is more than one, and the number of the at least one texture coordinate corresponds to the number of the at least one preset coefficient.
[0216] Sampling the depth of the snow with different texture coordinates eliminates the sense of repetition of snow on the snow, and can present a better display effect than the snow rendered by sampling with a single texture coordinate.
[0217] The above steps of respectively performing target color information determination and parallax mapping processing through target world coordinate data to obtain target color information and mapping results include:
[0218] Sampling a preset snow base color map through a target texture coordinate in at least one texture coordinate to obtain initial color information;
[0219] Obtain a smooth transition value of the target depth, and multiply the initial color information and the smooth transition value of the target depth to obtain the target color information;
[0220] The preset height map is sampled to obtain snow height information, where the preset height map is a height map corresponding to a preset snow base color map;
[0221] Parallax mapping is performed on the snow height information and the target texture coordinates to obtain a mapping result.
[0222] By performing parallax mapping on the snow height information and the target texture coordinates to render the parallax effect on the snow, the snow has a certain sense of thickness, allowing the material to produce an illusion of depth without the need for an additional model, making the snow look thicker without the need for model changes.
[0223] The computer program product of the method, device, electronic device and storage medium for rendering snow in a game scene provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0224] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0225] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0226] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0227] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0228] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for rendering snow in a game scene, It is characterized in that The method comprises: Obtain target world coordinate data of each point to be rendered in the area to be rendered, and convert the target world coordinate data by presetting user control parameters and at least one preset coefficient to obtain at least one texture coordinate; sample a preset snow depth normal map by the at least one texture coordinate to obtain a target depth and a target normal; the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling a target texture coordinate; Determining target color information based on the target texture coordinates and the target depth, and performing visual mapping processing based on a preset height map and the target texture coordinates to obtain a mapping result; Interpolating the mapping result, the target depth, the target normal and preset ground normal information to obtain edge normal information; Determine target edge information according to the edge normal information and a preset snow edge normal component parameter; the preset snow edge normal component parameter is used to indicate a reduction in a target component of the normal at the edge, the reduction being a preset value; The area to be rendered is rendered based on the target color information and the target edge information.
2. The method according to claim 1, It is characterized in that The step of interpolating the mapping result, the target depth, the target normal and the preset ground normal information to obtain edge normal information comprises: Mixing the mapping result, the target normal and preset ground normal information to obtain target fused normal information; Linear interpolation processing is performed on the target depth, the preset ground normal information and the target fused normal information to obtain edge normal information.
3. The method according to claim 2, It is characterized in that The step of mixing the mapping result, the target normal and the preset ground normal information to obtain target fused normal information comprises: The preset normal map is sampled through the mapping result to obtain snow height normal information; Mixing the snow height normal information and the target normal to obtain candidate fused normal information; Performing linear interpolation processing on preset ground normal information and preset geometric normal information to obtain interpolated normal information; The candidate fused normal information and the interpolated normal information are mixed to obtain target fused normal information.
4. The method according to claim 2, It is characterized in that The step of performing linear interpolation processing on the target depth, the preset ground normal information and the target fused normal information to obtain edge normal information comprises: Acquire a depth mean based on the target depth; Performing a smooth transition on the depth mean, a preset snow amount control parameter and a preset snow transition control parameter to obtain a smooth transition value of the target depth, wherein the preset snow amount control parameter is used to control the amount of snow, and the preset snow transition control parameter is used to control the transition range between snow and the ground; By using a preset linear interpolation function, the smooth transition value of the target depth, the preset ground normal information and the target fused normal information are calculated to obtain edge normal information.
5. The method according to claim 4, It is characterized in that The step of determining target edge information according to the edge normal information and preset snow edge normal component parameters comprises: Performing smooth transition processing on the target depth, the preset snow volume control parameter and the preset edge tolerance parameter to obtain snow edge information; Extracting components of the edge normal information to obtain edge normal component information; The edge normal component information, the snow edge information, the smooth transition value of the target depth and the preset snow edge normal component parameters are calculated according to preset rules to obtain the target edge information, and the preset snow edge normal component parameters are used to indicate the reduction of the target component of the normal at the edge.
6. The method according to any one of claims 1 to 5, It is characterized in that The step of obtaining target world coordinate data of each to-be-rendered point in the to-be-rendered area, and sampling a preset snow depth normal map through the target world coordinate data to obtain a target depth and a target normal, comprises: Obtaining world coordinate information of each point to be rendered in the area to be rendered, and extracting target components from the world coordinate information of each point to be rendered to obtain target world coordinate data; By presetting a user control parameter and at least one preset coefficient, the target world coordinate data is converted to obtain at least one texture coordinate; Sampling a preset snow depth normal map through the at least one texture coordinate to obtain at least one depth and at least one normal; The at least one depth and the at least one normal are extracted respectively to obtain a target depth and a target normal, wherein the target depth is used to indicate depth information obtained by sampling a target texture coordinate in the at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling the target texture coordinate.
7. The method according to claim 6, It is characterized in that The step of converting the target world coordinate data by presetting user control parameters and at least one preset coefficient to obtain at least one texture coordinate comprises: By presetting user control parameters, the target world coordinate data is reduced to obtain the target world coordinate data after initial conversion; At least one preset coefficient is multiplied by the target world coordinate data to obtain at least one texture coordinate, the number of the at least one preset coefficient is more than one, and the number of the at least one texture coordinate corresponds to the number of the at least one preset coefficient.
8. The method according to claim 7, It is characterized in that The step of determining target color information based on the target texture coordinates and the target depth, and performing visual mapping processing based on a preset height map and the target texture coordinates to obtain a mapping result includes: Sampling a preset snow base color map through a target texture coordinate in the at least one texture coordinate to obtain initial color information; Acquire a smooth transition value of the target depth, and multiply the initial color information by the smooth transition value of the target depth to obtain target color information; Sampling a preset height map to obtain snow height information, wherein the preset height map is a height map corresponding to the preset snow base color map; Parallax mapping is performed on the snow height information and the target texture coordinates to obtain a mapping result.
9. A snow rendering device in a game scene, It is characterized in that The snow rendering device in the game scene includes: A sampling module is used to obtain target world coordinate data of each to-be-rendered point in the to-be-rendered area, and convert the target world coordinate data by presetting user control parameters and at least one preset coefficient to obtain at least one texture coordinate; a preset snow depth normal map is sampled by the at least one texture coordinate to obtain a target depth and a target normal; the target depth is used to indicate depth information obtained by sampling a target texture coordinate in at least one texture coordinate, and the target normal is used to indicate normal information obtained by sampling a target texture coordinate; A mapping module, used to determine target color information based on the target texture coordinates and the target depth, and to perform visual mapping processing based on a preset height map and the target texture coordinates to obtain a mapping result; An interpolation module, used for interpolating the mapping result, the target depth, the target normal and preset ground normal information to obtain edge normal information; a determination module, configured to determine target edge information according to the edge normal information and a preset snow edge normal component parameter; the preset snow edge normal component parameter is used to indicate a reduction in a target component of the normal at the edge, the reduction being a preset value; A rendering module is used to render the area to be rendered based on the target color information and the target edge information.
10. An electronic device, It is characterized in that It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for rendering snow in a game scene according to any one of claims 1-8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by the processor, the machine-executable instructions prompt the processor to implement the method for rendering snow in a game scene according to any one of claims 1-8.
Citation Information
Patent Citations
Game resource making method and device, storage medium and terminal
CN112102492A
Virtual object display method in virtual scene, computer equipment and storage medium
CN112870707A