Method, apparatus, device and storage medium for water body reflection processing

By obtaining the reflection position and information of pixel points in the water body reflection algorithm, combining texture declaration maps and environmental reflection information, and calculating Fresnel information, the problem that the SSR algorithm cannot reflect objects outside the screen is solved, improving the reflection effect and reducing the performance consumption of the mobile terminal.

CN114748874BActive Publication Date: 2025-07-22NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210346543.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-02
Publication Date
2025-07-22
Estimated Expiration
2042-04-02

AI Technical Summary

Technical Problem

The existing screen space reflection algorithm (SSR) cannot reflect objects outside the screen, resulting in poor reflection of water and high performance consumption on mobile terminals.

Method used

By obtaining the reflection position of the light reflected by each pixel point of the water body surface on the target object, combining the opaque texture declaration map and environmental reflection information, calculate the Fresnel information, obtain the target reflection information, and determine the reflection position under the world space coordinate system, reducing the number of steps to reduce performance consumption.

Benefits of technology

The reflection quality of the vertical position of the viewing angle of the water body reflection effect is improved, and the performance consumption of the mobile terminal is reduced, achieving better water body reflection performance on the mobile terminal.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114748874B_ABST
    Figure CN114748874B_ABST
Patent Text Reader

Abstract

The present application provides a water body reflection processing method, apparatus, device and storage medium. The method includes: obtaining the reflection positions of the light rays reflected by each pixel point on the water surface on the target object; determining the first reflection information and the second reflection information corresponding to each pixel point according to the reflection positions corresponding to each pixel point; the first reflection information is sampled from the opaque texture declaration map, and the second reflection information is sampled from the preset environmental reflection information; determining the Fresnel information corresponding to each pixel point according to the normal line and the viewing vector at each pixel point; obtaining the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel point; and rendering each pixel point according to the target reflection information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of game technology, and in particular to a method, device, equipment and storage medium for processing water reflection. Background Art

[0002] There are usually water bodies such as rivers, seas, and lakes in game scenes. Water bodies are rendered and displayed in the game screen so that gamers can experience the game. The reflection effect of water bodies will affect the rendering effect of water bodies, which in turn affects the game experience of gamers.

[0003] At present, some water reflection algorithms are used to calculate the reflection color of each pixel in the water to show the water reflection effect. In one water reflection algorithm, the screen space reflection algorithm (Screen Space Reflection, SSR), the principle is to calculate the reflection vector of each pixel in the water in the camera space through the full-screen depth map and the full-screen normal map, and then make the reflection vector step along the reflection direction until it hits the object position, and then convert the position of the object into the position of the screen space, and sample the screen RT to obtain the reflection color corresponding to the pixel.

[0004] However, the SSR algorithm extracts pixel values in screen space and therefore cannot reflect objects outside the screen, resulting in poor reflection effects. Summary of the invention

[0005] The present application provides a water body reflection processing method, device, equipment and storage medium to solve the problem that the SSR algorithm in the prior art extracts the pixel value of the screen space and therefore cannot reflect objects outside the screen, resulting in poor reflection effect.

[0006] In a first aspect, the present application provides a method for processing water body reflection, including: obtaining the reflection position of light reflected by each pixel point on the water body surface on the target object; determining first reflection information and second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point; the first reflection information is sampled from an opaque texture declaration map, and the second reflection information is sampled from preset environment reflection information; determining Fresnel information corresponding to each pixel point according to the normal and viewing angle vector at each pixel point; obtaining target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel point; rendering each pixel point according to the target reflection information.

[0007] In some embodiments, obtaining the reflection position of the light reflected by each pixel point on the water surface on the target object includes: for each pixel point on the water surface, obtaining the viewing vector and the normal direction corresponding to the pixel point in the world coordinate system; determining the reflection direction corresponding to the pixel point according to the viewing vector and the normal direction; taking the position obtained by traveling a preset distance along the reflection direction from the pixel point as the reflection position of the light reflected by the pixel point on the target object; wherein, the preset distance is positively correlated with the component of the viewing vector in the vertical direction.

[0008] In some embodiments, determining the first reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point includes: for each pixel point, determining the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system; sampling in the opaque texture declaration map according to the UV coordinates to obtain the first reflection information corresponding to the pixel point.

[0009] In some embodiments, determining the second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point includes: for each pixel point, determining the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system; sampling in the preset environmental reflection information according to the UV coordinates to obtain the second reflection information corresponding to the pixel point.

[0010] In some embodiments, determining the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system includes: converting the reflection position corresponding to the pixel point in the world space to the clip space to obtain the reflection position of the pixel point in the clip space; converting the coordinates of the reflection position in the clip space to a preset interval range to obtain the UV coordinates corresponding to the reflection position.

[0011] In some embodiments, determining the Fresnel information corresponding to each pixel point according to the normal and the viewing vector at each pixel point includes: determining the Fresnel information corresponding to each pixel point according to the dot product result of the viewing vector and the normal.

[0012] In some embodiments, obtaining the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point includes: using the Fresnel information as the mask difference for the transitional calculation between the first reflection information and the second reflection information to obtain the target reflection information corresponding to each pixel point.

[0013] Second aspect, the present application provides a water body reflection processing device, including: an acquisition module, configured to acquire the reflection positions of the light rays reflected by each pixel point on the water surface on a target object; a determination module, configured to determine the first reflection information and the second reflection information corresponding to each pixel point according to the reflection positions corresponding to each pixel point; the first reflection information is sampled from an opaque texture declaration map, and the second reflection information is sampled from preset environmental reflection information; the determination module is further configured to determine the Fresnel information corresponding to each pixel point according to the normal vector and the viewing vector at each pixel point; the determination module is further configured to obtain the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point; a rendering module, configured to render each pixel point according to the target reflection information.

[0014] Third aspect, the present application provides an electronic device, including: a memory, a processor; a memory; a memory for storing executable instructions of the processor; wherein, the processor is configured to implement the method as described in the first aspect.

[0015] Fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method as described in the first aspect.

[0016] Fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method as described in the first aspect.

[0017] The water body reflection processing method, device, equipment and storage medium provided by this application obtain the reflection positions of the light rays reflected by each pixel point on the water surface on the target object; determine the first reflection information and the second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point; the first reflection information is sampled from the opaque texture declaration map, and the second reflection information is sampled from the preset environmental reflection information; determine the Fresnel information corresponding to each pixel point according to the normal line and the viewing vector at each pixel point; obtain the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel point; render each pixel point according to the target reflection information. Since the reflection positions of the light rays reflected by each pixel point on the water surface are obtained and the second reflection information corresponding to each pixel point is determined, the second reflection information is sampled from the preset environmental reflection information, and the target reflection information corresponding to each pixel point is obtained according to the Fresnel information, the first reflection information and the second reflection information, it is possible to ensure the reflection effect at a relatively flat viewing angle position, and the reflection information obtained at the viewing angle vertical position is stronger, so as to obtain a better reflection effect at the viewing angle vertical position. In addition, since in the world space coordinate system, a preset distance is traveled along the reflection direction of each pixel point to determine the reflection position of each pixel point in the world space, and the preset distance is positively correlated with the vertical component of the viewing vector, only one step is required to determine the reflection position, avoiding the need for hundreds of steps in the related art, thereby reducing the performance consumption of the mobile terminal and achieving a better reflection effect of the water body on the mobile terminal. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with this application and used together with the specification to explain the principles of this application.

[0019] Figure 1 It is a schematic diagram of the principle of screen space reflection in the prior art;

[0020] Figure 2 It is a flowchart of the water body reflection processing method provided by an embodiment of this application;

[0021] Figure 3 It is a schematic diagram of the principle of the calculation process of the reflection direction provided by an embodiment of this application;

[0022] Figure 4 It is a schematic diagram of the structure of the water body reflection processing device provided by an embodiment of this application;

[0023] Figure 5 It is a schematic diagram of the structure of the electronic device provided by an embodiment of this application.

[0024] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be provided hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Embodiments

[0025] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0026] Water bodies are common scenes in games. Water bodies can reflect target objects in the game scene. To display a better game screen effect, it is necessary to show the reflection effect of the water body in the game screen.

