Raindrop rendering method and device and computer readable storage medium
By adjusting and sampling raindrop maps to determine texture coordinates, the method enhances the realism and naturalness of raindrop rendering in games, addressing the unnatural effects caused by grid-based flow methods.
Patent Information
- Application Number
- CN202411146739.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-13
AI Technical Summary
Existing methods for rendering raindrops in games rely on grid flow, resulting in unrealistic and unnatural raindrop effects.
A method involving obtaining an initial raindrop map, adjusting its shape and special effects, sampling to obtain raindrop normals, and determining texture coordinates to distort the game screen frame, using custom post-processing rendering operations and NFX Shader to simulate raindrops flowing naturally.
Improves the authenticity and naturalness of raindrop rendering by generating raindrops through special effect particles, making the flow effect more realistic and controllable.
Smart Images

Figure CN119113515A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a raindrop rendering method, device and computer-readable storage medium. Background Art
[0002] When developing a game project, you may need to reflect a rainy scene in the game. Currently, when rendering a rainy scene in the game, a normal map full of raindrops is usually assigned to the screen, and multiple flowing grids are calculated based on the screen texture coordinates (Texture Coordinates, UV). The flow range of these grids is used to display the distortion of the raindrop normal, thereby simulating the effect of raindrops flowing on the screen.
[0003] However, the above method of using normal maps and screen UVs to simulate the flow of raindrops on the screen is that the falling raindrops are completely dependent on the flow of the grid, not the flow of the raindrops themselves, which will cause the rendered raindrops to flow unrealistically and unnaturally.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] At least some embodiments of the present application provide a raindrop rendering method, device and computer-readable storage medium to at least solve the technical problem in the related art of using normal maps and screen UV for calculation to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down in an unrealistic and unnatural effect.
[0006] According to one embodiment of the present application, a raindrop rendering method is provided, which includes: obtaining an initial raindrop map; adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map; sampling the target raindrop map to obtain a raindrop normal; determining the target texture coordinates based on the raindrop normal and the screen texture coordinates; sampling the initial game screen frame based on the target texture coordinates to obtain a target game screen frame, wherein the initial game screen frame is a game screen frame on the current screen.
[0007] According to one embodiment of the present application, a raindrop rendering device is also provided, which includes: an acquisition module for acquiring an initial raindrop map; an adjustment module for adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map; a first sampling module for sampling the target raindrop map to obtain a raindrop normal; a determination module for determining the target texture coordinates based on the raindrop normal and the screen texture coordinates; a second sampling module for sampling the initial game screen frame based on the target texture coordinates to obtain a target game screen frame, wherein the initial game screen frame is the game screen frame on the current screen.
[0008] According to one embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the raindrop rendering method in the above embodiment when running on a computer or a processor.
[0009] According to one embodiment of the present application, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the raindrop rendering method in the above embodiment.
[0010] According to one embodiment of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the raindrop rendering method in the above embodiment is implemented.
[0011] In at least some embodiments of the present application, an initial raindrop map is obtained, and then the shape and special effects of the initial raindrop map are adjusted to obtain a target raindrop map for simulating the effect of raindrops flowing down. Then, the target raindrop map is sampled to obtain raindrop normals. Finally, the target texture coordinates are determined based on the raindrop normals and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain a target game screen frame with the effect of raindrops flowing down on the screen. The purpose of rendering the screen raindrops flowing down effect based on the combination of custom post-processing rendering operations and NFX Shader is achieved, so that the technical effect of improving the authenticity and naturalness of the rendering can be achieved, thereby solving the technical problem in the related art that the normal map and screen UV are used to calculate to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down effect being unrealistic and unnatural. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] 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:
[0013] Figure 1 It is a hardware structure block diagram of a mobile terminal of a raindrop rendering method according to an embodiment of the present application;
[0014] Figure 2 is a flowchart of a raindrop rendering method according to one embodiment of the present application;
[0015] Figure 3 is a schematic diagram of a particle assembly according to one embodiment of the present application;
[0016] Figure 4 is a schematic diagram of a target noise map according to one embodiment of the present application;
[0017] Figure 5 is a partial schematic diagram of a target game screen frame according to one embodiment of the present application;
[0018] Figure 6 is a structural block diagram of a raindrop rendering device according to one optional embodiment of the present application;
[0019] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] To facilitate understanding, some descriptions of concepts related to the embodiments of the present application are given exemplarily for reference.
[0021] As shown below:
[0022] Texture Coordinates (UV): Usually represented by UV coordinates, it is a coordinate system used in computer graphics to specify the position of the texture mapped to the surface of the geometric figure. UV coordinates are usually represented by a two-dimensional vector (u, v), where u represents the horizontal position of the texture and v represents the vertical position of the texture. By mapping the UV coordinates to the texture image, the effect of displaying the texture pattern or image on the surface of the geometric figure can be achieved.
[0023] Render Texture (RT): A commonly used rendering target in the Unity engine that allows developers to render the content of the scene to a texture instead of directly to the screen. This method can be used to achieve some special effects, such as specular reflection, real-time shadows, screen post-processing, etc. RT maps can be created and destroyed dynamically, and their contents can be modified dynamically at runtime. In the Unity engine, by creating an RT object and setting it as the camera's rendering target, the camera's rendering results can be output to a texture. This texture can be used as a material map or in post-processing effects.
[0024] NFX: is a WebGL-based graphics rendering engine that allows users to create and apply various visual effects and special effects, such as shaders, to enhance the user experience of web pages and mobile applications. A shader is a programming language that controls how a graphics processing unit (GPU) renders graphics and images. In NFX, users can use shaders to achieve various effects, such as lighting, shadows, blur, distortion, and more. By using NFX's shader function, users can easily create a variety of eye-catching visual effects to enhance the visual appeal and interactive experience of the application.
[0025] Half2 data type: used to store two 16-bit half-precision floating-point numbers. It is usually used in graphics processors or other applications requiring high-performance computing. It can provide higher computing performance and smaller storage space.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. 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 an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] In a possible implementation, in the field of image processing technology, during the image rendering process of a game, when rendering the special effects of raindrops flowing on the screen, a normal map covered with raindrops is usually assigned to the screen, and multiple flowing grids are calculated based on the screen texture coordinates (Texture Coordinates, UV). The flow range of these grids is used to display the distortion of the raindrop normals, thereby simulating the effect of raindrops flowing on the screen.
[0029] After practice and careful research, the inventor found that the raindrop flow effect rendered by the above method is completely dependent on the flow of the grid, not the flow of the raindrops themselves, which will cause the rendered raindrop flow effect to be unrealistic and unnatural. Based on this, the game scene applied to the embodiment of the present application can be the field of image processing in the game, and a raindrop rendering method is proposed. By obtaining an initial raindrop map, and then adjusting the shape and special effects of the initial raindrop map, a target raindrop map for simulating the effect of raindrops flowing down is obtained, and then the target raindrop map is sampled to obtain the raindrop normal, and finally the target texture coordinates are determined based on the raindrop normal and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain a target game screen frame with a screen raindrop flow effect. The purpose of rendering the effect of raindrops flowing down the screen based on the combination of custom post-processing rendering operations and NFX's Shader is achieved, thereby achieving the technical effect of improving the realism and naturalness of the rendering, and further solving the technical problem in the related technology of using normal maps and screen UV for calculation to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down effect being unrealistic and unnatural.
[0030] The above method embodiments involved in this application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone, a PDA, a mobile Internet device, a tablet computer (Personal Access Display, PAD), a game console and other terminal devices. Figure 1 is a hardware structure block diagram of a mobile terminal of a raindrop rendering method according to an embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) processor 102 (the processor 102 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a programmable logic device (field-programmable gate array, FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. In one embodiment of the present application, it may also include: a transmission device 106, an input and output device 108 and a display device 110.
[0031] In some optional embodiments mainly based on game scenarios, the above-mentioned device can also provide a human-computer interaction interface with a touch-sensitive surface, which can sense finger contact and / or gestures to perform human-computer interaction with a graphical user interface (Graphical User Interface, GUI). The human-computer interaction function may include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital videos, playing digital music and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0032] Those skilled in the art will understand that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0033] According to one embodiment of the present application, an embodiment of a raindrop rendering method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] In a possible implementation, the present application embodiment provides a raindrop rendering method. Figure 2 is a flowchart of a raindrop rendering method according to one embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0035] Step S20, obtaining an initial raindrop map.
[0036] In an embodiment of the present application, when rendering the effect of falling raindrops, it is first necessary to obtain an initial raindrop map. Exemplarily, an initial raindrop map can be created in a post-processing configuration file of a game engine, thereby obtaining the initial raindrop map created in the post-processing configuration file.
[0037] The game engine may be a Neox2 game engine, which is not limited here. The post-processing configuration file of the game engine is the pipeline.xml file in the game engine. The pipeline.xml file is a file used to configure the data processing flow of the game engine. The file defines the steps and sequence of data processing, as well as the parameters and configuration information required in the data processing process.
[0038] The initial raindrop map is an RT map, which can be understood as creating an RT map in the post-processing configuration file. For example, an RT map named Distortion can be created in the post-processing configuration file, which is not limited here.
[0039] Optionally, when creating an initial raindrop map in a post-processing configuration file, the pixel format of the initial raindrop map can be defined as RGBA8, that is, each pixel of the initial raindrop map consists of four channels, namely: red (Red), green (Green), blue (Blue) and transparency (Alpha), each channel is represented by 8 bits, and each pixel is represented by 32 bits. In addition, the resolution and other information of the initial raindrop map can also be defined, which can be set according to actual needs and is not limited here.
[0040] Step S22, adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map.
[0041] In the embodiment of the present application, after obtaining the initial raindrop map, the shape and / or special effects of the initial raindrop map need to be adjusted to obtain a target raindrop map, that is, a target raindrop map for simulating the effect of raindrops flowing down.
[0042] Exemplarily, when the shape and / or special effects of the initial raindrop map are adjusted, the initial raindrop map can be rendered in the first shader of the game engine to obtain the target raindrop map. For example, a first shader can be created in the post-processing configuration file of the game engine, and the first shader can use the shader used for particles in the game engine. Furthermore, the NFX Shader file used by the game engine for particles by default can be copied and renamed to fx_screen_rain as the NFX Shader dedicated to the raindrop dynamic particles, that is, the first shader.
[0043] The first shader is used to adjust the shape and special effects of the initial raindrop map. It can be understood that the rendering content of the first shader can be passed to the initial raindrop map, so as to adjust the shape and special effects of the initial raindrop map and obtain the target raindrop map. For example, it can be understood that the rendering content of the fx_screen_rain shader will be passed to the RT map named Distortion, and the RT map named Distortion becomes the target raindrop map after receiving the rendering content of the fx_screen_rainshader.
[0044] The rendering content of the first shader may include but is not limited to the shape and special effects of the map. For example, a raindrop-shaped particle may be created in the first shader, and the visual effect of the particle may be set to simulate the effect of raindrops flowing down, thereby transferring the rendering content of the first shader to the initial raindrop map to obtain a target raindrop map for simulating the effect of raindrops flowing down. For example, the target raindrop map may be named s_distortion, which is not limited here.
[0045] Step S24, sampling the target raindrop map to obtain the raindrop normal.
[0046] In the embodiment of the present application, after obtaining the target raindrop map, the target raindrop map can be sampled to obtain the raindrop normal. For example, the target raindrop map can be sampled in the second shader to obtain the raindrop normal, that is, s_distortion can be sampled multiple times in the second shader to obtain the raindrop normal.
[0047] For example, a second shader may be created in a post-processing configuration file of a game engine, and the second shader is used to render the screen raindrop refraction effect and the screen raindrop blur effect of the target raindrop map, that is, the second shader is used to perform post-processing rendering on the target raindrop map, rendering so that the target raindrop map has the screen raindrop refraction effect and the screen raindrop blur effect. Exemplarily, the second shader may be named screen raindrop refraction, or rain_distortion, which is not limited here.
[0048] It should be noted that there are two maps that need to be sampled when setting the second shader. One is the map that can normally receive the current game screen frame, which can be named s_origin, and the other is the target raindrop map s_distortion obtained above.
[0049] Step S26, determining the target texture coordinates based on the raindrop normal and the screen texture coordinates.
[0050] In the embodiment of the present application, after obtaining the raindrop normal, the target texture coordinates can be determined based on the raindrop normal and the screen texture coordinates. For example, the screen texture coordinates on the game screen can be offset by the raindrop normal and the raindrop display range can be constrained to obtain the target texture coordinates, so that the initial game screen frame can be sampled based on the target texture coordinates, thereby simulating the effect of raindrops or other liquids flowing on the screen on the game screen.
[0051] Step S28, sampling the initial game screen frame based on the target texture coordinates to obtain the target game screen frame, wherein the initial game screen frame is the game screen frame on the current screen.
[0052] In an embodiment of the present application, after obtaining the target texture coordinates, the initial game screen frame is sampled based on the target texture coordinates to obtain the target game screen frame, that is, the game screen frame on the current screen is distorted using the target texture coordinates, and the special effects of simulating raindrops flowing are applied to the actual game scene, thereby obtaining the target game screen frame.
[0053] The initial game screen frame is the game screen frame on the current screen, which can be recorded as s_origin and is not limited here.
[0054] It can be seen that in the embodiment of the present application, by obtaining the initial raindrop map, and then adjusting the shape and special effects of the initial raindrop map, a target raindrop map for simulating the effect of raindrops flowing down is obtained, and then the target raindrop map is sampled to obtain the raindrop normal, and finally the target texture coordinates are determined based on the raindrop normal and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain the target game screen frame with the effect of screen raindrops flowing down. That is, the present application proposes a solution for using dynamic particles to generate raindrop RT maps and then to make post-processing screen raindrops, so as to achieve the purpose of rendering the screen raindrops flowing down effect based on the combination of custom post-processing rendering operations and NFX Shader. Since the shape of the raindrops is completely generated by special effect particles, it is highly controllable, thereby achieving a more realistic and natural screen raindrop flowing down effect, and improving the technical effect of the authenticity and naturalness of the rendering.
[0055] Through the above steps, by obtaining the initial raindrop map, and then adjusting the shape and special effects of the initial raindrop map, a target raindrop map for simulating the effect of raindrops flowing down is obtained, and then the target raindrop map is sampled to obtain the raindrop normal, and finally the target texture coordinates are determined based on the raindrop normal and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain the target game screen frame with the effect of raindrops flowing down on the screen. The purpose of rendering the screen raindrops flowing down effect based on the customized post-processing rendering operation combined with the NFX Shader is achieved, so that the technical effect of improving the authenticity and naturalness of the rendering can be achieved, and then the technical problem that the normal map and screen UV are used in the related technology to calculate to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down effect being unrealistic and unnatural is solved.
[0056] In a possible implementation, in step S22, adjusting the shape and / or special effects of the initial raindrop map to obtain the target raindrop map may include the following execution steps:
[0057] Step S220, creating a first face sheet particle and a first ribbon particle, wherein the material of the first face sheet particle is the same as the material of the first ribbon particle;
[0058] Step S221, assigning a circular map to a first surface particle to obtain a second surface particle, and assigning a strip map to a first ribbon particle to obtain a second ribbon particle;
[0059] Step S222, adjusting the material parameters of the second face sheet particles to obtain third face sheet particles, and adjusting the material parameters of the second ribbon particles to obtain third ribbon particles;
[0060] Step S223, combining the third surface particle and the third ribbon particle to obtain a target raindrop map.
[0061] In the embodiment of the present application, when the shape and / or special effects of the initial raindrop map are adjusted to obtain the target raindrop map, the first patch particles and the first ribbon particles can be created. The material of the first patch particles is the same as the material of the first ribbon particles, that is, a new material (Material, MTL) can be created, and the material is named mtl_screen_rain, and assigned to the created first patch particles and the first ribbon particles respectively. Exemplarily, the first patch particles and the first ribbon particles can be created in the first shader.
[0062] It is understandable that, although the first patch particle and the first ribbon particle use the same MTL material, the special effects editor of the game engine (such as Neox2 engine) can make different particles share the same MTL material, but adjust the parameters of the MTL material for different particles. That is, although the first patch particle and the first ribbon particle use the same MTL material, they can be assigned different textures.
[0063] Therefore, after creating the first patch particle and the first ribbon particle with the same material, the circular map can be assigned to the first patch particle to obtain the second patch particle, and the strip map can be assigned to the first ribbon particle to obtain the second ribbon particle. That is, a circular map is applied to the first patch particle to obtain the second patch particle, and a strip map is applied to the first ribbon particle to obtain the second ribbon particle.
[0064] After obtaining the second sheet particle and the second ribbon particle, the material parameters of the second sheet particle can be adjusted to obtain the third sheet particle, and the material parameters of the second ribbon particle can be adjusted to obtain the third ribbon particle. This can be understood as controlling some random values of the emitters of the second sheet particle and the second ribbon particle, such as adjusting the emission life, size, emission position, emission angle and other parameters of the second sheet particle and the second ribbon particle, which are not limited here.
[0065] For example, since it is necessary to simulate the special effect of raindrops flowing down the screen, the color can be set to white in the emitter.
[0066] After obtaining the third sheet particle and the third ribbon particle, the third sheet particle and the third ribbon particle are combined to obtain the target raindrop map. For example, in order to simulate the shape of raindrops flowing down the screen, the third sheet particle and the third ribbon particle can be combined to form a tadpole shape, thereby simulating the shape of raindrops flowing down, and finally simulating the effect of a large piece of raindrops.
[0067] For example, Figure 3 is a schematic diagram of a particle assembly according to one embodiment of the present application, such as Figure 3 As shown, the third patch particles and the third ribbon particles after adjusting the parameters can be composed Figure 3 The shape of the simulated raindrops shown. It should be noted that Figure 3 The effect presented is for demonstration only, the actual rendering content of fx_screen_rain has been passed to the RT map named Distortion.
[0068] In a possible implementation, in step S24, sampling the target raindrop map to obtain the raindrop normal may include the following execution steps:
[0069] Step S240, sampling the target raindrop map based on the first texture coordinate of the target raindrop map to obtain a first sampling value;
[0070] Step S241, sampling the target raindrop map based on the second texture coordinates of the target raindrop map to obtain a second sampling value, wherein the second texture coordinates are texture coordinates obtained by offsetting the first texture coordinates in at least one direction;
[0071] Step S242, determining a raindrop normal based on the first sampling value and the second sampling value.
[0072] In the embodiment of the present application, when sampling the target raindrop map to obtain the raindrop normal, the target raindrop map can be sampled based on the first texture coordinate of the target raindrop map to obtain a first sampling value. The first texture coordinate can be understood as the original texture coordinate of the target raindrop map, and sampling the target raindrop map based on the first texture coordinate can be understood as directly sampling the target raindrop map. Exemplarily, in the second shader, the target raindrop map can be directly sampled based on the first texture coordinate of the target raindrop map to obtain a first sampling value, and the first sampling value can be recorded as ddxyRainBase, which is not limited here.
[0073] At the same time, the target raindrop map can be sampled based on the second texture coordinates of the target raindrop map, wherein the second texture coordinates are texture coordinates obtained by offsetting the first texture coordinates in at least one direction, which can be understood as adding an offset to the original texture coordinates in at least one direction, and sampling the target raindrop map based on the second texture coordinates can be understood as offset sampling the target raindrop map in at least one direction based on the second texture coordinates to obtain a target sampling value. Exemplarily, in the second shader, the target raindrop map can be offset sampled based on the second texture coordinates of the target raindrop map to obtain a second sampling value.
[0074] Exemplarily, at least one direction may include an upward offset direction, a downward offset direction, a leftward offset direction, and a rightward offset direction, which are not limited here. Further, when sampling the target raindrop map based on the second texture coordinate, the target raindrop map may be offset sampled upward to obtain an upward offset sampling value, and the target raindrop map may be offset sampled downward to obtain a downward offset sampling value, the target raindrop map may be offset sampled to the left to obtain a leftward offset sampling value, and the target raindrop map may be offset sampled to the right to obtain a rightward offset sampling value.
[0075] Exemplarily, the upward-shifted sampling value can be recorded as ddxyRain0, the downward-shifted sampling value can be recorded as ddxyRain1, the left-shifted sampling value can be recorded as ddxyRain2, and the right-shifted sampling value can be recorded as ddxyRain3. There is no limitation here, so that the second sampling value is determined based on the upward-shifted sampling value, the downward-shifted sampling value, the left-shifted sampling value, and the right-shifted sampling value.
[0076] After obtaining the first sampling value and the second sampling value, a raindrop normal is determined based on the first sampling value and the second sampling value.
[0077] In a possible implementation, in step S242, determining the raindrop normal based on the first sampling value and the second sampling value may include the following execution steps:
[0078] Step S2420, performing data type conversion on the second sampled value to obtain a target sampled value, wherein the data type of the target sampled value is a floating point number with preset precision;
[0079] Step S2421, multiplying the target sampling value by the first sampling value to obtain a raindrop normal.
[0080] In an embodiment of the present application, when determining the raindrop normal based on the first sampling value and the second sampling value, the data type of the second sampling value can be converted to obtain a target sampling value. Among them, the data type of the target sampling value is a preset precision floating point number, and the preset precision floating point number is the Half2 data type. It can be understood that the first sampling value and the second sampling value together constitute a target value of the Half2 data type. Exemplarily, the target value can be recorded as ddxyRain, which is not limited here.
[0081] Exemplarily, when the data type conversion is performed on the second sampling value to obtain the target sampling value, the first difference between the upward offset sampling value ddxyRain0 and the downward offset sampling value ddxyRain1 can be determined first, that is, the first difference is ddxyRain0-ddxyRain1. At the same time, the second difference between the leftward offset sampling value ddxyRain2 and the rightward offset sampling value ddxyRain3 is determined, that is, the second difference is ddxyRain2-ddxyRain3.
[0082] Then, the target sampling value is determined based on the first difference and the second difference, which can be understood as performing data type conversion on the first difference and the second difference, and the first difference and the second difference together constitute a target sampling value of a data type of a preset precision floating point number, that is, a target sampling value of a Half2 data type composed of the result of ddxyRain0-ddxyRain1 and the result of ddxyRain2-ddxyRain3.
[0083] After obtaining the target sampling value, the target sampling value may be multiplied by the first sampling value to obtain a raindrop normal. Exemplarily, the raindrop normal may be recorded as ddxyRain.xy, which is not limited here.
[0084] It can be seen that when the embodiment of the present application samples the target raindrop map to obtain the raindrop normal, it is taken as an example that a total of 5 samplings of the target raindrop map are required (i.e., direct sampling, upward offset sampling, downward offset sampling, left offset sampling, and right offset sampling) to obtain the raindrop normal, and the actual number of samplings can be adjusted according to demand and is not limited here.
[0085] In a possible implementation, in step S26, determining the target texture coordinates based on the raindrop normal and the screen texture coordinates may include the following execution steps:
[0086] Step S260, generating a random value based on the random function and the screen texture coordinates;
[0087] Step S261, determining offset texture coordinates based on the target noise map and the screen texture coordinates;
[0088] Step S262, performing distance calculation between the offset texture coordinates and the coordinate center point to obtain a distorted circular mask, wherein the distorted circular mask is used to constrain the blur range and rain range of raindrops on the screen;
[0089] Step S263, determining the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates and the distorted circular mask.
[0090] In the embodiment of the present application, when determining the target texture coordinates based on the raindrop normal and the screen texture coordinates, a random value can be generated based on the random function and the screen texture coordinates, which can be understood as the effect of using a random function to generate screen noise. For example, the random value can be recorded as randomOffset, which is not limited here.
[0091] When generating random values based on random functions and screen texture coordinates, a random function Rand can be defined, and then the screen UV is input into the Rand function to calculate the random number, and the calculated random number can make the screen produce a blur effect. For example, the random value can be calculated using a dot product function (dot function) and a trigonometric function (sin function), which is not limited here.
[0092] At the same time, the offset texture coordinates can be determined based on the target noise map and the screen texture coordinates, and the distance between the offset texture coordinates and the center point of the coordinates is calculated to obtain a distorted circular mask. It can be understood as sampling a target noise map, and then allowing the sampling result to produce a distorted effect on the circular mask when the circular mask is calculated using the distance function (distance function), that is, using the distance function to calculate the distance between the offset texture coordinates and the coordinate center point float2 (0.5, 0.5). Due to the interference of noise, a distorted circular mask will be obtained, which will affect the blur and rain range of the screen. Exemplarily, the distorted circular mask can be recorded as Blurmask, which is not limited here.
[0093] After that, the target texture coordinates are determined based on the obtained raindrop normal, random value, offset texture coordinates and distorted circular mask, that is, the distorted screen UV is obtained. Therefore, the initial game screen frame can be sampled based on the target texture coordinates, that is, the s_origin image is sampled, and finally a target game screen frame with blurred and raindrop flowing screen post-processing effects is obtained.
[0094] In a possible implementation, in step S261, determining the offset texture coordinates based on the target noise map and the screen texture coordinates may include the following execution steps:
[0095] Step S2610, sampling the target noise map to obtain a noise value;
[0096] Step S2611, offset the screen texture coordinates based on the noise value to obtain offset texture coordinates.
[0097] In the embodiment of the present application, when determining the offset texture coordinates based on the target noise map and the screen texture coordinates, the target noise map may be sampled to obtain the noise value noise. Figure 4 is a schematic diagram of a target noise map according to one embodiment of the present application. The target noise map in the present application can be as follows Figure 4 As shown, no limitation is given here.
[0098] After obtaining the noise value noise, the screen texture coordinates are offset based on the noise value to obtain offset texture coordinates. For example, the noise value can be multiplied by an intensity factor and then added to the screen UV, so that the noise value noise is used to interfere with the screen UV to obtain offset texture coordinates.
[0099] In a possible implementation, in step S263, determining the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates, and the distorted circular mask may include the following execution steps:
[0100] Step S2630, multiplying the raindrop normal by the distorted circular mask to obtain a first calculation result;
[0101] Step S2631, multiplying the random value, the target calculation result and the distorted circular mask to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value;
[0102] Step S2632, adding the offset texture coordinates, the first calculation result and the second calculation result to obtain the target texture coordinates.
[0103] In an embodiment of the present application, when determining the target texture coordinates based on the raindrop normal, random value, offset texture coordinates and distorted circular mask, the raindrop normal can be multiplied by the distorted circular mask to obtain a first calculation result. For example, ddxyRain.xy can be multiplied by Blurmask so that the raindrop normal is displayed inside the distorted circular mask.
[0104] At the same time, the random value, the target calculation result and the distorted circular mask are multiplied to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value, and the target calculation result can be expressed as 1-ddxyRainBase. For example, randomOffset, 1-ddxyRainBase and Blurmask can be multiplied to display a blur effect outside the distorted circular mask and outside the raindrop range.
[0105] Finally, the offset texture coordinates, the first calculation result and the second calculation result are added to obtain the target texture coordinates, so that the offset texture coordinates are affected by the raindrop normal inside the distorted circular mask, as well as by the blur effect and randomOffset, to obtain the target texture coordinates.
[0106] Then, the target game screen frame can be obtained by sampling the initial game screen frame with the target texture coordinates. Figure 5 is a partial schematic diagram of a target game screen frame according to one embodiment of the present application, such as Figure 5 As shown, Figure 5This is a part of the target game screen frame rendered using the solution of the present application. It can be seen that Figure 5 There are faintly visible raindrops on the screen in the picture, and there is a blur effect outside the circular mask, so that the effect of raindrops flowing down the screen can be simulated more realistically and naturally. And compared with the traditional solution, the shape of the raindrops in the solution of this application is completely generated by special effect particles, so it is highly controllable and the flow effect is more realistic and natural.
[0107] 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 a necessary general hardware platform, and of course 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 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.
[0108] In this embodiment, a raindrop rendering device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0109] Figure 6 is a structural block diagram of a raindrop rendering device according to one embodiment of the present application. Figure 6 As shown, taking a raindrop rendering device 600 as an example, the raindrop rendering device 600 includes: an acquisition module 601, used to acquire an initial raindrop map; an adjustment module 602, used to adjust the shape and / or special effects of the initial raindrop map to obtain a target raindrop map; a first sampling module 603, used to sample the target raindrop map to obtain a raindrop normal; a determination module 604, used to determine the target texture coordinates based on the raindrop normal and the screen texture coordinates; a second sampling module 605, used to sample the initial game screen frame based on the target texture coordinates to obtain a target game screen frame, wherein the initial game screen frame is a game screen frame on the current screen.
[0110] Optionally, the adjustment module 602 is also used to: create a first surface patch particle and a first ribbon particle, wherein the material of the first surface patch particle is the same as the material of the first ribbon particle; assign a circular map to the first surface patch particle to obtain a second surface patch particle, and assign a strip map to the first ribbon particle to obtain a second ribbon particle; adjust the material parameters of the second surface patch particle to obtain a third surface patch particle, and adjust the material parameters of the second ribbon particle to obtain a third ribbon particle; combine the third surface patch particle with the third ribbon particle to obtain a target raindrop map.
[0111] Optionally, the first sampling module 603 is further used to: sample the target raindrop map based on the first texture coordinates of the target raindrop map to obtain a first sampling value; sample the target raindrop map based on the second texture coordinates of the target raindrop map to obtain a second sampling value, wherein the second texture coordinates are texture coordinates obtained by offsetting the first texture coordinates in at least one direction; and determine the raindrop normal based on the first sampling value and the second sampling value.
[0112] Optionally, the first sampling module 603 is further used to: perform data type conversion on the second sampling value to obtain a target sampling value, wherein the data type of the target sampling value is a floating point number with preset precision; and multiply the target sampling value by the first sampling value to obtain a raindrop normal.
[0113] Optionally, the determination module 604 is also used to: generate a random value based on a random function and screen texture coordinates; determine the offset texture coordinates based on the target noise map and the screen texture coordinates; perform distance calculation on the offset texture coordinates and the coordinate center point to obtain a distorted circular mask, the distorted circular mask is used to constrain the blur range and rain range of raindrops on the screen; determine the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates and the distorted circular mask.
[0114] Optionally, the determination module 604 is further configured to: sample the target noise map to obtain a noise value; and offset the screen texture coordinates based on the noise value to obtain offset texture coordinates.
[0115] Optionally, the determination module 604 is also used to: multiply the raindrop normal with the distorted circular mask to obtain a first calculation result; multiply the random value, the target calculation result and the distorted circular mask to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value; add the offset texture coordinates, the first calculation result and the second calculation result to obtain the target texture coordinates.
[0116] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0117] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0118] Optionally, in this embodiment, the above-mentioned computer-readable 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 computer programs.
[0119] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0120] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0121] Step S20, obtaining an initial raindrop map;
[0122] Step S22, adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map;
[0123] Step S24, sampling the target raindrop map to obtain the raindrop normal;
[0124] Step S26, determining the target texture coordinates based on the raindrop normal and the screen texture coordinates;
[0125] Step S28, sampling the initial game screen frame based on the target texture coordinates to obtain the target game screen frame, wherein the initial game screen frame is the game screen frame on the current screen.
[0126] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: creating a first surface patch particle and a first ribbon particle, wherein the material of the first surface patch particle is the same as the material of the first ribbon particle; assigning a circular map to the first surface patch particle to obtain a second surface patch particle, and assigning a strip map to the first ribbon particle to obtain a second ribbon particle; adjusting the material parameters of the second surface patch particle to obtain a third surface patch particle, and adjusting the material parameters of the second ribbon particle to obtain a third ribbon particle; combining the third surface patch particle with the third ribbon particle to obtain a target raindrop map.
[0127] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: sampling a target raindrop map based on a first texture coordinate of the target raindrop map to obtain a first sampling value; sampling the target raindrop map based on a second texture coordinate of the target raindrop map to obtain a second sampling value, wherein the second texture coordinate is a texture coordinate obtained by offsetting the first texture coordinate in at least one direction; and determining a raindrop normal based on the first sampling value and the second sampling value.
[0128] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: performing data type conversion on the second sampling value to obtain a target sampling value, wherein the data type of the target sampling value is a floating point number with a preset precision; and multiplying the target sampling value by the first sampling value to obtain a raindrop normal.
[0129] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: generating a random value based on a random function and screen texture coordinates; determining an offset texture coordinate based on a target noise map and the screen texture coordinates; performing a distance calculation between the offset texture coordinates and the coordinate center point to obtain a distorted circular mask, the distorted circular mask being used to constrain the blur range and rain range of raindrops on the screen; and determining the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates and the distorted circular mask.
[0130] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: sampling a target noise map to obtain a noise value; and offsetting screen texture coordinates based on the noise value to obtain offset texture coordinates.
[0131] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: multiplying the raindrop normal by the distorted circular mask to obtain a first calculation result; multiplying the random value, the target calculation result, and the distorted circular mask to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value; adding the offset texture coordinates, the first calculation result, and the second calculation result to obtain the target texture coordinates.
[0132] In the computer-readable storage medium of this embodiment, a technical solution for raindrop rendering is provided, which obtains an initial raindrop map, and then adjusts the shape and special effects of the initial raindrop map to obtain a target raindrop map for simulating the effect of raindrops flowing down. Then, the target raindrop map is sampled to obtain raindrop normals. Finally, the target texture coordinates are determined based on the raindrop normals and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain a target game screen frame with the effect of raindrops flowing down on the screen. The purpose of rendering the screen raindrops flowing down effect based on the combination of the custom post-processing rendering operation and the NFX Shader is achieved, so that the technical effect of improving the authenticity and naturalness of the rendering can be achieved, thereby solving the technical problem in the related art that the normal map and the screen UV are used to calculate to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down effect being unrealistic and unnatural.
[0133] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0134] In an exemplary embodiment of the present application, a program product capable of implementing the above method of the present embodiment is stored on a computer-readable storage medium. In some possible implementations, various aspects of the embodiments of the present application can also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present application described in the above "Exemplary Method" section of the present embodiment.
[0135] According to the program product for implementing the above method according to the embodiment of the present application, it can adopt a portable compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present application is not limited to this. In the embodiment of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0136] The program product may be in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Electrically Programmable Read-Only Memory, EPROM) or flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0137] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the above.
[0138] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0139] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0140] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0141] Step S20, obtaining an initial raindrop map;
[0142] Step S22, adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map;
[0143] Step S24, sampling the target raindrop map to obtain the raindrop normal;
[0144] Step S26, determining the target texture coordinates based on the raindrop normal and the screen texture coordinates;
[0145] Step S28, sampling the initial game screen frame based on the target texture coordinates to obtain the target game screen frame, wherein the initial game screen frame is the game screen frame on the current screen.
[0146] Optionally, the processor can also be configured to perform the following steps through a computer program: create a first surface patch particle and a first ribbon particle, wherein the material of the first surface patch particle is the same as the material of the first ribbon particle; assign a circular map to the first surface patch particle to obtain a second surface patch particle, and assign a strip map to the first ribbon particle to obtain a second ribbon particle; adjust the material parameters of the second surface patch particle to obtain a third surface patch particle, and adjust the material parameters of the second ribbon particle to obtain a third ribbon particle; combine the third surface patch particle with the third ribbon particle to obtain a target raindrop map.
[0147] Optionally, the processor may also be configured to perform the following steps through a computer program: sampling a target raindrop map based on a first texture coordinate of the target raindrop map to obtain a first sampling value; sampling the target raindrop map based on a second texture coordinate of the target raindrop map to obtain a second sampling value, wherein the second texture coordinate is a texture coordinate obtained by offsetting the first texture coordinate in at least one direction; and determining a raindrop normal based on the first sampling value and the second sampling value.
[0148] Optionally, the processor may also be configured to perform the following steps through a computer program: converting the data type of the second sampling value to obtain a target sampling value, wherein the data type of the target sampling value is a floating point number with a preset precision; and multiplying the target sampling value by the first sampling value to obtain a raindrop normal.
[0149] Optionally, the processor can also be configured to perform the following steps through a computer program: generate a random value based on a random function and screen texture coordinates; determine an offset texture coordinate based on a target noise map and the screen texture coordinates; perform a distance calculation between the offset texture coordinates and the center point of the coordinates to obtain a distorted circular mask, the distorted circular mask being used to constrain the blur range and rain range of raindrops on the screen; determine the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates and the distorted circular mask.
[0150] Optionally, the processor may also be configured to perform the following steps through a computer program: sampling a target noise map to obtain a noise value; and offsetting screen texture coordinates based on the noise value to obtain offset texture coordinates.
[0151] Optionally, the processor can also be configured to perform the following steps through a computer program: multiplying the raindrop normal with the distorted circular mask to obtain a first calculation result; multiplying the random value, the target calculation result and the distorted circular mask to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value; adding the offset texture coordinates, the first calculation result and the second calculation result to obtain the target texture coordinates.
[0152] In the electronic device of this embodiment, a technical solution for raindrop rendering is provided, which obtains an initial raindrop map, and then adjusts the shape and special effects of the initial raindrop map to obtain a target raindrop map for simulating the effect of raindrops flowing down. Then, the target raindrop map is sampled to obtain raindrop normals. Finally, the target texture coordinates are determined based on the raindrop normals and the screen texture coordinates, and the initial game screen frame is sampled based on the target texture coordinates, that is, the initial game screen frame on the current screen is distorted to obtain a target game screen frame with the effect of raindrops flowing down on the screen. The purpose of rendering the screen raindrops flowing down effect based on the customized post-processing rendering operation combined with the NFX Shader is achieved, so that the technical effect of improving the authenticity and naturalness of the rendering can be achieved, thereby solving the technical problem in the related art that the normal map and screen UV are used to calculate to simulate the flow of raindrops on the screen, resulting in the rendered raindrops flowing down effect being unrealistic and unnatural.
[0153] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device 700 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0154] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include but are not limited to: at least one processor 710, at least one memory 720, a bus 730 connecting different system components (including the memory 720 and the processor 710), and a display 740.
[0155] The memory 720 stores program codes, which can be executed by the processor 710, so that the processor 710 executes the steps described in the method part of the embodiment of the present application according to various exemplary implementations of the present application.
[0156] The memory 720 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 7201 and / or a cache memory unit 7202, and may further include a read-only memory unit (ROM) 7203, 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.
[0157] In some examples, the memory 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include the implementation of a network environment. The memory 720 may further include a memory remotely disposed relative to the processor 710, and these remote memories may be connected to the electronic device 700 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0158] Bus 730 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus of processor 710, or any of a variety of bus architectures.
[0159] The display 740 may be, for example, a touch screen liquid crystal display (LCD), which may enable a user to interact with a user interface of the electronic device 700 .
[0160] Optionally, the electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 700, and / or any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 760. Figure 7 As shown, the network adapter 760 communicates with other modules of the electronic device 700 via the bus 730. It should be understood that although Figure 7Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Array of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0161] The electronic device 700 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0162] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 1 The memory 720 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the method for rendering raindrops on the game screen in the embodiment of the present application. The processor 710 executes various functional applications and data processing by running the computer program stored in the memory 720, that is, implementing the above-mentioned method for rendering raindrops on the game screen.
[0163] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and the computer program implements the method provided in the embodiment when executed by a processor.
[0164] Optionally, the computer program included in the above-mentioned computer program product is executed by a processor to perform the following steps:
[0165] Step S20, obtaining an initial raindrop map;
[0166] Step S22, adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map;
[0167] Step S24, sampling the target raindrop map to obtain the raindrop normal;
[0168] Step S26, determining the target texture coordinates based on the raindrop normal and the screen texture coordinates;
[0169] Step S28, sampling the initial game screen frame based on the target texture coordinates to obtain the target game screen frame, wherein the initial game screen frame is the game screen frame on the current screen.
[0170] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0171] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0172] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that 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, which can be electrical or other forms.
[0173] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0174] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0175] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0176] The above is only a preferred implementation 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 raindrop rendering method, It is characterized in that The method comprises: Get the initial raindrop map; Adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map; Sampling the target raindrop map to obtain a raindrop normal; Determining target texture coordinates based on the raindrop normal and screen texture coordinates; The initial game screen frame is sampled based on the target texture coordinates to obtain a target game screen frame, wherein the initial game screen frame is a game screen frame on the current screen.
2. The method according to claim 1, It is characterized in that The adjusting the shape and / or special effects of the initial raindrop map to obtain the target raindrop map comprises: Creating a first face sheet particle and a first ribbon particle, wherein the material of the first face sheet particle is the same as the material of the first ribbon particle; Assigning a circular map to the first surface particle to obtain a second surface particle, and assigning a strip map to the first ribbon particle to obtain a second ribbon particle; Adjusting the material parameters of the second surface sheet particles to obtain third surface sheet particles, and adjusting the material parameters of the second ribbon particles to obtain third ribbon particles; The third surface particle and the third ribbon particle are combined to obtain the target raindrop map.
3. The method according to claim 1, It is characterized in that The sampling of the target raindrop map to obtain the raindrop normal includes: Sampling the target raindrop map based on a first texture coordinate of the target raindrop map to obtain a first sampling value; Sampling the target raindrop map based on second texture coordinates of the target raindrop map to obtain a second sampling value, wherein the second texture coordinates are texture coordinates obtained by offsetting the first texture coordinates in at least one direction; The raindrop normal is determined based on the first sampling value and the second sampling value.
4. The method according to claim 3, It is characterized in that The determining the raindrop normal based on the first sampling value and the second sampling value comprises: Performing data type conversion on the second sampled value to obtain a target sampled value, wherein the data type of the target sampled value is a floating point number with preset precision; The target sampling value is multiplied by the first sampling value to obtain the raindrop normal.
5. The method according to claim 3, It is characterized in that Determining the target texture coordinates based on the raindrop normal and the screen texture coordinates comprises: generating a random value based on a random function and the screen texture coordinates; determining an offset texture coordinate based on a target noise map and the screen texture coordinate; Performing distance calculation on the offset texture coordinates and the coordinate center point to obtain a distorted circular mask, wherein the distorted circular mask is used to constrain the blur range and rain range of raindrops on the screen; A target texture coordinate is determined based on the raindrop normal, the random value, the offset texture coordinate, and the warped circular mask.
6. The method according to claim 5, It is characterized in that Determining the offset texture coordinates based on the target noise map and the screen texture coordinates comprises: Sampling the target noise map to obtain a noise value; The screen texture coordinates are offset based on the noise value to obtain the offset texture coordinates.
7. The method according to claim 5, It is characterized in that The determining of the target texture coordinates based on the raindrop normal, the random value, the offset texture coordinates and the distorted circular mask comprises: Multiplying the raindrop normal by the distorted circular mask to obtain a first calculation result; Multiplying the random value, the target calculation result, and the distorted circular mask to obtain a second calculation result, wherein the target calculation result is determined based on the first sampling value; The offset texture coordinates, the first calculation result, and the second calculation result are added to obtain the target texture coordinates.
8. A raindrop rendering device, It is characterized in that The device comprises: An acquisition module is used to obtain an initial raindrop map; An adjustment module, used for adjusting the shape and / or special effects of the initial raindrop map to obtain a target raindrop map; A first sampling module, used for sampling the target raindrop map to obtain a raindrop normal; A determination module, used for determining target texture coordinates based on the raindrop normal and screen texture coordinates; The second sampling module is used to sample the initial game screen frame based on the target texture coordinates to obtain a target game screen frame, wherein the initial game screen frame is a game screen frame on the current screen.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the raindrop rendering method described in any one of claims 1 to 7 when running on a computer or a processor.
10. An electronic device comprising a memory and a processor, It is characterized in that The memory stores a computer program, and the processor is configured to run the computer program to execute the raindrop rendering method described in any one of claims 1 to 7.
11. A computer program product, It is characterized in that The invention comprises a computer program, which implements the raindrop rendering method described in any one of claims 1 to 7 when being executed by a processor.
