Method, device, electronic device and storage medium for generating directed distance field

By obtaining the specific coordinate information of pixel points in the world space and its adjacent point information, and directly calculating the SDF value in combination with the normal orientation, the error problem caused by insufficient depth information in the prior art is solved, and higher calculation accuracy and applicability are achieved.

CN116704098BActive Publication Date: 2025-03-04GUANGZHOU BOGUAN TELECOMM TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310680194.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-08
Publication Date
2025-03-04
Estimated Expiration
2043-06-08

AI Technical Summary

Technical Problem

In the prior art, when SDF values ​​are generated by relying on a layer of depth information, the scene information after the depth is ignored, resulting in large errors in the calculation results.

Method used

By obtaining the spatial coordinate information of the pixel points to be generated to the world space and its adjacent points, and combining the normal orientation, the closest distance between the spatial point and the scene object is directly calculated to improve the accuracy of the SDF value.

Benefits of technology

It improves the calculation accuracy of SDF values, avoids the accuracy problems caused by the lack of depth information in traditional methods, and can be applied to dynamic and static scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116704098B_ABST
    Figure CN116704098B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for generating a signed distance field, and relates to the field of image rendering technology. The method can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by acquiring the spatial coordinate information of the first pixel point to be generated for the SDF value mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image rendering technology, and in particular to a method, device, electronic device and storage medium for generating a signed distance field. Background Art

[0002] SDF (Signed Distance Field) refers to the return of the closest distance between a point in any space and an object in the space scene given a position point in space. SDF is used in ray marching technology to determine the distance of each step of the stepping ray. The purpose of ray marching technology is to emit stepping rays, which will eventually intersect with objects in the space scene through stepping, and a series of image rendering operations can be performed based on the intersection information.

[0003] In the prior art, the SDF value of a spatial point is obtained through the depth information of the spatial point. However, relying only on one layer of depth information will cause the scene information after the depth to be ignored, resulting in a large error in the calculated SDF value. Summary of the invention

[0004] The purpose of the present application is to provide a method, device, electronic device and storage medium for generating a signed distance field in order to improve the accuracy of the generated SDF value in view of the above-mentioned deficiencies in the prior art.

[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for generating a signed distance field, comprising:

[0007] Determine, according to pixel coordinate information of a first pixel point in the current target signed distance field texture map, spatial coordinate information of a first spatial point in the world space mapped from the first pixel point;

[0008] Determine, according to the pixel coordinate information of the first pixel and a preset rasterization direction, each adjacent pixel corresponding to the first pixel, and determine, according to the pixel coordinate information of each adjacent pixel, spatial coordinate information of each adjacent spatial point in the world space mapped from each adjacent pixel;

[0009] Generate, according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map;

[0010] According to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, the signed distance field information of each second pixel point in the current target signed distance field texture map is generated respectively, where the second pixel point is the remaining pixel point in the target signed distance field except the first pixel point and the adjacent pixel points.

[0011] In a second aspect, an embodiment of the present application further provides a device for generating a signed distance field, including: a determination module and a generation module;

[0012] The determination module is used to determine the spatial coordinate information of a first spatial point in the world space mapped from the first pixel point according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map;

[0013] The determination module is used to determine each adjacent pixel point corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction, and determine the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space according to the pixel coordinate information of each adjacent pixel point;

[0014] The generating module is used to generate the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point;

[0015] The generating module is used to generate the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, wherein the second pixel is the remaining pixel in the target signed distance field except the first pixel and the adjacent pixel.

[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to implement the method for generating a directed distance field provided in the first aspect.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for generating a signed distance field as provided in the first aspect is executed.

[0018] The beneficial effects of this application are:

[0019] The present application provides a method, device, electronic device and storage medium for generating a directed distance field. The method can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by acquiring the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.

[0020] Secondly, this solution adopts the method of separate storage of SDF for dynamic and static scenes. The SDF values ​​of static scenes are stored in the SDF texture map of static scenes, and the SDF values ​​of dynamic scenes are stored in the SDF texture map of dynamic scenes. Since the SDF values ​​of static scenes do not need to be updated one by one, the amount of calculation when generating SDF values ​​can be effectively reduced.

[0021] In addition, this solution uses an SDF texture map with multiple layers of texture maps to store the SDF values ​​of the corresponding spatial points in the world space. Different world space ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids excessive video memory usage caused by storing SDF texture maps uniformly for the entire scene (the same spatial range is mapped both near and far). BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 1 ;

[0024] Figure 2A schematic diagram of an SDF texture map provided in an embodiment of the present application;

[0025] Figure 3 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 2 ;

[0026] Figure 4 A schematic diagram showing overlapping areas of an SDF texture map provided in an embodiment of the present application;

[0027] Figure 5 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 3 ;

[0028] Figure 6 A schematic diagram of pixel display provided in an embodiment of the present application;

[0029] Figure 7 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 4 ;

[0030] Figure 8 A schematic diagram of a spatial point display provided in an embodiment of the present application;

[0031] Fig. 9 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 5 ;

[0032] Fig.10 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 6 ;

[0033] Fig.11 A schematic diagram of a device for generating a directed distance field provided in an embodiment of the present application;

[0034] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0036] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0037] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0038] First, the relevant background of this plan is explained:

[0039] Some advanced rendering effects in games, such as diffuse global illumination, specular reflection, soft shadows, and ambient occlusion, can be achieved through raymarching technology, which means emitting rays from the camera to each pixel on the screen. The rays intersect with the game scene (the virtual model in the scene) by moving forward step by step. The length of the ray step depends on the shortest distance between the current position of the ray and the game scene, which refers to the signed distance field information (SDF value) of the current position (spatial point). SDF (Signed Distance Field) refers to the return of the shortest distance between this point and the scene object given a position pos in any space.

[0040] Usually, SDF texture maps are used to store the SDF values ​​of each spatial point in the spatial range of the game scene. Since the models in the game scene may be dynamically moved, or due to the change of the virtual camera position, the same spatial point in the game scene will have different SDF values ​​when rendering different frames. In other words, the SDF values ​​of each spatial point in the game scene in each frame rendering are not constant, but will be updated in real time according to the actual situation. Therefore, how to accurately calculate the SDF value required for each frame rendering becomes particularly important.

[0041] In the prior art, the first method is to use Unreal 4 engine to calculate SDF, using the offline baking + real-time patchwork method: that is, offline calculation of the SDF data of each spatial point to a small 3D texture, and then apply this 3D texture containing SDF data to the actual position of the model in the scene through translation, rotation and scaling during real-time rendering to obtain the real SDF information of the spatial point. A significant disadvantage of this method is that it can only handle static scenes, but not dynamic scenes: such as breakable models, animated models, movable characters and vehicles, etc.; in addition, the offline pre-generated SDF data has no lighting information, so it is impossible to perform subsequent rendering calculations such as diffuse global light and specular reflection.

