CN118045352A - Method and device for realizing flow effect, electronic equipment and computer storage medium - Google Patents

Method and device for realizing flow effect, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN118045352A
CN118045352A CN202410255311.6A CN202410255311A CN118045352A CN 118045352 A CN118045352 A CN 118045352A CN 202410255311 A CN202410255311 A CN 202410255311A CN 118045352 A CN118045352 A CN 118045352A
Authority
CN
China
Prior art keywords
map
initial
flow
mapping
topographic
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410255311.6A
Other languages
Chinese (zh)
Inventor
黄涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202410255311.6A priority Critical patent/CN118045352A/en
Publication of CN118045352A publication Critical patent/CN118045352A/en
Pending legal-status Critical Current

Links

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The application relates to the technical field of computers, and discloses a method and a device for realizing a flow effect, electronic equipment and a computer storage medium, wherein the method comprises the following steps: obtaining a topography map of the quicksand topography; responding to an operation instruction aiming at the topographic map, carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; and respectively processing the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map. According to the embodiment of the application, the flowing map is processed through the waveform function with the phase difference, so that the flowing effect of the flowing sand is guaranteed to have flowing sensation, and meanwhile, the flowing effect of the flowing sand surface is realized in a flowing map mode, so that the flowing effect of the flowing sand surface in the flowing sand terrain can be compatible to operate on a mobile terminal and a PC platform with poor performance, and the compatibility of the flowing sand effect is improved.

Description