[0027] In the related art, the reflection effect belongs to the indirect lighting part. It is the lighting that the light source starts from the source point, is reflected by the pixel points on the object surface, and enters the eyes. This pixel point also receives the lighting reflected from all other pixel points in the game scene. If the reflection surface is smooth, the reflection surface can reflect the surrounding environment (such as mirror metals, etc.). Currently, the game simulates the emission effect of the above-introduced lighting to show the reflection effect in the game.

[0028] Figure 1 It is a schematic diagram of the principle of screen space reflection for the prior art. As Figure 1 shown, Figure 1 the position of point D in [the figure] is the position of the eyes, that is, the position of the camera; A is the position point of the target object, and C is a pixel point on the water surface, that is, the pixel point on the reflection surface. Since the light emitted from point A is reflected by point C and enters the human eyes, point A on the target object can be seen from point C. The SSR algorithm first calculates the direction of the reflected light, that is, the vector CA. Specifically, with C as the origin, and the light with the direction of CA, intersects with the target object to obtain the position of pixel point A in the camera space, and then converts it into a rectangular frame in the clip space position map, which is the position in the clip space. After that, sampling is performed in the texture according to the position in the clip space to obtain the pixel value reflected by point C for point A.

[0029] In the above process, since the pixel position is converted into the coordinates in the clip space, and then sampling is performed in the texture according to the position in the clip space. In some game scenarios, if the target object is outside the clip space, after converting the position coordinates of the pixels on the target object into the clip space, the converted position obtained will exceed the coordinate range of the clip space. For example, when the observer looks vertically at the lake surface, the observer's line of sight is relatively vertical at this time, that is, when the line of sight vector and the normal direction are close to being the same, after the pixels in the sky are converted into the clip space, they will exceed the coordinate range of the clip space. Then, if sampling is performed in the texture according to the coordinates outside the clip space, the color information (reflection information) sampled for the exceeded part is the color information of the last pixel at the edge of the texture, resulting in a stretched image for the finally obtained reflection effect diagram and a poor reflection effect.

[0030] In addition, the SSR algorithm calculates the reflection point position in a step-by-step manner, and when applied to mobile devices, it has relatively high requirements for the hardware resources of mobile devices. That is: when determining the intersection point of the light ray emitted from point A and the target object, it is to travel a preset distance along the direction of the light ray emitted from point A each time and determine whether it hits the target object. If it does not hit the target object, continue to travel a preset distance along the direction of the light ray emitted from point A until it hits the target object, and determine the position point when hitting the target object as the intersection point of the light ray emitted from point A and the target object.

[0031] In the related art, for each pixel point, it may be necessary to take hundreds of steps to find the intersection point of the light ray emitted from point A and the target object. And after each step, it is also necessary to calculate whether it hits the target object. Therefore, when this algorithm is applied to mobile devices, the performance consumption is large and the requirements for hardware resources are relatively high.

[0032] In view of the above technical problems, the technical concept process of the inventor of the present application is as follows: calculate the reflection position of the light ray reflected by each pixel point on the water surface on the target object, and then calculate the first reflection information sampled from the opaque texture declaration texture according to the reflection position, and the second reflection information sampled from the preset environmental reflection information; and combine the Fresnel information corresponding to each pixel point calculated according to the view vector and the normal line at each pixel point to obtain the target reflection information corresponding to each pixel point, and render the pixel point according to the target reflection information to obtain the reflection effect at the pixel point.

[0033] Next, the technical solution of the present application will be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0034] Figure 2 It is a flowchart of the water body reflection processing method provided by the embodiment of the present application. AsFigure 2 As shown in Figure 2 , the water body reflection processing method includes the following steps:

[0035] Step S201: Obtain the reflection position of the light reflected by each pixel point on the water surface on the target object.

[0036] The execution subject of the method in this embodiment can be a mobile terminal. For example, a smart phone, an IPAD, etc.

[0037] In this embodiment, the water surface can be understood as a reflection surface. In the game screen, the water surface includes multiple pixel points. This step is for each pixel point among the multiple pixel points on the water surface to obtain the position when each pixel point on the water surface reflects on the pixel points on the target object in the game.

[0038] Among them, the coordinates of the reflection position of each pixel point on the water surface on the target object in the game are the coordinates of the reflection position in the UV coordinate system.