[0042] The second method is to use the KinectFusion (point cloud reconstruction) algorithm to calculate the SDF. This algorithm constructs the scene SDF information based on the depth map rendered by multiple frames, and only updates a layer of information that the camera can see in each frame. However, this algorithm has the following limitations: 1. Since the SDF data is restored only through the depth map, the SDF information behind the depth map cannot be accurately obtained, resulting in incomplete SDF information. 2. The calculated SDF value is significantly different from the actual SDF value, which affects the step size during raymarching and may cause errors in skipping the actual surface. 3. Relying only on one layer of depth information, the scene information behind the depth is unknown. Sometimes this is a very thick wall, and sometimes it may be a thin ribbon. This will generate incorrect SDF information behind the depth, and the incorrect SDF information will cause various problems such as light leakage and ghosting during the global light calculation process.

[0043] Based on this, this scheme proposes a new SDF generation method, which calculates SDF by combining the coordinate information of spatial points, the normal direction and the information of triangular patches, thus getting rid of the calculation method that relies on depth information. It can be applied to the calculation of SDF of any spatial point in dynamic and static scenes, thus achieving more accurate SDF calculation.

[0044] Figure 1 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 1; The execution subject of this method can be a terminal device or a computing device such as a server or a processor. Figure 1 As shown, the method may include:

[0045] S101. Determine spatial coordinate information of a first spatial point in a world space mapped from the first pixel point according to pixel coordinate information of a first pixel point in a current target signed distance field texture map.

[0046] This solution focuses on the description of the method for generating a signed distance field (hereinafter referred to as SDF). In the embodiment, the generation of the current SDF texture corresponding to the current frame of the picture to be rendered is used for explanation. In actual application scenarios, each frame of the picture to be rendered will change, and the corresponding texture map used to store the scene space point SDF will also be updated in real time. For each update, the SDF generation method shown in this solution can be used to generate a new SDF, and the new SDF is used to replace the previous SDF to ensure that the SDF values ​​of each spatial point stored in the SDF texture map are the latest and most accurate SDF values ​​when each frame of the picture is rendered.

[0047] Assume that when the previous frame was rendered, the stepping ray stepped from spatial point a in the game scene to spatial point b, and is currently at point b. When the current frame is rendered, to obtain the distance that the stepping ray continues to step from point b, the SDF value stored corresponding to pixel point 1 mapped to spatial point b in the current SDF texture map can be calculated first, and then the SDF value stored in pixel point 1 in the texture map can be used as the distance that the stepping ray needs to step from point b when the current frame is rendered.

[0048] The first pixel point may refer to any pixel point among the pixel points whose SDF values ​​are to be updated in the current target SDF texture map, and the pixel coordinate information of the first pixel point may refer to the coordinates of the first pixel point in the SDF texture map.

[0049] Based on the acquired pixel coordinate information of the first pixel point, the spatial coordinate information of the first spatial point mapped from the first pixel point to the world space can be determined according to the coordinate mapping relationship between the texture map and the world space.

[0050] Here is an explanation of the mapping between texture maps and world space:

[0051] In order to access the SDF value of a certain position in the world space (world coordinates) through the SDF texture map, the coverage box range (AABB: axis-aligned bounding box) of the SD texture map in the world space is defined. The minimum value of the bounding box coordinates is BBMin, and the maximum value of the bounding box coordinates is BBMax. Then, the pixel coordinates (texture coordinates UVW) of each pixel of the SDF texture map can be accurately mapped to a spatial point (WorldPos) in the world space, and vice versa. The mapping formula is as follows: WorldPos = BBMin + (BBMax-BBMin) * UVW; UVW = (WorldPos-BBMin) / (BBMax-BBMin).

[0052] Based on the above mapping formula, when the pixel coordinate information of the first pixel point is known, the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space can be calculated; conversely, when the spatial coordinate information of the first spatial point in the world space is known, the pixel coordinate information of the first spatial point mapped to the first pixel point in the SDF texture map can also be calculated.

[0053] S102. Determine each adjacent pixel point corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction, and determine the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space according to the pixel coordinate information of each adjacent pixel point.

[0054] Usually, all spatial points in the world space exist attached to triangles, that is, objects in the world space are composed of the smallest unit triangles. Different spatial points may be located on the same triangle or on different triangles.

[0055] In order to avoid the problem that the surface where the pixel point whose SDF value is to be updated is located is parallel to the rasterization direction, resulting in the inability to obtain the depth of the pixel point through rasterization, and to ensure that the depth information of the surface can be obtained, rasterization is performed in multiple preset directions in this embodiment.

[0056] Rasterization refers to the process of converting triangles into pixels, taking into account occlusion relationships. If a pixel position is covered by multiple triangles at the same time, the frontmost triangle information is selected and absorbed into the pixel.

[0057] According to the preset rasterization direction, each adjacent pixel point corresponding to the first pixel point can be determined in the SDF texture map. For each adjacent pixel point, the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space can also be determined based on the pixel coordinate information of each adjacent pixel point and the mapping relationship between the texture map and the world space.

[0058] S103, generating respectively the signed distance field information of the first pixel point and the signed distance field information of the adjacent pixel points in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of the adjacent spatial points and the normal direction of the first spatial point.

[0059] In some embodiments, based on the spatial coordinate information of the first spatial point determined above, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map can be generated respectively.

[0060] In this embodiment, the SDF is calculated based on the spatial coordinate information of the spatial point and the spatial coordinate information of the adjacent spatial points corresponding to the spatial point. Since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the shortest distance between the spatial point and the scene object, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when traditionally relying on the depth information of the spatial point for calculation.

[0061] In addition, the normal direction of the spatial point can be used to further determine the positional relationship between the spatial point and its nearest scene object, thereby accurately determining the positive and negative signs of the calculated SDF value, effectively improving the accuracy of the calculation results.

[0062] S104. Generate signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, where the second pixel is the remaining pixel in the target signed distance field except the first pixel and the adjacent pixel.

[0063] The second pixel point is the remaining pixel point whose SDF value is to be updated except for the adjacent pixel points corresponding to the first pixel point and the second pixel point in the current target signed distance field texture map.

[0064] In a feasible manner, the generation of the SDF of the second pixel point can also be calculated in the manner of steps S101 to S103 described above. In this case, the second pixel point can be used as the first pixel point to perform calculations.

[0065] In another feasible method, in order to reduce the amount of calculation and improve the calculation efficiency, the SDF value of the second pixel point can be generated by performing a comprehensive analysis based on the calculated SDF value of the first pixel point and the SDF values ​​of each adjacent pixel point corresponding to the first pixel point to generate the SDF value of the second pixel point.

[0066] Based on this, SDF generation is completed for all pixel points in the current target signed distance field texture map that need to regenerate SDF values, so that the original stored SDF values ​​can be replaced according to the generated SDF values ​​to obtain an updated target signed distance field texture map.

[0067] In summary, the method for generating a signed distance field provided in this embodiment can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.

