Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
50acd8a5
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,发现更多精彩内容 >>
提交
50acd8a5
编写于
8月 17, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update from book source. No functional changes.
上级
f7028c27
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
38 deletion
+37
-38
src/pbrt/gpu/optix.cu
src/pbrt/gpu/optix.cu
+1
-1
src/pbrt/wavefront/aggregate.cpp
src/pbrt/wavefront/aggregate.cpp
+1
-1
src/pbrt/wavefront/integrator.cpp
src/pbrt/wavefront/integrator.cpp
+1
-1
src/pbrt/wavefront/intersect.h
src/pbrt/wavefront/intersect.h
+6
-6
src/pbrt/wavefront/media.cpp
src/pbrt/wavefront/media.cpp
+10
-11
src/pbrt/wavefront/surfscatter.cpp
src/pbrt/wavefront/surfscatter.cpp
+4
-3
src/pbrt/wavefront/workitems.h
src/pbrt/wavefront/workitems.h
+11
-12
src/pbrt/wavefront/workitems.soa
src/pbrt/wavefront/workitems.soa
+3
-3
未找到文件。
src/pbrt/gpu/optix.cu
浏览文件 @
50acd8a5
...
...
@@ -258,7 +258,7 @@ extern "C" __global__ void __raygen__shadow() {
Trace
(
params
.
traversable
,
sr
.
ray
,
1e-5
f
/* tMin */
,
sr
.
tMax
,
OPTIX_RAY_FLAG_NONE
,
missed
);
RecordShadowRay
Intersection
(
sr
,
&
params
.
pixelSampleState
,
!
missed
);
RecordShadowRay
Result
(
sr
,
&
params
.
pixelSampleState
,
!
missed
);
}
extern
"C"
__global__
void
__miss__shadow
()
{
...
...
src/pbrt/wavefront/aggregate.cpp
浏览文件 @
50acd8a5
...
...
@@ -59,7 +59,7 @@ void CPUAggregate::IntersectShadow(int maxRays, ShadowRayQueue *shadowRayQueue,
ParallelFor
(
0
,
shadowRayQueue
->
Size
(),
[
=
](
int
index
)
{
const
ShadowRayWorkItem
w
=
(
*
shadowRayQueue
)[
index
];
bool
hit
=
aggregate
.
IntersectP
(
w
.
ray
,
w
.
tMax
);
RecordShadowRay
Intersection
(
w
,
pixelSampleState
,
hit
);
RecordShadowRay
Result
(
w
,
pixelSampleState
,
hit
);
});
}
...
...
src/pbrt/wavefront/integrator.cpp
浏览文件 @
50acd8a5
...
...
@@ -630,7 +630,7 @@ void WavefrontPathIntegrator::HandleEmissiveIntersection() {
// Compute area light's weighted radiance contribution to the path
SampledSpectrum
L
(
0.
f
);
if
(
w
.
depth
==
0
||
w
.
isS
pecularBounce
)
{
if
(
w
.
depth
==
0
||
w
.
s
pecularBounce
)
{
L
=
w
.
T_hat
*
Le
/
w
.
uniPathPDF
.
Average
();
}
else
{
// Compute MIS-weighted radiance contribution from area light
...
...
src/pbrt/wavefront/intersect.h
浏览文件 @
50acd8a5
...
...
@@ -28,9 +28,9 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterMiss(RayWorkItem r,
}
}
inline
PBRT_CPU_GPU
void
RecordShadowRay
Intersection
(
const
ShadowRayWorkItem
w
,
SOA
<
PixelSampleState
>
*
pixelSampleState
,
bool
foundIntersection
)
{
inline
PBRT_CPU_GPU
void
RecordShadowRay
Result
(
const
ShadowRayWorkItem
w
,
SOA
<
PixelSampleState
>
*
pixelSampleState
,
bool
foundIntersection
)
{
if
(
foundIntersection
)
{
PBRT_DBG
(
"Shadow ray was occluded
\n
"
);
return
;
...
...
@@ -66,7 +66,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
r
.
lightPathPDF
,
r
.
pixelIndex
,
r
.
prevIntrCtx
,
r
.
isS
pecularBounce
,
r
.
s
pecularBounce
,
r
.
anyNonSpecularBounces
,
r
.
etaScale
,
intr
.
areaLight
,
...
...
@@ -103,7 +103,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
Ray
newRay
=
intr
.
SpawnRay
(
r
.
ray
.
d
);
nextRayQueue
->
PushIndirectRay
(
newRay
,
r
.
depth
,
r
.
prevIntrCtx
,
r
.
T_hat
,
r
.
uniPathPDF
,
r
.
lightPathPDF
,
r
.
lambda
,
r
.
etaScale
,
r
.
isS
pecularBounce
,
r
.
anyNonSpecularBounces
,
r
.
s
pecularBounce
,
r
.
anyNonSpecularBounces
,
r
.
pixelIndex
);
return
;
}
...
...
@@ -116,7 +116,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
hitAreaLightQueue
->
Push
(
HitAreaLightWorkItem
{
intr
.
areaLight
,
intr
.
p
(),
intr
.
n
,
intr
.
uv
,
intr
.
wo
,
r
.
lambda
,
r
.
depth
,
r
.
T_hat
,
r
.
uniPathPDF
,
r
.
lightPathPDF
,
r
.
prevIntrCtx
,
(
int
)
r
.
isS
pecularBounce
,
r
.
pixelIndex
});
r
.
prevIntrCtx
,
(
int
)
r
.
s
pecularBounce
,
r
.
pixelIndex
});
}
FloatTexture
displacement
=
material
.
GetDisplacement
();
...
...
src/pbrt/wavefront/media.cpp
浏览文件 @
50acd8a5
...
...
@@ -181,10 +181,9 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
if
(
escapedRayQueue
)
{
PBRT_DBG
(
"Adding ray to escapedRayQueue pixel index %d depth %d
\n
"
,
w
.
pixelIndex
,
w
.
depth
);
escapedRayQueue
->
Push
(
EscapedRayWorkItem
{
ray
.
o
,
ray
.
d
,
w
.
depth
,
lambda
,
w
.
pixelIndex
,
T_hat
,
(
int
)
w
.
isSpecularBounce
,
uniPathPDF
,
lightPathPDF
,
w
.
prevIntrCtx
});
escapedRayQueue
->
Push
(
EscapedRayWorkItem
{
ray
.
o
,
ray
.
d
,
w
.
depth
,
lambda
,
w
.
pixelIndex
,
T_hat
,
(
int
)
w
.
specularBounce
,
uniPathPDF
,
lightPathPDF
,
w
.
prevIntrCtx
});
}
return
;
}
...
...
@@ -207,7 +206,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
Ray
newRay
=
intr
.
SpawnRay
(
ray
.
d
);
nextRayQueue
->
PushIndirectRay
(
newRay
,
w
.
depth
,
w
.
prevIntrCtx
,
T_hat
,
uniPathPDF
,
lightPathPDF
,
lambda
,
w
.
etaScale
,
w
.
isS
pecularBounce
,
w
.
etaScale
,
w
.
s
pecularBounce
,
w
.
anyNonSpecularBounces
,
w
.
pixelIndex
);
return
;
}
...
...
@@ -217,10 +216,10 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
"Ray hit an area light: adding to hitAreaLightQueue pixel index %d "
"depth %d
\n
"
,
w
.
pixelIndex
,
w
.
depth
);
hitAreaLightQueue
->
Push
(
HitAreaLightWorkItem
{
w
.
areaLight
,
Point3f
(
w
.
pi
),
w
.
n
,
w
.
uv
,
-
ray
.
d
,
lambda
,
w
.
depth
,
T_hat
,
uniPathPDF
,
lightPathPDF
,
w
.
prevIntrCtx
,
w
.
isSpecularBounce
,
w
.
pixelIndex
});
hitAreaLightQueue
->
Push
(
HitAreaLightWorkItem
{
w
.
areaLight
,
Point3f
(
w
.
pi
),
w
.
n
,
w
.
uv
,
-
ray
.
d
,
lambda
,
w
.
depth
,
T_hat
,
uniPathPDF
,
lightPathPDF
,
w
.
prevIntrCtx
,
w
.
specularBounce
,
w
.
pixelIndex
});
}
FloatTexture
displacement
=
material
.
GetDisplacement
();
...
...
@@ -355,13 +354,13 @@ void WavefrontPathIntegrator::SampleMediumScattering(int wavefrontDepth) {
}
Ray
ray
(
w
.
p
,
phaseSample
->
wi
,
w
.
time
,
w
.
medium
);
bool
isS
pecularBounce
=
false
;
bool
s
pecularBounce
=
false
;
bool
anyNonSpecularBounces
=
true
;
// Spawn indirect ray.
nextRayQueue
->
PushIndirectRay
(
ray
,
w
.
depth
+
1
,
ctx
,
T_hat
,
uniPathPDF
,
lightPathPDF
,
w
.
lambda
,
w
.
etaScale
,
isS
pecularBounce
,
anyNonSpecularBounces
,
w
.
pixelIndex
);
w
.
etaScale
,
s
pecularBounce
,
anyNonSpecularBounces
,
w
.
pixelIndex
);
PBRT_DBG
(
"Enqueuing indirect medium ray at depth %d pixel index %d
\n
"
,
w
.
depth
+
1
,
w
.
pixelIndex
);
});
...
...
src/pbrt/wavefront/surfscatter.cpp
浏览文件 @
50acd8a5
...
...
@@ -71,15 +71,15 @@ template <typename ConcreteMaterial, typename TextureEvaluator>
void
WavefrontPathIntegrator
::
EvaluateMaterialAndBSDF
(
MaterialEvalQueue
*
evalQueue
,
int
wavefrontDepth
)
{
// Get BSDF for items in _evalQueue_ and sample illumination
// Construct _
name_ for material/texture evaluator
kernel
std
::
string
name
=
StringPrintf
(
// Construct _
desc_ for material/texture evaluation
kernel
std
::
string
desc
=
StringPrintf
(
"%s + BxDF eval (%s tex)"
,
ConcreteMaterial
::
Name
(),
std
::
is_same_v
<
TextureEvaluator
,
BasicTextureEvaluator
>
?
"Basic"
:
"Universal"
);
RayQueue
*
nextRayQueue
=
NextRayQueue
(
wavefrontDepth
);
auto
queue
=
evalQueue
->
Get
<
MaterialEvalWorkItem
<
ConcreteMaterial
>>
();
ForAllQueued
(
name
.
c_str
(),
queue
,
maxQueueSize
,
desc
.
c_str
(),
queue
,
maxQueueSize
,
PBRT_CPU_GPU_LAMBDA
(
const
MaterialEvalWorkItem
<
ConcreteMaterial
>
w
)
{
// Evaluate material and BSDF for ray intersection
TextureEvaluator
texEval
;
...
...
@@ -116,6 +116,7 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue
FloatTexture
displacement
=
w
.
material
->
GetDisplacement
();
const
Image
*
normalMap
=
w
.
material
->
GetNormalMap
();
if
(
displacement
||
normalMap
)
{
// Call _Bump()_ to find shading geometry
if
(
displacement
)
DCHECK
(
texEval
.
CanEvaluate
({
displacement
},
{}));
BumpEvalContext
bctx
=
w
.
GetBumpEvalContext
(
dudx
,
dudy
,
dvdx
,
dvdy
);
...
...
src/pbrt/wavefront/workitems.h
浏览文件 @
50acd8a5
...
...
@@ -139,7 +139,7 @@ struct RayWorkItem {
SampledSpectrum
T_hat
,
uniPathPDF
,
lightPathPDF
;
LightSampleContext
prevIntrCtx
;
Float
etaScale
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
int
anyNonSpecularBounces
;
};
...
...
@@ -169,7 +169,7 @@ struct HitAreaLightWorkItem {
int
depth
;
SampledSpectrum
T_hat
,
uniPathPDF
,
lightPathPDF
;
LightSampleContext
prevIntrCtx
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
int
pixelIndex
;
};
...
...
@@ -241,7 +241,7 @@ struct MediumSampleWorkItem {
SampledSpectrum
lightPathPDF
;
int
pixelIndex
;
LightSampleContext
prevIntrCtx
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
int
anyNonSpecularBounces
;
Float
etaScale
;
...
...
@@ -353,8 +353,7 @@ class RayQueue : public WorkQueue<RayWorkItem> {
const
SampledSpectrum
&
T_hat
,
const
SampledSpectrum
&
uniPathPDF
,
const
SampledSpectrum
&
lightPathPDF
,
const
SampledWavelengths
&
lambda
,
Float
etaScale
,
bool
isSpecularBounce
,
bool
anyNonSpecularBounces
,
int
pixelIndex
);
bool
specularBounce
,
bool
anyNonSpecularBounces
,
int
pixelIndex
);
};
// RayQueue Inline Methods
...
...
@@ -371,7 +370,7 @@ inline int RayQueue::PushCameraRay(const Ray &ray, const SampledWavelengths &lam
this
->
anyNonSpecularBounces
[
index
]
=
false
;
this
->
uniPathPDF
[
index
]
=
SampledSpectrum
(
1.
f
);
this
->
lightPathPDF
[
index
]
=
SampledSpectrum
(
1.
f
);
this
->
isS
pecularBounce
[
index
]
=
false
;
this
->
s
pecularBounce
[
index
]
=
false
;
return
index
;
}
...
...
@@ -380,7 +379,7 @@ inline int RayQueue::PushIndirectRay(
const
Ray
&
ray
,
int
depth
,
const
LightSampleContext
&
prevIntrCtx
,
const
SampledSpectrum
&
T_hat
,
const
SampledSpectrum
&
uniPathPDF
,
const
SampledSpectrum
&
lightPathPDF
,
const
SampledWavelengths
&
lambda
,
Float
etaScale
,
bool
isS
pecularBounce
,
bool
anyNonSpecularBounces
,
int
pixelIndex
)
{
bool
s
pecularBounce
,
bool
anyNonSpecularBounces
,
int
pixelIndex
)
{
int
index
=
AllocateEntry
();
DCHECK
(
!
ray
.
HasNaN
());
this
->
ray
[
index
]
=
ray
;
...
...
@@ -392,7 +391,7 @@ inline int RayQueue::PushIndirectRay(
this
->
lightPathPDF
[
index
]
=
lightPathPDF
;
this
->
lambda
[
index
]
=
lambda
;
this
->
anyNonSpecularBounces
[
index
]
=
anyNonSpecularBounces
;
this
->
isSpecularBounce
[
index
]
=
isS
pecularBounce
;
this
->
specularBounce
[
index
]
=
s
pecularBounce
;
this
->
etaScale
[
index
]
=
etaScale
;
return
index
;
}
...
...
@@ -414,7 +413,7 @@ class EscapedRayQueue : public WorkQueue<EscapedRayWorkItem> {
inline
int
EscapedRayQueue
::
Push
(
RayWorkItem
r
)
{
return
Push
(
EscapedRayWorkItem
{
r
.
ray
.
o
,
r
.
ray
.
d
,
r
.
depth
,
r
.
lambda
,
r
.
pixelIndex
,
r
.
T_hat
,
(
int
)
r
.
isS
pecularBounce
,
r
.
uniPathPDF
,
r
.
T_hat
,
(
int
)
r
.
s
pecularBounce
,
r
.
uniPathPDF
,
r
.
lightPathPDF
,
r
.
prevIntrCtx
});
}
...
...
@@ -482,7 +481,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
PBRT_CPU_GPU
int
Push
(
Ray
ray
,
Float
tMax
,
SampledWavelengths
lambda
,
SampledSpectrum
T_hat
,
SampledSpectrum
uniPathPDF
,
SampledSpectrum
lightPathPDF
,
int
pixelIndex
,
LightSampleContext
prevIntrCtx
,
int
isS
pecularBounce
,
LightSampleContext
prevIntrCtx
,
int
s
pecularBounce
,
int
anyNonSpecularBounces
,
Float
etaScale
)
{
int
index
=
AllocateEntry
();
this
->
ray
[
index
]
=
ray
;
...
...
@@ -493,7 +492,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
this
->
lightPathPDF
[
index
]
=
lightPathPDF
;
this
->
pixelIndex
[
index
]
=
pixelIndex
;
this
->
prevIntrCtx
[
index
]
=
prevIntrCtx
;
this
->
isSpecularBounce
[
index
]
=
isS
pecularBounce
;
this
->
specularBounce
[
index
]
=
s
pecularBounce
;
this
->
anyNonSpecularBounces
[
index
]
=
anyNonSpecularBounces
;
this
->
etaScale
[
index
]
=
etaScale
;
return
index
;
...
...
@@ -502,7 +501,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
PBRT_CPU_GPU
int
Push
(
RayWorkItem
r
,
Float
tMax
)
{
return
Push
(
r
.
ray
,
tMax
,
r
.
lambda
,
r
.
T_hat
,
r
.
uniPathPDF
,
r
.
lightPathPDF
,
r
.
pixelIndex
,
r
.
prevIntrCtx
,
r
.
isS
pecularBounce
,
r
.
pixelIndex
,
r
.
prevIntrCtx
,
r
.
s
pecularBounce
,
r
.
anyNonSpecularBounces
,
r
.
etaScale
);
}
};
...
...
src/pbrt/wavefront/workitems.soa
浏览文件 @
50acd8a5
...
...
@@ -45,7 +45,7 @@ soa RayWorkItem {
SampledSpectrum
T_hat
,
uniPathPDF
,
lightPathPDF
;
LightSampleContext
prevIntrCtx
;
Float
etaScale
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
int
anyNonSpecularBounces
;
};
...
...
@@ -70,7 +70,7 @@ soa HitAreaLightWorkItem {
Vector3f
wo
;
int
depth
;
LightSampleContext
prevIntrCtx
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
int
pixelIndex
;
};
...
...
@@ -131,7 +131,7 @@ soa MediumSampleWorkItem {
Vector3f
wo
;
Point2f
uv
;
LightSampleContext
prevIntrCtx
;
int
isS
pecularBounce
;
int
s
pecularBounce
;
Material
material
;
Normal3f
ns
;
Vector3f
dpdus
,
dpdvs
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录