[0039] The target object can be understood as the object being reflected, and the water body reflection can be understood as showing the reflection effect of the object at each pixel point on the water surface. Please continue to refer to Figure 1 , in the figure, the rectangular block is the target object. Light rays are emitted from point A of the target object, reflected by pixel point C on the water surface, and enter the human eye at point D. Point A is the reflection position.

[0040] Optionally, step S201 includes the following steps:

[0041] Step a1: For each pixel point on the water surface, obtain the viewing vector and normal direction corresponding to the pixel point in the world coordinate system.

[0042] Among them, since the target object is different, the viewing vector will also be different, and the normal direction is determined according to the water surface. Therefore, the normal direction generally does not change with the viewing vector.

[0043] Step a2: Determine the reflection direction corresponding to the pixel point according to the viewing vector and the normal direction.

[0044] In this embodiment, the viewing vector of each pixel point in the world space is the viewing vector of the camera in the game, which can be calculated according to the position coordinates of the camera in the world space and the position coordinates of each pixel point in the world space. Among them, the position coordinates of each pixel point in the world space can be obtained by multiplying the coordinates of each pixel point in the water body model space by the transformation matrix, and the coordinates of each pixel point in the water body model space can be obtained from the vertex information of the water body model.

[0045] Figure 3 is a schematic diagram of the principle of the calculation process of the reflection direction provided by the embodiment of the present application. As shown in Figure 3As shown, in this step, the normal direction of a pixel point O on the lake surface is used as the axis of symmetry to determine the vector symmetric to the vector of the line-of-sight direction, and the reflection direction corresponding to point O is obtained.

[0046] Optionally, the reflect function can be used to calculate the view vector and normal direction of each pixel point in world space to obtain the reflection direction corresponding to each pixel point.

[0047] Step a3: The position obtained by traveling a preset distance along the reflection direction from the pixel point is used as the reflection position of the light reflected by the pixel point on the target object; wherein, the preset distance is positively correlated with the vertical component of the view vector.

[0048] The preset distance in this step is determined based on the empirical values obtained after several tests, and it is the distance that can hit the reflected object after traveling the preset distance along the reflection direction.

[0049] Among them, the preset distance is positively correlated with the vertical component of the view vector, which can be understood as the preset distance is proportional to the vertical component of the view vector, that is, when the line-of-sight direction is perpendicular to the horizontal plane, the longer the distance traveled in the reflection direction; conversely, the shorter the distance traveled in the reflection direction.

[0050] In an alternative embodiment, before step a3, the corresponding relationship between the angle between the line-of-sight direction and the horizontal plane and the distance traveled in the reflection direction can also be stored in advance. Then, when calculating the preset distance traveled by each pixel point along the reflection direction, the angle between the line-of-sight direction and the horizontal plane at each pixel point position can be determined, and based on the angle between the line-of-sight direction and the horizontal plane at each pixel point position and the above-mentioned pre-stored corresponding relationship, the preset distance traveled by each pixel point along the reflection direction can be determined.

[0051] In another alternative embodiment, before step a3, the ratio of the preset distance traveled along the reflection direction to the vertical component of the vector of the line-of-sight direction can also be stored in advance, and the preset distance to be traveled along the reflection direction can be determined in real time according to the vertical component of the view vector and the pre-stored ratio.

[0052] Step S202: According to the reflection position corresponding to each pixel point, determine the first reflection information and the second reflection information corresponding to each pixel point; the first reflection information is sampled from the opaque texture declaration map, and the second reflection information is sampled from the preset environmental reflection information.

[0053] Among them, the preset environmental reflection information includes: environmental reflection map or reflection probe.

[0054] Optionally, step S202 may include at least two alternative implementation manners as follows:

[0055] In an alternative implementation manner, according to the reflection position corresponding to each pixel, determining the first reflection information corresponding to each pixel includes:

[0056] Step b1: For each pixel, according to the reflection position corresponding to the pixel in the world coordinate system, determining the UV coordinates corresponding to the reflection position.

[0057] Optionally, step b1 includes:

[0058] Step b11: Converting the reflection position corresponding to the pixel in world space to the clip space to obtain the reflection position of the pixel in the clip space.

