[go: up one dir, main page]

CN117893670B - Real-time global illumination rendering method, device and electronic device - Google Patents

Real-time global illumination rendering method, device and electronic device Download PDF

Info

Publication number
CN117893670B
CN117893670B CN202410057767.1A CN202410057767A CN117893670B CN 117893670 B CN117893670 B CN 117893670B CN 202410057767 A CN202410057767 A CN 202410057767A CN 117893670 B CN117893670 B CN 117893670B
Authority
CN
China
Prior art keywords
voxel
voxels
distance field
vector
illumination
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.)
Active
Application number
CN202410057767.1A
Other languages
Chinese (zh)
Other versions
CN117893670A (en
Inventor
王雪健
白欲立
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo New Vision Beijing Technology Co Ltd
Original Assignee
Lenovo New Vision Beijing Technology Co Ltd
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 Lenovo New Vision Beijing Technology Co Ltd filed Critical Lenovo New Vision Beijing Technology Co Ltd
Priority to CN202410057767.1A priority Critical patent/CN117893670B/en
Publication of CN117893670A publication Critical patent/CN117893670A/en
Application granted granted Critical
Publication of CN117893670B publication Critical patent/CN117893670B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/06Ray-tracing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02BCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO BUILDINGS, e.g. HOUSING, HOUSE APPLIANCES OR RELATED END-USER APPLICATIONS
    • Y02B20/00Energy efficient lighting technologies, e.g. halogen lamps or gas discharge lamps
    • Y02B20/40Control techniques providing energy savings, e.g. smart controller or presence detection

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Geometry (AREA)
  • Image Generation (AREA)

Abstract

The application provides a real-time global illumination rendering method, a device and electronic equipment, wherein the real-time global illumination rendering comprises the following steps: voxelization is carried out on the scene geometry of the current frame to obtain distance field voxels, wherein the attributes of the distance field voxels comprise: vector distance field, normal vector, albedo, and emission value; calculating direct illumination of a main light source with preset intensity to each distance field voxel and taking the direct illumination as emergent radiance; the outgoing radiance of the distance field voxels is anisotropically filtered to form a hierarchy to generate directional voxels; the outgoing emittance of the directional voxels is collected by the cone of ray bundles and the indirect illumination is calculated. The method and the device improve the running efficiency of real-time illumination, ensure the accuracy of illumination and improve the 3D rendering effect.

Description

一种实时全局光照渲染方法、装置及电子设备Real-time global illumination rendering method, device and electronic device

技术领域Technical Field

本申请涉及计算机图形学技术领域,特别涉及一种实时全局光照渲染方法、装置及电子设备。The present application relates to the technical field of computer graphics, and in particular to a real-time global illumination rendering method, device and electronic device.

背景技术Background Art

在计算机图形学中,精确计算场景中的光分布是实现真实感的重要方面,这种计算通常很昂贵,因为光不是沿着直线路径传播、反弹、散射,并且被场景中的不同对象吸收。In computer graphics, accurately computing the distribution of light in a scene is an important aspect of achieving realism, and such computations are usually expensive because light does not travel along straight paths, but bounces, scatters, and is absorbed by different objects in the scene.

标准渲染管道使用三角形来表示场景的几何体,这些三角形随后被光栅化、着色,并最终显示在屏幕上。这种表示对于局部碎片操作(如直接照明)是有效的,但对于更复杂的操作(如全局照明)具有许多限制。The standard rendering pipeline uses triangles to represent the geometry of the scene, which are then rasterized, shaded, and ultimately displayed on the screen. This representation is efficient for local fragment operations such as direct lighting, but has many limitations for more complex operations such as global illumination.

目前,3D图形学中全局光照方法普遍存在消耗过大,漏光和效率低等问题。Currently, global illumination methods in 3D graphics generally have problems such as excessive consumption, light leakage and low efficiency.

发明内容Summary of the invention

有鉴于此,本申请提供一种实时全局光照渲染方法、装置及电子设备,该方法通过建立一个有效的基于体素的照明过程,用于存储出射辐射,包括体素遮挡和体素法线衰减误差的解决方案和一种高效的体素全局照明过程,并使用锥形跟踪,解决3D图形学中全局光照方法普遍存在消耗过大,漏光和效率低等问题。In view of this, the present application provides a real-time global illumination rendering method, device and electronic device. The method establishes an effective voxel-based lighting process for storing outgoing radiation, including solutions to voxel occlusion and voxel normal attenuation errors and an efficient voxel global illumination process, and uses cone tracing to solve the problems of excessive consumption, light leakage and low efficiency that are common in global illumination methods in 3D graphics.

第一方面,本申请实施例提供一种实时全局光照渲染方法,包括:In a first aspect, an embodiment of the present application provides a real-time global illumination rendering method, comprising:

对当前帧的场景几何体进行体素化处理,得到距离场体素,所述距离场体素的属性包括:矢量距离场、法向量、反照率和发射值;voxelize the scene geometry of the current frame to obtain distance field voxels, wherein the attributes of the distance field voxels include: vector distance field, normal vector, albedo and emission value;

计算预设强度的主光源照射到每个距离场体素上的直接光照并作为出射辐射度;Calculate the direct light from the main light source of preset intensity to each distance field voxel as the outgoing radiance;

将距离场体素的出射辐射度经过各向异性过滤形成层级,以生成定向体素;Anisotropically filtering the outgoing radiance of the distance field voxels to form a hierarchy to generate directional voxels;

通过锥体的光线束收集定向体素的出射辐射度,并计算间接光照。Ray bundles through the cone collect outgoing radiance from directional voxels and compute indirect lighting.

在一种的可能实现中,对当前帧的场景几何体进行体素化处理,得到距离场体素;包括:In a possible implementation, voxelization is performed on the scene geometry of the current frame to obtain distance field voxels; including:

对当前帧的每个场景几何体的投影三角形,生成一个比投影三角形大的边界多边形,以生成至少一个片段,每个片段具有不同的属性,包括:反法向量、反照率和发射值;For each projected triangle of the scene geometry of the current frame, generate a bounding polygon larger than the projected triangle to generate at least one fragment, each fragment having different attributes including: an inverse normal vector, an albedo, and an emission value;

将一个体素内的所有片段的属性进行平均,得到所述体素的属性;Averaging the properties of all fragments within a voxel to obtain the properties of the voxel;

使用存储在3D纹理中的分层距离场表示来场景几何体,得到场景几何体的矢量距离场。Use the layered distance field representation stored in a 3D texture to represent the scene geometry, resulting in a vector distance field for the scene geometry.

在一种的可能实现中,所述方法还包括:In one possible implementation, the method further includes:

当上一帧的距离场体素为动态体素,对当前帧的属性体与辐射体进行更新;When the distance field voxel of the previous frame is a dynamic voxel, the attribute body and radiation body of the current frame are updated;

当上一帧的距离场体素为静态体素,当前帧的距离场体素沿用上一帧的值;When the distance field voxel of the previous frame is a static voxel, the distance field voxel of the current frame uses the value of the previous frame;

标记当前帧的距离场体素是动态体素还是静态体素。Marks whether the distance field voxel of the current frame is a dynamic voxel or a static voxel.

在一种的可能实现中,计算预设强度的主光源照射到每个距离场体素上的直接光照并作为出射辐射度,包括:In a possible implementation, the direct illumination of a main light source with a preset intensity on each distance field voxel is calculated as the outgoing radiance, including:

计算距离场体素的每个面的法向衰减矢量Dx,y,zCalculate the normal falloff vector D x,y,z for each face of the distance field voxel:

其中,Ψ为光方向;为每个面的体素法向矢量;Among them, Ψ is the light direction; is the voxel normal vector for each face;

根据体素的每个面的平均法线Nω的轴符号选择三个主面DωThe three principal faces D ω are selected according to the axis signs of the average normal N ω of each face of the voxel:

则预设强度的主光源照射到距离场体素上的出射辐射度Vr为:Then the outgoing radiance Vr of the main light source with preset intensity irradiating the distance field voxel is:

W=N2 W= N2

其中,Li为主光源的预设强度,ρ为体素的反照率,N为体素法线向量,W为体素平均法线权重向量:W=(Wx,Wy,Wz),(Dx,Dy,Dz)为三个主面的法向衰减矢量乘积后的向量。Among them, Li is the preset intensity of the main light source, ρ is the albedo of the voxel, N is the voxel normal vector, W is the voxel average normal weight vector: W = ( Wx , Wy , Wz ), ( Dx , Dy , Dz ) is the vector of the product of the normal attenuation vectors of the three main surfaces.

在一种的可能实现中,判断体素是否被遮挡,包括:In a possible implementation, determining whether a voxel is occluded includes:

将体素的位置投影在光空间中,并将投影点的深度与来自阴影图的存储深度进行比较,以确定体素是否被遮挡。The position of the voxel is projected in light space and the depth of the projected point is compared to the stored depth from the shadow map to determine whether the voxel is occluded.

在一种的可能实现中,将距离场体素的出射辐射度经过各向异性过滤形成层级,以生成定向体素;包括:In one possible implementation, the outgoing radiance of the distance field voxel is anisotropically filtered to form a hierarchy to generate directional voxels; comprising:

将距离场体素进行划分,然后在各个轴向上对距离场体素求和并取均值,采样时根据光线的角度进行插值得到辐射值;Divide the distance field voxels, then sum and average the distance field voxels in each axis, and interpolate the radiation value according to the angle of the light during sampling;

使用了各向异性过滤,为每个距离场体素存储六个方向值;Anisotropic filtering is used, storing six direction values for each distance field voxel;

通过对从所选定向体积获得的三个样本进行线性插值来获得定向体素。The oriented voxels are obtained by linear interpolation of the three samples obtained from the selected oriented volume.

在一种的可能实现中,通过锥体的光线束收集定向体素的出射辐射度,并计算间接光照,包括:In one possible implementation, a cone of rays collects outgoing radiance from directional voxels and computes indirect lighting, including:

从定向体素中获取遮挡值da和出射辐射度dcGet the occlusion value da and the outgoing radiance dc from the directional voxel;

光线在锥体的第m次步进后,间接光照值cm和跟踪遮挡值αm为:After the light steps through the cone for the mth time, the indirect illumination value cm and the tracking occlusion value αm are:

cm=cm-1αm-1+(1-αm-1)dadc c m =c m-1 α m-1 + (1-α m-1 )d a d c

αm=αm-1+(1-αm-1)da α mm-1 +(1-α m-1 )d a

其中,Cm-1和αm-1为光线在锥体的第m-1次步进后的间接光照值和跟踪遮挡值。Among them, C m-1 and α m-1 are the indirect lighting value and tracking occlusion value of the light after the m-1th step of the cone.

第二方面,本申请实施例提供一种实时全局光照渲染装置,包括:In a second aspect, an embodiment of the present application provides a real-time global illumination rendering device, comprising:

体素化单元,用于对当前帧的场景几何体进行体素化处理,得到距离场体素,所述距离场体素的属性包括:矢量距离场、法向量、反照率和发射值;A voxelization unit, used for voxelizing the scene geometry of the current frame to obtain distance field voxels, wherein the attributes of the distance field voxels include: vector distance field, normal vector, albedo and emission value;

直接光照计算单元,用于计算预设强度的主光源照射到每个距离场体素上的直接光照并作为出射辐射度;A direct lighting calculation unit, used to calculate the direct lighting of the main light source with a preset intensity irradiated on each distance field voxel as the outgoing radiance;

处理单元,用于将距离场体素的出射辐射度经过各向异性过滤形成层级,以生成定向体素;A processing unit for anisotropically filtering outgoing radiances of distance field voxels to generate directional voxels;

间接光照计算单元,用于通过锥体的光线束收集定向体素的出射辐射度,并计算间接光照。The indirect lighting calculation unit is used to collect the outgoing radiance of directional voxels through a cone of light beams and calculate the indirect lighting.

第三方面,本申请实施例提供一种电子设备,包括:存储器和处理器,所述存储器中存储有可执行程序,所述处理器执行所述可执行程序以实现本申请实施例的方法的步骤。In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor, wherein an executable program is stored in the memory, and the processor executes the executable program to implement the steps of the method of the embodiment of the present application.

第四方面,本申请实施例提供一种存储介质,所述存储介质承载有一个或者多个计算机程序,所述一个或者多个计算机程序被处理器执行时实现本申请实施例的方法的步骤In a fourth aspect, an embodiment of the present application provides a storage medium, wherein the storage medium carries one or more computer programs, and when the one or more computer programs are executed by a processor, the steps of the method of the embodiment of the present application are implemented.

本申请提升了实时光照的运行效率,确保了光照的正确性,提升了3D渲染效果。This application improves the operating efficiency of real-time lighting, ensures the correctness of lighting, and improves 3D rendering effects.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的实时全局光照渲染方法的流程图;FIG1 is a flow chart of a real-time global illumination rendering method provided by an embodiment of the present application;

图2(a)为本申请实施例提供的确定在射线的位置是否有体素的示意图;FIG2( a ) is a schematic diagram of determining whether there is a voxel at the position of a ray provided in an embodiment of the present application;

图2(b)为本申请实施例提供的穿过体素化几何体边界的光线的示意图;FIG2( b ) is a schematic diagram of a ray passing through a boundary of a voxelized geometric body provided in an embodiment of the present application;

图3为本申请实施例提供的实时全局光照渲染装置的功能结构图;FIG3 is a functional structure diagram of a real-time global illumination rendering device provided in an embodiment of the present application;

图4为本申请实施例提供的电子设备的功能结构图。FIG. 4 is a functional structure diagram of an electronic device provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

此处参考附图描述本申请的各种方案以及特征。Various aspects and features of the present application are described herein with reference to the accompanying drawings.

应理解的是,可以对此处申请的实施例做出各种修改。因此,上述说明书不应该视为限制,而仅是作为实施例的范例。本领域的技术人员将想到在本申请的范围和精神内的其他修改。It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.

包含在说明书中并构成说明书的一部分的附图示出了本申请的实施例,并且与上面给出的对本申请的大致描述以及下面给出的对实施例的详细描述一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

通过下面参照附图对给定为非限制性实例的实施例的优选形式的描述,本申请的这些和其它特性将会变得显而易见。These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.

还应当理解,尽管已经参照一些具体实例对本申请进行了描述,但本领域技术人员能够确定地实现本申请的很多其它等效形式。It should also be understood that although the present application has been described with reference to some specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the present application.

当结合附图时,鉴于以下详细说明,本申请的上述和其他方面、特征和优势将变得更为显而易见。The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.

此后参照附图描述本申请的具体实施例;然而,应当理解,所申请的实施例仅仅是本申请的实例,其可采用多种方式实施。熟知和/或重复的功能和结构并未详细描述以避免不必要或多余的细节使得本申请模糊不清。因此,本文所申请的具体的结构性和功能性细节并非意在限定,而是仅仅作为权利要求的基础和代表性基础用于教导本领域技术人员以实质上任意合适的详细结构多样地使用本申请。Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied for are merely examples of the present application, which may be implemented in a variety of ways. Well-known and/or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that obscure the present application. Therefore, the specific structural and functional details applied for herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present application in a variety of ways with substantially any suitable detailed structure.

本说明书可使用词组“在一种实施例中”、“在另一个实施例中”、“在又一实施例中”或“在其他实施例中”,其均可指代根据本申请的相同或不同实施例中的一个或多个。This specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present application.

首先对本申请实施例的设计思想进行简单介绍。First, the design concept of the embodiments of the present application is briefly introduced.

计算全局照明对于3D应用中的实时渲染来说是一个具有挑战性且复杂的问题。目前,3D图形学中全局光照方法普遍存在消耗过大,漏光和效率等问题。Calculating global illumination is a challenging and complex problem for real-time rendering in 3D applications. Currently, global illumination methods in 3D graphics generally suffer from problems such as excessive consumption, light leakage, and efficiency.

为此,本申请提出了一种全局照明渲染方法,该方法使用矢量距离场进行阶梯跟踪计算体素中存储的出射辐射和场景的简化版本实时计算间接照明。这种方法包括漫反射、镜面反射和发射材质的双反射间接照明。距离场中的相关结构基于通过mipmapping存储在3D纹理中的定向分层结构,该结构利用GPU实时更新,能够近似动态场景的间接照明。采用基于矢量距离场光路,直接计算距离场中的有效体素。以及用于简化的出射辐射的全局照明,环境遮挡、软阴影和间接照明。To this end, the present application proposes a global illumination rendering method, which uses a vector distance field for step tracing to calculate the outgoing radiation stored in the voxel and a simplified version of the scene to calculate indirect lighting in real time. This method includes diffuse reflection, specular reflection and double-reflection indirect lighting of emissive materials. The relevant structure in the distance field is based on a directional hierarchical structure stored in a 3D texture through mipmapping, which is updated in real time using the GPU and can approximate the indirect lighting of dynamic scenes. A vector distance field-based light path is used to directly calculate the effective voxels in the distance field. And global illumination, ambient occlusion, soft shadows and indirect lighting for simplified outgoing radiation.

本申请实施例的方法使用具有体素和圆锥体跟踪的场景的离散化,能够实现:The method of the embodiment of the present application uses discretization of the scene with voxel and cone tracking to achieve:

一种实时距离场计算过程,只存储捕获每个体素的直接和间接照明所需的信息。A real-time distance field calculation process that stores only the information needed to capture direct and indirect lighting for each voxel.

一个有效的基于体素的照明过程,用于存储出射辐射,包括体素遮挡和体素法线衰减误差的解决方案。An efficient voxel-based lighting process that stores outgoing radiance, including solutions for voxel occlusion and voxel normal falloff errors.

一种高效的体素全局照明过程,使用锥形跟踪,利用间接漫射项扩展过滤后的出射辐射。An efficient voxel global illumination pass that uses cone tracing to expand the filtered outgoing radiance with an indirect diffuse term.

本申请提升了实时光照的运行效率,确保了光照的正确性,提升了3D渲染效果。This application improves the operating efficiency of real-time lighting, ensures the correctness of lighting, and improves 3D rendering effects.

在介绍了本申请实施例的应用场景和设计思想之后,下面对本申请实施例提供的技术方案进行说明。After introducing the application scenarios and design concepts of the embodiments of the present application, the technical solutions provided by the embodiments of the present application are described below.

如图1所示,本申请实施例提供一种实时全局光照渲染方法,包括:As shown in FIG1 , an embodiment of the present application provides a real-time global illumination rendering method, comprising:

步骤101:对当前帧的场景几何体进行体素化处理,得到距离场体素,所述距离场体素的属性包括:矢量距离场、法向量、反照率和发射值;Step 101: voxelizing the scene geometry of the current frame to obtain distance field voxels, the attributes of which include: vector distance field, normal vector, albedo and emission value;

其中,本申请实施例使用存储在3D纹理中的分层距离场表示离散场景几何体,为此使用了阶梯的矢量距离场的构建过程。只有漫射照明所需的照明数据,如法线和反照率,才使用距离场体素空间内所有片段的平均运算存储在体素中,此外,还存储发射以近似发光表面。Among them, the embodiment of the present application uses a layered distance field stored in a 3D texture to represent discrete scene geometry, for which a step-wise vector distance field construction process is used. Only the lighting data required for diffuse lighting, such as normals and albedo, is stored in the voxel using the average operation of all fragments in the distance field voxel space. In addition, emission is also stored to approximate the luminous surface.

步骤102:计算预设强度的主光源照射到每个距离场体素上的直接光照并作为出射辐射度;Step 102: Calculate the direct illumination of the main light source of preset intensity onto each distance field voxel and use it as the outgoing radiance;

对每个距离场体素计算出射辐射,对于直接漫射照明,使用标准照明技术。在体素化过程中使用平均操作,这可能导致所得到的平均法线的不希望的法线方向。这可能会产生正常衰减项的负载问题。为了减少这个问题,提出了一个用于法线衰减的法线加权方向着色模型。为了计算遮挡,除了标准阴影映射技术外,还可以使用光线投射:从光方向的体素位置跟踪光线,并对体素体积进行采样,以测试光线-体素碰撞。Outgoing radiance is computed for each distance field voxel, and for direct diffuse lighting, standard lighting techniques are used. An averaging operation is used during voxelization, which can lead to undesired normal directions for the resulting average normal. This can create loading issues for the normal attenuation term. To reduce this problem, a normal-weighted directional shading model for normal attenuation is proposed. To compute occlusion, ray casting is used in addition to standard shadow mapping techniques: a ray is traced from the voxel position in the light direction, and the voxel volume is sampled to test for ray-voxel collisions.

步骤103:将距离场体素的出射辐射度经过各向异性过滤形成层级,以生成定向体素;Step 103: The outgoing radiance of the distance field voxel is subjected to anisotropic filtering to form a hierarchy to generate a directional voxel;

本申请实施例使用各向异性滤波来填充体素表示层次的级别,以生成定向体素。为此,使用方向积分和平均运算来按轴方向过滤层次结构中从较高到较低细节级别的值;细节级别被存储在用于3D纹理的mipmap级别中。MIPMAP方法相当于纹理LOD。当物体接近观察者的物体,使用高分辨率的MIPMAP图像:当物体逐渐远离观察者时,使用低分辨率的图像。The embodiment of the present application uses anisotropic filtering to fill the levels of the voxel representation hierarchy to generate directional voxels. To this end, directional integrals and averaging operations are used to filter the values from higher to lower detail levels in the hierarchy in the axial direction; the detail levels are stored in mipmap levels for 3D textures. The MIPMAP method is equivalent to texture LOD. When an object is close to the observer, a high-resolution MIPMAP image is used: when the object gradually moves away from the observer, a low-resolution image is used.

纹理不仅仅是一张图片数据,可能是一系列图数据,因为图片放大、缩小时纹理要进行插值计算,这个过程是比较耗时间的,为了避免这耗时的计算,提高性能,显卡采用一张图片多层级纹理方式,根据摄像机离纹理距离,采用不同层级的纹理,比如摄像机离纹理较近,选择较大的纹理,摄像机离纹理较远,选择较小的纹理。这就是多层级纹理。Texture is not just a piece of image data, it may be a series of image data, because when the image is enlarged or reduced, the texture needs to be interpolated, which is a time-consuming process. In order to avoid this time-consuming calculation and improve performance, the graphics card uses a multi-level texture method for one image. Different levels of texture are used according to the distance between the camera and the texture. For example, if the camera is close to the texture, a larger texture is selected, and if the camera is far from the texture, a smaller texture is selected. This is a multi-level texture.

步骤104:通过锥体的光线束收集定向体素的出射辐射度,并计算间接光照。Step 104: Collect the outgoing radiance of the directional voxels through the cone of rays and calculate the indirect lighting.

为了近似间接光的第二次反弹,可以在过滤来自出射辐射计算的值之后添加另一个步骤。在这一点上,体素结构中提供了使用圆锥体跟踪计算间接漫反射分量的必要信息。对于每个体素,执行圆锥体跟踪以近似间接漫反射分量,然后重复滤波步骤,这样,体素表示中的出射辐射现在包含直接照明和间接漫反射的第一次反弹。To approximate the second bounce of indirect light, another step can be added after filtering the values from the outgoing radiance calculation. At this point, the necessary information to calculate the indirect diffuse component using cone tracing is available in the voxel structure. For each voxel, cone tracing is performed to approximate the indirect diffuse component, and then the filtering step is repeated, so that the outgoing radiance in the voxel representation now contains both direct lighting and the first bounce of the indirect diffuse.

漫反射和镜面反射以及环境遮挡。对于每个可见片段,计算直接和间接照明。对于间接分量,使用最终采集方案,在法线方向的半球上跟踪圆锥体,以收集存储在体素表示中的出射辐射。Diffuse and specular reflections, as well as ambient occlusion. For each visible fragment, direct and indirect lighting are calculated. For the indirect component, a final acquisition scheme is used, tracing a cone over a hemisphere in the normal direction to collect the outgoing radiance stored in the voxel representation.

具体的,步骤101的具体实现过程如下:Specifically, the specific implementation process of step 101 is as follows:

在体素化过程中,法向量、反照率和发射值存储在体素中,每个属性都有自己的3D纹理。该信息是计算单独光路的漫反射和法向衰减所必需的,其中不是计算每个像素的照明,而是按体素计算。该结构可以扩展以支持更复杂的预测模型,但这可能意味着存储额外数据的内存消耗更高。During voxelization, normal vectors, albedo, and emission values are stored in voxels, with each attribute having its own 3D texture. This information is necessary to calculate diffuse and normal falloff for separate light paths, where instead of calculating lighting per pixel, it is calculated per voxel. This structure can be extended to support more complex prediction models, but this may mean higher memory consumption for storing the additional data.

此外,距离场阶梯跟踪过程使用了另一种结构。每个体素的照明计算结果值存储在另一个3D纹理中,称之为辐射体积。为了近似圆锥体的递增直径及其采样体积,使用体素化场景的细节级别。对于各向异性体素,需要六个具有辐射体积一半分辨率的3D纹理,每个轴方向一个纹理,也有正方向和负方向。细节级别存储在这些纹理的mipmap级别中,称之为定向体积。Additionally, the distance field step tracing process uses another structure. The lighting calculation results for each voxel are stored in another 3D texture, called the radiation volume. To approximate the increasing diameter of the cone and its sampling volume, the level of detail of the voxelized scene is used. For anisotropic voxels, six 3D textures with half the resolution of the radiation volume are needed, one texture for each axis, also in positive and negative directions. The level of detail is stored in the mipmap levels of these textures, called directional volumes.

辐射体积表示体素化场景的最大细节级别,此纹理与方向体积分离。为了绑定这两个结构,当距离场范围所需的mipmap级别介于最大级别和第一个过滤的详细级别之间时,在两个结构的样本之间使用线性插值。The radiation volume represents the maximum level of detail of the voxelized scene, this texture is separate from the direction volume. To bind these two structures, linear interpolation is used between samples of the two structures when the mipmap level required by the distance field range is between the maximum level and the first filtered level of detail.

体素化过程使用保守的体素化方案执行,这意味着如果几何体存在于体素的空间内,则该空间中必须有体素。可以通过测试由三角形的顶点定义的平面是否与B相交,以及三角形沿其法线主轴的2D投影是否与B的2D投影相交,来为每个体素B计算三角形的薄表面体素化。The voxelization process is performed using a conservative voxelization scheme, which means that if the geometry exists in the voxel's space, there must be a voxel in that space. A thin surface voxelization of a triangle can be calculated for each voxel B by testing whether the plane defined by the triangle's vertices intersects B, and whether the 2D projection of the triangle along its normal's principal axis intersects the 2D projection of B.

对于每个投影的三角形,都会生成一个稍大的边界多边形,以确保无论投影的三角形有多小,它都会生成至少一个片段。要创建此多边形,每个三角形边都会向外移动,以便放大三角形。边界多边形不会高估投影三角形的覆盖范围,因此使用由投影三角形顶点定义的扩展边界框丢弃多余的片段。For each projected triangle, a slightly larger bounding polygon is generated to ensure that no matter how small the projected triangle is, it will generate at least one fragment. To create this polygon, each triangle edge is moved outward so that the triangle is enlarged. The bounding polygon does not overestimate the coverage of the projected triangle, so excess fragments are discarded using the expanded bounding box defined by the projected triangle vertices.

一个体素可以包含许多片段,并且所有这些片段都可以具有不同的存储属性值(即反照率、法线和发射)。为了获得离散几何体的良好近似,对每个属性的体素空间内的所有值应用平均运算。必须使用原子操作在其各自的3D纹理中的每个体素位置写入和读取属性,以确保时间一致的结果。A voxel can contain many fragments, and all of these fragments can have different values for the stored attributes (i.e. albedo, normal, and emission). To get a good approximation of the discrete geometry, an average operation is applied to all values within the voxel space for each attribute. Attributes must be written and read using atomic operations at each voxel location in their respective 3D texture to ensure temporally consistent results.

对于动态更新,静态和动态几何体的对应的矢量距离场的属性计算是分开的。虽然静态体素化只发生一次,但动态体素化在每帧或需要时发生。两种类型的几何体的体素化发生在上述相同的过程中,因此需要一种指示哪些体素是静态的方法,本申请实施例使用单值3D纹理来识别静态体素,这种纹理将被称为流动体积。在静态体素化过程中,生成体素后,将一个值写入到流动体积中,指示该位置为静态。相反,在动态体素化过程中,在生成体素之前,从体素写入位置的流动体积中读取一个值。如果该值指示该位置标记为静态,则放弃写入,使静态体素保持不变。For dynamic updates, the attribute calculations of the corresponding vector distance fields of static and dynamic geometry are separated. Although static voxelization occurs only once, dynamic voxelization occurs in each frame or when needed. Voxelization of the two types of geometry occurs in the same process described above, so a method is needed to indicate which voxels are static. The embodiment of the present application uses a single-valued 3D texture to identify static voxels. This texture will be referred to as a flow volume. During the static voxelization process, after the voxel is generated, a value is written to the flow volume to indicate that the position is static. In contrast, during the dynamic voxelization process, before the voxel is generated, a value is read from the flow volume at the voxel write position. If the value indicates that the position is marked as static, the write is abandoned, leaving the static voxel unchanged.

为了不断地重新场景,有必要从3D纹理中清除先前存储的动态体素。这是在使用图形处理单元(GPU)上的通用计算或者ComputeShading的计算进行动态体素化之前完成的。在两种条件下读取流动体积以清除体素:体素是否存在以及体素是否动态。In order to continuously reshape the scene, it is necessary to clear previously stored dynamic voxels from the 3D texture. This is done before dynamic voxelization using general-purpose computation on the graphics processing unit (GPU) or computation with ComputeShading. The flow volume is read to clear voxels under two conditions: if the voxel exists and if the voxel is dynamic.

具体的,步骤102的具体实现过程包括:Specifically, the specific implementation process of step 102 includes:

为了在矢量距离场阶梯计算跟踪步骤期间正确地近似间接照明,有必要将入射辐射存储在体素结构的辐射体积中。受延迟渲染的启发,实现了计算每个体素的直接照明的体素光路。然而,与对每个可见像素执行光路的延迟渲染不同,这里的照明计算是对每个可见或不可见的体素进行的。这对于避免可见性问题是必要的,因为该结构用于近似间接照明。在这种情况下,无论是否有助于可见碎片的光分布,相机的遮挡或不可见几何体。为了加快这一过程,GPU基于GPGPU方法,对为辐射体积保留的每个体素执行一个线程。In order to correctly approximate the indirect lighting during the vector distance field ladder calculation tracing step, it is necessary to store the incoming radiation in a radiation volume of the voxel structure. Inspired by deferred rendering, a voxel light path is implemented that calculates the direct lighting of each voxel. However, unlike deferred rendering where the light path is performed for each visible pixel, here the lighting calculation is performed for each voxel, visible or invisible. This is necessary to avoid visibility issues, as the structure is used to approximate indirect lighting. In this case, it does not matter whether the light distribution contributes to visible debris, occlusions from the camera or invisible geometry. To speed up this process, the GPU executes one thread for each voxel reserved for the radiation volume based on a GPGPU approach.

对于Lambert反射模型,可以使用体素化过程中存储在3D纹理中的信息来计算每个体素的着色。对于每个光源,按体素计算以下方程以描述体素出射辐射度VrFor the Lambert reflectance model, the shading of each voxel can be calculated using the information stored in the 3D texture during the voxelization process. For each light source, the following equation is calculated per voxel to describe the voxel outgoing radiance V r :

其中,Li为光源强度,ρ为体素的反照率,N为体素法向矢量,Ψ为光方向。对于聚光灯和点光源等非均匀光源,需要体素的位置。这可以通过将体素在纹理空间中的位置投影到世界空间来获得。Where Li is the light intensity, ρ is the albedo of the voxel, N is the voxel normal vector, and Ψ is the light direction. For non-uniform light sources such as spotlights and point lights, the position of the voxel is required. This can be obtained by projecting the position of the voxel in texture space into world space.

当体素的法向向量用于法向衰减项(NΨ)时,它可能会给出不想要的结果。由于使用平均运算来存储法线向量,因此所得到的平均法线可能最终指向不方便的方向。当体素空间内的法向量不均匀时,这个问题是值得注意的。为了减少这个问题,本实施例使用了法向加权衰减,其中首先按体素的每个面计算法向衰减,如下所示:When the voxel's normal vector is used for the normal attenuation term (NΨ), it may give undesirable results. Since an average operation is used to store the normal vector, the resulting average normal may end up pointing in an inconvenient direction. This problem is noticeable when the normal vectors within the voxel space are not uniform. To reduce this problem, the present embodiment uses normal weighted attenuation, where the normal attenuation is first calculated per face of the voxel as follows:

计算距离场体素的每个面的法向衰减矢量Dx,y,zCalculate the normal falloff vector D x,y,z for each face of the distance field voxel:

其中,Ψ为光方向;为每个面的体素法向矢量;Among them, Ψ is the light direction; is the voxel normal vector for each face;

根据体素的每个面的平均法线Nω的轴符号选择三个主面DωThe three principal faces D ω are selected according to the axis signs of the average normal N ω of each face of the voxel:

则预设强度的主光源照射到距离场体素上的出射辐射度Vr为:Then the outgoing radiance Vr of the main light source with preset intensity irradiating the distance field voxel is:

W=N2 W= N2

其中,Li为主光源的预设强度,ρ为体素的反照率,N为体素法线向量,W为体素平均法线权重向量:W=(Wx,Wy,Wz),(Dx,Dy,Dz)为三个主面的法向衰减矢量乘积后的向量。Among them, Li is the preset intensity of the main light source, ρ is the albedo of the voxel, N is the voxel normal vector, W is the voxel average normal weight vector: W = ( Wx , Wy , Wz ), ( Dx , Dy , Dz ) is the vector of the product of the normal attenuation vectors of the three main surfaces.

为了在矢量距离场跟踪步骤中生成准确的结果,需要对体素进行遮挡,否则本应几乎没有传出辐射的体素化几何体将有助于间接照明计算。In order to produce accurate results in the Vector Distance Field tracing step, voxels need to be occluded, otherwise voxelized geometry that would have little outgoing radiance would contribute to the indirect lighting calculations.

将体素的位置投影在光空间中,并将投影点的深度与来自阴影图的存储深度进行比较,以确定体素是否被遮挡。对该技术的一个简单改进如下:不使用体素中心位置Vp,而是将该位置沿着体素的法向量平移半体素大小Vsize,即Vp=Vp+N×Vsize×0.5,这进一步暴露了体素位置,以防中心位置可能被体素附近的几何体遮挡。The position of the voxel is projected in light space, and the depth of the projected point is compared with the stored depth from the shadow map to determine whether the voxel is occluded. A simple improvement to this technique is as follows: instead of using the voxel center position Vp, the position is translated along the voxel's normal vector by half a voxel size Vsize, that is, Vp = Vp + N × Vsize × 0.5, which further exposes the voxel position in case the center position may be occluded by geometry near the voxel.

本申请实施例使用体积内的光线投射来计算遮挡。可以使用来自体素化过程的任何结果体积,因为该算法只需要确定体素是否存在于特定位置。为了确定体素的遮挡,从体素的位置沿着光的方向跟踪射线,对体积进行采样,以确定在射线的位置是否有体素(如图2(a)所示),如果此条件成立,则体素被遮挡。The present application embodiment uses ray casting within the volume to calculate occlusion. Any resulting volume from the voxelization process can be used, because the algorithm only needs to determine whether a voxel exists at a specific position. In order to determine the occlusion of a voxel, a ray is traced from the position of the voxel along the direction of the light, and the volume is sampled to determine whether there is a voxel at the position of the ray (as shown in Figure 2(a)). If this condition is met, the voxel is occluded.

软阴影不是在发现体素后立即停止射线,而是可以用单个射线来近似,每次碰撞累积一个值κ,并除以追踪距离t,即当前的软阴影|Α1为:Instead of stopping the ray immediately after finding a voxel, the soft shadow can be approximated with a single ray, accumulating a value κ for each collision and dividing it by the tracing distance t, that is, the current soft shadow |Α 1 is:

1=|Α0+(1-|Α0)κ÷t1 =|Α 0 +(1-|Α 0 )κ÷t

其中,上一帧的软阴影为|Α0;从光的角度来看,对于穿过体素化几何体边界的光线,碰撞次数通常会更高(如图2(b)所示)。Among them, the soft shadow of the previous frame is |Α 0 ; from the perspective of light, the number of collisions is usually higher for light that passes through the boundary of voxelized geometry (as shown in Figure 2(b)).

在获得直接照明值之后,来自体素化过程的发射项被添加到每个体素的该值。在圆锥体跟踪步骤中,这些体素即使在被遮挡的区域上也会看起来很亮,因此来自体素化场景的这些区域的间接光会在每个圆锥体上累积。After obtaining the direct lighting value, the emission term from the voxelization process is added to this value for each voxel. In the cone tracing step, these voxels will appear bright even on occluded areas, so the indirect light from these areas of the voxelized scene is accumulated on each cone.

具体的,步骤103的具体实现过程包括:Specifically, the specific implementation process of step 103 includes:

为了在矢量距离场跟踪步骤中获得更精确的结果,使用了各向异性体素。mipmapping级别将为每个体素存储六个方向值,每个方向轴正负一个方向值。每个圆锥体都有一个原点、孔径角度和方向,最后一个因素决定了对哪三个体积进行采样。通过对从所选定向体积获得的三个样本进行线性插值来获得定向样本。To get more accurate results in the vector distance field tracing step, anisotropic voxels are used. The mipmapping level will store six orientation values for each voxel, one for each orientation axis. Each cone has an origin, aperture angle, and orientation, the last factor determining which three volumes are sampled. Orientation samples are obtained by linearly interpolating the three samples obtained from the selected orientation volume.

为了生成各向异性体素,为了计算方向值,在深度上进行体积积分,并对方向值进行平均,以获得特定方向的结果值。本实施例使用GPU在mipmap级别上为每个体素执行一个线程来执行的,该线程将使用上一级别的值进行过滤,该过程是在每个mipmap级上执行的。To generate anisotropic voxels, to calculate the direction value, volume integration is performed over the depth, and the direction values are averaged to obtain the result value for a specific direction. This embodiment uses the GPU to execute one thread for each voxel at the mipmap level, which will filter using the value of the previous level, and this process is performed at each mipmap level.

矢量距离场跟踪类似于光线行进,每走一步都前进一定的长度,只是采样体积沿着距离场的直径增加。方向体积中的mipmap级别用于近似锥形轨迹期间采样体积的扩展,以确保样本之间的平滑变化,可以使用四次线性插值。Vector distance field tracing is similar to ray marching, advancing a certain distance with each step, except that the sampling volume increases along the diameter of the distance field. Mipmap levels in the direction volume are used to approximate the expansion of the sampling volume during conical tracing to ensure smooth changes between samples, using quartic linear interpolation.

在圆锥台阶过程中,圆锥的直径由d定义,该值可以使用跟踪距离t提取,公式如下:In the conical step process, the diameter of the cone is defined by d, which can be extracted using the tracking distance t, as follows:

d=2t×tan(θ/2)d=2t×tan(θ/2)

其中,θ为孔径角。Where θ is the aperture angle.

根据圆锥体的直径,应该对哪个mipmap级别Vlevel进行采样,可以使用以下方程:Depending on the diameter of the cone, which mipmap level Vlevel should be sampled, the following equation can be used:

Vlevel=log2(d÷Vsize)Vlevel=log2(d÷Vsize)

其中Vsize是最大细节水平下体素的大小。Where Vsize is the size of the voxel at the maximum level of detail.

具体的,步骤104的具体实现过程包括:Specifically, the specific implementation process of step 104 includes:

从定向体素中获取遮挡值da和出射辐射度dcGet the occlusion value da and the outgoing radiance dc from the directional voxel;

光线在锥体的第m次步进后,间接光照值cm和跟踪遮挡值αm为:After the light steps through the cone for the mth time, the indirect illumination value cm and the tracking occlusion value αm are:

cm=cm-1αm-1+(1-αm-1)dadc c m =c m-1 α m-1 + (1-α m-1 )d a d c

αm=αm-1+(1-αm-1)da α mm-1 +(1-α m-1 )d a

其中,cm-1和αm-1为光线在锥体的第m-1次步进后的间接光照值和跟踪遮挡值。Among them, cm -1 and αm -1 are the indirect lighting value and tracking occlusion value of the light after the m-1th step of the cone.

为了确保样本之间的良好集成质量,通过因子β来修改步骤之间的距离d0。当β=1时,d0的值等于圆锥的直径d,小于1的值会产生更高质量的结果,但需要更多的样本,这会降低性能。To ensure good integration quality between samples, the distance d0 between steps is modified by a factor β. When β = 1, the value of d0 is equal to the diameter d of the cone, and values less than 1 produce higher quality results but require more samples, which degrades performance.

为了提高效率,这个过程是在屏幕空间中实现的,使用延迟渲染。对于每个可见的碎片,都会跟踪一组锥体以获得不同的效果。For efficiency, this process is implemented in screen space, using deferred rendering. For each visible fragment, a set of cones are tracked to achieve a different effect.

间接照明采用粗略的蒙特卡罗近似。渲染方程中积分的半球区域可以划分为积分的和。对于规则分区,每个分区区域都类似于一个圆锥体。对于每个圆锥体,使用在距离场中跟踪有效的体素来近似它们的结果,然后对所得值进行加权,以获得圆锥体原点处的累积结果。A coarse Monte Carlo approximation is used for indirect lighting. The hemispherical region that is integrated in the rendering equation can be divided into a sum of integrals. For regular partitions, each partitioned region resembles a cone. For each cone, their results are approximated using traced valid voxels in the distance field, and then the resulting values are weighted to obtain the accumulated result at the cone origin.

对于Blinn Phong材质,分布在法线方向半球上的几个大圆锥体估计漫反射,而反射方向上的单个距离场(其孔径取决于镜面指数)近似于镜面反射。For Blinn Phong materials, several large cones distributed over the hemisphere in the normal direction estimate the diffuse reflection, while a single distance field in the reflection direction (whose aperture depends on the specular exponent) approximates the specular reflection.

为了提高效率,可以使用用于漫反射的相同锥体来近似环境遮挡。对于环境遮挡项δ,只累积遮挡值da,在每一步,累积值乘以加权函数f(r):For efficiency, ambient occlusion can be approximated using the same cone used for diffuse reflection. For the ambient occlusion term δ, only the occlusion value da is accumulated, and at each step, the accumulated value is multiplied by a weighting function f(r):

f(r)=1/(1+λr)f(r)=1/(1+λr)

其中,r是圆锥体的当前半径,λ是用户定义的值。Where r is the current radius of the cone and λ is a user-defined value.

控制f(r)沿追踪距离衰减的速度,光线在锥体的第m次步进后,环境遮挡项δm更新为:Controls the speed at which f(r) decays along the tracing distance. After the light steps through the cone for the mth time, the ambient occlusion term δm is updated to:

δm=δm-1+(1-δm-1)daf(r)δ mm-1 +(1-δ m-1 )d a f(r)

其中,δm-1为光线在锥体的第m-1次步进后的环境遮挡项。Among them, δ m-1 is the ambient occlusion term after the light steps through the cone for the m-1th time.

圆锥体跟踪也可用于实现从曲面点向灯光方向跟踪圆锥体的柔和阴影。圆锥体光圈控制生成的阴影的柔和度和散射度。对于带有圆锥体的柔和阴影,只在每一步累积遮挡值。Cone tracing can also be used to implement soft shadows by tracing a cone from a surface point towards the light. The cone aperture controls the softness and diffuseness of the resulting shadows. For soft shadows with cones, only occlusion values are accumulated at each step.

为了使用矢量距离场阶梯跟踪计算表面点上的漫反射,需要其法向量、反照率和该点的入射辐射。由于将几何法线向量和反照率体素化为3D纹理,因此在计算体素直接照明后,间接漫射项所需的所有信息都可用。使用GPGPU对每个有效体素执行对应的距离场阶梯跟踪,以计算每个体素处间接漫射的第一次反弹。该步骤是在对体素直接照明过程的出射辐射值进行各向异性滤波后完成的In order to compute the diffuse reflection at a surface point using Vector Distance Field Step Tracing, its normal vector, albedo, and the incoming radiance at that point are required. Since the geometry normal vector and albedo are voxelized as a 3D texture, all the information required for the indirect diffuse term is available after computing the voxel direct illumination. A corresponding distance field step trace is performed for each valid voxel using GPGPU to compute the first bounce of the indirect diffuse at each voxel. This step is done after anisotropic filtering of the outgoing radiance value of the voxel direct illumination pass.

对于每个体素,使用其平均法向量在法线方向的半球周围生成一组圆锥体,以计算体素位置的间接漫射。然后将来自所有距离场的有效加权结果乘以体素的反照率,并将其添加到直接照明值。For each voxel, a set of cones are generated around a hemisphere in the normal direction using its average normal vector to compute the indirect diffuse for the voxel's position. The effective weighted result from all distance fields is then multiplied by the voxel's albedo and added to the direct lighting value.

辐射体积的最终出射辐射现在存储直接照明和间接漫射的第一次反弹。对于新值,需要重复各向异性过滤过程。能够在每个像素的最终距离场的阶梯计算步骤中近似间接照明的第二次反弹。The final outgoing radiance of the radiation volume now stores the first bounce of direct illumination and indirect diffuse. The anisotropic filtering process needs to be repeated for the new values. The second bounce of indirect illumination can be approximated in the staircase calculation step of the final distance field for each pixel.

基于同样的发明构思,本申请实施例提供了一种实时全局光照渲染装置,参阅图3所示,本申请实施例提供的实时全局光照渲染装置200至少包括:Based on the same inventive concept, an embodiment of the present application provides a real-time global illumination rendering device. Referring to FIG. 3 , the real-time global illumination rendering device 200 provided in the embodiment of the present application at least includes:

体素化单元201,用于对当前帧的场景几何体进行体素化处理,得到距离场体素,所述距离场体素的属性包括:矢量距离场、法向量、反照率和发射值;A voxelization unit 201 is used to voxelize the scene geometry of the current frame to obtain distance field voxels, and the properties of the distance field voxels include: vector distance field, normal vector, albedo and emission value;

直接光照计算单元202,用于计算预设强度的主光源照射到每个距离场体素上的直接光照并作为出射辐射度;A direct illumination calculation unit 202, used to calculate the direct illumination of the main light source of preset intensity irradiated on each distance field voxel and use it as the outgoing radiance;

处理单元203,用于将距离场体素的出射辐射度经过各向异性过滤形成层级,以生成定向体素;A processing unit 203 is used to form a hierarchy by anisotropic filtering the outgoing radiance of the distance field voxels to generate directional voxels;

间接光照计算单元204,用于通过锥体的光线束收集定向体素的出射辐射度,并计算间接光照。The indirect lighting calculation unit 204 is used to collect the outgoing radiance of the directional voxels through the cone-shaped light beam and calculate the indirect lighting.

需要说明的是,本申请实施例提供的实时全局光照渲染装置200解决技术问题的原理与本申请实施例提供的方法相似,因此,本申请实施例提供的实时全局光照渲染装置200的实施可以参见本申请实施例提供的方法的实施,重复之处不再赘述。It should be noted that the principle of solving the technical problem by the real-time global illumination rendering device 200 provided in the embodiment of the present application is similar to the method provided in the embodiment of the present application. Therefore, the implementation of the real-time global illumination rendering device 200 provided in the embodiment of the present application can refer to the implementation of the method provided in the embodiment of the present application, and the repeated parts will not be repeated.

如图4所示,本申请实施例提供的电子设备300至少包括:处理器301、存储器302和存储在存储器302上并可在处理器301上运行的计算机程序,处理器301执行计算机程序时实现本申请实施例提供的实时全局光照渲染方法。As shown in Figure 4, the electronic device 300 provided in the embodiment of the present application includes at least: a processor 301, a memory 302, and a computer program stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program, the real-time global illumination rendering method provided in the embodiment of the present application is implemented.

本申请实施例提供的电子设备300还可以包括连接不同组件(包括处理器301和存储器302)的总线303。其中,总线303表示几类总线结构中的一种或多种,包括存储器总线、外围总线、局域总线等。The electronic device 300 provided in the embodiment of the present application may further include a bus 303 connecting different components (including the processor 301 and the memory 302). The bus 303 represents one or more of several types of bus structures, including a memory bus, a peripheral bus, a local bus, and the like.

存储器302可以包括易失性存储器形式的可读介质,例如随机存储器(RandomAccess Memory,RAM)3021和/或高速缓存存储器3022,还可以进一步包括只读存储器(ReadOnly Memory,ROM)3023。The memory 302 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 3021 and/or a cache memory 3022 , and may further include a read-only memory (ROM) 3023 .

存储器302还可以包括具有一组(至少一个)程序模块3025的程序工具3024,程序模块3025包括但不限于:操作子系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。The memory 302 may also include a program tool 3024 having a set (at least one) of program modules 3025, the program modules 3025 including but not limited to: an operating subsystem, one or more applications, other program modules and program data, each of which or some combination may include the implementation of a network environment.

电子设备300也可以与一个或多个外部设备304(例如键盘、遥控器等)通信,还可以与一个或者多个使得用户能与电子设备300交互的设备通信(例如手机、电脑等),和/或,与使得电子设备300与一个或多个其它电子设备300进行通信的任何设备(例如路由器、调制解调器等)通信。这种通信可以通过输入/输出(Input/Output,I/O)接口305进行。并且,电子设备300还可以通过网络适配器306与一个或者多个网络(例如局域网(Local AreaNetwork,LAN),广域网(Wide Area Network,WAN)和/或公共网络,例如因特网)通信。如图4所示,网络适配器306通过总线303与电子设备300的其它模块通信。应当理解,尽管图4中未示出,可以结合电子设备300使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理器、外部磁盘驱动阵列、磁盘阵列(Redundant Arrays of IndependentDisks,RAID)子系统、磁带驱动器以及数据备份存储子系统等。The electronic device 300 may also communicate with one or more external devices 304 (e.g., keyboards, remote controllers, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 300 (e.g., mobile phones, computers, etc.), and/or, may communicate with any device that enables the electronic device 300 to communicate with one or more other electronic devices 300 (e.g., routers, modems, etc.). Such communication may be performed via an input/output (I/O) interface 305. Furthermore, the electronic device 300 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and/or a public network, such as the Internet) via a network adapter 306. As shown in FIG. 4 , the network adapter 306 communicates with other modules of the electronic device 300 via a bus 303. It should be understood that although not shown in Figure 4, other hardware and/or software modules can be used in conjunction with the electronic device 300, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) subsystems, tape drives, and data backup storage subsystems.

