WO2017206325A1 - 全局光照的计算方法及装置 - Google Patents

全局光照的计算方法及装置 Download PDF

Info

Publication number
WO2017206325A1
WO2017206325A1 PCT/CN2016/093567 CN2016093567W WO2017206325A1 WO 2017206325 A1 WO2017206325 A1 WO 2017206325A1 CN 2016093567 W CN2016093567 W CN 2016093567W WO 2017206325 A1 WO2017206325 A1 WO 2017206325A1
Authority
WO
WIPO (PCT)
Prior art keywords
pixel
illumination
information
distance field
world
Prior art date
Application number
PCT/CN2016/093567
Other languages
English (en)
French (fr)
Inventor
黄健聪
Original Assignee
网易(杭州)网络有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 网易(杭州)网络有限公司 filed Critical 网易(杭州)网络有限公司
Priority to US15/778,227 priority Critical patent/US11024077B2/en
Publication of WO2017206325A1 publication Critical patent/WO2017206325A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/06Ray-tracing
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/08Volume rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/503Blending, e.g. for anti-aliasing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/506Illumination models
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/50Depth or shape recovery
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G5/00Control arrangements or circuits for visual indicators common to cathode-ray tube indicators and other visual indicators
    • G09G5/36Control arrangements or circuits for visual indicators common to cathode-ray tube indicators and other visual indicators characterised by the display of a graphic pattern, e.g. using an all-points-addressable [APA] memory
    • G09G5/363Graphics controllers
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images
    • A63F2300/6615Methods for processing data by generating or executing the game program for rendering three dimensional images using models with different levels of detail [LOD]
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images
    • A63F2300/6646Methods for processing data by generating or executing the game program for rendering three dimensional images for the computation and display of the shadow of an object or character
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2210/00Indexing scheme for image generation or computer graphics
    • G06T2210/36Level of detail
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G2350/00Solving problems of bandwidth in display systems
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G2360/00Aspects of the architecture of display systems
    • G09G2360/08Power processing, i.e. workload management for processors involved in display operations, such as CPUs or GPUs