[0059] Specifically, it may be to convert the coordinates of the reflection position of each pixel on the water surface in world space to the clip space through the TransformWorldToHClip function, so as to obtain the reflection position of each pixel on the water surface in the clip space. It can be understood that the coordinates of each pixel on the water surface are projected from 3D space onto a 2D plane.

[0060] Step b12: Converting the coordinates of the reflection position in the clip space to a preset interval range to obtain the UV coordinates corresponding to the reflection position; wherein, the preset interval range is an interval range between 0 and 1.

[0061] Among them, converting the coordinates of the reflection position in the clip space to a preset interval range includes: dividing the coordinates of the reflection position in the clip space by a preset component to obtain a first target value; multiplying the first target value by a second target value and adding a third target value to obtain the UV coordinates corresponding to the reflection position of each pixel for the target object in the game.

[0062] Exemplarily, if the coordinates of the reflection position in the clip space are denoted as (X, Y), then the X component and the Y component are respectively divided by the W component to obtain a first target value of the Vector2 type, and then the first target value of the Vector2 type is multiplied by 0.5 and added with 0.5, so as to convert the coordinates of the reflection position in the interval [-1, 1] to the preset interval range in the interval [0, 1].

[0063] Step b2: Sampling in the opaque texture declaration map according to the UV coordinates to obtain the first reflection information corresponding to the pixel.

[0064] In this embodiment, the first reflection information corresponding to each pixel includes: the first reflection color information corresponding to each pixel.

[0065] Specifically, the opaque texture declaration map is regarded as a map with the values of the X-axis and Y-axis ranging from 0 to 1. Assuming that the UV coordinates of a pixel are (0.5, 0.5), the color information of the pixel at the coordinate point (0.5, 0.5) is sampled from the opaque texture declaration map as the first reflection information.

[0066] Exemplarily, the opaque texture declaration map (CameraOpaqueTexture) output by the pre-rendering pipeline steps can be sampled according to the UV coordinates of each pixel. This opaque texture declaration map is declared in the engine pipeline. After the opaque objects are drawn, the information in the current color buffer is copied to this map for other processes to use.

[0067] In another alternative embodiment, according to the reflection position corresponding to each pixel, the second reflection information corresponding to each pixel is determined, including:

[0068] Step c1: For each pixel, according to the reflection position corresponding to the pixel in the world coordinate system, determine the UV coordinates corresponding to the reflection position.

[0069] Among them, the specific implementation of step c1 can refer to the introduction of step b1 and will not be repeated here.

[0070] Step c2: According to the UV coordinates, sample in the preset environmental reflection information to obtain the second reflection information corresponding to the pixel.

[0071] In this embodiment, the second reflection information corresponding to each pixel includes the second reflection color information corresponding to each pixel.

[0072] Among them, the environmental reflection information includes information about the environment where objects such as characters and objects are located in the game scene. Exemplarily, taking the environmental reflection information preset by the game engine as an environment map, the environment map is regarded as a map with the values of the X-axis and Y-axis ranging from 0 to 1. Assuming that the UV coordinates of a pixel are (0.25, 0.25), the color information of the pixel at the coordinate point (0.25, 0.25) is sampled from the environment map as the second reflection information.

[0073] Step S203: According to the normal vector and the view vector at each pixel, determine the Fresnel information corresponding to each pixel.

[0074] Optionally, according to the normal vector and the view vector at each pixel, determining the Fresnel information corresponding to each pixel includes: determining the Fresnel information corresponding to each pixel according to the dot product result of the view vector and the normal vector.

[0075] Among them, the angle between the viewing vector and the normal vector is within the range of 0-90 degrees. Among them, the dot product results of the viewing vector and the normal vector at different angles can be used to indicate the distance between the water surface pixel point and the viewing angle.

[0076] Specifically, according to the normal and the viewing vector at each pixel point of the water surface, Fresnel information is determined, including: according to the dot product result of the viewing vector and the normal, Fresnel information is determined.

