Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
2e759a5a
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,发现更多精彩内容 >>
提交
2e759a5a
编写于
8月 27, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update from book source. No functional changes.
Just variable renaming and formatting...
上级
4fa5af5e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
38 deletion
+43
-38
src/pbrt/cameras.h
src/pbrt/cameras.h
+1
-2
src/pbrt/interaction.cpp
src/pbrt/interaction.cpp
+21
-17
src/pbrt/scene.cpp
src/pbrt/scene.cpp
+4
-5
src/pbrt/util/parallel.h
src/pbrt/util/parallel.h
+1
-0
src/pbrt/util/pstd.cpp
src/pbrt/util/pstd.cpp
+1
-0
src/pbrt/wavefront/integrator.cpp
src/pbrt/wavefront/integrator.cpp
+2
-3
src/pbrt/wavefront/surfscatter.cpp
src/pbrt/wavefront/surfscatter.cpp
+13
-11
未找到文件。
src/pbrt/cameras.h
浏览文件 @
2e759a5a
...
...
@@ -156,11 +156,10 @@ class CameraBase {
Vector3f
*
dpdx
,
Vector3f
*
dpdy
)
const
{
// Compute tangent plane equation for ray differential intersections
Point3f
pCamera
=
CameraFromRender
(
p
,
time
);
Normal3f
nCamera
=
CameraFromRender
(
n
,
time
);
Transform
DownZFromCamera
=
RotateFromTo
(
Normalize
(
Vector3f
(
pCamera
)),
Vector3f
(
0
,
0
,
1
));
Point3f
pDownZ
=
DownZFromCamera
(
pCamera
);
Normal3f
nDownZ
=
DownZFromCamera
(
nCamera
);
Normal3f
nDownZ
=
DownZFromCamera
(
CameraFromRender
(
n
,
time
)
);
Float
d
=
Dot
(
nDownZ
,
Vector3f
(
pDownZ
));
// Find intersection points for approximated camera differential rays
...
...
src/pbrt/interaction.cpp
浏览文件 @
2e759a5a
...
...
@@ -42,7 +42,7 @@ void SurfaceInteraction::ComputeDifferentials(const RayDifferential &ray, Camera
int
samplesPerPixel
)
{
if
(
ray
.
hasDifferentials
&&
Dot
(
n
,
ray
.
rxDirection
)
!=
0
&&
Dot
(
n
,
ray
.
ryDirection
)
!=
0
)
{
// Estimate screen-space change in $\pt{}$
// Estimate screen-space change in $\pt{}$
using ray differentials
// Compute auxiliary intersection points with plane, _px_ and _py_
Float
d
=
-
Dot
(
n
,
Vector3f
(
p
()));
Float
tx
=
(
-
Dot
(
n
,
Vector3f
(
ray
.
rxOrigin
))
-
d
)
/
Dot
(
n
,
ray
.
rxDirection
);
...
...
@@ -55,24 +55,28 @@ void SurfaceInteraction::ComputeDifferentials(const RayDifferential &ray, Camera
dpdx
=
px
-
p
();
dpdy
=
py
-
p
();
}
else
}
else
{
// Approximate screen-space change in $\pt{}$ based on camera projection
camera
.
Approximate_dp_dxy
(
p
(),
n
,
time
,
samplesPerPixel
,
&
dpdx
,
&
dpdy
);
}
// Estimate screen-space change in $(u,v)$
Float
a00
=
Dot
(
dpdu
,
dpdu
),
a01
=
Dot
(
dpdu
,
dpdv
),
a11
=
Dot
(
dpdv
,
dpdv
);
Float
invDet
=
1
/
(
DifferenceOfProducts
(
a00
,
a11
,
a01
,
a01
));
Float
b0x
=
Dot
(
dpdu
,
dpdx
),
b1x
=
Dot
(
dpdv
,
dpdx
);
Float
b0y
=
Dot
(
dpdu
,
dpdy
),
b1y
=
Dot
(
dpdv
,
dpdy
);
/* Set the UV partials to zero if dpdu and/or dpdv == 0 */
// Compute $\transpose{\XFORM{A}} \XFORM{A}$ and its determinant
Float
ata00
=
Dot
(
dpdu
,
dpdu
),
ata01
=
Dot
(
dpdu
,
dpdv
);
Float
ata11
=
Dot
(
dpdv
,
dpdv
);
Float
invDet
=
1
/
(
DifferenceOfProducts
(
ata00
,
ata11
,
ata01
,
ata01
));
invDet
=
IsFinite
(
invDet
)
?
invDet
:
0.
f
;
dudx
=
DifferenceOfProducts
(
a11
,
b0x
,
a01
,
b1x
)
*
invDet
;
dvdx
=
DifferenceOfProducts
(
a00
,
b1x
,
a01
,
b0x
)
*
invDet
;
// Compute $\transpose{\XFORM{A}} \VEC{b}$ for $x$ and $y$
Float
atb0x
=
Dot
(
dpdu
,
dpdx
),
atb1x
=
Dot
(
dpdv
,
dpdx
);
Float
atb0y
=
Dot
(
dpdu
,
dpdy
),
atb1y
=
Dot
(
dpdv
,
dpdy
);
dudy
=
DifferenceOfProducts
(
a11
,
b0y
,
a01
,
b1y
)
*
invDet
;
dvdy
=
DifferenceOfProducts
(
a00
,
b1y
,
a01
,
b0y
)
*
invDet
;
// Compute $u$ and $v$ partial derivatives with respect to $x$ and $y$
dudx
=
DifferenceOfProducts
(
ata11
,
atb0x
,
ata01
,
atb1x
)
*
invDet
;
dvdx
=
DifferenceOfProducts
(
ata00
,
atb1x
,
ata01
,
atb0x
)
*
invDet
;
dudy
=
DifferenceOfProducts
(
ata11
,
atb0y
,
ata01
,
atb1y
)
*
invDet
;
dvdy
=
DifferenceOfProducts
(
ata00
,
atb1y
,
ata01
,
atb0y
)
*
invDet
;
// Clamp partial derivatives of $u$ and $v$ to reasonable values
dudx
=
IsFinite
(
dudx
)
?
Clamp
(
dudx
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
dvdx
=
IsFinite
(
dvdx
)
?
Clamp
(
dvdx
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
dudy
=
IsFinite
(
dudy
)
?
Clamp
(
dudy
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
...
...
@@ -106,12 +110,12 @@ RayDifferential SurfaceInteraction::SpawnRay(const RayDifferential &rayi,
rd
.
ryOrigin
=
p
()
+
dpdy
;
// Compute differential reflected directions
Float
dwoDot
N
dx
=
Dot
(
dwodx
,
ns
)
+
Dot
(
wo
,
dndx
);
Float
dwoDot
N
dy
=
Dot
(
dwody
,
ns
)
+
Dot
(
wo
,
dndy
);
Float
dwoDot
n_
dx
=
Dot
(
dwodx
,
ns
)
+
Dot
(
wo
,
dndx
);
Float
dwoDot
n_
dy
=
Dot
(
dwody
,
ns
)
+
Dot
(
wo
,
dndy
);
rd
.
rxDirection
=
wi
-
dwodx
+
2
*
Vector3f
(
Dot
(
wo
,
ns
)
*
dndx
+
dwoDot
N
dx
*
ns
);
wi
-
dwodx
+
2
*
Vector3f
(
Dot
(
wo
,
ns
)
*
dndx
+
dwoDot
n_
dx
*
ns
);
rd
.
ryDirection
=
wi
-
dwody
+
2
*
Vector3f
(
Dot
(
wo
,
ns
)
*
dndy
+
dwoDot
N
dy
*
ns
);
wi
-
dwody
+
2
*
Vector3f
(
Dot
(
wo
,
ns
)
*
dndy
+
dwoDot
n_
dy
*
ns
);
}
else
if
(
flags
==
BxDFFlags
::
SpecularTransmission
)
{
// Initialize origins of specular differential rays
...
...
src/pbrt/scene.cpp
浏览文件 @
2e759a5a
...
...
@@ -686,7 +686,7 @@ void BasicSceneBuilder::AreaLightSource(const std::string &name,
void
BasicScene
::
SetOptions
(
SceneEntity
filter
,
SceneEntity
film
,
CameraSceneEntity
camera
,
SceneEntity
sampler
,
SceneEntity
integ
,
SceneEntity
accel
)
{
// Store information for specifi
c
ed integrator and accelerator
// Store information for specified integrator and accelerator
filmColorSpace
=
film
.
parameters
.
ColorSpace
();
integrator
=
integ
;
accelerator
=
accel
;
...
...
@@ -767,7 +767,7 @@ Medium BasicScene::GetMedium(const std::string &name, const FileLoc *loc) {
Medium
m
=
iter
->
second
;
mediaMutex
.
unlock
();
return
m
;
}
else
{
}
else
{
auto
fiter
=
mediumFutures
.
find
(
name
);
if
(
fiter
==
mediumFutures
.
end
())
ErrorExit
(
loc
,
"%s: medium is not defined."
,
name
);
...
...
@@ -795,11 +795,10 @@ std::map<std::string, Medium> BasicScene::CreateMedia() {
mediaMap
[
m
.
first
]
=
*
med
;
}
}
LOG_VERBOSE
(
"Consume media futures finished"
);
mediumFutures
.
clear
();
}
mediumFutures
.
clear
();
mediaMutex
.
unlock
();
LOG_VERBOSE
(
"Consume media futures finished"
);
return
mediaMap
;
}
...
...
src/pbrt/util/parallel.h
浏览文件 @
2e759a5a
...
...
@@ -362,6 +362,7 @@ class Future {
Wait
();
return
fut
.
get
();
}
pstd
::
optional
<
T
>
TryGet
(
std
::
mutex
*
mutex
)
{
if
(
IsReady
())
return
Get
();
...
...
src/pbrt/util/pstd.cpp
浏览文件 @
2e759a5a
...
...
@@ -75,6 +75,7 @@ void *monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
// so this is tied to pbrt's current usage of them...
CHECK
(
constructTID
==
std
::
this_thread
::
get_id
());
#endif
if
(
bytes
>
block_size
)
// We've got a big allocation; let the current block be so that
// smaller allocations have a chance at using up more of it.
...
...
src/pbrt/wavefront/integrator.cpp
浏览文件 @
2e759a5a
...
...
@@ -79,9 +79,8 @@ static void updateMaterialNeeds(
WavefrontPathIntegrator
::
WavefrontPathIntegrator
(
pstd
::
pmr
::
memory_resource
*
memoryResource
,
BasicScene
&
scene
)
:
memoryResource
(
memoryResource
)
{
ThreadLocal
<
Allocator
>
threadAllocators
([
memoryResource
]()
{
return
Allocator
(
memoryResource
);
});
ThreadLocal
<
Allocator
>
threadAllocators
(
[
memoryResource
]()
{
return
Allocator
(
memoryResource
);
});
Allocator
alloc
=
threadAllocators
.
Get
();
...
...
src/pbrt/wavefront/surfscatter.cpp
浏览文件 @
2e759a5a
...
...
@@ -72,21 +72,23 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue
&
dpdy
);
Vector3f
dpdu
=
w
.
dpdu
,
dpdv
=
w
.
dpdv
;
// Estimate screen-space change in $(u,v)$
Float
a00
=
Dot
(
dpdu
,
dpdu
),
a01
=
Dot
(
dpdu
,
dpdv
),
a11
=
Dot
(
dpdv
,
dpdv
);
Float
invDet
=
1
/
(
DifferenceOfProducts
(
a00
,
a11
,
a01
,
a01
));
Float
b0x
=
Dot
(
dpdu
,
dpdx
),
b1x
=
Dot
(
dpdv
,
dpdx
);
Float
b0y
=
Dot
(
dpdu
,
dpdy
),
b1y
=
Dot
(
dpdv
,
dpdy
);
/* Set the UV partials to zero if dpdu and/or dpdv == 0 */
// Compute $\transpose{\XFORM{A}} \XFORM{A}$ and its determinant
Float
ata00
=
Dot
(
dpdu
,
dpdu
),
ata01
=
Dot
(
dpdu
,
dpdv
);
Float
ata11
=
Dot
(
dpdv
,
dpdv
);
Float
invDet
=
1
/
(
DifferenceOfProducts
(
ata00
,
ata11
,
ata01
,
ata01
));
invDet
=
IsFinite
(
invDet
)
?
invDet
:
0.
f
;
dudx
=
DifferenceOfProducts
(
a11
,
b0x
,
a01
,
b1x
)
*
invDet
;
dvdx
=
DifferenceOfProducts
(
a00
,
b1x
,
a01
,
b0x
)
*
invDet
;
// Compute $\transpose{\XFORM{A}} \VEC{b}$ for $x$ and $y$
Float
atb0x
=
Dot
(
dpdu
,
dpdx
),
atb1x
=
Dot
(
dpdv
,
dpdx
);
Float
atb0y
=
Dot
(
dpdu
,
dpdy
),
atb1y
=
Dot
(
dpdv
,
dpdy
);
dudy
=
DifferenceOfProducts
(
a11
,
b0y
,
a01
,
b1y
)
*
invDet
;
dvdy
=
DifferenceOfProducts
(
a00
,
b1y
,
a01
,
b0y
)
*
invDet
;
// Compute $u$ and $v$ partial derivatives with respect to $x$ and $y$
dudx
=
DifferenceOfProducts
(
ata11
,
atb0x
,
ata01
,
atb1x
)
*
invDet
;
dvdx
=
DifferenceOfProducts
(
ata00
,
atb1x
,
ata01
,
atb0x
)
*
invDet
;
dudy
=
DifferenceOfProducts
(
ata11
,
atb0y
,
ata01
,
atb1y
)
*
invDet
;
dvdy
=
DifferenceOfProducts
(
ata00
,
atb1y
,
ata01
,
atb0y
)
*
invDet
;
// Clamp partial derivatives of $u$ and $v$ to reasonable values
dudx
=
IsFinite
(
dudx
)
?
Clamp
(
dudx
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
dvdx
=
IsFinite
(
dvdx
)
?
Clamp
(
dvdx
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
dudy
=
IsFinite
(
dudy
)
?
Clamp
(
dudy
,
-
1e8
f
,
1e8
f
)
:
0.
f
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录