需要说明的是,图4所示的电子设备300仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。It should be noted that the electronic device 300 shown in FIG. 4 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机指令,该计算机指令被处理器执行时实现本申请实施例提供的实时全局光照渲染方法。The embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a processor, the real-time global illumination rendering method provided by the embodiment of the present application is implemented.

此外,尽管在附图中以特定顺序描述了本申请方法的操作,但是,这并非要求或者暗示必须按照该特定顺序来执行这些操作,或是必须执行全部所示的操作才能实现期望的结果。附加地或备选地,可以省略某些步骤,将多个步骤合并为一个步骤执行,和/或将一个步骤分解为多个步骤执行。In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and/or one step may be decomposed into multiple steps.

尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims (6)

1. A real-time global illumination rendering method, comprising:
voxelization is carried out on the scene geometry of the current frame to obtain distance field voxels, wherein the attributes of the distance field voxels comprise: vector distance field, normal vector, albedo, and emission value;
calculating direct illumination of a main light source with preset intensity to each distance field voxel and taking the direct illumination as emergent radiance, wherein the method specifically comprises the following steps of:
A normal attenuation vector D x,y,z for each face of the distance field voxel is calculated:
wherein ψ is the light direction; a voxel normal vector for each face;
Three main faces D ω are selected according to the axis sign of the average normal N ω to each face of the voxel:
the emergent radiance V r of the main light source with preset intensity irradiated to the distance field voxel is:
W=N2
Wherein L i is the preset intensity of the main light source, ρ is the albedo of the voxels, N is the voxel normal vector, and W is the voxel average normal weight vector: w= (W x,Wy,Wz),(Dx,Dy,Dz) is the vector of the normal decay vector product of the three main faces;
judging whether the voxel is blocked or not, specifically comprising: projecting the position of the voxel in a light space and comparing the depth of the projected point with the stored depth from the shadow map to determine if the voxel is occluded;
The outgoing radiance of the distance field voxels is anisotropically filtered to form a hierarchy to generate directional voxels, comprising:
Dividing the distance field voxels, summing the distance field voxels in each axial direction, taking a mean value, and interpolating according to the angle of the light during sampling to obtain a radiation value;
storing six direction values for each distance field voxel using anisotropic filtering;
obtaining directional voxels by linear interpolation of three samples obtained from the selected directional volume;
The method for collecting the emergent radiance of the directional voxels through the cone ray bundles and calculating indirect illumination specifically comprises the following steps:
Obtaining a shielding value d a and an emergent radiance d c from the directional voxels;
After the mth step of the cone, the indirect illumination value c m and the tracking occlusion value alpha m are:
cm=cm-1αm-1+(1-αm-1)dadc
αm=αm-1+(1-αm-1)da
Wherein c m-1 and alpha m-1 are indirect illumination values and tracking occlusion values of the light after the m-1 th step of the cone.
2. The real-time global illumination rendering method according to claim 1, wherein the scene geometry of the current frame is subjected to voxelization to obtain distance field voxels; comprising the following steps:
Generating a larger boundary polygon than the projected triangle for each scene geometry of the current frame to generate at least one segment, each segment having a different attribute, comprising: inverse normal vector, albedo, and emission value;
averaging the attributes of all fragments in a voxel to obtain the attribute of the voxel;
The layered distance field representation stored in the 3D texture is used to derive the vector distance field for the scene geometry.
3. The real-time global illumination rendering method of claim 1, further comprising:
When the distance field voxel of the previous frame is a dynamic voxel, updating the attribute body and the radiator of the current frame;
when the distance field voxel of the previous frame is a static voxel, the distance field voxel of the current frame uses the value of the previous frame;
The distance field voxels of the current frame are marked as dynamic voxels or static voxels.
4.A real-time global illumination rendering apparatus, comprising:
The voxelization unit is used for voxelization processing of the scene geometry of the current frame to obtain distance field voxels, and the attributes of the distance field voxels comprise: vector distance field, normal vector, albedo, and emission value;
the direct illumination calculation unit is used for calculating the direct illumination of the main light source with preset intensity irradiated to each distance field voxel and used as emergent radiance, and specifically comprises the following steps:
A normal attenuation vector D x,y,z for each face of the distance field voxel is calculated:
wherein ψ is the light direction; a voxel normal vector for each face;
Three main faces D ω are selected according to the axis sign of the average normal N ω to each face of the voxel:
the emergent radiance V r of the main light source with preset intensity irradiated to the distance field voxel is:
W=N2
Wherein L i is the preset intensity of the main light source, ρ is the albedo of the voxels, N is the voxel normal vector, and W is the voxel average normal weight vector: w= (W x,Wy,Wz),(Dx,Dy,Dz) is the vector of the normal decay vector product of the three main faces;
judging whether the voxel is blocked or not, specifically comprising: projecting the position of the voxel in a light space and comparing the depth of the projected point with the stored depth from the shadow map to determine if the voxel is occluded;
the processing unit is used for forming a hierarchy by anisotropically filtering the emergent radiance of the distance field voxels to generate directional voxels, and specifically comprises the following steps:
Dividing the distance field voxels, summing the distance field voxels in each axial direction, taking a mean value, and interpolating according to the angle of the light during sampling to obtain a radiation value;
storing six direction values for each distance field voxel using anisotropic filtering;
obtaining directional voxels by linear interpolation of three samples obtained from the selected directional volume;
An indirect illumination calculation unit for collecting outgoing radiance of the directional voxels through the ray bundles of the cone and calculating indirect illumination, specifically comprising:
Obtaining a shielding value d a and an emergent radiance d c from the directional voxels;
After the mth step of the cone, the indirect illumination value c m and the tracking occlusion value alpha m are:
cm=cm-1αm-1+(1-αm-1)dadc
αm=αm-1+(1-αm-1)da
Wherein c m-1 and alpha m-1 are indirect illumination values and tracking occlusion values of the light after the m-1 th step of the cone.
5. An electronic device, comprising: a memory and a processor, the memory having stored therein an executable program, the processor executing the executable program to implement the steps of the method of any one of claims 1 to 3.
6. A storage medium carrying one or more computer programs which, when executed by a processor, implement the steps of the method of any one of claims 1 to 3.
CN202410057767.1A 2024-01-15 2024-01-15 Real-time global illumination rendering method, device and electronic device Active CN117893670B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410057767.1A CN117893670B (en) 2024-01-15 2024-01-15 Real-time global illumination rendering method, device and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410057767.1A CN117893670B (en) 2024-01-15 2024-01-15 Real-time global illumination rendering method, device and electronic device