[0077] In this embodiment, the Fresnel information includes the transition information of the Fresnel edge; among them, the transition information of the Fresnel edge includes: the dot product result of the viewing vector and the normal vector when the viewing vector is parallel to the normal, and / or, the dot product result of the viewing vector and the normal vector when the viewing vector is perpendicular to the normal. Then, in this embodiment, the transition information of the Fresnel edge is obtained according to the dot product result of the viewing vector and the normal vector when the viewing vector is parallel to the normal, and / or, according to the dot product result of the viewing vector and the normal vector when the viewing vector is perpendicular to the normal.

[0078] Step S204: Obtain the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point.

[0079] Optionally, obtaining the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point includes: using the Fresnel information as the mask difference for the transition calculation between the first reflection information and the second reflection information to obtain the target reflection information corresponding to each pixel point.

[0080] Specifically, using the Fresnel information as the mask difference for the transition calculation between the first reflection information and the second reflection information to obtain the target reflection information corresponding to each pixel point includes: obtaining the target reflection information corresponding to each pixel point according to the sum of the product of the first reflection information and the Fresnel information corresponding to each pixel point and the product of the second reflection information corresponding to each pixel point and the target value; the target value is the difference between the preset value and the Fresnel information.

[0081] The implementation process of this step can be expressed by the following formula (1):

[0082] Lerp(A, B, x) = A * (1 - x) + B * x; (1)

[0083] In formula (1), A is the first reflection information, B is the second reflection information, x is the Fresnel information, and 1 is the preset value.

[0084] Among them, the calculated Fresnel information is used as the x input of the Lerp function. According to the above formula (1), it can be known that when the viewing angle is relatively flat, that is, the viewing angle vector and the normal vector approach perpendicularity, the x value in formula (1) approaches 0. Therefore, the first reflected color information A in formula (1) multiplied by (1 - x) approaches A, while the second reflected color information multiplied by x approaches 0. Thus, the second reflected color information can be weakened, and the reflected color information at a relatively flat viewing angle position can be ensured. Similarly, when the viewing angle is relatively vertical, that is, the viewing angle vector and the normal vector approach parallelism, the first reflected color information can be weakened, making the second emitted color information stronger. At this time, the color information sampled at the reflection position is the color information sampled from the environment map, which can ensure the correct rendering of the color information at the reflection position. Therefore, through the Fresnel information, the reflection effect at a relatively flat viewing angle position can be ensured, and the second reflection information at a relatively vertical viewing angle position can be made stronger, obtaining a better reflection effect.

[0085] S205. Render each pixel point according to the target reflection information.

[0086] Please continue to refer to Figure 1 , rendering each pixel point according to the target reflection information can be understood as the reflected color information of point A obtained by rendering at point C.

[0087] In this embodiment, the reflection positions of the light rays reflected by each pixel point on the water surface on the target object are obtained; according to the reflection positions corresponding to each pixel point, the first reflection information and the second reflection information corresponding to each pixel point are determined; the first reflection information is sampled from the opaque texture declaration map, and the second reflection information is sampled from the preset environmental reflection information; according to the normal vector and the viewing vector at each pixel point, the Fresnel information corresponding to each pixel point is determined; according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel point, the target reflection information corresponding to each pixel point is obtained; each pixel point is rendered according to the target reflection information. Since the reflection positions of the light rays reflected by each pixel point on the water surface are obtained and the second reflection information corresponding to each pixel point is determined, the second reflection information is sampled from the preset environmental reflection information, and according to the Fresnel information, the first reflection information and the second reflection information, the target reflection information corresponding to each pixel point is obtained, it is possible to ensure the reflection effect at a relatively flat viewing angle position, and the reflection information obtained at the viewing angle vertical position is stronger, so as to obtain a better reflection effect at the viewing angle vertical position. In addition, since in the world space coordinate system, a preset distance is traveled along the reflection direction of each pixel point to determine the reflection position of each pixel point in the world space, and the preset distance is positively correlated with the vertical component of the viewing vector, only one step is required to determine the reflection position, avoiding the need for hundreds of steps in the related art, thereby reducing the performance consumption of the mobile terminal and realizing a better reflection effect of the water body on the mobile terminal.