Method and device for realizing flow effect, electronic equipment and computer storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for implementing a streaming effect, an electronic device, and a computer storage medium.
Background
At present, the scheme with better quicksand effect in games is realized mostly by real physical particle simulation or complex fluid simulation calculation, the effect is very vivid, and the flowing feeling and the granular feeling like liquid in the quicksand in the real world can be well simulated.
However, while the schemes calculated by real physical particle simulation or fluid simulation can well restore the appearance of the real world quicksand effect, the high quality effect performance is often accompanied by a huge performance consumption. The scheme can be generally implemented only on a high-performance host computer or a PC platform, and the high-quality quicksand effect can not be realized by using real physical particles or fluid simulation calculation on a mobile terminal or even on a PC platform with poor performance, so that the compatibility of the quicksand effect of the conventional scheme is poor.
Disclosure of Invention
The present application is directed to solving at least one of the technical problems existing in the related art. Therefore, the embodiment of the application provides a method, a device, electronic equipment and a computer storage medium for realizing a flowing effect, which can ensure that the flowing effect has flowing feeling and improve the compatibility of the flowing effect.
In a first aspect, an embodiment of the present application provides a method for implementing a flow effect, including:
Obtaining a topography map of the quicksand topography;
Responding to an operation instruction aiming at the topographic map, and carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
respectively processing an initial attribute map, an initial normal map and an initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
In a second aspect, an embodiment of the present application provides a device for implementing a flow effect, including:
The acquisition module is used for acquiring a topography map of the quicksand topography;
the first mapping processing module is used for responding to the operation instruction aiming at the topographic map, mapping the topographic map, and obtaining an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
The second mapping processing module is used for respectively processing the initial attribute mapping, the initial normal mapping and the initial noise mapping in the initial flow mapping according to a preset waveform function to obtain a target flow mapping of the topographic mapping so as to realize the flowing sand topographic flow effect of the topographic mapping based on the target flow mapping;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
In a third aspect, embodiments of the present application further provide an electronic device, including a memory storing a plurality of computer programs; the processor loads the computer program from the memory to execute any of the implementation methods of the streaming effect provided by the embodiments of the present application.
In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, where a plurality of computer programs are stored, where the computer programs are adapted to be loaded by a processor, to execute any one of the implementation methods of the flow effect provided by the embodiments of the present application.
In a fifth aspect, embodiments of the present application further provide a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, implements a method for implementing any of the streaming effects provided by the embodiments of the present application.
The embodiment of the application acquires a topography map of a quicksand topography; responding to an operation instruction aiming at the topographic map, carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; and respectively processing the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map. Therefore, the embodiment of the application processes the flow mapping through the waveform function with the phase difference to obtain the target flow mapping, and the seamless connection effect of the mapping during flow is ensured through the target flow mapping, so that the flowing sand effect of the topography mapping is ensured to have flowing sensation, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography is realized in a flowing mapping mode, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode at the mobile end and a PC platform with poor performance through the characteristic of low performance consumption of the flowing mapping, and the compatibility of the flowing sand effect is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is one of the flow diagrams of a method for implementing a flow effect provided in an embodiment of the present application;
FIG. 2 is a second flow chart of a method for realizing the flow effect according to the embodiment of the application;
FIG. 3 is a third flow chart of a method for implementing a flow effect according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a flow effect realization device provided in an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to fall within the scope of the application. Meanwhile, in the description of the embodiments of the present application, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance. Thus, features defining "first", "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "plurality" is two or more, unless explicitly defined otherwise.
The embodiment of the application provides a method and a device for realizing a flow effect, electronic equipment and a computer storage medium. Specifically, the embodiment of the present application will be described from the perspective of a device for implementing a flow effect, which may be specifically integrated in an electronic device, that is, the method for implementing a flow effect of the embodiment of the present application may be executed by an electronic device. Optionally, the electronic device includes a terminal device. The terminal device may be a mobile phone, a tablet computer, a notebook computer, a game machine, or a personal computer (Personal Computer, PC). Optionally, the electronic device includes a server, which may be a stand alone server, or may be a server network or a server cluster including, but not limited to, a computer, a network host, a single network server, a network server set, or a cloud server formed by servers. Wherein the Cloud server is composed of a large number of computers or web servers based on Cloud Computing (Cloud Computing).
The following description of the embodiments is not intended to limit the preferred embodiments. Although a logical order is depicted in the flowchart, in some cases the steps shown or described may be performed in an order different than depicted in the figures.
At present, the scheme with better quicksand effect in games is realized mostly by real physical particle simulation or complex fluid simulation calculation, the effect is very vivid, and the flowing feeling and the granular feeling like liquid in the quicksand in the real world can be well simulated. However, while the schemes calculated by real physical particle simulation or fluid simulation can well restore the appearance of the real world quicksand effect, the high quality effect performance is often accompanied by a huge performance consumption. The scheme can be implemented only on a high-performance host computer or a PC platform, and high-quality quicksand effect can not be realized by using real physical particles or fluid simulation calculation on a mobile terminal or even on a PC platform with poor performance, so that the compatibility of the quicksand effect is poor.
In order to solve the problems in the prior art, the embodiment of the application acquires the topographic map of the quicksand topography; responding to an operation instruction aiming at the topographic map, carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; and respectively processing the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map.
Therefore, the embodiment of the application processes the flow mapping through the waveform function with the phase difference to obtain the target flow mapping, and the seamless connection effect of the mapping during flow is ensured through the target flow mapping, so that the flowing sand effect of the topography mapping is ensured to have flowing sensation, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography is realized in a flowing mapping mode, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode at the mobile end and a PC platform with poor performance through the characteristic of low performance consumption of the flowing mapping, and the compatibility of the flowing sand effect is improved.
Noun interpretation:
Flow mapping: is a mapping technology for simulating flowing effects of fluid, water flow, flame and the like in games. Is a 2D (Two-Dimensional) texture that is used to specify the flow direction and speed of each pixel in the scene, thereby providing a more realistic flow effect for the fluid and water streams in the scene.
DCC software: DCC (Digital Content Creation) software is a computer program for creating digital content. Various tools and functions are provided in DCC software for creating and editing digital media such as graphics, animations, movies, and audio.
FlowMapPainter is software for making a flow map, which can be used to directly draw the intensity and direction information of the map flow with a brush and save it on the flow map.
And the Unity engine: is a cross-platform game development engine, and is widely used for development of games, virtual reality VR, augmented reality AR, visual effect, simulators and other interactive application programs. The Unity engine provides rich tools and functions including graphics rendering, physical simulation, animation systems, collision detection, artificial intelligence, network functions, audio management, user interface design, etc. At the same time, the Unity engine also provides a powerful editor that allows developers to visually create scenes, set object properties, write scripts, debug and test games.
Optionally, the execution body of the embodiment of the present application may be described as a device for implementing a flow effect, where one of expression forms of the device for implementing a flow effect is a mapping processing device. Referring to fig. 1, fig. 1 is a schematic flow chart of a method for implementing a flow effect according to an embodiment of the present application.
In an embodiment, the specific flow of the method for implementing the flow effect provided in the embodiment of the present application may include the following steps 10 to 30:
and step 10, obtaining a topography map of the quicksand topography.
Optionally, when the flowing sand topography needs to be subjected to flowing effect processing, the position of the flowing sand topography to be processed needs to be input into the mapping processing device, or the flowing sand topography to be processed is directly circled on a display interface of the mapping processing device. Therefore, the mapping processing apparatus can acquire a topography map of the quicksand topography to be processed, wherein the topography map of the quicksand topography can be understood as a quicksand topography plane, and therefore, the acquired topography map is a static map and has no flowing effect.
Further, texture coordinates (UV Coordinates, or Texture Coordinates) of various maps are included in the quicksand terrain plane, the various maps including at least an attribute map, a normal map, and a noise map, wherein the attribute map can be understood as a base color map. In computer graphics, among other things, texture coordinates are used to locate a point or vertex on a texture map, thereby mapping the texture to the object surface, these coordinates being generally two-dimensional, denoted by (U, V), similar to cartesian coordinates on a plane.
Further, the basic color map (Albedo Map) is used for describing the color of the object surface, is a map reflecting the color of the object surface itself, generally includes basic color information of the object, does not include lighting effects such as shadows, highlights and the like, and is mainly used for defining the color and texture of the object. The Normal Map (Normal Map) is used for simulating the fine concave-convex texture of the surface of the object, and the purpose of generating illumination effect during rendering is achieved by modifying the Normal information of the vertexes, and each pixel in the Normal Map stores information related to the Normal direction of the surface of the object. Noise maps (Noise maps) are used to add natural randomness and detail to the surface of objects, often to simulate irregular textures, roughness and other fine details of natural materials, and thus can be used to create various effects such as simulating stone particles, wood textures, or increasing the visual complexity and realism of surfaces.
And step 20, mapping the topographic map in response to the operation instruction for the topographic map, so as to obtain an initial flow map of the topographic map.
Alternatively, when it is desired to perform a flow effect process on the topographic map, the user may need to operate on the topographic map at the interface of the map processing device. Accordingly, the mapping processing apparatus performs mapping processing on the topographic map in response to the operation instruction for the topographic map, resulting in an initial flow map of the topographic map, as specifically described in steps 201 to 202. The initial flow map obtained after the processing is a flow map having a flow effect, wherein the initial flow map includes an initial attribute map, an initial normal map, and an initial noise map, and the topography map includes a static attribute map, a normal map, and a noise map, so that the initial attribute map, the initial normal map, and the initial noise map can be understood as the attribute map, the normal map, and the noise map having the flow effect, respectively, but the flow effect of the initial flow map at this time is not optimal, and therefore, the initial flow map needs to be optimized, and step 30 is performed.
And step 30, respectively processing the initial attribute mapping, the initial normal mapping and the initial noise mapping in the initial flow mapping according to a preset waveform function to obtain a target flow mapping of the topographic mapping so as to realize the flowing sand topographic flow effect of the topographic mapping based on the target flow mapping.
Optionally, after the initial flow map is processed in FlowMapPainter software, the map processing device imports the initial flow map into the Unity engine, and the initial flow map can be applied to the terrain materials in the Unity engine, and the flow effect of the quicksand on the terrain is realized by controlling the sampling and transformation of the initial flow map. In the embodiment of the application, the Unity engine at least comprises a fragment shader and a vertex shader, and a preset waveform function is also constructed in the Unity engine, wherein the waveform function can be understood as a triangular function such as a sine function, a cosine function and the like.
Further, the waveform functions include a first waveform function and a second waveform function having a phase difference. In an embodiment, the periods of the first waveform function and the second waveform function are the same, and the phase difference between the first waveform function and the second waveform function is half of the period of the first waveform function or the second waveform function. It can be understood that if the period of the first and second waveform functions is 2pi, the phase difference between the first and second waveform functions is 1pi.
It can be understood that, in the Unity engine, two waveform functions having the same period, which change with time but have a phase difference of half period, are respectively defined as a first waveform function phase0 and a second waveform function phase1, which are constructed by the c# script. Further, the embodiment of the application also constructs a function change weight value which changes along with the first waveform function phase0, wherein the function change weight value is shown as flowLerpFactor, and the function change weight value flowLerpFactor can enable the weight of the follow-up flow map to become 0 when the sampling is close to the maximum offset value, so that the fading-out is realized, and the seamless connection effect during the flow is achieved. The function change weight value flowLerpFactor may be specifically expressed as flowLerpFactor = |1- |phase0|2|, where|phase0| is a function value of the first waveform function phase0 that changes with time.
Optionally, the mapping processing device processes the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain a target attribute map, a target normal map and a target noise map, and determines the target attribute map, the target normal map and the target noise map as target flow maps of the terrain map, and as described in steps 301 to 305, it can be understood that the target flow map includes a target attribute map, a target normal map and a target noise map obtained after processing the initial attribute map, the initial normal map and the initial noise map.
The embodiment of the application acquires a topography map of a quicksand topography; responding to an operation instruction aiming at the topographic map, carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; and respectively processing the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map. Therefore, the embodiment of the application processes the flow mapping through the waveform function with the phase difference to obtain the target flow mapping, and the seamless connection effect of the mapping during flow is ensured through the target flow mapping, so that the flowing sand effect of the topography mapping is ensured to have flowing sensation, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography is realized in a flowing mapping mode, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode at the mobile end and a PC platform with poor performance through the characteristic of low performance consumption of the flowing mapping, and the compatibility of the flowing sand effect is improved.
In an alternative embodiment, referring to fig. 2, fig. 2 is a second flowchart of a method for implementing a flow effect provided in an embodiment of the present application, and descriptions of steps 201 to 202 are as follows:
step 201, responding to a texture coordinate operation instruction aiming at the topographic map, expanding the texture of the topographic map to obtain the texture layout of the topographic map;
And 202, responding to a mapping processing instruction aiming at the topographic map, and drawing the flowing direction and the flowing strength of the quicksand in each area in the topographic map according to the texture layout of the topographic map to obtain the initial flowing map of the topographic map.
Alternatively, the topographic map may first need to be imported into the DCC software and thus the user may need to drag the topographic map to the DCC software at the interface of the map processing device.
Further, after dragging the topographic map to the DCC software, a texture operation instruction for the topographic map is triggered in the DCC software, so that the map processing device expands the texture of the topographic map in response to the texture operation instruction for the topographic map to obtain the texture layout of the topographic map, which can be specifically understood as mapping and adjusting the texture of the topographic map to expand the texture into a texture plane in two dimensions.
Further, the map processing device imports FlowMapPainter the texture layout after the topographic map is flattened to the software. In FlowMapPainter software, the user can use the brush tool in FlowMapPainter software according to the texture layout to simulate the flowing direction and flowing strength of the flowing sand in each region in the topographic map, wherein different brush types and parameters can be used to simulate the flowing effect of the flowing sand. It will be understood that the user triggers the mapping process instruction for the topographic map in FlowMapPainter software, and therefore, the mapping process apparatus responds to the mapping process instruction for the topographic map, and draws the flowing direction and flowing intensity of the quicksand in each area in the topographic map according to the texture layout of the topographic map, and derives the drawn map, and the posted map is the flowing map for controlling the topographic quicksand, that is, the initial flowing map of the topographic map is obtained.
It should be noted that the drawn initial flow map is derived as an image file, and the initial flow map is usually a gray scale image, and different gray scale values represent the flow direction and flow intensity of different areas.
In an alternative embodiment, steps 301 through 305 are described as follows:
Step 301, obtaining attribute texture coordinates of an initial attribute map, normal texture coordinates of an initial normal map and noise texture coordinates of an initial noise map;
step 302, determining final flow texture coordinates based on the attribute texture coordinates;
Step 303, processing the initial attribute map based on the waveform function, the final flow texture coordinate and the normal texture coordinate to obtain a target attribute map;
Step 304, processing the initial normal map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain a target normal map;
And 305, processing the initial noise map based on the waveform function, the final flow texture coordinates and the noise texture coordinates to obtain a target noise map.
Optionally, after the initial flow map is imported into the Unity engine, the map processing device performs subsequent function development by using a shader language, and it should be noted that, when the initial flow map is imported into the Unity engine, it is required to obtain an attribute texture coordinate of the initial attribute map, a normal texture coordinate of the initial normal map, and a noise texture coordinate of the initial noise map, where the attribute texture coordinate is denoted by texcoord, the normal texture coordinate is denoted by tilingUV and the noise texture coordinate noiseUV, the attribute texture coordinate texcoord, and the calculation process of the normal texture coordinate tilingUV and the noise texture coordinate noiseUV is as follows:
For attribute texture coordinates texcoord: if the quicksand terrain is a grid of vertices, the vertex coordinates may be used as the attribute texture coordinates texcoord of the base color map. If the terrain is rendered using a fragment shader, then the position of the fragment in screen space may be used to calculate attribute texture coordinates texcoord, for example, by dividing the screen size to convert the coordinates of the screen space into attribute texture coordinates texcoord. The normal texture coordinates tilingUV share the same UV coordinates as the base color map. Noise maps are used to add natural randomness and detail to the terrain, and thus noise texture coordinates noiseUV can be derived by scaling, rotating, and shifting the attribute texture coordinates texcoord of the base color map.
Further, the map processing device determines final flow texture coordinates according to the attribute texture coordinates texcoord, as specifically described in steps 3021 to 3024.
Further, the mapping processing device processes the initial attribute mapping according to the waveform function, the final flow texture coordinate and the normal texture coordinate tilingUV to obtain the target attribute mapping, as described in steps 3031 to 3032. Meanwhile, the mapping processing device processes the initial normal mapping according to the waveform function, the final flow texture coordinate and the normal texture coordinate tilingUV to obtain the target normal mapping. Meanwhile, the initial noise map is processed by the map processing device according to the waveform function, the final flow texture coordinates and the noise texture coordinates noiseUV, and the target noise map is obtained.
According to the embodiment of the application, the flow mapping is processed through the waveform function with the phase difference, so that the seamless connection effect during mapping flow is ensured, the flowing effect of the flowing sand surface in the flowing sand topography is ensured to have flowing feeling, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode through the characteristic of low performance consumption of the flow mapping, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized at a mobile end and a PC platform with poor performance, and the compatibility of the flowing sand effect is improved.
In an alternative embodiment, steps 3031 through 3032 are described as follows:
Step 3031, determining texture coordinate differences based on the normal texture coordinates and the final flow texture coordinates;
Step 3032, processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map.
Optionally, the process of obtaining the target attribute map includes: the texture coordinate difference of the initial attribute map is obtained by the map processing device by differencing the normal texture coordinate tilingUV and the final flow texture coordinate flowDirUV1, and therefore, the texture coordinate difference of the initial attribute map can be expressed as: normal texture coordinates tilingUV-final flow texture coordinates flowDirUV.
Further, the mapping processing device processes the initial attribute map according to the texture coordinate difference value of the initial attribute map, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map, as described in steps 30321 to 30322.
Similarly, the process of obtaining the target normal map is as follows: the texture coordinate difference of the initial normal map is obtained by the map processing device by differencing the normal texture coordinate tilingUV and the final flow texture coordinate flowDirUV1, and therefore, the texture coordinate difference of the initial normal map can be expressed as: normal texture coordinates tilingUV-final flow texture coordinates flowDirUV. Further, the mapping processing device processes the initial normal mapping according to the texture coordinate difference value of the initial normal mapping, the first waveform function, the second waveform function and the function change weight value to obtain the target normal mapping.
Similarly, the process of obtaining the target noise map is as follows: the texture coordinate difference of the initial noise map is obtained by the map processing device by differentiating the noise texture coordinate noiseUV and the final flow texture coordinate flowDirUV1, and therefore, the texture coordinate difference of the initial noise map can be expressed as: noise texture coordinates noiseUV-final flow texture coordinates flowDirUV. Further, the mapping processing device processes the initial noise mapping according to the texture coordinate difference value of the initial noise mapping, the first waveform function, the second waveform function and the function change weight value to obtain the target noise mapping.
According to the embodiment of the application, the flow mapping is processed through the waveform function with the phase difference, so that the seamless connection effect during mapping flow is ensured, the flowing effect of the flowing sand surface in the flowing sand topography is ensured to have flowing feeling, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode through the characteristic of low performance consumption of the flow mapping, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized at a mobile end and a PC platform with poor performance, and the compatibility of the flowing sand effect is improved.
In an alternative embodiment, steps 30321 through 30322 are described as follows:
step 30321, sampling the initial attribute map based on the texture coordinate difference value, the first waveform function and the second waveform function to obtain a first sampling result and a second sampling result of the initial attribute map;
And step 30322, performing interpolation processing on the first sampling result and the second sampling result based on the function change weight value to obtain the target attribute map.
Optionally, the process of obtaining the target attribute map includes: the mapping processing device carries out product calculation on the texture coordinate difference value of the initial attribute mapping and the first waveform function phase0 to obtain a first calculation result, and carries out product calculation on the texture coordinate difference value of the initial attribute mapping and the second waveform function phase1 to obtain a second calculation result, so that the phases of the obtained first calculation result and the second calculation result are different by half period, but the flowing texture coordinates with the same flowing period are obtained.
Further, the mapping processing device samples the initial attribute mapping through the first calculation result and the second calculation result respectively to obtain a first sampling result and a second sampling result of the initial attribute mapping, so that the flowing period of the first sampling result and the flowing period of the second sampling result are the same, the phase difference between the first sampling result and the second sampling result is half of the flowing period of the first sampling result or the flowing period of the second sampling result, the first sampling result can be expressed as albedoColor0, and the second sampling result can be expressed as albedoColor1.
Further, the mapping processing device interpolates the first sampling result and the second sampling result through the function change weight flowLerpFactor to obtain the target attribute mapping. In the embodiment of the application, interpolation processing is performed by a lerp algorithm, and the formula of the lerp algorithm is as follows:
Result=lerp(a,b,x)→Result=a*(1-x)+b*x
Thus, the interpolation process can be understood as: and substituting the first sampling result albedoColor and the second sampling result albedoColor1 into a and b in the above formula respectively, and substituting the function change weight value flowLerpFactor into x in the above formula to obtain the target attribute map.
Similarly, the process of obtaining the target normal map is as follows: the mapping processing device carries out product calculation on the texture coordinate difference value of the initial normal mapping and the first waveform function phase0 to obtain a first calculation result, and carries out product calculation on the texture coordinate difference value of the initial normal mapping and the second waveform function phase1 to obtain a second calculation result, so that the phases of the obtained first calculation result and the second calculation result are different by half a period, but the flowing texture coordinates with the same flowing period are obtained.
Further, the mapping processing device samples the initial normal mapping through the first calculation result and the second calculation result respectively to obtain a first sampling result and a second sampling result of the initial normal mapping, so that the flow period of the first sampling result and the flow period of the second sampling result are the same, the phase difference between the first sampling result and the second sampling result is half of the flow period of the first sampling result or the second sampling result, the first sampling result can be expressed as normalMap0, and the second sampling result can be expressed as normalMap1.
Further, the mapping processing device performs interpolation processing on the first sampling result and the second sampling result through the function change weight flowLerpFactor to obtain the target normal mapping. In the embodiment of the application, interpolation processing is performed by a lerp algorithm, and the formula of the lerp algorithm is as follows:
Result=lerp(a,b,x)→Result=a*(1-x)+b*x
Thus, the interpolation process can be understood as: and substituting the first sampling result normalMap and the second sampling result normalMap1 into a and b in the above formula respectively, and substituting the function change weight value flowLerpFactor into x in the above formula to obtain the target attribute map.
Similarly, the process of obtaining the target noise map is as follows: the mapping processing device carries out product calculation on the texture coordinate difference value of the initial noise mapping and the first waveform function phase0 to obtain a first calculation result, and carries out product calculation on the texture coordinate difference value of the initial noise mapping and the second waveform function phase1 to obtain a second calculation result, so that the phases of the obtained first calculation result and the second calculation result are different by half period, but the flowing texture coordinates with the same flowing period are obtained.
Further, the mapping processing device samples the initial noise mapping through the first calculation result and the second calculation result respectively to obtain a first sampling result and a second sampling result of the initial noise mapping, so that the flowing period of the first sampling result and the flowing period of the second sampling result are the same, the phase difference between the first sampling result and the second sampling result is half of the flowing period of the first sampling result or the flowing period of the second sampling result, the first sampling result can be expressed as noiseGlitterOut0, and the second sampling result can be expressed as noiseGlitterOut.
Further, the mapping processing device interpolates the first sampling result and the second sampling result through the function change weight flowLerpFactor to obtain the target noise mapping. In the embodiment of the application, interpolation processing is performed by a lerp algorithm, and the formula of the lerp algorithm is as follows:
Result=lerp(a,b,x)→Result=a*(1-x)+b*x
Thus, the interpolation process can be understood as: and substituting the first sampling result noiseGlitterOut and the second sampling result noiseGlitterOut1 into a and b in the above formula respectively, and substituting the function change weight value flowLerpFactor into x in the above formula to obtain the target attribute map.
According to the embodiment of the application, the flow mapping is processed through the waveform function with the phase difference, so that the seamless connection effect during mapping flow is ensured, the flowing effect of the flowing sand surface in the flowing sand topography is ensured to have flowing feeling, and meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode through the characteristic of low performance consumption of the flow mapping, so that the flowing effect of the flowing sand surface in the flowing sand topography can be realized at a mobile end and a PC platform with poor performance, and the compatibility of the flowing sand effect is improved.
In an alternative embodiment, referring to fig. 3, fig. 3 is a third flow chart of a method for implementing a flow effect provided in an embodiment of the present application, and the descriptions of steps 3021 to 3024 are as follows:
step 3021, obtaining a first vertical downward vector of initial flow map vertex coordinates in a tangent space;
Step 3022, sampling the initial flow map based on the attribute texture coordinates to obtain a first coordinate value of the initial flow map in the abscissa direction and a second coordinate value of the initial flow map in the ordinate direction;
step 3023, performing numerical mapping on the first coordinate value and the second coordinate value in a preset range to obtain an initial flow texture coordinate;
A final flow texture coordinate is determined based on the initial flow texture coordinate and the first vertical down vector, step 3024.
Optionally, the mapping processing apparatus obtains a first vertical downward vector of the vertex coordinates in the initial flow mapping in tangential space, where the first vertical downward vector may be denoted by GRAVITYDIR, and the specific obtaining process is described in steps 30211 to 30213.
Further, the mapping processing device samples the initial flow mapping by taking the attribute texture coordinates texcoord as sampling texture coordinates to obtain a first coordinate value x of the initial flow mapping in the abscissa direction (x-axis direction) and a second coordinate value y of the initial flow mapping in the ordinate direction (y-axis direction). Further, the mapping processing device multiplies the first coordinate value x and the second coordinate value y obtained by sampling by 2 by 1, and maps the calculated results to a preset range (-1, 1) respectively to obtain an initial flow texture coordinate flowDirUV2.
It should be noted that, the initial flow texture coordinate flowDirUV indicates the flow direction of each pixel point in the initial flow map, and in the embodiment of the present application, by mapping the sampling result to the range from-1 to 1, a two-dimensional vector may be conveniently used to indicate the flow direction, the x component indicates the flow in the horizontal direction, and the y component indicates the flow in the vertical direction.
Further, the mapping processing apparatus determines the final flow texture coordinate flowDirUV1 according to the initial flow texture coordinate flowDirUV and the first vertical down vector GRAVITYDIR by: the mapping processing unit performs point multiplication on the initial flow texture coordinates flowDirUV and the first vertical down vector GRAVITYDIR to obtain a down intensity vector, which may be represented as GRAVITYSTRENGTH, and thus the calculation formula of the vertical down intensity vector GRAVITYSTRENGTH may be represented as: GRAVITYSTRENGTH = flowDirUV 1. GRAVITYDIR. Further, the mapping processing unit multiplies the downward intensity vector GRAVITYSTRENGTH by the first vertical downward vector GRAVITYDIR to obtain the final flow texture coordinate flowDirUV1, and thus, the calculation formula of the final flow texture coordinate flowDirUV can be expressed as: flowDirUV = GRAVITYSTRENGTH × GRAVITYDIR.
According to the embodiment of the application, the final flow texture coordinates are determined according to the initial flow texture coordinates and the first vertical downward vector, so that the initial flow map is adjusted and corrected according to the final flow texture coordinates, a target flow map with better effect is obtained, and the flow effect of the final target flow map is enabled to have more flow sensation and granular sensation, so that the flowing sand effect is ensured to have flow sensation.
In an alternative embodiment, steps 30211 through 30213 are described as follows:
step 30211, obtaining tangential direction vector, auxiliary tangential direction vector and normal direction vector of the vertex coordinates in world space;
step 30212, constructing a vector matrix of vertex coordinates in world space based on the tangential direction vector, the secondary tangential direction vector and the normal direction vector;
In step 30213, a second vertical downward vector of the vertex coordinates in world space is mapped into tangent space based on the vector matrix, resulting in a first vertical downward vector of the vertex coordinates in tangent space.
Optionally, in the vertex shader of the Unity engine, the vertical downward vector (0, -1, 0) of the vertex coordinates in the world space in the initial flow map is transferred to the tangent space through matrix calculation, so as to obtain the vertical downward vector GRAVITYDIR of the vertex coordinates in the initial flow map in the tangent space, and the influence of gravity is added to the flow of the flowing sand, specifically:
Optionally, the mapping processing device obtains a tangential direction vector, a sub-tangential direction vector and a normal direction vector of the vertex coordinates in the initial flow mapping in world space, wherein the tangential direction vector, the normal direction vector and the sub-tangential direction vector are vectors perpendicular to each other in pairs.
Further, the mapping processing device constructs a vector matrix of vertex coordinates in world space according to the tangential direction vector, the auxiliary tangential direction vector and the normal direction vector, and the specific construction process is as described in step a to step d.
Further, the mapping processing device maps a second vertical downward vector (0, -1, 0) of the vertex coordinates in world space into tangent space according to the vector matrix, and the specific process of obtaining a first vertical downward vector GRAVITYDIR of the vertex coordinates in tangent space is as follows: and carrying out left multiplication calculation on the second vertical downward vector (0, -1, 0) and the vector matrix to obtain a first vertical downward vector GRAVITYDIR.
According to the embodiment of the application, the first vertical downward vector is calculated, a data basis is provided for calculating the final flow texture coordinate, so that the initial flow map is adjusted and corrected according to the final flow texture coordinate, a target flow map with better effect is obtained, and the flow effect of the final target flow map is enabled to have more flow sensation and granular sensation, so that the flowing sand effect is ensured to have flow sensation.
In an alternative embodiment, the descriptions of steps a through d are as follows:
Step a, sequentially sequencing tangential direction vectors, auxiliary tangential direction vectors and normal direction vectors to obtain a first row of vectors;
Step b, sequentially ordering the auxiliary tangential direction vector, the tangential direction vector and the normal direction vector to obtain a second row vector;
Step c, sequentially sequencing the normal direction vector, the tangential direction vector and the auxiliary tangential direction vector to obtain a third row vector;
and d, constructing a vector matrix based on the first row vector, the second row vector and the third row vector.
In the embodiment of the application, the tangential direction vector is expressed asThe sub tangential direction vector is denoted/>The normal direction vector is denoted/>
Alternatively, the mapping processing apparatus sequentially sorts the tangential direction vector, the sub tangential direction vector, and the normal direction vector to obtain a first row vector, and thus the first row vector may be expressed as
Alternatively, the mapping processing apparatus sequentially sorts the sub tangential direction vector, the tangential direction vector, and the normal direction vector to obtain a second row vector, and thus the second row vector may be expressed as
Optionally, the mapping processing unit sequentially sorts the normal direction vector, the tangential direction vector and the sub tangential direction vector to obtain a third row vector, so the third row vector may be expressed as
Optionally, the mapping processing apparatus sequentially arranges the first row vector, the second row vector and the third row vector according to rows, so as to construct a vector matrix M, so that the vector matrix M can be understood as a 3x3 matrix, and the vector matrix M can be expressed as:
According to the embodiment of the application, the vector matrix is constructed, a data basis is provided for calculating the final flow texture coordinates, so that the initial flow map is adjusted and corrected according to the final flow texture coordinates, the target flow map with better effect is obtained, the flow effect of the final target flow map is enabled to have more flow sensation and particle sensation, and therefore, the flowing sand effect is guaranteed to have flow sensation.
Thus, embodiments of the present application can be understood as: development and demonstration are carried out based on the Unity engine, and the technical implementation of the main body is realized by using a loader Shader language. Firstly, in DCC software, flattening texture coordinates UV of quicksand topography, and importing the developed texture layout into FlowMapPainter software, and in FlowMapPainter software, brushing the flowing direction and flowing strength of the quicksand in each region of the quicksand according to the texture layout. Then in the vertex Shader that calculates the quicksand loader, the vertical downward vector (0, -1, 0) in world space is turned down to tangent space, adding the influence of gravity to the flow of the quicksand later. Meanwhile, in the C# script, a waveform function with the same two periods and a phase difference of half period is calculated, so that a seamless connection effect in the process of flowing of the following mapping is achieved. And finally, in the fragment shader, the calculated final flow texture coordinates UV are used for sampling the basic color map, the normal line map and the noise map of the quicksand terrain, and the flow sensation and the particle sensation of the final quicksand effect are simulated.
Therefore, compared with other physical simulation schemes, the embodiment of the application has the advantages that the flowing sand ground surface realized in a flowing mapping mode is very friendly in performance consumption, and the PC platform with poor performance at the mobile end can also be perfectly operated. In addition, the high-quality quicksand surface effect in the game can be realized while the performance consumption is greatly reduced, the fluidity and granularity of the real quicksand flowing in the game can be well restored, and the artistic effect has high expansibility and expression effect.
The flow effect implementation device provided by the embodiment of the present application is described below, and the flow effect implementation device described below and the flow effect implementation method described above may be referred to correspondingly.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a device for realizing a flow effect according to an embodiment of the present application, where the device for realizing a flow effect may include:
an obtaining module 401, configured to obtain a topography map of a quicksand topography;
A first mapping processing module 402, configured to perform mapping processing on the topographic map in response to an operation instruction for the topographic map, so as to obtain an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
The second mapping processing module 403 is configured to process the initial attribute mapping, the initial normal mapping, and the initial noise mapping in the initial flow mapping according to a preset waveform function, so as to obtain a target flow mapping of the topography mapping, so as to implement a quicksand topography flow effect of the topography mapping based on the target flow mapping;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
According to the embodiment of the application, the target flow mapping is obtained by processing the flow mapping through the waveform function with the phase difference, and the seamless connection effect during mapping flow is ensured through the target flow mapping, so that the flowing sand effect of the topography mapping is ensured to have flowing sensation, meanwhile, the flowing effect of the flowing sand surface in the flowing sand topography is realized in a flowing mapping mode, and the flowing effect of the flowing sand surface in the flowing sand topography can be realized in a compatible operation mode at the mobile end and a PC platform with poor performance through the characteristic of low performance consumption of the flowing mapping, and the compatibility of the flowing sand effect is improved.
In an alternative embodiment, the second map processing module 403 is further configured to:
Acquiring attribute texture coordinates of the initial attribute map, normal texture coordinates of the initial normal map and noise texture coordinates of the initial noise map;
determining final flow texture coordinates based on the attribute texture coordinates;
processing the initial attribute map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target attribute map;
Processing the initial normal map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target normal map;
And processing the initial noise map based on the waveform function, the final flow texture coordinates and the noise texture coordinates to obtain the target noise map.
In an alternative embodiment, the second map processing module 403 is further configured to:
determining a texture coordinate difference based on the normal texture coordinate and the final flow texture coordinate;
Processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map; the function change weight value is determined based on the first waveform function.
In an alternative embodiment, the second map processing module 403 is further configured to:
Sampling the initial attribute map based on the texture coordinate difference value, the first waveform function and the second waveform function to obtain a first sampling result and a second sampling result of the initial attribute map; the flow period of the first sampling result and the flow period of the second sampling result are the same, and the phase difference between the first sampling result and the second sampling result is half of the flow period of the first sampling result or the second sampling result;
and carrying out interpolation processing on the first sampling result and the second sampling result based on the function change weight value to obtain the target attribute map.
In an alternative embodiment, the second map processing module 403 is further configured to:
acquiring a first vertical downward vector of vertex coordinates in the initial flow map in a tangent space;
Sampling the initial flow map based on the attribute texture coordinates to obtain a first coordinate value of the initial flow map in the abscissa direction and a second coordinate value of the initial flow map in the ordinate direction;
Respectively carrying out numerical mapping on the first coordinate value and the second coordinate value in a preset range to obtain an initial flow texture coordinate;
the final flow texture coordinates are determined based on the initial flow texture coordinates and the first vertical down vector.
In an alternative embodiment, the second map processing module 403 is further configured to:
obtaining tangential direction vectors, auxiliary tangential direction vectors and normal direction vectors of the vertex coordinates in world space; the tangential direction vector, the normal direction vector and the auxiliary tangential direction vector are vectors perpendicular to each other;
constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector and the normal direction vector;
and mapping a second vertical downward vector of the vertex coordinates in world space into tangent space based on the vector matrix to obtain a first vertical downward vector of the vertex coordinates in tangent space.
In an alternative embodiment, the second map processing module 403 is further configured to:
sequentially ordering the tangential direction vector, the auxiliary tangential direction vector and the normal direction vector to obtain a first row vector;
Sequentially ordering the auxiliary tangential direction vector, the tangential direction vector and the normal direction vector to obtain a second row vector;
Sequentially ordering the normal direction vector, the tangential direction vector and the auxiliary tangential direction vector to obtain a third row vector;
the vector matrix is constructed based on the first row vector, the second row vector, and the third row vector.
In an alternative embodiment, the first map processing module 402 is further configured to:
Responding to a texture coordinate operation instruction aiming at the topographic map, expanding the texture of the topographic map to obtain the texture layout of the topographic map;
and responding to a mapping processing instruction aiming at the topographic map, and drawing the flowing direction and the flowing strength of the quicksand in each area in the topographic map according to the texture layout of the topographic map to obtain the initial flowing map of the topographic map.
The specific embodiment of the device for realizing the flow effect provided by the application is basically the same as each embodiment of the method for realizing the flow effect, and is not described herein.
Optionally, as shown in fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may include: processor 510, communication interface (Communication Interface) 520, memory 530, and communication bus 540, wherein processor 510, communication interface 520, memory 530 complete communication with each other through communication bus 540. Processor 510 may invoke a computer program in memory 530 to perform the steps of a method of implementing a streaming effect, including:
Obtaining a topography map of the quicksand topography;
Responding to an operation instruction aiming at the topographic map, and carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
respectively processing an initial attribute map, an initial normal map and an initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
In an alternative embodiment, the periods of the first and second waveform functions are the same, and the phase difference between the first and second waveform functions is half the period of the first or second waveform functions.
In an alternative embodiment, the processing of the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain the target flow map of the topographic map includes:
Acquiring attribute texture coordinates of the initial attribute map, normal texture coordinates of the initial normal map and noise texture coordinates of the initial noise map;
determining final flow texture coordinates based on the attribute texture coordinates;
processing the initial attribute map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target attribute map;
Processing the initial normal map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target normal map;
And processing the initial noise map based on the waveform function, the final flow texture coordinates and the noise texture coordinates to obtain the target noise map.
In an alternative embodiment, processing the initial attribute map based on the waveform function, the final flow texture coordinates, and the normal texture coordinates to obtain the target attribute map includes:
determining a texture coordinate difference based on the normal texture coordinate and the final flow texture coordinate;
Processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map; the function change weight value is determined based on the first waveform function.
In an alternative embodiment, processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function, and a function change weight value to obtain the target attribute map includes:
Sampling the initial attribute map based on the texture coordinate difference value, the first waveform function and the second waveform function to obtain a first sampling result and a second sampling result of the initial attribute map; the flow period of the first sampling result and the flow period of the second sampling result are the same, and the phase difference between the first sampling result and the second sampling result is half of the flow period of the first sampling result or the second sampling result;
and carrying out interpolation processing on the first sampling result and the second sampling result based on the function change weight value to obtain the target attribute map.
In an alternative embodiment, determining final flow texture coordinates based on the attribute texture coordinates includes:
acquiring a first vertical downward vector of vertex coordinates in the initial flow map in a tangent space;
Sampling the initial flow map based on the attribute texture coordinates to obtain a first coordinate value of the initial flow map in the abscissa direction and a second coordinate value of the initial flow map in the ordinate direction;
Respectively carrying out numerical mapping on the first coordinate value and the second coordinate value in a preset range to obtain an initial flow texture coordinate;
the final flow texture coordinates are determined based on the initial flow texture coordinates and the first vertical down vector.
In an alternative embodiment, obtaining a first vertical downward vector of vertex coordinates in the initial flow map under tangential space comprises:
obtaining tangential direction vectors, auxiliary tangential direction vectors and normal direction vectors of the vertex coordinates in world space; the tangential direction vector, the normal direction vector and the auxiliary tangential direction vector are vectors perpendicular to each other;
constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector and the normal direction vector;
and mapping a second vertical downward vector of the vertex coordinates in world space into tangent space based on the vector matrix to obtain a first vertical downward vector of the vertex coordinates in tangent space.
In an alternative embodiment, constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector, and the normal direction vector, includes:
sequentially ordering the tangential direction vector, the auxiliary tangential direction vector and the normal direction vector to obtain a first row vector;
Sequentially ordering the auxiliary tangential direction vector, the tangential direction vector and the normal direction vector to obtain a second row vector;
Sequentially ordering the normal direction vector, the tangential direction vector and the auxiliary tangential direction vector to obtain a third row vector;
the vector matrix is constructed based on the first row vector, the second row vector, and the third row vector.
In an alternative embodiment, in response to an operation instruction for the topographic map, performing mapping processing on the topographic map to obtain an initial flow map of the topographic map, including:
Responding to a texture coordinate operation instruction aiming at the topographic map, expanding the texture of the topographic map to obtain the texture layout of the topographic map;
and responding to a mapping processing instruction aiming at the topographic map, and drawing the flowing direction and the flowing strength of the quicksand in each area in the topographic map according to the texture layout of the topographic map to obtain the initial flowing map of the topographic map.
Furthermore, the logic computer program in the memory 530 may be implemented in the form of a software functional unit and may be stored in a computer readable storage medium when sold or used as a separate product. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in the form of a software product stored in a storage medium, comprising a number of computer programs for causing a computer device (which may be a personal computer, a server, a network device, etc.) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, embodiments of the present application further provide a non-transitory computer readable storage medium, where the non-transitory computer readable storage medium includes a computer program, where the computer program may be stored on the non-transitory computer readable storage medium, and when the computer program is executed by a processor, the computer program may be capable of executing the steps of the implementation method of the flow effect provided by the foregoing embodiments, where the method includes:
Obtaining a topography map of the quicksand topography;
Responding to an operation instruction aiming at the topographic map, and carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
respectively processing an initial attribute map, an initial normal map and an initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
In an alternative embodiment, the periods of the first and second waveform functions are the same, and the phase difference between the first and second waveform functions is half the period of the first or second waveform functions.
In an alternative embodiment, the processing of the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to a preset waveform function to obtain the target flow map of the topographic map includes:
Acquiring attribute texture coordinates of the initial attribute map, normal texture coordinates of the initial normal map and noise texture coordinates of the initial noise map;
determining final flow texture coordinates based on the attribute texture coordinates;
processing the initial attribute map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target attribute map;
Processing the initial normal map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target normal map;
And processing the initial noise map based on the waveform function, the final flow texture coordinates and the noise texture coordinates to obtain the target noise map.
In an alternative embodiment, processing the initial attribute map based on the waveform function, the final flow texture coordinates, and the normal texture coordinates to obtain the target attribute map includes:
determining a texture coordinate difference based on the normal texture coordinate and the final flow texture coordinate;
Processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map; the function change weight value is determined based on the first waveform function.
In an alternative embodiment, processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function, and a function change weight value to obtain the target attribute map includes:
Sampling the initial attribute map based on the texture coordinate difference value, the first waveform function and the second waveform function to obtain a first sampling result and a second sampling result of the initial attribute map; the flow period of the first sampling result and the flow period of the second sampling result are the same, and the phase difference between the first sampling result and the second sampling result is half of the flow period of the first sampling result or the second sampling result;
and carrying out interpolation processing on the first sampling result and the second sampling result based on the function change weight value to obtain the target attribute map.
In an alternative embodiment, determining final flow texture coordinates based on the attribute texture coordinates includes:
acquiring a first vertical downward vector of vertex coordinates in the initial flow map in a tangent space;
Sampling the initial flow map based on the attribute texture coordinates to obtain a first coordinate value of the initial flow map in the abscissa direction and a second coordinate value of the initial flow map in the ordinate direction;
Respectively carrying out numerical mapping on the first coordinate value and the second coordinate value in a preset range to obtain an initial flow texture coordinate;
the final flow texture coordinates are determined based on the initial flow texture coordinates and the first vertical down vector.
In an alternative embodiment, obtaining a first vertical downward vector of vertex coordinates in the initial flow map under tangential space comprises:
obtaining tangential direction vectors, auxiliary tangential direction vectors and normal direction vectors of the vertex coordinates in world space; the tangential direction vector, the normal direction vector and the auxiliary tangential direction vector are vectors perpendicular to each other;
constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector and the normal direction vector;
and mapping a second vertical downward vector of the vertex coordinates in world space into tangent space based on the vector matrix to obtain a first vertical downward vector of the vertex coordinates in tangent space.
In an alternative embodiment, constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector, and the normal direction vector, includes:
sequentially ordering the tangential direction vector, the auxiliary tangential direction vector and the normal direction vector to obtain a first row vector;
Sequentially ordering the auxiliary tangential direction vector, the tangential direction vector and the normal direction vector to obtain a second row vector;
Sequentially ordering the normal direction vector, the tangential direction vector and the auxiliary tangential direction vector to obtain a third row vector;
the vector matrix is constructed based on the first row vector, the second row vector, and the third row vector.
In an alternative embodiment, in response to an operation instruction for the topographic map, performing mapping processing on the topographic map to obtain an initial flow map of the topographic map, including:
Responding to a texture coordinate operation instruction aiming at the topographic map, expanding the texture of the topographic map to obtain the texture layout of the topographic map;
and responding to a mapping processing instruction aiming at the topographic map, and drawing the flowing direction and the flowing strength of the quicksand in each area in the topographic map according to the texture layout of the topographic map to obtain the initial flowing map of the topographic map.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the above technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., comprising a number of computer programs for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (12)

1. A method for implementing a flow effect, comprising:
Obtaining a topography map of the quicksand topography;
Responding to an operation instruction aiming at the topographic map, and carrying out mapping treatment on the topographic map to obtain an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
respectively processing an initial attribute map, an initial normal map and an initial noise map in the initial flow map according to a preset waveform function to obtain a target flow map of the topographic map, so as to realize the flowing sand topographic flow effect of the topographic map based on the target flow map;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
2. The method according to claim 1, wherein the periods of the first waveform function and the second waveform function are the same, and the phase difference between the first waveform function and the second waveform function is half of the period of the first waveform function or the second waveform function.
3. The method for realizing the flow effect according to claim 1, wherein the processing the initial attribute map, the initial normal map and the initial noise map in the initial flow map according to the preset waveform function to obtain the target flow map of the topographic map comprises:
Acquiring attribute texture coordinates of the initial attribute map, normal texture coordinates of the initial normal map and noise texture coordinates of the initial noise map;
determining final flow texture coordinates based on the attribute texture coordinates;
processing the initial attribute map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target attribute map;
Processing the initial normal map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target normal map;
And processing the initial noise map based on the waveform function, the final flow texture coordinates and the noise texture coordinates to obtain the target noise map.
4. A method of implementing a flow effect according to claim 3, wherein said processing the initial attribute map based on the waveform function, the final flow texture coordinates and the normal texture coordinates to obtain the target attribute map comprises:
determining a texture coordinate difference based on the normal texture coordinate and the final flow texture coordinate;
Processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function and the function change weight value to obtain the target attribute map; the function change weight value is determined based on the first waveform function.
5. The method according to claim 4, wherein the processing the initial attribute map based on the texture coordinate difference value, the first waveform function, the second waveform function, and a function change weight value to obtain the target attribute map includes:
Sampling the initial attribute map based on the texture coordinate difference value, the first waveform function and the second waveform function to obtain a first sampling result and a second sampling result of the initial attribute map; the flow period of the first sampling result and the flow period of the second sampling result are the same, and the phase difference between the first sampling result and the second sampling result is half of the flow period of the first sampling result or the second sampling result;
and carrying out interpolation processing on the first sampling result and the second sampling result based on the function change weight value to obtain the target attribute map.
6. A method of implementing a flow effect according to claim 3, wherein said determining final flow texture coordinates based on said attribute texture coordinates comprises:
acquiring a first vertical downward vector of vertex coordinates in the initial flow map in a tangent space;
Sampling the initial flow map based on the attribute texture coordinates to obtain a first coordinate value of the initial flow map in the abscissa direction and a second coordinate value of the initial flow map in the ordinate direction;
Respectively carrying out numerical mapping on the first coordinate value and the second coordinate value in a preset range to obtain an initial flow texture coordinate;
the final flow texture coordinates are determined based on the initial flow texture coordinates and the first vertical down vector.
7. The method of claim 6, wherein the obtaining a first vertical downward vector of vertex coordinates in the initial flow map in tangential space comprises:
obtaining tangential direction vectors, auxiliary tangential direction vectors and normal direction vectors of the vertex coordinates in world space; the tangential direction vector, the normal direction vector and the auxiliary tangential direction vector are vectors perpendicular to each other;
constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector and the normal direction vector;
and mapping a second vertical downward vector of the vertex coordinates in world space into tangent space based on the vector matrix to obtain a first vertical downward vector of the vertex coordinates in tangent space.
8. The method according to claim 7, wherein constructing a vector matrix of the vertex coordinates in the world space based on the tangential direction vector, the secondary tangential direction vector, and the normal direction vector comprises:
sequentially ordering the tangential direction vector, the auxiliary tangential direction vector and the normal direction vector to obtain a first row vector;
Sequentially ordering the auxiliary tangential direction vector, the tangential direction vector and the normal direction vector to obtain a second row vector;
Sequentially ordering the normal direction vector, the tangential direction vector and the auxiliary tangential direction vector to obtain a third row vector;
the vector matrix is constructed based on the first row vector, the second row vector, and the third row vector.
9. The method according to any one of claims 1 to 8, wherein said mapping said topographic map in response to an operation command for said topographic map to obtain an initial flow map for said topographic map, comprises:
Responding to a texture coordinate operation instruction aiming at the topographic map, expanding the texture of the topographic map to obtain the texture layout of the topographic map;
and responding to a mapping processing instruction aiming at the topographic map, and drawing the flowing direction and the flowing strength of the quicksand in each area in the topographic map according to the texture layout of the topographic map to obtain the initial flowing map of the topographic map.
10. A device for achieving a flow effect, comprising:
The acquisition module is used for acquiring a topography map of the quicksand topography;
the first mapping processing module is used for responding to the operation instruction aiming at the topographic map, mapping the topographic map, and obtaining an initial flow map of the topographic map; the initial flow map comprises an initial attribute map, an initial normal map and an initial noise map;
The second mapping processing module is used for respectively processing the initial attribute mapping, the initial normal mapping and the initial noise mapping in the initial flow mapping according to a preset waveform function to obtain a target flow mapping of the topographic mapping so as to realize the flowing sand topographic flow effect of the topographic mapping based on the target flow mapping;
The target flow map comprises a target attribute map, a target normal map and a target noise map which are obtained by processing the initial attribute map, the initial normal map and the initial noise map respectively; the waveform functions include a first waveform function and a second waveform function having a phase difference.
11. An electronic device comprising a processor and a memory, the memory storing a plurality of computer programs; the processor loads a computer program from the memory to perform the method of implementing a flow effect as claimed in any one of claims 1 to 9.
12. A computer readable storage medium, characterized in that it stores a plurality of computer programs adapted to be loaded by a processor for executing the method of implementing a flow effect according to any of claims 1 to 9.
CN202410255311.6A 2024-03-06 2024-03-06 Method and device for realizing flow effect, electronic equipment and computer storage medium Pending CN118045352A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410255311.6A CN118045352A (en) 2024-03-06 2024-03-06 Method and device for realizing flow effect, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410255311.6A CN118045352A (en) 2024-03-06 2024-03-06 Method and device for realizing flow effect, electronic equipment and computer storage medium