[0068] Optionally, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map.

[0069] In this embodiment, the SDF values ​​of static scenes are stored separately, and the SDF values ​​of dynamic scenes are stored in the SDF texture map of static scenes, and the SDF values ​​of dynamic scenes are stored in the SDF texture map of dynamic scenes. Since the SDF values ​​of static scenes do not need to be updated one by one, the amount of calculation when generating SDF values ​​can be effectively reduced.

[0070] Static scenes can be composed of static models in the scene, such as a wall, a road, etc., while dynamic scenes can be composed of dynamic models in the scene, such as moving vehicles, floating clouds, etc. The scene exists in the world space.

[0071] The target signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same size to store the signed distance field information of each spatial point in the corresponding world space range, and each pixel point in each layer of texture maps stores the signed distance field information of the corresponding spatial point; wherein the world space range corresponding to each layer of texture maps is determined according to the distance between the world space range and the virtual camera.

[0072] Figure 2 A schematic diagram of an SDF texture map provided in an embodiment of the present application. Figure 2 As shown, taking the target SDF texture map including three layers of texture maps as an example, the target SDF texture map can be a three-layer 3D texture map established around the virtual camera, which respectively maps the spatial range of the game world space at different distances from the virtual camera.

[0073] like Figure 2 As shown in the figure, each layer is the world space range mapped by the SDF texture map. The world space range of the SDF of the space points stored in each layer of texture maps is determined by the virtual camera position. When the virtual camera position changes, the world space range corresponding to the texture map also changes accordingly. Among them, the number of textures in each layer of texture maps does not change. Each layer of texture maps uses the same pixel size (for example: 128*128*128) to store the directed distance field information of the space points corresponding to the world space range. That is, each layer of texture maps is a texture map with equal length, width and height, so the video memory occupied by the SDF texture map is always fixed.

[0074] Optionally, different world space ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids excessive video memory usage caused by storing SDF texture maps uniformly for the entire scene (the same spatial range is mapped both near and far).

[0075] Figure 3 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 2 Optionally, in step S101, before determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the method may include:

[0076] S301. If the current target signed distance field texture map is a static scene signed distance field texture map, determining an overlapping area and a non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to a world space range corresponding to the current target signed distance field texture map and a world space range corresponding to the previous target signed distance field texture map.

[0077] Before obtaining the pixel coordinate information of the first pixel from the current target SDF texture map, if it is determined that the current target SDF texture map is a static scene SDF texture map, the overlapping area and non-overlapping area between the current target SDF texture map and the previous target SDF texture map can be determined first. For the overlapping area, the SDF value stored in the previous target SDF texture map can be copied to the current target SDF texture map, and for the non-overlapping area, the method of steps S101-S104 is used to generate the SDF value of each pixel in the non-overlapping area. Then, the first pixel in the current target SDF texture map can refer to any pixel in the non-overlapping area.

[0078] It is worth noting that the previous target SDF texture map can correspond to the target SDF texture map that needs to read the SDF value when rendering the previous frame. That is to say, when rendering the previous frame, the stepping distance of the stepping ray can be obtained by reading the corresponding SDF from the previous target SDF texture map; the current target SDF texture map corresponds to the target SDF texture map that needs to read the SDF value when rendering the current frame; when rendering the current frame, the stepping distance of the stepping ray can be obtained by reading the corresponding SDF from the current target SDF texture map. During the running of the game, the rendering of each frame of the game screen can read the SDF of the spatial point from the SDF texture map corresponding to each frame to perform ray stepping, and obtain the relevant information of the intersection based on the intersection of the stepping ray and the scene, and perform some advanced rendering.

[0079] The current target SDF texture map and the previous target SDF texture map are the same map, and only the SDF values ​​stored corresponding to the same pixel points in the map may have changed.

[0080] S302: Update the signed distance field information of each pixel in the overlapping area of ​​the current target signed distance field texture map according to the signed distance field information of each pixel in the overlapping area of ​​the previous target signed distance field texture map.

[0081] Figure 4 A schematic diagram showing an overlapping area of ​​an SDF texture map provided in an embodiment of the present application is shown in FIG. Figure 4As shown, the black part represents the overlapping area between the previous target SDF texture map and the current target SDF texture map (it is worth noting that the texture map is three-dimensional in actual applications, but it is simplified to two-dimensional here for the convenience of demonstration). For the overlapping area, the SDF value stored in each pixel point in the overlapping area of ​​the current target SDF texture map can directly copy the SDF value stored in each pixel point in the overlapping area of ​​the previous target SDF texture map. Since the world space range corresponding to the overlapping area has not changed between the current frame and the previous frame, the SDF values ​​of the spatial points in the corresponding stored world space range have not changed either. However, for the target SDF texture map, the pixel coordinate information of the same pixel point in the overlapping area in the previous target SDF texture map and in the current DF texture map are different, which results in the need to copy the SDF values ​​of each pixel point in the overlapping area from the previous target SDF texture map accordingly. For example, the pixel point in the upper left corner of the overlapping area in the previous target SDF texture map is assumed to be (4, 7, 9), and its corresponding stored SDF value is a, while the pixel point (4, 7, 9) in the upper left corner of the overlapping area in the previous target SDF texture map becomes the pixel point (0, 0, 11) in the current target SDF texture map. Then, the SDF value stored in the pixel point (0, 0, 11) of the overlapping area in the current target SDF texture map is replaced with a. Similarly, the SDF values ​​of each pixel point in the overlapping area can be obtained accordingly.

[0082] S303: Initialize the signed distance field information of each pixel in the non-overlapping area in the current target signed distance field texture map to a preset value, where the first pixel point is a pixel point in the non-overlapping area.

[0083] For non-overlapping areas, Figure 4 For the area represented by the slashed part in , the SDF values ​​of each pixel in the non-overlapping area can be initialized to a preset value, where the preset value can be CellSize*4 (4 times the CellSize), where CellSize represents the length of a single pixel side length in the SDF texture map mapped to the world space.

[0084] For each pixel point in the non-overlapping area, it is necessary to recalculate a new SDF value of each pixel point. Therefore, the first pixel point mentioned above may be any pixel point in the non-overlapping area.

[0085] Optionally, in step S101, before determining the spatial coordinate information of the first pixel mapped to the first spatial point in the world space based on the pixel coordinate information of the first pixel in the current target signed distance field texture map, it can include: if the target signed distance field texture map is a dynamic scene signed distance field texture map, initializing the signed distance field information of each pixel in the current target signed distance field texture map to a preset value, and the first pixel is any pixel in the current target signed distance field texture map.

[0086] If the current target SDF texture map is a dynamic scene SDF texture map, the SDF of all pixels in the texture map needs to be regenerated. At this time, the SDF of all pixels can be initialized to a preset value. The preset value here is consistent with the above and can be CellSize*4.