[0088] Based on the above embodiment of the water body reflection processing method, Figure 4 This is a schematic structural diagram of the water body reflection processing device provided by the embodiment of the present application. As Figure 4 shown, the water body reflection processing device includes: an acquisition module 41, a determination module 42, and a rendering module 43; the acquisition module 41 is configured to acquire the reflection positions of the light rays reflected by each pixel point on the water surface on the target object; the determination module 42 is configured to determine the first reflection information and the second reflection information corresponding to each pixel point according to the reflection positions corresponding to each pixel point; the first reflection information is sampled from the opaque texture declaration map, and the second reflection information is sampled from the preset environmental reflection information; the determination module 42 is further configured to determine the Fresnel information corresponding to each pixel point according to the normal vector and the viewing vector at each pixel point; the determination module 42 is further configured to obtain the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point; the rendering module 43 is configured to render each pixel point according to the target reflection information.

[0089] In some embodiments, the obtaining module 41 obtains the reflection position of the light reflected by each pixel point on the water surface on the target object, which specifically includes: for each pixel point on the water surface, in the world coordinate system, obtaining the viewing vector and the normal direction corresponding to the pixel point; determining the reflection direction corresponding to the pixel point according to the viewing vector and the normal direction; taking the position obtained by traveling a preset distance along the reflection direction from the pixel point as the reflection position of the light reflected by the pixel point on the target object; wherein, the preset distance is positively correlated with the vertical component of the viewing vector.

[0090] In some embodiments, the determining module 42 determines the first reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point, which specifically includes: for each pixel point, determining the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system; sampling in the opaque texture declaration map according to the UV coordinates to obtain the first reflection information corresponding to the pixel point.

[0091] In some embodiments, the determining module 42 determines the second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point, which specifically includes: for each pixel point, determining the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system; sampling in the preset ambient reflection information according to the UV coordinates to obtain the second reflection information corresponding to the pixel point.

[0092] In some embodiments, the determining module 42 determines the UV coordinates corresponding to the reflection position according to the reflection position corresponding to the pixel point in the world coordinate system, including: converting the reflection position corresponding to the pixel point in the world space to the clip space to obtain the reflection position of the pixel point in the clip space; converting the coordinates of the reflection position in the clip space to a preset interval range to obtain the UV coordinates corresponding to the reflection position.

[0093] In some embodiments, the determining module 42 determines the Fresnel information corresponding to each pixel point according to the normal and the viewing vector at each pixel point, including: determining the Fresnel information corresponding to each pixel point according to the dot product result of the viewing vector and the normal.

[0094] In some embodiments, the determining module 42 obtains the target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point, including: using the Fresnel information as the mask difference for the transition calculation between the first reflection information and the second reflection information to obtain the target reflection information corresponding to each pixel point.

[0095] The water body reflection processing device provided by the embodiments of the present application can be used to execute the technical solutions of the water body reflection processing method in the above embodiments. Its implementation principle and technical effects are similar and will not be elaborated here.

[0096] It should be noted that it should be understood that the division of each module of the above device is only a logical function division. In actual implementation, it can be fully or partially integrated into a physical entity, or physically separated. And these modules can all be implemented in the form of software called by a processing element; they can also all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the determination module 42 can be a separately established processing element, or can be integrated in a certain chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a certain processing element of the above device to perform the functions of the above determination module 42. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together or can be independently implemented. Here, the processing element can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the integrated logic circuit in the hardware of the processor element or the instructions in the form of software.

[0097] Figure 5 It is a schematic structural diagram of an electronic device provided by the embodiments of the present application. As Figure 5 shown, the electronic device may include: a processor 51, a memory 52, and a transceiver 53.

[0098] The processor 51 executes the computer execution instructions stored in the memory, so that the processor 51 executes the solutions in the above embodiments. The processor 51 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application specific integrated circuit ASIC, a field programmable gate array FPGA, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0099] The memory 52 is connected to the processor 51 through a system bus and completes communication with each other. The memory 52 is used to store computer program instructions.

[0100] The transceiver 53 can be used to obtain the reflection positions of the light reflected by each pixel point on the water surface on the target object.

[0101] The system bus can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The system bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to implement communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include Random Access Memory (RAM), and may also include non-volatile memory.

[0102] The electronic device provided by the embodiment of the present application can be used to execute the technical solution of the water body reflection processing method in the above embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0103] The embodiment of the present application also provides a chip for running instructions, and this chip is used to execute the technical solution of the water body reflection processing method in the above embodiment.

[0104] The embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions run on a computer, the computer is enabled to execute the technical solution of the water body reflection processing method in the above embodiment.

[0105] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium, and when at least one processor executes the computer program, the technical solution of the water body reflection processing method in the above embodiment can be implemented.

[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for processing water body reflection, characterized in that, Including: Obtaining the reflection position of the light reflected by each pixel on the water surface on the target object, where the target object is an object reflected by the water; Determining, according to the reflection position corresponding to each pixel, a first reflection information and a second reflection information corresponding to each pixel; the first reflection information is sampled from an opaque texture declaration map, and the second reflection information is sampled from a preset environmental reflection information; Determining, according to the normal and the viewing vector at each pixel, the Fresnel information corresponding to each pixel; Obtaining the target reflection information corresponding to each pixel according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel; Rendering each pixel according to the target reflection information; The determining, according to the reflection position corresponding to each pixel, a first reflection information and a second reflection information corresponding to each pixel includes: For each pixel, converting the reflection position corresponding to the pixel in world space to clip space to obtain the reflection position of the pixel in clip space; Converting the coordinates of the reflection position in clip space to a preset interval range to obtain the UV coordinates corresponding to the reflection position; Sampling in the opaque texture declaration map according to the UV coordinates to obtain the first reflection information corresponding to the pixel, and sampling in the preset environmental reflection information to obtain the second reflection information corresponding to the pixel.

2. The method according to claim 1, wherein The obtaining the reflection position of the light reflected by each pixel on the water surface on the target object includes: For each pixel on the water surface, obtaining the viewing vector and the normal direction corresponding to the pixel in the world coordinate system; Determining the reflection direction corresponding to the pixel according to the viewing vector and the normal direction; Taking the position obtained by traveling a preset distance from the pixel along the reflection direction as the reflection position of the light reflected by the pixel on the target object; Wherein, the preset distance is positively correlated with the component of the viewing vector in the vertical direction.

3. The method according to claim 1, wherein The determining, according to the normal and the viewing vector at each pixel, the Fresnel information corresponding to each pixel includes: Determining the Fresnel information corresponding to each pixel according to the dot product result of the viewing vector and the normal.

4. The method according to claim 1 or 3, characterized in that The obtaining the target reflection information corresponding to each pixel according to the Fresnel information, the first reflection information and the second reflection information corresponding to each pixel includes: Taking the Fresnel information as the mask difference for the transition calculation between the first reflection information and the second reflection information to obtain the target reflection information corresponding to each pixel.

5. A water body reflection processing device, characterized in that, Including: An obtaining module, configured to obtain the reflection position of the light reflected by each pixel on the water surface on the target object, where the target object is an object reflected by the water; A determination module, configured to determine first reflection information and second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point; the first reflection information is sampled from an opaque texture declaration map, and the second reflection information is sampled from preset ambient reflection information; The determination module is further configured to determine Fresnel information corresponding to each pixel point according to the normal vector and the view vector at each pixel point; The determination module is further configured to obtain target reflection information corresponding to each pixel point according to the Fresnel information, the first reflection information, and the second reflection information corresponding to each pixel point; A rendering module, configured to render each pixel point according to the target reflection information; When determining the first reflection information and the second reflection information corresponding to each pixel point according to the reflection position corresponding to each pixel point, the determination module is specifically configured to: Convert the reflection position corresponding to the pixel point in world space to clip space to obtain the reflection position of the pixel point in clip space; Convert the coordinates of the reflection position in clip space to a preset interval range to obtain the UV coordinates corresponding to the reflection position; Sample in the opaque texture declaration map according to the UV coordinates to obtain the first reflection information corresponding to the pixel point, and sample in the preset ambient reflection information to obtain the second reflection information corresponding to the pixel point.

6. An electronic device, characterized in that, Comprising: A memory and a processor; A memory; A memory for storing executable instructions of the processor; Wherein, the processor is configured to implement the method according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by the processor, they are used to implement the method according to any one of claims 1-4.

8. A computer program product, characterized in that, Including a computer program, which when executed by a processor implements the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Real-time rendering method and real-time rendering device

    CN107067455A