Rendering method, rendering device, computer readable storage medium and electronic device
Patent Information
- Application Number
- CN202310095991.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-18
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2043-01-18
AI Technical Summary
[0003]然而,这种方法无法实现流体元素与面料模型表面结构的交互渲染,进而存在面料模型表面的流体元素渲染效果差的问题
[0009]本申请提供的渲染方法、渲染装置、计算机可读存储介质及电子设备,通过获取待渲染的虚拟面料模型,并确定虚拟面料模型的目标表面对应的目标二维纹理贴图和有向距离场信息,有向距离场信息包括目标二维纹理贴图的各个像素点在预设流动方向上到目标二维纹理贴图的边界的第一距离值,然后根据目标二维纹理贴图的纹理坐标对预设的流体碰撞效果贴图进行采样得到效果贴图采样结果,并根据效果贴图采样结果和有向距离场信息对流体触碰目标表面进行渲染,以得到虚拟面料模型表面的流体触边碰撞效果。从而,实现了对虚拟面料模型的表面流体元素与表面结构的交互渲染,进而提高了虚拟面料模型表面的流体元素渲染效果。
Smart Images

Figure CN116188656B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a rendering method, rendering apparatus, computer-readable storage medium, and electronic device. Background Technology
[0002] In game development, there is often a need to represent fluid elements (such as water ripples and waves) on fabric models. Currently, this is generally achieved by drawing textures on the surface of the fabric model that simulate fluid elements in nature.
[0003] However, this method cannot achieve interactive rendering of fluid elements and fabric model surface structure, resulting in poor rendering effect of fluid elements on the fabric model surface. Summary of the Invention
[0004] The purpose of this application is to provide a rendering method, rendering device, computer-readable storage medium and electronic device to realize interactive rendering of surface fluid elements and surface structure of fabric model, thereby improving the rendering effect of fluid elements on the surface of fabric model.
[0005] This application provides a rendering method, including: Obtain the virtual fabric model to be rendered; Determine the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in the preset flow direction. The preset fluid collision effect map is sampled based on the texture coordinates of the target 2D texture map to obtain the effect map sampling result; The fluid touches the target surface and is rendered based on the effect texture sampling results and directional distance field information to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0006] This application embodiment also provides a rendering apparatus, including: The acquisition module is used to acquire the virtual fabric model to be rendered; The determination module is used to determine the target two-dimensional texture map and the directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in the preset flow direction. The sampling module is used to sample the preset fluid collision effect map based on the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result; The rendering module is used to render the fluid touching the target surface based on the effect texture sampling results and directional distance field information, so as to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0007] This application also provides a computer-readable storage medium storing a computer program adapted for loading by a processor to execute the above-described rendering method.
[0008] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the above-described rendering method by calling the computer program stored in the memory.
[0009] The rendering method, rendering apparatus, computer-readable storage medium, and electronic device provided in this application acquire a virtual fabric model to be rendered and determine the target 2D texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target 2D texture map from the boundary of the target 2D texture map in a preset flow direction. Then, a preset fluid collision effect map is sampled according to the texture coordinates of the target 2D texture map to obtain the effect map sampling result. The fluid touching the target surface is rendered according to the effect map sampling result and the directed distance field information to obtain the fluid edge collision effect on the surface of the virtual fabric model. Thus, interactive rendering of the surface fluid elements and surface structure of the virtual fabric model is realized, thereby improving the rendering effect of the fluid elements on the surface of the virtual fabric model. Attached Figure Description
[0010] The technical solution and other beneficial effects of this application will become apparent from the following detailed description of specific embodiments in conjunction with the accompanying drawings.
[0011] Figure 1 This is a scene diagram of the rendering system provided in the embodiments of this application; Figure 2 This is a flowchart illustrating the rendering method provided in an embodiment of this application; Figure 3 This is another flowchart illustrating the rendering method provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the unfolded diagram obtained by unfolding each surface of the virtual fabric model according to the texture coordinates, as provided in the embodiments of this application. Figure 5 This is a schematic diagram of the structure of the two-dimensional texture map provided in the embodiments of this application; Figure 6 This is a schematic diagram of the structure of the mask image provided in the embodiments of this application; Figure 7This is a schematic diagram of the structure of the caustic texture map provided in the embodiments of this application; Figure 8 This is a schematic diagram of the structure of the virtual fabric model provided in the embodiments of this application; Figure 9 This is a schematic diagram showing the effect of mapping the first grayscale image provided in this application embodiment onto the virtual fabric model; Figure 10 This is a schematic diagram illustrating the effect of mapping the second grayscale image provided in this application embodiment onto a virtual fabric model; Figure 11 This is a schematic diagram of the effect after the preset fluid collision effect texture provided in this application embodiment is mapped onto the virtual fabric model; Figure 12 This is a schematic diagram of the structure of a virtual fabric model with a fluid contact edge collision effect on the surface, provided in an embodiment of this application; Figure 13 This is a schematic diagram of the rendering apparatus provided in the embodiments of this application; Figure 14 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0013] Please see Figure 1 , Figure 1 This is a scene diagram of the rendering system provided in the embodiments of this application. The rendering system may include any of the rendering devices provided in the embodiments of this application. The rendering device may be integrated into electronic devices such as terminals or servers. The terminal may be a smartphone, tablet computer, smart Bluetooth device, laptop computer, or personal computer (PC). The server may be a single server or a server cluster composed of multiple servers.
[0014] The electronic device can acquire a virtual fabric model to be rendered; determine the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model, the directed distance field information including the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in a preset flow direction; sample a preset fluid collision effect map according to the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result; and render the fluid touching the target surface according to the effect map sampling result and the directed distance field information to obtain the fluid touch edge collision effect on the surface of the virtual fabric model.
[0015] The virtual fabric model can be created using pre-defined material creation tools (such as 3D Max, Maya, and other existing mature 3D animation rendering and production software). The virtual fabric model can include multiple surfaces. The target surface can be the surface of the virtual fabric model that requires fluid edge collision effect rendering. In one example, the virtual fabric model can be a clothing model or a home textile model, or other virtual model with fabric materials. The target 2D texture map can be the unfolded texture map obtained by unfolding the texture map of the target surface. The preset flow direction can be the flow direction of the fluid on the rendered target surface after applying the fluid edge collision effect rendering. In one example, the fluid can be water (e.g., water ripples, waves), and the preset flow direction can be from top to bottom. The preset fluid collision effect map can be a map used to simulate fluid edge collision effects. In one example, the preset fluid collision effect map can be a mesh map used to simulate shoreline waves.
[0016] Specifically, such as Figure 1As shown, the aforementioned electronic device can be configured with a preset model rendering tool (such as Unreal Engine 4, Maya, Unity3D, etc.). This model rendering tool can be used to create fluid edge collision effects on the surface of the aforementioned virtual fabric model, and the aforementioned material creation tool can be installed on the electronic device. When a user wants to create a fluid edge collision effect on the surface of a certain virtual fabric model, the aforementioned electronic device can be triggered to retrieve the virtual fabric model from the local machine or the cloud to obtain the virtual fabric model to be rendered. Then, the aforementioned electronic device can determine the target 2D texture map corresponding to the target surface of the virtual fabric model, and determine the directed distance field information corresponding to the target surface based on the target 2D texture map. Next, the aforementioned electronic device can sample the preset fluid collision effect map based on the texture coordinates of the target 2D texture map to obtain the effect map sampling result, and render the fluid touching the target surface based on the effect map sampling result and the directed distance field information to obtain the fluid edge collision effect on the surface of the aforementioned virtual fabric model, thereby realizing the interactive rendering of fluid elements and boundaries on the surface of the aforementioned virtual fabric model.
[0017] like Figure 2 As shown, Figure 2 This is a flowchart illustrating the rendering method provided in an embodiment of this application. The specific flow of the rendering method is as follows: S101. Obtain the virtual fabric model to be rendered.
[0018] Rendering refers to the visual processing of models during game development. For example, by setting relevant parameters such as the model's lighting, materials, textures, colors, and environment, the model's appearance in a three-dimensional environment can be achieved.
[0019] The aforementioned virtual fabric model can be created using pre-defined material creation tools (such as 3D Max, Maya, and other existing mature 3D animation rendering and production software). In one example, the virtual fabric model can be a clothing model or a home textile model, or a virtual model with fabric materials.
[0020] S102. Determine the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in the preset flow direction.
[0021] Specifically, the virtual fabric model can include multiple surfaces, and different surfaces can exhibit different visual effects. The target surface can be the surface of the virtual fabric model that needs to undergo fluid edge collision effect rendering, and the target surface can be part or all of the surface of the virtual fabric model. The target 2D texture map can include the texture coordinates of each vertex in the target surface. In one example, the target 2D texture map can be the unfolded texture map obtained by unfolding the texture map of the target surface. The preset flow direction can be the flow direction of the fluid on the rendered target surface after the fluid edge collision effect is applied to the target surface of the virtual fabric model, and can determine which boundary of the target surface the fluid on the target surface collides with in the fluid edge collision effect. In one example, the preset flow direction can be from top to bottom, corresponding to the simulation of the fluid on the target surface colliding with the lower boundary of the target surface in the fluid edge collision effect.
[0022] Specifically, the aforementioned directed distance field information can be a directed distance field map, which can be a grayscale image. Each pixel of the target two-dimensional texture map can correspond one-to-one with each pixel of the directed distance field map. Furthermore, the first distance value from each pixel of the target two-dimensional texture map to its boundary in a preset flow direction can be represented by the grayscale value of the corresponding pixel in the directed distance field map. In one example, the first distance value from each pixel of the target two-dimensional texture map to its boundary in the preset flow direction can correspond to the grayscale value of each pixel in the directed distance field map.
[0023] In some embodiments, such as Figure 3 As shown, the above S102 can specifically include: S1021. Unfold the target surface of the virtual fabric model according to the texture coordinates to obtain a texture coordinate map.
[0024] Specifically, the rendering device can unfold the target surface of the virtual fabric model according to texture coordinates to obtain a texture coordinate map, and place the texture coordinate map in a preset texture coordinate space in the texture coordinate plane. In one example, the preset texture coordinate space can be a (0, 1) space, corresponding to the u coordinate in the texture coordinate of the texture coordinate map having a value range of (0, 1), and the v coordinate also having a value range of (0, 1).
[0025] In some embodiments, the number of target surfaces can be one or more. Furthermore, in embodiments where the number of target surfaces is multiple, the rendering apparatus can unfold the multiple target surfaces according to texture coordinates to obtain corresponding multiple texture coordinate maps, and can place these multiple texture coordinate maps within the preset texture coordinate space.
[0026] S1022. Adjust the texture coordinates of the texture coordinate map to obtain the target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape.
[0027] Specifically, for virtual fabric models with complex surface topography, such as virtual fabric models with irregular (e.g., curved) surface boundaries (e.g., clothing models), to ensure that the surface texture of the virtual fabric model shifts according to its surface topography when performing texture offset, after obtaining the texture coordinate map, the rendering device can straighten the boundaries of the texture coordinate grid of the texture coordinate map to make the boundaries of the texture coordinate map straight lines. In some embodiments, the adjustment process may further include adjusting the density distribution of the texture coordinate grid of the texture coordinate map; that is, the rendering device may also adjust the density distribution of the texture coordinate grid of the texture coordinate map to reduce the stretching of the texture coordinates of the texture coordinate map.
[0028] In some specific embodiments, the target two-dimensional texture map can be rectangular, that is, the target two-dimensional texture map can have four straight-line boundaries. Specifically, the target two-dimensional texture map can be placed horizontally and vertically within the preset texture coordinate space, that is, the two boundaries connecting the target two-dimensional texture map can be parallel to the u-axis and v-axis of the texture coordinate system, respectively, to ensure that the texture coordinates of the target two-dimensional texture map can be offset according to the shape of the target surface of the virtual fabric model, thereby avoiding distortion when the texture map is mapped to the target surface.
[0029] S1023. Determine the directional distance field information corresponding to the target surface based on the target 2D texture map.
[0030] In one specific embodiment, S1023 may specifically include: S1-1. Generate a mask image including the target 2D texture map, wherein the second pixel value of each pixel of the target 2D texture map in the mask image is a preset pixel value.
[0031] Specifically, in the aforementioned mask image, the second pixel value of the pixel corresponding to the target 2D texture map can be a first preset pixel value, and the second pixel value of the pixel corresponding to the image other than the target 2D texture map can be a second preset pixel value. In one example, each pixel of the target 2D texture map in the aforementioned mask image can be a white pixel, and all pixels of the image other than the target 2D texture map in the aforementioned mask image can be black pixels. Here, the pixel value of a white pixel can be represented by 1, and the pixel value of a black pixel can be represented by 0; that is, the first preset pixel value can be 1, and the second preset pixel value can be 0.
[0032] S1-2. According to the preset flow direction, the second pixel value of each pixel point of the target two-dimensional texture map in the mask image is gradually changed to obtain the directional distance field information corresponding to the target surface.
[0033] Specifically, the gradient-processed pixel values obtained by applying a gradient processing method to the second pixel values of each pixel in the target 2D texture map in the aforementioned mask image can be consistent with the first distance value of each pixel in the target 2D texture map from the boundary of the target 2D texture map in the aforementioned preset flow direction. Furthermore, the gradient-processed pixel values of each pixel in the target 2D texture map in the aforementioned mask image can gradually increase or gradually decrease along the aforementioned preset flow direction.
[0034] In the embodiment where white pixels are represented by 1 and black pixels by 0, and the first preset pixel value is 1, the range of pixel values after gradient processing for each pixel of the target two-dimensional texture map in the mask image can be 0 to 1. That is, the pixel values after gradient processing for each pixel of the target two-dimensional texture map in the mask image can be obtained by gradient-changing the second pixel value of each pixel of the target two-dimensional texture map in the mask image from 0 to 1. Correspondingly, the directional distance field information can be a grayscale image where the brightness gradually changes from highest to lowest along the preset flow direction, or it can be a grayscale image where the brightness gradually changes from lowest to highest along the preset flow direction.
[0035] In a specific application scenario, in order to obtain the target 2D texture map corresponding to the target surface of the aforementioned virtual fabric model, such as... Figure 4As shown, the rendering device can divide the surface of the virtual fabric model into multiple surface regions based on the orientation of the virtual fabric model, and unfold each surface region of the virtual fabric model according to texture mapping coordinates to obtain corresponding unfolded images 21A / 21B. Then, the rendering device can arrange all the obtained unfolded images 21A / 21B at uniform intervals in the preset texture coordinate space according to the orientation order of each surface region on the virtual fabric model from top to bottom. Accordingly, the target surface of the virtual fabric model can be specifically one of the multiple surface regions of the virtual fabric model.
[0036] Next, as Figure 4 and Figure 5 As shown, the rendering apparatus can adjust the texture coordinates of the unfolded map (i.e., the texture coordinate map) 21A corresponding to the target surface to obtain a two-dimensional texture map including the target two-dimensional texture map 22A. Then, in order to obtain the directed distance field information corresponding to the target surface of the virtual fabric model, the rendering apparatus can, based on the two-dimensional texture map obtained in the previous step (such as...), adjust the texture coordinates of the unfolded map (i.e., the texture coordinate map) 21A corresponding to the target surface to obtain the target surface of the virtual fabric model. Figure 5 Baking the above mask image (as shown) Figure 6 As shown), the target two-dimensional texture map 23A in the above mask map is gradually filled with gray values from the minimum gray value (e.g., 0) to the maximum gray value (e.g., 1) along the preset flow direction (e.g., from top to bottom), or gradually filled with gray values from the maximum gray value to the minimum gray value along the preset flow direction, so as to obtain the directional distance field information corresponding to the target surface.
[0037] S103. Sample the preset fluid collision effect map according to the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result.
[0038] Among them, such as Figure 3 As shown, the above S103 can specifically include: S1031. Offset the texture coordinates of the target two-dimensional texture map according to the preset offset parameters to obtain the offset texture coordinates.
[0039] Specifically, the aforementioned preset offset parameters may include the u-coordinate offset and the v-coordinate deflection. In one example, if (u, v) represents the texture coordinates, then the offset texture coordinates can be represented as (u+d11, v+d12), where d11 is the u-coordinate offset and d12 is the v-coordinate offset.
[0040] In some embodiments, before S1031, S103 may further include: scaling the texture coordinates of the target two-dimensional texture map according to a preset scaling parameter to obtain scaled texture coordinates. Accordingly, S1031 may specifically include: offsetting the scaled texture coordinates according to a preset offset parameter to obtain offset texture coordinates.
[0041] Specifically, the aforementioned preset scaling parameters may include the scaling amount for the u-coordinate and the scaling amount for the v-coordinate. In one example, where (u, v) represents the texture coordinates, the scaled texture coordinates can be represented as (u... d21, v d21), where d21 is the scaling factor for the u coordinate and d22 is the scaling factor for the v coordinate. Correspondingly, the offset texture coordinates obtained by offsetting the scaled texture coordinates according to the aforementioned preset offset parameters can be represented as (u... d21+d11, v (d22+d12). This allows designers to control the size of the preset fluid collision effect map when it is mapped onto the target surface in subsequent steps by adjusting the preset scaling parameters mentioned above.
[0042] In some embodiments, to ensure that the texture fits the target surface of the virtual fabric model better when it is offset, S1031 may specifically include: offsetting the texture coordinates of the target two-dimensional texture map according to a preset offset parameter and the normal vector of the target surface to obtain the offset texture coordinates. Specifically, the u-coordinate of the offset texture coordinates can be obtained by adding the u-coordinate offset and the x-component of the normal vector of the target surface to the u-coordinate of the texture coordinates, and the v-coordinate of the offset texture coordinates can be obtained by adding the v-coordinate offset and the y-component of the normal vector of the target surface to the v-coordinate of the texture coordinates, so that the texture is affected by the model normal when it is offset on the target surface, thereby making the texture of the target surface fit the model surface structure better.
[0043] Accordingly, in the embodiment where the texture coordinates of the target two-dimensional texture map are scaled before offsetting them, S1031 may specifically include: offsetting the scaled texture coordinates according to a preset offset parameter and the normal vector of the target surface to obtain the offset texture coordinates. Specifically, denoted as (u, v), the offset texture coordinates can be represented as (u... d21+d11+x1, v d22+d12+y2), where x1 is the x-component of the normal vector of the target surface and y1 is the y-component of the normal vector of the target surface.
[0044] S1032. Sample the preset fluid collision effect map according to the offset texture coordinates to obtain the effect map sampling result.
[0045] Specifically, the aforementioned preset fluid collision effect texture can be a texture used to simulate the effect of fluid touching the edge and colliding. In one example, the aforementioned preset fluid collision effect texture can be a mesh texture used to simulate waves on the shore, for example... Figure 7 The image shows a caustic texture map. This caustic texture map is a mesh map used to simulate underwater caustics, and it can be created by designers using the Perlin Noise and Blur HQ Grayscale nodes in the Material Designer software, based on the rendering requirements of fluid contact and collision effects.
[0046] S104. Render the fluid touching the target surface based on the effect texture sampling results and the directional distance field information to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0047] In the above embodiments, the rendering method may further include: S105. Update the preset offset parameters at preset intervals to obtain the updated offset parameters.
[0048] Accordingly, S1031 can specifically include: offsetting the texture coordinates of the target 2D texture map according to the updated offset parameters to obtain the offset texture coordinates. Furthermore, after offsetting the texture coordinates of the target 2D texture map according to the updated offset parameters to obtain the offset texture coordinates, the rendering device can re-execute S1032 and S104 to re-render the fluid touching the target surface every preset time interval based on the effect map sampling results and the directional distance field information, thereby achieving the fluid flow effect on the target surface.
[0049] Specifically, the preset time can be set according to actual needs, such as 1 second or 500 milliseconds. The update of the offset parameter can be random or it can be updated regularly in ascending order of offset value, etc.
[0050] In some embodiments, such as Figure 3 As shown, the above S104 can specifically include: S1041. Map the first distance value of each pixel of the target two-dimensional texture map to the corresponding second distance value to obtain the remapped directed distance field information. The remapped directed distance field information includes the second distance value corresponding to each pixel of the target two-dimensional texture map, and the difference between the second distance values corresponding to each pixel of the target two-dimensional texture map is greater than the difference between the first distance values of each pixel of the target two-dimensional texture map.
[0051] Specifically, the aforementioned directed distance field information can be a first grayscale image, and each pixel of the aforementioned target two-dimensional texture map can correspond one-to-one with each pixel of the first grayscale image. Furthermore, the first distance value of each pixel in the aforementioned target two-dimensional texture map to the boundary of the aforementioned target two-dimensional texture map in a preset flow direction can be the grayscale value of the corresponding pixel in the first grayscale image. The degree of difference between the first distance values of each pixel in the aforementioned target two-dimensional texture map can include the contrast between each pixel in the first grayscale image.
[0052] Accordingly, the remapped directed distance field information can be a second grayscale image, and each pixel of the target 2D texture map can correspond one-to-one with each pixel of the second grayscale image. Furthermore, the second distance value corresponding to each pixel in the target 2D texture map can be the grayscale value of the corresponding pixel in the second grayscale image. The degree of difference between the second distance values corresponding to each pixel in the target 2D texture map can be the contrast between each pixel in the second grayscale image. The degree of difference between the second distance values corresponding to each pixel in the target 2D texture map is greater than the degree of difference between the first distance values of each pixel in the target 2D texture map; that is, the contrast between each pixel in the second grayscale image is greater than the contrast between each pixel in the first grayscale image.
[0053] In one specific embodiment, the rendering device can map the first distance value of each pixel in the target two-dimensional texture map to a corresponding second distance value using a preset smoothing algorithm, thereby obtaining the remapped directed distance field information. The preset smoothing algorithm can be as follows: y=clamp((x-min) / (max-min), 0, 1); Final1=y y (3-2 y); In this context, `min` is the preset minimum value parameter, `max` is the preset maximum value parameter, and `min` is less than `max` and less than 1. `x` is the first distance value, and its value can range from 0 to 1. The `clamp()` function is used to restrict `(x-min) / (max-min)` to between 0 and 1. If `(x-min) / (max-min)` is between 0 and 1, `clamp()` will return `(x-min) / (max-min)`; if `(x-min) / (max-min)` is greater than 1, `clamp()` will return 1; if `(x-min) / (max-min)` is less than 0, `clamp()` will return 0. `y` is an intermediate variable with no actual physical meaning, and `Final1` is the second distance value. Specifically, `min` and `max` can be determined by the designer based on the rendering requirements of the fluid edge collision effect. In one example, `min` and `max` can be 0 and 0.5, respectively.
[0054] Furthermore, it should be noted that in this embodiment, the purpose of mapping the first distance value of each pixel in the target two-dimensional texture map included in the above-mentioned directed distance field information to the corresponding second distance value to obtain the above-mentioned remapped directed distance field information is to increase the difference in directed distance values between pixels in the above-mentioned target two-dimensional texture map that are close to the fluid collision boundary and those that are far from the fluid collision boundary. The fluid collision boundary is the boundary in the above-mentioned target two-dimensional texture map that can interact with the fluid, and it can be determined by the above-mentioned preset flow direction. In one example, the fluid can be water (e.g., water waves, spray, etc.), and the above-mentioned preset flow direction can be from top to bottom. Then, the above-mentioned fluid collision boundary can be the lower boundary of the above-mentioned target two-dimensional texture map.
[0055] In the embodiment where the directed distance field information and the remapped directed distance field information are respectively the first grayscale image and the second grayscale image, the virtual fabric model is used as an example. Figure 8 Taking the clothing model shown as an example, the first rendered virtual fabric model obtained after mapping the first grayscale image to the virtual fabric model can be as follows: Figure 9 As shown, the second rendered virtual fabric model obtained after mapping the first grayscale image to the virtual fabric model can be as follows: Figure 10 As shown. Furthermore, a comparison reveals that the relative darkness of a darker surface area in the first rendered virtual fabric model is less than its relative darkness in the second rendered virtual fabric model, and the relative brightness of a brighter surface area in the first rendered virtual fabric model is less than its relative brightness in the second rendered virtual fabric model.
[0056] S1042. Render the fluid touching the target surface based on the remapped directional distance field information and effect texture sampling results to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0057] It should be noted that, compared to related technologies that perform fluid rendering on the surface of a virtual fabric model based on effect map sampling results, such as... Figure 11 As shown, because the fluid flows across the surface of the virtual fabric model without interacting with its boundaries, the fluid rendering effect is poor. In this embodiment, fluid rendering is performed on the target surface of the virtual fabric model by combining effect map sampling results and directional distance field information. Figure 12 As shown, it can realize the interactive rendering of the fluid on the surface of the virtual fabric model and the boundary of the virtual fabric model, thereby improving the fluid rendering effect on the surface of the virtual fabric model.
[0058] In one specific embodiment, the above-mentioned effect texture sampling result may include the first pixel value corresponding to each pixel point of the target two-dimensional texture texture, and, as Figure 3 As shown, the above S1042 can specifically include: S2-1. Determine the target pixel value corresponding to each pixel of the target 2D texture map based on the first pixel value and the second distance value corresponding to each pixel of the target 2D texture map.
[0059] In some embodiments, in order to obtain the target pixel value corresponding to each pixel of the target two-dimensional texture map, the rendering device may perform a floor function on the sum of the first pixel value and the second distance value corresponding to each pixel of the target two-dimensional texture map to obtain the target pixel value corresponding to each pixel of the target two-dimensional texture map.
[0060] Specifically, the rendering device described above can use a preset algorithm to round down the sum of the first pixel value and the second distance value corresponding to each pixel of the target two-dimensional texture map, thereby obtaining the target pixel value corresponding to each pixel of the target two-dimensional texture map. The preset algorithm can be as follows: Final2 = floor((m+n) A); Where m is the first pixel value corresponding to each pixel of the target 2D texture map, and the value of m can be in the range of 0 to 1; n is the second distance value corresponding to each pixel of the target 2D texture map, and the value of n can be in the range of 0 to 1; A is a preset effect parameter value; floor() is a floor function used to round down to the nearest integer (m+n). The largest integer of A, where Final2 is the target pixel value corresponding to each pixel of the target 2D texture map. In one example, A can be 1.08.
[0061] Furthermore, it should be noted that the aforementioned preset effect parameter values can be used to control the size of the area affected by the final generated fluid edge collision effect on the target surface of the virtual fabric model. The larger the preset effect parameter value, the larger the area affected by the final generated fluid edge collision effect on the target surface of the virtual fabric model can be. In practice, the aforementioned preset effect parameter values can be set by the designer according to the desired rendering effect.
[0062] In other embodiments, to obtain the target pixel value corresponding to each pixel of the target two-dimensional texture map, the rendering device may further round down the sum of the first pixel value and the second distance value corresponding to each pixel of the target two-dimensional texture map and then scale it up or down according to a preset ratio to obtain the target pixel value corresponding to each pixel of the target two-dimensional texture map. The preset ratio can be used to control the brightness of the final generated fluid edge collision effect on the target surface of the virtual fabric model. The larger the preset ratio, the brighter the final generated fluid edge collision effect can be on the target surface of the virtual fabric model. Furthermore, in specific implementations, the preset ratio can be set by the designer according to the desired rendering effect.
[0063] In one specific embodiment, the fluid collision effect texture and the remapped oriented distance field information can both be grayscale images, and the grayscale values of the grayscale images can range from 0 to 1. A grayscale value of 1 indicates that the corresponding pixel is a white pixel, and a grayscale value of 0 indicates that the corresponding pixel is a black pixel. Accordingly, the first pixel value, the second distance value, and the target pixel value can all be grayscale values within the range of 0 to 1. Furthermore, it is understandable that, in the aforementioned target 2D texture map, the differences between the first pixel values corresponding to each pixel are relatively small, and the second distance value corresponding to pixels near the fluid collision boundary (e.g., the lower boundary) is 1 or close to 1, while the second distance value corresponding to pixels far from the fluid collision boundary is 0 or close to 0. Therefore, after using the floor function to round down the sum of the corresponding first pixel value and second distance value of each pixel in the aforementioned target 2D texture map, the target pixel value corresponding to the pixel near the fluid collision boundary with the larger corresponding first pixel value will be 1, i.e., a white pixel; the target pixel value corresponding to the pixel near the fluid collision boundary with the smaller corresponding first pixel value will be 0, i.e., a black pixel; and the target pixel value corresponding to the pixel far from the fluid collision boundary will be almost entirely 0, i.e., almost entirely a black pixel. Thus, the visual effect of fluid colliding with the fluid collision boundary can be represented.
[0064] S2-2. Render the fluid touching the target surface based on the target pixel value and the texture coordinates of the target 2D texture map to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0065] Specifically, the rendering device can map the target pixel values corresponding to each pixel of the target two-dimensional texture map onto the target surface of the virtual fabric model according to the texture coordinates of the target two-dimensional texture map, so as to obtain the fluid contact collision effect on the surface of the virtual fabric model (e.g., Figure 12 (As shown).
[0066] As can be seen from the above, the rendering method provided in this embodiment obtains the virtual fabric model to be rendered and determines the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map from the boundary of the target two-dimensional texture map in a preset flow direction. Then, based on the texture coordinates of the target two-dimensional texture map, a preset fluid collision effect map is sampled to obtain the effect map sampling result. Based on the effect map sampling result and the directed distance field information, the fluid touches the target surface to obtain the fluid touch collision effect on the surface of the virtual fabric model. Thus, interactive rendering of the surface fluid elements and surface structure of the virtual fabric model is realized, thereby improving the rendering effect of the fluid elements on the surface of the virtual fabric model.
[0067] Based on the methods described in the above embodiments, this embodiment will further describe the process from the perspective of the rendering device. Please refer to [link / reference]. Figure 13 , Figure 13 The rendering apparatus provided in this application embodiment is described in detail. The rendering apparatus includes: an acquisition module 301, a determination module 302, a sampling module 303, and a rendering module 304, wherein: (1) Acquisition module 301 The acquisition module 301 is used to acquire the virtual fabric model to be rendered.
[0068] (2) Determine module 302 The determination module 302 is used to determine the target two-dimensional texture map and the directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in a preset flow direction.
[0069] In one embodiment, the determining module 302 may include: The unfolding unit is used to unfold the target surface of the virtual fabric model according to the texture coordinates to obtain a texture coordinate map; An adjustment unit is used to adjust the texture coordinates of a texture coordinate map to obtain a target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape. The determination unit is used to determine the directional distance field information corresponding to the target surface based on the target 2D texture map.
[0070] In one specific embodiment, the determining unit described above can be specifically used for: Generate a mask image including the target 2D texture map, wherein the second pixel value of each pixel of the target 2D texture map in the mask image is a preset pixel value; The second pixel value of each pixel in the target 2D texture map in the mask image is gradually changed according to the preset flow direction to obtain the directional distance field information corresponding to the target surface.
[0071] (3) Sampling module 303 The sampling module 303 is used to sample the preset fluid collision effect map according to the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result.
[0072] In one embodiment, the sampling module 303 may include: Offset unit, used to offset the texture coordinates of the target 2D texture map according to preset offset parameters, to obtain the offset texture coordinates; The sampling unit is used to sample the preset fluid collision effect map based on the offset texture coordinates to obtain the effect map sampling result.
[0073] (4) Rendering module 304 The rendering module 304 is used to render the fluid touching the target surface based on the effect texture sampling results and the directional distance field information, so as to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0074] In one embodiment, the rendering module 304 may include: The mapping unit is used to map the first distance value of each pixel of the target two-dimensional texture map to the corresponding second distance value to obtain the remapped directed distance field information. The remapped directed distance field information includes the second distance value corresponding to each pixel of the target two-dimensional texture map, and the difference between the second distance values corresponding to each pixel of the target two-dimensional texture map is greater than the difference between the first distance values of each pixel of the target two-dimensional texture map. The rendering unit is used to render the fluid touching the target surface based on the remapped directional distance field information and the effect map sampling results, so as to obtain the fluid touching the collision effect on the surface of the virtual fabric model.
[0075] In one specific embodiment, the above-mentioned effect map sampling result may include the first pixel value corresponding to each pixel point of the target two-dimensional texture map, and the above-mentioned rendering unit may be specifically used for: Based on the first pixel value and the second distance value corresponding to each pixel of the target 2D texture map, determine the target pixel value corresponding to each pixel of the target 2D texture map; The fluid touches the target surface based on the target pixel value and the texture coordinates of the target 2D texture map to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0076] In the above embodiments, the rendering apparatus may further include: (5) Update module The update module is used to update the preset offset parameters at preset time intervals to obtain the updated offset parameters.
[0077] Accordingly, the aforementioned offset unit can be specifically used for: The texture coordinates of the target 2D texture map are offset according to the updated offset parameters to obtain the offset texture coordinates.
[0078] In some embodiments, the rendering apparatus may further include: (6) Scaling module The scaling module is used to scale the texture coordinates of the target 2D texture map according to preset scaling parameters to obtain scaled texture coordinates.
[0079] Accordingly, the aforementioned offset unit can be specifically used for: The scaled texture coordinates are offset based on preset offset parameters and the normal vector of the target surface to obtain the offset texture coordinates.
[0080] In practice, each of the above units and modules can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units and modules, please refer to the previous method implementation examples, which will not be repeated here.
[0081] As described above, the rendering apparatus provided in this embodiment includes an acquisition module for acquiring a virtual fabric model to be rendered; a determination module for determining the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model, wherein the directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in a preset flow direction; a sampling module for sampling a preset fluid collision effect map according to the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result; and a rendering module for rendering the fluid touching the target surface according to the effect map sampling result and the directed distance field information to obtain the fluid edge collision effect on the surface of the virtual fabric model. Thus, interactive rendering of the surface fluid elements and surface structure of the virtual fabric model is achieved, thereby improving the rendering effect of the fluid elements on the surface of the virtual fabric model.
[0082] Accordingly, this application also provides an electronic device, which can be a terminal or a server. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA), or other terminal device. Figure 14 As shown, Figure 14This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 400 includes a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 and the memory 402 are electrically connected. Those skilled in the art will understand 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, or combine certain components, or have different component arrangements.
[0083] The processor 401 is the control center of the electronic device 400. It connects various parts of the electronic device 400 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, it performs various functions of the electronic device 400 and processes data, thereby monitoring the electronic device 400 as a whole.
[0084] In this embodiment, the processor 401 in the electronic device 400 loads the instructions corresponding to the processes of one or more applications into the memory 402 according to the following steps, and the processor 401 runs the applications stored in the memory 402 to realize various functions: Obtain the virtual fabric model to be rendered; Determine the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in the preset flow direction. The preset fluid collision effect map is sampled based on the texture coordinates of the target 2D texture map to obtain the effect map sampling result; The fluid touches the target surface and is rendered based on the effect texture sampling results and directional distance field information to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0085] In one example, the fluid touching the target surface is rendered based on the effect map sampling results and directional distance field information to obtain the fluid edge collision effect on the surface of the virtual fabric model, including: The first distance value of each pixel of the target two-dimensional texture map is mapped to the corresponding second distance value to obtain the remapped directed distance field information. The remapped directed distance field information includes the second distance value corresponding to each pixel of the target two-dimensional texture map, and the difference between the second distance values corresponding to each pixel of the target two-dimensional texture map is greater than the difference between the first distance values of each pixel of the target two-dimensional texture map. The fluid touches the target surface and is rendered based on the remapped directional distance field information and effect map sampling results to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0086] In one example, the effect map sampling result includes the first pixel value corresponding to each pixel point of the target 2D texture map; the fluid touches the target surface and is rendered based on the remapped directed distance field information and the effect map sampling result to obtain the fluid touch-edge collision effect on the virtual fabric model surface, including: Based on the first pixel value and the second distance value corresponding to each pixel of the target 2D texture map, determine the target pixel value corresponding to each pixel of the target 2D texture map; The fluid touches the target surface based on the target pixel value and the texture coordinates of the target 2D texture map to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0087] In one example, the target 2D texture map and directed distance field information corresponding to the target surface are determined based on the target surface of the virtual fabric model, including: The target surface of the virtual fabric model is unfolded according to texture coordinates to obtain a texture coordinate map; The texture coordinates of the texture coordinate map are adjusted to obtain the target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape. The directional distance field information corresponding to the target surface is determined based on the target's two-dimensional texture map.
[0088] In one example, the directed distance field information corresponding to the target surface is determined based on the target 2D texture map, including: Generate a mask image including the target 2D texture map, wherein the second pixel value of each pixel of the target 2D texture map in the mask image is a preset pixel value; The second pixel value of each pixel in the target 2D texture map in the mask image is gradually changed according to the preset flow direction to obtain the directional distance field information corresponding to the target surface.
[0089] In one example, the preset fluid collision effect texture is sampled based on the texture coordinates of the target 2D texture map to obtain the effect texture sampling result, including: The texture coordinates of the target 2D texture map are offset according to the preset offset parameters to obtain the offset texture coordinates; The effect texture sampling result is obtained by sampling the preset fluid collision effect map based on the offset texture coordinates.
[0090] In one example, it also includes: The preset offset parameters are updated at preset intervals to obtain the updated offset parameters; The texture coordinates of the target 2D texture map are offset according to preset offset parameters to obtain the offset texture coordinates, including: The texture coordinates of the target 2D texture map are offset according to the updated offset parameters to obtain the offset texture coordinates.
[0091] In one example, before offsetting the texture coordinates of the target 2D texture map according to preset offset parameters to obtain the offset texture coordinates, the process includes: The texture coordinates of the target 2D texture map are scaled according to the preset scaling parameters to obtain the scaled texture coordinates. The texture coordinates of the target 2D texture map are offset according to preset offset parameters to obtain the offset texture coordinates, specifically including: The scaled texture coordinates are offset based on preset offset parameters and the normal vector of the target surface to obtain the offset texture coordinates.
[0092] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0093] Optional, such as Figure 14 As shown, the electronic device 400 also includes: a touch display screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch display screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407. Those skilled in the art will understand that... Figure 14 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0094] The touch display screen 403 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 403 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 401. It can also receive and execute commands from the processor 401. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 401 to determine the type of touch event. Subsequently, the processor 401 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 403 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 403 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 403 can also be used as part of the input unit 406 to achieve input functions.
[0095] In this embodiment of the application, the processor 401 executes a game application to generate a virtual three-dimensional scene on the touch screen 403. The scene includes a graphical user interface (UI), which includes a second spatial orientation indicator. The second spatial orientation indicator displays a spatial orientation mark corresponding to the target object. The spatial orientation mark is used to indicate the location of the target object.
[0096] The touch display screen 403 can be used to present images of virtual three-dimensional scenes, as well as graphical user interfaces and receive operation commands generated by the user interacting with the graphical user interface.
[0097] The radio frequency circuit 404 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.
[0098] Audio circuit 405 can be used to provide an audio interface between a user and an electronic device via a speaker and a microphone. Audio circuit 405 can convert received audio data into electrical signals and transmit them to the speaker, where the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuit 405, converted back into audio data, and then processed by processor 401 before being transmitted via radio frequency circuit 404 to, for example, another electronic device, or output to memory 402 for further processing. Audio circuit 405 may also include an earphone jack to provide communication between peripheral headphones and electronic devices.
[0099] The input unit 406 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0100] Power supply 407 is used to supply power to various components of electronic device 400. Optionally, power supply 407 can be logically connected to processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 407 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0101] although Figure 14 As not shown in the diagram, the electronic device 400 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0102] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0103] As can be seen from the above, the electronic device provided in this embodiment can realize interactive rendering of surface fluid elements and surface structure of virtual fabric models, thereby improving the rendering effect of fluid elements on the surface of virtual fabric models.
[0104] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0105] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute steps in any of the rendering methods provided in embodiments of this application. For example, the computer program can execute the following steps: Obtain the virtual fabric model to be rendered; Determine the target two-dimensional texture map and directed distance field information corresponding to the target surface of the virtual fabric model. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in the preset flow direction. The preset fluid collision effect map is sampled based on the texture coordinates of the target 2D texture map to obtain the effect map sampling result; The fluid touches the target surface and is rendered based on the effect texture sampling results and directional distance field information to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0106] In one example, the fluid touching the target surface is rendered based on the effect map sampling results and directional distance field information to obtain the fluid edge collision effect on the surface of the virtual fabric model, including: The first distance value of each pixel of the target two-dimensional texture map is mapped to the corresponding second distance value to obtain the remapped directed distance field information. The remapped directed distance field information includes the second distance value corresponding to each pixel of the target two-dimensional texture map, and the difference between the second distance values corresponding to each pixel of the target two-dimensional texture map is greater than the difference between the first distance values of each pixel of the target two-dimensional texture map. The fluid touches the target surface and is rendered based on the remapped directional distance field information and effect map sampling results to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0107] In one example, the effect map sampling result includes the first pixel value corresponding to each pixel point of the target 2D texture map; the fluid touches the target surface and is rendered based on the remapped directed distance field information and the effect map sampling result to obtain the fluid touch-edge collision effect on the virtual fabric model surface, including: Based on the first pixel value and the second distance value corresponding to each pixel of the target 2D texture map, determine the target pixel value corresponding to each pixel of the target 2D texture map; The fluid touches the target surface based on the target pixel value and the texture coordinates of the target 2D texture map to obtain the fluid touch collision effect on the surface of the virtual fabric model.
[0108] In one example, the target 2D texture map and directed distance field information corresponding to the target surface are determined based on the target surface of the virtual fabric model, including: The target surface of the virtual fabric model is unfolded according to texture coordinates to obtain a texture coordinate map; The texture coordinates of the texture coordinate map are adjusted to obtain the target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape. The directional distance field information corresponding to the target surface is determined based on the target's two-dimensional texture map.
[0109] In one example, the directed distance field information corresponding to the target surface is determined based on the target 2D texture map, including: Generate a mask image including the target 2D texture map, wherein the second pixel value of each pixel of the target 2D texture map in the mask image is a preset pixel value; The second pixel value of each pixel in the target 2D texture map in the mask image is gradually changed according to the preset flow direction to obtain the directional distance field information corresponding to the target surface.
[0110] In one example, the preset fluid collision effect texture is sampled based on the texture coordinates of the target 2D texture map to obtain the effect texture sampling result, including: The texture coordinates of the target 2D texture map are offset according to the preset offset parameters to obtain the offset texture coordinates; The effect texture sampling result is obtained by sampling the preset fluid collision effect map based on the offset texture coordinates.
[0111] In one example, it also includes: The preset offset parameters are updated at preset intervals to obtain the updated offset parameters; The texture coordinates of the target 2D texture map are offset according to preset offset parameters to obtain the offset texture coordinates, including: The texture coordinates of the target 2D texture map are offset according to the updated offset parameters to obtain the offset texture coordinates.
[0112] In one example, before offsetting the texture coordinates of the target 2D texture map according to preset offset parameters to obtain the offset texture coordinates, the process includes: The texture coordinates of the target 2D texture map are scaled according to the preset scaling parameters to obtain the scaled texture coordinates. The texture coordinates of the target 2D texture map are offset according to preset offset parameters to obtain the offset texture coordinates, specifically including: The scaled texture coordinates are offset based on preset offset parameters and the normal vector of the target surface to obtain the offset texture coordinates.
[0113] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0114] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0115] Since the computer program stored in the storage medium can execute the steps of any of the rendering methods provided in the embodiments of this application, the beneficial effects that any of the rendering methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0116] The rendering method, rendering apparatus, computer-readable storage medium, and electronic device provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A rendering method, characterized in that, include: Obtain the virtual fabric model to be rendered; The target surface of the virtual fabric model is unfolded according to texture coordinates to obtain a texture coordinate map; The texture coordinates of the texture coordinate map are adjusted to obtain the target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape. The directed distance field information corresponding to the target surface is determined based on the target two-dimensional texture map. The directed distance field information includes the first distance value of each pixel of the target two-dimensional texture map to the boundary of the target two-dimensional texture map in a preset flow direction. The preset fluid collision effect map is sampled based on the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result; The fluid touches the target surface based on the effect texture sampling results and the directional distance field information to obtain the fluid touch collision effect on the surface of the virtual fabric model.
2. The rendering method according to claim 1, characterized in that, The step of rendering the fluid touching the target surface based on the effect texture sampling results and the directional distance field information to obtain the fluid edge collision effect on the surface of the virtual fabric model includes: The first distance value of each pixel of the target two-dimensional texture map is mapped to the corresponding second distance value to obtain the remapped directed distance field information. The remapped directed distance field information includes the second distance value corresponding to each pixel of the target two-dimensional texture map, and the degree of difference between the second distance values corresponding to each pixel of the target two-dimensional texture map is greater than the degree of difference between the first distance values of each pixel of the target two-dimensional texture map. The fluid touches the target surface based on the remapped directional distance field information and the effect texture sampling results to obtain the fluid touch collision effect on the surface of the virtual fabric model.
3. The rendering method according to claim 2, characterized in that, The effect map sampling result includes the first pixel value corresponding to each pixel point of the target two-dimensional texture map; the step of rendering the fluid touching the target surface based on the remapped oriented distance field information and the effect map sampling result to obtain the fluid edge collision effect on the surface of the virtual fabric model includes: Based on the first pixel value and the second distance value corresponding to each pixel of the target two-dimensional texture map, determine the target pixel value corresponding to each pixel of the target two-dimensional texture map; The fluid touches the target surface based on the target pixel value and the texture coordinates of the target two-dimensional texture map to obtain the fluid touch collision effect on the surface of the virtual fabric model.
4. The rendering method according to claim 1, characterized in that, The step of determining the directed distance field information corresponding to the target surface based on the target two-dimensional texture map includes: Generate a mask image including the target two-dimensional texture map, wherein the second pixel value of each pixel point of the target two-dimensional texture map in the mask image is a preset pixel value; According to the preset flow direction, the second pixel value of each pixel point of the target two-dimensional texture map in the mask image is gradually changed to obtain the directional distance field information corresponding to the target surface.
5. The rendering method according to claim 1, characterized in that, The step of sampling a preset fluid collision effect map based on the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result includes: The texture coordinates of the target two-dimensional texture map are offset according to the preset offset parameters to obtain the offset texture coordinates; The preset fluid collision effect map is sampled based on the offset texture coordinates to obtain the effect map sampling result.
6. The rendering method according to claim 5, characterized in that, The rendering method also includes: The preset offset parameters are updated at preset time intervals to obtain the updated offset parameters; The step of offsetting the texture coordinates of the target two-dimensional texture map according to a preset offset parameter to obtain the offset texture coordinates includes: The texture coordinates of the target 2D texture map are offset according to the updated offset parameters to obtain the offset texture coordinates.
7. The rendering method according to claim 5, characterized in that, Before offsetting the texture coordinates of the target 2D texture map according to preset offset parameters to obtain the offset texture coordinates, the rendering method further includes: The texture coordinates of the target two-dimensional texture map are scaled according to preset scaling parameters to obtain scaled texture coordinates; The step of offsetting the texture coordinates of the target two-dimensional texture map according to a preset offset parameter to obtain the offset texture coordinates specifically includes: The scaled texture coordinates are offset according to the preset offset parameters and the normal vector of the target surface to obtain the offset texture coordinates.
8. A rendering apparatus, characterized in that, include: The acquisition module is used to acquire the virtual fabric model to be rendered; The determination module is used to unfold the target surface of the virtual fabric model according to texture coordinates to obtain a texture coordinate map; The texture coordinates of the texture coordinate map are adjusted to obtain a target two-dimensional texture map corresponding to the target surface. The adjustment process includes adjusting the boundary of the curved shape of the texture coordinate map to the boundary of the straight shape. The directed distance field information corresponding to the target surface is determined based on the target two-dimensional texture map. The directed distance field information includes a first distance value of each pixel of the target two-dimensional texture map from the boundary of the target two-dimensional texture map in a preset flow direction. The sampling module is used to sample the preset fluid collision effect map according to the texture coordinates of the target two-dimensional texture map to obtain the effect map sampling result; The rendering module is used to render the fluid touching the target surface based on the effect texture sampling results and the directional distance field information, so as to obtain the fluid touch-edge collision effect on the surface of the virtual fabric model.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading by a processor to perform the rendering method as described in any one of claims 1-7.
10. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the rendering method as described in any one of claims 1-7 by calling the computer program stored in the memory.
Citation Information
Patent Citations
Fabric simulation method and device, electronic equipment and readable storage medium
CN112419490A
Sea wave simulation method and device and electronic equipment
CN113902784A