[0087] It should be noted that the reason for selecting CellSize*4 is that when rasterizing the preset direction, the first pixel point is selected and the adjacent pixel points are selected 3 pixels along the rasterization direction for calculation. If the preset value is larger than CellSize*4, obstacles will be skipped during the ray stepping process, and the accurate result of the ray stepping cannot be obtained.

[0088] Of course, the selection of the preset value can be adaptively adjusted according to the actual rasterization scene.

[0089] Figure 5 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 3 ;like Figure 5 As shown, in step S102, according to the pixel coordinate information of the first pixel and the preset rasterization direction, respectively determining the adjacent pixel points corresponding to the first pixel point may include:

[0090] S501 , according to pixel coordinate information of a first pixel point and a first rasterization direction, determining that a preset number of pixel points along the first rasterization direction and adjacent to the first pixel point are first adjacent pixel points corresponding to the first pixel point.

[0091] The first rasterization direction can be the x-axis direction. Assuming that the pixel coordinate information of the first pixel point is [x, y, z], the first adjacent pixel points corresponding to the first pixel point can be determined based on the three pixels before and after [x, y, z] along the x-axis direction, including: [x-3, y, z], [x-2, y, z], [x-1, y, z], [x+1, y, z], [x+2, y, z], [x+3, y, z].

[0092] S502: Determine, according to pixel coordinate information of the first pixel and the second rasterization direction, a preset number of pixel points along the second rasterization direction and adjacent to the first pixel as second adjacent pixel points corresponding to the first pixel.

[0093] The second rasterization direction can be the y-axis direction. Based on [x, y, z], the three pixels before and after along the y-axis direction can respectively determine the second adjacent pixel points corresponding to the first pixel point, including: [x, y-3, z], [x, y-2, z], [x, y-1, z], [x, y+1, z], [x, y+2, z], [x, y+3, z].

[0094] S503: Determine, according to the pixel coordinate information of the first pixel and the third rasterization direction, that a preset number of pixel points along the third rasterization direction and adjacent to the first pixel are third adjacent pixel points corresponding to the first pixel.

[0095] The third rasterization direction can be the z-axis direction. Based on [x, y, z], the three pixels before and after along the z-axis direction can respectively determine the second adjacent pixel points corresponding to the first pixel point, including: [x, y, z-3], [x, y, z-2], [x, y, z-1], [x, y, z+1], [x, y, z+2], [x, y, z+3].

[0096] Figure 6 A schematic diagram of a pixel display provided in an embodiment of the present application is shown as follows: Figure 6 As shown, the pixel coordinate information and positional relationship of the first pixel point and each adjacent pixel point corresponding to the first pixel point determined according to the above-mentioned rasterization direction are respectively displayed.

[0097] Figure 7 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 4 Optionally, in step S103, generating the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point respectively may include:

[0098] S701 . Generate signed distance field information of a first pixel point in a current target signed distance field texture map according to spatial coordinate information of a first spatial point and depth information of a triangle patch corresponding to the first spatial point.

[0099] Figure 8 A schematic diagram of a spatial point display provided in an embodiment of the present application, assuming that the positional relationship between a first spatial point and a triangular facet corresponding to the first spatial point is as follows: Figure 8As shown, first, the depth information of the triangular patch can be obtained, where the depth information of the patch can refer to the distance between the position represented by the patch and the observer (which can refer to the virtual camera). The depth information can be calculated by making a ray parallel to the observation direction through a certain pixel point on the screen, and the distance from the point where the ray intersects the patch to the pixel point is the depth of the patch.

[0100] The position information of the triangle patch in the world space can be calculated based on the depth information of the triangle patch. Then, according to the position information of the first spatial point and the position information of the triangle patch, the SDF value of the first spatial point can be calculated by performing vector operations, that is, the distance solution operation from point to surface. The SDF value of the first spatial point is stored in the first pixel point in the current target SDF texture map, thereby obtaining the SDF value of the first pixel point.

[0101] S702: Generate signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point.

[0102] As for the generation of the SDF values ​​of the adjacent pixel points of the first pixel point, the SDF values ​​can be calculated one by one according to the spatial coordinate information of the adjacent spatial points, the spatial coordinate information of the first spatial point and the normal direction of the first spatial point.

[0103] Fig. 9 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 5 Optionally, in step S702, generating the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point may include:

[0104] S901. Determine a distance value between a target adjacent spatial point and the first spatial point according to spatial coordinate information of the target adjacent spatial point and spatial coordinate information of the first spatial point. The target adjacent spatial point is any adjacent spatial point among the adjacent spatial points.

[0105] by Figure 6 As an example, the pixel point display diagram shown in the figure is used as an example. The target adjacent spatial point here can refer to Figure 6 Any pixel point except the first pixel point [x, y, z] is mapped to the spatial point in world space.

[0106] Taking the SDF value of the pixel point [x-1, y, z] as an example, the target adjacent spatial point refers to the spatial point in the world space mapped to the pixel point [x-1, y, z]. The spatial coordinate information of the target adjacent spatial point can be determined based on the coordinate mapping relationship between the texture map and the world space.

[0107] Assuming that the spatial coordinate information of the first spatial point is P, and the spatial coordinate information of the target adjacent spatial point is P2, then the distance D from point P to point P2 can be calculated to obtain the distance value between the target adjacent spatial point and the first spatial point.

[0108] S902: Calculate the dot product result of the first spatial point, the direction vector of the target adjacent spatial point, and the normal of the first spatial point.

[0109] In addition, assume that the normal direction of the first spatial point is The direction vector between the first spatial point and the target adjacent spatial point is: Then we can calculate and The dot product of is obtained.

[0110] S903: Generate the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value.

[0111] According to the dot product result, the positive and negative signs of the SDF values ​​of the target adjacent spatial points can be determined, thereby obtaining the SDF values ​​of the target adjacent spatial points. The SDF values ​​of the target adjacent spatial points are stored in the target adjacent pixel points, and the SDF values ​​of the target adjacent pixel points can be obtained, that is, the SDF value of the pixel point [x-1, y, z] in the current target SDF texture map can be obtained, such as Figure 6 The SDF value of the pixel point [x-1, y, z] is shown.

[0112] And for Figure 6 The calculation of the SDF value of any adjacent pixel point other than the first pixel point [x, y, z] shown in can be performed one by one according to the above calculation method, so as to obtain the SDF values ​​of each adjacent pixel point corresponding to the first pixel point.

[0113] Optionally, in step S903, generating the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value may include: if the dot product result is greater than 0, using the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.

[0114] like and If the result of the dot product is greater than 0, it means that the target adjacent spatial point is located outside the triangle patch corresponding to the first spatial point. At this time, the calculated distance value between the target adjacent spatial point and the first spatial point can be determined as the SDF value of the target adjacent pixel point.

[0115] If the dot product result is less than or equal to 0, the negative of the distance value is used as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.

[0116] And if and If the result of the dot product is less than or equal to 0, it means that the target adjacent spatial point is located on the inner side of the triangle corresponding to the first spatial point. At this time, the negative of the calculated distance value between the target adjacent spatial point and the first spatial point can be determined as the SDF value of the target adjacent pixel point.

