CN101840566A - Real-time shadow generating method based on GPU parallel calculation and system thereof - Google Patents
Real-time shadow generating method based on GPU parallel calculation and system thereof Download PDFInfo
- Publication number
- CN101840566A CN101840566A CN201010153573A CN201010153573A CN101840566A CN 101840566 A CN101840566 A CN 101840566A CN 201010153573 A CN201010153573 A CN 201010153573A CN 201010153573 A CN201010153573 A CN 201010153573A CN 101840566 A CN101840566 A CN 101840566A
- Authority
- CN
- China
- Prior art keywords
- shadow
- gpu
- shade
- value
- filtering
- 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
Links
Images
Landscapes
- Processing Or Creating Images (AREA)
Abstract
Description
技术领域technical field
本发明属于图形学领域,特别是涉及到一种基于GPU并行计算的实时阴影生产方法及系统。The invention belongs to the field of graphics, and in particular relates to a real-time shadow production method and system based on GPU parallel computing.
背景技术Background technique
近年来,计算机图形学有了较大的发展,在游戏,虚拟现实,电影特效制作等多个方向有了非常广泛的应用,伴随着应用需求的不断增加,人们对真实感图形的需求也与日俱增。实现真实感图形生成包含很多方面,其中阴影是比较难的一方面。进来随着GPU以及CPU能力不断增强,尤其是显卡的不断进步,使得原来由CPU处理的大部分数据改由GPU处理,并在硬件上实现了部分通用功能,如变化与光照计算等,从而大大提升了处理能力,使真实感渲染方法逐步得到广泛应用。In recent years, computer graphics has developed greatly, and has been widely used in games, virtual reality, film special effects production, etc. With the continuous increase of application requirements, people's demand for realistic graphics is also increasing day by day . There are many aspects to achieving photorealistic graphics generation, and shadows are one of the more difficult aspects. With the continuous enhancement of GPU and CPU capabilities, especially the continuous improvement of graphics cards, most of the data originally processed by the CPU has been processed by the GPU, and some general functions have been realized on the hardware, such as changes and lighting calculations, which greatly greatly The processing power has been improved, and the photorealistic rendering method has gradually been widely used.
阴影方法作为真实感渲染领域极其重要的组成部分,目前阴影方法主要包括扫描线方法、细节多边形方法(两次消隐方法)、影域多边形方法(shadow volumes)、阴影映射(shadow mapping)、Z-buffer方法、光线跟踪方法、辐射度方法等。而在交互式3D应用中使用最多的是阴影映射及其改进方法。这一方法及其改进方法在游戏、虚拟现实、医学成像、电影制作等领域都有着越来越广泛的应用。As an extremely important part of the realistic rendering field, the shadow method mainly includes scan line method, detail polygon method (twice blanking method), shadow volume polygon method (shadow volumes), shadow mapping (shadow mapping), Z -buffer method, ray tracing method, radiosity method, etc. However, shadow mapping and its improved methods are most used in interactive 3D applications. This approach and its improvements are increasingly used in games, virtual reality, medical imaging, filmmaking, and more.
在未来计算机硬件性能不断提升的过程中,真实感渲染方法势必将向着高速、实时、现实方向发展。其中必然对阴影生成方法有着更高的要求。因此在这一方向的研究是具有极高应用价值的。In the process of continuous improvement of computer hardware performance in the future, photorealistic rendering methods are bound to develop towards high-speed, real-time, and realistic directions. Among them, there must be higher requirements for the shadow generation method. Therefore, the research in this direction has extremely high application value.
发明内容Contents of the invention
本发明的目的之一在于克服现有技术的不足,提出一种基于GPU并行计算的实时阴影生成方法。本发明的目的之二在于根据目的一的方法,提出一种基于GPU并行计算的实时阴影生成系统。One of the objectives of the present invention is to overcome the deficiencies of the prior art, and propose a real-time shadow generation method based on GPU parallel computing. The second object of the present invention is to propose a real-time shadow generation system based on GPU parallel computing according to the method of the first object.
为了实现发明目的一,采用的技术方案如下:In order to realize the purpose of the invention one, the technical scheme adopted is as follows:
以光源视点渲染场景保存物体深度信息;将深度信息做一次函数变换;存储变换后的深度信息;用GPU对深度信息并行滤波;以视点渲染场景,得到物体与光源的距离;对距离值做函数变换;将变换后的深度值和距离值相乘,得到当前渲染点的阴影值信息;利用此阴影值信息渲染场景,最终得到平滑阴影效果。Render the scene with the viewpoint of the light source to save the depth information of the object; perform a function transformation on the depth information; store the transformed depth information; use the GPU to filter the depth information in parallel; render the scene with the viewpoint to obtain the distance between the object and the light source; do a function on the distance value Transformation; multiply the transformed depth value and distance value to obtain the shadow value information of the current rendering point; use this shadow value information to render the scene, and finally obtain a smooth shadow effect.
为了实现发明目的二,采用的技术方案为:In order to realize the purpose of the invention two, the technical scheme adopted is:
一种基于GPU并行计算的实时阴影生成系统,包括新的阴影映射贴图生成模块、GPU并行处理阴影映射贴图模块以及阴影贴图生成实时阴影的渲染模块。A real-time shadow generation system based on GPU parallel computing, including a new shadow map texture generation module, a GPU parallel processing shadow map texture module, and a rendering module for generating real-time shadows from shadow maps.
所述新的阴影映射贴图生成模块包括深度采集子模块、生成连续函数阴影贴图子模块。The new shadow map generation module includes a depth acquisition submodule and a continuous function shadow map generation submodule.
所述GPU并行处理阴影映射贴图模块包括GPU阴影图载入子模块、GPU并行滤波子模块。The GPU parallel processing shadow map texture module includes a GPU shadow map loading sub-module and a GPU parallel filtering sub-module.
所述阴影贴图生成实时阴影的渲染模块包括连续函数阴影贴图阴影映射贴图还原子模块、阴影生成子模块。The rendering module for generating real-time shadows by shadow maps includes a continuous function shadow map shadow map map reduction sub-module and a shadow generation sub-module.
新的阴影映射贴图生成模块,收集场景物体到光源的深度信息后,用连续函数将深度信息做一次映射,利用映射后的值生成阴影贴图。The new shadow map generation module, after collecting the depth information from the scene object to the light source, uses a continuous function to map the depth information once, and uses the mapped value to generate a shadow map.
将阴影贴图送入GPU阴影图载入子模块,包含如下3个步骤的处理:Send the shadow map to the GPU shadow map loading submodule, including the following three steps:
将原始图像分割成大小相同的小块;将每个小块读入GPU的处理单元的内存;将读入后的数据边缘部分进行扩展。Divide the original image into small blocks of the same size; read each small block into the memory of the processing unit of the GPU; expand the edge part of the read data.
如果是图像最外层边界用0进行扩展,扩展行数根据滤波阶数而定;如果是图像内部分块边界,用相邻行或列数据复制补齐扩展,扩展行数根据滤波阶数而定。If it is the outermost border of the image, use 0 to expand, and the number of extended rows depends on the filter order; if it is the inner block boundary of the image, use adjacent row or column data to copy and expand, and the number of extended rows depends on the filter order Certainly.
将扩展后的数据送入GPU并行滤波子模块,包括如下3个步骤的处理:Send the expanded data to the GPU parallel filtering sub-module, including the following three steps:
每个处理单元同时读入补齐扩展后的数据;每个处理单元用滤波核对数据进行乘加滤波运算;将运算后的结果写入公共内存区,并等待线程同步后返回结束信号。Each processing unit simultaneously reads in the supplemented and extended data; each processing unit uses filtering to check the data for multiplication and addition filtering; writes the result after the operation into the common memory area, and returns the end signal after waiting for thread synchronization.
之后进入连续函数阴影贴图阴影映射贴图还原子模块和阴影生成子模块。Then enter the continuous function shadow map shadow map map restoration sub-module and shadow generation sub-module.
映射贴图还原子模块对距离值做函数变换;将变换后的深度值和距离值相乘,得到当前渲染点的阴影值信息。送入阴影生成子模块,利用此阴影值信息渲染场景,最终得到平滑阴影效果。The map texture reduction sub-module performs functional transformation on the distance value; multiplies the transformed depth value and the distance value to obtain the shadow value information of the current rendering point. Send it to the shadow generation sub-module, use this shadow value information to render the scene, and finally get a smooth shadow effect.
本发明的优点在于阴影生成速度快,边缘平滑。在场景中有多个光源情况下比一般的方法能有效提高阴影生成速度50%以上。在复杂场景的渲染应用需求中具有极大优势。The invention has the advantages of fast shadow generation speed and smooth edges. In the case of multiple light sources in the scene, it can effectively increase the shadow generation speed by more than 50% compared with the general method. It has great advantages in the rendering application requirements of complex scenes.
附图说明Description of drawings
图1为本发明的基于GPU并行计算的实时阴影生成系统框架示意图;Fig. 1 is the framework schematic diagram of the real-time shadow generation system based on GPU parallel computing of the present invention;
图2为本发明的基于GPU并行计算的实时阴影生成方法的流程图;Fig. 2 is the flowchart of the real-time shadow generation method based on GPU parallel computing of the present invention;
图3为阴影图载入子模块流程图;Figure 3 is a flow chart of the shadow map loading sub-module;
图4为GPU并行处理阴影映射贴图流程图。FIG. 4 is a flow chart of GPU parallel processing of shadow map textures.
具体实施方式Detailed ways
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings without any creative effort.
图1展示了基于GPU并行计算的实时阴影生成系统框架。首先渲染系统从场景中得到所有待渲染物体在场景中的深度信息,这步操作无特殊要求。Figure 1 shows the framework of real-time shadow generation system based on GPU parallel computing. First, the rendering system obtains the depth information of all objects to be rendered in the scene from the scene, and there are no special requirements for this step.
得到深度信息后将深度信息传入连续函数阴影贴图模块,此模块完成如下工作:After obtaining the depth information, pass the depth information to the continuous function shadow map module. This module completes the following tasks:
首先此模块根据深度信息得到离散的阴影测试函数,此阴影测试函数定义为如果光源到物体的深度信息值小于视点空间中光源到物体的深度信息值即视为此点在阴影中,这样得到的阴影测试函数为0-1离散函数。其次选用一个连续函数来逼近这个离散函数,函数的选取可以有多种,开发者可以尝试选取不同种类的连续函数。所有函数的选取目的均在逼近模拟0-1离散函数,最后将连续函数变换后的阴影测试函数存储到一张阴影贴图中。First, this module obtains a discrete shadow test function based on the depth information. This shadow test function is defined as if the depth information value from the light source to the object is smaller than the depth information value from the light source to the object in the viewpoint space, it is considered that the point is in the shadow. The shadow test function is a 0-1 discrete function. Secondly, a continuous function is selected to approximate the discrete function. There are many choices of functions, and developers can try to select different types of continuous functions. The selection purpose of all functions is to approximate and simulate the 0-1 discrete function, and finally store the shadow test function transformed by the continuous function into a shadow map.
接下来将存储的阴影贴图送入GPU阴影图载入子模块,此模块负责对阴影贴图做前期处理,目的是为GPU并行滤波提供准备。具体所作工作如图3所示,包含如下3个步骤的处理:Next, the stored shadow map is sent to the GPU shadow map loading sub-module. This module is responsible for pre-processing the shadow map to prepare for GPU parallel filtering. The specific work is shown in Figure 3, including the following three steps:
1、将原始阴影贴图分割成大小相同的小块。此步操作根据滤波核的大小,和图像本身的大小分块大小会有所不同,应满足一般原则:分块个数应满足GPU数据对齐原则,即分块应为2次方数。1. Divide the original shadow map into small pieces of the same size. The size of the blocks in this step will vary according to the size of the filter kernel and the size of the image itself, and should meet the general principles: the number of blocks should meet the GPU data alignment principle, that is, the number of blocks should be the power of 2.
2、将每个小块读入GPU的处理单元的内存。此步操作是为GPU并行计算单元提供原始数据。2. Read each small block into the memory of the processing unit of the GPU. This step is to provide raw data for the GPU parallel computing unit.
3、将读入后的数据边缘部分进行扩展。此步操作是为了计算分块边缘的值,根据卷积滤波的定义这步不能缺少,否则图像将会缩小。扩展方法如下所述:3. Expand the edge part of the read data. This step is to calculate the value of the edge of the block. According to the definition of convolution filtering, this step cannot be missing, otherwise the image will shrink. The extension methods are described below:
如果是图像最外层边界用0进行扩展,扩展行数根据滤波阶数而定;如果是图像内部分块边界,用相邻行或列数据复制补齐扩展,扩展行数根据滤波阶数而定。If it is the outermost border of the image, use 0 to expand, and the number of extended rows depends on the filter order; if it is the inner block boundary of the image, use adjacent row or column data to copy and expand, and the number of extended rows depends on the filter order Certainly.
接下来如图4所示,将扩展后的数据送入GPU并行滤波子模块,此模块将阴影贴图进行并行滤波,包括如下3个步骤的处理:Next, as shown in Figure 4, the expanded data is sent to the GPU parallel filtering sub-module, which performs parallel filtering on the shadow map, including the following three steps:
1、每个处理单元同时读入补齐扩展后的数据;1. Each processing unit simultaneously reads in the completed and expanded data;
2、每个处理单元用滤波核对数据进行乘加滤波运算;此处滤波的方法可以不同,本系统采用的是高斯滤波。2. Each processing unit uses filtering to check the data to perform multiplication and addition filtering operations; the filtering method here can be different, and this system uses Gaussian filtering.
3、将运算后的结果写入公共存储区,并等待线程同步后返回结束信号。至此已经完成对图像的并行滤波,结果存储在公共存储区。3. Write the calculated result into the public storage area, and wait for the thread synchronization to return the end signal. So far, the parallel filtering of the image has been completed, and the result is stored in the common storage area.
之后进入连续函数阴影贴图阴影映射贴图还原子模块和阴影生成子模块。Then enter the continuous function shadow map shadow map map restoration sub-module and shadow generation sub-module.
阴影贴图还原子模块对距离值做函数变换;将变换后的深度值和距离值相乘,得到当前渲染点的阴影值信息。送入阴影生成子模块,利用此阴影值信息渲染场景,最终自然得到平滑阴影效果。The shadow map restoration sub-module performs functional transformation on the distance value; multiplies the transformed depth value and the distance value to obtain the shadow value information of the current rendering point. Send it to the shadow generation sub-module, use this shadow value information to render the scene, and finally get a smooth shadow effect naturally.
如上所诉的系统及方法是为了能让本领域的技术人员制造和使用本发明而提供的。本领域的技术人员可以对具体实现做相应修改,但其所对应的最大范畴与这里所揭示的原理和新颖性是一致的。The systems and methods described above are provided to enable those skilled in the art to make and use the present invention. Those skilled in the art can make corresponding modifications to the specific implementation, but the maximum scope corresponding to it is consistent with the principles and novelties disclosed here.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201010153573A CN101840566A (en) | 2010-04-16 | 2010-04-16 | Real-time shadow generating method based on GPU parallel calculation and system thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201010153573A CN101840566A (en) | 2010-04-16 | 2010-04-16 | Real-time shadow generating method based on GPU parallel calculation and system thereof |
Publications (1)
Publication Number | Publication Date |
---|---|
CN101840566A true CN101840566A (en) | 2010-09-22 |
Family
ID=42743923
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201010153573A Pending CN101840566A (en) | 2010-04-16 | 2010-04-16 | Real-time shadow generating method based on GPU parallel calculation and system thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101840566A (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102592306A (en) * | 2010-10-21 | 2012-07-18 | 汤姆森许可贸易公司 | Method for estimation of occlusion in a virtual environment |
CN102663208A (en) * | 2012-04-28 | 2012-09-12 | 浪潮电子信息产业股份有限公司 | Method for carrying out large-eddy simulation real-time rendering by utilizing graphic processing unit (GPU) |
CN104103092A (en) * | 2014-07-24 | 2014-10-15 | 无锡梵天信息技术股份有限公司 | Real-time dynamic shadowing realization method based on projector lamp |
CN105931286A (en) * | 2016-03-29 | 2016-09-07 | 赵岳生 | Terrain shadow real time simulation method applied to three-dimensional scene simulation GIS (geographic information system) |
CN103699426B (en) * | 2013-12-11 | 2017-07-28 | 四川九洲电器集团有限责任公司 | A kind of computer simulation computational methods |
CN107463398A (en) * | 2017-07-21 | 2017-12-12 | 腾讯科技(深圳)有限公司 | Game rendering intent, device, storage device and terminal |
CN109949401A (en) * | 2019-03-14 | 2019-06-28 | 成都风际网络科技股份有限公司 | A kind of method of the non real-time Shading Rendering of non-static object of mobile platform |
CN112836872A (en) * | 2021-01-29 | 2021-05-25 | 西安理工大学 | A high-performance numerical solution method for pollutant convection-diffusion equation based on multi-GPU |
CN113163185A (en) * | 2021-03-26 | 2021-07-23 | 复旦大学 | VR real-time self-adaptive transmission system and method based on heterogeneous calculation |
CN113421199A (en) * | 2021-06-23 | 2021-09-21 | 北京达佳互联信息技术有限公司 | Image processing method, image processing device, electronic equipment and storage medium |
CN116740254A (en) * | 2022-09-27 | 2023-09-12 | 荣耀终端有限公司 | An image processing method and terminal |
-
2010
- 2010-04-16 CN CN201010153573A patent/CN101840566A/en active Pending
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102592306A (en) * | 2010-10-21 | 2012-07-18 | 汤姆森许可贸易公司 | Method for estimation of occlusion in a virtual environment |
CN102592306B (en) * | 2010-10-21 | 2017-03-01 | 汤姆森许可贸易公司 | The method of estimation blocked in virtual environment |
CN102663208A (en) * | 2012-04-28 | 2012-09-12 | 浪潮电子信息产业股份有限公司 | Method for carrying out large-eddy simulation real-time rendering by utilizing graphic processing unit (GPU) |
CN103699426B (en) * | 2013-12-11 | 2017-07-28 | 四川九洲电器集团有限责任公司 | A kind of computer simulation computational methods |
CN104103092A (en) * | 2014-07-24 | 2014-10-15 | 无锡梵天信息技术股份有限公司 | Real-time dynamic shadowing realization method based on projector lamp |
CN105931286A (en) * | 2016-03-29 | 2016-09-07 | 赵岳生 | Terrain shadow real time simulation method applied to three-dimensional scene simulation GIS (geographic information system) |
WO2019015591A1 (en) * | 2017-07-21 | 2019-01-24 | 腾讯科技(深圳)有限公司 | Method for rendering game, and method, apparatus and device for generating game resource file |
CN107463398B (en) * | 2017-07-21 | 2018-08-17 | 腾讯科技(深圳)有限公司 | Game rendering intent, device, storage device and terminal |
CN107463398A (en) * | 2017-07-21 | 2017-12-12 | 腾讯科技(深圳)有限公司 | Game rendering intent, device, storage device and terminal |
US11344806B2 (en) | 2017-07-21 | 2022-05-31 | Tencent Technology (Shenzhen) Company Limited | Method for rendering game, and method, apparatus and device for generating game resource file |
CN109949401A (en) * | 2019-03-14 | 2019-06-28 | 成都风际网络科技股份有限公司 | A kind of method of the non real-time Shading Rendering of non-static object of mobile platform |
CN112836872A (en) * | 2021-01-29 | 2021-05-25 | 西安理工大学 | A high-performance numerical solution method for pollutant convection-diffusion equation based on multi-GPU |
CN112836872B (en) * | 2021-01-29 | 2023-08-18 | 西安理工大学 | Multi-GPU-based high-performance numerical solution method for pollutant convection diffusion equation |
CN113163185A (en) * | 2021-03-26 | 2021-07-23 | 复旦大学 | VR real-time self-adaptive transmission system and method based on heterogeneous calculation |
CN113421199A (en) * | 2021-06-23 | 2021-09-21 | 北京达佳互联信息技术有限公司 | Image processing method, image processing device, electronic equipment and storage medium |
CN113421199B (en) * | 2021-06-23 | 2024-03-12 | 北京达佳互联信息技术有限公司 | Image processing method, device, electronic equipment and storage medium |
CN116740254A (en) * | 2022-09-27 | 2023-09-12 | 荣耀终端有限公司 | An image processing method and terminal |
CN116740254B (en) * | 2022-09-27 | 2024-07-26 | 荣耀终端有限公司 | Image processing method and terminal |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101840566A (en) | Real-time shadow generating method based on GPU parallel calculation and system thereof | |
CN112184575B (en) | Image rendering method and device | |
McGuire et al. | Hardware-accelerated global illumination by image space photon mapping | |
CN102915559B (en) | Real-time transparent object GPU (graphic processing unit) parallel generating method based on three-dimensional point cloud | |
JP2018060556A (en) | Visibility-based state updates in graphical processing units | |
CN108335349B (en) | Filtering Image Data Using Neural Networks | |
CN114549723A (en) | Rendering method, device and device for lighting information in game scene | |
CN103500463B (en) | The method for visualizing that on a kind of GPU, multilayer shape facility merges | |
Livnat et al. | Interactive point-based isosurface extraction | |
CN103021018B (en) | Method for parallel ray tracing by building BVH tree based on graphics processing unit (GPU) | |
JP2007514230A5 (en) | ||
CN105550973B (en) | Graphics processing unit, graphics processing system and anti-aliasing processing method | |
CA2744504A1 (en) | Optimal point density using camera proximity for point-based global illumination | |
Luksch et al. | Fast light-map computation with virtual polygon lights | |
CN102915563A (en) | Method and system for transparently drawing three-dimensional grid model | |
CN102831634B (en) | Efficient accurate general soft shadow generation method | |
CN114758051A (en) | An image rendering method and related equipment | |
Vasilakis et al. | A survey of multifragment rendering | |
WO2023061364A1 (en) | Model establishment method and related apparatus | |
CN117990088A (en) | Dense visual SLAM method and system using three-dimensional Gaussian back end representation | |
CN104966313B (en) | A Geometric Shadow Map Method for Triangle Reconstruction | |
CN114757822B (en) | Binocular-based human body three-dimensional key point detection method and system | |
Yang et al. | Optimization of false-overlap detection of tile assembly in tile-based rendering | |
Li et al. | Real-time 3D graphics for mobile devices on reconfigurable hardware | |
CN118247411B (en) | Material map generation method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C12 | Rejection of a patent application after its publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20100922 |