Publications (2)

Publication Number Publication Date
CN117893670A CN117893670A (en) 2024-04-16
CN117893670B true CN117893670B (en) 2024-10-18

Family

ID=90651781

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410057767.1A Active CN117893670B (en) 2024-01-15 2024-01-15 Real-time global illumination rendering method, device and electronic device

Country Status (1)

Country Link
CN (1) CN117893670B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109364481A (en) * 2018-10-30 2019-02-22 网易(杭州)网络有限公司 Real-time global illumination method, apparatus, medium and electronic equipment in game
CN115713584A (en) * 2022-11-10 2023-02-24 上海纵游网络技术有限公司 Method, system, device and storage medium for rendering volume cloud based on directed distance field

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107452048B (en) * 2016-05-30 2019-03-12 网易(杭州)网络有限公司 The calculation method and device of global illumination
EP3662451B1 (en) * 2017-07-31 2021-09-01 Ecole Polytechnique Fédérale de Lausanne (EPFL) A method for voxel ray-casting of scenes on a whole screen
CN116206041A (en) * 2021-11-30 2023-06-02 华为技术有限公司 A rendering method and related equipment
CN115830208B (en) * 2023-01-09 2023-05-09 腾讯科技(深圳)有限公司 Global illumination rendering method, device, computer equipment and storage medium
CN116310053A (en) * 2023-01-19 2023-06-23 安徽空境信息科技有限公司 Determination method, rendering method, device and medium for light intensity distribution in scene rendering
CN117152237A (en) * 2023-09-25 2023-12-01 不鸣科技(杭州)有限公司 Distance field generation method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109364481A (en) * 2018-10-30 2019-02-22 网易(杭州)网络有限公司 Real-time global illumination method, apparatus, medium and electronic equipment in game
CN115713584A (en) * 2022-11-10 2023-02-24 上海纵游网络技术有限公司 Method, system, device and storage medium for rendering volume cloud based on directed distance field