[0117] Fig.10 Schematic diagram of the process of generating a directed distance field provided in an embodiment of the present application Figure 6 Optionally, in step S104, generating the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel respectively may include:

[0118] S1001. Determine whether the signed distance field information of a target second pixel point in a current target signed distance field texture map is greater than a preset threshold, the target second pixel point being any pixel point among the second pixel points.

[0119] The calculation of the SDF of the second pixel can be performed by multi-frame diffusion. Taking the generation of the SDF value of the second target pixel as an example, it can be determined whether the absolute value of the current SDF value of the second target pixel is greater than a preset threshold, where the preset threshold can refer to 3*CellSize.

[0120] Before the SDF of the target second pixel point is regenerated, the SDF value of the target second pixel point is initialized to 4*CellSize. When it is determined that the SDF value of the target second pixel point is greater than 3*CellSize, it can be considered that the SDF value of the target second pixel point has not been regenerated before.

[0121] S1002: If yes, determine initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map.

[0122] Optionally, the SDF values ​​of all neighboring pixels of the target second pixel may be obtained, where the neighboring pixels refer to the four neighboring pixels of the target second pixel in the current target SDF texture map, and the minimum value K of the absolute value of the SDF value is taken from the SDF values ​​of the four neighboring pixels as the initial SDF.

[0123] S1003: Generate the signed distance field information of the target second pixel point in the current target signed distance field texture map according to the initial signed distance field information and the length of the unit pixel side length in the target signed distance field texture map mapped to the length in the world space range.

[0124] Then, the SDF value of the target second pixel point can be updated by (K+1)*CellSize. The target second pixel point is any one of all the second pixel points, and the SDF values ​​of all the second pixel points can be generated according to the generation method of the SDF value of the target second pixel point.

[0125] When it is determined that the absolute value of the current SDF value of the target second pixel is less than 3*CellSize, the current update logic can be skipped, that is, the SDF value of the target second pixel remains unchanged.

[0126] Optionally, in step S104, after respectively generating the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, the method may further include: if the absolute value of the signed distance field information of the first pixel in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel in the previous target signed distance field texture map, adjusting the signed distance field information of the first pixel in the generated current target signed distance field texture map to the signed distance field information of the first pixel in the previous target signed distance field texture map.

[0127] Through the above steps, the new SDF values ​​of the pixels in the current target SDF texture map that need to recalculate the SDF value have been preliminarily generated. However, the calculated new SDF values ​​may not be adopted. Since the SDF value refers to the closest distance between the spatial point and the scene, the absolute value of the SDF value of each pixel in the generated current target SDF texture map can be compared with the absolute value of the SDF value of each pixel in the previous target SDF texture map. The minimum value of the two is taken as the SDF value of each pixel in the current target SDF texture map.

[0128] For example: the SDF value of the first pixel in the current target SDF texture map generated by this method is -4, while the SDF value of the first pixel in the previous target SDF texture map is 5. Since the absolute value of the SDF value of the first pixel in the current target SDF texture map is smaller than the absolute value of the SDF value of the first pixel in the previous target SDF texture map, the SDF value of the first pixel in the current target SDF texture map -4 can be used as the final SDF value of the first pixel in the current target SDF texture map.

[0129] If the SDF value of the first pixel in the current target SDF texture map is -5, and the SDF value of the first pixel in the previous target SDF texture map is 4, since the absolute value of the SDF value of the first pixel in the current target SDF texture map is greater than the absolute value of the SDF value of the first pixel in the previous target SDF texture map, the SDF value of the first pixel in the current target SDF texture map remains unchanged at 4.

[0130] By correcting the generated SDF value through this method, it can be ensured that the SDF value of each pixel in the target SDF texture map corresponding to each frame rendering can obtain the most accurate value, thereby ensuring the accuracy of light stepping.

[0131] Optionally, the method of the present application may further include: rendering the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.

[0132] Assuming that the picture to be rendered in the current frame is the indirect lighting for rendering virtual model a, then a stepping ray can be emitted from virtual model a to the game scene, and the distance that the stepping ray needs to step in the current frame is read from the current target signed distance field texture map. Assuming that the current position of the stepping ray is spatial point a, the SDF value of spatial point a stored in the pixel corresponding to spatial point a in the current target signed distance field texture map can be read, so that the stepping ray steps according to the SDF value. Assuming that it intersects with the virtual model b in the scene after stepping, the material information of the intersection can be read, such as the material and texture of the scene surface at the intersection position, etc., so as to combine the incident light information, such as light color, intensity, angle, material, attenuation, etc., to determine the color information of the intersection, and thus calculate the indirect lighting of the virtual model a according to the color information of the intersection.

[0133] Of course, this is just an example of a rendering scene. In actual applications, the role of stepping rays is not limited to the calculation of indirect lighting, but the stepping distance of the stepping rays is related to the SDF of the space point at each frame step.

[0134] In summary, the method for generating a signed distance field provided in this embodiment can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.

[0135] Secondly, this solution adopts the method of separate storage of SDF for dynamic and static scenes. The SDF values ​​of static scenes are stored in the SDF texture map of static scenes, and the SDF values ​​of dynamic scenes are stored in the SDF texture map of dynamic scenes. Since the SDF values ​​of static scenes do not need to be updated one by one, the amount of calculation when generating SDF values ​​can be effectively reduced.

[0136] In addition, this solution uses an SDF texture map with multiple layers of texture maps to store the SDF values ​​of the corresponding spatial points in the world space. Different world space ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids excessive video memory usage caused by storing SDF texture maps uniformly for the entire scene (the same spatial range is mapped both near and far).

[0137] The following describes the apparatus, device, storage medium, etc. used to execute the method for generating a signed distance field provided in the present application. The specific implementation process and technical effects thereof are as mentioned above and will not be described in detail below.

[0138] Fig.11 A schematic diagram of a device for generating a directed distance field provided in an embodiment of the present application, wherein the functions implemented by the device for generating a directed distance field correspond to the steps performed by the method for generating a directed distance field. The device can be understood as the terminal device or server, or the processor of the server, or can also be understood as a component independent of the server or processor that implements the functions of the present application under the control of the server, such as Fig.11As shown, the device may include: a determination module 110, a generation module 120;

[0139] A determination module 110, configured to determine spatial coordinate information of a first spatial point in a world space mapped from the first pixel point according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map;

[0140] A determination module 110 is used to determine each adjacent pixel point corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction, and determine the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space according to the pixel coordinate information of each adjacent pixel point;

[0141] A generating module 120, configured to generate the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point;

[0142] The generating module 120 is used to generate the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, wherein the second pixel is the remaining pixel in the target signed distance field except the first pixel and each adjacent pixel.

[0143] Optionally, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map;

