Image processing method and device, computer device and storage medium
By obtaining the vertex coordinates and normal texture maps of the water surface area, and simulating the changes in water flow speed and time, the problem of poor rendering of the water surface area in the navigation map was solved, and realistic rendering of dynamic effects was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-03-22
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, the rendering effect of water areas in navigation maps is poor, and the use of solid color filling usually results in an unrealistic effect.
By obtaining the coordinates of multiple vertices in the water surface area, combining the dynamic information of the water surface area with the normal texture map, the target texture information of the vertices is determined, and the water surface area is rendered based on this information to simulate the dynamic changes in water flow speed and time.
Dynamic special effects rendering of the water surface area has been achieved, improving the rendering effect and making the water surface display more realistic.
Smart Images

Figure CN116828207B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an image processing method, apparatus, computer equipment, and storage medium. Background Technology
[0002] With the development of computer technology, navigation maps are widely used in people's daily lives. These navigation maps include water areas, which are rendered to represent these areas. How to render realistic water surfaces has become a key research focus in the industry.
[0003] Currently, water areas in navigation maps are typically rendered using solid color fills, resulting in poor rendering quality. Summary of the Invention
[0004] This application provides an image processing method, apparatus, computer device, and storage medium that enables dynamic effects to be displayed on water surfaces, resulting in better rendering. The technical solution is as follows:
[0005] On the one hand, an image processing method is provided, the method comprising:
[0006] Obtain the coordinates of the first vertex of multiple vertices in the water surface region of the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image.
[0007] Based on the dynamic information and normal texture map of the water surface area, the target texture information of the plurality of vertices is determined. The dynamic information includes water flow speed and water flow time. The normal texture map is used to represent the correspondence between the pixels in the normal texture map and the texture information. The target texture information is used to represent the texture of the vertex.
[0008] The water surface area is rendered based on the target texture information of the multiple vertices.
[0009] On the other hand, an image processing apparatus is provided, the apparatus comprising:
[0010] The acquisition module is used to acquire the coordinates of the first vertex of multiple vertices of the water surface region in the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image.
[0011] The determination module is used to determine the target texture information of the plurality of vertices based on the dynamic information of the water surface region and the normal texture map. The dynamic information includes water flow speed and water flow time. The normal texture map is used to represent the correspondence between the pixels in the normal texture map and the texture information. The target texture information is used to represent the texture of the vertex.
[0012] The rendering module is used to render the water surface area based on the target texture information of the multiple vertices.
[0013] In some embodiments, the determining module includes:
[0014] The first determining unit is configured to, for any vertex, determine at least two second vertex coordinates of the vertex based on at least two water flow velocities and water flow times in the dynamic information and the first vertex coordinates of the vertex, wherein the second vertex coordinates are used to represent the position of the vertex after offset in the target image;
[0015] The second determining unit is used to determine the target texture information of the vertex based on the coordinates of the at least two second vertices and the normal texture map.
[0016] In some embodiments, the first determining unit includes:
[0017] The first determining subunit is used to determine the coordinates of the third vertex corresponding to the coordinates of the first vertex based on the mapping relationship between the target image and the target map, wherein the coordinates of the third vertex are used to represent the position of the vertex in the target map;
[0018] The second determining subunit is used to determine at least two fourth vertex coordinates of the vertex based on the third vertex coordinates, the at least two water flow velocities, and the water flow time, wherein the fourth vertex coordinates are used to represent the position of the vertex after offset in the target map;
[0019] The first determining subunit is further configured to determine the coordinates of the at least two second vertices corresponding to the coordinates of the at least two fourth vertices based on the mapping relationship.
[0020] In some embodiments, the second determining subunit is used to determine at least two offsets of the vertex based on the at least two water flow velocities and the water flow time; and to offset the coordinates of the third vertex based on the at least two offsets to obtain the coordinates of the at least two fourth vertices.
[0021] In some embodiments, the normal texture map includes normal vectors corresponding to pixels;
[0022] The second determining unit includes:
[0023] A sub-unit is obtained for acquiring at least two normal vectors from the normal texture map based on the coordinates of the at least two second vertices, wherein the at least two normal vectors are the normal vectors of at least two pixels indicated by the coordinates of the at least two second vertices;
[0024] The third determining subunit is used to determine the target texture information of the vertex based on the at least two normal vectors.
[0025] In some embodiments, the third determining subunit is configured to: obtain the initial texture coordinates of the vertex, the initial texture coordinates corresponding to the coordinates of the first vertex; add the at least two normal vectors to obtain a target normal vector; determine the target texture coordinates of the vertex based on the initial texture coordinates of the vertex and the target normal vector; and determine the target texture information based on the target texture coordinates.
[0026] In some embodiments, the third determining subunit is used to offset the initial texture coordinates based on the magnitude of the target normal vector to obtain the target texture coordinates.
[0027] In some embodiments, the rendering module is configured to obtain multiple target colors from a color texture map based on the target texture information of the multiple vertices, wherein the color texture map is used to represent the correspondence between texture information and colors; and to render the water surface area based on the multiple target colors.
[0028] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded and executed by the processor to implement the image processing method in the embodiments of this application.
[0029] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, the at least one computer program being loaded and executed by a processor to implement the image processing method as described in the embodiments of this application.
[0030] On the other hand, a computer program product or computer program is provided, which includes computer program code stored in a computer-readable storage medium. A processor of a computer device reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the computer device to perform the image processing method provided in the above aspects or various alternative implementations.
[0031] The solution provided in this application embodiment obtains target texture information of multiple vertices through dynamic information and normal texture mapping of the water surface area in the target image, so that the target texture information can reflect the dynamic changes of the multiple vertices based on the water flow speed during the water flow time, and then renders the water surface area based on the target texture information, so that the water surface area can display dynamic effects and the rendering effect is better. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 This is a schematic diagram of the implementation environment of an image processing method provided according to an embodiment of this application;
[0034] Figure 2 This is a flowchart of an image processing method provided according to an embodiment of this application;
[0035] Figure 3 This is a flowchart of another image processing method provided according to an embodiment of this application;
[0036] Figure 4 This is a schematic diagram of a water surface area according to an embodiment of this application;
[0037] Figure 5 This is a schematic diagram of a normal texture map provided according to an embodiment of this application;
[0038] Figure 6 This is a flowchart of rendering a water surface area according to an embodiment of this application;
[0039] Figure 7 This is a schematic diagram of the structure of an image processing apparatus according to an embodiment of this application;
[0040] Figure 8 This is a schematic diagram of another image processing apparatus provided according to an embodiment of this application;
[0041] Figure 9 This is a structural block diagram of a terminal provided according to an embodiment of this application. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be further described below with reference to the accompanying drawings.
[0043] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor are there any restrictions on quantity or execution order.
[0044] In this application, the term "at least one" means one or more, and "multiple" means two or more.
[0045] It should be noted that all information (including but not limited to the target's device information, the target's personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the target or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the normal texture maps involved in this application were obtained with full authorization.
[0046] For ease of understanding, the terms used in this application are explained below.
[0047] OpenGL ES is a rendering engine that runs on mobile devices. Other rendering engines include Unity3D (Unity Three-Dimensional) and Unreal Engine.
[0048] Texture: refers to the uneven grooves on the surface of an object, as well as the patterns on the smooth surface of an object.
[0049] Normal mapping: A type of texture that uses RGB color channels to mark the direction of normals. The normal is the normal at every point on the surface of an object, whether it be uneven or not.
[0050] The rendering pipeline is the process of converting objects from a 3D scene into an image within a 2D scene, and ultimately displaying that image. This rendering pipeline includes vertex shaders and fragment shaders. In this embodiment, water surfaces from the target map are rendered into the target image.
[0051] Vertex shader: A shader program that runs in a GPU (Graphics Processing Unit) and is used to perform coordinate transformations and other processing on the vertices of an object.
[0052] Fragment shader: This is a shader program that runs in the GPU and is used to determine the color of an object to be rendered on the terminal screen based on the object's texture information. It can also be called a pixel shader.
[0053] Sampling: This refers to the method OpenGL ES uses texture coordinates to read data from corresponding positions on a texture. In this embodiment, sampling is the process of obtaining the target color from a color texture map using texture coordinates.
[0054] The information display method provided in this application can be executed by a computer device. In some embodiments, the computer device is a terminal or a server. The following section first uses a computer device as an example to describe the implementation environment of the image processing method provided in this application. Figure 1 This is a schematic diagram illustrating the implementation environment of an image processing method according to an embodiment of this application. See also... Figure 1 The implementation environment includes terminal 101 and server 102. Terminal 101 and server 102 can be connected directly or indirectly via wired or wireless communication, which is not limited herein.
[0055] In some embodiments, terminal 101 may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, smart voice interaction device, smart home appliance, in-vehicle terminal, etc., but is not limited thereto. Terminal 101 has an application that supports image display installed and running. This application may be a navigation application, a multimedia application, or a game application, etc., and this embodiment of the application does not impose any limitations on this. Taking a navigation application as an example, the navigation application provides a target map. Terminal 101 can display a target image, which corresponds to a portion of the target map, and the target image includes a water surface area. Terminal 101 can render the displayed water surface area through the navigation application.
[0056] In some embodiments, server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 102 is used to provide background services for applications that support image display. In some embodiments, server 102 undertakes the main computing work, and terminal 101 undertakes the secondary computing work; or, server 102 undertakes the secondary computing work, and terminal 101 undertakes the main computing work; or, server 102 and terminal 101 collaborate on computing using a distributed computing architecture.
[0057] Figure 2 This is a flowchart of an image processing method according to an embodiment of this application. See also: Figure 2In this embodiment, the method is described using an execution method performed by a terminal as an example. The image processing method includes the following steps:
[0058] 201. The terminal obtains the coordinates of the first vertex of multiple vertices in the water surface region of the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image.
[0059] In this embodiment, the target image is the image currently displayed on the terminal. The target image includes a water surface area. The water surface area has multiple boundaries, and the intersection of any two adjacent boundaries is a vertex of the water surface area. The water surface area includes multiple vertices. For any vertex, there is a first vertex coordinate. The first vertex coordinate is a two-dimensional coordinate that represents the position of the vertex in the target image. The terminal can obtain the first vertex coordinates of the multiple vertices of the water surface area based on the currently displayed water surface area.
[0060] 202. The terminal determines the target texture information of multiple vertices based on the dynamic information of the water surface area and the normal texture map. The dynamic information includes the water flow speed and water flow time. The normal texture map is used to represent the correspondence between the pixels in the normal texture map and the texture information. The target texture information is used to represent the texture of the vertex.
[0061] In this embodiment, the terminal can offset multiple vertices in the water surface region based on the water flow speed and time in the dynamic information to simulate the dynamic effect represented by the dynamic information. The terminal can determine multiple corresponding pixels from the normal texture map based on the mapping relationship between vertex coordinates and the normal texture map, using the offset vertex coordinates of the multiple vertices. Then, the terminal determines the target texture information of the multiple vertices based on these pixels. This target texture information can represent the texture of the vertex. The texture is used to represent the degree of undulation of the water surface at the vertex location.
[0062] 203. The terminal renders the water surface area based on the target texture information of multiple vertices.
[0063] In this embodiment, the terminal can determine multiple textures for multiple vertices based on target texture information of multiple vertices. The textures can reflect information such as the light intensity, shadows, and vertex color at the location of the vertex. Then, the terminal can render the water surface area based on these multiple textures.
[0064] In this embodiment, target texture information of multiple vertices is obtained by using the dynamic information of the water surface region and the normal texture map in the target image. This allows the target texture information to reflect the dynamic changes of the multiple vertices based on the water flow speed during the water flow time. The water surface region is then rendered based on the target texture information, enabling the water surface region to display dynamic effects and resulting in a better rendering effect.
[0065] Figure 3 This is a flowchart of another image processing method provided according to an embodiment of this application. See also... Figure 3 In this embodiment, the method is described using an execution method performed by a terminal as an example. The image processing method includes the following steps:
[0066] 301. The terminal obtains the coordinates of the first vertex of multiple vertices in the water surface region of the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image.
[0067] In this embodiment, the terminal displays a target image, which includes a water surface area. This water surface area is the region where the water surface is located on the target map. The water surface area is surrounded by multiple boundaries. Any two adjacent boundaries intersect, and the intersection point formed by the boundary intersection is a vertex of the water surface area. The water surface area includes multiple vertices. The terminal can obtain the first vertex coordinates of these multiple vertices based on their positions in the target image. The first vertex coordinates are two-dimensional coordinates.
[0068] The target image corresponds to a portion of the target map. This target image includes a water surface area, which can represent a complete water surface in the target map or a portion of a water surface; this embodiment does not impose such a limitation. The area corresponding to the target image changes in real time with the terminal's position, and the water surface area in the target image also changes in real time with the terminal's movement. During terminal movement, when the water surface area in the target image represents a complete water surface, the boundaries and vertices of the water surface area in the target image correspond one-to-one with the boundaries and vertices of the water surface in the target map. When the water surface area in the target image represents a portion of a water surface, i.e., the portion of the water surface displayed on the terminal screen is from the target map, and the water surface area outside the screen has been cropped, forming new vertices and boundaries.
[0069] For example, Figure 4 This is a schematic diagram of a water surface area according to an embodiment of this application. See also... Figure 4The terminal screen displays a portion of the water surface of any water surface in the target map. This portion of the water surface is the water surface area in the target image. This water surface area includes vertices a, b, c, d, e, and f. Figure 4 The area shown by the dashed line represents the water surface outside the screen, which has been cut off. The new vertex formed during the cutting process is vertex f, and the new boundary is the boundary between vertex a and vertex f.
[0070] It should be noted that the embodiments of this application use water surface as an example for illustration. In some embodiments, the water surface can also be replaced by the surface of oil, alcohol or other liquids with fluidity. The embodiments of this application do not limit this.
[0071] 302. For any vertex, based on at least two water flow velocities and water flow times in the dynamic information and the first vertex coordinates of the vertex, determine at least two second vertex coordinates of the vertex, which are used to represent the position of the vertex after offset in the target image.
[0072] In this embodiment, the dynamic information includes at least two water flow velocities and a water flow time. The directions of the at least two water flow velocities are different, and the angle between any two water flow velocities is no greater than a preset angle. The water flow velocity can be represented by a two-dimensional vector; a longer vector magnitude indicates a faster water flow velocity, and a shorter vector magnitude indicates a slower water flow velocity. The water flow time is a time interval from the start of rendering the water surface area to the current time. For any vertex, the terminal can offset the vertex in the direction corresponding to the water flow velocity based on the water flow velocity and water flow time. The vertex's position in the target image, represented by the first vertex coordinates, is offset to the position represented by the second vertex coordinates. The solution provided in this embodiment determines the offset position of a vertex in the target image using water flow velocity and water flow time, so that the offset position of the vertex can reflect the dynamic changes of the vertex, which is beneficial for subsequent rendering of water surface areas with dynamic effects.
[0073] It should be noted that the at least two water flow velocities and water flow times are parameters in the target map, and there is a mapping relationship between the target map and the target image. That is, multiple vertices of the water surface area in the target image have corresponding location points in the target map. The terminal can determine the coordinates of at least two second vertices of the vertex in the target image through steps 3021 to 3023, including:
[0074] 3021. Based on the mapping relationship between the target image and the target map, the terminal determines the coordinates of the third vertex corresponding to the coordinates of the first vertex. The coordinates of the third vertex are used to represent the position of the vertex in the target map.
[0075] There is a mapping relationship between the target image and the target map. The position of a vertex in the target image corresponds to its position in the target map. Based on this mapping relationship and the coordinates of the first vertex, the terminal can determine the coordinates of the third vertex in the target map that corresponds to the coordinates of the first vertex.
[0076] 3022. The terminal determines at least two fourth vertex coordinates of the vertex based on the third vertex coordinates, at least two water flow velocities, and water flow time. These fourth vertex coordinates are used to represent the position of the vertex after offset in the target map.
[0077] Specifically, the terminal can move the vertex in the target map based on at least two water flow velocities and flow times, shifting the vertex from its position represented by the coordinates of a third vertex to its position represented by the coordinates of a fourth vertex. Correspondingly, the terminal determines at least two offsets of the vertex based on these at least two water flow velocities and flow times. Then, the terminal offsets the third vertex coordinates based on these at least two offsets to obtain at least two fourth vertex coordinates.
[0078] The following explanation uses a terminal that determines the coordinates of two fourth vertices of a given vertex based on two water flow velocities and a water flow time offset. These two velocities are the first and second water flow velocities, respectively. The terminal can determine the coordinates of these two fourth vertices based on the following formula:
[0079] Formula 1:
[0080] Velocity0*time+InputCoord*Scale1=NewPoint_1
[0081] Velocity1*time+InputCoord*Scale2=NewPoint_2
[0082] In this context, Velocity0 represents the first water flow velocity, Velocity1 represents the second water flow velocity, and time represents the water flow time. InputCoord represents the latitude and longitude coordinates of the vertex. Scale1 and Scale2 are scaling parameters used to transform the latitude and longitude coordinates of the vertex into the target map. InputCoord*Scale1 and InputCoord*Scale2 both represent the coordinates of the third vertex. Due to the target map, the coordinate values are very large and need to be reduced. Therefore, InputCoord can be multiplied by the vectors Scale1 and Scale2 to reduce the coordinate values. NewPoint_1 and NewPoint_2 both represent the coordinates of the fourth vertex.
[0083] It should be noted that the Velocity0 and Velocity1 parameters can be determined based on the units of the vertex positions in the water surface area, and this embodiment does not impose such restrictions. Since the distances in the target map are obtained by scaling down real-world distances according to a preset ratio, the units of the data in the target map are relatively small. If coordinates with larger real-world units are directly converted to smaller units, the coordinate values will become larger, which is not conducive to calculation; therefore, the coordinate values need to be scaled down. The terminal can scale down the coordinate values using Scale1 and Scale2. The Scale1 and Scale2 parameters can also be determined based on the units of the vertex positions in the water surface area, and this embodiment does not impose such restrictions. The terminal can adjust the corresponding parameters based on different data units. Scale1 and Scale2 can be the same or different, and this embodiment does not impose such restrictions.
[0084] For example, the terminal settings are as follows:
[0085] Veclocity0: float2 (0.016, -0.014); Veclocity1: float2 (0.025, -0.03);
[0086] Scale1: float2 (0.00072, 0.00072); Scale2: float2 (0.0003, 0.0003).
[0087] 3023. Based on the mapping relationship, the terminal determines the coordinates of at least two second vertices corresponding to at least two fourth vertex coordinates.
[0088] The terminal determines the coordinates of at least two second vertices corresponding to the coordinates of the at least two fourth vertices from the target image based on the mapping relationship between the target image and the target map.
[0089] The solution provided in this application determines the position of the vertex after offset in the target map by measuring the water flow speed and water flow time, and then determines the position of the vertex after offset in the target image. This allows the dynamic changes of the vertex in the target image to accurately reflect the dynamic changes of the vertex in the target map, thereby making the dynamic changes of the vertex in the target image more realistic and facilitating the subsequent rendering of a water surface area with better results.
[0090] After the terminal determines the coordinates of at least two second vertices of the vertex, it can determine the target texture information of the vertex based on the coordinates of the two second vertices and the normal texture map, and then continue to execute steps 303 to 304.
[0091] 303. The terminal obtains at least two normal vectors from the normal texture map based on at least two second vertex coordinates. The at least two normal vectors are the normal vectors of at least two pixels indicated by at least two second vertex coordinates. The normal texture map includes the normal vectors corresponding to the pixels.
[0092] In this embodiment, the normal texture map can represent the correspondence between pixels and normal vectors in the normal texture map. The normal vector can be used to represent the degree of undulation of the water surface at the corresponding position in the water surface region indicated by the pixel. The normal vector belongs to the texture information of the vertex; therefore, the normal texture map can be used to represent the correspondence between pixels and texture information in the normal texture map. The pixels in the normal texture map correspond to the pixels in the target image. Among the pixels in the target image, there are pixels corresponding to vertices in the water surface region. The terminal can determine at least two pixels indicated by at least two second vertex coordinates from the normal texture map based on at least two second vertex coordinates. Then, the terminal determines the normal vector corresponding to the at least two second vertex coordinates based on the at least two pixels. For example, Figure 5 This is a schematic diagram of a normal texture map provided according to an embodiment of this application. See also... Figure 5 The terminal can obtain the normal vectors corresponding to the coordinates of at least two second vertices based on the normal texture map.
[0093] It should be noted that during the rendering of multiple water surface areas, the terminal can render the multiple water surface areas based on a single normal texture map; or, the terminal can render the multiple water surface areas separately based on multiple normal texture maps. This application embodiment does not impose any restrictions on this.
[0094] 304. The terminal determines the target texture information of the vertex based on at least two normal vectors.
[0095] In this embodiment, the target texture information is used to represent the texture of the vertex. The terminal can offset the initial texture coordinates of the vertex based on at least two normal vectors to obtain the target texture coordinates. Then, the terminal determines the target texture information of the vertex using the target texture coordinates.
[0096] In some embodiments, the terminal can determine a target normal vector using at least two normal vectors, and then offset the initial texture coordinates of the vertex based on the target normal vector to obtain the target texture coordinates, thereby determining the target texture information of the vertex. Accordingly, the process by which the terminal determines the target texture information of the vertex based on the at least two normal vectors can be implemented through the following steps 3041 to 3044, including:
[0097] 3041. The terminal obtains the initial texture coordinates of the vertices.
[0098] The texture coordinates are used to obtain the color for rendering the water surface area. The initial texture coordinates (texture_coord) correspond to the coordinates of the first vertex. The terminal can obtain the initial texture coordinates of a vertex based on the coordinates of the first vertex.
[0099] 3042. The terminal adds at least two normal vectors to obtain the target normal vector.
[0100] Specifically, the terminal adds at least two normal vectors, resulting in a change in the range of values for the target normal vector (AccumulateNormal). The terminal can transform the coordinates of this target normal vector so that its coordinate range is between -1 and 1.
[0101] For example, let's take two normal vectors as an example. The value of any single normal vector is between 0 and 1. Adding these two normal vectors together results in a target normal vector with a value between 0 and 2. The terminal can then perform an AccumulateNormal-=1.0 transformation on the coordinates of this target normal vector, making its coordinates between -1 and 1.
[0102] 3043. The terminal determines the target texture coordinates of the vertex based on the initial texture coordinates of the vertex and the target normal vector.
[0103] Specifically, the terminal offsets the initial texture coordinates based on the magnitude of the target normal vector to obtain the target texture coordinates. Alternatively, the terminal can add the magnitude of the target normal vector to the initial texture coordinates to obtain the target texture coordinates; or, the terminal can subtract the magnitude of the target normal vector from the initial texture coordinates to obtain the target texture coordinates. In both methods, the terminal offsets the initial texture coordinates in opposite directions.
[0104] 3044. The terminal determines the target texture information based on the target texture coordinates.
[0105] The terminal can determine the target texture information of a vertex based on its target texture coordinates.
[0106] The terminal can repeatedly execute steps 302 to 304 to obtain target texture information for multiple vertices; or, the terminal can execute steps 302 to 304 simultaneously through multiple threads to obtain target texture information for multiple vertices. This application embodiment does not impose any restrictions on this.
[0107] 305. The terminal renders the water surface area based on the target texture information of multiple vertices.
[0108] In this embodiment, the terminal can render a water surface area using target texture information. Accordingly, the terminal obtains multiple target colors from a color texture map based on the target texture information of multiple vertices; then, the terminal renders the water surface area based on the multiple target colors. The color texture map represents the correspondence between texture information and colors. The terminal can determine multiple pixels in the water surface area based on multiple vertices. The terminal can obtain the target texture information of multiple pixels by acquiring the target texture information of multiple vertices. Then, the terminal can obtain multiple target colors based on the multiple target texture information corresponding to the water surface area to render the water surface area.
[0109] The target texture information includes target texture coordinates, which the terminal can use to obtain the target color corresponding to the target texture coordinates from the color texture map. These target texture coordinates are two-dimensional vectors. Taking (x, y) as an example, the terminal can invert the y-component of these coordinates within the range of 0 to 1. Then, based on the processed target texture coordinates, the terminal performs texture sampling on the color texture map to obtain the target color corresponding to those coordinates.
[0110] To better understand this solution, the overall process of this application will be described again below. Figure 6 This is a flowchart illustrating the rendering of a water surface area according to an embodiment of this application. See also... Figure 6 The terminal loads water system data of the water surface area in the target map from the hard drive into memory. Based on this water system data, the terminal can obtain the third vertex coordinates of multiple vertices in the water surface area. Then, the terminal pushes this water system data from memory to video memory, that is, it pushes the water system data into the rendering pipeline running on the GPU. This rendering pipeline includes vertex shaders and fragment shaders. The terminal processes the water system data through the vertex shader, obtaining the first vertex coordinates of a vertex based on its third vertex coordinates. Using the vertex shader, the terminal offsets the vertex from its third vertex coordinate position in at least two directions of water flow velocity, determining at least two fourth vertex coordinates of the vertex. Then, based on the mapping relationship between the target image and the target map, it determines at least two second vertex coordinates of the vertex. Finally, the terminal performs rasterization processing on the at least two second vertex coordinates corresponding to multiple vertices; that is, the terminal obtains the offset positions of multiple pixels in the water surface area in the target image through linear interpolation. Then, the terminal can obtain the target texture information of these multiple pixels through the fragment shader, and obtain the corresponding target color based on the target texture information to render the water surface area. The terminal then displays the rendered water surface area on the screen. The water surface area displays dynamically changing water ripples.
[0111] The solution provided in this application embodiment obtains target texture information of multiple vertices through dynamic information and normal texture mapping of the water surface area in the target image, so that the target texture information can reflect the dynamic changes of the multiple vertices based on the water flow speed during the water flow time, and then renders the water surface area based on the target texture information, so that the water surface area can display dynamic effects and the rendering effect is better.
[0112] Figure 7 This is a schematic diagram of an image processing apparatus according to an embodiment of this application. The apparatus is used to perform the steps of the image processing method described above. (See attached diagram.) Figure 7 The device includes:
[0113] The acquisition module 701 is used to acquire the coordinates of the first vertex of multiple vertices of the water surface region in the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image.
[0114] The determination module 702 is used to determine the target texture information of multiple vertices based on the dynamic information of the water surface region and the normal texture map. The dynamic information includes the water flow speed and water flow time. The normal texture map is used to represent the correspondence between the pixels in the normal texture map and the texture information. The target texture information is used to represent the texture of the vertex.
[0115] Rendering module 703 is used to render the water surface area based on target texture information from multiple vertices.
[0116] In some embodiments, Figure 8 This is a schematic diagram of another image processing apparatus provided according to an embodiment of this application. See also... Figure 8 The determining module 702 includes:
[0117] The first determining unit 801 is used to determine at least two second vertex coordinates of any vertex based on at least two water flow velocities and water flow times in the dynamic information and the first vertex coordinates of the vertex. The second vertex coordinates are used to represent the position of the vertex after offset in the target image.
[0118] The second determining unit 802 is used to determine the target texture information of a vertex based on at least two second vertex coordinates and a normal texture map.
[0119] In some embodiments, the first determining unit 801 includes:
[0120] The first determining subunit 8011 is used to determine the coordinates of the third vertex corresponding to the coordinates of the first vertex based on the mapping relationship between the target image and the target map. The coordinates of the third vertex are used to represent the position of the vertex in the target map.
[0121] The second determining subunit 8012 is used to determine at least two fourth vertex coordinates of a vertex based on the third vertex coordinates, at least two water flow velocities, and water flow time. These fourth vertex coordinates are used to represent the position of the vertex after offset in the target map.
[0122] The first determining subunit 8011 is also used to determine the coordinates of at least two second vertices corresponding to at least two fourth vertex coordinates based on the mapping relationship.
[0123] In some embodiments, the second determining subunit 8012 is used to determine at least two offsets of a vertex based on at least two water flow velocities and water flow times; and to offset the coordinates of a third vertex based on the at least two offsets to obtain at least two coordinates of a fourth vertex.
[0124] In some embodiments, the normal texture map includes the normal vectors corresponding to the pixels;
[0125] The second determining unit 802 includes:
[0126] The subunit 8021 is used to obtain at least two normal vectors from the normal texture map based on at least two second vertex coordinates, wherein the at least two normal vectors are the normal vectors of at least two pixels indicated by at least two second vertex coordinates;
[0127] The third determining subunit 8022 is used to determine the target texture information of a vertex based on at least two normal vectors.
[0128] In some embodiments, the third determining subunit 8022 is used to obtain the initial texture coordinates of the vertex, which correspond to the coordinates of the first vertex; add at least two normal vectors to obtain a target normal vector; determine the target texture coordinates of the vertex based on the initial texture coordinates and the target normal vector; and determine the target texture information based on the target texture coordinates.
[0129] In some embodiments, the third determining subunit 8022 is used to offset the initial texture coordinates based on the magnitude of the target normal vector to obtain the target texture coordinates.
[0130] In some embodiments, the rendering module 703 is used to obtain multiple target colors from a color texture map based on the target texture information of multiple vertices, the color texture map being used to represent the correspondence between texture information and colors; and to render the water surface area based on the multiple target colors.
[0131] The image processing apparatus provided in this application obtains target texture information of multiple vertices through dynamic information of the water surface region and normal texture mapping in the target image, so that the target texture information can reflect the dynamic changes of the multiple vertices based on the water flow speed during the water flow time, thereby rendering the water surface region based on the target texture information, so that the water surface region can display dynamic effects and the rendering effect is better.
[0132] It should be noted that the image processing apparatus provided in the above embodiments is illustrated using the division of the above functional modules when running the application. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the apparatus can be divided into different functional modules to complete all or part of the functions described above. In addition, the image processing apparatus and image processing method embodiments provided in the above embodiments belong to the same concept, and their implementation process can be found in the method embodiments, which will not be repeated here.
[0133] In the embodiments of this application, the computer device can be configured as a terminal or a server. When the computer device is configured as a terminal, the terminal can act as the execution subject to implement the technical solutions provided in the embodiments of this application. When the computer device is configured as a server, the server can act as the execution subject to implement the technical solutions provided in the embodiments of this application. Alternatively, the technical solutions provided in this application can be implemented through the interaction between the terminal and the server. The embodiments of this application do not limit this.
[0134] Figure 9 This is a structural block diagram of a terminal 900 provided according to an embodiment of this application. The terminal 900 can be a portable mobile terminal, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The terminal 900 may also be referred to as an object device, portable terminal, laptop terminal, desktop terminal, or other names.
[0135] Typically, terminal 900 includes a processor 901 and a memory 902.
[0136] Processor 901 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 901 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 901 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 901 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 901 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0137] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 902 are used to store at least one computer program, which is executed by the processor 901 to implement the image processing method provided in the method embodiments of this application.
[0138] In some embodiments, the terminal 900 may also optionally include a peripheral device interface 903 and at least one peripheral device. The processor 901, memory 902, and peripheral device interface 903 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 903 via a bus, signal line, or circuit board. The peripheral device includes at least one of the following: a radio frequency circuit 904, a display screen 905, a camera assembly 906, an audio circuit 907, and a power supply 908.
[0139] Peripheral device interface 903 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 901 and memory 902. In some embodiments, processor 901, memory 902 and peripheral device interface 903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 901, memory 902 and peripheral device interface 903 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0140] The radio frequency (RF) circuit 904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 904 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 904 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. In some embodiments, the RF circuit 904 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, an object identity module card, etc. The RF circuit 904 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 904 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0141] Display screen 905 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 905 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 901 for processing. In this case, display screen 905 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 905, disposed on the front panel of terminal 900; in other embodiments, there may be at least two display screens 905, disposed on different surfaces of terminal 900 or in a folded design; in other embodiments, display screen 905 may be a flexible display screen, disposed on a curved or folded surface of terminal 900. Furthermore, display screen 905 may be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 905 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0142] The camera assembly 906 is used to acquire images or videos. In some embodiments, the camera assembly 906 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 906 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0143] The audio circuit 907 may include a microphone and a speaker. The microphone is used to collect sound waves from the target object and environment, converting the sound waves into electrical signals that are input to the processor 901 for processing, or input to the radio frequency circuit 904 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal 900. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert the electrical signals from the processor 901 or the radio frequency circuit 904 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 907 may also include a headphone jack.
[0144] Power supply 908 is used to power the various components in terminal 900. Power supply 908 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 908 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0145] In some embodiments, the terminal 900 further includes one or more sensors 909. The one or more sensors 909 include, but are not limited to, an accelerometer 910, a gyroscope 911, a pressure sensor 912, an optical sensor 913, and a proximity sensor 914.
[0146] Accelerometer 910 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by terminal 900. For example, accelerometer 910 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 901 can control display screen 905 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 910. Accelerometer 910 can also be used to acquire motion data of games or target objects.
[0147] The gyroscope sensor 911 can detect the orientation and rotation angle of the terminal 900. The gyroscope sensor 911, in conjunction with the accelerometer sensor 910, can collect 3D motion data of the target object on the terminal 900. Based on the data collected by the gyroscope sensor 911, the processor 901 can perform the following functions: motion sensing (e.g., changing the UI based on the tilt of the target object), image stabilization during shooting, game control, and inertial navigation.
[0148] The pressure sensor 912 can be disposed on the side bezel of the terminal 900 and / or the lower layer of the display screen 905. When the pressure sensor 912 is disposed on the side bezel of the terminal 900, it can detect the grip signal of the target object on the terminal 900, and the processor 901 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 912. When the pressure sensor 912 is disposed on the lower layer of the display screen 905, the processor 901 can control the operable controls on the UI interface based on the pressure operation of the target object on the display screen 905. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0149] An optical sensor 913 is used to collect ambient light intensity. In one embodiment, the processor 901 can control the display brightness of the display screen 905 based on the ambient light intensity collected by the optical sensor 913. When the ambient light intensity is high, the display brightness of the display screen 905 is increased; when the ambient light intensity is low, the display brightness of the display screen 905 is decreased. In another embodiment, the processor 901 can also dynamically adjust the shooting parameters of the camera assembly 906 based on the ambient light intensity collected by the optical sensor 913.
[0150] The proximity sensor 914, also known as a distance sensor, is typically located on the front panel of the terminal 900. The proximity sensor 914 is used to detect the distance between a target object and the front of the terminal 900. In one embodiment, when the proximity sensor 914 detects that the distance between the target object and the front of the terminal 900 is gradually decreasing, the processor 901 controls the display screen 905 to switch from a screen-on state to a screen-off state; when the proximity sensor 914 detects that the distance between the target object and the front of the terminal 900 is gradually increasing, the processor 901 controls the display screen 905 to switch from a screen-off state to a screen-on state.
[0151] Those skilled in the art will understand that Figure 9 The structure shown does not constitute a limitation on terminal 900, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0152] This application also provides a computer-readable storage medium storing at least one computer program. This computer program is loaded and executed by a terminal's processor to implement the operations performed by the terminal in the image processing method described above. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, or optical data storage device, etc.
[0153] This application also provides a computer program product or computer program, which includes computer program code stored in a computer-readable storage medium. The terminal's processor reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the terminal to perform the image processing methods provided in the various optional implementations described above.
[0154] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0155] The above are optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An image processing method, characterized in that, The method includes: Obtain the coordinates of the first vertex of multiple vertices in the water surface region of the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image. For any vertex, based on at least two water flow velocities and water flow times in the dynamic information of the water surface region and the first vertex coordinates of the vertex, at least two second vertex coordinates of the vertex are determined, the second vertex coordinates being used to represent the position of the vertex after offset in the target image; based on the at least two second vertex coordinates and the normal texture map of the water surface region, target texture information of the vertex is determined, the normal texture map being used to represent the correspondence between pixels in the normal texture map and texture information, the target texture information being used to represent the texture of the vertex; The water surface area is rendered based on the target texture information of the multiple vertices.
2. The method according to claim 1, characterized in that, The determination of at least two second vertex coordinates of the vertex based on at least two water flow velocities and water flow times from the dynamic information of the water surface region and the first vertex coordinates of the vertex includes: Based on the mapping relationship between the target image and the target map, the coordinates of the third vertex corresponding to the coordinates of the first vertex are determined, and the coordinates of the third vertex are used to represent the position of the vertex in the target map; Based on the coordinates of the third vertex, the at least two water flow velocities, and the water flow time, at least two fourth vertex coordinates of the vertex are determined, and the fourth vertex coordinates are used to represent the position of the vertex after offset in the target map; Based on the mapping relationship, determine the coordinates of the at least two second vertices corresponding to the coordinates of the at least two fourth vertices.
3. The method according to claim 2, characterized in that, Determining the coordinates of at least two fourth vertices of the vertex based on the coordinates of the third vertex, the at least two water flow velocities, and the water flow time includes: Based on the at least two water flow velocities and the water flow time, determine at least two offsets of the vertex; The coordinates of the third vertex are offset based on the at least two offsets to obtain the coordinates of the at least two fourth vertices.
4. The method according to claim 1, characterized in that, The normal texture map includes the normal vectors corresponding to the pixels; The determination of the target texture information of the vertex based on the coordinates of the at least two second vertices and the normal texture map of the water surface region includes: Based on the coordinates of the at least two second vertices, at least two normal vectors are obtained from the normal texture map, wherein the at least two normal vectors are the normal vectors of the at least two pixels indicated by the coordinates of the at least two second vertices; The target texture information of the vertex is determined based on the at least two normal vectors.
5. The method according to claim 4, characterized in that, Determining the target texture information of the vertex based on the at least two normal vectors includes: Obtain the initial texture coordinates of the vertex, wherein the initial texture coordinates correspond to the coordinates of the first vertex; The target normal vector is obtained by adding the at least two normal vectors together. The target texture coordinates of the vertex are determined based on the initial texture coordinates of the vertex and the target normal vector. The target texture information is determined based on the target texture coordinates.
6. The method according to claim 5, characterized in that, Determining the target texture coordinates of a vertex based on its initial texture coordinates and the target normal vector includes: The target texture coordinates are obtained by offsetting the initial texture coordinates based on the magnitude of the target normal vector.
7. The method according to any one of claims 1 to 6, characterized in that, The rendering of the water surface area based on the target texture information of the multiple vertices includes: Based on the target texture information of the multiple vertices, multiple target colors are obtained from the color texture map, which is used to represent the correspondence between texture information and color. The water surface area is rendered based on the multiple target colors.
8. An image processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the coordinates of the first vertex of multiple vertices of the water surface region in the target image. The vertex is used to represent the intersection point on the boundary of the water surface region, and the coordinates of the first vertex are used to represent the position of the vertex in the target image. A determination module is configured to, for any vertex, determine at least two second vertex coordinates of the vertex based on at least two water flow velocities and water flow times in the dynamic information of the water surface region and the first vertex coordinates of the vertex, wherein the second vertex coordinates represent the position of the vertex after offset in the target image; and determine the target texture information of the vertex based on the at least two second vertex coordinates and the normal texture map of the water surface region, wherein the normal texture map represents the correspondence between pixels in the normal texture map and texture information, and the target texture information represents the texture of the vertex; The rendering module is used to render the water surface area based on the target texture information of the multiple vertices.
9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded by the processor and executed as the image processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store at least one computer program, which is executed by a processor to implement the image processing method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the image processing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Water surface rendering method and apparatus
CN108470369A