Also Published As

Publication number Publication date
CN117893670A (en) 2024-04-16

Similar Documents

Publication Publication Date Title
US11030794B2 (en) Importance sampling for determining a light map
Woo et al. A survey of shadow algorithms
US7212207B2 (en) Method and apparatus for real-time global illumination incorporating stream processor based hybrid ray tracing
Thiedemann et al. Voxel-based global illumination
US8542231B2 (en) Method, computer graphics image rendering system and computer-readable data storage medium for computing of indirect illumination in a computer graphics image of a scene
US9953457B2 (en) System, method, and computer program product for performing path space filtering
Wand et al. Processing and interactive editing of huge point clouds from 3D scanners
Lefohn et al. Resolution-matched shadow maps
US20100085360A1 (en) Rendering in scattering media
US9508191B2 (en) Optimal point density using camera proximity for point-based global illumination
Lensing et al. Instant indirect illumination for dynamic mixed reality scenes
US9208610B2 (en) Alternate scene representations for optimizing rendering of computer graphics
US20080012853A1 (en) Generating mesh from implicit surface
KR101447552B1 (en) Method for selecting mip-map level and system for texture mapping using same
CN102831634B (en) Efficient accurate general soft shadow generation method
US20230274493A1 (en) Direct volume rendering apparatus
CN104112034A (en) System, method, and computer program product for performing path space filtering
Wand et al. Multi-Resolution Point-Sample Raytracing.
Liktor et al. Real-time volume caustics with adaptive beam tracing
Eisemann et al. Efficient real-time shadows
CN117893670B (en) Real-time global illumination rendering method, device and electronic device
Papaioannou et al. Real-time volume-based ambient occlusion
Jabłoński Real-time voxel rendering algorithm based on screen space billboard voxel buffer with sparse lookup textures
Jansen et al. Data locality in parallel rendering
Simion et al. Practical gpu and voxel-based indirect illumination for real time computer games

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant