WO2024251027A1 - Procédé et appareil de génération de champ de distance signé, dispositif électronique et support de stockage - Google Patents
Procédé et appareil de génération de champ de distance signé, dispositif électronique et support de stockage Download PDFInfo
- Publication number
- WO2024251027A1 WO2024251027A1 PCT/CN2024/096366 CN2024096366W WO2024251027A1 WO 2024251027 A1 WO2024251027 A1 WO 2024251027A1 CN 2024096366 W CN2024096366 W CN 2024096366W WO 2024251027 A1 WO2024251027 A1 WO 2024251027A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- distance field
- pixel
- signed distance
- point
- texture map
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—Three-dimensional [3D] image rendering
- G06T15/04—Texture mapping
Definitions
- the present disclosure 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.
- SDF Space Distance Field
- the SDF value of a spatial point is obtained through the depth information of the spatial point.
- 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.
- a method for generating a signed distance field including: determining spatial coordinate information of a first pixel in a current target signed distance field texture map mapped to a first spatial point in a world space according to pixel coordinate information of a first pixel; determining adjacent pixels corresponding to the first pixel according to the pixel coordinate information of the first pixel and a preset rasterization direction, and determining spatial coordinate information of adjacent spatial points mapped to the world space according to the pixel coordinate information of the adjacent pixels; generating the signed distance field information of the first pixel and the signed distance field information of the adjacent pixels 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; generating the signed distance field information of the 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 the adjacent pixels, the second pixel being the remaining pixel in the target signed distance
- a device for generating a signed distance field comprising: a determination module and a generation module; the determination module is used to determine the spatial coordinate information of the first pixel mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel in the current target signed distance field texture map; the determination module is used to determine the adjacent pixels corresponding to the first pixel according to the pixel coordinate information of the first pixel and a preset rasterization direction, and determine the spatial coordinate information of the adjacent pixels mapped to the adjacent spatial points in the world space according to the pixel coordinate information of the adjacent pixels; the generation module is used to generate the signed distance field information of the first pixel and the signed distance field information of the adjacent pixels 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; the generation module is used to generate the signed distance field information of the second pixel in the current target signed distance field texture map according to the signed
- an electronic device including: a processor, a storage medium and a bus, the storage medium storing 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 as provided in the first aspect.
- a computer-readable storage medium on which a computer program is stored.
- the computer program is executed by a processor, the method for generating a signed distance field as provided in the first aspect is executed.
- the present disclosure 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.
- the spatial coordinate information is the actual position information of the spatial point
- the SDF itself represents the closest 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 the traditional calculation relies on the depth information 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.
- this scheme adopts the method of separate storage of dynamic and static scene SDF, and stores the SDF value of static scene in the SDF texture map of static scene, and stores the SDF value of dynamic scene in the SDF texture map of dynamic scene. Since the SDF value of static scene does not need to be updated every time, the amount of calculation when generating SDF value can be effectively reduced.
- this scheme uses SDF texture map with multi-layer texture map to store SDF value of space point in world space, and different world space ranges are mapped with SDF texture map of the same size (same pixel size) to achieve different mapping accuracy. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of SDF texture map.
- FIG1 is a schematic diagram of a flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure
- FIG2 is a schematic diagram of an SDF texture map provided by an embodiment of the present disclosure.
- FIG3 is a second flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure
- FIG4 is a schematic diagram showing an overlapping area of an SDF texture map provided in an embodiment of the present disclosure
- FIG5 is a third flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure
- FIG6 is a schematic diagram showing a pixel point display provided by an embodiment of the present disclosure.
- FIG. 7 is a fourth flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure.
- FIG8 is a schematic diagram of a spatial point display provided by an embodiment of the present disclosure.
- FIG9 is a fifth flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure.
- FIG10 is a sixth flow chart of a method for generating a signed distance field according to an embodiment of the present disclosure
- FIG11 is a schematic diagram of a device for generating a directed distance field according to an embodiment of the present disclosure
- FIG. 12 is a schematic diagram of the structure of one of the electronic devices provided in an embodiment of the present disclosure.
- Some advanced rendering effects in games 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
- 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.
- Unreal 4 engine to calculate SDF, using the method of offline baking + real-time patchwork: 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.
- 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.
- 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.
- 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.
- FIG1 is a flow chart of a method for generating a directed distance field provided by an embodiment of the present disclosure; the execution subject of the method may be a terminal device or a computing device such as a server or a processor. As shown in FIG1 , the method may include the following steps S101-S104:
- This solution focuses on the description of the method for generating a signed distance field (hereinafter referred to as SDF).
- SDF signed distance field
- the generation of the current SDF texture corresponding to the current frame of the picture to be rendered is used for explanation.
- 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.
- 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.
- 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.
- 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.
- 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.
- the coverage box range of the SD texture map in the world space (AABB: axis-aligned bounding box) is defined.
- the minimum value of the bounding box coordinates is BBMin
- the maximum value of the bounding box coordinates is BBMax.
- 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 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.
- rasterization is performed in multiple preset directions in this embodiment.
- 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.
- each adjacent pixel point corresponding to the first pixel point can be determined in the SDF texture map.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- the generation of the SDF of the second pixel point can also be calculated in the manner of steps S101 to S103 described above.
- the second pixel point can be used as the first pixel point to perform calculations.
- 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.
- 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.
- the method for generating a signed distance field 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.
- the spatial coordinate information is the actual position information of the spatial point
- the SDF itself represents the closest 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 the traditional calculation relies on the depth information 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.
- 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 SDF value of the static scene is stored in the static scene SDF texture map
- the SDF value of the dynamic scene is stored in the dynamic scene SDF texture map. Since the SDF value of the static scene does not need to be updated, the amount of calculation when generating the SDF value can be effectively reduced.
- Static scenes can be composed of static models in the scene, such as a wall, a road, etc.
- 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.
- 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.
- FIG. 2 is a schematic diagram of an SDF texture map provided by an embodiment of the present disclosure.
- 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.
- each layer is the world space range mapped by the SDF texture map.
- the world space range to which the SDF of the space points stored in each layer of texture maps belongs 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.
- the number of textures in each layer of texture maps does not change, and 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.
- different world space ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies.
- FIG3 is a second flow chart of a method for generating a signed distance field provided by an embodiment of the present disclosure; 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 following steps S301-S303 may be included:
- 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.
- 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.
- 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.
- the first pixel in the current target SDF texture map can refer to any pixel in the non-overlapping area.
- 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.
- 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.
- 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.
- 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.
- FIG4 is a schematic diagram showing an overlapping area of an SDF texture map provided by an embodiment of the present disclosure.
- the black portion represents the overlapping area of the previous target SDF texture map and the current target SDF texture map (it is worth noting that in actual applications, texture maps are three-dimensional, but are simplified to two-dimensional for demonstration convenience).
- 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 value of the space point in the corresponding stored world space range has not changed either.
- the same pixel point in the overlapping area has not changed.
- the pixel coordinate information of the pixel in the previous target SDF texture map and in the current DF texture map is different, which means that when copying the SDF value of each pixel in the overlapping area from the previous target SDF texture map, it is necessary to copy it accordingly.
- 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 corresponds to the pixel point (0, 0, 11) in the current target SDF texture map.
- the SDF value stored in the pixel point (0, 0, 11) in the overlapping area in the current target SDF texture map is replaced with a.
- the SDF value of each pixel in the overlapping area can be obtained accordingly.
- 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.
- 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 the CellSize represents the length of a single pixel side in the SDF texture map mapped to the world space.
- the first pixel point mentioned above may be any pixel point in the non-overlapping area.
- 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.
- the SDF of all pixels in the texture map needs to be regenerated.
- 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.
- 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.
- the selection of the preset value can be adaptively adjusted according to the actual rasterization scene.
- FIG5 is a flow chart of a method for generating a signed distance field according to an embodiment of the present disclosure; as shown in FIG5 , in step S102, each adjacent pixel corresponding to the first pixel is determined according to the pixel coordinate information of the first pixel and the preset rasterization direction, which may include the following steps S501-S503:
- 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].
- 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.
- 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].
- 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.
- the third rasterization direction may be the z-axis direction.
- the first pixel may be determined by the three pixels before and after the first pixel along the z-axis direction.
- the second adjacent pixel points corresponding to the point include: [x, y, z-3], [x, y, z-2], [x, y, z-1], [x, y, z+1], [x, y, z+2], [x, y, z+3].
- FIG6 is a schematic diagram of a pixel point display provided in an embodiment of the present disclosure. As shown in FIG6 , 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.
- FIG7 is a fourth flow chart of a method for generating a signed distance field provided by an embodiment of the present disclosure; optionally, in step S103, 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 are generated respectively 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, which may include the following steps S701-S702:
- FIG8 is a schematic diagram of a spatial point display provided by an embodiment of the present disclosure.
- the depth information of the triangular facet can be obtained first, wherein the depth information of the facet can refer to the distance from the position represented by the facet to the observer (which can refer to a virtual camera).
- the depth information can be calculated by making a ray parallel to the viewing direction through a certain pixel point on the screen, and the distance from the point where the ray intersects with the facet to the pixel point is the depth of the facet.
- 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.
- 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.
- 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.
- FIG9 is a flowchart diagram 5 of a method for generating a signed distance field provided by an embodiment of the present disclosure; 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 the following steps S901-S903:
- 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.
- the target adjacent spatial point here may refer to a spatial point in the world space mapped to any pixel point except the first pixel point [x, y, z] in FIG6 .
- 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.
- 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.
- 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.
- S903 Generate a distance field texture map of the target adjacent pixels according to the dot product result and the distance value. Distance field information.
- 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 is obtained, such as the SDF value of the pixel point [x-1, y, z] shown in Figure 6.
- the calculation of the SDF value of any adjacent pixel point other than the first pixel point [x, y, z] shown in FIG6 can be performed one by one according to the above calculation method, so as to obtain the SDF value of each adjacent pixel point corresponding to the first pixel point.
- 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.
- 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.
- 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.
- 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.
- the target adjacent spatial point is located on the inner side of the triangle corresponding to the first spatial point.
- 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.
- FIG10 is a flowchart of the sixth method for generating a signed distance field according to an embodiment of the present disclosure; optionally, in step S104, the signed distance field information of each second pixel in the current target signed distance field texture map is generated according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, which may include the following steps S1001-S1003:
- 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.
- the SDF value of the target second pixel point is initialized to 4*CellSize.
- 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.
- 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.
- 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.
- 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.
- the current update logic can be skipped, that is, the SDF value of the target second pixel remains unchanged.
- 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.
- 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.
- 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.
- 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.
- 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.
- the method of the present disclosure 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.
- 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.
- 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.
- 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.
- stepping rays are 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.
- the method for generating a signed distance field 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.
- 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, breaking away from the traditional reliance on spatial coordinate information.
- the lack of depth information leads to poor accuracy of the calculation result.
- 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, effectively improving the accuracy of the calculation result.
- this scheme adopts the method of separate storage of dynamic and static scene SDF, and stores the SDF value of static scene in the SDF texture map of static scene, and stores the SDF value of dynamic scene in the SDF texture map of dynamic scene. Since the SDF value of static scene does not need to be updated every time, the amount of calculation when generating SDF value can be effectively reduced.
- this scheme uses SDF texture map with multi-layer texture map to store SDF value of space point in world space, and different world space ranges are mapped with SDF texture map of the same size (same pixel size) to achieve different mapping accuracy. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of SDF texture map.
- FIG11 is a schematic diagram of a device for generating a directed distance field provided by an embodiment of the present disclosure.
- the functions implemented by the device for generating a directed distance field correspond to the steps performed by the above-mentioned method for generating a directed distance field.
- the device can be understood as the above-mentioned terminal device or server, or a processor of the server, or can also be understood as a component independent of the above-mentioned server or processor that implements the functions of the present disclosure under the control of the server.
- the device may include: a determination module 110, a generation module 120;
- the determination module 110 is used to determine the spatial coordinate information of the first pixel mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel in the current target signed distance field texture map; the determination module 110 is used to determine the adjacent pixels corresponding to the first pixel according to the pixel coordinate information of the first pixel and the preset rasterization direction, and determine the spatial coordinate information of the adjacent spatial points mapped to the world space according to the pixel coordinate information of the adjacent pixels; the generation module 120 is used to generate the directed distance field information of the first pixel and the directed distance field information of the adjacent pixels 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; the generation module 120 is used to generate the directed distance field information of the second pixel in the current target signed distance field texture map according to the directed distance field information of the first pixel and the directed distance field information of the adjacent pixel, the second pixel being the remaining pixel in the target directed distance field except
- 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 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.
- the SDF value of the static scene is stored in the static scene SDF texture map
- the SDF value of the dynamic scene is stored in the dynamic scene SDF texture map. Since the SDF value of the static scene does not need to be updated, the amount of calculation when generating the SDF value can be effectively reduced.
- the device also includes: an updating module and an initialization module; a determining module 110, further used to determine the overlapping area and non-overlapping area of 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 if the current target signed distance field texture map is a static scene signed distance field texture map; an updating module, used 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; and an initialization module, 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.
- the initialization module is also 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.
- Initializing the signed distance field information of each pixel in the current target signed distance field texture map to a preset value by the initialization module can avoid the technical problem that obstacles will be jumped over during the ray stepping process and the accurate result of the ray stepping cannot be obtained, thereby making the calculation result more accurate, getting 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 effectively improving the accuracy of the calculation result.
- the determination module 110 is specifically used to determine, based on the pixel coordinate information of the first pixel point and the first rasterization direction, that each pixel point that is adjacent to the first pixel point for a preset number along the first rasterization direction is first adjacent pixel points corresponding to the first pixel point; based on the pixel coordinate information of the first pixel point and the second rasterization direction, determine that each pixel point that is adjacent to the first pixel point for a preset number along the second rasterization direction is second adjacent pixel points corresponding to the first pixel point; based on the pixel coordinate information of the first pixel point and the third rasterization direction, determine that each pixel point that is adjacent to the first pixel point for a preset number along the third rasterization direction is third adjacent pixel points corresponding to the first pixel point.
- the generation module 120 is specifically used to generate the signed distance field information of the first pixel point in the current target signed distance field texture map based on the spatial coordinate information of the first spatial point and the depth information of the triangular patch corresponding to the first spatial point; and to generate the signed distance field information of each adjacent pixel point in the current target signed distance field texture map based on 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 generation module 120 is specifically used to generate a distance value between a target adjacent spatial point and a first spatial point based on spatial coordinate information of the target adjacent spatial point and spatial coordinate information of the first spatial point, where the target adjacent spatial point is any adjacent spatial point among the adjacent spatial points; based on a dot product result of the first spatial point and the direction vector of the target adjacent spatial point and a normal of the first spatial point; and based on the dot product result and the distance value, generate the directed distance field information of the target adjacent pixel points in the current target directed distance field texture map.
- 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.
- the generating module 120 is specifically configured 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, where the target second pixel point is any pixel point among the second pixel points; if so, determine 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; and 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 world space.
- the device further includes: an adjustment module; 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.
- an 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.
- the device further includes: a rendering module; 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.
- the spatial coordinate information of the first pixel point to be generated 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 can be obtained to generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point respectively.
- the spatial coordinate information is the actual position information of the spatial point
- SDF itself represents the closest distance between a spatial point and a 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 the traditional calculation relies on the depth information 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, effectively improving the accuracy of the calculation result.
- 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).
- ASIC application specific integrated circuits
- DSP digital singnal processors
- FPGA field programmable gate arrays
- the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code.
- CPU central processing unit
- these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
- SOC system-on-a-chip
- 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 module may be divided into two or more units.
- FIG12 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure, including: 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.
- the processor 801 communicates with the storage medium 802 via the bus 803, and the processor 801 executes the machine-readable instructions to perform the following steps:
- the spatial coordinate information of the first pixel mapped to the first spatial point in the world space is determined; according to the pixel coordinate information of the first pixel and the preset rasterization direction, the adjacent pixels corresponding to the first pixel are determined respectively, and according to the pixel coordinate information of the adjacent pixels, the spatial coordinate information of the adjacent spatial points in the world space mapped to the adjacent pixels is determined; 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, the signed distance field information of the first pixel and the signed distance field information of the adjacent pixels in the current target signed distance field texture map are generated respectively; according to the signed distance field information of the first pixel and the signed distance field information of the adjacent pixels, the signed distance field information of the second pixels in the current target signed distance field texture map is generated respectively, and the second pixels are the remaining pixels in the target signed distance field except the first pixel and the adjacent pixels.
- 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 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.
- the SDF value of the static scene is stored in the static scene SDF texture map
- the SDF value of the dynamic scene is stored in the dynamic scene SDF texture map. Since the SDF value of the static scene does not need to be updated, the amount of calculation when generating the SDF value can be effectively reduced.
- the processor 801 determines 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, it is further used to: if the current target signed distance field texture map is a static scene signed distance field texture map, then 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, determine the overlapping area and non-overlapping area of the current target signed distance field texture map and the previous target signed distance field texture map; according to the previous target signed distance field texture map The signed distance field information of each pixel in the overlapping area of the departure texture map is updated for the signed distance field information of each pixel in the overlapping area of the current target signed distance field texture map; the signed distance field information of each pixel in the non-overlapping area of 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-
- the processor 801 determines the spatial coordinate information of the first spatial point mapped to the world space according to the pixel coordinate information of the first pixel in the current target signed distance field texture map, it 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 is any pixel in the current target 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 can avoid the technical problem that obstacles will be skipped during the ray stepping process and the accurate result of the ray stepping cannot be obtained, thereby making the calculation result more accurate.
- the processor 801 determines the 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, it is specifically used to: determine, according to the pixel coordinate information of the first pixel point and the first rasterization direction, the pixel points along the first rasterization direction and a preset number of which are adjacent to the first pixel point as the first adjacent pixel points corresponding to the first pixel point; determine, according to the pixel coordinate information of the first pixel point and the second rasterization direction, the pixel points along the second rasterization direction and a preset number of which are adjacent to the first pixel point as the second adjacent pixel points corresponding to the first pixel point; determine, according to the pixel coordinate information of the first pixel point and the third rasterization direction, the pixel points along the third rasterization direction and a preset number of which are adjacent to the first pixel point as the third adjacent pixel points corresponding to
- the processor 801 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, it 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; generate 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 processor 801 when the processor 801 generates 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, it 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; generate the signed distance field information of the target adjacent pixel point in the current target signed distance field texture map according to the dot product result of the first spatial point and the direction vector of the target adjacent spatial point and the normal of the first spatial point; and generate the signed distance field information of the target adjacent pixel point in the current target signed distance field texture map according to the dot product result and the distance value.
- the processor 801 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; if the dot product result is less than or equal to 0, use the negative 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.
- the processor 801 when the processor 801 generates 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 processor 801 is specifically used to: determine whether the signed distance field information of the target second pixel in the current target signed distance field texture map is greater than a preset threshold, and the target second pixel is any pixel among the second pixels; if so, determine the initial signed distance field information according to the signed distance field information of each preset adjacent pixel of the target second pixel in the current target signed distance field texture map; generate the current 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 world space; The signed distance field information of the second pixel point of the target in the target signed distance field texture map.
- the processor 801 is further used 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, then 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.
- 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.
- 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.
- the spatial coordinate information is the actual position information of the spatial point
- the SDF itself represents the closest 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 the traditional calculation relies on the depth information 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.
- the storage medium 802 stores program codes.
- the processor 801 executes various steps of the method for generating a directed distance field according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
- Processor 801 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and may implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure.
- a general-purpose processor may be a microprocessor or any conventional processor, etc.
- the steps of the method disclosed in conjunction with the embodiments of the present disclosure may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
- the storage medium 802 is a non-volatile computer-readable storage medium that 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.
- flash memory 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
- the memory is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
- the storage medium 802 in the embodiment of the present disclosure can also be a circuit or any other device that can realize the storage function, which is used to store program instructions and/or data.
- an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored.
- the processor executes the following steps:
- the invention relates to a method for generating a texture map of a first spatial point in a target signed distance field; determining the adjacent pixels corresponding to the first pixel according to the pixel coordinate information of the first pixel and a preset rasterization direction, and determining the spatial coordinate information of the adjacent spatial points in the world space mapped to the adjacent pixels according to the pixel coordinate information of the adjacent pixels; generating the signed distance field information of the first pixel and the signed distance field information of the adjacent pixels 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; generating the signed distance field information of the second pixels 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 the adjacent pixels, wherein the second pixels are the remaining pixels in the target signed distance field except the first pixel
- 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 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.
- the SDF value of the static scene is stored in the static scene SDF texture map
- the SDF value of the dynamic scene is stored in the dynamic scene SDF texture map. Since the SDF value of the static scene does not need to be updated, the amount of calculation when generating the SDF value can be effectively reduced.
- the processor 801 before executing the process of determining the spatial coordinate information of the first pixel mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel 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; update the signed distance field information of each pixel in the overlapping area in the current 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; 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.
- the processor 801 determines the spatial coordinate information of the first pixel mapped to the first spatial point in the world space according to the pixel coordinate information of the first pixel in the current target signed distance field texture map, it is also used to: 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 is any pixel in the current target 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 can avoid the technical problem that obstacles will be skipped during the ray stepping process and the accurate result of the ray stepping cannot be obtained, thereby making the calculation result more accurate, getting 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 effectively improving the accuracy of the calculation result.
- the processor 801 determines the 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, it is specifically used to: determine, according to the pixel coordinate information of the first pixel point and the first rasterization direction, the pixel points along the first rasterization direction and a preset number of which are adjacent to the first pixel point as the first adjacent pixel points corresponding to the first pixel point; determine, according to the pixel coordinate information of the first pixel point and the second rasterization direction, the pixel points along the second rasterization direction and a preset number of which are adjacent to the first pixel point as the second adjacent pixel points corresponding to the first pixel point; determine, according to the pixel coordinate information of the first pixel point and the third rasterization direction, the pixel points along the third rasterization direction and a preset number of which are adjacent to the first pixel point as the third adjacent pixel points corresponding to
- the processor 801 generates the first 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 signed distance field information and the signed distance field information of each adjacent pixel point are generated, it 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 triangular facet corresponding to the first spatial point; generate 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 processor 801 when the processor 801 generates 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, it 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; generate the signed distance field information of the target adjacent pixel point in the current target signed distance field texture map according to the dot product result of the first spatial point and the direction vector of the target adjacent spatial point and the normal of the first spatial point; and generate the signed distance field information of the target adjacent pixel point in the current target signed distance field texture map according to the dot product result and the distance value.
- the processor 801 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; if the dot product result is less than or equal to 0, use the negative 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.
- the processor 801 when the processor 801 generates 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 processor 801 is specifically used to: determine whether the signed distance field information of the target second pixel in the current target signed distance field texture map is greater than a preset threshold, where the target second pixel is any pixel among the second pixels; if so, determine the initial signed distance field information according to the signed distance field information of each preset adjacent pixel of the target second pixel in the current target signed distance field texture map; and generate the signed distance field information of the target second pixel 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 world space.
- the processor 801 is further used 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, then 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.
- 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.
- 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.
- the spatial coordinate information is the actual position information of the spatial point
- the SDF itself represents the closest 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 the traditional calculation relies on the depth information 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.
- the computer program can also execute other machine-readable instructions when it is executed by the processor to implement the following
- the description of the embodiment please refer to the description of the embodiment for the specific implementation steps and principles, which will not be described in detail here.
- the disclosed devices and methods can be implemented in other ways.
- the device embodiments described above are only schematic.
- the division of units is only a logical function division. There may be other division methods in actual implementation.
- 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.
- 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.
- each functional unit in each embodiment of the present disclosure may be integrated into a 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.
- the above-mentioned integrated unit implemented in the form of a software functional unit may be stored in a computer-readable storage medium.
- the above-mentioned software functional unit is stored in a storage medium, including several instructions for a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present disclosure.
- the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, referred to as: ROM), random access memory (English: Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program code.
- ROM Read-Only Memory
- RAM Random Access Memory
Landscapes
- Engineering & Computer Science (AREA)
- Computer Graphics (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Generation (AREA)
Abstract
La présente invention concerne un procédé de génération d'un champ de distance signé (SDF), le procédé comprenant : l'acquisition d'informations de coordonnées spatiales d'un premier point spatial, auquel est mappé un premier point de pixel dont une valeur de champ SDF doit être générée, dans un espace du monde, et d'informations de coordonnées spatiales de points spatiaux adjacents, auxquels sont mappés des points de pixel adjacents correspondant au premier point de pixel, dans l'espace du monde, de sorte que la valeur de champ SDF du premier point de pixel et des valeurs de champ SDF des points de pixel adjacents peuvent être respectivement générées. Puisque des informations de coordonnées spatiales sont des informations de position réelle d'un point spatial, et qu'un champ SDF représente lui-même la distance la plus courte entre le point spatial et un objet dans une scène, l'utilisation directe des informations de position réelle du point spatial pour calculer le champ SDF peut rendre la précision d'un résultat de calcul relativement élevée, ce qui permet d'éliminer le problème de la précision d'un résultat de calcul relativement médiocre en raison de l'absence d'informations de profondeur lorsque le calcul est réalisé, par convention, au moyen des informations de profondeur de points spatiaux.
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310680194.3A CN116704098B (zh) | 2023-06-08 | 2023-06-08 | 有向距离场的生成方法、装置、电子设备及存储介质 |
| CN202310680194.3 | 2023-06-08 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024251027A1 true WO2024251027A1 (fr) | 2024-12-12 |
Family
ID=87830691
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/096366 Ceased WO2024251027A1 (fr) | 2023-06-08 | 2024-05-30 | Procédé et appareil de génération de champ de distance signé, dispositif électronique et support de stockage |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN116704098B (fr) |
| WO (1) | WO2024251027A1 (fr) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116704098B (zh) * | 2023-06-08 | 2025-03-04 | 网易(杭州)网络有限公司 | 有向距离场的生成方法、装置、电子设备及存储介质 |
| CN117152237A (zh) * | 2023-09-25 | 2023-12-01 | 不鸣科技(杭州)有限公司 | 一种距离场生成方法、装置、电子设备及存储介质 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107452048A (zh) * | 2016-05-30 | 2017-12-08 | 网易(杭州)网络有限公司 | 全局光照的计算方法及装置 |
| CN114820836A (zh) * | 2021-01-28 | 2022-07-29 | 北京字跳网络技术有限公司 | 有向距离场图像、文字效果图像生成方法、设备及介质 |
| CN115115747A (zh) * | 2021-03-09 | 2022-09-27 | 网易(杭州)网络有限公司 | 光照渲染方法、装置、电子设备及存储介质 |
| US20230082839A1 (en) * | 2021-09-10 | 2023-03-16 | Adobe Inc. | Rendering scalable raster content |
| CN116704098A (zh) * | 2023-06-08 | 2023-09-05 | 网易(杭州)网络有限公司 | 有向距离场的生成方法、装置、电子设备及存储介质 |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113012210B (zh) * | 2021-03-25 | 2022-09-27 | 北京百度网讯科技有限公司 | 深度图的生成方法、装置、电子设备和存储介质 |
| CN115375847B (zh) * | 2022-08-25 | 2023-08-29 | 北京百度网讯科技有限公司 | 材质恢复方法、三维模型的生成方法和模型的训练方法 |
-
2023
- 2023-06-08 CN CN202310680194.3A patent/CN116704098B/zh active Active
-
2024
- 2024-05-30 WO PCT/CN2024/096366 patent/WO2024251027A1/fr not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107452048A (zh) * | 2016-05-30 | 2017-12-08 | 网易(杭州)网络有限公司 | 全局光照的计算方法及装置 |
| CN114820836A (zh) * | 2021-01-28 | 2022-07-29 | 北京字跳网络技术有限公司 | 有向距离场图像、文字效果图像生成方法、设备及介质 |
| CN115115747A (zh) * | 2021-03-09 | 2022-09-27 | 网易(杭州)网络有限公司 | 光照渲染方法、装置、电子设备及存储介质 |
| US20230082839A1 (en) * | 2021-09-10 | 2023-03-16 | Adobe Inc. | Rendering scalable raster content |
| CN116704098A (zh) * | 2023-06-08 | 2023-09-05 | 网易(杭州)网络有限公司 | 有向距离场的生成方法、装置、电子设备及存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116704098B (zh) | 2025-03-04 |
| CN116704098A (zh) | 2023-09-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12347016B2 (en) | Image rendering method and apparatus, device, medium, and computer program product | |
| CN113808241B (zh) | 共享顶点的射线追踪图元的硬件加速 | |
| JP7606007B2 (ja) | 3dモデリングを強化するために一時的なテクスチャアプリケーションを提供する方法及びシステム | |
| CN111369655B (zh) | 渲染方法、装置和终端设备 | |
| US9098930B2 (en) | Stereo-aware image editing | |
| CN111243071A (zh) | 实时三维人体重建的纹理渲染方法、系统、芯片、设备和介质 | |
| US12469201B2 (en) | Illumination rendering method and apparatus, and electronic device and storage medium | |
| US9478065B2 (en) | System and method for remote generation of indirect illumination sources in three-dimensional graphics | |
| WO2024251027A1 (fr) | Procédé et appareil de génération de champ de distance signé, dispositif électronique et support de stockage | |
| CN114119853B (zh) | 图像渲染方法、装置、设备和介质 | |
| US9224233B2 (en) | Blending 3D model textures by image projection | |
| US12602858B2 (en) | Rendering method and apparatus, and device | |
| CN113643414A (zh) | 一种三维图像生成方法、装置、电子设备及存储介质 | |
| CN113570697A (zh) | 基于模型预烘焙的阴影渲染方法、装置及可读存储介质 | |
| US8872824B1 (en) | System, method, and computer program product for performing shadowing utilizing shadow maps and ray tracing | |
| KR102558739B1 (ko) | 3d 렌더링 방법 및 장치 | |
| JP3629243B2 (ja) | モデリング時の距離成分を用いてレンダリング陰影処理を行う画像処理装置とその方法 | |
| CN110276835B (zh) | 用于高效建筑覆盖区确定的方法和设备 | |
| US7586494B2 (en) | Surface detail rendering using leap textures | |
| CN116993894A (zh) | 虚拟画面的生成方法、装置、设备、存储介质及程序产品 | |
| CN115690365A (zh) | 用于管理三维模型的方法、装置、设备和介质 | |
| CN118985009A (zh) | 用于渲染三维场景的方法和系统 | |
| US12499622B2 (en) | Late stage reprojection using tessellated mesh | |
| Kim et al. | UTexGen: High‐quality texture reconstruction for large‐scale scenes using multi‐view images | |
| CN116109758B (zh) | 一种光源投影位置定位、场景渲染的方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24818559 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |