[go: up one dir, main page]

CN118537468A - Multi-level parallel rendering method and system for light field image - Google Patents

Multi-level parallel rendering method and system for light field image Download PDF

Info

Publication number
CN118537468A
CN118537468A CN202410506005.5A CN202410506005A CN118537468A CN 118537468 A CN118537468 A CN 118537468A CN 202410506005 A CN202410506005 A CN 202410506005A CN 118537468 A CN118537468 A CN 118537468A
Authority
CN
China
Prior art keywords
parallel
rendering
level
data
triangle
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.)
Pending
Application number
CN202410506005.5A
Other languages
Chinese (zh)
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.)
Zhejiang Sci Tech University ZSTU
Original Assignee
Zhejiang Sci Tech University ZSTU
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 Zhejiang Sci Tech University ZSTU filed Critical Zhejiang Sci Tech University ZSTU
Priority to CN202410506005.5A priority Critical patent/CN118537468A/en
Publication of CN118537468A publication Critical patent/CN118537468A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering

Landscapes

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

Abstract

本发明公开了一种光场图像的多层级并行渲染方法和系统,属于图像渲染技术领域。本发明的一种光场图像的多层级并行渲染方法,通过构建第一层级渲染模型、第二层级渲染模型、第三层级渲染模型,得到光场图像,能够实现三层级的并行渲染,从而有效减少冗余计算,提升渲染效率,因而可以实现大数据量、高品质光场图像的快速渲染。进一步,本发明利用多层级的并行渲染方法可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。同时,本发明利用多层级的并行渲染方法可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。

The present invention discloses a multi-level parallel rendering method and system for light field images, and belongs to the field of image rendering technology. The multi-level parallel rendering method for light field images of the present invention obtains light field images by constructing a first-level rendering model, a second-level rendering model, and a third-level rendering model, and can realize three-level parallel rendering, thereby effectively reducing redundant calculations and improving rendering efficiency, thereby realizing fast rendering of large data volumes and high-quality light field images. Furthermore, the present invention utilizes a multi-level parallel rendering method to effectively overcome the rendering bottlenecks of high-dimensional data and graphics encountered by traditional methods in the problem of parallel rendering of high-dimensional parallax images, thereby greatly improving rendering efficiency. At the same time, the present invention utilizes a multi-level parallel rendering method to give full play to the parallel computing capabilities of the GPU, greatly reducing the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving communication and computing efficiency.

Description

一种光场图像的多层级并行渲染方法和系统A multi-level parallel rendering method and system for light field images

技术领域Technical Field

本发明涉及一种光场图像的多层级并行渲染方法和系统,属于图像渲染技术领域。The invention relates to a multi-level parallel rendering method and system for a light field image, belonging to the technical field of image rendering.

背景技术Background Art

光场显示技术需要大数据量的光场图像作为显示素材。如何快速有效地生成高分辨率的动态光场图像信息,实现高质量的三维显示,仍是领域内的一个重要问题。在各种光场信息采集方法中,利用计算机生成光场图像信息的方法具有设备简单,参数调控灵活,可以记录虚拟物体的光场图像数据等优势。而且,这种方法可以有效兼容各种计算机图形技术,所以受到了越来越多的关注。Light field display technology requires a large amount of light field images as display materials. How to quickly and effectively generate high-resolution dynamic light field image information to achieve high-quality three-dimensional display is still an important issue in the field. Among various light field information acquisition methods, the method of using computers to generate light field image information has the advantages of simple equipment, flexible parameter control, and the ability to record light field image data of virtual objects. Moreover, this method can be effectively compatible with various computer graphics technologies, so it has received more and more attention.

计算机生成光场图像的技术可分为基于图像的渲染技术和基于模型的渲染技术。基于图像的渲染技术利用已知视点的图像数据通过重投影、插值、变形等方法生成新视点的光场图像。基于模型的渲染技术需要输入三维模型数据然后通过虚拟相机阵列和对应的图形渲染管线来生成新视点的图像。利用这种方法可以得到较高质量的光场图像。The technology of computer-generated light field images can be divided into image-based rendering technology and model-based rendering technology. Image-based rendering technology uses image data of known viewpoints to generate light field images of new viewpoints through reprojection, interpolation, deformation and other methods. Model-based rendering technology requires input of three-dimensional model data and then generates images of new viewpoints through a virtual camera array and a corresponding graphics rendering pipeline. This method can obtain higher quality light field images.

但传统的基于模型的计算机生成光场图像的技术通常需要利用针孔相机模型逐个渲染每一个相机所拍摄的图像。其过程如图1所示,程序首先读取三维模型数据,然后进入逐相机循环渲染步骤。每一次循环程序都需要根据相机参数对三维数据进行模型视图变换、透视投影变换、视口变换、光栅化计算。直到所有的相机渲染完成,这种渲染方法存在大量的冗余计算,效率低下。However, traditional model-based computer-generated light field image technology usually requires the use of a pinhole camera model to render each camera's image one by one. The process is shown in Figure 1. The program first reads the 3D model data and then enters the camera-by-camera loop rendering step. Each loop requires the 3D data to be transformed into a model view, perspective projection, viewport, and rasterized according to the camera parameters. This rendering method has a lot of redundant calculations and is inefficient until all cameras are rendered.

因此,目前的技术无论是基于图像还是基于模型的渲染技术,其渲染效率普遍不高,要实现大数据量、高品质光场图像的快速渲染还存在较大的挑战。Therefore, the current rendering technology, whether it is image-based or model-based, generally has low rendering efficiency, and there are still great challenges in achieving fast rendering of large amounts of data and high-quality light field images.

本背景技术中公开的信息仅用于理解本发明构思的背景,因此它可以包括不构成现有技术的信息。The information disclosed in this Background Art is only for understanding the background of the inventive concept and therefore it may include information that does not constitute the prior art.

发明内容Summary of the invention

针对上述问题或上述问题之一,本发明的目的一在于提供一种光场图像的多层级并行渲染方法,通过构建第一层级渲染模型、第二层级渲染模型、第三层级渲染模型,得到光场图像,能够实现三层级的并行渲染,从而可以有效减少冗余计算,提升渲染效率,因而可以实现大数据量、高品质光场图像的快速渲染。In view of the above problem or one of the above problems, an object of the present invention is to provide a multi-level parallel rendering method for a light field image, by constructing a first-level rendering model, a second-level rendering model, and a third-level rendering model to obtain a light field image, which can realize three-level parallel rendering, thereby effectively reducing redundant calculations and improving rendering efficiency, thereby realizing rapid rendering of large data volume and high-quality light field images.

针对上述问题或上述问题之一,本发明的目的二在于提供一种光场图像的多层级并行渲染方法和系统,可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率;并且可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。In view of the above problem or one of the above problems, the second object of the present invention is to provide a multi-level parallel rendering method and system for light field images, which can effectively overcome the rendering bottleneck of high-dimensional data and graphics encountered in the traditional method in the parallel rendering problem of high-dimensional parallax images, and greatly improve the rendering efficiency; and can give full play to the parallel computing capability of the GPU, and greatly reduce the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving the communication and computing efficiency.

针对上述问题或上述问题之一,本发明的目的三在于提供一种光场图像的多层级并行渲染方法和系统,可以快速计算具有复杂光照、阴影和纹理等效果的光场图像,大幅提升光场图像的真实感。In response to the above problem or one of the above problems, the third object of the present invention is to provide a multi-level parallel rendering method and system for light field images, which can quickly calculate light field images with complex lighting, shadows, textures and other effects, and greatly improve the realism of light field images.

为实现上述目的之一,本发明的第一种技术方案为:To achieve one of the above purposes, the first technical solution of the present invention is:

一种光场图像的多层级并行渲染方法,包括以下内容:A multi-level parallel rendering method for light field images, comprising the following contents:

获取光场图像的三维模型数据和相机阵列参数;Obtaining three-dimensional model data and camera array parameters of light field images;

利用预先构建的第一层级渲染模型,根据相机阵列参数,复制三维模型数据,并根据每一行或者每一列的相机参数对三维模型数据进行变换,得到变换后的三维模型数据,实现第一层级的并行渲染;Using the pre-built first-level rendering model, according to the camera array parameters, the 3D model data is copied, and the 3D model data is transformed according to the camera parameters of each row or each column to obtain the transformed 3D model data, thereby realizing the first-level parallel rendering;

通过预先构建的第二层级渲染模型,基于透视相关性,利用变换后的三维模型数据对多个视点位置处的视图进行并行渲染,得到极平面图像,实现第二层级的并行渲染;Through the pre-built second-level rendering model, based on perspective correlation, the transformed three-dimensional model data is used to render the views at multiple viewpoints in parallel to obtain the polar plane image, thereby realizing the second-level parallel rendering;

采用预先构建的第三层级渲染模型,基于并行像素重映射将极平面图像进行数据处理层面的并行计算,得到光场图像,实现第三层级的并行渲染,以完成光场图像的多层级并行渲染。Using a pre-built third-level rendering model, the polar plane image is parallelly calculated at the data processing level based on parallel pixel remapping to obtain a light field image, thereby realizing third-level parallel rendering and completing multi-level parallel rendering of the light field image.

本发明经过不断探索以及试验,通过构建第一层级渲染模型、第二层级渲染模型、第三层级渲染模型,得到光场图像,能够实现三层级的并行渲染,从而可以有效减少冗余计算,提升渲染效率,因而可以实现大数据量、高品质光场图像的快速渲染。After continuous exploration and experiments, the present invention obtains light field images by constructing a first-level rendering model, a second-level rendering model, and a third-level rendering model, and can realize three-level parallel rendering, thereby effectively reducing redundant calculations and improving rendering efficiency, thereby realizing rapid rendering of large data volumes and high-quality light field images.

进一步,本发明利用多层级的并行渲染方法可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。同时,本发明利用多层级的并行渲染方法可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。Furthermore, the present invention utilizes a multi-level parallel rendering method to effectively overcome the high-dimensional data and graphics rendering bottlenecks encountered by traditional methods in the high-dimensional parallax image parallel rendering problem, thereby greatly improving the rendering efficiency. At the same time, the present invention utilizes a multi-level parallel rendering method to fully utilize the parallel computing capabilities of the GPU, greatly reducing the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving the communication and computing efficiency.

作为优选技术措施:As the preferred technical measures:

获取三维模型数据和相机阵列参数的方法如下:The method to obtain 3D model data and camera array parameters is as follows:

利用预先构建的渲染管线模型,读取储存在硬盘或者内存中的三维模型数据,所述三维模型数据包括模型顶点的位置坐标或/和索引坐标或/和纹理坐标或/和法向量;Using a pre-built rendering pipeline model, read the three-dimensional model data stored in a hard disk or a memory, wherein the three-dimensional model data includes position coordinates and/or index coordinates and/or texture coordinates and/or normal vectors of model vertices;

利用渲染管线模型,根据光场采集需求设定相机阵列的视点参数;Using the rendering pipeline model, the viewpoint parameters of the camera array are set according to the light field acquisition requirements;