[0144] The target signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same size to store the signed distance field information of each spatial point in the corresponding world space range, and each pixel point in each layer of texture maps stores the signed distance field information of the corresponding spatial point; wherein the world space range corresponding to each layer of texture maps is determined according to the distance between the world space range and the virtual camera.

[0145] Optionally, the device further includes: an updating module and an initialization module;

[0146] The determination module 110 is further configured to determine, if the current target signed distance field texture map is a static scene signed distance field texture map, an overlapping area and a non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to a world space range corresponding to the current target signed distance field texture map and a world space range corresponding to the previous target signed distance field texture map;

[0147] An updating module, configured to update the signed distance field information of each pixel in the overlapping area of ​​the current target signed distance field texture map according to the signed distance field information of each pixel in the overlapping area of ​​the previous target signed distance field texture map;

[0148] The initialization module is used to initialize the signed distance field information of each pixel in the non-overlapping area of ​​the current target signed distance field texture map to a preset value, and the first pixel point is a pixel point in the non-overlapping area.

[0149] Optionally, the initialization module is further used to initialize the signed distance field information of each pixel in the current target signed distance field texture map to a preset value if the target signed distance field texture map is a dynamic scene signed distance field texture map, and the first pixel point is any pixel point in the current target signed distance field texture map.

[0150] Optionally, the determination module 110 is specifically configured to determine, according to the pixel coordinate information of the first pixel point and the first rasterization direction, that the pixel points that are a preset number of pixels adjacent to the first pixel point along the first rasterization direction are first adjacent pixel points corresponding to the first pixel point;

[0151] According to the pixel coordinate information of the first pixel point and the second rasterization direction, determining that a preset number of pixel points along the second rasterization direction and adjacent to the first pixel point are second adjacent pixel points corresponding to the first pixel point;

[0152] According to the pixel coordinate information of the first pixel point and the third rasterization direction, a preset number of pixel points along the third rasterization direction and adjacent to the first pixel point are determined as third adjacent pixel points corresponding to the first pixel point.

[0153] Optionally, the generating module 120 is specifically configured to generate the signed distance field information of the first pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point and the depth information of the triangular facet corresponding to the first spatial point;

[0154] The signed distance field information of each adjacent pixel point in the current target signed distance field texture map is generated according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point.

[0155] Optionally, the generating module 120 is specifically configured to generate a distance value between the target adjacent spatial point and the first spatial point according to the spatial coordinate information of the target adjacent spatial point and the spatial coordinate information of the first spatial point, wherein the target adjacent spatial point is any adjacent spatial point among the adjacent spatial points;

[0156] A dot product result of the first spatial point, the direction vector of the target adjacent spatial point and the normal of the first spatial point;

[0157] According to the dot product result and the distance value, the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map is generated.

[0158] Optionally, the generating module 120 is specifically configured to use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map if the dot product result is greater than 0; and use the negative number of the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map if the dot product result is less than or equal to 0.

[0159] Optionally, the generating module 120 is specifically used to determine whether the signed distance field information of the target second pixel point in the current target signed distance field texture map is greater than a preset threshold, and the target second pixel point is any pixel point among the second pixel points;

[0160] If yes, determining the initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map;

[0161] The signed distance field information of the target second pixel point in the current target signed distance field texture map is generated according to the initial signed distance field information and the length of the unit pixel side length in the target signed distance field texture map mapped to the world space.

[0162] Optionally, the device further comprises: an adjustment module;

[0163] The adjustment module is used to adjust the signed distance field information of the first pixel point in the generated current target signed distance field texture map to the signed distance field information of the first pixel point in the previous target signed distance field texture map if the absolute value of the signed distance field information of the first pixel point in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel point in the previous target signed distance field texture map.

[0164] Optionally, the device further comprises: a rendering module;

[0165] The rendering module is used to render the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.

[0166] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0167] The above modules can be connected or communicated with each other via a wired connection or a wireless connection. The wired connection may include a metal cable, an optical cable, a hybrid cable, etc., or any combination thereof. The wireless connection may include a connection in the form of a LAN, a WAN, Bluetooth, a ZigBee, or NFC, or any combination thereof. Two or more modules may be combined into a single module, and any one module may be divided into two or more units. Those skilled in the art will clearly understand that for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application.

[0168] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application includes: a processor 801, a storage medium 802 and a bus 803, wherein the storage medium 802 stores machine-readable instructions executable by the processor 801. When the electronic device runs a method for generating a directed distance field in an embodiment, the processor 801 communicates with the storage medium 802 through the bus 803, and the processor 801 executes the machine-readable instructions to perform the following steps:

[0169] Determine, according to pixel coordinate information of a first pixel point in the current target signed distance field texture map, spatial coordinate information of a first spatial point in the world space mapped from the first pixel point;

[0170] Determine, according to the pixel coordinate information of the first pixel and the preset rasterization direction, each adjacent pixel corresponding to the first pixel, and determine, according to the pixel coordinate information of each adjacent pixel, the spatial coordinate information of each adjacent spatial point in the world space mapped from each adjacent pixel;

[0171] Generate the signed distance field information of the first pixel point and the signed distance field information of the adjacent pixel points in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point;

[0172] According to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, the signed distance field information of each second pixel point in the current target signed distance field texture map is generated respectively, and the second pixel point is the remaining pixel point in the target signed distance field except the first pixel point and each adjacent pixel point.

[0173] In a feasible implementation, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map;

[0174] The target signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same size to store the signed distance field information of each spatial point in the corresponding world space range, and each pixel point in each layer of texture maps stores the signed distance field information of the corresponding spatial point; wherein the world space range corresponding to each layer of texture maps is determined according to the distance between the world space range and the virtual camera.

[0175] In a feasible implementation manner, before executing the process of determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the processor 801 is further used to: if the current target signed distance field texture map is a static scene signed distance field texture map, determine the overlapping area and non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to the world space range corresponding to the current target signed distance field texture map and the world space range corresponding to the previous target signed distance field texture map;

[0176] According to the signed distance field information of each pixel in the overlapping area in the previous target signed distance field texture map, the signed distance field information of each pixel in the overlapping area in the current target signed distance field texture map is updated;

[0177] Initialize the signed distance field information of each pixel in the non-overlapping area of ​​the current target signed distance field texture map to a preset value, and the first pixel point is a pixel point in the non-overlapping area.

[0178] In a feasible implementation scheme, before executing the process of determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space based on the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the processor 801 is also used to: if the target signed distance field texture map is a dynamic scene signed distance field texture map, initialize the signed distance field information of each pixel in the current target signed distance field texture map to a preset value, and the first pixel point is any pixel point in the current target signed distance field texture map.

[0179] In a feasible implementation manner, when the processor 801 is executing to determine the adjacent pixel points corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and the preset rasterization direction, it is specifically used to: determine the pixel points along the first rasterization direction and adjacent to the first pixel point by a preset number as the first adjacent pixel points corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and the first rasterization direction;

