Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
1954354f
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
1954354f
编写于
9月 03, 2020
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update from book source
上级
fc37e41b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
29 addition
and
31 deletion
+29
-31
src/pbrt/cmd/pbrt.cpp
src/pbrt/cmd/pbrt.cpp
+1
-1
src/pbrt/cpu/integrators.cpp
src/pbrt/cpu/integrators.cpp
+24
-26
src/pbrt/cpu/integrators.h
src/pbrt/cpu/integrators.h
+4
-4
未找到文件。
src/pbrt/cmd/pbrt.cpp
浏览文件 @
1954354f
...
...
@@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
ParsedScene
scene
;
ParseFiles
(
&
scene
,
filenames
);
// Render scene
// Render
the
scene
if
(
options
.
useGPU
)
GPURender
(
scene
);
else
...
...
src/pbrt/cpu/integrators.cpp
浏览文件 @
1954354f
...
...
@@ -59,10 +59,10 @@ SampledSpectrum RandomWalkIntegrator::Li(RayDifferential ray, SampledWavelengths
SamplerHandle
sampler
,
ScratchBuffer
&
scratchBuffer
,
VisibleSurface
*
visibleSurface
)
const
{
return
SafeDiv
(
RandomWalk
(
ray
,
lambda
,
sampler
,
scratchBuffer
,
0
),
lambda
.
PDF
());
return
SafeDiv
(
Li
RandomWalk
(
ray
,
lambda
,
sampler
,
scratchBuffer
,
0
),
lambda
.
PDF
());
}
SampledSpectrum
RandomWalkIntegrator
::
RandomWalk
(
RayDifferential
ray
,
SampledSpectrum
RandomWalkIntegrator
::
Li
RandomWalk
(
RayDifferential
ray
,
SampledWavelengths
&
lambda
,
SamplerHandle
sampler
,
ScratchBuffer
&
scratchBuffer
,
...
...
@@ -102,7 +102,7 @@ SampledSpectrum RandomWalkIntegrator::RandomWalk(RayDifferential ray,
// Recursively trace ray to estimate incident radiance at surface
ray
=
isect
.
SpawnRay
(
wi
);
return
L
+
beta
*
RandomWalk
(
ray
,
lambda
,
sampler
,
scratchBuffer
,
depth
+
1
);
return
L
+
beta
*
Li
RandomWalk
(
ray
,
lambda
,
sampler
,
scratchBuffer
,
depth
+
1
);
}
// Integrator Method Definitions
...
...
@@ -153,7 +153,7 @@ void ImageTileIntegrator::Render() {
ProgressReporter
progress
(
int64_t
(
spp
)
*
pixelBounds
.
Area
(),
"Rendering"
,
Options
->
quiet
);
int
startWave
=
0
,
endWave
=
1
,
waveDelta
=
1
;
int
waveStart
=
0
,
waveEnd
=
1
,
nextWaveSize
=
1
;
if
(
Options
->
recordPixelStatistics
)
StatsEnablePixelStats
(
pixelBounds
,
...
...
@@ -206,20 +206,20 @@ void ImageTileIntegrator::Render() {
}
// Render image in waves
while
(
startWave
<
spp
)
{
// Render image tiles in parallel
while
(
waveStart
<
spp
)
{
// Render
current wave's
image tiles in parallel
ParallelFor2D
(
pixelBounds
,
[
&
](
Bounds2i
tileBounds
)
{
// Render image tile given by _tileBounds_
ScratchBuffer
&
scratchBuffer
=
scratchBuffers
[
ThreadIndex
];
SamplerHandle
&
sampler
=
samplers
[
ThreadIndex
];
PBRT_DBG
(
"Starting image tile (%d,%d)-(%d,%d)
startWave %d, endWave
%d
\n
"
,
PBRT_DBG
(
"Starting image tile (%d,%d)-(%d,%d)
waveStart %d, waveEnd
%d
\n
"
,
tileBounds
.
pMin
.
x
,
tileBounds
.
pMin
.
y
,
tileBounds
.
pMax
.
x
,
tileBounds
.
pMax
.
y
,
startWave
,
endWave
);
tileBounds
.
pMax
.
y
,
waveStart
,
waveEnd
);
for
(
Point2i
pPixel
:
tileBounds
)
{
StatsReportPixelStart
(
pPixel
);
threadPixel
=
pPixel
;
// Render samples in pixel _pPixel_
for
(
int
sampleIndex
=
startWave
;
sampleIndex
<
endWave
;
++
sampleIndex
)
{
for
(
int
sampleIndex
=
waveStart
;
sampleIndex
<
waveEnd
;
++
sampleIndex
)
{
threadSampleIndex
=
sampleIndex
;
sampler
.
StartPixelSample
(
pPixel
,
sampleIndex
);
EvaluatePixelSample
(
pPixel
,
sampleIndex
,
sampler
,
scratchBuffer
);
...
...
@@ -230,31 +230,31 @@ void ImageTileIntegrator::Render() {
}
PBRT_DBG
(
"Finished image tile (%d,%d)-(%d,%d)
\n
"
,
tileBounds
.
pMin
.
x
,
tileBounds
.
pMin
.
y
,
tileBounds
.
pMax
.
x
,
tileBounds
.
pMax
.
y
);
progress
.
Update
((
endWave
-
startWave
)
*
tileBounds
.
Area
());
progress
.
Update
((
waveEnd
-
waveStart
)
*
tileBounds
.
Area
());
});
// Update start and end wave
startWave
=
endWave
;
endWave
=
std
::
min
(
spp
,
endWave
+
waveDelta
);
waveStart
=
waveEnd
;
waveEnd
=
std
::
min
(
spp
,
waveEnd
+
nextWaveSize
);
if
(
!
referenceImage
)
waveDelta
=
std
::
min
(
2
*
waveDelta
,
64
);
nextWaveSize
=
std
::
min
(
2
*
nextWaveSize
,
64
);
// Write current image to disk
LOG_VERBOSE
(
"Writing image with spp = %d"
,
startWave
);
LOG_VERBOSE
(
"Writing image with spp = %d"
,
waveStart
);
ImageMetadata
metadata
;
metadata
.
renderTimeSeconds
=
progress
.
ElapsedSeconds
();
metadata
.
samplesPerPixel
=
startWave
;
metadata
.
samplesPerPixel
=
waveStart
;
if
(
referenceImage
)
{
ImageMetadata
filmMetadata
;
Image
filmImage
=
camera
.
GetFilm
().
GetImage
(
&
filmMetadata
,
1.
f
/
startWave
);
Image
filmImage
=
camera
.
GetFilm
().
GetImage
(
&
filmMetadata
,
1.
f
/
waveStart
);
ImageChannelValues
mse
=
filmImage
.
MSE
(
filmImage
.
AllChannelsDesc
(),
*
referenceImage
);
fprintf
(
mseOutFile
,
"%d, %.9g
\n
"
,
startWave
,
mse
.
Average
());
fprintf
(
mseOutFile
,
"%d, %.9g
\n
"
,
waveStart
,
mse
.
Average
());
metadata
.
MSE
=
mse
.
Average
();
fflush
(
mseOutFile
);
}
camera
.
InitMetadata
(
&
metadata
);
camera
.
GetFilm
().
WriteImage
(
metadata
,
1.0
f
/
startWave
);
camera
.
GetFilm
().
WriteImage
(
metadata
,
1.0
f
/
waveStart
);
}
if
(
mseOutFile
)
...
...
@@ -305,14 +305,12 @@ void RayIntegrator::EvaluatePixelSample(const Point2i &pPixel, int sampleIndex,
// Issue warning if unexpected radiance value is returned
if
(
L
.
HasNaNs
())
{
LOG_ERROR
(
"Not-a-number radiance value returned for pixel (%d, "
"%d), sample %d. "
"Setting to black."
,
"%d), sample %d. Setting to black."
,
pPixel
.
x
,
pPixel
.
y
,
sampleIndex
);
L
=
SampledSpectrum
(
0.
f
);
}
else
if
(
IsInf
(
L
.
y
(
lambda
)))
{
LOG_ERROR
(
"Infinite radiance value returned for pixel (%d, %d), "
"sample %d. "
"Setting to black."
,
"sample %d. Setting to black."
,
pPixel
.
x
,
pPixel
.
y
,
sampleIndex
);
L
=
SampledSpectrum
(
0.
f
);
}
...
...
src/pbrt/cpu/integrators.h
浏览文件 @
1954354f
...
...
@@ -117,7 +117,7 @@ class RayIntegrator : public ImageTileIntegrator {
virtual
SampledSpectrum
Li
(
RayDifferential
ray
,
SampledWavelengths
&
lambda
,
SamplerHandle
sampler
,
ScratchBuffer
&
scratchBuffer
,
VisibleSurface
*
visibleSurface
=
nullptr
)
const
=
0
;
VisibleSurface
*
visibleSurface
)
const
=
0
;
};
// RandomWalkIntegrator Definition
...
...
@@ -139,7 +139,7 @@ class RandomWalkIntegrator : public RayIntegrator {
private:
// RandomWalkIntegrator Private Methods
SampledSpectrum
RandomWalk
(
RayDifferential
ray
,
SampledWavelengths
&
lambda
,
SampledSpectrum
Li
RandomWalk
(
RayDifferential
ray
,
SampledWavelengths
&
lambda
,
SamplerHandle
sampler
,
ScratchBuffer
&
scratchBuffer
,
int
depth
)
const
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录