视点参数包括视点数量或/和视点间隔或/和视点排列或/和单视点分辨率或/和相机行列信息或/和零视差平面;并根据视点参数计算每一行左右两端相机或者每一列上下两端相机的模型、视图参数以及投影矩阵,得到相机阵列参数。The viewpoint parameters include the number of viewpoints and/or the viewpoint interval and/or the viewpoint arrangement and/or the single viewpoint resolution and/or the camera row and column information and/or the zero parallax plane; and the models, view parameters and projection matrices of the cameras at the left and right ends of each row or the cameras at the top and bottom ends of each column are calculated according to the viewpoint parameters to obtain the camera array parameters.

作为优选技术措施:As the preferred technical measures:

利用第一层级渲染模型实现第一层级的并行渲染的方法如下:The method of implementing the first-level parallel rendering using the first-level rendering model is as follows:

步骤11,获取三维模型数据,其包括模型顶点的位置坐标或/和索引坐标或/和纹理坐标或/和法向量;Step 11, obtaining three-dimensional model data, which includes position coordinates and/or index coordinates and/or texture coordinates and/or normal vectors of model vertices;

步骤12,利用预先构建的顶点着色器对三维模型数据进行处理,得到三角形图元数据;Step 12, using a pre-built vertex shader to process the three-dimensional model data to obtain triangle primitive data;

步骤13,根据三角形图元数据以及相机阵列参数,利用预先构建的实例化模型为每一行或者每一列相机复制一组三角形图元数据;Step 13, according to the triangle primitive data and the camera array parameters, using the pre-built instantiation model to copy a set of triangle primitive data for each row or column of cameras;

步骤14,基于不同行或者列的相机对应不同的垂直或者水平视差,并根据每一行相机中的最左、最右端相机或者每一列相机中的最上、最下端的变换矩阵对三角形图元数据执行变换,将三角形图元数据转换到屏幕坐标系下,得到变换后的三维模型数据,多个行或者多个列对应的三维模型数据被并行送入第二层级的渲染,实现第一层级的并行渲染。Step 14, based on the different vertical or horizontal parallaxes corresponding to cameras in different rows or columns, and according to the transformation matrices of the leftmost and rightmost cameras in each row of cameras or the topmost and bottommost cameras in each column of cameras, the triangle primitive data are transformed into the screen coordinate system to obtain the transformed three-dimensional model data, and the three-dimensional model data corresponding to multiple rows or multiple columns are sent to the second-level rendering in parallel to realize the parallel rendering of the first level.

作为优选技术措施:As the preferred technical measures:

通过第二层级渲染模型实现第二层级的并行渲染的方法如下:The method of implementing the second-level parallel rendering through the second-level rendering model is as follows:

步骤21,对三维模型数据进行并行三角形顶点排序处理、并行前缀和计算处理以及并行三角形切片处理,得到三角形切片;步骤22,基于相关性,利用预先构建的并行处理单元将三角形切片转换为多边形图元,在极平面坐标系下并行渲染每一个三角形切片在同一行或/和列相机中所有视点位置处的视图,得到三角形切片的多边形图元;所述相关性包括几何相关性、透视相关性、纹理相关性和光照相关性;Step 21, performing parallel triangle vertex sorting processing, parallel prefix sum calculation processing and parallel triangle slicing processing on the three-dimensional model data to obtain triangle slices; Step 22, based on the correlation, using a pre-built parallel processing unit to convert the triangle slices into polygonal primitives, and rendering each triangle slice in parallel at all viewpoint positions in the same row or/and column camera in a polar plane coordinate system to obtain polygonal primitives of the triangle slices; the correlation includes geometric correlation, perspective correlation, texture correlation and illumination correlation;

步骤23,通过预先构建的并行多边形光栅化单元,将三角形切片的多边形图元在同一行或/和列相机中所有视点位置处的视图进行光栅化,得到同一行或者同一列相机的极平面图像;Step 23, rasterizing the views of the polygonal primitives of the triangle slice at all viewpoint positions in the same row or/and column of cameras through a pre-built parallel polygon rasterization unit to obtain an extreme plane image of the same row or column of cameras;

或/和,采用第三层级渲染模型实现第三层级的并行渲染的方法如下:Alternatively or alternatively, the method for implementing the third-level parallel rendering using the third-level rendering model is as follows:

步骤31,获取极平面图像;Step 31, obtaining an extreme plane image;

步骤32,根据光照和纹理的相关性,利用预先构建的片段着色器对极平面图像进行着色,得到着色图像;Step 32, according to the correlation between illumination and texture, the polar plane image is shaded using a pre-built fragment shader to obtain a shaded image;

步骤33,根据着色图像,输出极平面图像的像素数据;Step 33, outputting pixel data of the polar plane image according to the colored image;

步骤34,对像素数据进行并行像素重组形成最终的光场图像。Step 34 , performing parallel pixel reorganization on the pixel data to form a final light field image.

作为优选技术措施:As the preferred technical measures:

并行三角形切片处理的方法,包括以下内容:The method of parallel triangle slicing processing includes the following:

步骤221,获取三维模型数据中的三角形以及其三个顶点坐标,三角形的三个顶点分别是v1(x0,y0)、v2(x1,y1)、v3(x2,y2);Step 221, obtaining a triangle and its three vertex coordinates in the three-dimensional model data, wherein the three vertices of the triangle are v 1 (x 0 , y 0 ), v 2 (x 1 , y 1 ), and v 3 (x 2 , y 2 );

步骤222,沿着屏幕扫描线的方向对三角形进行切片,三角形与每条屏幕扫描线相交都会得到一个切片的两个交点va、vbStep 222, slicing the triangle along the direction of the screen scan line, where the triangle intersects with each screen scan line to obtain two intersection points va and vb of a slice;

步骤223,屏幕扫描线与三角形的两个交点va、vb的坐标va(xa,ya)、vb(xb,yb)通过已知的三个顶点坐标之间的线性插值计算获得,相应的x方向的坐标如下:Step 223, the coordinates va ( xa , ya ) and vb ( xb , yb ) of the two intersection points va and vb of the screen scan line and the triangle are obtained by linear interpolation between the three known vertex coordinates. The corresponding x-direction coordinates are as follows:

xb=(1-b)*x0+b*x2 y0≤y≤y2 x b =(1-b)*x 0 +b*x 2 y 0 ≤y≤y 2

其中a、b为插值参数,不同的扫描线有不同的插值参数:Among them, a and b are interpolation parameters, and different scan lines have different interpolation parameters:

b=(y-y0)/(y2-y0) y0≤y≤y2 b=(yy 0 )/(y 2 -y 0 ) y 0 ≤y≤y 2

步骤224,将交点的纹理坐标、法向量数据进行插值处理,得到切片的顶点数据,并存储下来供后续的数据处理;Step 224, interpolating the texture coordinates and normal vector data of the intersection point to obtain the vertex data of the slice, and storing it for subsequent data processing;

或/和,并行三角形切片处理的方法,包括两个层级的并行处理;第一层级利用不同的线程块Block并行处理不同的三角形的切片过程;第二层级利用线程块中的不同线程并行处理一个三角形中的切片计算,最终得到所有三角形的所有切片数据;Or/and, a method for parallel triangle slicing processing includes two levels of parallel processing; the first level uses different thread blocks to parallelly process the slicing process of different triangles; the second level uses different threads in the thread block to parallelly process the slicing calculation in a triangle, and finally obtains all the slicing data of all the triangles;

在执行并行扫描切片算法之前,三角形的三个顶点位置数据满足y0≤y1≤y2的条件;Before executing the parallel scanning and slicing algorithm, the position data of the three vertices of the triangle satisfy the condition y 0 ≤y 1 ≤y 2 ;

三角形顶点排序处理方法使用核函数的线程来并行地排列三角形的顶点数据,以满足y0≤y1≤y2的条件。The triangle vertex sorting processing method uses threads of a kernel function to arrange the vertex data of a triangle in parallel to satisfy the condition of y 0 ≤y 1 ≤y 2 .

作为优选技术措施:As the preferred technical measures:

并行前缀和计算处理的方法如下:The method for parallel prefix sum calculation processing is as follows:

获取每个三角形的切片数据;Get the slice data of each triangle;

使用前缀和算法计算切片数据的前缀和,得到存储切片数据所需的内存空间及每个切片在全局内存中的位置,以节约切片数据的存储空间;Use the prefix sum algorithm to calculate the prefix sum of the slice data, obtain the memory space required to store the slice data and the position of each slice in the global memory, so as to save the storage space of the slice data;

并行前缀和算法使用每一个线程来对每两个切片数量元素进行和运算,其包括以下内容:第一步,进行归约求和,求取切片数据的部分和;第二步,使用倒置树来分发部分和,得到切片数量的前缀和;The parallel prefix sum algorithm uses each thread to perform a sum operation on every two slice quantity elements, which includes the following: the first step is to perform a reduction sum to obtain the partial sum of the slice data; the second step is to use an inverted tree to distribute the partial sum to obtain the prefix sum of the slice quantity;

或,并行前缀和算法为多层级扫描结构的并行前缀和算法,其实现步骤如下:Alternatively, the parallel prefix sum algorithm is a parallel prefix sum algorithm with a multi-level scanning structure, and its implementation steps are as follows:

(1)首先对整个切片数量数据划分为多个数据块,并进行并行扫描处理,扫描后的结果数组中仅保留了各自块内扫描的结果;(1) First, the entire slice quantity data is divided into multiple data blocks and scanned in parallel. After scanning, only the results of scanning in each block are retained in the result array;

(2)将每个数据块最后一个数保留到长度为m的辅助数组S中,对辅助数组S进行扫描;(2) The last number of each data block is saved in an auxiliary array S of length m, and the auxiliary array S is scanned;

(3)将辅助数组S的前m-1个元素分别加到结果数组的后m-1个扫描块的每个元素中。这种算法进一步减少了数据处理在渲染流程中的时间占比,从而提高了处理的整体效率。(3) The first m-1 elements of the auxiliary array S are added to each element of the last m-1 scan blocks of the result array. This algorithm further reduces the time proportion of data processing in the rendering process, thereby improving the overall processing efficiency.

作为优选技术措施:As the preferred technical measures:

用于将三角形切片转换为多边形图元的并行处理单元,包括以下内容:Parallel processing units for converting triangle slices into polygon primitives, including the following:

获取一个三角形切片在某一行相机的最左和最右视点位置处拍摄得到的视图;Get the view of a triangle slice taken at the leftmost and rightmost viewpoints of a row of cameras;

对于一个三角形切片v0v1,在左端视点的视图上记录的是线段SL,右端视点的视图上记录的是线段SRFor a triangle slice v 0 v 1 , the line segment S L is recorded in the view of the left viewpoint, and the line segment S R is recorded in the view of the right viewpoint;

根据相关性,扫描线在这一行相机上所成的所有像在EPI坐标系里能表示为由两条不同斜率和两条平行线构成的一个四边形vL0 vL1 vR1 vR0;其中两条平行的边缘线段分别是线段SL和线段SR;两条直线段的斜率分别由物点v0和v1的深度和相机的焦距确定,两条直线段的两个端点由左右两个端点相机记录的该点的图像的坐标确定;这个四边形即为一个三角形切片的多边形图元;每一个三角形切片由相应的线程块来并行生成多个三角形切片的多边形图元;According to the correlation, all the images formed by the scan lines on this row of cameras can be expressed in the EPI coordinate system as a quadrilateral v L0 v L1 v R1 v R0 consisting of two different slopes and two parallel lines; the two parallel edge segments are line segment SL and line segment SR ; the slopes of the two straight line segments are determined by the depth of the object point v0 and v1 and the focal length of the camera, respectively, and the two endpoints of the two straight line segments are determined by the coordinates of the images of the points recorded by the left and right endpoint cameras; this quadrilateral is a polygonal primitive of a triangular slice; each triangular slice is generated by the corresponding thread block in parallel to generate multiple polygonal primitives of triangular slices;

