WO2024251027A1 - Method and apparatus for generating signed distance field, and electronic device and storage medium - Google Patents
Method and apparatus for generating signed distance field, and electronic device and storage medium 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
Description
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求申请日为2023年06月08日,申请号为202310680194.3,名称为“有向距离场的生成方法、装置、电子设备及存储介质”的中国专利申请的优先权,该中国专利申请的全部内容通过引用结合在本文中。This application claims priority to a Chinese patent application filed on June 8, 2023, with application number 202310680194.3 and entitled “Method, device, electronic device and storage medium for generating a directed distance field”, the entire contents of which are incorporated herein by reference.
本公开涉及图像渲染技术领域,具体而言,涉及一种有向距离场的生成方法、装置、电子设备及存储介质。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(Signed Distance Field,有向距离场)是指给定任意空间的位置点,返回这个点离空间场景物体最近的距离。SDF在光线步进技术中用于决定步进光线每次步进的距离。而光线步进技术的目的是通过发射步进光线,步进光线通过逐步步进最终与空间场景中的物体相交,而基于交点信息则可进行一系列的图像渲染操作。SDF (Signed Distance Field) refers to the return of the closest distance between a point in space and an object in the space scene given a position point in any space. SDF is used in ray marching technology to determine the distance of each step of the stepping ray. The purpose of ray marching technology is to emit stepping rays, which eventually intersect with objects in the space scene through stepping, and a series of image rendering operations can be performed based on the intersection information.
相关技术中,是通过空间点的深度信息获取空间点的SDF值,但是,仅依赖于一层深度信息,会使得深度之后的场景信息被忽略,从而导致计算得到的SDF值存在较大误差。In the related art, the SDF value of a spatial point is obtained through the depth information of the spatial point. However, relying only on one layer of depth information will cause the scene information after the depth to be ignored, resulting in a large error in the calculated SDF value.
发明内容Summary of the invention
根据本公开的一个方面,提供了一种有向距离场的生成方法,包括:根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息;根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息;根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,第二像素点为目标有向距离场中除第一像素点以及各相邻像素点之外的剩余像素点。According to one aspect of the present disclosure, a method for generating a signed distance field is provided, 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 field except the first pixel and the adjacent pixels.
根据本公开的一个方面,提供了一种有向距离场的生成装置,包括:确定模块、生成模块;确定模块,用于根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息;确定模块,用于根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息;生成模块,用于根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息;生成模块,用于根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,第二像素点为目标有向距离场中除第一像素点以及各相邻像素点之外的剩余像素点。 According to one aspect of the present disclosure, a device for generating a signed distance field is provided, 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 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 field except the first pixel and the adjacent pixels.
根据本公开的一个方面,提供了一种电子设备,包括:处理器、存储介质和总线,存储介质存储有处理器可执行的机器可读指令,当电子设备运行时,处理器与存储介质之间通过总线通信,处理器执行机器可读指令,以执实现如第一方面中提供的有向距离场的生成方法。According to one aspect of the present disclosure, an electronic device is provided, 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.
根据本公开的一个方面,提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如第一方面提供的有向距离场的生成方法。According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for generating a signed distance field as provided in the first aspect is executed.
本公开的有益效果是:The beneficial effects of the present disclosure are:
本公开提供一种有向距离场的生成方法、装置、电子设备及存储介质,该方法通过获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。并且进一步地结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。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. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.
其次,本方案采用动静场景SDF分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。另外,本方案中采用具有多层纹理贴图的SDF纹理贴图存储对应世界空间中空间点的SDF值,不同的世界空间范围使用相同大小(相同像素尺寸)的SDF纹理贴图进行映射,以实现不同映射精度。距虚拟相机越近,所需精度越大,SDF纹理贴图的映射精度越大,反之距虚拟相机越远,所需精度越小,SDF纹理贴图的映射精度越小。如此避免了因存储全场景均匀(远近皆映射相同的空间范围)SDF纹理贴图造成的过高显存占用。Secondly, 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. In addition, 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. On the contrary, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of SDF texture map. This avoids the excessive video memory occupation caused by storing SDF texture map uniformly for the whole scene (the same spatial range is mapped both near and far).
图1为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图一;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;
图2为本公开实施例提供的其中一种SDF纹理贴图的示意图;FIG2 is a schematic diagram of an SDF texture map provided by an embodiment of the present disclosure;
图3为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图二;FIG3 is a second flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure;
图4为本公开实施例提供的其中一种SDF纹理贴图重叠区域展示示意图;FIG4 is a schematic diagram showing an overlapping area of an SDF texture map provided in an embodiment of the present disclosure;
图5为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图三;FIG5 is a third flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure;
图6为本公开实施例提供的其中一种像素点展示示意图;FIG6 is a schematic diagram showing a pixel point display provided by an embodiment of the present disclosure;
图7为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图四;FIG. 7 is a fourth flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure;
图8为本公开实施例提供的其中一种空间点展示示意图;FIG8 is a schematic diagram of a spatial point display provided by an embodiment of the present disclosure;
图9为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图五;FIG9 is a fifth flow chart of a method for generating a signed distance field provided in an embodiment of the present disclosure;
图10为本公开实施例提供的其中一种有向距离场的生成方法的流程示意图六;FIG10 is a sixth flow chart of a method for generating a signed distance field according to an embodiment of the present disclosure;
图11为本公开实施例提供的其中一种有向距离场的生成装置的示意图;FIG11 is a schematic diagram of a device for generating a directed distance field according to an embodiment of the present disclosure;
图12为本公开实施例提供的其中一种电子设备的结构示意图。FIG. 12 is a schematic diagram of the structure of one of the electronic devices provided in an embodiment of the present disclosure.
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,应当理解,本公开中附图仅起到说明和描述的目的, 并不用于限定本公开的保护范围。另外,应当理解,示意性的附图并未按实物比例绘制。本公开中使用的流程图示出了根据本公开的一些实施例实现的操作。应该理解,流程图的操作可以不按顺序实现,没有逻辑的上下文关系的步骤可以反转顺序或者同时实施。此外,本领域技术人员在本公开内容的指引下,可以向流程图添加一个或多个其他操作,也可以从流程图中移除一个或多个操作。In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. It should be understood that the drawings in the present disclosure are only for the purpose of illustration and description. It is not intended to limit the scope of protection of the present disclosure. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in the present disclosure illustrate operations implemented according to some embodiments of the present disclosure. It should be understood that the operations of the flowcharts may be implemented out of sequence, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts, under the guidance of the present disclosure.
另外,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In addition, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure claimed for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
需要说明的是,本公开实施例中将会用到术语“包括”,用于指出其后所声明的特征的存在,但并不排除增加其它的特征。It should be noted that the term “comprising” will be used in the embodiments of the present disclosure to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
首先,对本方案所涉及的相关背景进行说明:First, the relevant background of this plan is explained:
在游戏的一些高级渲染效果如漫反射全局光、镜面反射、软阴影、环境光遮蔽中,可通过raymarching(光线步进)技术实现,raymarching技术也即指从相机向屏幕各像素发射射线,射线通过逐步前进的方式与游戏场景(场景中的虚拟模型)求交,射线步进的长度取决于射线当前所在的位置离游戏场景的最短距离,也即指当前位置(空间点)的有向距离场信息(SDF值)。SDF(Signed Distance Field,有向距离场),指给定任意空间的位置pos,返回这个点离场景物体最近的距离。Some advanced rendering effects in games, such as diffuse global illumination, specular reflection, soft shadows, and ambient occlusion, can be achieved through raymarching technology, which means emitting rays from the camera to each pixel on the screen. The rays intersect with the game scene (the virtual model in the scene) by moving forward step by step. The length of the ray step depends on the shortest distance between the current position of the ray and the game scene, which refers to the signed distance field information (SDF value) of the current position (spatial point). SDF (Signed Distance Field) refers to the return of the shortest distance between this point and the scene object given the position pos in any space.
通常,采用SDF纹理贴图来对应存储游戏场景空间范围中各空间点的SDF值。由于游戏场景中的模型可能是动态移动的,或者由于虚拟相机位置的改变,会导致游戏场景中的同一空间点在不同帧渲染时具有不同的SDF值,也即,每帧渲染中游戏场景中各空间点的SDF值并非是保持不变的,会根据实际情况进行实时更新,那么,如何精确的计算出每帧渲染时所需的SDF值变得尤为重要。Usually, SDF texture maps are used to store the SDF values of each spatial point in the spatial range of the game scene. Since the models in the game scene may be dynamically moved, or due to the change of the virtual camera position, the same spatial point in the game scene will have different SDF values when rendering different frames. In other words, the SDF values of each spatial point in the game scene in each frame rendering are not constant, but will be updated in real time according to the actual situation. Therefore, how to accurately calculate the SDF value required for each frame rendering becomes particularly important.
相关技术中,第一种是采用Unreal 4引擎(虚幻4引擎)进行SDF的计算,使用了离线烘培+实时拼凑的方法:即离线计算每个空间点的SDF数据到一张小型的3D纹理,在实时渲染的时候再把此包含SDF数据的3D纹理通过平移旋转缩放应用到该模型在场景中的实际位置上,得到空间点的真实SDF信息。这种方法的一个显著缺点是只能处理静态场景,无法处理动态场景:比如可破碎模型,带动画的模型,可移动的角色车辆等;另离线预生成的SDF数据没有光照信息,也就无法进行后续漫反射全局光,镜面反射等一些渲染计算。Among the related technologies, the first one is to use 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.
第二种是采用KinectFusion(点云重建)算法进行SDF的计算,该算法是基于多帧渲染的深度贴图来构建场景SDF信息,每帧只更新相机所能看到的一层信息。但是该算法存在以下确定:1、由于仅通过深度贴图恢复SDF数据,深度贴图后侧的SDF信息无法准确获取,导致SDF的信息不完整。2、计算出的SDF值跟真实的SDF值差异较大,从而影响raymarching时的步长取值,可能造成跳过实际表面的错误。3、只依赖一层深度信息,深度背后的场景信息一无所知,有时候这是一堵很厚的墙,有时候可能就是一片薄薄的飘带,这样就会在深度后面生成错误的SDF信息,而错误的SDF信息会导致全局光计算过程中的漏光,鬼影ghosting等各种问题。The second method is to use the KinectFusion (point cloud reconstruction) algorithm to calculate the SDF. This algorithm constructs the scene SDF information based on the depth map rendered by multiple frames, and only updates a layer of information that the camera can see in each frame. However, this algorithm has the following limitations: 1. Since the SDF data is restored only through the depth map, the SDF information behind the depth map cannot be accurately obtained, resulting in incomplete SDF information. 2. The calculated SDF value is significantly different from the actual SDF value, which affects the step size during raymarching and may cause errors in skipping the actual surface. 3. Relying only on one layer of depth information, the scene information behind the depth is unknown. Sometimes this is a very thick wall, and sometimes it may be a thin ribbon. This will generate incorrect SDF information behind the depth, and the incorrect SDF information will cause various problems such as light leakage and ghosting during the global light calculation process.
基于此,本方案提出一种全新的SDF生成方法,通过结合空间点的坐标信息和法线朝向以及三角面片的信息进行SDF的计算,摆脱了依赖深度信息的计算方式,且能够适用于动态场景和静态场景下的任一空间点的SDF的计算,实现了更加精确的SDF计算。Based on this, this scheme proposes a new SDF generation method, which calculates SDF by combining the coordinate information of spatial points, the normal direction and the information of triangular patches, thus getting rid of the calculation method that relies on depth information. It can be applied to the calculation of SDF of any spatial point in dynamic and static scenes, thus achieving more accurate SDF calculation.
图1为本公开实施例提供的有向距离场的生成方法的流程示意图一;本方法的执行主体可以是终端设备或者服务器、处理器等计算设备。如图1所示,该方法可包括如下步骤S101-S104: 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:
S101、根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息。S101. Determine spatial coordinate information of a first spatial point in a world space mapped from the first pixel point according to pixel coordinate information of a first pixel point in a current target signed distance field texture map.
本方案侧重于对有向距离场(下文中以SDF指代)的生成方法的描述,在实施例中是以当前待渲染画面帧所对应的当前SDF纹理的生成进行说明,在实际的应用场景中,待渲染画面每一帧都会发生变化,对应的用于存储场景空间点SDF的纹理贴图也会实时更新,而针对每一次的更新,则均可采用如本方案所示出的SDF生成方法,生成新的SDF,并采用新的SDF替换前一次的SDF,以保证SDF纹理贴图中所存储的各空间点的SDF值在每一帧渲染画面时均为最新的最精确的SDF值。This solution focuses on the description of the method for generating a signed distance field (hereinafter referred to as SDF). In the embodiment, the generation of the current SDF texture corresponding to the current frame of the picture to be rendered is used for explanation. In actual application scenarios, each frame of the picture to be rendered will change, and the corresponding texture map used to store the scene space point SDF will also be updated in real time. For each update, the SDF generation method shown in this solution can be used to generate a new SDF, and the new SDF is used to replace the previous SDF to ensure that the SDF values of each spatial point stored in the SDF texture map are the latest and most accurate SDF values when each frame of the picture is rendered.
假设在前一帧渲染时,步进光线由游戏场景中的空间点a点步进至空间点b点,当前正处于b点,而当前帧渲染时,要获取步进光线由b点继续步进的距离,则可先计算当前的SDF纹理贴图中空间点b所映射至的像素点1所对应存储的SDF值,从而将纹理贴图中像素点1所存储的SDF值作为当前帧渲染时,步进光线由b点所要步进的距离。Assume that when the previous frame was rendered, the stepping ray stepped from spatial point a in the game scene to spatial point b, and is currently at point b. When the current frame is rendered, to obtain the distance that the stepping ray continues to step from point b, the SDF value stored corresponding to pixel point 1 mapped to spatial point b in the current SDF texture map can be calculated first, and then the SDF value stored in pixel point 1 in the texture map can be used as the distance that the stepping ray needs to step from point b when the current frame is rendered.
第一像素点可以指当前的目标SDF纹理贴图中待更新SDF值的像素点中的任一像素点,第一像素点的像素坐标信息可以指第一像素点在SDF纹理贴图中的坐标。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.
基于所获取的第一像素点的像素坐标信息,可以根据纹理贴图与世界空间的坐标映射关系,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息。Based on the acquired pixel coordinate information of the first pixel point, the spatial coordinate information of the first spatial point mapped from the first pixel point to the world space can be determined according to the coordinate mapping relationship between the texture map and the world space.
这里对纹理贴图与世界空间之间的映射方式进行说明:Here is an explanation of the mapping between texture maps and world space:
为通过SDF纹理贴图实现访问世界空间(世界坐标)下空间某位置的SDF值,现定义SD纹理贴图在世界空间中的覆盖盒子范围(AABB:axis-aligned bounding box),包围盒坐标最小值为BBMin,包围盒坐标最大值为BBMax,则SDF纹理贴图的每个像素的像素坐标(纹理坐标UVW)就可以准确的映射到世界空间中的一个空间点(WorldPos),反之亦然,映射公式如下:WorldPos=BBMin+(BBMax-BBMin)*UVW;UVW=(WorldPos-BBMin)/(BBMax-BBMin)。In order to access the SDF value of a certain position in the world space (world coordinates) through the SDF texture map, the coverage box range 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, and the maximum value of the bounding box coordinates is BBMax. Then, the pixel coordinates (texture coordinates UVW) of each pixel of the SDF texture map can be accurately mapped to a spatial point (WorldPos) in the world space, and vice versa. The mapping formula is as follows: WorldPos = BBMin + (BBMax-BBMin) * UVW; UVW = (WorldPos-BBMin) / (BBMax-BBMin).
基于上述映射公式,在已知第一像素点的像素坐标信息时,可以计算得到第一像素点映射至世界空间中的第一空间点的空间坐标信息;反之,在已知世界空间中的第一空间点的空间坐标信息时,同样可以计算得到第一空间点映射至SDF纹理贴图中的第一像素点的像素坐标信息。Based on the above mapping formula, when the pixel coordinate information of the first pixel point is known, the spatial coordinate information of the first pixel point mapped to the first spatial point in the world space can be calculated; conversely, when the spatial coordinate information of the first spatial point in the world space is known, the pixel coordinate information of the first spatial point mapped to the first pixel point in the SDF texture map can also be calculated.
S102、根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息。S102. Determine each adjacent pixel point corresponding to the first pixel point according to the pixel coordinate information of the first pixel point and a preset rasterization direction, and determine the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space according to the pixel coordinate information of each adjacent pixel point.
通常,世界空间中的空间点均是依附于三角面片而存在的,也就是世界空间中的物体均是由最小单元的三角面片构成的,不同的空间点可能位于同一个三角面片上,也有可能位于不同的三角面片上。Usually, all spatial points in the world space exist attached to triangles, that is, objects in the world space are composed of the smallest unit triangles. Different spatial points may be located on the same triangle or on different triangles.
为了避免待更新SDF值的像素点所在的面片与光栅化方向平行导致无法通过光栅化获取该下像素点的深度的问题,保证能够拿到面片的深度信息,本实施例中在预设的多个方向上进行光栅化。In order to avoid the problem that the surface where the pixel point whose SDF value is to be updated is located is parallel to the rasterization direction, resulting in the inability to obtain the depth of the pixel point through rasterization, and to ensure that the depth information of the surface can be obtained, rasterization is performed in multiple preset directions in this embodiment.
光栅化是指把三角面片转化为像素的过程,并且考虑遮挡关系,如果一个像素位置同时被多个三角面片覆盖,则选取最前面的三角面片信息吸入这个像素。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.
根据预设的光栅化方向,可以在SDF纹理贴图中确定出第一像素点对应的各相邻像素点。而针对各相邻像素点同样可基于各相邻像素点的像素坐标信息以及纹理贴图与世界空间的映射关系,确定出各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息。According to the preset rasterization direction, each adjacent pixel point corresponding to the first pixel point can be determined in the SDF texture map. For each adjacent pixel point, the spatial coordinate information of each adjacent pixel point mapped to each adjacent spatial point in the world space can also be determined based on the pixel coordinate information of each adjacent pixel point and the mapping relationship between the texture map and the world space.
S103、根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息。 S103, generating respectively the signed distance field information of the first pixel point and the signed distance field information of the adjacent pixel points in the current target signed distance field texture map according to the spatial coordinate information of the first spatial point, the spatial coordinate information of the adjacent spatial points and the normal direction of the first spatial point.
在一些实施例中,可基于上述所确定出的第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息。In some embodiments, based on the spatial coordinate information of the first spatial point determined above, the spatial coordinate information of each adjacent spatial point, and the normal direction of the first spatial point, the signed distance field information of the first pixel point and the signed distance field information of each adjacent pixel point in the current target signed distance field texture map can be generated respectively.
本实施例中采用基于空间点的空间坐标信息以及空间点对应的相邻空间点的空间坐标信息进行SDF的计算,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。In this embodiment, the SDF is calculated based on the spatial coordinate information of the spatial point and the spatial coordinate information of the adjacent spatial points corresponding to the spatial point. Since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the shortest distance between the spatial point and the scene object, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when traditionally relying on the depth information of the spatial point for calculation.
另外,根据空间点的法线朝向可以进一步地确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。In addition, the normal direction of the spatial point can be used to further determine the positional relationship between the spatial point and its nearest scene object, thereby accurately determining the positive and negative signs of the calculated SDF value, effectively improving the accuracy of the calculation results.
S104、根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,第二像素点为目标有向距离场中除第一像素点以及各相邻像素点之外的剩余像素点。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.
第二像素点为当前的目标有向距离场纹理贴图中除了第一像素点和第二像素点对应的各相邻像素点之外的剩余待更新SDF值的像素点。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.
在一种可实现的方式中,对于第二像素点的SDF的生成,同样可采用上述步骤S101-S103的方式进行计算,此时,第二像素点可以作为第一像素点执行运算。In a feasible manner, the generation of the SDF of the second pixel point can also be calculated in the manner of steps S101 to S103 described above. In this case, the second pixel point can be used as the first pixel point to perform calculations.
而在另一种可实现的方式中,为了减少运算量,提高计算效率,对于第二像素点的SDF值的生成,可以是根据已经计算得到的第一像素点的SDF值以及第一像素点对应的各相邻像素点的SDF值进行综合分析,生成第二像素点的SDF值。In another feasible method, in order to reduce the amount of calculation and improve the calculation efficiency, the SDF value of the second pixel point can be generated by performing a comprehensive analysis based on the calculated SDF value of the first pixel point and the SDF values of each adjacent pixel point corresponding to the first pixel point to generate the SDF value of the second pixel point.
基于此,对当前的目标有向距离场纹理贴图中所有需要重新生成SDF值的像素点均完成了SDF生成,从而可根据生成的SDF值替换原始所存储的SDF值,得到更新后的目标有向距离场纹理贴图。Based on this, SDF generation is completed for all pixel points in the current target signed distance field texture map that need to regenerate SDF values, so that the original stored SDF values can be replaced according to the generated SDF values to obtain an updated target signed distance field texture map.
综上,本实施例提供的有向距离场的生成方法,通过获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。并且进一步地结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。In summary, the method for generating a signed distance field provided in this embodiment can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.
可选地,目标有向距离场纹理贴图包括:静态场景有向距离场纹理贴图和动态场景有向距离场纹理贴图。本实施例中通过动静场景分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。Optionally, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map. In this embodiment, the SDF value of the static scene is stored in the static scene SDF texture map, and 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., while dynamic scenes can be composed of dynamic models in the scene, such as moving vehicles, floating clouds, etc. The scene exists in the world space.
目标有向距离场纹理贴图包括多层纹理贴图,各层纹理贴图采用相同尺寸存储对应世界空间范围中各空间点的有向距离场信息,且各层纹理贴图中各像素点存储对应空间点的有向距离场信息;其中,各层纹理贴图所对应的世界空间范围根据世界空间范围与虚拟相机的距离确定。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.
图2为本公开实施例提供的一种SDF纹理贴图的示意图。如图2所示,以目标SDF纹理贴图包 括三层纹理贴图为例,目标SDF纹理贴图可以为围绕虚拟相机建立的三层3D纹理贴图,分别映射距离虚拟相机不同距离的游戏世界空间的空间范围。FIG. 2 is a schematic diagram of an SDF texture map provided by an embodiment of the present disclosure. Taking three layers of texture maps as an example, the target SDF texture map can be a three-layer 3D texture map established around the virtual camera, which respectively maps the spatial range of the game world space at different distances from the virtual camera.
如图2所示,每一层为SDF纹理贴图映射的世界空间范围。每一层纹理贴图存储的空间点的SDF所属的世界空间范围由虚拟相机位置决定,当虚拟相机位置发生变化时,纹理贴图对应的世界空间范围也随之变化,其中,每层纹理贴图的纹理数量不发生变化,每层纹理贴图采用相同像素尺寸(例如:128*128*128,)存储对应世界空间范围的空间点的有向距离场信息,也即,每层纹理贴图均为长宽高相等的纹理贴图,因而SDF纹理贴图所占用的显存始终固定。As shown in Figure 2, 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.
可选地,不同的世界空间范围使用相同大小(相同像素尺寸)的SDF纹理贴图进行映射,以实现不同映射精度。距虚拟相机越近,所需精度越大,SDF纹理贴图的映射精度越大,反之距虚拟相机越远,所需精度越小,SDF纹理贴图的映射精度越小。如此避免了因存储全场景均匀(远近皆映射相同的空间范围)SDF纹理贴图造成的过高显存占用。Optionally, different world space ranges are mapped using SDF texture maps of the same size (same pixel size) to achieve different mapping accuracies. The closer to the virtual camera, the greater the required accuracy, and the greater the mapping accuracy of the SDF texture map. Conversely, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of the SDF texture map. This avoids excessive video memory usage caused by storing SDF texture maps uniformly for the entire scene (the same spatial range is mapped both near and far).
图3为本公开实施例提供的有向距离场的生成方法的流程示意图二;可选地,步骤S101中,根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,可以包括以下步骤S301-S303: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:
S301、若当前的目标有向距离场纹理贴图为静态场景有向距离场纹理贴图,则根据当前的目标有向距离场纹理贴图所对应的世界空间范围与前一目标有向距离场纹理贴图所对应的世界空间范围,确定当前的目标有向距离场纹理贴图与前一目标有向距离场纹理贴图的重叠区域和非重叠区域。S301. If the current target signed distance field texture map is a static scene signed distance field texture map, determining an overlapping area and a non-overlapping area between the current target signed distance field texture map and the previous target signed distance field texture map according to a world space range corresponding to the current target signed distance field texture map and a world space range corresponding to the previous target signed distance field texture map.
在从当前的目标SDF纹理贴图中获取第一像素点的像素坐标信息之前,若确定当前的目标SDF纹理贴图为静态场景SDF纹理贴图,则可先确定出当前的目标SDF纹理贴图与前一目标SDF纹理贴图的重叠区域和非重叠区域,对于重叠区域,可以将前一目标SDF纹理贴图所存储的SDF值对应复制到当前的目标SDF纹理贴图中,而对于非重叠区域,则采用步骤S101-S104的方法生成非重叠区域中各像素点的SDF值。那么,当前的目标SDF纹理贴图中的第一像素点则可以指非重叠区域中的任一像素点。Before obtaining the pixel coordinate information of the first pixel from the current target SDF texture map, if it is determined that the current target SDF texture map is a static scene SDF texture map, the overlapping area and non-overlapping area between the current target SDF texture map and the previous target SDF texture map can be determined first. For the overlapping area, the SDF value stored in the previous target SDF texture map can be copied to the current target SDF texture map, and for the non-overlapping area, the method of steps S101-S104 is used to generate the SDF value of each pixel in the non-overlapping area. Then, the first pixel in the current target SDF texture map can refer to any pixel in the non-overlapping area.
值得注意的是,前一目标SDF纹理贴图可以对应前一帧渲染画面时需要读取SDF值的目标SDF纹理贴图,也就是说,前一帧渲染画面时,步进光线的步进距离可以从前一目标SDF纹理贴图中读取对应的SDF得到;当前的目标SDF纹理贴图则对应当前帧渲染画面时需要读取SDF值的目标SDF纹理贴图;当前帧渲染画面时,步进光线的步进距离可以从当前的目标SDF纹理贴图中读取对应的SDF得到。在游戏运行的过程中,每一帧游戏画面的渲染可以从每帧所对应的SDF纹理贴图中读取空间点的SDF以进行光线步进,并根据步进光线与场景的交点,获取交点的相关信息,进行一些高级渲染。It is worth noting that the previous target SDF texture map can correspond to the target SDF texture map that needs to read the SDF value when rendering the previous frame. That is to say, when rendering the previous frame, the stepping distance of the stepping ray can be obtained by reading the corresponding SDF from the previous target SDF texture map; the current target SDF texture map corresponds to the target SDF texture map that needs to read the SDF value when rendering the current frame; when rendering the current frame, the stepping distance of the stepping ray can be obtained by reading the corresponding SDF from the current target SDF texture map. During the running of the game, the rendering of each frame of the game screen can read the SDF of the spatial point from the SDF texture map corresponding to each frame to perform ray stepping, and obtain the relevant information of the intersection based on the intersection of the stepping ray and the scene, and perform some advanced rendering.
其中,当前的目标SDF纹理贴图和前一目标SDF纹理贴图为同一贴图,仅仅是贴图中相同的像素点所对应存储的SDF值可能发生了变化。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、根据前一目标有向距离场纹理贴图中重叠区域的各像素的有向距离场信息,对当前的目标有向距离场纹理贴图中重叠区域中各像素的有向距离场信息进行更新。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.
图4为本公开实施例提供的一种SDF纹理贴图重叠区域展示示意图,如图4所示,黑色部分表示前一目标SDF纹理贴图与当前的目标SDF纹理贴图的重叠区域(值得注意的是,实际应用中纹理贴图是三维的,此处为演示方便简略为二维),对于重叠区域而言,当前的目标SDF纹理贴图中重叠区域的各像素点存储的SDF值可以直接复制前一目标SDF纹理贴图中该重叠区域中各像素点存储的SDF值。由于重叠区域所对应的世界空间范围在当前帧和前一帧是未发生改变的,对应存储的世界空间范围中空间点的SDF值也是未发生改变的,只是对于目标SDF纹理贴图而言,重叠区域中同一像 素点在前一目标SDF纹理贴图中和在当前的DF纹理贴图中的像素坐标信息是不同的,从而导致在从前一目标SDF纹理贴图中复制重叠区域中各像素点的SDF值时,需要对应进行复制,例如前一目标SDF纹理贴图中重叠区域左上角的像素点假设为(4,7,9),其对应存储的SDF值为a,而前一目标SDF纹理贴图中重叠区域左上角的像素点(4,7,9)对应在当前的目标SDF纹理贴图中则变为像素点(0,0,11),那么,当前的目标SDF纹理贴图中重叠区域的像素点(0,0,11)存储的SDF值则替换为a,同理,可对应得到重叠区域中各像素点的SDF值。FIG4 is a schematic diagram showing an overlapping area of an SDF texture map provided by an embodiment of the present disclosure. As shown in FIG4 , 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). For the overlapping area, the SDF value stored in each pixel point in the overlapping area of the current target SDF texture map can directly copy the SDF value stored in each pixel point in the overlapping area of the previous target SDF texture map. Since the world space range corresponding to the overlapping area has not changed between the current frame and the previous frame, the SDF value of the space point in the corresponding stored world space range has not changed either. However, for the target SDF texture map, 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. For example, the pixel point in the upper left corner of the overlapping area in the previous target SDF texture map is assumed to be (4, 7, 9), and its corresponding stored SDF value is a, while the pixel point (4, 7, 9) in the upper left corner of the overlapping area in the previous target SDF texture map corresponds to the pixel point (0, 0, 11) in the current target SDF texture map. Then, the SDF value stored in the pixel point (0, 0, 11) in the overlapping area in the current target SDF texture map is replaced with a. Similarly, the SDF value of each pixel in the overlapping area can be obtained accordingly.
S303、将当前的目标有向距离场纹理贴图中非重叠区域中各像素的有向距离场信息初始化为预设值,第一像素点为非重叠区域中的像素点。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.
而对于非重叠区域而言,如图4中的斜线部分所表示的区域,可首先将非重叠区域中各像素点的SDF值均初始化为预设值,其中,预设值可以为CellSize*4(4倍的CellSize),其中,CellSize表征SDF纹理贴图中单个像素边长映射到世界空间中的长度。For non-overlapping areas, such as the areas represented by the diagonal lines in FIG4 , 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.
对于非重叠区域中的各像素点而言,均需要重新计算得到各像素点的新的SDF值,那么,上述的第一像素点可以为非重叠区域中的任一像素点。For each pixel point in the non-overlapping area, it is necessary to recalculate a new SDF value of each pixel point. Therefore, the first pixel point mentioned above may be any pixel point in the non-overlapping area.
可选地,步骤S101中,根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,可以包括:若目标有向距离场纹理贴图为动态场景有向距离场纹理贴图,则将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值,第一像素点为当前的目标有向距离场纹理贴图中的任一像素点。Optionally, in step S101, before determining the spatial coordinate information of the first pixel mapped to the first spatial point in the world space based on the pixel coordinate information of the first pixel in the current target signed distance field texture map, it can include: if the target signed distance field texture map is a dynamic scene signed distance field texture map, initializing the signed distance field information of each pixel in the current target signed distance field texture map to a preset value, and the first pixel is any pixel in the current target signed distance field texture map.
而若当前的目标SDF纹理贴图为动态场景SDF纹理贴图时,则纹理贴图中所有像素点的SDF均需要重新生成,那么,此时可将所有像素点的SDF均初始化为预设值,这里的预设值与上述一致,可以为CellSize*4。If the current target SDF texture map is a dynamic scene SDF texture map, the SDF of all pixels in the texture map needs to be regenerated. At this time, the SDF of all pixels can be initialized to a preset value. The preset value here is consistent with the above and can be CellSize*4.
需要说明的是,选取CellSize*4的原因是上述对预设方向进行光栅化时是选取第一像素点沿光栅化方向3个像素选取相邻像素点进行计算,若预设值选取大于CellSize*4,则光线步进的过程中会跳过障碍物,无法获取光线步进的准确结果。It should be noted that the reason for selecting CellSize*4 is that when rasterizing the preset direction, the first pixel point is selected and the adjacent pixel points are selected 3 pixels along the rasterization direction for calculation. If the preset value is larger than CellSize*4, obstacles will be skipped during the ray stepping process, and the accurate result of the ray stepping cannot be obtained.
当然预设值的选取可根据实际的光栅化场景进行适应性调整。Of course, the selection of the preset value can be adaptively adjusted according to the actual rasterization scene.
图5为本公开实施例提供的有向距离场的生成方法的流程示意图三;如图5所示,步骤S102中,根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,可以包括如下步骤S501-S503: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:
S501、根据第一像素点的像素坐标信息以及第一光栅化方向,确定沿第一光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第一相邻像素点。S501 , according to pixel coordinate information of a first pixel point and a first rasterization direction, determining that a preset number of pixel points along the first rasterization direction and adjacent to the first pixel point are first adjacent pixel points corresponding to the first pixel point.
第一光栅化方向可以为x轴方向,假设第一像素点的像素坐标信息为[x,y,z],基于[x,y,z]沿着x轴方向前后各3个像素可分别确定出第一像素点对应的各第一相邻像素点,分别包括:[x-3,y,z],[x-2,y,z],[x-1,y,z],[x+1,y,z],[x+2,y,z],[x+3,y,z]。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、根据第一像素点的像素坐标信息以及第二光栅化方向,确定沿第二光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第二相邻像素点。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.
第二光栅化方向可以为y轴方向,基于[x,y,z]沿着y轴方向前后各3个像素可分别确定出第一像素点对应的各第二相邻像素点,分别包括:[x,y-3,z],[x,y-2,z],[x,y-1,z],[x,y+1,z],[x,y+2,z],[x,y+3,z]。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、根据第一像素点的像素坐标信息以及第三光栅化方向,确定沿第三光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第三相邻像素点。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.
第三光栅化方向可以为z轴方向,基于[x,y,z]沿着z轴方向前后各3个像素可分别确定出第一像素 点对应的各第二相邻像素点,分别包括:[x,y,z-3],[x,y,z-2],[x,y,z-1],[x,y,z+1],[x,y,z+2],[x,y,z+3]。The third rasterization direction may be the z-axis direction. Based on [x, y, z], 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].
图6为本公开实施例提供的一种像素点展示示意图,如图6所示,则分别展示了第一像素点及按照上述光栅化方向所确定出的第一像素点对应的各相邻像素点的像素坐标信息及位置关系。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.
图7为本公开实施例提供的有向距离场的生成方法的流程示意图四;可选地,步骤S103中,根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,可以包括如下步骤S701-S702: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:
S701、根据第一空间点的空间坐标信息以及第一空间点所对应的三角面片的深度信息,生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息。S701 . Generate signed distance field information of a first pixel point in a current target signed distance field texture map according to spatial coordinate information of a first spatial point and depth information of a triangle patch corresponding to the first spatial point.
图8为本公开实施例提供的一种空间点展示示意图,假设第一空间点以及第一空间点对应的三角面片的位置关系如图8所示,首先可获取三角面片的深度信息,其中,面片的深度信息可以指面片所代表的位置距观察者(可以指虚拟相机)的距离。深度信息的计算方式可以为过屏幕某像素点做平行于观察方向的射线,该射线与面片相交的点距该像素点的距离即为该面片的深度。FIG8 is a schematic diagram of a spatial point display provided by an embodiment of the present disclosure. Assuming that the positional relationship between the first spatial point and the triangular facet corresponding to the first spatial point is as shown in FIG8, 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.
根据三角面片的深度信息可以计算出三角面片的在世界空间中的位置信息,那么,根据第一空间点的位置信息以及三角面片的位置信息,进行矢量运算,则可计算出第一空间点的SDF值,也就是点到面的距离求解运算。而第一空间点的SDF值则对应存储至当前的目标SDF纹理贴图中的第一像素点中,从而得到了第一像素点的SDF值。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、根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息。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.
而对于第一像素点的各相邻像素点的SDF值的生成,则可以分别根据各相邻空间点的空间坐标信息、第一空间点的空间坐标信息以及第一空间点的法线朝向,逐一进行计算。具体在下面实施例进行详细展开。As for the generation of the SDF values of the adjacent pixel points of the first pixel point, the SDF values can be calculated one by one according to the spatial coordinate information of the adjacent spatial points, the spatial coordinate information of the first spatial point and the normal direction of the first spatial point.
图9为本公开实施例提供的有向距离场的生成方法的流程示意图五;可选地,步骤S702中,根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息,可以包括如下步骤S901-S903: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、根据目标相邻空间点的空间坐标信息、以及第一空间点的空间坐标信息,确定目标相邻空间点与第一空间点之间的距离值,目标相邻空间点为各相邻空间点中的任一相邻空间点。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.
以图6所示的像素点展示示意图为例,这里的目标相邻空间点可以指图6中除第一像素点[x,y,z]之外的任一像素点所映射至世界空间中的空间点。Taking the pixel point display diagram shown in FIG6 as an example, 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 .
以生成像素点[x-1,y,z]的SDF值为例,那么,目标相邻空间点则指像素点[x-1,y,z]映射至世界空间中的空间点,可根据纹理贴图与世界空间之间的坐标映射关系,确定出目标相邻空间点的空间坐标信息。Taking the SDF value of the pixel point [x-1, y, z] as an example, the target adjacent spatial point refers to the spatial point in the world space mapped to the pixel point [x-1, y, z]. The spatial coordinate information of the target adjacent spatial point can be determined based on the coordinate mapping relationship between the texture map and the world space.
假设第一空间点的空间坐标信息为P,目标相邻空间点的空间坐标信息为P2,那么,可计算P点到P2点的距离D,得到目标相邻空间点与第一空间点之间的距离值。Assuming that the spatial coordinate information of the first spatial point is P, and the spatial coordinate information of the target adjacent spatial point is P2, then the distance D from point P to point P2 can be calculated to obtain the distance value between the target adjacent spatial point and the first spatial point.
S902、根据第一空间点与目标相邻空间点的方向矢量以及第一空间点的法线的点乘结果。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.
另外,假设第一空间点的法线朝向为第一空间点与目标相邻空间点的方向矢量为则可计算与的点乘,得到点乘结果。In addition, assume that the normal direction of the first spatial point is The direction vector between the first spatial point and the target adjacent spatial point is: Then we can calculate and The dot product of is obtained.
S903、根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有 向距离场信息。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.
根据点乘结果可以确定目标相邻空间点的SDF值取值的正负号,从而得到目标相邻空间点的SDF值,而目标相邻空间点的SDF值对应存储至目标相邻像素点中,则可得到目标相邻像素点的SDF值,也即得到当前的目标SDF纹理贴图中像素点[x-1,y,z]的SDF值,如图6所示的像素点[x-1,y,z]的SDF值。According to the dot product result, the positive and negative signs of the SDF values of the target adjacent spatial points can be determined, thereby obtaining the SDF values of the target adjacent spatial points. The SDF values of the target adjacent spatial points are stored in the target adjacent pixel points, and the SDF values of the target adjacent pixel points can be obtained, that is, the SDF value of the pixel point [x-1, y, z] in the current target SDF texture map is obtained, such as the SDF value of the pixel point [x-1, y, z] shown in Figure 6.
而对于图6中所示出的第一像素点[x,y,z]之外的任一相邻像素点的SDF值的计算,可按照上述的计算方式逐一执行,从而分别得到第一像素点对应的各相邻像素点的SDF值。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.
可选地,步骤S903中根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息,可以包括:若点乘结果大于0,则将距离值作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。Optionally, in step S903, generating the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value may include: if the dot product result is greater than 0, using the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.
若与的点乘结果大于0,则可说明目标相邻空间点位于第一空间点对应的三角面片的外侧,此时,可将计算得到的目标相邻空间点与第一空间点之间的距离值确定为目标相邻像素点的SDF值。like and If the result of the dot product is greater than 0, it means that the target adjacent spatial point is located outside the triangle patch corresponding to the first spatial point. At this time, the calculated distance value between the target adjacent spatial point and the first spatial point can be determined as the SDF value of the target adjacent pixel point.
若点乘结果小于或等于0,则将距离值的负数作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。If the dot product result is less than or equal to 0, the negative of the distance value is used as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map.
而若与的点乘结果小于或等于0,则可说明目标相邻空间点位于第一空间点对应的三角面片的内侧,此时,可将计算得到的目标相邻空间点与第一空间点之间的距离值的负数确定为目标相邻像素点的SDF值。And if and If the result of the dot product is less than or equal to 0, it means that the target adjacent spatial point is located on the inner side of the triangle corresponding to the first spatial point. At this time, the negative of the calculated distance value between the target adjacent spatial point and the first spatial point can be determined as the SDF value of the target adjacent pixel point.
图10为本公开实施例提供的有向距离场的生成方法的流程示意图六;可选地,步骤S104中,根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,可以包括如下步骤S1001-S1003: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:
S1001、判断当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息是否大于预设阈值,目标第二像素点为各第二像素点中的任一像素点。S1001. Determine whether the signed distance field information of a target second pixel point in a current target signed distance field texture map is greater than a preset threshold, the target second pixel point being any pixel point among the second pixel points.
而对于第二像素点的SDF的运算,可通过多帧扩散的方式进行运算。以目标第二像素点的SDF值的生成为例,可先判断目标第二像素点当前的SDF值的绝对值是否大于预设阈值,这里的预设阈值可以指3*CellSize。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.
在目标第二像素点的SDF未被重新生成之前,目标第二像素点的SDF值被初始化为4*CellSize,而当判断目标第二像素点的SDF值大于3*CellSize时,可认为目标第二像素点的SDF值在此之前还未被重新生成。Before the SDF of the target second pixel point is regenerated, the SDF value of the target second pixel point is initialized to 4*CellSize. When it is determined that the SDF value of the target second pixel point is greater than 3*CellSize, it can be considered that the SDF value of the target second pixel point has not been regenerated before.
S1002、若是,则根据当前的目标有向距离场纹理贴图中目标第二像素点的各预设相邻像素点的有向距离场信息,确定初始的有向距离场信息。S1002: If yes, determine initial signed distance field information according to the signed distance field information of each preset adjacent pixel point of the target second pixel point in the current target signed distance field texture map.
可选地,可获取目标第二像素点的所有邻居像素点的SDF值,这里的邻居像素点指目标第二像素点在当前的目标SDF纹理贴图中上下左右四个相邻的像素点。并从四个相邻的像素点的SDF值中取SDF值绝对值的最小值K为初始的SDF。Optionally, the SDF values of all neighboring pixels of the target second pixel may be obtained, where the neighboring pixels refer to the four neighboring pixels of the target second pixel in the current target SDF texture map, and the minimum value K of the absolute value of the SDF value is taken from the SDF values of the four neighboring pixels as the initial SDF.
S1003、根据初始的有向距离场信息、以及目标有向距离场纹理贴图中单位像素边长映射至世界空间范围中的长度,生成当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息。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.
那么,目标第二像素点的SDF值则可以用(K+1)*CellSize来更新。目标第二像素点为所有第二像素点中的任意一个,可以按照目标第二像素点的SDF值的生成方式,生成所有第二像素点的SDF值。 Then, the SDF value of the target second pixel point can be updated by (K+1)*CellSize. The target second pixel point is any one of all the second pixel points, and the SDF values of all the second pixel points can be generated according to the generation method of the SDF value of the target second pixel point.
而当判断目标第二像素点当前的SDF值的绝对值小于3*CellSize时,则可跳过当前的更新逻辑,也即目标第二像素点的SDF值保持不变。When it is determined that the absolute value of the current SDF value of the target second pixel is less than 3*CellSize, the current update logic can be skipped, that is, the SDF value of the target second pixel remains unchanged.
可选地,步骤S104中,根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息之后,本方法还可包括:若生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值大于前一目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值,则将生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息调整为前一目标有向距离场纹理贴图中第一像素点的有向距离场信息。Optionally, in step S104, after respectively generating the signed distance field information of each second pixel in the current target signed distance field texture map according to the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel, the method may further include: if the absolute value of the signed distance field information of the first pixel in the generated current target signed distance field texture map is greater than the absolute value of the signed distance field information of the first pixel in the previous target signed distance field texture map, adjusting the signed distance field information of the first pixel in the generated current target signed distance field texture map to the signed distance field information of the first pixel in the previous target signed distance field texture map.
通过上述的各步骤,已经初步的生成了当前的目标SDF纹理贴图中各需要重新计算SDF值的像素点的新的SDF值,但是,不一定所计算出的新的SDF值会被采用,由于SDF值指的是空间点与场景的最近距离,那么,还可将所生成的当前的目标SDF纹理贴图中各像素点的SDF值的绝对值与前一目标SDF纹理贴图各像素点的SDF值的绝对值进行比较。取两次中的最小值作为当前的目标SDF纹理贴图中各像素点的SDF值。Through the above steps, the new SDF values of the pixels in the current target SDF texture map that need to recalculate the SDF value have been preliminarily generated. However, the calculated new SDF values may not be adopted. Since the SDF value refers to the closest distance between the spatial point and the scene, the absolute value of the SDF value of each pixel in the generated current target SDF texture map can be compared with the absolute value of the SDF value of each pixel in the previous target SDF texture map. The minimum value of the two is taken as the SDF value of each pixel in the current target SDF texture map.
例如:通过本方法所生成的当前的目标SDF纹理贴图中第一像素点的SDF值为-4,而前一目标SDF纹理贴图中第一像素点的SDF值为5,由于当前的目标SDF纹理贴图中第一像素点的SDF值的绝对值小于前一目标SDF纹理贴图中第一像素点的SDF值的绝对值,则可采用生成的当前的目标SDF纹理贴图中第一像素点的SDF值-4作为当前的目标SDF纹理贴图中第一像素点的最终SDF值。For example: the SDF value of the first pixel in the current target SDF texture map generated by this method is -4, while the SDF value of the first pixel in the previous target SDF texture map is 5. Since the absolute value of the SDF value of the first pixel in the current target SDF texture map is smaller than the absolute value of the SDF value of the first pixel in the previous target SDF texture map, the SDF value of the first pixel in the current target SDF texture map -4 can be used as the final SDF value of the first pixel in the current target SDF texture map.
而若所生成的当前的目标SDF纹理贴图中第一像素点的SDF值为-5,而前一目标SDF纹理贴图中第一像素点的SDF值为4,由于当前的目标SDF纹理贴图中第一像素点的SDF值的绝对值大于前一目标SDF纹理贴图中第一像素点的SDF值的绝对值,则生成的当前的目标SDF纹理贴图中第一像素点的SDF值仍然保持4不变。If the SDF value of the first pixel in the current target SDF texture map is -5, and the SDF value of the first pixel in the previous target SDF texture map is 4, since the absolute value of the SDF value of the first pixel in the current target SDF texture map is greater than the absolute value of the SDF value of the first pixel in the previous target SDF texture map, the SDF value of the first pixel in the current target SDF texture map remains unchanged at 4.
通过本方法对生成的SDF的值进行校正,可以保证每一帧渲染时所对应的目标SDF纹理贴图中各像素点的SDF值均能取得最精确的值,从而保证光线步进的准确性。By correcting the generated SDF value through this method, it can be ensured that the SDF value of each pixel in the target SDF texture map corresponding to each frame rendering can obtain the most accurate value, thereby ensuring the accuracy of light stepping.
可选地,本公开的方法还可包括:根据当前的目标有向距离场纹理贴图中各像素点的有向距离场信息渲染当前帧。Optionally, 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的间接光照,那么,可以从虚拟模型a向游戏场景中发射步进光线,在当前帧步进光线所要步进的距离则从当前的目标有向距离场纹理贴图中读取,假设步进光线当前所在的位置为空间点a,则可从当前的目标有向距离场纹理贴图中空间点a所对应的像素点中读取所存储的空间点a的SDF值,从而步进光线根据该SDF值进行步进,假设步进后与场景中的虚拟模型b相交,那么可读取交点的材质信息,例如交点位置场景表面的材质、纹理等信息,从而结合入射光线信息,例如:光线颜色、强度、角度、材质、衰减度等,可以确定交点的颜色信息,从而根据交点的颜色信息对虚拟模型a进行间接光照的计算。Assuming that the picture to be rendered in the current frame is the indirect lighting for rendering virtual model a, then a stepping ray can be emitted from virtual model a to the game scene, and the distance that the stepping ray needs to step in the current frame is read from the current target signed distance field texture map. Assuming that the current position of the stepping ray is spatial point a, the SDF value of spatial point a stored in the pixel corresponding to spatial point a in the current target signed distance field texture map can be read, so that the stepping ray steps according to the SDF value. Assuming that it intersects with the virtual model b in the scene after stepping, the material information of the intersection can be read, such as the material and texture of the scene surface at the intersection position, etc., so as to combine the incident light information, such as light color, intensity, angle, material, attenuation, etc., to determine the color information of the intersection, and thus calculate the indirect lighting of the virtual model a according to the color information of the intersection.
当然,这仅为一种渲染场景的举例,实际应用中,步进光线的作用并不限于进行间接光照的计算,但是步进光线的步进距离则根每帧步进时空间点的SDF相关。Of course, this is just an example of a rendering scene. In actual applications, the role of stepping rays is not limited to the calculation of indirect lighting, but the stepping distance of the stepping rays is related to the SDF of the space point at each frame step.
综上,本实施例提供的有向距离场的生成方法,通过获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间 点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。并且进一步地结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。In summary, the method for generating a signed distance field provided in this embodiment can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, breaking away from the traditional reliance on spatial coordinate information. When calculating the depth information of a point, the lack of depth information leads to poor accuracy of the calculation result. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, effectively improving the accuracy of the calculation result.
其次,本方案采用动静场景SDF分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。另外,本方案中采用具有多层纹理贴图的SDF纹理贴图存储对应世界空间中空间点的SDF值,不同的世界空间范围使用相同大小(相同像素尺寸)的SDF纹理贴图进行映射,以实现不同映射精度。距虚拟相机越近,所需精度越大,SDF纹理贴图的映射精度越大,反之距虚拟相机越远,所需精度越小,SDF纹理贴图的映射精度越小。如此避免了因存储全场景均匀(远近皆映射相同的空间范围)SDF纹理贴图造成的过高显存占用。Secondly, 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. In addition, 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. On the contrary, the farther from the virtual camera, the smaller the required accuracy, and the smaller the mapping accuracy of SDF texture map. This avoids the excessive video memory occupation caused by storing SDF texture map uniformly for the whole scene (the same spatial range is mapped both near and far).
下述对用以执行本公开所提供的有向距离场的生成方法的装置、设备及存储介质等进行说明,其具体的实现过程以及技术效果参见上述,下述不再赘述。The following describes the apparatus, device, storage medium, etc. used to execute the method for generating a signed distance field provided by the present disclosure. The specific implementation process and technical effects thereof are as mentioned above and will not be described in detail below.
图11为本公开实施例提供的一种有向距离场的生成装置的示意图,该有向距离场的生成装置实现的功能对应上述有向距离场的生成方法执行的步骤。该装置可以理解为上述的终端设备或服务器,或服务器的处理器,也可以理解为独立于上述服务器或处理器之外的在服务器控制下实现本公开功能的组件,如图11所示,该装置可包括:确定模块110、生成模块120;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. As shown in FIG11, the device may include: a determination module 110, a generation module 120;
确定模块110,用于根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息;确定模块110,用于根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息;生成模块120,用于根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息;生成模块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 first pixel and the adjacent pixel.
可选地,目标有向距离场纹理贴图包括:静态场景有向距离场纹理贴图和动态场景有向距离场纹理贴图;目标有向距离场纹理贴图包括多层纹理贴图,各层纹理贴图采用相同尺寸存储对应世界空间范围中各空间点的有向距离场信息,且各层纹理贴图中各像素点存储对应空间点的有向距离场信息;其中,各层纹理贴图所对应的世界空间范围根据世界空间范围与虚拟相机的距离确定。通过动静场景分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。Optionally, the target signed distance field texture map includes: a static scene signed distance field texture map and a dynamic scene signed distance field texture map; 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. By storing static and dynamic scenes separately, the SDF value of the static scene is stored in the static scene SDF texture map, and 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.
可选地,装置还包括:更新模块、初始化模块;确定模块110,还用于若当前的目标有向距离场纹理贴图为静态场景有向距离场纹理贴图,则根据当前的目标有向距离场纹理贴图所对应的世界空间范围与前一目标有向距离场纹理贴图所对应的世界空间范围,确定当前的目标有向距离场纹理贴图与前一目标有向距离场纹理贴图的重叠区域和非重叠区域;更新模块,用于根据前一目标有向距离场纹理贴图中重叠区域的各像素的有向距离场信息,对当前的目标有向距离场纹理贴图中重叠区域中各像素的有向距离场信息进行更新;初始化模块,用于将当前的目标有向距离场纹理贴图中非重叠区域中各像素的有向距离场信息初始化为预设值,第一像素点为非重叠区域中的像素点。 Optionally, 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.
可选地,初始化模块,还用于若目标有向距离场纹理贴图为动态场景有向距离场纹理贴图,则将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值,第一像素点为当前的目标有向距离场纹理贴图中的任一像素点。通过该初始化模块将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值可以避免光线步进的过程中会跳过障碍物,无法获取光线步进的准确结果的技术问题,从而使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题,有效提升计算结果的准确性。Optionally, 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.
可选地,确定模块110,具体用于根据第一像素点的像素坐标信息以及第一光栅化方向,确定沿第一光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第一相邻像素点;根据第一像素点的像素坐标信息以及第二光栅化方向,确定沿第二光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第二相邻像素点;根据第一像素点的像素坐标信息以及第三光栅化方向,确定沿第三光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第三相邻像素点。Optionally, 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.
可选地,生成模块120,具体用于根据第一空间点的空间坐标信息以及第一空间点所对应的三角面片的深度信息,生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息。Optionally, 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.
可选地,生成模块120,具体用于根据目标相邻空间点的空间坐标信息、以及第一空间点的空间坐标信息,生成目标相邻空间点与第一空间点之间的距离值,目标相邻空间点为各相邻空间点中的任一相邻空间点;根据第一空间点与目标相邻空间点的方向矢量以及第一空间点的法线的点乘结果;根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。Optionally, 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.
可选地,生成模块120,具体用于若点乘结果大于0,则将距离值作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息;若点乘结果小于或等于0,则将距离值的负数作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。Optionally, the generating module 120 is specifically configured to use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map if the dot product result is greater than 0; and use the negative number of the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map if the dot product result is less than or equal to 0.
可选地,生成模块120,具体用于判断当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息是否大于预设阈值,目标第二像素点为各第二像素点中的任一像素点;若是,则根据当前的目标有向距离场纹理贴图中目标第二像素点的各预设相邻像素点的有向距离场信息,确定初始的有向距离场信息;根据初始的有向距离场信息、以及目标有向距离场纹理贴图中单位像素边长映射至世界空间中的长度,生成当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息。Optionally, 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.
可选地,装置还包括:调整模块;调整模块,用于若生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值大于前一目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值,则将生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息调整为前一目标有向距离场纹理贴图中第一像素点的有向距离场信息。通过该调整模块对生成的SDF的值进行校正,可以保证每一帧渲染时所对应的目标SDF纹理贴图中各像素点的SDF值均能取得最精确的值,从而保证光线步进的准确性。Optionally, 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. By correcting the value of the generated SDF through the adjustment module, it can be ensured that the SDF value of each pixel point in the target SDF texture map corresponding to each frame of rendering can obtain the most accurate value, thereby ensuring the accuracy of light stepping.
可选地,装置还包括:渲染模块;渲染模块,用于根据当前的目标有向距离场纹理贴图中各像素点的有向距离场信息渲染当前帧。Optionally, 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.
通过上述装置,获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息, 而SDF本身表征的为空间点与场景物体的最近距离,那么直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。进一步结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。By using the above device, 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. Among them, since the spatial coordinate information is the actual position information of the spatial point, Since 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. Further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, effectively improving the accuracy of the calculation result.
以上这些模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit,简称ASIC),或,一个或多个微处理器(digital singnal processor,简称DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array,简称FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(Central Processing Unit,简称CPU)或其它可以调用程序代码的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,简称SOC)的形式实现。The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
上述模块可以经由有线连接或无线连接彼此连接或通信。有线连接可以包括金属线缆、光缆、混合线缆等,或其任意组合。无线连接可以包括通过LAN、WAN、蓝牙、ZigBee、或NFC等形式的连接,或其任意组合。两个或更多个模块可以组合为单个模块,并且任何一个模块可以分成两个或更多个单元。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考方法实施例中的对应过程,本公开中不再赘述。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. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this disclosure.
图12为本公开实施例提供的一种电子设备的结构示意图,包括:处理器801、存储介质802和总线803,存储介质802存储有处理器801可执行的机器可读指令,当电子设备运行如实施例中的一种有向距离场的生成方法时,处理器801与存储介质802之间通过总线803通信,处理器801执行机器可读指令,以执行以下步骤: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. When the electronic device runs a method for generating a directed distance field in the embodiment, 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:
根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息;根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息;根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,第二像素点为目标有向距离场中除第一像素点以及各相邻像素点之外的剩余像素点。According to the pixel coordinate information of the first pixel in the current target signed distance field texture map, 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.
在一个可行的实施方案中,目标有向距离场纹理贴图包括:静态场景有向距离场纹理贴图和动态场景有向距离场纹理贴图;目标有向距离场纹理贴图包括多层纹理贴图,各层纹理贴图采用相同尺寸存储对应世界空间范围中各空间点的有向距离场信息,且各层纹理贴图中各像素点存储对应空间点的有向距离场信息;其中,各层纹理贴图所对应的世界空间范围根据世界空间范围与虚拟相机的距离确定。在本实施例中,通过动静场景分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。In a feasible implementation scheme, 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. In this embodiment, the SDF value of the static scene is stored in the static scene SDF texture map, and 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.
在一个可行的实施方案中,处理器801在执行根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,还用于:若当前的目标有向距离场纹理贴图为静态场景有向距离场纹理贴图,则根据当前的目标有向距离场纹理贴图所对应的世界空间范围与前一目标有向距离场纹理贴图所对应的世界空间范围,确定当前的目标有向距离场纹理贴图与前一目标有向距离场纹理贴图的重叠区域和非重叠区域;根据前一目标有向距 离场纹理贴图中重叠区域的各像素的有向距离场信息,对当前的目标有向距离场纹理贴图中重叠区域中各像素的有向距离场信息进行更新;将当前的目标有向距离场纹理贴图中非重叠区域中各像素的有向距离场信息初始化为预设值,第一像素点为非重叠区域中的像素点。In a feasible implementation manner, before 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-overlapping area.
在一个可行的实施方案中,处理器801在执行根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,还用于:若目标有向距离场纹理贴图为动态场景有向距离场纹理贴图,则将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值,第一像素点为当前的目标有向距离场纹理贴图中的任一像素点。在该实施例中,将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值可以避免光线步进的过程中会跳过障碍物,无法获取光线步进的准确结果的技术问题,从而使得计算结果精确度较高。In a feasible implementation manner, before 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. In this embodiment, 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.
在一个可行的实施方案中,处理器801在执行根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点时,具体用于:根据第一像素点的像素坐标信息以及第一光栅化方向,确定沿第一光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第一相邻像素点;根据第一像素点的像素坐标信息以及第二光栅化方向,确定沿第二光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第二相邻像素点;根据第一像素点的像素坐标信息以及第三光栅化方向,确定沿第三光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第三相邻像素点。In a feasible implementation scheme, when 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 first pixel point.
在一个可行的实施方案中,处理器801在执行根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息时,具体用于:根据第一空间点的空间坐标信息以及第一空间点所对应的三角面片的深度信息,生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息。In a feasible implementation scheme, 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.
在一个可行的实施方案中,处理器801在执行根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息时,具体用于:根据目标相邻空间点的空间坐标信息、以及第一空间点的空间坐标信息,确定目标相邻空间点与第一空间点之间的距离值,目标相邻空间点为各相邻空间点中的任一相邻空间点;根据第一空间点与目标相邻空间点的方向矢量以及第一空间点的法线的点乘结果;根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。In a feasible implementation scheme, 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.
在一个可行的实施方案中,处理器801在执行根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息时,具体用于:若点乘结果大于0,则将距离值作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息;若点乘结果小于或等于0,则将距离值的负数作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。In a feasible implementation manner, when the processor 801 generates the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value, it is specifically configured to: if the dot product result is greater than 0, use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map; 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.
在一个可行的实施方案中,处理器801在执行根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息时,具体用于:判断当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息是否大于预设阈值,目标第二像素点为各第二像素点中的任一像素点;若是,则根据当前的目标有向距离场纹理贴图中目标第二像素点的各预设相邻像素点的有向距离场信息,确定初始的有向距离场信息;根据初始的有向距离场信息、以及目标有向距离场纹理贴图中单位像素边长映射至世界空间中的长度,生成当前 的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息。In a feasible implementation scheme, 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.
在一个可行的实施方案中,处理器801在执行第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息之后,还用于:若生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值大于前一目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值,则将生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息调整为前一目标有向距离场纹理贴图中第一像素点的有向距离场信息。通过该实施例对生成的SDF的值进行校正,可以保证每一帧渲染时所对应的目标SDF纹理贴图中各像素点的SDF值均能取得最精确的值,从而保证光线步进的准确性。In a feasible implementation scheme, after executing the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel to generate the signed distance field information of each second pixel in the current target signed distance field texture map, the processor 801 is further 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. By correcting the value of the generated SDF in this embodiment, it can be ensured that the SDF value of each pixel in the target SDF texture map corresponding to each frame rendering can obtain the most accurate value, thereby ensuring the accuracy of the light stepping.
在一个可行的实施方案中,处理器801还用于:根据当前的目标有向距离场纹理贴图中各像素点的有向距离场信息渲染当前帧。In a feasible implementation, the processor 801 is further configured to render the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.
通过上述方式,电子设备通过获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。并且进一步地结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。Through the above method, the electronic device can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.
其中,存储介质802存储有程序代码,当程序代码被处理器801执行时,使得处理器801执行本说明书上述“示例性方法”部分中描述的根据本公开各种示例性实施方式的有向距离场的生成方法中的各种步骤。The storage medium 802 stores program codes. When the program codes are executed by the processor 801, the processor 801 executes various steps of the method for generating a directed distance field according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
处理器801可以是通用处理器,例如中央处理器(CPU)、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本公开实施例中公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本公开实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。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.
存储介质802作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。存储器可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random Access Memory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性存储器、磁盘、光盘等等。存储器是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本公开实施例中的存储介质802还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。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. 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.
可选地,本公开实施例还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行,处理器执行以下步骤:Optionally, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor performs the following steps:
根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界 空间中的第一空间点的空间坐标信息;根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点,并根据各相邻像素点的像素坐标信息确定各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息;根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息,第二像素点为目标有向距离场中除第一像素点以及各相邻像素点之外的剩余像素点。According to the pixel coordinate information of the first pixel in the current target signed distance field texture map, determine the first pixel mapped to the world 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 and the adjacent pixels.
在一个可行的实施方案中,目标有向距离场纹理贴图包括:静态场景有向距离场纹理贴图和动态场景有向距离场纹理贴图;目标有向距离场纹理贴图包括多层纹理贴图,各层纹理贴图采用相同尺寸存储对应世界空间范围中各空间点的有向距离场信息,且各层纹理贴图中各像素点存储对应空间点的有向距离场信息;其中,各层纹理贴图所对应的世界空间范围根据世界空间范围与虚拟相机的距离确定。在本实施例中,通过动静场景分离存储的方式,将静态场景的SDF值对应存储至静态场景SDF纹理贴图中,将动态场景的SDF值对应存储至动态场景SDF纹理贴图中,由于静态场景的SDF值不需要每个都进行更新,从而可有效降低生成SDF值时的运算量。In a feasible implementation scheme, 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. In this embodiment, the SDF value of the static scene is stored in the static scene SDF texture map, and 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.
在一个可行的实施方案中,处理器801在执行根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,还用于:若当前的目标有向距离场纹理贴图为静态场景有向距离场纹理贴图,则根据当前的目标有向距离场纹理贴图所对应的世界空间范围与前一目标有向距离场纹理贴图所对应的世界空间范围,确定当前的目标有向距离场纹理贴图与前一目标有向距离场纹理贴图的重叠区域和非重叠区域;根据前一目标有向距离场纹理贴图中重叠区域的各像素的有向距离场信息,对当前的目标有向距离场纹理贴图中重叠区域中各像素的有向距离场信息进行更新;将当前的目标有向距离场纹理贴图中非重叠区域中各像素的有向距离场信息初始化为预设值,第一像素点为非重叠区域中的像素点。In a feasible implementation manner, 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.
在一个可行的实施方案中,处理器801在执行根据当前的目标有向距离场纹理贴图中第一像素点的像素坐标信息,确定第一像素点映射至世界空间中的第一空间点的空间坐标信息之前,还用于:若目标有向距离场纹理贴图为动态场景有向距离场纹理贴图,则将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值,第一像素点为当前的目标有向距离场纹理贴图中的任一像素点。在该实施例中,将当前的目标有向距离场纹理贴图中各像素的有向距离场信息初始化为预设值可以避免光线步进的过程中会跳过障碍物,无法获取光线步进的准确结果的技术问题,从而使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题,有效提升计算结果的准确性。In a feasible implementation scheme, before 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. In this embodiment, 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.
在一个可行的实施方案中,处理器801在执行根据第一像素点的像素坐标信息以及预设的光栅化方向,分别确定第一像素点对应的各相邻像素点时,具体用于:根据第一像素点的像素坐标信息以及第一光栅化方向,确定沿第一光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第一相邻像素点;根据第一像素点的像素坐标信息以及第二光栅化方向,确定沿第二光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第二相邻像素点;根据第一像素点的像素坐标信息以及第三光栅化方向,确定沿第三光栅化方向且与第一像素点相邻预设数量的各像素点为第一像素点对应的各第三相邻像素点。In a feasible implementation scheme, when 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 first pixel point.
在一个可行的实施方案中,处理器801在执行根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,分别生成当前的目标有向距离场纹理贴图中第一像素点的 有向距离场信息以及各相邻像素点的有向距离场信息时,具体用于:根据第一空间点的空间坐标信息以及第一空间点所对应的三角面片的深度信息,生成当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息;根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息。In a feasible implementation, 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. When 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.
在一个可行的实施方案中,处理器801在执行根据第一空间点的空间坐标信息、各相邻空间点的空间坐标信息以及第一空间点的法线朝向,生成当前的目标有向距离场纹理贴图中各相邻像素点的有向距离场信息时,具体用于:根据目标相邻空间点的空间坐标信息、以及第一空间点的空间坐标信息,确定目标相邻空间点与第一空间点之间的距离值,目标相邻空间点为各相邻空间点中的任一相邻空间点;根据第一空间点与目标相邻空间点的方向矢量以及第一空间点的法线的点乘结果;根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。In a feasible implementation scheme, 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.
在一个可行的实施方案中,处理器801在执行根据点乘结果、以及距离值,生成当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息时,具体用于:若点乘结果大于0,则将距离值作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息;若点乘结果小于或等于0,则将距离值的负数作为当前的目标有向距离场纹理贴图中目标相邻像素点的有向距离场信息。In a feasible implementation manner, when the processor 801 generates the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map according to the dot product result and the distance value, it is specifically configured to: if the dot product result is greater than 0, use the distance value as the signed distance field information of the target adjacent pixel points in the current target signed distance field texture map; 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.
在一个可行的实施方案中,处理器801在执行根据第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息时,具体用于:判断当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息是否大于预设阈值,目标第二像素点为各第二像素点中的任一像素点;若是,则根据当前的目标有向距离场纹理贴图中目标第二像素点的各预设相邻像素点的有向距离场信息,确定初始的有向距离场信息;根据初始的有向距离场信息、以及目标有向距离场纹理贴图中单位像素边长映射至世界空间中的长度,生成当前的目标有向距离场纹理贴图中目标第二像素点的有向距离场信息。In a feasible implementation manner, 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.
在一个可行的实施方案中,处理器801在执行第一像素点的有向距离场信息以及各相邻像素点的有向距离场信息,分别生成当前的目标有向距离场纹理贴图中各第二像素点的有向距离场信息之后,还用于:若生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值大于前一目标有向距离场纹理贴图中第一像素点的有向距离场信息的绝对值,则将生成的当前的目标有向距离场纹理贴图中第一像素点的有向距离场信息调整为前一目标有向距离场纹理贴图中第一像素点的有向距离场信息。通过该实施例对生成的SDF的值进行校正,可以保证每一帧渲染时所对应的目标SDF纹理贴图中各像素点的SDF值均能取得最精确的值,从而保证光线步进的准确性。In a feasible implementation scheme, after executing the signed distance field information of the first pixel and the signed distance field information of each adjacent pixel to generate the signed distance field information of each second pixel in the current target signed distance field texture map, the processor 801 is further 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. By correcting the value of the generated SDF in this embodiment, it can be ensured that the SDF value of each pixel in the target SDF texture map corresponding to each frame rendering can obtain the most accurate value, thereby ensuring the accuracy of the light stepping.
在一个可行的实施方案中,处理器801还用于:根据当前的目标有向距离场纹理贴图中各像素点的有向距离场信息渲染当前帧。In a feasible implementation, the processor 801 is further configured to render the current frame according to the signed distance field information of each pixel point in the current target signed distance field texture map.
通过上述方式,电子设备通过获取待生成SDF值的第一像素点映射至世界空间中的第一空间点的空间坐标信息以及第一像素点对应的各相邻像素点映射至世界空间中的各相邻空间点的空间坐标信息可分别生成第一像素点的SDF值以及各相邻像素点的SDF值。其中,由于空间坐标信息为空间点的实际位置信息,而SDF本身表征的为空间点与场景物体的最近距离,那么,直接采用空间点的实际位置信息进行SDF的计算,可以使得计算结果精确度较高,摆脱了传统依赖空间点的深度信息进行计算时,深度信息缺失所导致的计算结果准确性较差的问题。并且进一步地结合空间点的法线朝向可以确定空间点与其最近的场景物体的位置关系,从而对计算得到的SDF的取值正负号进行准确判定,有效提升计算结果的准确性。Through the above method, the electronic device can respectively generate the SDF value of the first pixel point and the SDF value of each adjacent pixel point by obtaining the spatial coordinate information of the first pixel point to be generated and mapped to the first spatial point in the world space and the spatial coordinate information of each adjacent pixel point corresponding to the first pixel point and mapped to each adjacent spatial point in the world space. Among them, since the spatial coordinate information is the actual position information of the spatial point, and the SDF itself represents the closest distance between the spatial point and the scene object, then, directly using the actual position information of the spatial point to calculate the SDF can make the calculation result more accurate, and get rid of the problem of poor accuracy of the calculation result caused by the lack of depth information when the traditional calculation relies on the depth information of the spatial point. And further combined with the normal direction of the spatial point, the positional relationship between the spatial point and its nearest scene object can be determined, so as to accurately determine the positive and negative signs of the calculated SDF value, and effectively improve the accuracy of the calculation result.
在本公开实施例中,该计算机程序被处理器运行时还可以执行其它机器可读指令,以执行如实施 例中其它的方法,关于具体执行的方法步骤和原理参见实施例的说明,在此不再详细赘述。In the embodiment of the present disclosure, the computer program can also execute other machine-readable instructions when it is executed by the processor to implement the following For other methods in the example, please refer to the description of the embodiment for the specific implementation steps and principles, which will not be described in detail here.
在本公开所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, 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.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(英文:processor)执行本公开各个实施例方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(英文:Read-Only Memory,简称:ROM)、随机存取存储器(英文:Random Access Memory,简称:RAM)、磁碟或者光盘等各种可以存储程序代码的介质。 In addition, 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.
Claims (14)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310680194.3A CN116704098B (en) | 2023-06-08 | 2023-06-08 | Method, device, electronic device and storage medium for generating directed distance field |
| CN202310680194.3 | 2023-06-08 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024251027A1 true WO2024251027A1 (en) | 2024-12-12 |
Family
ID=87830691
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/096366 Ceased WO2024251027A1 (en) | 2023-06-08 | 2024-05-30 | Method and apparatus for generating signed distance field, and electronic device and storage medium |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN116704098B (en) |
| WO (1) | WO2024251027A1 (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116704098B (en) * | 2023-06-08 | 2025-03-04 | 网易(杭州)网络有限公司 | Method, device, electronic device and storage medium for generating directed distance field |
| CN117152237A (en) * | 2023-09-25 | 2023-12-01 | 不鸣科技(杭州)有限公司 | A distance field generation method, device, electronic equipment and storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107452048A (en) * | 2016-05-30 | 2017-12-08 | 网易(杭州)网络有限公司 | The computational methods and device of global illumination |
| CN114820836A (en) * | 2021-01-28 | 2022-07-29 | 北京字跳网络技术有限公司 | Directed distance field image, character effect image generation method, device and medium |
| CN115115747A (en) * | 2021-03-09 | 2022-09-27 | 网易(杭州)网络有限公司 | Lighting rendering method, device, electronic device and storage medium |
| US20230082839A1 (en) * | 2021-09-10 | 2023-03-16 | Adobe Inc. | Rendering scalable raster content |
| CN116704098A (en) * | 2023-06-08 | 2023-09-05 | 网易(杭州)网络有限公司 | Directed distance field generation method, device, electronic device and storage medium |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113012210B (en) * | 2021-03-25 | 2022-09-27 | 北京百度网讯科技有限公司 | Method and device for generating depth map, electronic equipment and storage medium |
| CN115375847B (en) * | 2022-08-25 | 2023-08-29 | 北京百度网讯科技有限公司 | Material recovery method, 3D model generation method and model training method |
-
2023
- 2023-06-08 CN CN202310680194.3A patent/CN116704098B/en active Active
-
2024
- 2024-05-30 WO PCT/CN2024/096366 patent/WO2024251027A1/en not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107452048A (en) * | 2016-05-30 | 2017-12-08 | 网易(杭州)网络有限公司 | The computational methods and device of global illumination |
| CN114820836A (en) * | 2021-01-28 | 2022-07-29 | 北京字跳网络技术有限公司 | Directed distance field image, character effect image generation method, device and medium |
| CN115115747A (en) * | 2021-03-09 | 2022-09-27 | 网易(杭州)网络有限公司 | Lighting rendering method, device, electronic device and storage medium |
| US20230082839A1 (en) * | 2021-09-10 | 2023-03-16 | Adobe Inc. | Rendering scalable raster content |
| CN116704098A (en) * | 2023-06-08 | 2023-09-05 | 网易(杭州)网络有限公司 | Directed distance field generation method, device, electronic device and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116704098B (en) | 2025-03-04 |
| CN116704098A (en) | 2023-09-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12347016B2 (en) | Image rendering method and apparatus, device, medium, and computer program product | |
| CN113808241B (en) | Hardware acceleration of ray traced primitives sharing vertices | |
| JP7606007B2 (en) | Method and system for providing temporary texture application to enhance 3D modeling - Patents.com | |
| CN111369655B (en) | Rendering method, rendering device and terminal equipment | |
| US9098930B2 (en) | Stereo-aware image editing | |
| CN111243071A (en) | Texture rendering method, system, chip, device and medium for real-time three-dimensional human body reconstruction | |
| 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 (en) | Method and apparatus for generating signed distance field, and electronic device and storage medium | |
| CN114119853B (en) | Image rendering method, apparatus, device and medium | |
| US9224233B2 (en) | Blending 3D model textures by image projection | |
| US12602858B2 (en) | Rendering method and apparatus, and device | |
| CN113643414A (en) | Three-dimensional image generation method and device, electronic equipment and storage medium | |
| CN113570697A (en) | Shadow rendering method and device based on model prebaking and readable storage medium | |
| US8872824B1 (en) | System, method, and computer program product for performing shadowing utilizing shadow maps and ray tracing | |
| KR102558739B1 (en) | 3d graphic rendering method and apparatus | |
| JP3629243B2 (en) | Image processing apparatus and method for rendering shading process using distance component in modeling | |
| CN110276835B (en) | Method and apparatus for efficient building footprint determination | |
| US7586494B2 (en) | Surface detail rendering using leap textures | |
| CN116993894A (en) | Virtual screen generation method, device, equipment, storage medium and program product | |
| CN115690365A (en) | Method, apparatus, device and medium for managing three-dimensional model | |
| CN118985009A (en) | Method and system for rendering three-dimensional scenes | |
| 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 (en) | Method and device for positioning projection position of light source and rendering scene |
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 |