[0180] According to the pixel coordinate information of the first pixel point and the second rasterization direction, determining that a preset number of pixel points along the second rasterization direction and adjacent to the first pixel point are second adjacent pixel points corresponding to the first pixel point;

[0181] According to the pixel coordinate information of the first pixel point and the third rasterization direction, a preset number of pixel points along the third rasterization direction and adjacent to the first pixel point are determined as third adjacent pixel points corresponding to the first pixel point.

[0182] In a feasible implementation manner, when the processor 801 generates the signed distance field information of the first pixel point in the current target signed distance field texture map and the signed distance field information of each adjacent pixel point according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the processor 801 is specifically used to: generate the signed distance field information of the first pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point and the depth information of the triangle patch corresponding to the first spatial point;

[0183] The signed distance field information of each adjacent pixel point in the current target signed distance field texture map is generated according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point.

[0184] In a feasible implementation scheme, when the processor 801 generates the directed distance field information of each adjacent pixel point in the current target directed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the processor 801 is specifically used to: determine the distance value between the target adjacent spatial point and the first spatial point according to the spatial coordinate information of the target adjacent spatial point and the spatial coordinate information of the first spatial point, where the target adjacent spatial point is any adjacent spatial point among the adjacent spatial points;

[0185] A dot product result of the first spatial point, the direction vector of the target adjacent spatial point and the normal of the first spatial point;

[0186] According to the dot product result and the distance value, the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map is generated.

[0187] In a feasible implementation manner, when the processor 801 generates the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value, it is specifically configured to: if the dot product result is greater than 0, use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map;

[0188] If the dot product result is less than or equal to 0, the negative of the distance value is used as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.

[0189] In a feasible implementation manner, when the processor 801 generates the signed distance field information of each second pixel point in the current target signed distance field texture map according to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, it is specifically used to: determine whether the signed distance field information of the target second pixel point in the current target signed distance field texture map is greater than a preset threshold, and the target second pixel point is any pixel point among the second pixel points;

[0190] If yes, determining the initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map;

[0191] The signed distance field information of the target second pixel point in the current target signed distance field texture map is generated according to the initial signed distance field information and the length of the unit pixel side length in the target signed distance field texture map mapped to the world space.

[0192] In a feasible implementation manner, after executing the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel to generate the signed distance field information of each second pixel in the current target signed distance field texture map, the processor 801 is further configured to: if the absolute value of the signed distance field information of the first pixel in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel in the previous target signed distance field texture map, adjust the signed distance field information of the first pixel in the generated current target signed distance field texture map to the signed distance field information of the first pixel in the previous target signed distance field texture map.

[0193] In a feasible implementation, the processor 801 is further configured to render the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.

[0194] Through the above method, the electronic device can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.

[0195] The storage medium 802 stores program codes. When the program codes are executed by the processor 801, the processor 801 executes various steps of the method for generating a directed distance field according to various exemplary embodiments of the present application described in the above “Exemplary Method” section of this specification.

[0196] Processor 801 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor (DigitalSignal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.

[0197] Storage medium 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic memory, disk, optical disk, etc. The memory is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The storage medium 802 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0198] Optionally, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor performs the following steps:

[0199] Determine, according to pixel coordinate information of a first pixel point in the current target signed distance field texture map, spatial coordinate information of a first spatial point in the world space mapped from the first pixel point;

[0200] Determine, according to the pixel coordinate information of the first pixel and the preset rasterization direction, each adjacent pixel corresponding to the first pixel, and determine, according to the pixel coordinate information of each adjacent pixel, the spatial coordinate information of each adjacent spatial point in the world space mapped from each adjacent pixel;

[0201] Generate the signed distance field information of the first pixel point and the signed distance field information of the adjacent pixel points in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point;

[0202] According to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, the signed distance field information of each second pixel point in the current target signed distance field texture map is generated respectively, and the second pixel point is the remaining pixel point in the target signed distance field except the first pixel point and each adjacent pixel point.

[0203] In a feasible implementation, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map;

[0204] The target signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same size to store the signed distance field information of each spatial point in the corresponding world space range, and each pixel point in each layer of texture maps stores the signed distance field information of the corresponding spatial point; wherein the world space range corresponding to each layer of texture maps is determined according to the distance between the world space range and the virtual camera.

[0205] In a feasible implementation manner, before executing the process of determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the processor 801 is further used to: if the current target signed distance field texture map is a static scene signed distance field texture map, determine the overlapping area and non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to the world space range corresponding to the current target signed distance field texture map and the world space range corresponding to the previous target signed distance field texture map;

[0206] According to the signed distance field information of each pixel in the overlapping area in the previous target signed distance field texture map, the signed distance field information of each pixel in the overlapping area in the current target signed distance field texture map is updated;

[0207] The signed distance field information of each pixel in the non-overlapping area in the current target signed distance field texture map is initialized to a preset value, and the first pixel point is a pixel point in the non-overlapping area.

[0208] In a feasible implementation scheme, before executing the process of determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space based on the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the processor 801 is also used to: if the target signed distance field texture map is a dynamic scene signed distance field texture map, initialize the signed distance field information of each pixel in the current target signed distance field texture map to a preset value, and the first pixel point is any pixel point in the current target signed distance field texture map.

[0209] In a feasible implementation manner, when the processor 801 is executing to determine the adjacent pixel points corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and the preset rasterization direction, it is specifically used to: determine the pixel points along the first rasterization direction and adjacent to the first pixel point by a preset number as the first adjacent pixel points corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and the first rasterization direction;

[0210] According to the pixel coordinate information of the first pixel point and the second rasterization direction, determining that a preset number of pixel points along the second rasterization direction and adjacent to the first pixel point are second adjacent pixel points corresponding to the first pixel point;

[0211] According to the pixel coordinate information of the first pixel point and the third rasterization direction, a preset number of pixel points along the third rasterization direction and adjacent to the first pixel point are determined as third adjacent pixel points corresponding to the first pixel point.

[0212] In a feasible implementation manner, when the processor 801 generates the signed distance field information of the first pixel point in the current target signed distance field texture map and the signed distance field information of each adjacent pixel point according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the processor 801 is specifically used to: generate the signed distance field information of the first pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point and the depth information of the triangle patch corresponding to the first spatial point;

[0213] The signed distance field information of each adjacent pixel point in the current target signed distance field texture map is generated according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point.

[0214] In a feasible implementation scheme, when the processor 801 generates the directed distance field information of each adjacent pixel point in the current target directed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the processor 801 is specifically used to: determine the distance value between the target adjacent spatial point and the first spatial point according to the spatial coordinate information of the target adjacent spatial point and the spatial coordinate information of the first spatial point, where the target adjacent spatial point is any adjacent spatial point among the adjacent spatial points;

[0215] A dot product result of the first spatial point, the direction vector of the target adjacent spatial point and the normal of the first spatial point;

[0216] According to the dot product result and the distance value, the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map is generated.

