Rendering method and device, electronic equipment and storage medium
By obtaining the target pixel points of the water domain model in the virtual scene, calculating the target normal and lighting intensity, and rendering the light and shadow effects, the problem of large resource consumption when forming wave effects in the waters in the prior art is solved, and the resource reduction and wave effects are realized.
Patent Information
- Application Number
- CN202411613266.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-07
AI Technical Summary
The prior art requires a lot of resources to form wave effects in waters, mainly due to the need to continuously generate and release wave models.
By obtaining the target pixel points of the water model in the virtual scene, the target normal is calculated based on the motion control information for the pixel points, and the lighting intensity is determined based on the target normal and the shooting direction of the virtual camera. Finally, the light and shadow effect is rendered on the target pixel points to form a wave effect in the water boundary area.
The resource reduction is achieved when the wave effect is formed in the water. Just render the light and shadow effect on the pixels to form a wave effect in the water, reducing the use of computing resources.
Smart Images

Figure CN119579762A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of rendering technology, and in particular to a rendering method, device, electronic device and storage medium. Background Art
[0002] Under the tide of the Internet, entertainment projects are becoming more and more important in people's lives. In order to meet the needs of scene effect presentation in some entertainment projects (such as animated movies and games), the water area in the scene needs to be rendered to form a wave effect in the water area.
[0003] At present, the main way to form wave effects in water areas is to set at least one layer of wave model in a virtual scene, and control the wave model to continuously move in a cycle at the boundary of the water area through a program to form a wave effect. However, this method requires continuous generation and release of wave models during actual control, which results in a large amount of resources being consumed when forming wave effects in water areas. Summary of the invention
[0004] The embodiments of the present application provide a rendering method, device, electronic device and storage medium, which can reduce the resources consumed when forming a wave effect in water areas.
[0005] In a first aspect, an embodiment of the present application provides a rendering method, the method comprising:
[0006] Acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary region of the water area model, and the water area boundary region is adjacent to a land model in the virtual scene;
[0007] Based on the motion control information for the pixel point, a target normal line of the target pixel point on the wave formed in the boundary area of the water area is calculated;
[0008] Determining the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene;
[0009] A light and shadow effect is rendered for the target pixel point based on the light intensity to form a wave effect in the water boundary area.
[0010] In a second aspect, an embodiment of the present application provides a rendering device, the device comprising:
[0011] A pixel point acquisition module is used to acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary area of the water area model, and the water area boundary area is adjacent to a land model in the virtual scene;
[0012] A normal determination module, used for calculating a target normal of the target pixel point on the wave formed in the water boundary area based on the motion control information for the pixel point;
[0013] An illumination determination module, used to determine the illumination intensity of the target pixel point based on the target normal and the shooting direction of the virtual camera in the virtual scene;
[0014] A rendering module is used to render light and shadow effects on the target pixel points based on the light intensity to form a wave effect in the water boundary area.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; a processor loads instructions from the memory to execute the steps of any rendering method provided in the embodiment of the present application.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any rendering method provided in an embodiment of the present application.
[0017] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of any rendering method provided in the embodiment of the present application.
[0018] By adopting the scheme of the embodiment of the present application, the target pixel point in the water boundary area of the water model in the virtual scene can be obtained, and the target normal on the wave formed by the above-mentioned target pixel point in the above-mentioned water boundary area can be calculated based on the motion control information of the pixel point, and the light intensity of the above-mentioned target pixel point can be determined based on the above-mentioned target normal and the shooting direction of the virtual camera in the above-mentioned virtual scene, and then the light and shadow effect of the above-mentioned target pixel point is rendered based on the above-mentioned light intensity to visually show an uneven effect, so as to realize the formation of a wave effect in the above-mentioned water boundary area, so that the wave effect can be formed in the water area by only rendering the light and shadow effect on the pixel, thereby reducing the resources consumed in forming the wave effect in the water area. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 It is a schematic diagram of an embodiment of the rendering method provided in the embodiments of the present application;
[0021] Figure 2 is a schematic diagram of a land model provided in an embodiment of the present application;
[0022] Figure 3 is a depth map provided in an embodiment of the present application;
[0023] Figure 4 is a binarized depth map provided in an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of the normal line of the ocean wave provided in the embodiment of the present application;
[0025] Figure 6 is a schematic diagram of a sea wave waveform provided in an embodiment of the present application;
[0026] Figure 7 is a schematic diagram of the normal determination process provided in an embodiment of the present application;
[0027] Figure 8 It is a schematic diagram of a wave effect provided in an embodiment of the present application;
[0028] Fig. 9 is another schematic diagram of wave effect provided in an embodiment of the present application;
[0029] Fig.10 is a schematic diagram of the structure of a rendering device provided in an embodiment of the present application;
[0030] Fig.11 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0032] Embodiments of the present application provide a rendering method, apparatus, electronic device, and computer-readable storage medium.
[0033] Specifically, this embodiment will be described from the perspective of a rendering device, which can be integrated into an electronic device, that is, the rendering method of the embodiment of the present application can be executed by an electronic device, and optionally, the electronic device can include: a terminal device. The terminal device can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a game console, or a personal computer (PC) and other devices.
[0034] The rendering method provided in the embodiment of the present application can be applied to a rendering system. The rendering system may include a player terminal device and a server, and the terminal may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. The player terminal device and the server may perform two-way communication via a network.
[0035] Optionally, the server may be an independent server, or a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
[0036] The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device as an example. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0037] The rendering method of this embodiment obtains the target pixel point of the water model in the virtual scene, the target pixel point is in the water boundary area of the water model, and the water boundary area is adjacent to the land model in the virtual scene; based on the motion control information for the pixel point, calculates the height information to which the target pixel point moves when forming waves in the water boundary area; based on the height information, determines the target normal of the target pixel point on the wave; based on the target normal and the shooting direction of the virtual camera in the virtual scene, determines the light intensity of the target pixel point; based on the light intensity, renders the light and shadow effect for the target pixel point to form a wave effect in the water boundary area, which can reduce the resources consumed when forming the wave effect in the water area.
[0038] Please refer to Figure 1 Taking a terminal as an example, this embodiment provides a rendering method. The specific process of the rendering method may be as follows: Steps 101 to 104, wherein:
[0039] Step 101: Acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is in a water area boundary region of the water area model, and the water area boundary region is adjacent to a land model in the virtual scene.
[0040] The water area model includes but is not limited to a model composed of at least one type of water resources such as streams, rivers, lakes or oceans. For example, when the water area model is an ocean model, the wave effect formed in the water area may be the formation of sea waves.
[0041] It is understandable that waves generally need to be rendered in the area where the water area and land meet in the virtual scene to ensure the authenticity of the rendering effect and show the effect of waves at the edge of the water area constantly "washing" the coast. For this purpose, it is necessary to determine the water boundary area in the water model. The water boundary area is actually the area in the water model adjacent to the land model, so as to form a wave effect in the water boundary area.
[0042] Furthermore, in order to achieve a wave effect in the water boundary area, it is necessary to obtain target pixel points in the water boundary area. The target pixel points are part of all pixel points in the water model, and the target pixel points are used to form the above-mentioned water boundary area for display on the screen.
[0043] It should be noted that since the water area model has many vertices, if the vertices of the water area model are controlled for motion rendering to form a wave effect in the water area boundary area, it will undoubtedly cause greater rendering pressure. Therefore, in this embodiment, by using the pixel points of the water area model, the pixel points of the water area model are the smallest unit when the water area model is displayed on the screen, so as to control the display method of the pixel points of the water area model to visually achieve the wave effect in the water area boundary area.
[0044] In some embodiments, the above-mentioned method of obtaining the target pixel points of the water model in the virtual scene includes but is not limited to: the terminal can determine the target pixel points based on the user's marking of each pixel point in the water model, wherein the mark of the pixel point is used to indicate the area where the pixel point is located; or, the terminal can traverse the relative position between each pixel point in the water model and the land model to divide the target pixel points based on the relative position, etc.
[0045] Specifically, the terminal may obtain the pixel distance of each pixel in the water model, where the pixel distance indicates the distance between the pixel and the land model. Then, the terminal may determine the target pixel in the water boundary area based on the pixel distance of each pixel.
[0046] A preset distance range or a preset distance threshold may be set to take pixels whose distance is within the preset distance range, or pixels whose distance is less than the preset distance threshold, as target pixels.
[0047] Exemplarily, the preset distance range may be set to 0 to 1, and pixels within the range of 0 to 1 are taken as target pixels.
[0048] In some embodiments, the above-mentioned obtaining the pixel distance of each pixel point in the above-mentioned water area model may include steps 1011 to 1013:
[0049] Step 1011: Obtain a signed distance field map corresponding to the virtual scene, where the signed distance field map is used to indicate the distance between a pixel point in the virtual scene and the land model.
[0050] It can be understood that since the virtual scene includes the land model area where the land model is located and the non-land model area where the land model is not located, in the directed distance field map corresponding to the virtual scene, the distance between the pixel point and the land model can be the distance between the pixel point and the model edge of the land model.
[0051] Specifically, the step of obtaining the signed distance field map corresponding to the virtual scene may include:
[0052] Firstly, the terminal may shoot the virtual scene by using a preset orthogonal camera in a direction facing the land model to obtain a depth map.
[0053] Among them, only land models can be placed in the virtual scene, such as Figure 2 As shown, Figure 2 The model at the center is the land model. By placing only the land model, the generated signed distance field map can distinguish the land model area from the non-land model area, and the non-land model area can include the area where the water model is located.
[0054] It can be understood that, generally, the orientation of the land model in the virtual scene is upward, so the shooting direction of the orthogonal camera can be a downward direction perpendicular to the plane where the land model is located. In this embodiment, the land model in the virtual scene is photographed by the orthogonal camera to obtain the depth information of the land model, thereby generating a depth map of the virtual scene containing the depth information of the land model, such as Figure 3 As shown, Figure 3 The gray area in is the area corresponding to the land model. If the depths of different positions of the land model are different, the colors of the displayed depth map will also be different.
[0055] Alternatively, the terminal may also shoot the virtual scene using a preset orthogonal camera in a direction facing the water model to obtain a depth map. In the virtual scene, only the ocean model may be placed.
[0056] Then, the terminal can binarize the depth map to obtain a binarized depth map, wherein the two values in the binarized depth map respectively indicate that the pixel point belongs to a land model area or a non-land model area, so that the terminal can generate a signed distance field based on the depth map that can clearly distinguish between the land model area and the non-land model area.
[0057] It can be understood that since the depth value range in the depth map is usually 0 to 1, 0 can be used to represent the distance within the near plane of the camera, and 1 can be used to represent the distance within the far plane of the camera. That is, the area where the land model is less than 1 is considered to be a non-land model area, and the area equal to 1 is considered to be a water area. Therefore, 1 can be used for binarization to obtain a depth map with only 0 and 1 values. For example, 0 is indicated as a black area, that is, a non-land model area, and 1 is indicated as a white area, that is, a land model area. Conversely, 0 can be indicated as a land model area and 1 can be indicated as a non-land model area. The specific setting is based on demand and is not limited here.
[0058] For example, Figure 4 As shown, the terminal can Figure 3 The provided depth map is binarized to obtain Figure 4 The binarized depth map shown.
[0059] Alternatively, when the terminal shoots the virtual scene using a preset orthogonal camera facing the water model, the two values in the binarized depth map respectively indicate whether the pixel belongs to the water model area or the non-water model area.
[0060] Finally, the terminal can calculate the distance and direction between each pixel point in the virtual scene and the boundary of the land model area and the non-land model area based on the binarized depth map, and generate a directed distance field map corresponding to the virtual scene.
[0061] Among them, the terminal can use Photoshop to create a signed distance field map, such as obtaining a binarized depth map, that is, a black and white image, traversing the distance from each pixel to the nearest edge, and determining the direction pointing to the edge.
[0062] For example, the terminal may generate Figure 5 The terminal can determine the target pixel point in the water boundary area based on the pixel distance of each pixel point in the distance field map. Figure 5 The white area is the land model area, and the black area is the non-land model area. The fuzzy area between the white area and the black area is the water boundary area. The value in this fuzzy area is between 0 and 1, but does not include 0 and 1. Figure 5 As can be seen, the farther away from the land model area, the darker the color, until it reaches the black area corresponding to 0.
[0063] A preset distance range or a preset distance threshold may be set to take pixels whose distance is within the preset distance range, or pixels whose distance is less than the preset distance threshold, as target pixels.
[0064] Alternatively, when the terminal shoots the above-mentioned virtual scene through a preset orthogonal camera in the direction facing the above-mentioned water model, the terminal can calculate the distance and direction between each pixel point in the above-mentioned virtual scene and the boundary of the above-mentioned water model area and the above-mentioned non-water model area based on the above-mentioned binarized depth map, and generate a signed distance field map corresponding to the above-mentioned virtual scene.
[0065] Step 1012: Determine the sampling coordinates of each pixel point in the water area model in the signed distance field map.
[0066] In this embodiment, the terminal needs to determine the sampling coordinates of each pixel point in the water area model in the signed distance field, so that the terminal samples the pixel distance of the corresponding pixel point based on the sampling coordinates.
[0067] Specifically, the above-mentioned determination of the sampling coordinates of each pixel point in the above-mentioned water area model in the above-mentioned signed distance field map may include steps 10121 to 10123:
[0068] Step 10121: Obtain the baking range of the above-mentioned signed distance field map in world space.
[0069] If the signed distance field map is generated based on an image taken by an orthogonal camera, then the baking range of the signed distance field map in the world space can be obtained based on the orthogonal camera.
[0070] Specifically, the terminal can obtain the initial baking range of the signed distance field map in the camera space of the orthogonal camera, and then the terminal can obtain the camera coordinates of the orthogonal camera in the world space. Finally, the terminal can determine the baking range of the signed distance field map in the world space based on the camera coordinates and the initial baking range.
[0071] Among them, the above-mentioned method of obtaining the initial baking range of the above-mentioned signed distance field map in the camera space of the above-mentioned orthogonal camera can be: the terminal can obtain the target plane size and the camera aspect ratio of the camera viewing frustum of the above-mentioned orthogonal camera, and then the terminal can determine the far plane height and the far plane width of the camera viewing frustum based on the above-mentioned target plane size and the camera aspect ratio. Finally, the terminal can determine the initial baking range of the above-mentioned signed distance field map in the camera space of the above-mentioned orthogonal camera based on the above-mentioned far plane height and the above-mentioned far plane width.
[0072] It should be noted that the above-mentioned target plane size can be a size set for the width or height of any plane of the camera frustum of the orthogonal camera, for example, the far plane height of the camera frustum, the near plane height of the camera frustum, the far plane width of the camera frustum, or the near plane width of the camera frustum.
[0073] For example, the far plane height of the camera frustum can be set to farClipPlaneHeight, the near plane height of the camera frustum can be set to nearClipPlaneHeight, the far plane width of the camera frustum can be set to farClipPlaneWidth, the near plane width of the camera frustum can be set to nearClipPlaneWidth, and the camera aspect ratio can be set to Aspect.
[0074] Since the above-mentioned signed distance field map is generated based on the image taken by the orthographic camera, then:
[0075] farClipPlaneHeight=nearClipPlaneHeight;
[0076] nearClipPlaneHeight=2*Size;
[0077] nearClipPlaneWidth=Aspect*nearClipPlaneHeight;
[0078] farClipPlaneWidth=nearClipPlaneWidth;
[0079] Among them, by setting Size as an adjustable parameter so that the user can adjust it, the nearClipPlaneHeight can be obtained through Size, that is, the near plane height of the camera cone is used as the target plane size.
[0080] Furthermore, after obtaining farClipPlaneHeight and farClipPlaneWidth, the above-mentioned initial baking range can be determined based on farClipPlaneHeight and farClipPlaneWidth. The initial baking range is as follows:
[0081] ((-farClipPlaneWidth / 2,-farClipPlaneHeight / 2),(farClipPlaneWidth / 2,farClipPlaneHeight / 2)).
[0082] Furthermore, since the orthogonal camera is perpendicular to the world coordinate system and points downward, if the camera coordinates in the world space are set to CameraPos, then based on the initial baking range and CameraPos, the baking range of the above-mentioned signed distance field map in the above-mentioned world space can be determined, and the baking range is as follows:
[0083] ((CameraPos.x-farClipPlaneWidth / 2,CameraPos.z-farClipPlaneHeight / 2),(Ca meraPos.y+farClipPlaneWidth / 2,CameraPos.z+farClipPlaneHeight / 2));
[0084] Among them, CameraPos.x is the x-axis coordinate of the camera coordinate, and CameraPos.z is the z-axis coordinate of the camera coordinate.
[0085] Step 10122: Obtain the pixel coordinates of each pixel in the water area model in the world space.
[0086] Among them, since the water area model is composed of multiple vertices, when calculating the pixel coordinates of each pixel point in the water area model in the world space, the vertex shader can output the vertex coordinates of the vertices of the water area model in the world space when drawing the water area model, and then use rasterization processing to project the water area model on the screen into discrete pixels, so that the pixel coordinates of each pixel point in the world space can be obtained in the pixel shader stage.
[0087] Step 10123: Determine the sampling coordinates of each pixel in the signed distance field map based on the relative positions of the pixel coordinates of each pixel in the baking range.
[0088] In this embodiment, after obtaining the pixel coordinates of each pixel in the world space, the sampling coordinates of each pixel can be obtained by the relative position of the pixel coordinates in the baking range, so that the pixel shader corresponding to the water model can sample the signed distance field map based on the sampling coordinates.
[0089] Among them, the method of determining the sampling coordinates of the above-mentioned pixel points in the above-mentioned signed distance field map based on the relative position of the above-mentioned pixel coordinates of the above-mentioned pixel points in the above-mentioned baking range may be: the terminal may calculate the distance difference between the above-mentioned pixel coordinates of the above-mentioned pixel points and the initial position of the above-mentioned baking range to obtain the relative coordinates of the above-mentioned pixel points, and then calculate the ratio between the relative coordinates of the above-mentioned pixel points and the range length of the above-mentioned baking range to obtain the sampling coordinates of the above-mentioned pixel points in the above-mentioned signed distance field map, and the sampling coordinates may be coordinates in the range of 0 to 1.
[0090] It should be noted that, since the world coordinates are three-dimensional and the signed distance field map is two-dimensional, only the horizontal coordinates of the pixel coordinates need to be selected to participate in the process of determining the sampling coordinates, and the horizontal coordinate axes are different in different shaders. For example, the horizontal coordinate axes on a shader are the x-axis and the z-axis.
[0091] For example, the baking range obtained in the above example can obtain the starting position of the baking range, and the starting position is as follows:
[0092] StartPos=(CameraPos.x-farClipPlaneWidth / 2,CameraPos.z-farClipPlaneHeigh t / 2);
[0093] The StartPos is the starting position of the baking range.
[0094] Furthermore, if the pixel coordinates of the above pixel points are set as WorldPos, then the sampling coordinates of the above pixel points are as follows:
[0095] Texcoord = (WorldPos.xz-StartPos.xz) / the range length of the above baking range;
[0096] The range length of the above baking range = float2(farClipPlaneWidth, farClipPlaneHeight);
[0097] Among them, the above WorldPos.xz is the x-axis coordinate and the z-axis coordinate of the pixel point coordinate, the above StartPos.xz is the x-axis coordinate and the z-axis coordinate of the starting position of the baking range, and the above Texcoord is the sampling coordinate of the above pixel point.
[0098] Step 1013: based on the sampling coordinates of each pixel point, sample the signed distance field map to obtain the pixel distance of each pixel point.
[0099] In this embodiment, the terminal may sample the distance field map through a shader to obtain the pixel distance of each pixel.
[0100] Exemplarily, the above pixel distance is determined as follows:
[0101] float w=1.0-tSDFMap.Sample(sSDFSampler,Texcoord.xy).r;
[0102] Among them, the above w is the pixel distance of the pixel point, the above tSDFMap is the signed distance field map, the above sSDFSampler is the sampler for sampling the signed distance field map, the above Texcoord.xy is the x-axis coordinate and the y-axis coordinate of the sampling coordinate, and the above r is used to indicate the r channel in the signed distance field map.
[0103] It can be understood that sSDFSampler can read the r channel data of the corresponding position in tSDFMap based on Texcoord.xy to obtain w, and w is data between 0 and 1, including 0 and 1. If w is equal to 0, it means that the corresponding pixel point belongs to the land model area, and if w is equal to 1, it means that the corresponding pixel point belongs to the non-water boundary area of the water model, and if w is between the two, it means that the corresponding pixel point belongs to the water boundary area of the water model. The larger the value of w, the farther the land model is.
[0104] Step 102: Based on the motion control information for the pixel point, a target normal line of the target pixel point on the wave formed in the boundary area of the water area is calculated.
[0105] The motion control information is used to calculate relevant information when the pixel point moves to the corresponding position when simulating the wave motion.
[0106] It can be understood that, in this embodiment, it is necessary to simulate the formation of waves in the above-mentioned water boundary area in order to clarify the relevant information of the wave position of the target pixel point, so the above-mentioned motion control information for the pixel point is used to control the waveform change of the simulated wave of the pixel point, so as to calculate the relevant information of the pixel point on the formed wave.
[0107] In this embodiment, since the target pixel points are used to visually simulate the formation of waves in the water boundary area, it is necessary to clearly define the target normal corresponding to the position of the target pixel point on the wave when the wave is formed in the water boundary area, so as to render the pixel point accordingly based on the target normal, thereby causing the water boundary area where the pixel point is located to visually present a wave effect.
[0108] The target normal may be a normal of a target pixel point compared to a wave section.
[0109] It can be understood that before waves are formed in the water boundary area, the normal of the target pixel point in the water boundary area is perpendicular to the reference plane and upward, that is, the water model as a whole is flat and parallel to the horizontal direction of the land model. When waves are simulated in the water boundary area, the normal of the target pixel point will change, and the normal of the target pixel point will be adjusted according to its position on the simulated wave. The adjusted target normal is equivalent to the normal that the target pixel point should express when waves are formed in the water boundary area in the virtual scene. Therefore, through the target normal, the position of the target pixel point does not change, and the expression of the target pixel point can still be visually controlled to visually present the change of the target pixel point, that is, the state of the target pixel point changing with the change of the waves.
[0110] In some embodiments, since the target normal is perpendicular to the section of the wave, the normal of the target pixel point can be determined based on the tangent by determining the tangent of the target pixel point on the wave.
[0111] Among them, the tangent at the target pixel point can be determined based on the method of determining the height information of the target normal. The above height information can be the height information between the target pixel point and the reference horizontal plane of the water model. The reference horizontal plane can be the horizontal plane corresponding to the area where no waves are formed in the water model, that is, the horizontal plane corresponding to the non-water boundary area.
[0112] Specifically, the above-mentioned calculation of the target normal of the target pixel point on the wave formed in the above-mentioned water boundary area based on the motion control information for the pixel point may include: the terminal may determine the pixel tangent of the above-mentioned target pixel point on the wave in the two-dimensional space based on the above-mentioned motion control information, so as to determine the two-dimensional pixel normal perpendicular to the above-mentioned pixel tangent of the above-mentioned target pixel point in the above-mentioned two-dimensional space, and then convert the two-dimensional pixel normal of the above-mentioned target pixel point into the target normal in the three-dimensional space.
[0113] The two-dimensional pixel normal is the normal of the target pixel point in the two-dimensional space, and the normal is perpendicular to the pixel tangent.
[0114] It is understandable that the terminal can obtain a cross-sectional view of the wave along a direction perpendicular to the reference horizontal plane to obtain the following Figure 6 The wave shape shown, Figure 6 The wave waveform shown is a wave waveform in two-dimensional space. The terminal can be based on Figure 6 The parameters in are used to calculate the slope of the pixel tangent of the target pixel on the wave to obtain a slope of dy / dx. Then, the terminal can determine the vector of the pixel tangent based on the slope, that is, (1,dy / dx).
[0115] Furthermore, the terminal can Figure 7 The perpendicular relationship between the pixel tangent and the 2D pixel normal is shown, and the slope of the 2D pixel normal is -dx / dy, while the vector of the 2D pixel normal is (-dy / dx, 1). It can be understood that because the 2D pixel normal and the pixel tangent are perpendicular to each other, and their coordinate axes are perpendicular to each other, the slope of the 2D pixel normal can be obtained according to the law of similar triangles.
[0116] In some embodiments, the pixel tangent of the target pixel point on the wave in the two-dimensional space can be obtained through the height information of the target pixel point. Since the height information of the target pixel point needs to be obtained through a waveform function, the pixel tangent of the target pixel point on the wave in the two-dimensional space needs to be determined through the waveform function in the motion control information.
[0117] Specifically, the above-mentioned motion control information may include a waveform function; the above-mentioned determination of the pixel tangent of the above-mentioned target pixel point on the wave in the two-dimensional space based on the motion control information for the pixel point may include: the terminal may determine the variable parameters of the above-mentioned waveform function based on the current moment and the above-mentioned pixel distance of the above-mentioned target pixel point at the above-mentioned current moment, and then, the terminal may obtain the pixel tangent of the above-mentioned target pixel point on the wave in the two-dimensional space based on the processing result obtained by processing the above-mentioned variable parameters based on the above-mentioned waveform function.
[0118] It is understandable that the waves formed in the water boundary area in the virtual scene change in real time. Therefore, the distance between the pixel point and the land model at different times is also different. Therefore, it is necessary to determine the relevant information at the current moment to determine the variable parameters of the waveform function so that the waveform function can process the above variable parameters to obtain the pixel tangent to which the target pixel point moves when waves are formed in the above water boundary area.
[0119] Among them, the above-mentioned waveform function includes but is not limited to the sine function (denoted as sin function), cosine function (denoted as cos function), etc., so that the position of the pixel point is modified by the sine function or cosine function to simulate the movement of water waves, thereby simulating the waveform of the wave. For example, the y-axis coordinate of the pixel point can be changed to achieve the ups and downs effect of water waves, or by adjusting the amplitude, angular frequency and initial phase, water waves with different effects can be simulated.
[0120] Exemplarily, the slope of the pixel tangent may be cos (variable parameter).
[0121] Among them, the above-mentioned determination of the variable parameters of the above-mentioned waveform function based on the current moment and the above-mentioned pixel distance of the above-mentioned target pixel point at the above-mentioned current moment may include: the terminal may determine the first variable value of the above-mentioned waveform function based on the above-mentioned current moment and the frequency information corresponding to the above-mentioned waveform function, and the first variable value is used to represent the speed of waveform advancement. Then, the terminal may determine the second variable value of the above-mentioned waveform function according to the above-mentioned pixel distance of the above-mentioned target pixel point at the current moment and the phase coefficient corresponding to the above-mentioned waveform function, and the second variable value is used to represent the phase. Finally, the terminal may use the sum of the above-mentioned first variable value and the above-mentioned second variable value as the variable parameter of the above-mentioned waveform function.
[0122] Specifically, the terminal can simulate the simple harmonic motion of the target pixel point based on the above waveform function to simulate the formation of waves in the water boundary area, and the target pixel point is located on the waves.
[0123] It should be noted that the above-mentioned simple harmonic motion refers to the periodic reciprocating motion of a pixel point around an equilibrium position at a certain frequency under the action of a constant periodic force, and the law of change of the displacement of the simple harmonic motion with time can be described by a sine function or a cosine function.
[0124] Exemplarily, when simple harmonic motion is used to simulate wave formation in a water boundary area, the first variable value may be at, and the second variable value may be w*WaveWidth, so that the variable parameter may be determined based on at and w*WaveWidth, i.e., the variable parameter = at + w*WaveWidth, and then the height information of the target pixel point may be determined, i.e., height = sin(at + w*WaveWidth).
[0125] Among them, the above a is frequency information, which is used to indicate the speed of wave propulsion and can be manually adjusted by the user to achieve the expected effect; the above t is the current moment; the above w is the pixel distance; the above WaveWidth is the phase coefficient, which can be manually adjusted by the user to achieve the expected effect, and the width of the waveform can be adjusted.
[0126] It can be understood that the phase is represented by w*WaveWidth, and the phase changes with the change of w, that is, it is linearly related to the distance between the pixel point and the land model. Moreover, t will change over time, so the changes of the continuous advancement of the wave can be seen.
[0127] Furthermore, the slope of the pixel tangent can be obtained by deriving the height information, so the slope of the pixel tangent can be height′=cos(at+w*WaveWidth).
[0128] Accordingly, the vector of the above two-dimensional pixel normal is as follows:
[0129] N=normalize(-cos(at+w*WaveWidth),1);
[0130] Wherein, N is the vector of the two-dimensional pixel normal; the above-mentioned normalize function is a normalization function, which is used to scale the vector into a direction vector with a length of 1.
[0131] In some embodiments, the above-mentioned method of converting the two-dimensional pixel normal of the above-mentioned target pixel point into the target normal in three-dimensional space can be: the terminal can obtain the horizontal projection coefficient of the above-mentioned two-dimensional pixel normal on the horizontal plane of the above-mentioned water area model, and the vertical projection coefficient in the vertical direction of the above-mentioned horizontal plane, so as to determine the above-mentioned target normal based on the above-mentioned horizontal projection coefficient and the above-mentioned vertical projection coefficient, that is, the terminal can respectively calculate the first product of the horizontal projection coefficient and the horizontal vector in the horizontal direction corresponding to the horizontal plane, and the first product is the horizontal normal component of the target normal in the horizontal direction, and the second product of the vertical projection coefficient and the vertical vector in the vertical direction, and the second product is the vertical normal component of the target normal in the water quality direction. Finally, the sum of the first product and the second product can be used as the normal vector of the target normal.
[0132] The horizontal vector and the vertical vector may be set as required and are not limited here.
[0133] Exemplarily, the horizontal vector may be set to vector3(1,0,1), the vertical vector may be set to vector3(0,1,0), and based on the determination example of the vector of the two-dimensional pixel normal, the horizontal projection coefficient N of the two-dimensional pixel normal is h and the vertical projection coefficient N of the above two-dimensional pixel normal v is determined as follows:
[0134] Nh∝-cos(at+w*WaveWidth)
[0135] Nv∝1
[0136] Then, the terminal can use the horizontal projection coefficient N of the above two-dimensional pixel normal h and the vertical projection coefficient N of the above two-dimensional pixel normal v , determine the above target normal, that is, the formula for determining the target normal is as follows:
[0137] waveNormal=normalize(N h *vector3(1,0,1)+N v *vector3(0,1,0));
[0138] Among them, the above waveNormal is the above target normal.
[0139] Step 103: Determine the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene.
[0140] It is understandable that since the water model has many vertices, controlling the vertices of the water model for motion rendering to form a wave effect in the water boundary area will undoubtedly cause greater rendering pressure. Therefore, in this embodiment, the display method of the pixels of the water model is controlled to visually achieve the wave effect in the water boundary area, and the shape of the waves cannot be directly produced by changing the vertices, so as to reduce the resources consumed in forming the wave effect in the water area.
[0141] In this embodiment, if a light and shadow effect is to be rendered for a target pixel, the light intensity corresponding to the target pixel is calculated to simulate the interaction between light and the surface of the water model based on the light intensity.
[0142] Specifically, the above-mentioned illumination intensity can be determined based on the Lambert diffuse reflection model. The formula corresponding to the Lambert diffuse reflection model is I=dot(N,V), wherein I is the illumination intensity, N is the target normal, and V is the shooting direction. If the above-mentioned target normal is the same as the above-mentioned shooting direction, then the diffuse reflection illumination intensity is the largest, and as the angle between the above-mentioned target normal and the above-mentioned shooting direction increases, the diffuse reflection illumination intensity becomes smaller and smaller.
[0143] Step 104: Rendering a light and shadow effect on the target pixel point based on the light intensity to form a wave effect in the water boundary area.
[0144] In this embodiment, the terminal can render light and shadow effects for the target pixel based on the light intensity, such as Figure 8As shown, a bumpy effect is visually created for the surface of the water boundary area to achieve a wave effect in the water boundary area, so that the coastline generated in the water boundary area is beautiful and natural, and the computing resources required are reduced, which can ensure that some low-end devices can also be used.
[0145] In some embodiments, Figure 5 As shown, it can be seen that the transition between the waves formed in the water boundary area and the non-water boundary area of the land model or the water model is relatively abrupt. Therefore, it is necessary to optimize the target normal based on which the illumination intensity of the target pixel is determined, such as smoothing the target normal, to enhance the realistic effect of wave formation in the water boundary area.
[0146] It can be understood that since the normals of the non-water boundary areas of the land model or the water model are vertically upward, the normals of the waves formed in the water boundary areas are vertically upward only at the crests, and as the normal progresses from the crests to the troughs, the vertical normal component of the normal in the vertical direction becomes smaller, until the vertical normal component is the smallest when the normal is at the trough.
[0147] In this regard, after calculating the target normal of the target pixel point on the wave formed in the water boundary area, it may also include: the terminal may obtain the regional normal of the water area adjacent to the water boundary area in the water model, and then, the terminal may interpolate the regional normal and the target normal of the target pixel point to obtain the interpolation result of the target pixel point, and finally, the terminal may update the target normal of the target pixel point based on the interpolation result, that is, the terminal uses the interpolation result as the target normal.
[0148] Specifically, the above-mentioned interpolation processing of the above-mentioned regional normal and the target normal of the above-mentioned target pixel point to obtain the interpolation result of the above-mentioned target pixel point may include: the terminal may obtain the vertical normal component of the above-mentioned target normal in the vertical direction, and then, the terminal may use a smooth transition function to take values in a preset coefficient value range based on the above-mentioned vertical normal component to obtain the target weight coefficient corresponding to the above-mentioned target normal, and the two end points of the above-mentioned preset coefficient value range are the weight coefficient corresponding to the normal at the crest of the wave, and the weight coefficient corresponding to the normal at the trough of the wave. Finally, the terminal may interpolate the above-mentioned regional normal and the target normal of the above-mentioned target pixel point based on the above-mentioned target weight coefficient to obtain the interpolation result of the above-mentioned target pixel point.
[0149] Exemplarily, the above-mentioned region normal and the target normal of the above-mentioned target pixel point may be interpolated by an interpolation function, such as a lerp function, as shown below:
[0150] waveNormal_Final=normalize(lerp(SeaNormal,waveNormal,x));
[0151] Among them, the above waveNormal_Final is the interpolation result, the above SeaNormal is used to represent the area normal, that is, the vertical upward direction vector3(0,1,0), and the above x is the target weight coefficient. In order to make the weighted result of x as smooth as possible, a smooth transition function, such as the Smoothstep function, can be used to obtain x. It should be noted that compared with the linear function, the Smoothstep function can slowly parallel the coordinate axis at both ends to achieve a smooth effect, and using two Smoothstep functions to subtract each other can obtain a function with a wave-like waveform.
[0152] Furthermore, a smooth transition function can be used to obtain the weight coefficient, that is, the method of obtaining x through the Smoothstep function can be x=Smoothstep(a,1,waveNormal.y). From this method, it can be clear that the maximum value of the vertical normal component waveNormal.y can be 1, which is equivalent to the value of the target normal at the crest, and the minimum value of the vertical normal component waveNormal.y can be a, which is equivalent to the value of the target normal at the trough, where a can be a value between 0 and 1. The smaller the value of a, the more obvious the wave effect is. On the contrary, the larger the value of a, the smoother the wave effect is. The value of a can be set according to demand and is not limited here. For example, through experiments, a can be set to 0.3, and the smoothed wave effect is as follows: Fig. 9 shown.
[0153] It is understandable that if you want the intersection of the waves formed in the water boundary area and the non-water boundary area of the land model or the water model to be smoother, the normals of the waves formed in the water boundary area and the intersection of the non-water boundary area of the land model or the water model need to be more similar. Therefore, when interpolating the normal, the interpolation weight coefficient can be: the pixel points on the wave closer to the non-water boundary area of the land model or the water model have a larger weight coefficient, that is, the weight of the wave normal is smaller, and the pixel points closer to the wave crest have a smaller weight coefficient, that is, the weight of the wave normal is larger. The sum of the weights of the two can be equal to 1.
[0154] Therefore, the value trend of the weight coefficient of the wave normal changes with the waveform of the wave, such as the weight coefficient at the trough is the smallest, and the weight coefficient at the peak is the largest.
[0155] It should be noted that the smaller the vertical component of the target normal, the closer the pixel point to which the target normal belongs is to the trough, that is, the larger the vertical component of the target normal, the closer the pixel point to which the target normal belongs is to the peak. It can be seen that the weight coefficient is positively correlated with the vertical component of the target normal, and the vertical component of the target normal is the length of the projection of the target normal in the vertical direction.
[0156] From the above content, it can be seen that by acquiring the target pixel points in the water boundary area of the water model in the virtual scene, the target normal of the wave formed by the above target pixel points in the above water boundary area is calculated based on the motion control information of the pixel points, and the light intensity of the above target pixel points is determined based on the above target normal and the shooting direction of the virtual camera in the above virtual scene, and then the light and shadow effects are rendered for the above target pixel points based on the above light intensity to visually show an uneven effect, so as to realize the formation of a wave effect in the above water boundary area, so that the wave effect can be formed in the water area by only rendering the light and shadow effects on the pixels, thereby reducing the resources consumed in forming the wave effect in the water area.
[0157] This embodiment also provides a rendering device, which can be integrated into a terminal device. Fig.10 As shown, the rendering device may include:
[0158] The pixel point acquisition module 1001 is used to acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary area of the water area model, and the water area boundary area is adjacent to a land model in the virtual scene;
[0159] A normal determination module 1002 is used to calculate a target normal of the target pixel on the wave formed by the target pixel in the water boundary area based on the motion control information of the pixel;
[0160] An illumination determination module 1003 is used to determine the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene;
[0161] The rendering module 1004 is used to render light and shadow effects on the target pixel points based on the light intensity to form a wave effect in the water boundary area.
[0162] In some embodiments, the pixel acquisition module 1001 is specifically used for:
[0163] Obtaining a pixel distance of each pixel point in the water model, where the pixel distance is used to indicate the distance between the pixel point and the land model;
[0164] Based on the pixel distances of the above pixel points, a target pixel point located in the above water area boundary area is determined.
[0165] In some embodiments, the pixel acquisition module 1001 is specifically used for:
[0166] Obtaining a signed distance field map corresponding to the virtual scene, where the signed distance field map is used to indicate the distance between a pixel point in the virtual scene and the land model;
[0167] Determine the sampling coordinates of each pixel point in the water area model in the signed distance field map;
[0168] Based on the sampling coordinates of each pixel point, the signed distance field map is sampled to obtain the pixel distance of each pixel point.
[0169] In some embodiments, the pixel acquisition module 1001 is specifically used for:
[0170] The virtual scene is photographed by a preset orthogonal camera facing the land model to obtain a depth map;
[0171] Binarizing the depth map to obtain a binarized depth map, wherein the two values in the binarized depth map respectively indicate that the pixel point belongs to a land model area or a non-land model area;
[0172] Based on the binarized depth map, the distance and direction between each pixel in the virtual scene and the boundary between the land model area and the non-land model area are calculated to generate a directed distance field map corresponding to the virtual scene.
[0173] In some embodiments, the pixel acquisition module 1001 is specifically used for:
[0174] Get the baking range of the above-mentioned signed distance field map in world space;
[0175] Obtain the pixel coordinates of each pixel in the water area model in the world space;
[0176] Based on the relative positions of the pixel coordinates of the pixels in the baking range, the sampling coordinates of the pixels in the signed distance field map are determined.
[0177] In some embodiments, the normal determination module 1002 is specifically used to:
[0178] Based on the motion control information, determine a pixel tangent of the target pixel point on the wave in a two-dimensional space;
[0179] Determine a two-dimensional pixel normal line perpendicular to the pixel tangent line of the target pixel point in the two-dimensional space;
[0180] The two-dimensional pixel normal of the target pixel point is converted into a target normal in three-dimensional space.
[0181] In some embodiments, the motion control information includes a waveform function; the normal determination module 1002 is specifically used for:
[0182] Determine the variable parameters of the waveform function based on the current moment and the pixel distance of the target pixel at the current moment;
[0183] The variable parameters are processed based on the waveform function to obtain the pixel tangent of the target pixel point on the wave in two-dimensional space.
[0184] In some embodiments, the normal determination module 1002 is specifically used to:
[0185] Determine a first variable value of the waveform function based on the current moment and the frequency information corresponding to the waveform function;
[0186] Determine a second variable value of the waveform function according to the pixel distance of the target pixel at the current moment and a phase coefficient corresponding to the waveform function;
[0187] The sum of the first variable value and the second variable value is used as the variable parameter of the waveform function.
[0188] In some embodiments, the normal determination module 1002 is specifically used to:
[0189] Obtaining a horizontal projection coefficient of the two-dimensional pixel normal on the horizontal plane of the water area model and a vertical projection coefficient in the vertical direction of the horizontal plane;
[0190] Based on the horizontal projection coefficient and the vertical projection coefficient, the target normal is determined.
[0191] In some embodiments, the rendering device further includes a normal updating module, and the normal updating module is specifically used to:
[0192] Obtaining a region normal of a water area adjacent to the water area boundary area in the water area model;
[0193] Performing interpolation processing on the above-mentioned regional normal and the target normal of the above-mentioned target pixel point to obtain an interpolation result of the above-mentioned target pixel point;
[0194] Based on the interpolation result, the target normal of the target pixel is updated.
[0195] In some embodiments, the normal update module is specifically used to:
[0196] Obtain the vertical normal component of the target normal in the vertical direction;
[0197] Through a smooth transition function, based on the vertical normal component, a value is taken in a preset coefficient value range to obtain a target weight coefficient corresponding to the target normal, and the two end points of the preset coefficient value range are the weight coefficient corresponding to the normal at the crest of the wave and the weight coefficient corresponding to the normal at the trough of the wave, respectively.
[0198] Based on the target weight coefficient, the region normal and the target normal of the target pixel are interpolated to obtain an interpolation result of the target pixel.
[0199] From the above content, it can be seen that by acquiring the target pixel points in the water boundary area of the water model in the virtual scene, the target normal of the wave formed by the above target pixel points in the above water boundary area is calculated based on the motion control information of the pixel points, and the light intensity of the above target pixel points is determined based on the above target normal and the shooting direction of the virtual camera in the above virtual scene, and then the light and shadow effects are rendered for the above target pixel points based on the above light intensity to visually show an uneven effect, so as to realize the formation of a wave effect in the above water boundary area, so that the wave effect can be formed in the water area by only rendering the light and shadow effects on the pixels, thereby reducing the resources consumed in forming the wave effect in the water area.
[0200] Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
[0201] like Fig.11 As shown, Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1100 includes a processor 1101 having one or more processing cores, a memory 1102 having one or more computer-readable storage media, and a computer program stored in the memory 1102 and executable on the processor. The processor 1101 is electrically connected to the memory 1102. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0202] The processor 1101 is the control center of the electronic device 1100, and uses various interfaces and lines to connect various parts of the entire electronic device 1100. By running or loading software programs and / or units stored in the memory 1102, and calling data stored in the memory 1102, the processor 1101 executes various functions of the electronic device 1100 and processes data, thereby monitoring the electronic device 1100 as a whole. The processor 1101 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
[0203] In the embodiment of the present application, the processor 1101 in the electronic device 1100 will load instructions corresponding to the processes of one or more application programs into the memory 1102 according to the following steps, and the processor 1101 will run the application programs stored in the memory 1102 to implement various functions, such as:
[0204] Acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary region of the water area model, and the water area boundary region is adjacent to a land model in the virtual scene;
[0205] Based on the motion control information for the pixel point, a target normal line of the target pixel point on the wave formed in the boundary area of the water area is calculated;
[0206] Determining the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene;
[0207] A light and shadow effect is rendered for the target pixel point based on the light intensity to form a wave effect in the water boundary area.
[0208] Therefore, the electronic device 1100 provided in this embodiment can bring the following technical effects: reducing the resources consumed when forming wave effects in water areas.
[0209] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0210] Optional, such as Fig.11 As shown, the electronic device 1100 further includes: a touch screen 1103, a radio frequency circuit 1104, an audio circuit 1105, an input unit 1106, and a power supply 1107. The processor 1101 is electrically connected to the touch screen 1103, the radio frequency circuit 1104, the audio circuit 1105, the input unit 1106, and the power supply 1107, respectively. Those skilled in the art can understand that Fig.11The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0211] The touch display screen 1103 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 1103 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-EmittingDiode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1101, and can receive the command sent by the processor 1101 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 1101 to determine the type of touch event, and then the processor 1101 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 1103 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 1103 can also be used as a part of the input unit 1106 to realize the input function.
[0212] The radio frequency circuit 1104 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals between the network device or other electronic devices.
[0213] The audio circuit 1105 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 1105 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 1105 and converted into audio data, and then the audio data is output to the processor 1101 for processing, and then sent to another electronic device through the radio frequency circuit 1104, or the audio data is output to the memory 1102 for further processing. The audio circuit 1105 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0214] The input unit 1106 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0215] The power supply 1107 is used to supply power to various components of the electronic device 1100. Optionally, the power supply 1107 can be logically connected to the processor 1101 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 1107 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0216] although Fig.11 Not shown, the electronic device 1100 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0217] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0218] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0219] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any rendering method provided in the embodiment of the present application. The computer program can execute the following steps of the rendering method:
[0220] Acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary region of the water area model, and the water area boundary region is adjacent to a land model in the virtual scene;
[0221] Based on the motion control information for the pixel point, a target normal line of the target pixel point on the wave formed in the boundary area of the water area is calculated;
[0222] Determining the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene;
[0223] A light and shadow effect is rendered for the target pixel point based on the light intensity to form a wave effect in the water boundary area.
[0224] It can be seen that the computer program can be loaded by the processor to execute any rendering method provided in the embodiments of the present application, thereby bringing about the following technical effects: reducing the resources consumed in forming wave effects in the water area.
[0225] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0226] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0227] Since the computer program stored in the computer-readable storage medium can execute any rendering method provided in the embodiments of the present application, the beneficial effects that can be achieved by any rendering method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0228] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0229] In the above rendering device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described rendering device, computer-readable storage medium, computer program product, electronic device, and corresponding units can refer to the description of the rendering method in the above embodiment, and will not be repeated here.
[0230] The above is a detailed introduction to a rendering method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A rendering method, characterized in that: The method comprises: Acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is in a water area boundary region of the water area model, and the water area boundary region is adjacent to a land model in the virtual scene; Based on the motion control information for the pixel point, a target normal line of the target pixel point on the wave formed in the boundary area of the water area is calculated; Determining the illumination intensity of the target pixel based on the target normal and the shooting direction of the virtual camera in the virtual scene; A light and shadow effect is rendered on the target pixel point based on the light intensity to form a wave effect in the water boundary area.
2. The rendering method according to claim 1, characterized in that: The step of obtaining target pixel points of the water area model in the virtual scene includes: Obtaining a pixel distance of each pixel point in the water model, where the pixel distance is used to indicate the distance between the pixel point and the land model; Based on the pixel distances of the pixels, a target pixel point in the water area boundary area is determined.
3. The rendering method according to claim 2, characterized in that: The obtaining of the pixel distance of each pixel point in the water area model comprises: Acquire a signed distance field map corresponding to the virtual scene, wherein the signed distance field map is used to indicate the distance between a pixel point in the virtual scene and the land model; Determine the sampling coordinates of each pixel point in the water area model in the signed distance field map; The signed distance field map is sampled based on the sampling coordinates of each pixel point to obtain a pixel distance of each pixel point.
4. The rendering method according to claim 3, characterized in that: The obtaining of a directed distance field map corresponding to the virtual scene includes: The virtual scene is photographed by a preset orthogonal camera in a direction facing the land model to obtain a depth map; Binarizing the depth map to obtain a binarized depth map, wherein two values in the binarized depth map respectively indicate that the pixel point belongs to a land model area or a non-land model area; Based on the binarized depth map, the distance and direction between each pixel point in the virtual scene and the boundary between the land model area and the non-land model area are calculated to generate a directed distance field map corresponding to the virtual scene.
5. The rendering method according to claim 3, characterized in that: The step of determining the sampling coordinates of each pixel point in the water area model in the directed distance field map comprises: Obtaining a baking range of the signed distance field map in world space; Obtaining pixel coordinates of each pixel in the water area model in world space; Based on the relative positions of the pixel coordinates of each pixel in the baking range, sampling coordinates of each pixel in the signed distance field map are determined.
6. The rendering method according to claim 1, characterized in that: The step of calculating a target normal of a wave formed by the target pixel point on the boundary area of the water area based on the motion control information of the pixel point comprises: Based on the motion control information, determining a pixel tangent of the target pixel point on the wave in a two-dimensional space; Determine a two-dimensional pixel normal that is perpendicular to the pixel tangent of the target pixel point in the two-dimensional space; The two-dimensional pixel normal of the target pixel point is converted into a target normal in three-dimensional space.
7. The rendering method according to claim 6, characterized in that: The motion control information includes a waveform function; and determining a pixel tangent of the target pixel point on the wave in a two-dimensional space based on the motion control information includes: Determine the variable parameters of the waveform function based on the current moment and the pixel distance of the target pixel at the current moment; The variable parameters are processed based on the waveform function to obtain a pixel tangent of the target pixel point on the wave in a two-dimensional space.
8. The rendering method according to claim 7, characterized in that: The step of determining the variable parameters of the waveform function based on the current moment and the pixel distance of the target pixel at the current moment includes: Determine a first variable value of the waveform function based on the current moment and frequency information corresponding to the waveform function; Determine a second variable value of the waveform function according to the pixel distance of the target pixel point at the current moment and a phase coefficient corresponding to the waveform function; The sum of the first variable value and the second variable value is used as the variable parameter of the waveform function.
9. The rendering method according to claim 6, characterized in that: The converting the two-dimensional pixel normal of the target pixel point into a target normal in three-dimensional space includes: Obtaining a horizontal projection coefficient of the two-dimensional pixel normal on the horizontal plane of the water area model and a vertical projection coefficient in the vertical direction of the horizontal plane; The object normal is determined based on the horizontal projection coefficient and the vertical projection coefficient.
10. The rendering method according to any one of claims 1 to 9, characterized in that: After calculating the target normal of the target pixel point on the wave formed in the water boundary area, the method further includes: Acquire a region normal of a water area adjacent to the water area boundary area in the water area model; Performing interpolation processing on the region normal and the target normal of the target pixel point to obtain an interpolation result of the target pixel point; Based on the interpolation result, the target normal of the target pixel is updated.
11. The rendering method according to claim 10, characterized in that: The interpolating the region normal and the target normal of the target pixel point to obtain the interpolation result of the target pixel point includes: Obtaining the vertical normal component of the target normal in the vertical direction; By using a smooth transition function, based on the vertical normal component, a value is taken in a preset coefficient value interval to obtain a target weight coefficient corresponding to the target normal, wherein the two end points of the preset coefficient value interval are respectively the weight coefficient corresponding to the normal at the crest of the wave and the weight coefficient corresponding to the normal at the trough of the wave; Based on the target weight coefficient, the region normal and the target normal of the target pixel are interpolated to obtain an interpolation result of the target pixel.
12. A rendering device, characterized in that: The device comprises: A pixel point acquisition module, used to acquire a target pixel point of a water area model in a virtual scene, wherein the target pixel point is located in a water area boundary area of the water area model, and the water area boundary area is adjacent to a land model in the virtual scene; A normal determination module, configured to calculate a target normal of a wave formed by the target pixel point on the boundary area of the water area based on motion control information for the pixel point; An illumination determination module, used to determine the illumination intensity of the target pixel point based on the target normal and the shooting direction of the virtual camera in the virtual scene; A rendering module is used to render light and shadow effects on the target pixel points based on the light intensity to form a wave effect in the water boundary area.
13. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the rendering method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the rendering method according to any one of claims 1 to 11.