或/和,并行多边形光栅化单元利用渲染管线对切片的多边形图元进行光栅化操作,从而在EPI坐标系下实现扫描线v0 v1的一维多视点图像信息的并行渲染;or/and, the parallel polygon rasterization unit performs rasterization operation on the sliced polygon primitives using the rendering pipeline, thereby realizing parallel rendering of one-dimensional multi-viewpoint image information of scan lines v 0 v 1 in the EPI coordinate system;

或/和,还包括对切片的多边形图元进行光照处理,具体内容如下:Or/and, it also includes lighting processing for the sliced polygonal primitives, the specific contents are as follows:

基于预先构建的片段着色器,利用光照的相关性对切片的多边形图元的光照效果进行渲染;并采用Phone氏光照模型,实现各向同性和各向异性的光照效果;Based on the pre-built fragment shader, the lighting effects of the sliced polygon primitives are rendered using the correlation of lighting; and the Phone lighting model is used to achieve isotropic and anisotropic lighting effects;

以镜面光为例,多边形图元的四端点的镜面光照值为SL0、SL1、SR0、SR1,其由下面的公式得到:Taking specular light as an example, the specular light values of the four endpoints of the polygon primitive are S L0 , S L1 , S R0 , and S R1 , which are obtained by the following formula:

specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness)specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness)

其中specularResult指切片的多边形图元表面的镜面光照值,lightColor指光照的颜色,specularMaterial指切片的多边形图元表面的镜面材质,V指视点的观察向量,R指光照入射向量的反射向量,shiness则表示高光反光度,pow()函数用于计算一个数的幂次方,它的基本语法是pow(base,exponent),其中base表示底数,exponent表示指数;Where specularResult refers to the specular lighting value of the sliced polygonal primitive surface, lightColor refers to the color of the lighting, specularMaterial refers to the specular material of the sliced polygonal primitive surface, V refers to the view vector of the viewpoint, R refers to the reflection vector of the incident light vector, and shines refers to the specular reflectivity. The pow() function is used to calculate the power of a number. Its basic syntax is pow(base, exponent), where base refers to the base and exponent refers to the exponent.

最后通过片段着色器的重心坐标插值得到多边形图元的镜面光照的结果。Finally, the result of the specular lighting of the polygonal primitive is obtained by interpolating the barycentric coordinates of the fragment shader.

为实现上述目的之一,本发明的第二种技术方案为:To achieve one of the above purposes, the second technical solution of the present invention is:

一种光场图像的多层级并行渲染系统,设有渲染管线和渲染硬件;A multi-level parallel rendering system for light field images, comprising a rendering pipeline and rendering hardware;

所述渲染管线,用于实现多层级并行渲染,其包括应用程序、应用程序接口、通用并行计算架构和操作系统;The rendering pipeline is used to implement multi-level parallel rendering, which includes an application program, an application program interface, a general parallel computing architecture and an operating system;

所述渲染硬件,用于提供运行渲染管线所需的硬件资源,其包括内存、CPU、GPU和显存;The rendering hardware is used to provide the hardware resources required to run the rendering pipeline, including memory, CPU, GPU and video memory;

所述操作系统用于控制应用程序,调用应用程序接口和通用并行计算构架;The operating system is used to control applications, call application program interfaces and general parallel computing frameworks;

所述应用程序、应用程序接口和通用并行计算构架驱动CPU、GPU、内存和显存,执行时实现如上述的一种光场图像的多层级并行渲染方法,完成从三维模型数据到光场图像的多层级并行渲染。The application, application program interface and general parallel computing architecture drive the CPU, GPU, memory and video memory, and when executed, implement the multi-level parallel rendering method of a light field image as described above, completing the multi-level parallel rendering from three-dimensional model data to light field images.

本发明通过设置渲染管线和渲染硬件,可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。同时,本发明可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。进而本发明可以快速计算具有复杂光照、阴影和纹理等效果的光场图像,大幅提升光场图像的真实感。By setting up a rendering pipeline and rendering hardware, the present invention can effectively overcome the rendering bottleneck of high-dimensional data and graphics encountered by traditional methods in the problem of parallel rendering of high-dimensional parallax images, and greatly improve the rendering efficiency. At the same time, the present invention can give full play to the parallel computing capability of the GPU, greatly reduce the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving the communication and computing efficiency. Furthermore, the present invention can quickly calculate light field images with complex lighting, shadows, textures and other effects, and greatly improve the realism of the light field images.

为实现上述目的之一,本发明的第三种技术方案为:To achieve one of the above purposes, the third technical solution of the present invention is:

一种光场图像的多层级并行渲染方法,采用上述的一种光场图像的多层级并行渲染系统,其包括以下步骤:A multi-level parallel rendering method for light field images, using the above-mentioned multi-level parallel rendering system for light field images, comprises the following steps:

第一步,设置世界坐标XYZ,其中相机阵列位于XY平面;三维模型位于相机阵列前;当所有相机完成对三维模型的拍摄后,光场图像被记录下来;The first step is to set the world coordinates XYZ, where the camera array is located in the XY plane; the 3D model is located in front of the camera array; when all cameras complete shooting the 3D model, the light field image is recorded;

第二步,所述渲染管线通过CPU从内存中读取三维模型数据传入GPU端的顶点着色器;In the second step, the rendering pipeline reads the 3D model data from the memory through the CPU and transmits it to the vertex shader on the GPU side;

第三步,利用顶点着色器将三维模型数据中的顶点数据组装成三角形图元并传入几何着色器;同时从CPU端设定相机阵列的参数,并传入GPU端的几何着色器;The third step is to use the vertex shader to assemble the vertex data in the 3D model data into triangle primitives and pass them into the geometry shader. At the same time, the parameters of the camera array are set from the CPU side and passed into the geometry shader on the GPU side.

第四步,利用实例化功能为每一列或者每一行相机复制一组三角形图元;The fourth step is to use the instantiation function to copy a set of triangle primitives for each column or row of cameras;

第五步,根据每一列相机中的最上端和最下端相机或者每一行最左端和最右端相机的变换矩阵对三角形图元执行变换,得到变换后的三维模型数据;Step 5: transform the triangle primitives according to the transformation matrices of the top and bottom cameras in each column or the left and right cameras in each row to obtain transformed three-dimensional model data;

第六步,利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作把变换后的图元数据映射到通用并行计算构架CUDA空间;Step 6: Map the transformed image metadata to the CUDA space using the interoperability between the CUDA and OpenGL.

第七步,在通用并行计算构架CUDA空间中进行顶点并行排序计算、并行前缀和计算和并行三角形切片计算,得到三角形切片数据;Step 7: Perform vertex parallel sorting calculation, parallel prefix sum calculation and parallel triangle slicing calculation in the general parallel computing framework CUDA space to obtain triangle slicing data;

第八步,利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作将三角形切片数据映射到顶点着色器上;利用顶点着色器和相关性将三角形切片数据中的顶点数据组装成切片的多边形图元;Step 8: Map the triangle slice data to the vertex shader by using the interoperation between the general parallel computing framework CUDA and the application program interface OpenGL; assemble the vertex data in the triangle slice data into the polygon primitives of the slice by using the vertex shader and correlation;

第九步,将切片的多边形图元光栅化并在片段着色器中根据光照和纹理的相关性进行着色,得到极平面图像;In the ninth step, the sliced polygonal primitives are rasterized and colored in the fragment shader according to the correlation of lighting and texture to obtain a polar plane image;

第十步,根据极平面图像的像素数据,并通过并行像素重映射获得光场图像。In the tenth step, a light field image is obtained based on the pixel data of the polar plane image through parallel pixel remapping.

本发明利用多层级的并行渲染方法可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。同时,本发明利用多层级的并行渲染方法可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。进而本发明利用多层级的并行渲染方法可以快速计算具有复杂光照、阴影和纹理等效果的光场图像,大幅提升光场图像的真实感。The present invention utilizes a multi-level parallel rendering method to effectively overcome the high-dimensional data and graphics rendering bottlenecks encountered by traditional methods in the parallel rendering of high-dimensional parallax images, thereby greatly improving rendering efficiency. At the same time, the present invention utilizes a multi-level parallel rendering method to fully utilize the parallel computing capabilities of the GPU, greatly reducing the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving communication and computing efficiency. Furthermore, the present invention utilizes a multi-level parallel rendering method to quickly calculate light field images with complex lighting, shadows, textures and other effects, greatly improving the realism of the light field images.

为实现上述目的之一,本发明的第四种技术方案为:To achieve one of the above purposes, the fourth technical solution of the present invention is:

一种光场图像的多层级并行渲染方法,包括以下步骤:A multi-level parallel rendering method for light field images comprises the following steps:

利用预先构建的第一层级渲染模型,对不同维度的视差图像进行并行渲染;Using the pre-built first-level rendering model, parallax images of different dimensions are rendered in parallel;

通过预先构建的第二层级渲染模型,对同一维度的不同视点图像进行并行渲染;Through the pre-built second-level rendering model, different viewpoint images of the same dimension are rendered in parallel;

采用预先构建的第三层级渲染模型,进行数据处理层面的并行计算。A pre-built third-level rendering model is used to perform parallel computing at the data processing level.

为实现上述目的之一,本发明的第五种技术方案为:To achieve one of the above purposes, the fifth technical solution of the present invention is:

一种电子设备,其包括:An electronic device comprising:

一个或多个处理器;one or more processors;

存储装置,用于存储一个或多个程序;A storage device for storing one or more programs;

当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现上述的一种光场图像的多层级并行渲染方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned multi-level parallel rendering method of light field images.

为实现上述目的之一,本发明的第六种技术方案为:To achieve one of the above purposes, the sixth technical solution of the present invention is:

一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述的一种光场图像的多层级并行渲染方法。A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned multi-level parallel rendering method for light field images.

与现有技术方案相比,本发明具有以下有益效果:Compared with the prior art solutions, the present invention has the following beneficial effects:

本发明经过不断探索以及试验,通过构建第一层级渲染模型、第二层级渲染模型、第三层级渲染模型,得到光场图像,能够实现三层级的并行渲染,从而可以有效减少冗余计算,提升渲染效率,因而可以实现大数据量、高品质光场图像的快速渲染。After continuous exploration and experiments, the present invention obtains light field images by constructing a first-level rendering model, a second-level rendering model, and a third-level rendering model, and can realize three-level parallel rendering, thereby effectively reducing redundant calculations and improving rendering efficiency, thereby realizing rapid rendering of large data volumes and high-quality light field images.

进一步,本发明利用多层级的并行渲染方法可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。同时,本发明利用多层级的并行渲染方法可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。Furthermore, the present invention utilizes a multi-level parallel rendering method to effectively overcome the high-dimensional data and graphics rendering bottlenecks encountered by traditional methods in the high-dimensional parallax image parallel rendering problem, thereby greatly improving the rendering efficiency. At the same time, the present invention utilizes a multi-level parallel rendering method to fully utilize the parallel computing capabilities of the GPU, greatly reducing the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving the communication and computing efficiency.

更进一步,本发明利用多层级的并行渲染方法可以快速计算具有复杂光照、阴影和纹理等效果的光场图像,大幅提升光场图像的真实感。Furthermore, the present invention utilizes a multi-level parallel rendering method to quickly calculate light field images with complex lighting, shadow, texture and other effects, thereby greatly improving the realism of the light field images.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为单视角循环渲染方法的流程图;FIG1 is a flow chart of a single-view cyclic rendering method;

图2为本发明多层级并行渲染方法的一种流程图;FIG2 is a flow chart of a multi-level parallel rendering method according to the present invention;

图3为本发明光场图像采集系统的一种示意图FIG. 3 is a schematic diagram of a light field image acquisition system of the present invention.

图4为本发明渲染管线的一种处理流程图;FIG4 is a processing flow chart of the rendering pipeline of the present invention;

图5为本发明多层级并行渲染系统的一种结构示图;FIG5 is a structural diagram of a multi-level parallel rendering system of the present invention;

图6为本发明并行三角形切片算法和相关的顶点排序算法的一种流程图;FIG6 is a flow chart of the parallel triangle slicing algorithm and the related vertex sorting algorithm of the present invention;

图7为本发明并行前缀和算法的一种流程图;FIG7 is a flow chart of a parallel prefix sum algorithm of the present invention;

图8为本发明切片多边形图元生成算法的一种流程图。FIG8 is a flow chart of the slice polygon primitive generation algorithm of the present invention.

具体实施方式DETAILED DESCRIPTION

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

相反,本发明涵盖任何由权利要求定义的在本发明的精髓和范围上做的替代、修改、等效方法以及方案。进一步,为了使公众对本发明有更好的了解,在下文对本发明的细节描述中,详尽描述了一些特定的细节部分。对本领域技术人员来说没有这些细节部分的描述也可以完全理解本发明。On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims. Further, in order to make the public have a better understanding of the present invention, some specific details are described in detail in the detailed description of the present invention below. Those skilled in the art can fully understand the present invention without the description of these details.

除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文所使用的术语只是为了描述具体的实施例的目的,不是旨在限制本发明。本文所使用的术语“或/和”包括一个或多个相关的所列项目的任意的和所有的组合。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention pertains. The terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "or/and" as used herein includes any and all combinations of one or more of the associated listed items.

本发明光场图像的多层级并行渲染方法的第一种具体实施例:A first specific embodiment of the multi-level parallel rendering method of light field images of the present invention:

一种光场图像的多层级并行渲染方法,包括以下内容:A multi-level parallel rendering method for light field images, comprising the following contents:

获取光场图像的三维模型数据和相机阵列参数;Obtaining three-dimensional model data and camera array parameters of light field images;

利用预先构建的第一层级渲染模型,根据相机阵列参数,复制三维模型数据,并根据每一行或者每一列的相机参数对三维模型数据进行变换,得到变换后的三维模型数据,实现第一层级的并行渲染;Using the pre-built first-level rendering model, according to the camera array parameters, the 3D model data is copied, and the 3D model data is transformed according to the camera parameters of each row or each column to obtain the transformed 3D model data, thereby realizing the first-level parallel rendering;

通过预先构建的第二层级渲染模型,基于透视相关性,利用变换后的三维模型数据对多个视点位置处的视图进行并行渲染,得到极平面图像,实现第二层级的并行渲染;Through the pre-built second-level rendering model, based on perspective correlation, the transformed three-dimensional model data is used to render the views at multiple viewpoints in parallel to obtain the polar plane image, thereby realizing the second-level parallel rendering;

采用预先构建的第三层级渲染模型,基于并行像素重映射将极平面图像进行数据处理层面的并行计算,得到光场图像,实现第三层级的并行渲染,以完成光场图像的多层级并行渲染。Using a pre-built third-level rendering model, the polar plane image is parallelly calculated at the data processing level based on parallel pixel remapping to obtain a light field image, thereby realizing third-level parallel rendering and completing multi-level parallel rendering of the light field image.

本发明光场图像的多层级并行渲染方法的第二种具体实施例:A second specific embodiment of the multi-level parallel rendering method of light field images of the present invention:

一种光场图像的多层级并行渲染方法,包括如下层级的并行渲染过程:A multi-level parallel rendering method for light field images includes the following levels of parallel rendering process:

第一层级:不同维度视差图像的并行渲染;First level: parallel rendering of parallax images of different dimensions;

第二层级:同一维度不同视点图像的并行渲染;Second level: parallel rendering of images from different viewpoints in the same dimension;

第三层级:数据处理层面的并行计算。The third level: parallel computing at the data processing level.

所述第一层级的并行渲染包括水平视差和垂直视差两个维度的并行渲染。所述第二层级的并行渲染包括水平视差维度不同视点图像的并行渲染或者垂直视差维度不同视点图像的并行渲染。所述第三层级的并行渲染包括三维模型数据的并行处理和像素数据的并行处理。The first level of parallel rendering includes parallel rendering in two dimensions: horizontal parallax and vertical parallax. The second level of parallel rendering includes parallel rendering of different viewpoint images in the horizontal parallax dimension or parallel rendering of different viewpoint images in the vertical parallax dimension. The third level of parallel rendering includes parallel processing of 3D model data and parallel processing of pixel data.

所述第一层级的并行渲染包括对模型的逐行或者逐列进行的实例化操作;对不同行或者不同列的实例化数据的并行渲染。The first level of parallel rendering includes instantiation operations performed row by row or column by column on the model; and parallel rendering of instantiation data of different rows or columns.

所述实例化操作包括结合一行相机的垂直视差或者一列相机的水平视差对应的观察矩阵和投影矩阵进行的实例化操作。The instantiation operation includes an instantiation operation performed by combining an observation matrix and a projection matrix corresponding to the vertical parallax of a row of cameras or the horizontal parallax of a column of cameras.

所述第二层级的并行渲染包括利用三维模型的相关性实现同一维度的包括视差信息、光照信息和纹理信息的多视点并行渲染。The second level of parallel rendering includes utilizing the correlation of the three-dimensional model to implement multi-viewpoint parallel rendering including disparity information, illumination information and texture information in the same dimension.

所述相关性包括几何、视差、光照和纹理等信息的透视投影相关性或者正交投影相关性。The correlation includes perspective projection correlation or orthogonal projection correlation of information such as geometry, parallax, illumination and texture.

所述第三层级的模型数据的并行处理包括并行三角形顶点排序计算、并行前缀和计算、并行三角形扫描切片计算、光栅化等。The parallel processing of the model data of the third level includes parallel triangle vertex sorting calculation, parallel prefix sum calculation, parallel triangle scan slicing calculation, rasterization, etc.

所述第三层级的像素数据的并行处理包括并行的像素重映射。所述并行的像素重映射完成极平面图像(EPI)到光场图像的转换。The parallel processing of the pixel data at the third level includes parallel pixel remapping. The parallel pixel remapping completes the conversion of the epipolar plane image (EPI) to the light field image.

因此,本发明可以实现大数据量、高品质光场图像的快速渲染,本发明利用多层级的并行渲染方法可以有效克服传统方法在高维视差图像并行渲染问题上遇到的高维数据和图型的渲染瓶颈,大幅提升了渲染效率。进一步,本发明利用多层级的并行渲染方法可以充分发挥GPU的并行运算能力,大幅减少传统光场渲染方法中所需的CPU与GPU之间的通讯,从而提升了通讯与计算效率。同时本发明利用多层级的并行渲染方法可以快速计算具有复杂光照、阴影和纹理等效果的光场图像,大幅提升光场图像的真实感。Therefore, the present invention can achieve fast rendering of large data volumes and high-quality light field images. The present invention uses a multi-level parallel rendering method to effectively overcome the rendering bottleneck of high-dimensional data and graphics encountered by traditional methods in the problem of parallel rendering of high-dimensional parallax images, thereby greatly improving the rendering efficiency. Furthermore, the present invention uses a multi-level parallel rendering method to give full play to the parallel computing capabilities of the GPU, greatly reducing the communication between the CPU and the GPU required in the traditional light field rendering method, thereby improving the communication and computing efficiency. At the same time, the present invention uses a multi-level parallel rendering method to quickly calculate light field images with complex lighting, shadows, textures and other effects, greatly improving the realism of the light field images.

如图2所示,本发明光场图像的多层级并行渲染方法的第三种具体实施例:As shown in FIG. 2 , a third specific embodiment of the multi-level parallel rendering method of a light field image of the present invention is as follows:

一种光场图像的多层级并行渲染方法,包括文件读取、三个层级的并行渲染和光场图像的输出。A multi-level parallel rendering method for light field images includes file reading, three-level parallel rendering and light field image output.

所述方法首先读取三维模型数据,然后设定相机阵列的参数,其中包括n行m列个相机。The method first reads the three-dimensional model data, and then sets the parameters of the camera array, which includes n rows and m columns of cameras.

再利用实例化技术分别为每一行相机复制一组模型数据,Then use the instantiation technology to copy a set of model data for each row of cameras.

接着利用与每一行左右两端的相机对应的参数对3D模型做变换,将3D模型转换到屏幕坐标系下。Then, the 3D model is transformed using the parameters corresponding to the cameras at the left and right ends of each row, and the 3D model is converted to the screen coordinate system.

其中不同行的相机对应不同的垂直视差。程序将变换后的数据分别输入并行的水平视差处理管道,实现第一层级的并行渲染。Cameras in different rows correspond to different vertical parallaxes. The program inputs the transformed data into parallel horizontal parallax processing pipelines to achieve the first level of parallel rendering.

所述水平视差处理管道利用几何、视差、纹理、光照等信息的透视相关性,并行渲染模型在同一行相机中所有视点位置处的视图。从而实现第二层级的并行渲染。The horizontal disparity processing pipeline uses the perspective correlation of geometry, disparity, texture, lighting and other information to render the views of the model at all viewpoints in the same row of cameras in parallel, thereby achieving the second level of parallel rendering.

所述的第二层级中对模型的并行渲染是通过对模型中每一个三角形的并行处理实现的,所述模型中包括k个三角形。包括并行的三角形顶点排序,并行前缀和计算,并行三角形切片,并行切片多边形图元生成,并行多边形光栅化等操作。所述并行切片多边形图元生成过程将在极平面坐标系下并行渲染每一个三角形切片在同一行相机中所有视点位置处的视图。所述并行多边形光栅化将所有切片在同一行相机中所有视点位置处的视图进行光栅化。The parallel rendering of the model in the second level is achieved by parallel processing of each triangle in the model, wherein the model includes k triangles. The operations include parallel triangle vertex sorting, parallel prefix sum calculation, parallel triangle slicing, parallel slice polygon primitive generation, parallel polygon rasterization, etc. The parallel slicing polygon primitive generation process will render the views of each triangle slice at all viewpoints in the same row of cameras in parallel in the polar plane coordinate system. The parallel polygon rasterization will rasterize the views of all slices at all viewpoints in the same row of cameras.

最后将所述光栅化的像素数据进行并行像素重组形成最终的光场图像。Finally, the rasterized pixel data is subjected to parallel pixel reorganization to form a final light field image.

上述并行的数据处理构成第三层级的并行渲染,包括模型数据的并行处理和像素数据的并行处理。The above-mentioned parallel data processing constitutes the third level of parallel rendering, including parallel processing of model data and parallel processing of pixel data.

本发明光场图像的多层级并行渲染系统的第一种具体实施例:The first specific embodiment of the multi-level parallel rendering system of the light field image of the present invention:

一种光场图像的多层级并行渲染系统,包括渲染管线和渲染硬件。A multi-level parallel rendering system for light field images includes a rendering pipeline and rendering hardware.

所述渲染管线包括如下流程:The rendering pipeline includes the following processes:

1、读取三维模型数据,并组装图元。1. Read 3D model data and assemble graphics elements.

2、设定相机阵列的参数。2. Set the parameters of the camera array.

3、根据相机参数为每一行或者每列相机实例化三维模型数据。3. Instantiate 3D model data for each row or column of cameras according to camera parameters.

4、利用实例化模型数据并行渲染不同行或者不同列相机的光场图像。4. Use the instantiated model data to render light field images of cameras in different rows or columns in parallel.

5、利用相关性并行渲染模型的同一行或者同一列相机的极平面图像。5. Use correlation to render the polar plane images of the cameras in the same row or column of the model in parallel.

6、利用并行像素重映射将极平面图像转换为光场图像。6. Convert the epipolar plane image to a light field image using parallel pixel remapping.

所述渲染管线还包括执行上述流程所需的应用程序,应用程序接口,通用并行计算架构,操作系统等软件。The rendering pipeline also includes software such as applications, application programming interfaces, general parallel computing architectures, operating systems, etc. required to execute the above processes.

所述流程1中,渲染管线从硬盘或者内存中读取三维模型数据并传入顶点着色器。利用顶点着色器将顶点数据组装成三角形后传入几何着色器。所述三维模型数据包括模型顶点的位置坐标、索引坐标、纹理坐标、法向量等数据。In the process 1, the rendering pipeline reads the 3D model data from the hard disk or memory and passes it to the vertex shader. The vertex shader assembles the vertex data into triangles and then passes them to the geometry shader. The 3D model data includes the position coordinates, index coordinates, texture coordinates, normal vectors and other data of the model vertices.

所述流程2中,渲染管线根据光场采集需求设定相机阵列的视点数量,视点间隔,视点排列,单视点分辨率,零视差平面等参数,并根据这些参数计算每一行左右两端相机或者每一列上下两端相机的模型、观察、投影矩阵,并传入几何着色器。In the process 2, the rendering pipeline sets the number of viewpoints, viewpoint interval, viewpoint arrangement, single viewpoint resolution, zero parallax plane and other parameters of the camera array according to the light field acquisition requirements, and calculates the model, observation, and projection matrices of the cameras at the left and right ends of each row or the upper and lower ends of each column based on these parameters, and passes them into the geometry shader.

所述流程3中,利用实例化函数为每一行或者每一列相机复制一套三维模型数据,并利用流程2中的模型矩阵、观察矩阵、投影矩阵和视口矩阵对所述顶点进行变换。变换后的顶点数据供后续程序调用。In the process 3, a set of 3D model data is copied for each row or column of cameras using the instantiation function, and the vertices are transformed using the model matrix, observation matrix, projection matrix and viewport matrix in process 2. The transformed vertex data is used for subsequent program calls.

所述流程4将不同行或者不同列的变换后的实例化数据并行输入多个由流程5和流程6组成的子管线。The process 4 inputs the transformed instantiation data of different rows or columns into a plurality of sub-pipelines composed of the processes 5 and 6 in parallel.

所述流程5的操作对象包括实例化数据中的三角形数据,所述流程5利用相关性在极平面坐标系中并行渲染三角形在一行或一列相机中的所有视点的图像。The operation object of the process 5 includes the triangle data in the instantiation data, and the process 5 uses the correlation to render the images of the triangles in parallel at all viewpoints in a row or a column of cameras in the polar plane coordinate system.

所述流程5具体包括对三角形顶点的排序计算、并行前缀和计算、并行三角形扫描切片计算,三角形切片在极平面坐标系中的多边形图元生成和光栅化计算。The process 5 specifically includes sorting calculation of triangle vertices, parallel prefix sum calculation, parallel triangle scanning slice calculation, polygon primitive generation and rasterization calculation of triangle slices in the polar plane coordinate system.

所述流程5并行处理模型中的多个三角形数据。所述流程5并行处理一个三角形中的多个扫描切片数据。所述流程5在极平面坐标系中并行生成和光栅化多个多边形图元,最终形成所述三维模型的极平面图像。The process 5 processes multiple triangle data in the model in parallel. The process 5 processes multiple scan slice data in a triangle in parallel. The process 5 generates and rasterizes multiple polygonal primitives in parallel in the polar plane coordinate system, and finally forms a polar plane image of the three-dimensional model.

所述流程6并行处理多个极平面图像,所述流程并行处理一个极平面图像中的多个像素。The process 6 processes a plurality of polar plane images in parallel, and the process processes a plurality of pixels in one polar plane image in parallel.

所述渲染硬件包括运行上述渲染管线所需的硬盘、内存、CPU、GPU、显存等。The rendering hardware includes the hard disk, memory, CPU, GPU, video memory, etc. required to run the above rendering pipeline.

本发明光场图像的多层级并行渲染系统的第二种具体实施例:A second specific embodiment of the multi-level parallel rendering system of light field images of the present invention:

首先,如图3所示定义世界坐标XYZ,其中相机阵列位于XY平面。三维模型位于相机阵列前。当所有相机完成对三维模型的拍摄后,光场图像被记录下来。First, the world coordinates XYZ are defined as shown in Figure 3, where the camera array is located in the XY plane. The 3D model is located in front of the camera array. When all cameras complete shooting the 3D model, the light field image is recorded.

进而如图4所示,所述渲染管线通过CPU从硬盘中读取3D模型数据传入GPU端的顶点着色器,然后利用顶点着色器将顶点数据组装成三角形图元并传入几何着色器。接着从CPU端设定相机阵列的参数,并传入GPU端的几何着色器。As shown in Figure 4, the rendering pipeline reads 3D model data from the hard disk through the CPU and passes it to the vertex shader on the GPU side, and then uses the vertex shader to assemble the vertex data into triangle primitives and pass them to the geometry shader. Then, the parameters of the camera array are set from the CPU side and passed to the geometry shader on the GPU side.

利用实例化功能为每一列相机复制一组图元。Use instancing to replicate a set of primitives for each column of cameras.

然后根据每一列相机中的最上端和最下端相机的变换矩阵对图元数据执行变换。The metadata is then transformed according to the transformation matrices of the top and bottom cameras in each column of cameras.

接着,利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作把变换后的图元数据映射到CUDA空间。Then, the transformed image metadata is mapped to the CUDA space by using the interoperability between the general parallel computing framework CUDA and the application program interface OpenGL.

在CUDA空间中进行顶点并行排序计算、并行前缀和计算和并行三角形切片计算。Parallel vertex sorting calculations, parallel prefix sum calculations, and parallel triangle slicing calculations are performed in CUDA space.

再接着利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作将三角形切片数据映射到顶点着色器上。然后利用顶点着色器和相关性将切片顶点数据组装成切片多边形图元。Then, the triangle slice data is mapped to the vertex shader by using the interoperation between the general parallel computing framework CUDA and the application program interface OpenGL. Then, the slice vertex data is assembled into slice polygon primitives by using the vertex shader and correlation.

再将切片多边形图元光栅化并在片段着色器中根据光照和纹理的相关性进行着色。The tile polygon primitives are then rasterized and shaded in the fragment shader based on lighting and texture dependencies.

通过着色后输出极平面图像(EPI)像素数据。最后通过并行像素重映射获得。The pixel data of the output epipolar plane image (EPI) is obtained by shading and then parallel pixel remapping.

所述渲染管线还包括执行上述流程所需的应用程序,应用程序接口,通用并行计算架构,操作系统等软件。The rendering pipeline also includes software such as applications, application programming interfaces, general parallel computing architectures, operating systems, etc. required to execute the above processes.

本实施例中的渲染硬件包括由硬盘、CPU、内存、GPU、显存、显示器等硬件构成的计算机系统。The rendering hardware in this embodiment includes a computer system composed of hardware such as a hard disk, a CPU, a memory, a GPU, a video memory, and a display.

如图5所示,本实施例的渲染系统内嵌在计算机系统中,所述计算机系统包括操作系统,为所述渲染系统提供运行环境。所述渲染系统包括应用程序,所述应用程序调用所述的多层级并行渲染管线,所述渲染管线调用应用程序接口和通用并行计算构架。所述应用程序、应用程序接口和通用并行计算构架驱动CPU、GPU、内存和显存等计算硬件完成从3D模型数据到光场图像的渲染。As shown in FIG5 , the rendering system of this embodiment is embedded in a computer system, and the computer system includes an operating system to provide a running environment for the rendering system. The rendering system includes an application program, and the application program calls the multi-level parallel rendering pipeline, and the rendering pipeline calls an application program interface and a general parallel computing framework. The application program, the application program interface and the general parallel computing framework drive computing hardware such as a CPU, a GPU, a memory and a video memory to complete the rendering from 3D model data to a light field image.

如图6所示,本发明并行三角形切片算法和相关的顶点排序算法的一种具体实施例:As shown in FIG6 , a specific embodiment of the parallel triangle slicing algorithm and the related vertex sorting algorithm of the present invention is as follows:

本发明的并行三角形切片算法和相关的顶点排序算法,包括以下内容:The parallel triangle slicing algorithm and the related vertex sorting algorithm of the present invention include the following contents:

以如图6左侧的三角形为例,三角形的三个顶点分别是v1,v2,v3,为了渲染三角形,需要沿着屏幕扫描线的方向对其进行切片。已知三个顶点的坐标,扫描线与三角形的两个交点va、vb的坐标可以通过已知的三个顶点坐标之间的线性插值计算获得,以x方向为例,其坐标为:Take the triangle on the left side of Figure 6 as an example. The three vertices of the triangle are v 1 , v 2 , and v 3 . In order to render the triangle, it needs to be sliced along the direction of the screen scan line. Given the coordinates of the three vertices, the coordinates of the two intersection points of the scan line and the triangle, v a and v b , can be obtained by linear interpolation between the known coordinates of the three vertices. Taking the x direction as an example, its coordinates are:

xb=(1-b)*x0+b*x2 y0≤y≤y2 x b =(1-b)*x 0 +b*x 2 y 0 ≤y≤y 2

其中a、b为插值参数,不同的扫描线有不同的插值参数:Among them, a and b are interpolation parameters, and different scan lines have different interpolation parameters:

b=(y-y0)/(y2-y0) y0≤y≤y2 b=(yy 0 )/(y 2 -y 0 ) y 0 ≤y≤y 2

三角形与每条扫描线相交都会得到一个切片的两个顶点坐标va、vb。同样,将顶点的纹理坐标、法向量等数据也做相同的插值处理,然后将这些切片的顶点数据存储下来供后续的数据处理。When a triangle intersects with each scan line, two vertex coordinates va and vb of a slice are obtained. Similarly, the texture coordinates, normal vector and other data of the vertex are also interpolated in the same way, and then the vertex data of these slices are stored for subsequent data processing.

如图6右侧所示,所述并行三角形切片算法包括两个层级的并行处理。第一层级利用不同的CUDA线程块(Block)并行处理不同的三角形的切片过程。第二层级利用线程块中的不同线程(Thread)并行处理一个三角形中的切片计算,最终得到所有三角形的所有切片数据。As shown on the right side of Figure 6, the parallel triangle slicing algorithm includes two levels of parallel processing. The first level uses different CUDA thread blocks to parallelly process the slicing process of different triangles. The second level uses different threads in the thread block to parallelly process the slicing calculation in a triangle, and finally obtains all the slicing data of all triangles.

在执行并行扫描切片算法之前,需要确保三角形的三个顶点位置数据满足y0≤y1≤y2的条件。并行三角形顶点排序算法使用CUDA核函数的线程来并行地排列三角形的顶点数据,以满足y0≤y1≤y2的条件。Before executing the parallel scan slicing algorithm, it is necessary to ensure that the three vertex position data of the triangle meet the condition y 0 ≤y 1 ≤y 2. The parallel triangle vertex sorting algorithm uses threads of the CUDA kernel function to arrange the vertex data of the triangle in parallel to meet the condition y 0 ≤y 1 ≤y 2 .

如图7所示,本发明并行前缀和算法的一种具体实施例:As shown in FIG. 7 , a specific embodiment of the parallel prefix sum algorithm of the present invention is as follows:

在得到了每个三角形的切片数据后,使用前缀和算法计算这些切片数量的前缀和,从而得出存储切片数据所需的内存空间及每个切片在全局内存中的位置,这样可以节约切片数据的存储空间。如图7左侧所示。所述并行前缀和算法使用每一个线程来对每两个切片数量元素进行和运算,在第一步的归约求和阶段,求取切片数据的部分和,在第二步使用倒置树来分发部分和,得到切片数量的前缀和。After obtaining the slice data of each triangle, the prefix sum algorithm is used to calculate the prefix sum of the number of slices, thereby obtaining the memory space required to store the slice data and the position of each slice in the global memory, which can save the storage space of the slice data. As shown on the left side of Figure 7. The parallel prefix sum algorithm uses each thread to perform a sum operation on every two slice number elements. In the first step of the reduction and summation stage, the partial sum of the slice data is obtained. In the second step, the inverted tree is used to distribute the partial sum to obtain the prefix sum of the number of slices.

如图7右侧所示,本实施例还提供一种多层级扫描结构的并行前缀和算法,其实现步骤为:(1)首先对整个切片数量数据划分为多个数据块,并进行并行扫描处理,扫描后的结果数组中仅保留了各自块内扫描的结果。(2)将每个块最后一个数保留到长度为m的辅助数组S中,对S进行扫描。(3)将S的前m-1个元素分别加到结果数组的后m-1个扫描块的每个元素中。这种算法进一步减少了数据处理在渲染流程中的时间占比,从而提高了处理的整体效率。As shown on the right side of Figure 7, this embodiment also provides a parallel prefix sum algorithm with a multi-level scanning structure, and its implementation steps are as follows: (1) First, the entire slice quantity data is divided into multiple data blocks, and parallel scanning processing is performed. After scanning, only the results of scanning in each block are retained in the result array. (2) The last number of each block is retained in an auxiliary array S of length m, and S is scanned. (3) The first m-1 elements of S are added to each element of the last m-1 scan blocks of the result array. This algorithm further reduces the time proportion of data processing in the rendering process, thereby improving the overall processing efficiency.

如图8所示,本发明切片多边形图元生成算法的一种具体实施例:As shown in FIG8 , a specific embodiment of the slice polygon primitive generation algorithm of the present invention is as follows:

本发明的切片多边形图元生成算法,包括以下内容:The slice polygon primitive generation algorithm of the present invention includes the following contents:

图8中的(a)所示的是模型中的一个三角形在某一行相机的最左和最右视点位置处拍摄得到的视图。对于一个扫描线切片v0v1,在左端视点的视图上记录的是线段SL,右端视点的视图上记录的是线段SR。如图8中的(b),根据相关性,扫描线在这一行相机上所成的所有像在EPI坐标系里可以表示为由两条不同斜率和两条平行线构成的一个四边形vL0 vL1vR1 vR0。其中两条平行的边缘线段分别是SL和SR。两条直线段的斜率分别由物点v0和v1的深度和相机的焦距确定,两条直线段的两个端点由左右两个端点相机记录的该点的图像的坐标确定。这个四边形即为切片多边形图元。每一个切片由相应的线程块来并行生成切片多边形图元。渲染管线通过光栅化切片多边形图元即可在EPI坐标系下实现扫描线v0 v1的一维多视点图像信息的并行渲染。(a) in FIG8 shows the views of a triangle in the model taken at the leftmost and rightmost viewpoints of a row of cameras. For a scan line slice v 0 v 1 , the line segment SL is recorded on the view of the left end viewpoint, and the line segment SR is recorded on the view of the right end viewpoint. As shown in (b) in FIG8 , based on the correlation, all the images formed by the scan line on this row of cameras can be represented in the EPI coordinate system as a quadrilateral v L0 v L1 v R1 v R0 consisting of two different slopes and two parallel lines. The two parallel edge segments are SL and SR . The slopes of the two straight line segments are determined by the depth of the object point v 0 and v 1 and the focal length of the camera, respectively, and the two endpoints of the two straight line segments are determined by the coordinates of the images of the point recorded by the left and right endpoint cameras. This quadrilateral is the slice polygon primitive. Each slice is generated in parallel by the corresponding thread block. The rendering pipeline can realize parallel rendering of one-dimensional multi-viewpoint image information of scan line v 0 v 1 in the EPI coordinate system by rasterizing sliced polygon primitives.

为提升图像的真实性,需要在片段着色器中,利用光照的相关性对模型的光照效果进行渲染。本实施例中采用的是Phone氏光照模型,其中各向异性的镜面光照实现过程如图8中的(c)所示。其中为三角形切片两端点的光照方向,为两端点的法线方向,为两端点的镜面光反射方向,中间相机的位置信息可以通过图8中的(b)中构建切片多边形图元的光栅化插值得到,同时可以得到左右两端相机视点相对于两端点的视线方向分别为 图8中的(d)中四端点的镜面光照值为SL0、SL1、SR0、SR1,可以由下面的公式得到:In order to improve the realism of the image, it is necessary to render the lighting effect of the model in the fragment shader using the correlation of lighting. In this embodiment, the Phone lighting model is adopted, and the anisotropic specular lighting implementation process is shown in (c) of FIG8 . is the lighting direction of the two end points of the triangle slice, is the normal direction of the two end points, is the direction of the specular light reflection at the two end points. The position information of the middle camera can be obtained by rasterization interpolation of the slice polygon primitive constructed in (b) of Figure 8. At the same time, the line of sight directions of the left and right camera viewpoints relative to the two end points can be obtained respectively. The specular illumination values of the four endpoints in (d) of FIG8 are S L0 , S L1 , S R0 , and S R1 , which can be obtained by the following formula:

specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness)specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness)

其中lightColor指的就是光照的颜色,specularMaterial指的就是物体表面的镜面材质,而V指的就是视点观察的向量,然后R指的就是光照入射向量的反射向量。最后通过片段着色器的重心坐标插值得到多边形图元的镜面光照的结果。Among them, lightColor refers to the color of the light, specularMaterial refers to the specular material of the object surface, V refers to the vector observed by the viewpoint, and R refers to the reflection vector of the incident light vector. Finally, the specular lighting result of the polygon primitive is obtained by interpolating the barycentric coordinates of the fragment shader.

应用本发明方法的一种设备实施例:An embodiment of a device applying the method of the present invention:

一种电子设备,其包括:An electronic device comprising:

一个或多个处理器;one or more processors;

存储装置,用于存储一个或多个程序;A storage device for storing one or more programs;

当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现上述的一种光场图像的多层级并行渲染方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned multi-level parallel rendering method of light field images.

应用本发明方法的一种计算机介质实施例:A computer medium embodiment using the method of the present invention:

一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述的一种光场图像的多层级并行渲染方法。A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned multi-level parallel rendering method for light field images.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, and computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

本申请是根据本申请实施例的方法、设备(系统)、计算机程序产品的流程图或/和方框图来描述的。应理解可由计算机程序指令实现流程图或/和方框图中的每一流程或/和方框以及流程图或/和方框图中的流程或/和方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程或/和方框图一个方框或多个方框中指定的功能的装置。The present application is described by flowcharts or/and block diagrams of the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each process or/and box in the flowchart or/and block diagram and the combination of the processes or/and boxes in the flowchart or/and block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate a device for implementing the functions specified in one process or multiple processes in the flowchart or/and one box or multiple boxes in the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程或/和方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程或/和方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

最后应当说明的是:以上实施例仅用以说明本发明的技术方案而非对其限制,尽管参照上述实施例对本发明进行了详细的说明,所属领域的普通技术人员应当理解:依然可以对本发明的具体实施方式进行修改或者等同替换,而未脱离本发明精神和范围的任何修改或者等同替换,其均应涵盖在本发明的权利要求保护范围之内。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims (10)

1.一种光场图像的多层级并行渲染方法,其特征在于:1. A multi-level parallel rendering method for light field images, characterized in that: 包括以下内容:Includes the following: 获取光场图像的三维模型数据和相机阵列参数;Obtaining three-dimensional model data and camera array parameters of light field images; 利用预先构建的第一层级渲染模型,根据相机阵列参数,复制三维模型数据,并根据每一行或者每一列的相机参数对三维模型数据进行变换,得到变换后的三维模型数据,实现第一层级的并行渲染;Using the pre-built first-level rendering model, according to the camera array parameters, the 3D model data is copied, and the 3D model data is transformed according to the camera parameters of each row or each column to obtain the transformed 3D model data, thereby realizing the first-level parallel rendering; 通过预先构建的第二层级渲染模型,基于透视相关性,利用变换后的三维模型数据对多个视点位置处的视图进行并行渲染,得到极平面图像,实现第二层级的并行渲染;Through the pre-built second-level rendering model, based on perspective correlation, the transformed three-dimensional model data is used to render the views at multiple viewpoints in parallel to obtain the polar plane image, thereby realizing the second-level parallel rendering; 采用预先构建的第三层级渲染模型,基于并行像素重映射将极平面图像进行数据处理层面的并行计算,得到光场图像,实现第三层级的并行渲染,以完成光场图像的多层级并行渲染。Using a pre-built third-level rendering model, the polar plane image is parallelly calculated at the data processing level based on parallel pixel remapping to obtain a light field image, thereby realizing third-level parallel rendering and completing multi-level parallel rendering of the light field image. 2.如权利要求1所述的一种光场图像的多层级并行渲染方法,其特征在于:2. The multi-level parallel rendering method of a light field image according to claim 1, characterized in that: 获取三维模型数据和相机阵列参数的方法如下:The method to obtain 3D model data and camera array parameters is as follows: 利用预先构建的渲染管线模型,读取储存在硬盘或者内存中的三维模型数据,所述三维模型数据包括模型顶点的位置坐标或/和索引坐标或/和纹理坐标或/和法向量;Using a pre-built rendering pipeline model, read the three-dimensional model data stored in a hard disk or a memory, wherein the three-dimensional model data includes position coordinates and/or index coordinates and/or texture coordinates and/or normal vectors of model vertices; 利用渲染管线模型,根据光场采集需求设定相机阵列的视点参数;Using the rendering pipeline model, the viewpoint parameters of the camera array are set according to the light field acquisition requirements; 视点参数包括视点数量或/和视点间隔或/和视点排列或/和单视点分辨率或/和相机行列信息或/和零视差平面;并根据视点参数计算每一行左右两端相机或者每一列上下两端相机的模型、视图参数以及投影矩阵,得到相机阵列参数。The viewpoint parameters include the number of viewpoints and/or the viewpoint interval and/or the viewpoint arrangement and/or the single viewpoint resolution and/or the camera row and column information and/or the zero parallax plane; and the models, view parameters and projection matrices of the cameras at the left and right ends of each row or the cameras at the top and bottom ends of each column are calculated according to the viewpoint parameters to obtain the camera array parameters. 3.如权利要求2所述的一种光场图像的多层级并行渲染方法,其特征在于:3. The multi-level parallel rendering method of a light field image according to claim 2, characterized in that: 利用第一层级渲染模型实现第一层级的并行渲染的方法如下:The method of implementing the first-level parallel rendering using the first-level rendering model is as follows: 步骤11,获取三维模型数据,其包括模型顶点的位置坐标或/和索引坐标或/和纹理坐标或/和法向量;Step 11, obtaining three-dimensional model data, which includes position coordinates and/or index coordinates and/or texture coordinates and/or normal vectors of model vertices; 步骤12,利用预先构建的顶点着色器对三维模型数据进行处理,得到三角形图元数据;Step 12, using a pre-built vertex shader to process the three-dimensional model data to obtain triangle primitive data; 步骤13,根据三角形图元数据以及相机阵列参数,利用预先构建的实例化模型为每一行或者每一列相机复制一组三角形图元数据;Step 13, according to the triangle primitive data and the camera array parameters, using the pre-built instantiation model to copy a set of triangle primitive data for each row or column of cameras; 步骤14,基于不同行或者列的相机对应不同的垂直或者水平视差,并根据每一行相机中的最左、最右端相机或者每一列相机中的最上、最下端的变换矩阵对三角形图元数据执行变换,将三角形图元数据转换到屏幕坐标系下,得到变换后的三维模型数据,多个行或者多个列对应的三维模型数据被并行送入第二层级的渲染,实现第一层级的并行渲染。Step 14, based on the different vertical or horizontal parallaxes corresponding to cameras in different rows or columns, and according to the transformation matrices of the leftmost and rightmost cameras in each row of cameras or the topmost and bottommost cameras in each column of cameras, the triangle primitive data are transformed into the screen coordinate system to obtain the transformed three-dimensional model data, and the three-dimensional model data corresponding to multiple rows or multiple columns are sent to the second-level rendering in parallel to realize the parallel rendering of the first level. 4.如权利要求1所述的一种光场图像的多层级并行渲染方法,其特征在于:4. The multi-level parallel rendering method of a light field image according to claim 1, characterized in that: 通过第二层级渲染模型实现第二层级的并行渲染的方法如下:The method of implementing the second-level parallel rendering through the second-level rendering model is as follows: 步骤21,对三维模型数据进行并行三角形顶点排序处理、并行前缀和计算处理以及并行三角形切片处理,得到三角形切片;步骤22,基于相关性,利用预先构建的并行处理单元将三角形切片转换为多边形图元,在极平面坐标系下并行渲染每一个三角形切片在同一行或/和列相机中所有视点位置处的视图,得到三角形切片的多边形图元;所述相关性包括几何相关性、透视相关性、纹理相关性和光照相关性;Step 21, performing parallel triangle vertex sorting processing, parallel prefix sum calculation processing and parallel triangle slicing processing on the three-dimensional model data to obtain triangle slices; Step 22, based on the correlation, using a pre-built parallel processing unit to convert the triangle slices into polygonal primitives, and rendering each triangle slice in parallel at all viewpoint positions in the same row or/and column camera in a polar plane coordinate system to obtain polygonal primitives of the triangle slices; the correlation includes geometric correlation, perspective correlation, texture correlation and illumination correlation; 步骤23,通过预先构建的并行多边形光栅化单元,将三角形切片的多边形图元在同一行或/和列相机中所有视点位置处的视图进行光栅化,得到同一行或者同一列相机的极平面图像;Step 23, rasterizing the views of the polygonal primitives of the triangle slice at all viewpoint positions in the same row or/and column of cameras through a pre-built parallel polygon rasterization unit to obtain an extreme plane image of the same row or column of cameras; 或/和,采用第三层级渲染模型实现第三层级的并行渲染的方法如下:Alternatively or alternatively, the method for implementing the third-level parallel rendering using the third-level rendering model is as follows: 步骤31,获取极平面图像;Step 31, obtaining an extreme plane image; 步骤32,根据光照和纹理的相关性,利用预先构建的片段着色器对极平面图像进行着色,得到着色图像;Step 32, according to the correlation between illumination and texture, the polar plane image is shaded using a pre-built fragment shader to obtain a shaded image; 步骤33,根据着色图像,输出极平面图像的像素数据;Step 33, outputting pixel data of the polar plane image according to the colored image; 步骤34,对像素数据进行并行像素重组形成最终的光场图像。Step 34 , performing parallel pixel reorganization on the pixel data to form a final light field image. 5.如权利要求4所述的一种光场图像的多层级并行渲染方法,其特征在于:5. The multi-level parallel rendering method of light field images according to claim 4, characterized in that: 并行三角形切片处理的方法,包括以下内容:The method of parallel triangle slicing processing includes the following: 步骤221,获取三维模型数据中的三角形以及其三个顶点坐标,三角形的三个顶点分别是v1(x0,y0)、v2(x1,y1)、v3(x2,y2);Step 221, obtaining a triangle and its three vertex coordinates in the three-dimensional model data, wherein the three vertices of the triangle are v 1 (x 0 , y 0 ), v 2 (x 1 , y 1 ), and v 3 (x 2 , y 2 ); 步骤222,沿着屏幕扫描线的方向对三角形进行切片,三角形与每条屏幕扫描线相交都会得到一个切片的两个交点va、vbStep 222, slicing the triangle along the direction of the screen scan line, where the triangle intersects with each screen scan line to obtain two intersection points va and vb of a slice; 步骤223,屏幕扫描线与三角形的两个交点va、vb的坐标va(xa,ya)、vb(xb,yb)通过已知的三个顶点坐标之间的线性插值计算获得,相应的x方向的坐标如下:Step 223, the coordinates va ( xa , ya ) and vb ( xb , yb ) of the two intersection points va and vb of the screen scan line and the triangle are obtained by linear interpolation between the three known vertex coordinates. The corresponding x-direction coordinates are as follows: xb=(1-b)*x0+b*x2 y0≤y≤y2 x b =(1-b)*x 0 +b*x 2 y 0 ≤y≤y 2 其中a、b为插值参数,不同的扫描线有不同的插值参数:Among them, a and b are interpolation parameters, and different scan lines have different interpolation parameters: b=(y-y0)/(y2-y0) y0≤y≤y2 b=(yy 0 )/(y 2 -y 0 ) y 0 ≤y≤y 2 步骤224,将交点的纹理坐标、法向量数据进行插值处理,得到切片的顶点数据,并存储下来供后续的数据处理;Step 224, interpolating the texture coordinates and normal vector data of the intersection point to obtain the vertex data of the slice, and storing it for subsequent data processing; 或/和,并行三角形切片处理的方法,包括两个层级的并行处理;第一层级利用不同的线程块Block并行处理不同的三角形的切片过程;第二层级利用线程块中的不同线程并行处理一个三角形中的切片计算,最终得到所有三角形的所有切片数据;Or/and, a method for parallel triangle slicing processing includes two levels of parallel processing; the first level uses different thread blocks to parallelly process the slicing process of different triangles; the second level uses different threads in the thread block to parallelly process the slicing calculation in a triangle, and finally obtains all the slicing data of all the triangles; 在执行并行扫描切片算法之前,三角形的三个顶点位置数据满足y0≤y1≤y2的条件;Before executing the parallel scanning and slicing algorithm, the position data of the three vertices of the triangle satisfy the condition y 0 ≤y 1 ≤y 2 ; 三角形顶点排序处理方法使用核函数的线程来并行地排列三角形的顶点数据,以满足y0≤y1≤y2的条件。The triangle vertex sorting processing method uses threads of a kernel function to arrange the vertex data of a triangle in parallel to satisfy the condition of y 0 ≤y 1 ≤y 2 . 6.如权利要求5所述的一种光场图像的多层级并行渲染方法,其特征在于:6. The multi-level parallel rendering method of light field images according to claim 5, characterized in that: 并行前缀和计算处理的方法如下:The method for parallel prefix sum calculation processing is as follows: 获取每个三角形的切片数据;Get the slice data of each triangle; 使用前缀和算法计算切片数据的前缀和,得到存储切片数据所需的内存空间及每个切片在全局内存中的位置;Use the prefix sum algorithm to calculate the prefix sum of the slice data, and obtain the memory space required to store the slice data and the location of each slice in the global memory; 并行前缀和算法使用每一个线程来对每两个切片数量元素进行和运算,其包括以下内容:第一步,进行归约求和,求取切片数据的部分和;第二步,使用倒置树来分发部分和,得到切片数量的前缀和;The parallel prefix sum algorithm uses each thread to perform a sum operation on every two slice quantity elements, which includes the following: the first step is to perform a reduction sum to obtain the partial sum of the slice data; the second step is to use an inverted tree to distribute the partial sum to obtain the prefix sum of the slice quantity; 或,并行前缀和算法为多层级扫描结构的并行前缀和算法,其实现步骤如下:Alternatively, the parallel prefix sum algorithm is a parallel prefix sum algorithm with a multi-level scanning structure, and its implementation steps are as follows: (1)首先对整个切片数量数据划分为多个数据块,并进行并行扫描处理,扫描后的结果数组中仅保留了各自块内扫描的结果;(1) First, the entire slice quantity data is divided into multiple data blocks and scanned in parallel. After scanning, only the results of scanning in each block are retained in the result array; (2)将每个数据块最后一个数保留到长度为m的辅助数组S中,对辅助数组S进行扫描;(2) The last number of each data block is saved in an auxiliary array S of length m, and the auxiliary array S is scanned; (3)将辅助数组S的前m-1个元素分别加到结果数组的后m-1个扫描块的每个元素中。(3) Add the first m-1 elements of the auxiliary array S to each element of the last m-1 scan blocks of the result array. 7.如权利要求6所述的一种光场图像的多层级并行渲染方法,其特征在于:7. The multi-level parallel rendering method of light field images according to claim 6, characterized in that: 用于将三角形切片转换为多边形图元的并行处理单元,包括以下内容:Parallel processing units for converting triangle slices into polygon primitives, including the following: 获取一个三角形切片在某一行相机的最左和最右视点位置处拍摄得到的视图;Get the view of a triangle slice taken at the leftmost and rightmost viewpoints of a row of cameras; 对于一个三角形切片v0 v1,在左端视点的视图上记录的是线段SL,右端视点的视图上记录的是线段SRFor a triangle slice v 0 v 1 , the line segment S L is recorded in the view of the left viewpoint, and the line segment S R is recorded in the view of the right viewpoint; 根据相关性,扫描线在这一行相机上所成的所有像在EPI坐标系里能表示为由两条不同斜率和两条平行线构成的一个四边形vL0 vL1 vR1 vR0;其中两条平行的边缘线段分别是线段SL和线段SR;两条直线段的斜率分别由物点v0和v1的深度和相机的焦距确定,两条直线段的两个端点由左右两个端点相机记录的该点的图像的坐标确定;这个四边形即为一个三角形切片的多边形图元;每一个三角形切片由相应的线程块来并行生成多个三角形切片的多边形图元;According to the correlation, all the images formed by the scan lines on this row of cameras can be expressed in the EPI coordinate system as a quadrilateral v L0 v L1 v R1 v R0 consisting of two different slopes and two parallel lines; the two parallel edge segments are line segment SL and line segment SR ; the slopes of the two straight line segments are determined by the depth of the object point v0 and v1 and the focal length of the camera, respectively, and the two endpoints of the two straight line segments are determined by the coordinates of the images of the points recorded by the left and right endpoint cameras; this quadrilateral is a polygonal primitive of a triangular slice; each triangular slice is generated by the corresponding thread block in parallel to generate multiple polygonal primitives of triangular slices; 或/和,并行多边形光栅化单元利用渲染管线对切片的多边形图元进行光栅化操作,从而在EPI坐标系下实现扫描线v0 v1的一维多视点图像信息的并行渲染;or/and, the parallel polygon rasterization unit performs rasterization operation on the sliced polygon primitives using the rendering pipeline, thereby realizing parallel rendering of one-dimensional multi-viewpoint image information of scan lines v 0 v 1 in the EPI coordinate system; 或/和,还包括对切片的多边形图元进行光照处理,具体内容如下:Or/and, it also includes lighting processing for the sliced polygonal primitives, the specific contents are as follows: 基于预先构建的片段着色器,利用光照的相关性对切片的多边形图元的光照效果进行渲染;并采用Phone氏光照模型,实现各向同性和各向异性的光照效果;Based on the pre-built fragment shader, the lighting effects of the sliced polygon primitives are rendered using the correlation of lighting; and the Phone lighting model is used to achieve isotropic and anisotropic lighting effects; 以镜面光为例,多边形图元的四端点的镜面光照值为SL0、SL1、SR0、SR1,其由下面的公式得到:Taking specular light as an example, the specular light values of the four endpoints of the polygon primitive are S L0 , S L1 , S R0 , and S R1 , which are obtained by the following formula: specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness)specularResult=lightColor*specularMaterial*pow(max(0,V·R),shiness) 其中specularResult指切片的多边形图元表面的镜面光照值,lightColor指光照的颜色,specularMaterial指切片的多边形图元表面的镜面材质,V指视点的观察向量,R指光照入射向量的反射向量,shiness则表示高光反光度,pow()函数用于计算一个数的幂次方;Where specularResult refers to the specular lighting value of the sliced polygonal primitive surface, lightColor refers to the color of the lighting, specularMaterial refers to the specular material of the sliced polygonal primitive surface, V refers to the view vector of the viewpoint, R refers to the reflection vector of the lighting incident vector, shines refers to the specular reflectivity, and the pow() function is used to calculate the power of a number; 最后通过片段着色器的重心坐标插值得到多边形图元的镜面光照的结果。Finally, the result of the specular lighting of the polygonal primitive is obtained by interpolating the barycentric coordinates of the fragment shader. 8.一种光场图像的多层级并行渲染系统,其特征在于:8. A multi-level parallel rendering system for light field images, characterized in that: 设有渲染管线和渲染硬件;It has a rendering pipeline and rendering hardware; 所述渲染管线,用于实现多层级并行渲染,其包括应用程序、应用程序接口、通用并行计算架构和操作系统;The rendering pipeline is used to implement multi-level parallel rendering, which includes an application program, an application program interface, a general parallel computing architecture and an operating system; 所述渲染硬件,用于提供运行渲染管线所需的硬件资源,其包括内存、CPU、GPU和显存;The rendering hardware is used to provide the hardware resources required to run the rendering pipeline, including memory, CPU, GPU and video memory; 所述操作系统用于控制应用程序,调用应用程序接口和通用并行计算构架;The operating system is used to control applications, call application program interfaces and general parallel computing frameworks; 所述应用程序、应用程序接口和通用并行计算构架驱动CPU、GPU、内存和显存,执行时实现如权利要求1-7任一所述的一种光场图像的多层级并行渲染方法,完成从三维模型数据到光场图像的多层级并行渲染。The application, application program interface and general parallel computing architecture drive the CPU, GPU, memory and video memory, and when executed, implement a multi-level parallel rendering method for light field images as described in any one of claims 1 to 7, and complete multi-level parallel rendering from three-dimensional model data to light field images. 9.一种光场图像的多层级并行渲染方法,其特征在于:9. A multi-level parallel rendering method for light field images, characterized in that: 采用如权利要求8所述的一种光场图像的多层级并行渲染系统,其包括以下步骤:A multi-level parallel rendering system for light field images as claimed in claim 8 comprises the following steps: 第一步,设置世界坐标XYZ,其中相机阵列位于XY平面;三维模型位于相机阵列前;当所有相机完成对三维模型的拍摄后,光场图像被记录下来;The first step is to set the world coordinates XYZ, where the camera array is located in the XY plane; the 3D model is located in front of the camera array; when all cameras complete shooting the 3D model, the light field image is recorded; 第二步,所述渲染管线通过CPU从内存中读取三维模型数据传入GPU端的顶点着色器;In the second step, the rendering pipeline reads the 3D model data from the memory through the CPU and transmits it to the vertex shader on the GPU side; 第三步,利用顶点着色器将三维模型数据中的顶点数据组装成三角形图元并传入几何着色器;同时从CPU端设定相机阵列的参数,并传入GPU端的几何着色器;The third step is to use the vertex shader to assemble the vertex data in the 3D model data into triangle primitives and pass them into the geometry shader. At the same time, the parameters of the camera array are set from the CPU side and passed into the geometry shader on the GPU side. 第四步,利用实例化功能为每一列或者每一行相机复制一组三角形图元;The fourth step is to use the instantiation function to copy a set of triangle primitives for each column or row of cameras; 第五步,根据每一列相机中的最上端和最下端相机或者每一行最左端和最右端相机的变换矩阵对三角形图元执行变换,得到变换后的三维模型数据;Step 5: transform the triangle primitives according to the transformation matrices of the top and bottom cameras in each column or the left and right cameras in each row to obtain transformed three-dimensional model data; 第六步,利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作把变换后的图元数据映射到通用并行计算构架CUDA空间;Step 6: Map the transformed image metadata to the CUDA space using the interoperability between the CUDA and OpenGL. 第七步,在通用并行计算构架CUDA空间中进行顶点并行排序计算、并行前缀和计算和并行三角形切片计算,得到三角形切片数据;Step 7: Perform vertex parallel sorting calculation, parallel prefix sum calculation and parallel triangle slicing calculation in the general parallel computing framework CUDA space to obtain triangle slicing data; 第八步,利用通用并行计算构架CUDA和应用程序接口OpenGL的互操作将三角形切片数据映射到顶点着色器上;利用顶点着色器和相关性将三角形切片数据中的顶点数据组装成切片的多边形图元;Step 8: Map the triangle slice data to the vertex shader by using the interoperation between the general parallel computing framework CUDA and the application program interface OpenGL; assemble the vertex data in the triangle slice data into the polygon primitives of the slice by using the vertex shader and correlation; 第九步,将切片的多边形图元光栅化并在片段着色器中根据光照和纹理的相关性进行着色,得到极平面图像;In the ninth step, the sliced polygonal primitives are rasterized and colored in the fragment shader according to the correlation of lighting and texture to obtain a polar plane image; 第十步,根据极平面图像的像素数据,并通过并行像素重映射获得光场图像。In the tenth step, a light field image is obtained based on the pixel data of the polar plane image through parallel pixel remapping. 10.一种光场图像的多层级并行渲染方法,其特征在于:10. A multi-level parallel rendering method for light field images, characterized in that: 包括以下步骤:The following steps are involved: 利用预先构建的第一层级渲染模型,对不同维度的视差图像进行并行渲染;Using the pre-built first-level rendering model, parallax images of different dimensions are rendered in parallel; 通过预先构建的第二层级渲染模型,对同一维度的不同视点图像进行并行渲染;Through the pre-built second-level rendering model, different viewpoint images of the same dimension are rendered in parallel; 采用预先构建的第三层级渲染模型,进行数据处理层面的并行计算。A pre-built third-level rendering model is used to perform parallel computing at the data processing level.
CN202410506005.5A 2024-04-25 2024-04-25 Multi-level parallel rendering method and system for light field image Pending CN118537468A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410506005.5A CN118537468A (en) 2024-04-25 2024-04-25 Multi-level parallel rendering method and system for light field image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410506005.5A CN118537468A (en) 2024-04-25 2024-04-25 Multi-level parallel rendering method and system for light field image

Publications (1)

Publication Number Publication Date
CN118537468A true CN118537468A (en) 2024-08-23

Family

ID=92391199

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410506005.5A Pending CN118537468A (en) 2024-04-25 2024-04-25 Multi-level parallel rendering method and system for light field image

Country Status (1)

Country Link
CN (1) CN118537468A (en)

Similar Documents

Publication Publication Date Title
US11252392B2 (en) Layered scene decomposition CODEC with layered depth imaging
McGuire et al. Hardware-accelerated global illumination by image space photon mapping
CN113808241B (en) Hardware acceleration of ray traced primitives sharing vertices
KR20160033128A (en) Sparse gpu voxelization for 3d surface reconstruction
CN115769266A (en) Light field volume rendering system and method
US11120611B2 (en) Using bounding volume representations for raytracing dynamic units within a virtual space
CN1890694A (en) Computer graphics processor and method for rendering 3-d scenes on a 3-d image display screen
CN106228594A (en) Typhoon model cloud cartoon display method based on surface subdivision
CN1655191A (en) A Fast Voxelization Method for Polygonal Mesh Models Based on Programmable Graphics Hardware
KR20160068204A (en) Data processing method for mesh geometry and computer readable storage medium of recording the same
CN113129420B (en) A ray tracing rendering method based on depth buffer acceleration
El Seoud et al. A comprehensive review on volume rendering techniques
JP7460641B2 (en) Apparatus and method for generating a light intensity image - Patents.com
KR950025512A (en) Hardware-based graphical workstation solution for refraction
Gao et al. Real-time hierarchical parallel rendering and display of light field images
CN117635454A (en) Multi-source light field fusion rendering method, device and storage medium
CN118537468A (en) Multi-level parallel rendering method and system for light field image
US20230377250A1 (en) Light field offset rendering
Lee et al. A bimodal empty space skipping of ray casting for terrain data
Ivanov et al. Spatial Patches‐A Primitive for 3D Model Representation
CN116993894B (en) Virtual picture generation method, device, equipment, storage medium and program product
Wang et al. Ray Tracing Acceleration Algorithm Based on FaceMap
De Toledo et al. Visualization of industrial structures with implicit gpu primitives
Lopez-Moreno et al. GPU Visualization and Voxelization of Yarn-Level Cloth.
Popescu et al. Sample-based cameras for feed forward reflection rendering

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