Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
61933b85
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pbrt-v4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
61933b85
编写于
1月 09, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GPU: support multiple infinite lights
上级
914af265
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
34 deletion
+35
-34
src/pbrt/gpu/pathintegrator.cpp
src/pbrt/gpu/pathintegrator.cpp
+34
-33
src/pbrt/gpu/pathintegrator.h
src/pbrt/gpu/pathintegrator.h
+1
-1
未找到文件。
src/pbrt/gpu/pathintegrator.cpp
浏览文件 @
61933b85
...
...
@@ -50,7 +50,8 @@ namespace pbrt {
STAT_MEMORY_COUNTER
(
"Memory/GPU path integrator pixel state"
,
pathIntegratorBytes
);
GPUPathIntegrator
::
GPUPathIntegrator
(
Allocator
alloc
,
const
ParsedScene
&
scene
)
{
GPUPathIntegrator
::
GPUPathIntegrator
(
Allocator
alloc
,
const
ParsedScene
&
scene
)
:
envLights
(
alloc
)
{
// Allocate all of the data structures that represent the scene...
std
::
map
<
std
::
string
,
MediumHandle
>
media
=
scene
.
CreateMedia
(
alloc
);
...
...
@@ -110,10 +111,7 @@ GPUPathIntegrator::GPUPathIntegrator(Allocator alloc, const ParsedScene &scene)
if
(
l
.
Is
<
UniformInfiniteLight
>
()
||
l
.
Is
<
ImageInfiniteLight
>
()
||
l
.
Is
<
PortalImageInfiniteLight
>
())
{
if
(
envLight
)
Warning
(
&
light
.
loc
,
"Multiple infinite lights specified. Using this one."
);
envLight
=
l
;
envLights
.
push_back
(
l
);
}
allLights
.
push_back
(
l
);
...
...
@@ -216,7 +214,7 @@ GPUPathIntegrator::GPUPathIntegrator(Allocator alloc, const ParsedScene &scene)
alloc
.
new_object
<
SubsurfaceScatterQueue
>
(
maxQueueSize
,
alloc
);
}
if
(
envLight
)
if
(
envLight
s
.
size
()
)
escapedRayQueue
=
alloc
.
new_object
<
EscapedRayQueue
>
(
maxQueueSize
,
alloc
);
hitAreaLightQueue
=
alloc
.
new_object
<
HitAreaLightQueue
>
(
maxQueueSize
,
alloc
);
...
...
@@ -449,37 +447,40 @@ void GPUPathIntegrator::HandleEscapedRays(int depth) {
"Handle escaped rays"
,
escapedRayQueue
,
maxQueueSize
,
PBRT_GPU_LAMBDA
(
const
EscapedRayWorkItem
w
)
{
// Update pixel radiance for escaped ray
SampledSpectrum
Le
=
envLight
.
Le
(
Ray
(
w
.
rayo
,
w
.
rayd
),
w
.
lambda
);
if
(
!
Le
)
return
;
// Compute path radiance contribution from infinite light
SampledSpectrum
L
(
0.
f
);
PBRT_DBG
(
"L %f %f %f %f T_hat %f %f %f %f Le %f %f %f %f"
,
L
[
0
],
L
[
1
],
L
[
2
],
L
[
3
],
w
.
T_hat
[
0
],
w
.
T_hat
[
1
],
w
.
T_hat
[
2
],
w
.
T_hat
[
3
],
Le
[
0
],
Le
[
1
],
Le
[
2
],
Le
[
3
]);
PBRT_DBG
(
"pdf uni %f %f %f %f pdf nee %f %f %f %f"
,
w
.
uniPathPDF
[
0
],
w
.
uniPathPDF
[
1
],
w
.
uniPathPDF
[
2
],
w
.
uniPathPDF
[
3
],
w
.
lightPathPDF
[
0
],
w
.
lightPathPDF
[
1
],
w
.
lightPathPDF
[
2
],
w
.
lightPathPDF
[
3
]);
if
(
depth
==
0
||
w
.
specularBounce
)
{
L
=
w
.
T_hat
*
Le
/
w
.
uniPathPDF
.
Average
();
}
else
{
// Compute MIS-weighted radiance contribution from infinite light
LightSampleContext
ctx
=
w
.
prevIntrCtx
;
Float
lightChoicePDF
=
lightSampler
.
PDF
(
ctx
,
envLight
);
SampledSpectrum
lightPathPDF
=
w
.
lightPathPDF
*
lightChoicePDF
*
envLight
.
PDF_Li
(
ctx
,
w
.
rayd
,
LightSamplingMode
::
WithMIS
);
L
=
w
.
T_hat
*
Le
/
(
w
.
uniPathPDF
+
lightPathPDF
).
Average
();
for
(
const
auto
&
light
:
envLights
)
{
if
(
SampledSpectrum
Le
=
light
.
Le
(
Ray
(
w
.
rayo
,
w
.
rayd
),
w
.
lambda
);
Le
)
{
// Compute path radiance contribution from infinite light
PBRT_DBG
(
"L %f %f %f %f T_hat %f %f %f %f Le %f %f %f %f"
,
L
[
0
],
L
[
1
],
L
[
2
],
L
[
3
],
w
.
T_hat
[
0
],
w
.
T_hat
[
1
],
w
.
T_hat
[
2
],
w
.
T_hat
[
3
],
Le
[
0
],
Le
[
1
],
Le
[
2
],
Le
[
3
]);
PBRT_DBG
(
"pdf uni %f %f %f %f pdf nee %f %f %f %f"
,
w
.
uniPathPDF
[
0
],
w
.
uniPathPDF
[
1
],
w
.
uniPathPDF
[
2
],
w
.
uniPathPDF
[
3
],
w
.
lightPathPDF
[
0
],
w
.
lightPathPDF
[
1
],
w
.
lightPathPDF
[
2
],
w
.
lightPathPDF
[
3
]);
if
(
depth
==
0
||
w
.
specularBounce
)
{
L
+=
w
.
T_hat
*
Le
/
w
.
uniPathPDF
.
Average
();
}
else
{
// Compute MIS-weighted radiance contribution from infinite light
LightSampleContext
ctx
=
w
.
prevIntrCtx
;
Float
lightChoicePDF
=
lightSampler
.
PDF
(
ctx
,
light
);
SampledSpectrum
lightPathPDF
=
w
.
lightPathPDF
*
lightChoicePDF
*
light
.
PDF_Li
(
ctx
,
w
.
rayd
,
LightSamplingMode
::
WithMIS
);
L
+=
w
.
T_hat
*
Le
/
(
w
.
uniPathPDF
+
lightPathPDF
).
Average
();
}
}
}
L
=
SafeDiv
(
L
,
w
.
lambda
.
PDF
());
if
(
L
)
{
L
=
SafeDiv
(
L
,
w
.
lambda
.
PDF
());
PBRT_DBG
(
"Added L %f %f %f %f for escaped ray pixel index %d
\n
"
,
L
[
0
],
L
[
1
],
L
[
2
],
L
[
3
],
w
.
pixelIndex
);
PBRT_DBG
(
"Added L %f %f %f %f for escaped ray pixel index %d
\n
"
,
L
[
0
],
L
[
1
],
L
[
2
],
L
[
3
],
w
.
pixelIndex
);
L
+=
pixelSampleState
.
L
[
w
.
pixelIndex
];
pixelSampleState
.
L
[
w
.
pixelIndex
]
=
L
;
L
+=
pixelSampleState
.
L
[
w
.
pixelIndex
];
pixelSampleState
.
L
[
w
.
pixelIndex
]
=
L
;
}
});
}
...
...
src/pbrt/gpu/pathintegrator.h
浏览文件 @
61933b85
...
...
@@ -100,7 +100,7 @@ class GPUPathIntegrator {
FilmHandle
film
;
SamplerHandle
sampler
;
CameraHandle
camera
;
LightHandle
envLight
;
pstd
::
vector
<
LightHandle
>
envLights
;
LightSamplerHandle
lightSampler
;
int
maxDepth
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录