[0217] In a feasible implementation manner, when the processor 801 generates the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value, it is specifically configured to: if the dot product result is greater than 0, use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map;

[0218] If the dot product result is less than or equal to 0, the negative of the distance value is used as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.

[0219] In a feasible implementation manner, when the processor 801 generates the signed distance field information of each second pixel point in the current target signed distance field texture map according to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, it is specifically used to: determine whether the signed distance field information of the target second pixel point in the current target signed distance field texture map is greater than a preset threshold, and the target second pixel point is any pixel point among the second pixel points;

[0220] If yes, determining the initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map;

[0221] The signed distance field information of the target second pixel point in the current target signed distance field texture map is generated according to the initial signed distance field information and the length of the unit pixel side length in the target signed distance field texture map mapped to the world space.

[0222] In a feasible implementation manner, after executing the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel to generate the signed distance field information of each second pixel in the current target signed distance field texture map, the processor 801 is further configured to: if the absolute value of the signed distance field information of the first pixel in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel in the previous target signed distance field texture map, adjust the signed distance field information of the first pixel in the generated current target signed distance field texture map to the signed distance field information of the first pixel in the previous target signed distance field texture map.

[0223] In a feasible implementation, the processor 801 is further configured to render the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.

[0224] Through the above method, the electronic device can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.

[0225] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.

[0226] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0227] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0228] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0229] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

Claims

1. A method for generating a signed distance field, characterized in that: include: Determine, according to pixel coordinate information of a first pixel point in the current target signed distance field texture map, spatial coordinate information of a first spatial point in the world space mapped from the first pixel point; Determine, according to the pixel coordinate information of the first pixel and a preset rasterization direction, each adjacent pixel corresponding to the first pixel, and determine, according to the pixel coordinate information of each adjacent pixel, spatial coordinate information of each adjacent spatial point in the world space mapped from each adjacent pixel; Generate, according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map; According to the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point, the signed distance field information of each second pixel point in the current target signed distance field texture map is generated respectively, where the second pixel point is the remaining pixel point in the target signed distance field except the first pixel point and the adjacent pixel points.

2. The method according to claim 1, characterized in that The target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map; The target signed distance field texture map includes multiple layers of texture maps, each layer of texture maps uses the same size to store the signed distance field information of each spatial point in the corresponding world space range, and each pixel point in each layer of texture maps stores the signed distance field information of the corresponding spatial point; wherein the world space range corresponding to each layer of texture maps is determined according to the distance between the world space range and the virtual camera.

3. The method according to claim 2, characterized in that Before determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the method includes: If the current target signed distance field texture map is a static scene signed distance field texture map, determining an overlapping area and a non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to a world space range corresponding to the current target signed distance field texture map and a world space range corresponding to the previous target signed distance field texture map; According to the signed distance field information of each pixel in the overlapping area in the previous target signed distance field texture map, the signed distance field information of each pixel in the overlapping area in the current target signed distance field texture map is updated; Initialize the signed distance field information of each pixel in the non-overlapping area in the current target signed distance field texture map to a preset value, and the first pixel point is a pixel point in the non-overlapping area.

4. The method according to claim 2, characterized in that: Before determining the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map, the method includes: If the target signed distance field texture map is a dynamic scene signed distance field texture map, the signed distance field information of each pixel in the current target signed distance field texture map is initialized to a preset value, and the first pixel point is any pixel point in the current target signed distance field texture map.

5. The method according to claim 1, characterized in that The step of respectively determining adjacent pixel points corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction includes: According to the pixel coordinate information of the first pixel point and the first rasterization direction, determining that a preset number of pixel points are adjacent to the first pixel point along the first rasterization direction as first adjacent pixel points corresponding to the first pixel point; According to the pixel coordinate information of the first pixel point and the second rasterization direction, determining that a preset number of pixel points along the second rasterization direction and adjacent to the first pixel point are second adjacent pixel points corresponding to the first pixel point; According to the pixel coordinate information of the first pixel point and the third rasterization direction, a preset number of pixel points along the third rasterization direction and adjacent to the first pixel point are determined as third adjacent pixel points corresponding to the first pixel point.

6. The method according to claim 1, characterized in that The generating, according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point, the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map respectively includes: Generate the signed distance field information of the first pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point and the depth information of the triangular patch corresponding to the first spatial point; The signed distance field information of each adjacent pixel point in the current target signed distance field texture map is generated according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point.

7. The method according to claim 6, characterized in that The step of generating the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point comprises: Determine a distance value between the target adjacent spatial point and the first spatial point according to spatial coordinate information of the target adjacent spatial point and the spatial coordinate information of the first spatial point, wherein the target adjacent spatial point is any adjacent spatial point among the adjacent spatial points; A dot product result of the first spatial point, the direction vector of the target adjacent spatial point and the normal of the first spatial point; According to the dot product result and the distance value, the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map is generated.

8. The method according to claim 7, characterized in that Generating the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value includes: If the dot product result is greater than 0, the distance value is used as the signed distance field information of the target adjacent pixel point in the current target signed distance field texture map; If the dot product result is less than or equal to 0, the negative number of the distance value is used as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.

9. The method according to claim 1, characterized in that: Generating the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, respectively, comprises: Determine whether the signed distance field information of the target second pixel point in the current target signed distance field texture map is greater than a preset threshold, the target second pixel point being any pixel point among the second pixel points; If yes, determining the initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map; The signed distance field information of the target second pixel point in the current target signed distance field texture map is generated according to the initial signed distance field information and the length of the unit pixel side length in the target signed distance field texture map mapped to the world space.

10. The method according to claim 1, characterized in that After respectively generating the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, the method further includes: If the absolute value of the signed distance field information of the first pixel in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel in the previous target signed distance field texture map, the signed distance field information of the first pixel in the generated current target signed distance field texture map is adjusted to the signed distance field information of the first pixel in the previous target signed distance field texture map.

11. The method according to any one of claims 1 to 10, characterized in that: Also includes: The current frame is rendered according to the signed distance field information of each pixel point in the current target signed distance field texture map.

12. A device for generating a signed distance field, characterized in that: include: Determine modules and generate modules; The determination module is used to determine the spatial coordinate information of a first spatial point in the world space mapped from the first pixel point according to the pixel coordinate information of the first pixel point in the current target signed distance field texture map; The determination module is used to determine each adjacent pixel point corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction, and determine the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space according to the pixel coordinate information of each adjacent pixel point; The generating module is used to generate the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of each adjacent spatial point and the normal direction of the first spatial point; The generating module is used to generate the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, wherein the second pixel is the remaining pixel in the target signed distance field except the first pixel and the adjacent pixel.

13. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the program instructions to implement the method for generating a directed distance field according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method for generating a signed distance field according to any one of claims 1 to 11 is executed.

Citation Information

Patent Citations

  • Illumination rendering method and device, electronic equipment and storage medium

    CN115115747A

  • Material recovery method, three-dimensional model generation method and model training method

    CN115375847A