Definitions

  • the present invention relates to the field of computer image processing, and in particular to a method and apparatus for calculating global illumination.
  • the offline global illumination method is mainly used in the production of movies, game computer animation (CG), and animated short films. Since these technologies generally have more computational complexity and there is no real-time game running requirement, the offline method is to achieve photos. Level rendering quality is required, combined with optical related knowledge to re-approach true lighting effects.
  • the core algorithms used for offline global illumination include: Path Tracing and Photon Mapping. The main feature of these offline calculation methods is that the illumination intensity is calculated accurately, including multiple reflections, but the calculation is large, and it usually takes tens of minutes to render a frame of results.
  • Path Tracing is an optical path tracking algorithm that integrates all the rays reaching a certain point in the scene to determine the intensity of the light reflected into the camera and performs the same recursive operation on the rays.
  • Photon Mapping is an optical path tracking algorithm, but it records the incident result of the light before the lens is recorded in the texture, and then can interpolate the smoothing result in these illumination information, which is a more positive and fast convergence.
  • Global illumination algorithm which typically has lower computational complexity than Path Tracing.
  • the real-time global illumination method is mainly applied to real-time rendering engines, including: modeling software and game engine.
  • the range of considerations that can be considered according to technology can be roughly divided into screen space algorithms and world space algorithms.
  • the characteristics of the algorithm take into account the quality of the single frame, the computation of the single frame, the adaptation of the hardware and rendering application programming interface (API), and the less data throughput of the central processing unit (CPU) and graphics processing unit (GPU). This ensures the stability of each frame rendering and maintains a high frame rate.
  • the real-time global illumination technology is mainly divided into two technical routes: screen space and world space.
  • the global illumination scheme for screen space mainly includes: Screen Space Ambient Occlusion (SSAO).
  • SSAO Ambient Occlusion
  • AO Ambient Occlusion
  • SSAO uses the depth information of the screen space to calculate the geometric occlusion of the scene.
  • the general SSAO technique uses only one layer of depth information to calculate.
  • the world space scheme achieves better technical results because the rendering method takes into account the three-dimensional data of the entire scene and does not suffer from defects such as screen space schemes (eg : Incomplete data and AO close to the camera object will interfere with the object AO that is far away. Therefore, the calculated value of the rendering method is closer to the deterministic solution.
  • defects such as screen space schemes (eg : Incomplete data and AO close to the camera object will interfere with the object AO that is far away. Therefore, the calculated value of the rendering method is closer to the deterministic solution.
  • the global illumination scheme of the world space includes: Voxel Ambient Occlusion (VXAO) based on the voxel Ambient Occlusion (VXAO) based on the model voxel abstraction method, based on voxels
  • VXGI Voxel Global Illumination
  • Cryengine which is the next-generation game engine produced by the German company Crytek, representing the game: Crysis, Far Cry Series, Son of Rome
  • SVOTI sparse octree Sparse Voxel Octree Total Illumination
  • DFAO DFGI based on the Unreal Engine of the directed distance field method.
  • the principle of world space global illumination scheme is: the scene is stored in the GPU as voxel to store geometry and illumination information; voxel is the three-dimensional representation of pixels, and the scene of voxel data visualization is similar to Microsoft.
  • the performance of the Minecraft game the generation of voxels is generally performed in the GPU, the geometric patch information of the scene is three-dimensionally rasterized and stored in the three-dimensional texture; the greater the resolution of the voxel, the fineness of the scene object The better; when voxel data is generated, global illumination can be calculated using the Voxel Cone Tracing technique.
  • the main drawback of the voxel abstraction method is that the CPU and GPU have a large amount of data transmission, and it is impossible to complete a wide range of field scenes and a large number of skeletal animation models. Because these methods of three-dimensionally rasterizing the model need to fill the geometric information of the model in the three-dimensional texture, it has a high filling rate, especially the increase of the three-dimensional texture resolution is very fast for the increase of the required calculation data. If there are many models in the entire scene that are dynamic or the characters are moving fast, it will result in high data loading load or load generation. When the model has skeletal animation, this method requires a new voxel rasterization of the model per frame, and also needs to inject this part of the data into the global data.
  • the principle of the global illumination scheme of world space is to reconstruct the scene through the directed distance field.
  • the method used by Epic's Unreal 4 game engine is to generate local directional distance field data for each object offline, and combine the DX11 features during game rendering so that the distance field of objects within the ray and visible range can be achieved in world space ( Distance Field, which is a scalar field, the distance to the nearest surface in the storage space) bounds the box and uses the Distance Field for Sphere Tracing.
  • the Unreal 4 game engine does not store direct lighting of objects, so its indirect lighting implementation combines Distance Filed and Virtual Point Light technology.
  • the embodiment of the invention provides a method and a device for calculating the global illumination, so as to at least solve the technical problem that the global illumination calculation method provided in the related art is easy to consume more hardware resources and the presented picture effect is not ideal.
  • a method for calculating global illumination including:
  • the global illumination calculation is performed according to the directed distance field information and/or the illumination information corresponding to each pixel.
  • obtaining the illumination information corresponding to each pixel includes: rasterizing the two-dimensional texture, and obtaining the world coordinate position of the corresponding voxel in the three-dimensional texture by mapping the position of each pixel in the two-dimensional texture. Mapping the world coordinate position of each voxel to the display space of the screen to obtain corresponding screen display coordinates; extracting illumination information corresponding to the screen display coordinates from the current frame image data.
  • obtaining the directional distance field information corresponding to each pixel includes: rasterizing the two-dimensional texture, The position of each pixel in the two-dimensional map is mapped to obtain the world coordinate position of the corresponding voxel in the three-dimensional map; the world coordinate position of each voxel is mapped into the display space of the screen to obtain the corresponding screen display coordinate.
  • the directional distance field information and the illumination information corresponding to the image data of the previous frame adjacent to the current frame image data displayed in the screen are calculated, and the corresponding world position distance of each pixel on the image data of the previous frame is calculated, and each pixel is used.
  • the corresponding world position distance on the current frame image data and the corresponding world position distance of each pixel on the previous frame image data are weighted and averaged to obtain the directed distance field information corresponding to each pixel.
  • performing global illumination calculation according to the directional distance field information and/or the illumination information corresponding to each pixel includes: determining a sampling point to be used in performing global illumination calculation for each pixel; corresponding to each sampling point
  • the voxel acquires a plurality of adjacent voxels at the world coordinate position in the three-dimensional map; and uses the directed distance field information and the illumination information of the plurality of adjacent voxels to perform the directed distance field information and the illumination information corresponding to each pixel.
  • the iterative correction is performed to obtain the adjusted directed distance field information and illumination information corresponding to each pixel; and the global illumination calculation is performed by using the adjusted directed distance field information and/or illumination information corresponding to each pixel.
  • performing global illumination calculation using the adjusted directed distance field information and/or illumination information corresponding to each pixel includes at least one of the following: a world in which each pixel corresponds to a starting sampling point of the surface of the object to be rendered.
  • the normalized occlusion calculation is performed by tracking the adjusted directional distance field information corresponding to the cone uniformly distributed in the plurality of directions in the hemispherical plane of the normal line to obtain the ambient light occlusion information; corresponding to each pixel on the surface of the object to be rendered
  • the world normal line of the starting sampling point tracks the adjusted directed distance field information and the illumination information corresponding to the evenly distributed cone in a plurality of directions in the hemispherical plane of the starting sampling point to obtain indirect illumination information, and obtains indirect illumination information;
  • the inward ray of the orientation and the reflection line on the world normal direction of the initial sampling point corresponding to the surface of the object to be rendered are spheroidally tracked by the adjusted directional distance field information corresponding to the voxel,
  • the method further includes: smoothing the global illumination calculation result by using an inter-frame anti-aliasing (Temporal AA), and The resolution adopted when selecting a plurality of pixels is upsampled to the full screen resolution of the screen, wherein the global illumination calculation result includes at least one of the following: ambient light shading information, indirect lighting information, and specular reflection information.
  • Temporal AA inter-frame anti-aliasing
  • a computing device for global illumination including:
  • the acquiring module is configured to obtain directional distance field information and/or illumination information corresponding to each pixel of the plurality of pre-selected pixels in the screen, wherein the directional distance field information and the illumination information corresponding to each pixel are stored in the three-dimensional The two-dimensional texture mapd by the map; the calculation module is configured to perform global illumination calculation according to the directional distance field information and/or the illumination information corresponding to each pixel.
  • the obtaining module includes: a first mapping unit configured to perform rasterization processing on the two-dimensional texture, and obtain a world coordinate of the corresponding voxel in the three-dimensional texture by mapping the position of each pixel in the two-dimensional map. a second mapping unit configured to map a world coordinate position of each voxel to a display space of the screen to obtain a corresponding screen display coordinate; the first acquiring unit is configured to extract and display screen coordinates from the current frame image data Corresponding lighting information.
  • the obtaining module includes: a first mapping unit configured to perform rasterization processing on the two-dimensional texture, and obtain a world coordinate of the corresponding voxel in the three-dimensional texture by mapping the position of each pixel in the two-dimensional map.
  • a second mapping unit configured to map a world coordinate position of each voxel to a display space of the screen to obtain a corresponding screen display coordinate
  • the first calculating unit is configured to calculate a world coordinate position and corresponding to each voxel separately
  • the screen display coordinate s the world position distance between the world coordinate positions restored according to the depth map of the screen, and limits the world position distance within a preset numerical range
  • the second obtaining unit is configured to acquire and the screen
  • the directional distance field information and the illumination information corresponding to the image data of the previous frame adjacent to the current frame image data displayed therein are calculated, and the corresponding world position distance of each pixel on the image data of the previous frame is calculated, and each pixel is used.
  • Corresponding world position distance on the current frame image data and corresponding to each pixel on the previous frame image data Boundary position distance weighted average calculation, to obtain information from fields corresponding to each pixel.
  • the calculation module includes: a determining unit, configured to determine a sampling point to be used in performing global illumination calculation for each pixel; and a third acquiring unit configured to be in the three-dimensional map according to the voxel corresponding to each sampling point
  • the world coordinate position acquires a plurality of adjacent voxels
  • the adjusting unit is configured to perform the directed distance field information and the illumination information corresponding to each pixel multiple times by using the directed distance field information and the illumination information of the plurality of adjacent voxels
  • the iterative correction is performed to obtain the adjusted directed distance field information and illumination information corresponding to each pixel
  • the second calculating unit is configured to perform global illumination by using the adjusted directed distance field information and/or illumination information corresponding to each pixel. Calculation.
  • the second calculating unit is configured to track the corresponding adjustment of the cone uniformly distributed in the plurality of directions in the hemispherical plane of the world normal direction of the initial sampling point corresponding to the surface of the object to be rendered corresponding to each pixel.
  • Mean occlusion calculation of the directed distance field information to obtain ambient light occlusion information and/or tracking multiple directions in a hemispherical plane of the world normal direction of the starting sampling point corresponding to the surface of the object to be rendered Performing voxel cone tracking on the adjusted directional distance field information and illumination information corresponding to the evenly distributed cone to obtain indirect illumination information; and/or, according to the directional ray of the viewpoint orientation and the surface of the object to be rendered at each pixel
  • the corresponding normal sampling point of the corresponding sampling point is oriented upward, and the spherical tracking is performed by the adjusted directed distance field information corresponding to the voxel to obtain specular reflection information.
  • the apparatus further includes: a processing module configured to perform smoothing on the global illumination calculation result by using the Temporal AA, and upsampling the resolution used when selecting the plurality of pixels to the full screen resolution of the screen, wherein, the global The lighting calculation result includes at least one of the following: ambient light shading information, indirect lighting information, mirror surface Reflect information.
  • the directional distance field information and the illumination information of the voxels corresponding to the pixels selected on the screen are stored in a two-dimensional map mapped by the three-dimensional map, and global illumination calculation is needed for the pixel.
  • the utility model reduces the calculation amount of the global illumination, reduces the hardware resource consumption, and improves the technical effect of the screen display effect, thereby solving the global illumination calculation method provided in the related art, which is easy to consume more hardware resources and the presented picture effect is not ideal. technical problem.
  • FIG. 1 is a flow chart of a method of calculating global illumination according to an embodiment of the present invention
  • FIG. 2 is a structural block diagram of a computing device for global illumination according to an embodiment of the present invention
  • FIG. 3 is a block diagram showing the structure of a computing device for global illumination in accordance with a preferred embodiment of the present invention.
  • an embodiment of a method of calculating global illumination is provided, it being noted that the steps illustrated in the flowchart of the figures may be performed in a computer system such as a set of computer executable instructions, and Although the logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
  • FIG. 1 is a flowchart of a method for calculating global illumination according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • Step S12 Obtain directional distance field information and/or illumination information corresponding to each pixel of the plurality of pixels pre-selected in the screen, where the directional distance field information and the illumination information corresponding to each pixel are stored in the three-dimensional map. In a two-dimensional map;
  • Step S14 performing global illumination calculation according to the directional distance field information and/or the illumination information corresponding to each pixel.
  • the global illumination calculation methods provided in the related art all have high GPU consumption and calculation amount, which have high requirements on computer hardware configuration, and are generally applicable to stand-alone games, but are not applicable to online games; specifically, CPU and GPU Data transmission per frame is large or data that needs to be preprocessed offline.
  • the global lighting method of world space mainly needs to establish a whole scene information in the GPU for the calculation of global illumination. This information mainly includes the direct illumination brightness of the scene and the geometric information of the scene.
  • the game scenes are generally very large, and some require seamless loading of maps. Therefore, the transmission performance of these data from the CPU to the GPU is one of the bottlenecks of the entire global illumination system.
  • the directional distance field information and the illumination information corresponding to each pixel are stored in the two-dimensional texture mapped by the three-dimensional map, thereby reducing the CPU and the GPU.
  • the amount of data transferred which in turn reduces the bandwidth of the data from the CPU to the GPU.
  • the same picture effect can be achieved while occupying less system resources than the prior art solution, and the possession and the prior art can be realized. A more picture effect can be achieved if the system resources of the solution are the same.
  • the material information bus of the current frame in the delayed rendering including but not limited to: material color, normal, material rendering parameters, which is mainly used for decoupling the material and the illumination during the rendering process, first
  • the opaque material in the screen generates the material bus, and then calculates the lighting result, avoiding the illumination calculation of the occluded position.
  • the illumination information and the directed distance field information are filled into the voxel map, wherein the data storage is pressed.
  • the directed distance field stores the illumination information and the distance field data; the illumination information is stored in the RGB component of the texture, and the directed distance field is stored in the alpha channel in the texture.
  • DirectX 9 only supports the writing of 2D textures, so you need to map 2D textures to 3D textures. That is, voxel maps use two-dimensional maps to store three-dimensional data. Data writing and reading require separate mapping of locations.
  • the 3D data UV needs to be mapped to a 2D texture UV.
  • the three-dimensional texture is firstly developed in two dimensions according to the depth segmentation, and is implemented by using a plurality of tiled two-dimensional textures. If you re-stack these tiled 2D textures together, you can restore the above 3D texture. Assuming that the resolution of the three-dimensional voxel is set to 128*128*128, then a two-dimensional texture corresponding to 16384 (ie 128*128)*128 size needs to be generated.
  • the reading of the two-dimensional texture can only perform linear interpolation between two-dimensional u and v
  • u, v, w it is necessary to read the two-dimensional texture to read w
  • the coordinates correspond to the two nearest slices in the 2D map (ie, the data in the two small squares), and the data of the two planes are interpolated to simulate the function of the 3D texture.
  • These two coordinate points are defined as uv1, uv2, and their corresponding mapping formulas are as follows:
  • float2 represents a vector with x, y values separated by commas;
  • Cell represents the coordinate value of the local space accessed in the three-dimensional data, SDF_VOLUME_WIDTH, SDF_VOLUME_HEIGHT, SDF_VOLUME_DEPTH is the maximum width and maximum height of the voxel map, Maximum depth.
  • step S12 acquiring the illumination information corresponding to each pixel may include the following steps:
  • Step S120 performing rasterization processing on the two-dimensional texture, and obtaining a world coordinate position of the corresponding voxel in the three-dimensional texture by mapping the position of each pixel in the two-dimensional texture;
  • Step S121 mapping the world coordinate position of each voxel to the display space of the screen to obtain corresponding screen display coordinates
  • Step S122 extracting illumination information corresponding to the screen display coordinates from the current frame image data.
  • lighting information can be calculated online using a simple Lambert rendering model.
  • this step calculation is a shadow calculation result that needs to be delayed. That is, in order to make the data injected into the three-dimensional voxel have the shadow information, the shadow map matching of the delayed rendering is required to generate the illumination information of the voxel data.
  • step S12 acquiring the directed distance field information corresponding to each pixel may include the following steps:
  • Step S123 performing rasterization processing on the two-dimensional texture, and obtaining a world coordinate position of the corresponding voxel in the three-dimensional texture by mapping the position of each pixel in the two-dimensional texture;
  • Step S124 mapping the world coordinate position of each voxel to the display space of the screen to obtain corresponding screen display coordinates
  • Step S125 respectively calculating a world position distance between the world coordinate position of each voxel and the world coordinate position restored by the screen display coordinate according to the depth map of the screen, and limiting the world position distance within a preset numerical range;
  • Step S126 acquiring directional distance field information and illumination information corresponding to the previous frame image data adjacent to the current frame image data displayed on the screen, and calculating a corresponding world position distance of each pixel on the previous frame image data, and The weighted average calculation is performed by using the corresponding world position distance of each pixel on the current frame image data and the corresponding world position distance of each pixel on the previous frame image data, to obtain the directed distance field information corresponding to each pixel.
  • the Signed Distance Field is a scalar field that stores the distance from each spatial location to the nearest triangular surface. The calculation process of this data is as follows:
  • the two-dimensional texture mapped to the three-dimensional data is rasterized, and the position of each pixel is mapped back to the three-dimensional data world coordinate position; secondly, the world coordinate position of each voxel is mapped into the screen space, thereby obtaining a corresponding screen.
  • UV coordinates if the voxel belongs to the visible range of the screen, calculate the world coordinate of the voxel and the corresponding screen UV coordinate sampling screen depth map (ie, get the data of the corresponding pixel in the screen in the depth map) The distance of the position (that is, the distance between two points in the three-dimensional world); finally, the distance is cut off from the maximum and minimum upper and lower limits (that is, the distance obtained in the previous step is cut off in a range), and the direction of the maximum and minimum cutoff is obtained.
  • the Truncated Signed Distance Field (TSDF) is a weighted average of the data corresponding to the previous frame.
  • the technical solution provided by the embodiment of the present invention is mainly applicable to network games and other general rendering rings. Therefore, the calculation of global illumination needs to cover a considerable range. In order to ensure that the global light is generated in a large range, and the calculation result near the screen can ensure sufficient accuracy, it is necessary to introduce a level of detail (referred to as LOD, that is, reduce the corresponding detail according to the distance of the camera distance). Rendering optimization scheme) system.
  • LOD level of detail
  • Clipmap is a kind of LOD technology. The principle is to use high-precision data to wrap the close-up part of the camera while using low-precision data to wrap the camera's distant view.
  • the implementation of the LOD is to generate a three-dimensional data package camera of the same resolution but different corresponding scene ranges, and to follow the camera for movement.
  • the lowest level of LOD is the smallest, and the highest accuracy is generated in generating 3D data.
  • the most advanced LOD level has the smallest accuracy, but the range is the largest; in other words, the space closer to the camera generates high-precision data, and the space farther from the camera generates low-precision data, thus ensuring that the near-field portion has a lower memory consumption.
  • a better picture presentation effect thereby ensuring that the user has a better global light rendering result when viewing the close-up view, and the foreground can also have a relatively moderate picture rendering effect.
  • the data preparation work before the global illumination calculation is as follows: using the three-dimensional voxel data storage to dynamically generate the world directed distance field information and the illumination information represented by the world space coordinates corresponding to the world directed distance field, and adopting The high-precision data package camera close-range area and the low-precision data package camera remote area, that is, using the Clipmap+LOD method to cover the camera-centered cube area to save memory usage.
  • the voxel data in the range of the camera frustum is updated by using the depth map generated by the conventional game engine's delayed rendering technology, wherein the directed distance field information uses the depth map to restore the world coordinate calculation, and the direct illumination information is utilized. Diffuse calculation.
  • the directed distance field and direct illumination voxel data of the entire scene reconstruction are obtained. Since the current data is obtained by weighted averaging of the data of the directed distance field and the data of the previous frame, it is also necessary to perform data preparation through a filtering process. When it is necessary to implement a rendering effect obtained by using a rendering technique (for example, ambient light shading, indirect lighting, reflection) to use a directed distance field, the above globally generated data may be used. In addition to global illumination, this data enables soft shadows, specular reflections, and physical collisions.
  • a rendering technique for example, ambient light shading, indirect lighting, reflection
  • step S14 performing global illumination calculation according to the directional distance field information and/or the illumination information corresponding to each pixel may include the following execution steps:
  • Step S140 determining sampling points to be used in performing global illumination calculation for each pixel
  • Step S141 Acquire a plurality of adjacent voxels according to a voxel corresponding to each sampling point in a world coordinate position in the three-dimensional map;
  • Step S142 using the directed distance field information and the illumination information of the plurality of adjacent voxels to perform iterative correction on the directed distance field information and the illumination information corresponding to each pixel to obtain the adjusted directed direction corresponding to each pixel.
  • Distance information and lighting information
  • Step S143 performing global illumination calculation using the adjusted directed distance field information and/or illumination information corresponding to each pixel.
  • the fused data is usually the highest ratio directly opposite the camera, the data itself has a great directional deviation from the standard SDF when the cutoff distance range is not small enough. However, if the range of the truncation is smaller, the latter is used. The more the voxel texture rendering technology needs to track, in other words, because the depth field generated by the camera generates the distance field, the effectiveness of the preferentially generated data is mainly biased toward the camera direction. There is an error with the definition of the standard distance field.
  • the loop finds the square Q that is adjacent to each face of the square O (ie, the adjacent voxels in the three-dimensional map are offset by the uv coordinate Corresponding to the length of the side of the voxel, the center distance of the two squares is d; the surface of the object can be set to the origin from the direction of the camera toward the surface of the object, and the plane outside the surface of the object can be set to the positive direction (take the positive sign ), the plane inside the surface of the object can be set to reverse (take a negative sign):
  • the guess distance of the square O is calculated according to the previously generated directed distance field information (distance) stored in the square Q (ie, the distance+d of Q) And storing the smaller of the previously generated directed distance field information and the guess distance stored in the partner O, wherein the convergence is the best case;
  • the intersection of the two circles of the common chord and the two circles is assumed to be the surface zero (ie, two adjacent grids are stored).
  • the distance can be regarded as the radius of two circles, the line connecting the two circles is the common chord of two circles, the intersection of the line connecting the two centers with the common chord is the approximate point), and then the intersection point to the square is obtained. distance.
  • the adjusted directed distance field information and/or illumination information is finally obtained.
  • step S142 performing global illumination calculation by using the adjusted directed distance field information and/or illumination information corresponding to each pixel may include at least one of the following steps:
  • Step S1420 Performing an average of the adjusted directed distance field information corresponding to the cone uniformly distributed in a plurality of directions in a hemispherical plane of the world normal direction of the initial sampling point corresponding to the surface of the object to be rendered. Obscuring calculations to obtain ambient light shading information;
  • the sampling start point is the world coordinate position of the current screen pixel according to the depth map, and the world normal corresponding to the pixel is obtained according to the pixel screen coordinates, thereby obtaining the orientation of the pixel representing the patch.
  • the illumination and occlusion information are tracked in the nine directions of the average distribution of the patch orientations starting at the sampling start point, wherein 10 tracking samples are taken in each direction. Finally, the average of the calculation results in the nine directions is obtained, and the final result is obtained. It should be noted that the cones formed in the nine directions are distributed as much as possible and occupy the hemispherical surface in the normal direction of the tracking surface.
  • StepVisibility is the visibility of each step of sampling
  • Distance is the directed distance field
  • SphereRadius is the radius of the cone bottom circle with the sampling starting point as the cone apex and the sampling point as the center of the section. This is an approximation method that uses the directed distance field to linearly calculate the visibility of a particular solid angle direction; at the same time, since the embodiment provided by the present invention can use TSDF, SphereRadius also needs to cut off the maximum value of the same directed distance field. .
  • the calculation of the corresponding pixel can be completed by using the ambient light shielding formula provided in the related art. I will not repeat them here.
  • Step S1421 Tracking the adjusted directed distance field information and illumination corresponding to the cone uniformly distributed in the plurality of directions in the hemispherical plane of the world normal direction of the initial sampling point corresponding to the surface of the object to be rendered.
  • the information is subjected to voxel cone tracking to obtain indirect illumination information;
  • the world coordinate value of the pixel is first restored by the screen depth, and this coordinate is taken as the starting point, and the illumination information is collected from the point in nine directions. Since the previously generated directed distance field data is provided with illumination information, the world normal of the voxel corresponding to each pixel can be used to track the correspondingly adjusted cones in multiple directions in the hemispherical plane. The voxel cone tracking is performed on the directed distance field information and the illumination information, thereby obtaining the indirect illumination calculation result.
  • Step S1422 Performing a sphere according to the adjusted directed distance field information corresponding to the voxel according to the incident ray of the viewpoint orientation and the reflection line of the world normal direction of the initial sampling point corresponding to the surface of the object to be rendered. Track and get specular reflection information.
  • the world value of the pixel is restored by using the depth value of the screen.
  • Sphere Tracing is performed using the directed distance field data to the direction of the incident ray and the normal of the pixel surface. . Get the lighting information for that point at the tracking end point.
  • Sphere Tracing is a method for tracking the distance field. It is mainly used to find the surface position of a starting point to the nearest distance in a specific direction. The principle is mainly: iteratively steps the step of each tracking using the directed distance field. The value of the directed distance field at the current tracking point is added during each recursion process; since the data stored by the directed distance field is the distance from the corresponding position to the nearest surface, it is consistent with the setting function of Sphere Tracing. So Sphere Tracing is a very efficient way to ray tracing in a directed distance field.
  • step S14 after the global illumination calculation is performed according to the directional distance field information and/or the illumination information corresponding to each pixel in step S14, the following execution steps may also be included:
  • Step S16 using the inter-frame anti-aliasing (Temporal AA) to smooth the global illumination calculation result, and upsampling the resolution used when selecting a plurality of pixels to the full-screen resolution of the screen, wherein the global illumination calculation result includes the following At least one of: ambient light shading information, indirect lighting information, specular reflection information.
  • Temporal AA inter-frame anti-aliasing
  • Temporal AA Inter-aliased anti-aliasing
  • Temporal AA Inter-aliased anti-aliasing
  • Its working principle is: using multi-frame data pairs to distinguish the results of the same pixel rendering over-sampling;
  • the biggest difference between the sawtooth technology is that the data that is oversampled by the traditional technology is derived from the position near it to render more results, while the Temporal AA distributes the data to be sampled in the multi-frame rendering result. Therefore, Temporal AA can achieve better anti-aliasing with lower hardware and software resources.
  • Temporal AA needs to effectively remap most of the previous frame to the current frame position. In this case, it is necessary to save the camera matrix of the previous frame and calculate the pixel 2D velocity field of the current frame. Temporal AA correctly maps more data from the previous frame, and the supersampling result will be better.
  • the global light tracking calculation occurs at one-eighth resolution of the screen, then bi-directional filtering upsampling (Upsample, which is a texture sampling method) to half resolution, and then upsampling by using Temperal AA. To full resolution.
  • the global illumination computing device may include: an obtaining module 10 configured to acquire directed distance field information and/or illumination information corresponding to each pixel of the plurality of pixels preselected in the screen, wherein each The directional distance field information and the illumination information corresponding to the pixels are stored in the two-dimensional map mapped by the three-dimensional map; the calculation module 20 is configured to globally according to the directional distance field information and/or the illumination information corresponding to each pixel. Light calculation.
  • FIG. 3 is a structural block diagram of a computing device for global illumination in accordance with a preferred embodiment of the present invention.
  • the obtaining module 10 includes: a first mapping unit 100 configured to perform rasterization processing on the two-dimensional texture, and obtain a corresponding voxel in the three-dimensional map by mapping the position of each pixel in the two-dimensional map.
  • the second mapping unit 102 is configured to map the world coordinate position of each voxel to the display space of the screen to obtain corresponding screen display coordinates;
  • the first obtaining unit 104 is configured to image data from the current frame. Extract the illumination information corresponding to the screen display coordinates.
  • the acquiring module 10 includes: a first mapping unit 100 configured to perform rasterization processing on the two-dimensional texture, and obtain a corresponding body by mapping the position of each pixel in the two-dimensional texture.
  • the second mapping unit 102 is configured to map the world coordinate position of each voxel to the display space of the screen to obtain corresponding screen display coordinates;
  • the first calculating unit 106 is configured to respectively Calculating a world position distance between a world coordinate position of each voxel and a world coordinate position restored by the corresponding screen display coordinate according to the depth map of the screen, and limiting the world position distance within a preset numerical range;
  • the obtaining unit 108 is configured to acquire directional distance field information and illumination information corresponding to the previous frame image data adjacent to the current frame image data displayed in the screen, and calculate each pixel on the previous frame image data.
  • Corresponding world position distance and adopting a corresponding world position distance of each pixel on the current frame image data and each pixel is in front of the Frame image data corresponding to the position of the world distance weighted average calculation, to obtain information from fields corresponding to each pixel.
  • the calculation module 20 includes: a determining unit 200 configured to determine a sampling point to be used in performing global illumination calculation process for each pixel; and a third obtaining unit 202 configured to be configured according to each sampling
  • the voxel corresponding to the point acquires a plurality of adjacent voxels in the world coordinate position in the three-dimensional map
  • the adjusting unit 204 is configured to use the directed distance field information and the illumination information of the plurality of adjacent voxels to correspond to each pixel Performing iterative correction on the distance field information and the illumination information to obtain the adjusted directed distance field information and illumination information corresponding to each pixel
  • the second calculation unit 206 is configured to use the adjusted directed direction corresponding to each pixel.
  • Global illumination calculations are performed from distance information and/or illumination information.
  • the second calculating unit 206 is configured to start at each pixel corresponding to the surface of the object to be rendered.
  • the world normal of the sample points to the average occlusion field corresponding to the adjusted directional distance field information corresponding to the cone uniformly distributed in the plurality of directions in the hemispherical plane of the sample, to obtain ambient light occlusion information; and/or, in each The pixel performs voxel cone tracking on the adjusted directed distance field information and illumination information corresponding to the cone uniformly distributed in multiple directions in the hemispherical surface of the starting point of the corresponding sampling point corresponding to the surface of the object to be rendered.
  • the adjusted corresponding to the voxel Sphere tracking is performed on the distance field information to obtain specular reflection information.
  • the foregoing apparatus further includes: a processing module 30 configured to perform smoothing on the global illumination calculation result by using the Temporal AA, and upsampling the resolution used when selecting the plurality of pixels to the screen.
  • a processing module 30 configured to perform smoothing on the global illumination calculation result by using the Temporal AA, and upsampling the resolution used when selecting the plurality of pixels to the screen.
  • Full screen resolution wherein the global illumination calculation result includes at least one of the following: ambient light shading information, indirect lighting information, and specular reflection information.
  • the disclosed technical contents may be implemented in other manners.
  • the device embodiments described above are only schematic.
  • the division of the unit may be a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium. , including a number of instructions to make one
  • the computer device (which may be a personal computer, server or network device, etc.) performs all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computer Hardware Design (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种全局光照的计算方法及装置,其中,该方法包括:获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中(S12);根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算(S14)。该方法解决了相关技术中所提供的全局光照计算方法易耗费较多的硬件资源且呈现的画面效果不够理想的技术问题。

Description

全局光照的计算方法及装置 技术领域
本发明涉及计算机图像处理领域,具体而言,涉及一种全局光照的计算方法及装置。
背景技术
目前,全局光照一直是实时游戏渲染的热点,其渲染的画面不仅需要考虑场景光源发出的光直接照射在考量表面(即物体表面)的效果,而且还需要考虑从光源出发的光线经过其他表面反射后再击中考量表面的光照效果。全局光照对于物件光照真实感和周围环境的融合发挥着巨大的作用。为了解决全局渲染方程,全局光照需要多次迭代积分,而没有分析解,因此只有使用蒙特卡罗相关的积分方法才能够求出数值解。考虑到精确全局光照算法的计算量十分庞大,通常所采用的实现方法可以分为离线和实时两大类技术方案。
离线全局光照方法主要应用于电影、游戏计算机动画(CG)、动画短片的制作,由于这些技术一般都具有更充足的运算量,同时还没有实时游戏的运行要求,因此,离线方法都以达到照片级渲染质量为要求,结合光学相关知识,重新接近真实的光照效果。离线全局光照所采用的核心算法包括:光路跟踪算法(Path Tracing)和光子映射算法(Photon Mapping)。这些离线计算方法主要特点是光照强度计算准确,包含多次反射,但是计算量大,一般要数十分钟才能渲染出一帧结果。Path Tracing是一种光路跟踪算法,其可以对到达场景某个点的所有光线进行积分得出该点反射入摄像机的光强,并对这些光线进行相同的递归操作。类似的,Photon Mapping也是一种光路跟踪算法,但它会将光线到达镜头前的一次入射结果记录在贴图中,而后能够在这些光照信息中进行插值平滑结果,属于一种更积极和快速收敛的全局光照算法,其通常比Path Tracing具有更低的运算复杂度。
实时全局光照方法主要应用于实时渲染引擎,其中,包括:建模软件、游戏引擎。鉴于其技术路线和原理多样化,根据技术实现的考量输入范围可以大致分为屏幕空间算法和世界空间的算法。算法特点在考量质量的同时,还要考虑单帧的计算量,硬件和渲染应用程序编程接口(API)的适应,较少的中央处理器(CPU)和图形处理器(GPU)数据传输量,从而保证每帧渲染的稳定性以及保持较高帧率。
由于本申请主要关注游戏引擎,因此,在下文中将重点讨论实时领域的全局光照计算方法。
实时全局光照技术的主要分为屏幕空间和世界空间两种技术路线。
屏幕空间的全局光照方案主要包括:屏幕空间环境光遮蔽(SSAO)。环境光遮蔽(Ambient Occlusion,简称为AO)主要用于模拟天光这种大范围面光源对物体产生的软阴影。带有AO技术的画面可以更好地分辨物体的距离和体积感。SSAO使用屏幕空间的深度信息用于计算场景的几何遮挡。一般的SSAO技术只使用一层深度信息计算。
相比于屏幕空间的全局光照方案,世界空间方案所取得的技术效果更佳,其原因在于:该渲染方法考虑了整个场景的三维数据,而且不会出现如屏幕空间方案所存在的缺陷(例如:数据不完备以及靠近摄像机物体的AO会对距离较远的物体AO产生干扰),故而,该渲染方法的计算数值也更接近确定解。
相关技术中所提供的世界空间的全局光照方案包括:基于模型体素抽象方法的英伟达公司(Nvidia)游戏插件的基于体素的环境光遮蔽算法(Voxel Ambient Occlusion,简称为VXAO)、基于体素的全局光照算法(Voxel Global Illumination,简称为VXGI)和Cryengine(其为德国公司Crytek出品的次时代游戏引擎,代表游戏有:孤岛危机、孤岛惊魂系列,罗马之子)引擎的基于稀疏八叉树体素的全局光照算法(Sparse Voxel Octree Total Illumination,简称为SVOTI),此外,还包括:基于有向距离场方法的虚幻引擎的DFAO、DFGI。
基于体素技术,世界空间的全局光照方案的原理在于:将场景在GPU中以体素形成存储几何与光照信息;体素即为像素的三维化表示方法,体素数据可视化构建的场景类似微软Minecraft游戏的表现;体素的生成一般在GPU中进行,将场景的几何面片信息进行三维的光栅化,并存储在三维纹理中;体素的分辨率越大,其代表场景物件的精细度越好;当生成体素数据后,就可以使用体素圆锥追踪(Voxel Cone Tracing)技术计算全局光照。
然而,基于体素抽象方法主要存在的缺陷在于:CPU与GPU的数据传输量较大,无法完成大范围的野外场景和大量骨骼动画的模型。因为这些将模型三维光栅化的方法需要将模型的几何信息填充在三维贴图中,其具有较高的填充率,特别是三维贴图分辨率的增大对需要计算数据的增大十分迅速。如果整个场景有很多模型都是动态的或者角色在快速的移动,就会带来很高的数据加载负载或生成负载。当模型带有骨骼动画时,这种方法需要每帧对模型进行重新的体素光栅化,同时还需要将这部分数据注入到全局的数据中。
基于有向距离场的技术,世界空间的全局光照方案的原理在于将场景通过有向距离场重建数据。Epic公司的虚幻4游戏引擎所采用的方法是离线生成每个物件的局部有向距离场数据,并在游戏渲染时结合DX11特性,从而可以在世界空间对射线与可视范围内物体距离场(Distance Field,其为一种标量场,存储空间中到达最近表面的距离)包围盒求交和利用Distance Field进行球体追踪(Sphere Tracing)。另一方面,虚幻4游戏引擎并没有存储物体的直接光照,因此,其间接光照实现是结合了Distance Filed和虚拟点光源(Virtual Point Light)技术。
然而,基于有向距离场的技术的主要缺陷在于:不支持镜面反射。以虚幻引擎的DFGI为例,其通过离线生成的有向距离场来计算全局光照,同样不能支持动态骨骼动画物件。不仅如此,由于虚幻引擎的DFGI仅具有距离场信息,而没有场景的光照信息,其不能支持镜面反射的渲染。同时,DFGI的间接光照是利用虚拟点光源实现,而这些虚拟点光源模拟间接光照在数量较少的情况下效果较差,而数量增大又会带来巨大的开销。
同时,还需要指出的是,上述相关技术中所提供的技术方案的实现都需要借助于DirectX 11的高级特性,由于存在较高的性能开销,故而难以支持带骨骼动画的物件,不适合在网游引擎里实现。
针对上述的问题,目前尚未提出有效的解决方案。
发明内容
本发明实施例提供了一种全局光照的计算方法及装置,以至少解决相关技术中所提供的全局光照计算方法易耗费较多的硬件资源且呈现的画面效果不够理想的技术问题。
根据本发明实施例的一个方面,提供了一种全局光照的计算方法,包括:
获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
可选地,获取每个像素对应的光照信息包括:对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;从当前帧图像数据中提取与屏幕显示坐标对应的光照信息。
可选地,获取每个像素对应的有向距离场信息包括:对二维贴图进行光栅化处理, 将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;分别计算每个体素的世界坐标位置与应的屏幕显示坐标根据屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将世界位置距离限定在预设的数值范围内;获取与屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在前一帧图像数据上对应的世界位置距离,并采用每个像素在当前帧图像数据上对应的世界位置距离和每个像素在前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
可选地,根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算包括:确定每个像素在进行全局光照计算过程中待使用的采样点;根据每个采样点对应的体素在三维贴图中的世界坐标位置获取多个相邻体素;利用多个相邻体素的有向距离场信息和光照信息对每个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
可选地,利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算包括以下至少之一:在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
可选地,在根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算之后,还包括:利用帧间抗锯齿(Temporal AA)对全局光照计算结果进行平滑处理,将与选取多个像素时所采用的分辨率上采样至屏幕的全屏分辨率,其中,全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面反射信息。
根据本发明实施例的另一方面,还提供了一种全局光照的计算装置,包括:
获取模块,设置为获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;计算模块,设置为根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
可选地,获取模块包括:第一映射单元,设置为对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;第二映射单元,设置为将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;第一获取单元,设置为从当前帧图像数据中提取与屏幕显示坐标对应的光照信息。
可选地,获取模块包括:第一映射单元,设置为对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;第二映射单元,设置为将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;第一计算单元,设置为分别计算每个体素的世界坐标位置与对应的屏幕显示坐标根据屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将所述世界位置距离限定在预设的数值范围内;第二获取单元,设置为获取与所述屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在所述前一帧图像数据上对应的世界位置距离,并采用每个像素在所述当前帧图像数据上对应的世界位置距离和每个像素在所述前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
可选地,计算模块包括:确定单元,设置为确定每个像素在进行全局光照计算过程中待使用的采样点;第三获取单元,设置为根据每个采样点对应的体素在三维贴图中的世界坐标位置获取多个相邻体素;调整单元,设置为利用多个相邻体素的有向距离场信息和光照信息对每个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;第二计算单元,设置为利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
可选地,第二计算单元,设置为在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;和/或,在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;和/或,根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
可选地,上述装置还包括:处理模块,设置为利用Temporal AA对全局光照计算结果进行平滑处理,将与选取多个像素时所采用的分辨率上采样至屏幕的全屏分辨率,其中,全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面 反射信息。
在本发明实施例中,采用将屏幕上选取的像素对应的体素的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中,当需要针对该像素进行全局光照计算时,从二维贴图中获取该像素对应的体素的有向距离场信息和/或光照信息,并运用获取到的有向距离场信息和/或光照信息进行全局光照计算的方式,从而实现了降低全局光照的计算量,减小硬件资源消耗,提升画面显示效果的技术效果,进而解决了相关技术中所提供的全局光照计算方法易耗费较多的硬件资源且呈现的画面效果不够理想的技术问题。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1是根据本发明实施例的全局光照的计算方法的流程图;
图2是根据本发明实施例的全局光照的计算装置的结构框图;
图3是根据本发明优选实施例的全局光照的计算装置的结构框图。
具体实施方式
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
根据本发明实施例,提供了一种全局光照的计算方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
图1是根据本发明实施例的全局光照的计算方法的流程图,如图1所示,该方法包括如下步骤:
步骤S12,获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;
步骤S14,根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
相关技术中所提供的全局光照计算方法都具有很高的GPU消耗和计算量,其对计算机硬件配置要求较高,通常适用于单机游戏,但却不适用于网络游戏;具体地,CPU和GPU每帧数据传输量大或者需要离线预处理的数据。世界空间的全局光照方法主要需要在GPU中建立一份整个场景的信息用于全局光照的计算。这份信息中主要包括场景的直接光照亮度和场景的几何信息。而游戏场景一般都十分庞大,有的还要求无缝加载地图,因此,这些数据从CPU到GPU的传输性能便是整个全局光照系统的瓶颈之一。而且,由于至少需要DirectX 10以上才能够支持三维纹理写入,而当前工业领域游戏渲染的前沿所采用的世界空间全局光照方法都需要使用较高图形API的一些特性才能高效地实现。与之相反,通过采用本发明实施例所提供的技术方案,通过每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中,减少CPU与GPU之间的数据传输量,进而减少从CPU到GPU数据带宽的占用。另外,由于降低了CPU与GPU之间的数据传输量,因此,既能够实现在占用少于现有技术方案的系统资源的情况下能够达到相同的画面效果,又能够实现在占有与现有技术方案的系统资源相同的情况下能够达到更加的画面效果。
在优选实施过程中,利用延迟渲染中的当前帧的材质信息总线(包括但不限于:材质颜色、法线、材质渲染参数,其主要用于渲染着色过程中材质与光照进行解耦,先对屏幕内不透明的材质生成材质总线,再计算光照结果,避免了被遮挡位置的光照计算,典型的诸如GBuffer)将光照信息和有向距离场信息填充至体素贴图中,其中,数据存储是按有向距离场来存储光照信息与距离场数据;光照信息存储在贴图的RGB分量,有向距离场存储在贴图中的Alpha通道中。
由于本发明所提供的实施例需要采用DirectX 9渲染框架来替代相关技术中所使 用的DirectX 10以上渲染框架,而DirectX 9仅支持二维贴图的写入,因此,需要将二维贴图映射成三维贴图。即体素贴图使用二维贴图实现三维数据的存储。数据写入和读取需要分别进行位置的映射。三维数据UV需要映射到二维贴图UV。具体地,先将三维贴图按照深度切分进行二维展开,采用多个平铺的二维贴图来实现。如果将这些平铺的二维贴图再重新叠加在一起,便可以还原出上述三维贴图。假设三维体素的分辨率设定为128*128*128,那么,便需要生成对应16384(即128*128)*128大小的二维贴图。
进一步地,由于二维贴图的读取只能进行二维u、v间的线性插值,如果希望还原出三维贴图的u、v、w三维线性插值,则需要读取二维贴图中读取w坐标在二维贴图中对应的两个最近的切面(即两个小正方形中的数据),再对这两个平面的数据进行插值,从而模拟三维贴图的功能。这两个坐标点定义为uv1,uv2,其对应的映射公式如下:
uv2=float2(
(floor(Cell.z)+1+Cell.x/SDF_VOLUME_WIDTH)/SDF_VOLUME_DEPTH,
1.0f-Cell.y/SDF_VOLUME_HEIGHT)
uv1=float2(
(floor(Cell.z)+Cell.x/SDF_VOLUME_WIDTH)/SDF_VOLUME_DEPTH,
1.0f-Cell.y/SDF_VOLUME_HEIGHT)
其中,float2表示一个矢量,分别具有x,y的取值,并通过逗号隔开;Cell表示访问在三维数据局部空间的坐标值,SDF_VOLUME_WIDTH、SDF_VOLUME_HEIGHT、SDF_VOLUME_DEPTH是体素贴图的最大宽度、最大高度、最大深度。
可选地,在步骤S12中,获取每个像素对应的光照信息可以包括以下执行步骤:
步骤S120,对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;
步骤S121,将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;
步骤S122,从当前帧图像数据中提取与屏幕显示坐标对应的光照信息。
首先,对映射成三维数据的二维贴图进行光栅化,并将每个像素的位置映射回三维数据世界坐标位置;其次,将每个体素的世界坐标位置映射到屏幕空间中,从而得 到对应屏幕的UV坐标;然后,再从当前视点(例如:摄像机)观察到的当前帧图像数据中提取对应UV坐标的光照信息。此外,光照信息还可以在线使用简单兰伯特渲染模型计算。
需要说明的是,这一步计算是需要延迟渲染的阴影计算结果。即,为了使得注入三维体素的数据具有阴影信息,需要延时渲染的阴影贴图配合,以生成的体素数据的光照信息。
可选地,在步骤S12中,获取每个像素对应的有向距离场信息可以包括以下执行步骤:
步骤S123,对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;
步骤S124,将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;
步骤S125,分别计算每个体素的世界坐标位置与应的屏幕显示坐标根据屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将世界位置距离限定在预设的数值范围内;
步骤S126,获取与屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在前一帧图像数据上对应的世界位置距离,并采用每个像素在当前帧图像数据上对应的世界位置距离和每个像素在前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
有向距离场(Signed Distance Field,简称为SDF)是一个标量场,用于存储每个空间位置到最近的三角表面的距离。该数据的计算流程如下:
首先,对映射成三维数据的二维贴图进行光栅化,并将每个像素的位置映射回三维数据世界坐标位置;其次,将每个体素的世界坐标位置映射到屏幕空间中,从而得到对应屏幕的UV坐标;然后,假如该体素属于屏幕的可见范围,就计算体素的世界坐标位置与对应屏幕UV坐标采样屏幕深度图(即得到屏幕中对应像素在深度图的数据)还原的世界坐标位置的距离(即三维世界的两点间距离);最后,将这个距离截断最大、最小上下限(即将前一步骤得到的距离取值截断在一个范围内),得到截断最大最小值的有向距离场(Truncated Signed Distance Field,简称为TSDF),并与上一帧对应的数据进行加权平均。
考虑到本发明实施例所提供的技术方案主要适用于网络游戏和其它通用的渲染环 境,因此,全局光照的计算需要覆盖相当大的范围。为了保证在大范围生成全局光的情况下,同时位于屏幕附近的计算结果又能够保证足够的精度,需要引入多细节层次(Level of Detail,简称为LOD,即按照摄像机距离的远近减少相应细节的渲染优化方案)系统。而裁剪图(Clipmap)是一种LOD技术,其原理在于:使用高精度数据包裹摄像机的近景部分,同时使用低精度数据包裹摄像机的远景部分。
在优选实施例中,LOD的实现是分别生成相同分辨率但不同对应场景范围的三维数据包裹摄像机,并会跟随摄像机进行移动。最低层级的LOD范围最小,生成三维数据单位精度最高。最高级的LOD层级精度最小,但范围最大;换言之,距离摄像机较近的空间生成精度高数据,距离摄像机较远的空间生成低精度数据,这样保证在较低显存消耗下情况下,近景部分具有较好的画面呈现效果,由此能够保证用户在观看近景时具有较好的全局光渲染结果,同时远景也能够具有相对适中的画面呈现效果。
综合上述介绍,在进行全局光照计算前的数据准备工作如下:使用三维体素数据存储动态生成的世界有向距离场信息以及与世界有向距离场对应的世界空间坐标代表的光照信息,并且采用高精度数据包裹摄像机近距离区域以及采用低精度数据包裹摄像机远距离区域,即采用Clipmap+LOD方式覆盖以摄像机为中心的正方体区域,以节省显存的占用。利用当前帧渲染的通过常规游戏引擎的延迟渲染技术产生的深度图,更新摄像机视锥体包裹范围内的体素数据,其中,有向距离场信息利用深度图还原世界坐标计算,直接光照信息利用漫反射计算。此时,得到整个场景重建的有向距离场和直接光照体素数据。由于当前数据由有向距离场的数据与上一帧的数据进行加权平均得到的,因此,还需要经过一个滤波处理完成数据准备。当需要实现通过渲染技术(例如:环境光遮蔽、间接光照、反射)来提升使用有向距离场得到的画面效果时,使用上述全局动态生成的数据即可。该数据除了能够实现全局光照,还能够实现软阴影,镜面反射,物理碰撞等效果。
可选地,在步骤S14中,根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算可以包括以下执行步骤:
步骤S140,确定每个像素在进行全局光照计算过程中待使用的采样点;
步骤S141,根据每个采样点对应的体素在三维贴图中的世界坐标位置获取多个相邻体素;
步骤S142,利用多个相邻体素的有向距离场信息和光照信息对每个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;
步骤S143,利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
由于融合的数据通常都是位于摄像机正对面的比例最高,在截断距离范围不够小的情况下,数据本身与标准的SDF存在极大的方向性偏差,但是,如果截断的范围越小,后面使用体素贴图的渲染技术需要跟踪的次数越多,换言之,因为通过摄像机拍摄的深度图生成距离场,优先生成数据的有效性主要偏向于摄像机方向。其与标准距离场定义存在误差。
故而,可以尝试使用最小距离范式的优化方法,使得已有SDF数据能够在多次迭代后逼近正确结果。
在优选实施过程中,假设当前方格O(包括:6个面),循环寻找与方格O每个面相接的方格Q(即三维贴图中相邻的体素,通过uv坐标偏移对应体素的边长大小),两个方格的中心距离为d;从摄像机朝向物体表面的方向上,物体表面可以设置为原点,位于物体表面外部的平面可以设置为正向(取正号),位于物体表面内部的平面可以设置为反向(取负号):
若方格O与方格Q同为正号或同为负号,根据方格Q中存储的先前生成的有向距离场信息(distance)计算方格O的猜测距离(即Q的distance+d),并对方格O中存储的先前生成的有向距离场信息(distance)与猜测距离这两者中的较小值进行存储,其中,收敛为最佳情况;
若方格O与方格Q中存在一个正号和一个负号,那么当d小于圆心距时,则两圆公共弦与两圆连线的交点为假设表面零点(即两个相邻格子存储的距离可以看作是两个圆的半径,两圆交点的连线为两圆的公共弦,两圆心的连线与公共弦的交点为所求近似点),继而求出交点到方格的距离。
通过将方格O与相邻的6个方格按照上述计算方式进行重复计算,最终得到调整后的有向距离场信息和/或光照信息。
可选地,在步骤S142中,利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算可以包括以下执行步骤至少之一:
步骤S1420,在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;
全局光照分为环境光遮蔽和间接光照两个部分。为了计算效率考虑,两个计算都 需要复用相同的采样点数据。
采样点分布:采样起始点为当前屏幕像素根据深度图转换的世界坐标位置,同时根据像素屏幕坐标获取像素对应的世界法线,进而得到该像素代表面片的朝向。在优选实施过程中,在采样起始点开始分别往面片朝向的平均分布的9个方向跟踪光照与遮挡信息,其中,每个方向进行10步跟踪采样。最后,对9个方向的计算结果求取均值,继而得到最后结果。需要说明的是,这9个方向形成的圆锥尽量分布和占满跟踪表面的法线方向的半球面。
在环境光遮蔽(Ambient Occlusion)的计算过程中,每步采样的环境遮挡的计算公式如下:
StepVisibility=Distance/SphereRadius
其中,StepVisibility为每步采样的可见性,Distance为有向距离场,SphereRadius是以采样起始点为圆锥顶点,采样点为截面圆心的的圆锥底面圆半径。这是利用有向距离场线性计算特定立体角方向可见性的一个逼近方法;同时,由于本发明所提供的实施例可以使用TSDF,因此,SphereRadius也需要在同样的有向距离场最大值进行截断。
每个方向记录下当前方向可见性最低的StepVisibility值:
ConeVisibility=min(StepVisibility,ConeVisibility)
在得到每个方向上的环境光遮蔽值后,便可以运用相关技术中所提供的环境光遮蔽公式完成对应像素的计算。此处不再赘述。
步骤S1421,在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;
在间接光照计算的过程中,与环境光遮蔽的计算相类似,先采用屏幕深度还原像素的世界坐标值,以这个坐标为起始点,从该点出发分别往9个方向收集光照信息。由于前面生成的有向距离场数据是带有光照信息,故而,可以利用每个像素对应的体素的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,从而得到间接光照计算结果。
步骤S1422,根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
在镜面反射的计算过程中,利用屏幕的深度值还原像素的世界坐标,以这个坐标为起始点,向以摄像机朝向的入射线与像素表面法线的反射方向利用有向距离场数据进行Sphere Tracing。在跟踪结束点获取该点的光照信息。
Sphere Tracing是有向距离场进行跟踪的一种方法,主要用于查找一个起始点到达特定方向最近距离的表面位置,其原理主要在于:利用有向距离场迭代每次跟踪的步长,其步长每次递归过程中都会加上有向距离场在当前跟踪点的数值;由于有向距离场本来存储的数据便是对应位置到达最近表面的距离,与Sphere Tracing的设定功能是一致的。因此Sphere Tracing是一个十分高效的在有向距离场中进行光线跟踪的方法。
可选地,在步骤S14,根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算之后,还可以包括以下执行步骤:
步骤S16,利用帧间抗锯齿(Temporal AA)对全局光照计算结果进行平滑处理,将与选取多个像素时所采用的分辨率上采样至屏幕的全屏分辨率,其中,全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面反射信息。
帧间抗锯齿(Temporal Antialiasing,简称为Temporal AA)技术是一种抗锯齿手段,其工作原理在于:利用多帧的数据对能够分辨出属于同一个像素渲染的结果进行超采样;其与传统抗锯齿技术的最大差别在于:传统技术对像素进行超采样的数据来源于其附近的位置渲染更多的结果,而Temporal AA则是将需要采样的数据分布在多帧的渲染结果中,因此,Temporal AA能够在更低的软硬件资源消耗下,达到更好的抗锯齿效果。
Temporal AA需要将上一帧大部分数据都能够有效地重新映射到当前帧的位置,这时需要保存上一帧的摄像机矩阵并计算当前帧的像素2D速度场。Temporal AA正确映射越多上一帧的数据,其超采样结果会越好。
由于全局光照属于中频的信息,而且全局光照的计算属于GPU密集型的操作,因此,可以在一个较低的分辨率下进行渲染,以减少整体计算量,再利用GBuffer的深度图和法线进行双向滤波至全屏分辨率。而上采样所带来的问题是数据的跳变与信息的缺失,故而,在这里引入Temporal AA可以在一定程度上减少数据跳变与采样精度降低的问题。
在优选实施过程中,全局光的跟踪计算发生在屏幕八分之一分辨率下,然后双向滤波上采样(Upsample,其为一种纹理采样方法)到一半分辨率,通过使用Temperal AA再上采样至全分辨率。
根据本发明的另一实施例,提供了一种全局光照的计算装置的实施例。图2是根据本发明实施例的全局光照的计算装置的结构框图。如图2所示,该全局光照的计算装置可以包括:获取模块10,设置为获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;计算模块20,设置为根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
可选地,图3是根据本发明优选实施例的全局光照的计算装置的结构框图。如图3所示,获取模块10包括:第一映射单元100,设置为对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;第二映射单元102,设置为将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;第一获取单元104,设置为从当前帧图像数据中提取与屏幕显示坐标对应的光照信息。
可选地,如图3所示,获取模块10包括:第一映射单元100,设置为对二维贴图进行光栅化处理,将每个像素在二维贴图中的位置通过映射的方式得到对应体素在三维贴图中的世界坐标位置;第二映射单元102,设置为将每个体素的世界坐标位置映射至屏幕的显示空间内,得到对应的屏幕显示坐标;第一计算单元106,设置为分别计算每个体素的世界坐标位置与对应的屏幕显示坐标根据屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将所述世界位置距离限定在预设的数值范围内;第二获取单元108,设置为获取与所述屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在所述前一帧图像数据上对应的世界位置距离,并采用每个像素在所述当前帧图像数据上对应的世界位置距离和每个像素在所述前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
可选地,如图3所示,计算模块20包括:确定单元200,设置为确定每个像素在进行全局光照计算过程中待使用的采样点;第三获取单元202,设置为根据每个采样点对应的体素在三维贴图中的世界坐标位置获取多个相邻体素;调整单元204,设置为利用多个相邻体素的有向距离场信息和光照信息对每个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;第二计算单元206,设置为利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
可选地,第二计算单元206,设置为在每个像素在待渲染物体表面对应的起始采 样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;和/或,在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;和/或,根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
可选地,如图3所示,上述装置还包括:处理模块30,设置为利用Temporal AA对全局光照计算结果进行平滑处理,将与选取多个像素时所采用的分辨率上采样至屏幕的全屏分辨率,其中,全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面反射信息。
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。
在本发明的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一 台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。

Claims (12)

  1. 一种全局光照的计算方法,包括:
    获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;
    根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
  2. 根据权利要求1所述的方法,其中,获取每个像素对应的光照信息包括:
    对所述二维贴图进行光栅化处理,将每个像素在所述二维贴图中的位置通过映射的方式得到对应体素在所述三维贴图中的世界坐标位置;
    将每个体素的世界坐标位置映射至所述屏幕的显示空间内,得到对应的屏幕显示坐标;
    从当前帧图像数据中提取与所述屏幕显示坐标对应的光照信息。
  3. 根据权利要求1所述的方法,其中,获取每个像素对应的有向距离场信息包括:
    对所述二维贴图进行光栅化处理,将每个像素在所述二维贴图中的位置通过映射的方式得到对应体素在所述三维贴图中的世界坐标位置;
    将每个体素的世界坐标位置映射至所述屏幕的显示空间内,得到对应的屏幕显示坐标;
    分别计算每个体素的世界坐标位置与对应的屏幕显示坐标根据所述屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将所述世界位置距离限定在预设的数值范围内;
    获取与所述屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在所述前一帧图像数据上对应的世界位置距离,并采用每个像素在所述当前帧图像数据上对应的世界位置距离和每个像素在所述前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
  4. 根据权利要求2或3所述的方法,其中,根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算包括:
    确定每个像素在进行全局光照计算过程中待使用的采样点;
    根据每个采样点对应的体素在所述三维贴图中的世界坐标位置获取多个相邻体素;
    利用所述多个相邻体素的有向距离场信息和光照信息对每个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;
    利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
  5. 根据权利要求4所述的方法,其中,利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算包括以下至少之一:
    在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;
    在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;
    根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
  6. 根据权利要求1至5中任一项所述的方法,其中,在根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算之后,还包括:
    利用帧间抗锯齿Temporal AA对全局光照计算结果进行平滑处理,将与选取所述多个像素时所采用的分辨率上采样至所述屏幕的全屏分辨率,其中,所述全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面反射信息。
  7. 一种全局光照的计算装置,包括:
    获取模块,设置为获取屏幕内预先选取的多个像素中每个像素对应的有向距离场信息和/或光照信息,其中,每个像素对应的有向距离场信息和光照信息存储于由三维贴图映射而成的二维贴图中;
    计算模块,设置为根据每个像素对应的有向距离场信息和/或光照信息进行全局光照计算。
  8. 根据权利要求7所述的装置,其中,所述获取模块包括:
    第一映射单元,设置为对所述二维贴图进行光栅化处理,将每个像素在所述二维贴图中的位置通过映射的方式得到对应体素在所述三维贴图中的世界坐标位置;
    第二映射单元,设置为将每个体素的世界坐标位置映射至所述屏幕的显示空间内,得到对应的屏幕显示坐标;
    第一获取单元,设置为从当前帧图像数据中提取与所述屏幕显示坐标对应的光照信息。
  9. 根据权利要求7所述的装置,其中,所述获取模块包括:
    第一映射单元,设置为对所述二维贴图进行光栅化处理,将每个像素在所述二维贴图中的位置通过映射的方式得到对应体素在所述三维贴图中的世界坐标位置;
    第二映射单元,设置为将每个体素的世界坐标位置映射至所述屏幕的显示空间内,得到对应的屏幕显示坐标;
    第一计算单元,设置为分别计算每个体素的世界坐标位置与对应的屏幕显示坐标根据所述屏幕的深度图还原出的世界坐标位置之间的世界位置距离,并将所述世界位置距离限定在预设的数值范围内;
    第二获取单元,设置为获取与所述屏幕内显示的当前帧图像数据相邻的前一帧图像数据对应的有向距离场信息和光照信息,计算每个像素在所述前一帧图像数据上对应的世界位置距离,并采用每个像素在所述当前帧图像数据上对应的世界位置距离和每个像素在所述前一帧图像数据上对应的世界位置距离进行加权平均计算,得到每个像素对应的有向距离场信息。
  10. 根据权利要求8或9所述的装置,其中,所述计算模块包括:
    确定单元,设置为确定每个像素在进行全局光照计算过程中待使用的采样点;
    第三获取单元,设置为根据每个采样点对应的体素在所述三维贴图中的世界坐标位置获取多个相邻体素;
    调整单元,设置为利用所述多个相邻体素的有向距离场信息和光照信息对每 个像素对应的有向距离场信息和光照信息进行多次迭代修正,得到每个像素对应的调整后的有向距离场信息和光照信息;
    第二计算单元,设置为利用每个像素对应的调整后的有向距离场信息和/或光照信息进行全局光照计算。
  11. 根据权利要求10所述的装置,其中,所述第二计算单元,设置为在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息进行均值遮蔽计算,得到环境光遮蔽信息;和/或,在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的半球面内跟踪多个方向上均匀分布的圆锥体对应的调整后的有向距离场信息和光照信息进行体素圆锥追踪,得到间接光照信息;和/或,根据视点朝向的入射线与在每个像素在待渲染物体表面对应的起始采样点的世界法线朝向上的反射线,通过体素对应的调整后的有向距离场信息进行球体追踪,得到镜面反射信息。
  12. 根据权利要求7至11中任一项所述的装置,其中,所述装置还包括:
    处理模块,设置为利用帧间抗锯齿Temporal AA对全局光照计算结果进行平滑处理,将与选取所述多个像素时所采用的分辨率上采样至所述屏幕的全屏分辨率,其中,所述全局光照计算结果包括以下至少之一:环境光遮蔽信息、间接光照信息、镜面反射信息。
PCT/CN2016/093567 2016-05-30 2016-08-05 全局光照的计算方法及装置 WO2017206325A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US15/778,227 US11024077B2 (en) 2016-05-30 2016-08-05 Global illumination calculation method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610371167.8A CN107452048B (zh) 2016-05-30 2016-05-30 全局光照的计算方法及装置
CN201610371167.8 2016-05-30

Publications (1)

Publication Number Publication Date
WO2017206325A1 true WO2017206325A1 (zh) 2017-12-07

Family

ID=60478457

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/093567 WO2017206325A1 (zh) 2016-05-30 2016-08-05 全局光照的计算方法及装置

Country Status (3)

Country Link
US (1) US11024077B2 (zh)
CN (1) CN107452048B (zh)
WO (1) WO2017206325A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112734896A (zh) * 2021-01-08 2021-04-30 网易(杭州)网络有限公司 环境遮蔽渲染方法、装置、存储介质及电子设备

Families Citing this family (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019045144A1 (ko) 2017-08-31 2019-03-07 (주)레벨소프트 의료용 항법 장치를 위한 의료 영상 처리 장치 및 의료 영상 처리 방법
CN108122266B (zh) * 2017-12-20 2021-07-27 成都卓杭网络科技股份有限公司 一种缓存骨骼动画渲染纹理的方法、装置和存储介质
CN108090949A (zh) * 2017-12-26 2018-05-29 苏州蜗牛数字科技股份有限公司 一种基于光能传播的实时全局光照方法
CN108537869B (zh) * 2018-03-08 2022-03-18 哈尔滨工程大学 一种基于级联纹理的圆锥追踪动态全局光照方法
CN108986195B (zh) * 2018-06-26 2023-02-28 东南大学 一种结合环境映射和全局光照渲染的单镜头混合现实实现方法
CN109389667B (zh) * 2018-08-23 2023-07-18 北京大学 一种基于深度学习的高效全局光照明绘制方法
CN109364481B (zh) * 2018-10-30 2022-09-13 网易(杭州)网络有限公司 游戏内的实时全局光照方法、装置、介质及电子设备
CN109472856B (zh) * 2018-11-07 2022-12-09 长春理工大学 基于虚拟点光源的复杂真实感三维场景渐进交互式绘制方法
CN109745704B (zh) * 2018-11-19 2022-09-09 苏州蜗牛数字科技股份有限公司 一种体素地形的管理方法
CN109934900A (zh) * 2019-01-23 2019-06-25 杭州炽橙文创科技有限公司 基于vr硬件架构的实时全局光照解决方法
US11200722B2 (en) * 2019-12-20 2021-12-14 Intel Corporation Method and apparatus for viewport shifting of non-real time 3D applications
US11315310B2 (en) * 2020-03-12 2022-04-26 Nvidia Corporation Reservoir-based spatiotemporal importance resampling utilizing a global illumination data structure
CN111739074B (zh) * 2020-06-03 2023-07-18 福建数博讯信息科技有限公司 一种场景多点光源渲染方法及装置
CN111744183B (zh) * 2020-07-02 2024-02-09 网易(杭州)网络有限公司 游戏中的光照采样方法、装置以及计算机设备
CN112153280B (zh) * 2020-08-31 2022-02-15 浙江赫千电子科技有限公司 一种应用于摄像头模组的主动对准方法
US11216916B1 (en) * 2020-10-09 2022-01-04 Nvidia Corporation History clamping for denoising dynamic ray-traced scenes using temporal accumulation
CN112604278B (zh) * 2020-12-29 2021-09-17 广州银汉科技有限公司 一种基于游戏在智能设备模拟全局光照的方法
CN115115747A (zh) * 2021-03-09 2022-09-27 网易(杭州)网络有限公司 光照渲染方法、装置、电子设备及存储介质
CN112927123A (zh) * 2021-03-19 2021-06-08 中国人民解放军战略支援部队信息工程大学 一种gpu加速的有向距离场符号建模方法
CN113648652B (zh) * 2021-08-20 2023-11-14 腾讯科技(深圳)有限公司 对象渲染方法和装置、存储介质及电子设备
CN114937111B (zh) * 2022-03-29 2024-06-04 网易(杭州)网络有限公司 阴影贴图混合方法、装置、电子设备和存储介质
CN116051713B (zh) * 2022-08-04 2023-10-31 荣耀终端有限公司 渲染方法、电子设备和计算机可读存储介质
CN115330640B (zh) * 2022-10-11 2023-01-10 腾讯科技(深圳)有限公司 光照贴图降噪方法、装置、设备和介质
CN115830208B (zh) * 2023-01-09 2023-05-09 腾讯科技(深圳)有限公司 全局光照渲染方法、装置、计算机设备和存储介质
CN116672706B (zh) * 2023-08-03 2023-11-03 腾讯科技(深圳)有限公司 光照渲染方法、装置、终端和存储介质
CN117392315A (zh) * 2023-10-13 2024-01-12 威创软件南京有限公司 一种基于分布式光伏出力动态绘制星光图的算法
CN117893670A (zh) * 2024-01-15 2024-04-16 联想新视界(北京)科技有限公司 一种实时全局光照渲染方法、装置及电子设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060066616A1 (en) * 2004-09-30 2006-03-30 Intel Corporation Diffuse photon map decomposition for parallelization of global illumination algorithm
US20080279450A1 (en) * 2005-04-01 2008-11-13 Graham Finlayson Illuminant Estimation
CN101826214A (zh) * 2010-03-29 2010-09-08 中山大学 一种基于光子映射的全局光照方法
CN102314703A (zh) * 2011-06-14 2012-01-11 天津大学 一种蒙特卡罗全局光照的自适应抽样方法
CN103426199A (zh) * 2013-08-09 2013-12-04 中国科学院自动化研究所 一种三维几何场景的低噪声实时全局光照绘制方法
CN104484896A (zh) * 2014-10-30 2015-04-01 无锡梵天信息技术股份有限公司 一种基于环境贴图来模拟人物皮肤次表面散射的物理方法

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070052704A1 (en) * 2005-09-08 2007-03-08 Arm Limited 3D graphics image formation
US7750906B2 (en) * 2006-04-19 2010-07-06 Pixar Systems and methods for light pruning
US20090102843A1 (en) * 2007-10-17 2009-04-23 Microsoft Corporation Image-based proxy accumulation for realtime soft global illumination
CN101882323B (zh) * 2010-05-19 2012-06-13 北京航空航天大学 基于高度图的微结构表面全局光照实时绘制方法
US9202258B2 (en) * 2012-06-20 2015-12-01 Disney Enterprises, Inc. Video retargeting using content-dependent scaling vectors
US9857470B2 (en) * 2012-12-28 2018-01-02 Microsoft Technology Licensing, Llc Using photometric stereo for 3D environment modeling
US9129443B2 (en) * 2013-05-21 2015-09-08 Nvidia Corporation Cache-efficient processor and method of rendering indirect illumination using interleaving and sub-image blur
US20160189419A1 (en) * 2013-08-09 2016-06-30 Sweep3D Corporation Systems and methods for generating data indicative of a three-dimensional representation of a scene
US9811721B2 (en) * 2014-08-15 2017-11-07 Apple Inc. Three-dimensional hand tracking using depth sequences
US20160155261A1 (en) * 2014-11-26 2016-06-02 Bevelity LLC Rendering and Lightmap Calculation Methods
CN105335995B (zh) * 2015-10-28 2018-06-05 华为技术有限公司 一种多光源全局光照绘制方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060066616A1 (en) * 2004-09-30 2006-03-30 Intel Corporation Diffuse photon map decomposition for parallelization of global illumination algorithm
US20080279450A1 (en) * 2005-04-01 2008-11-13 Graham Finlayson Illuminant Estimation
CN101826214A (zh) * 2010-03-29 2010-09-08 中山大学 一种基于光子映射的全局光照方法
CN102314703A (zh) * 2011-06-14 2012-01-11 天津大学 一种蒙特卡罗全局光照的自适应抽样方法
CN103426199A (zh) * 2013-08-09 2013-12-04 中国科学院自动化研究所 一种三维几何场景的低噪声实时全局光照绘制方法
CN104484896A (zh) * 2014-10-30 2015-04-01 无锡梵天信息技术股份有限公司 一种基于环境贴图来模拟人物皮肤次表面散射的物理方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112734896A (zh) * 2021-01-08 2021-04-30 网易(杭州)网络有限公司 环境遮蔽渲染方法、装置、存储介质及电子设备
CN112734896B (zh) * 2021-01-08 2024-04-26 网易(杭州)网络有限公司 环境遮蔽渲染方法、装置、存储介质及电子设备

Also Published As

Publication number Publication date
CN107452048B (zh) 2019-03-12
CN107452048A (zh) 2017-12-08
US20200302683A1 (en) 2020-09-24
US11024077B2 (en) 2021-06-01

Similar Documents

Publication Publication Date Title
WO2017206325A1 (zh) 全局光照的计算方法及装置
JP6910130B2 (ja) 3dレンダリング方法及び3dレンダリング装置
CN108986195B (zh) 一种结合环境映射和全局光照渲染的单镜头混合现实实现方法
US11625894B2 (en) Virtual photogrammetry
CN111243071A (zh) 实时三维人体重建的纹理渲染方法、系统、芯片、设备和介质
US9501860B2 (en) Sparse rasterization
US9508191B2 (en) Optimal point density using camera proximity for point-based global illumination
US20230230311A1 (en) Rendering Method and Apparatus, and Device
US11195319B1 (en) Computing ray trajectories for pixels and color sampling using interpolation
WO2022143367A1 (zh) 一种图像渲染方法及其相关设备
Kivi et al. Real-time rendering of point clouds with photorealistic effects: a survey
CN116385619B (zh) 对象模型渲染方法、装置、计算机设备和存储介质
CN108230430B (zh) 云层遮罩图的处理方法及装置
KR101118597B1 (ko) 모바일용 컴퓨터 그래픽 랜더링 방법 및 시스템
Lall et al. View-region optimized image-based scene simplification
Xu et al. Visualization methods of vector data on a Digital Earth System
KR20230013099A (ko) 실시간 깊이 맵을 사용한 지오메트리 인식 증강 현실 효과
Lechlek et al. Interactive hdr image-based rendering from unstructured ldr photographs
Chen et al. A quality controllable multi-view object reconstruction method for 3D imaging systems
Gao et al. EvaSurf: Efficient View-Aware Implicit Textured Surface Reconstruction on Mobile Devices
Nilsson et al. Design and novel uses of higher-dimensional rasterization
WO2023222923A1 (en) Method of content generation from sparse point datasets
Hu et al. Signed Distance Fields Dynamic Diffuse Global Illumination
Gaitatzes et al. Fast approximate visibility on the GPU using precomputed 4d visibility fields
Schertler et al. Visualization of Scanned Cave Data with Global Illumination.

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: 16903707

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16903707

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16903707

Country of ref document: EP

Kind code of ref document: A1