Publications (1)

Publication Number Publication Date
CN118045352A true CN118045352A (en) 2024-05-17

Family

ID=91044772

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410255311.6A Pending CN118045352A (en) 2024-03-06 2024-03-06 Method and device for realizing flow effect, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN118045352A (en)

Similar Documents

Publication Publication Date Title
CN106373187B (en) Two dimensional image based on AR is converted to the implementation method of three-dimensional scenic
KR101145260B1 (en) Apparatus and method for mapping textures to object model
US7468730B2 (en) Volumetric hair simulation
US7983884B2 (en) Water particle manipulation
US10163243B2 (en) Simulation of hair in a distributed computing environment
Su et al. Multi-dimensional visualization of large-scale marine hydrological environmental data
US20130120386A1 (en) Systems and Methods for Simulating the Effects of Liquids on a Camera Lens
US8847963B1 (en) Systems and methods for generating skin and volume details for animated characters
US8902234B1 (en) Simulation primitives
US8665261B1 (en) Automatic spatial correspondence disambiguation
Schmidt et al. Sketching, scaffolding, and inking: a visual history for interactive 3D modeling
Yan et al. A non-photorealistic rendering method based on Chinese ink and wash painting style for 3D mountain models
US9317967B1 (en) Deformation of surface objects
US8952968B1 (en) Wave modeling for computer-generated imagery using intersection prevention on water surfaces
US8786611B1 (en) Sliding skin deformer
KR20160109692A (en) Method for generation of coloring design using 3d model, recording medium and device for performing the method
CN118045352A (en) Method and device for realizing flow effect, electronic equipment and computer storage medium
Gois et al. Interactive shading of 2.5 D models.
Kageyama et al. IMMERSIVE VR VISUALIZATIONS BY VFIVE PART 1: DEVELOPMENT
Wang et al. LVDIF: a framework for real-time interaction with large volume data
García-Feal et al. Advanced fluid visualization with DualSPHysics and Blender
US9639981B1 (en) Tetrahedral Shell Generation
US8077183B1 (en) Stepmode animation visualization
Kang et al. Real-time cloud modelling and rendering approach based on L-system for flight simulation
US8010330B1 (en) Extracting temporally coherent surfaces from particle systems

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination