Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
fb1c4106
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,发现更多精彩内容 >>
提交
fb1c4106
编写于
2月 12, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove "Handle" from assorted variable names.
上级
eec95f75
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
65 deletion
+61
-65
src/pbrt/cpu/render.cpp
src/pbrt/cpu/render.cpp
+11
-14
src/pbrt/gpu/accel.cpp
src/pbrt/gpu/accel.cpp
+38
-38
src/pbrt/gpu/pathintegrator.cpp
src/pbrt/gpu/pathintegrator.cpp
+3
-3
src/pbrt/lightsamplers.h
src/pbrt/lightsamplers.h
+1
-1
src/pbrt/materials.cpp
src/pbrt/materials.cpp
+7
-7
src/pbrt/util/spectrum.cpp
src/pbrt/util/spectrum.cpp
+1
-2
未找到文件。
src/pbrt/cpu/render.cpp
浏览文件 @
fb1c4106
...
...
@@ -121,10 +121,10 @@ void CPURender(ParsedScene &parsedScene) {
[
&
](
const
std
::
vector
<
ShapeSceneEntity
>
&
shapes
)
->
std
::
vector
<
Primitive
>
{
// Parallelize Shape::Create calls, which will in turn
// parallelize PLY file loading, etc...
pstd
::
vector
<
pstd
::
vector
<
Shape
>>
shape
Handle
Vectors
(
shapes
.
size
());
pstd
::
vector
<
pstd
::
vector
<
Shape
>>
shapeVectors
(
shapes
.
size
());
ParallelFor
(
0
,
shapes
.
size
(),
[
&
](
int64_t
i
)
{
const
auto
&
sh
=
shapes
[
i
];
shape
Handle
Vectors
[
i
]
=
shapeVectors
[
i
]
=
Shape
::
Create
(
sh
.
name
,
sh
.
renderFromObject
,
sh
.
objectFromRender
,
sh
.
reverseOrientation
,
sh
.
parameters
,
&
sh
.
loc
,
alloc
);
});
...
...
@@ -132,7 +132,7 @@ void CPURender(ParsedScene &parsedScene) {
std
::
vector
<
Primitive
>
primitives
;
for
(
size_t
i
=
0
;
i
<
shapes
.
size
();
++
i
)
{
const
auto
&
sh
=
shapes
[
i
];
pstd
::
vector
<
Shape
>
&
shapes
=
shape
Handle
Vectors
[
i
];
pstd
::
vector
<
Shape
>
&
shapes
=
shapeVectors
[
i
];
if
(
shapes
.
empty
())
continue
;
...
...
@@ -155,25 +155,24 @@ void CPURender(ParsedScene &parsedScene) {
for
(
auto
&
s
:
shapes
)
{
// Possibly create area light for shape
Light
area
Handle
=
nullptr
;
Light
area
=
nullptr
;
if
(
sh
.
lightIndex
!=
-
1
)
{
CHECK_LT
(
sh
.
lightIndex
,
parsedScene
.
areaLights
.
size
());
const
auto
&
areaLightEntity
=
parsedScene
.
areaLights
[
sh
.
lightIndex
];
Light
area
=
Light
::
CreateArea
(
area
=
Light
::
CreateArea
(
areaLightEntity
.
name
,
areaLightEntity
.
parameters
,
*
sh
.
renderFromObject
,
mi
,
s
,
&
areaLightEntity
.
loc
,
Allocator
{});
areaHandle
=
area
;
if
(
area
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lightsMutex
);
lights
.
push_back
(
area
);
}
}
if
(
area
Handle
==
nullptr
&&
!
mi
.
IsMediumTransition
()
&&
!
alphaTex
)
if
(
area
==
nullptr
&&
!
mi
.
IsMediumTransition
()
&&
!
alphaTex
)
primitives
.
push_back
(
new
SimplePrimitive
(
s
,
mtl
));
else
primitives
.
push_back
(
new
GeometricPrimitive
(
s
,
mtl
,
area
Handle
,
mi
,
alphaTex
));
new
GeometricPrimitive
(
s
,
mtl
,
area
,
mi
,
alphaTex
));
}
}
return
primitives
;
...
...
@@ -217,7 +216,7 @@ void CPURender(ParsedScene &parsedScene) {
std
::
vector
<
Primitive
>
prims
;
for
(
auto
&
s
:
shapes
)
{
// Possibly create area light for shape
Light
area
Handle
=
nullptr
;
Light
area
=
nullptr
;
if
(
sh
.
lightIndex
!=
-
1
)
{
CHECK_LT
(
sh
.
lightIndex
,
parsedScene
.
areaLights
.
size
());
const
auto
&
areaLightEntity
=
parsedScene
.
areaLights
[
sh
.
lightIndex
];
...
...
@@ -226,18 +225,16 @@ void CPURender(ParsedScene &parsedScene) {
if
(
sh
.
renderFromObject
.
IsAnimated
())
ErrorExit
(
&
sh
.
loc
,
"Animated area lights are not supported."
);
Light
area
=
Light
::
CreateArea
(
area
=
Light
::
CreateArea
(
areaLightEntity
.
name
,
areaLightEntity
.
parameters
,
sh
.
renderFromObject
.
startTransform
,
mi
,
s
,
&
sh
.
loc
,
Allocator
{});
areaHandle
=
area
;
if
(
area
)
lights
.
push_back
(
area
);
}
if
(
area
Handle
==
nullptr
&&
!
mi
.
IsMediumTransition
()
&&
!
alphaTex
)
if
(
area
==
nullptr
&&
!
mi
.
IsMediumTransition
()
&&
!
alphaTex
)
prims
.
push_back
(
new
SimplePrimitive
(
s
,
mtl
));
else
prims
.
push_back
(
new
GeometricPrimitive
(
s
,
mtl
,
areaHandle
,
mi
,
alphaTex
));
prims
.
push_back
(
new
GeometricPrimitive
(
s
,
mtl
,
area
,
mi
,
alphaTex
));
}
// TODO: could try to be greedy or even segment them according
...
...
src/pbrt/gpu/accel.cpp
浏览文件 @
fb1c4106
...
...
@@ -146,12 +146,12 @@ static FloatTexture getAlphaTexture(
const
ShapeSceneEntity
&
shape
,
const
std
::
map
<
std
::
string
,
FloatTexture
>
&
floatTextures
,
Allocator
alloc
)
{
FloatTexture
alphaTexture
Handle
;
FloatTexture
alphaTexture
;
std
::
string
alphaTexName
=
shape
.
parameters
.
GetTexture
(
"alpha"
);
if
(
alphaTexName
.
empty
())
{
if
(
Float
alpha
=
shape
.
parameters
.
GetOneFloat
(
"alpha"
,
1.
f
);
alpha
<
1.
f
)
alphaTexture
Handle
=
alloc
.
new_object
<
FloatConstantTexture
>
(
alpha
);
alphaTexture
=
alloc
.
new_object
<
FloatConstantTexture
>
(
alpha
);
else
return
nullptr
;
}
else
{
...
...
@@ -159,28 +159,28 @@ static FloatTexture getAlphaTexture(
if
(
iter
==
floatTextures
.
end
())
ErrorExit
(
&
shape
.
loc
,
"%s: alpha texture not defined."
,
alphaTexName
);
alphaTexture
Handle
=
iter
->
second
;
alphaTexture
=
iter
->
second
;
}
if
(
!
BasicTextureEvaluator
().
CanEvaluate
({
alphaTexture
Handle
},
{}))
{
if
(
!
BasicTextureEvaluator
().
CanEvaluate
({
alphaTexture
},
{}))
{
// It would be nice to just use the UniversalTextureEvaluator (maybe
// always), but optix complains "Error: Found call graph recursion"...
Warning
(
&
shape
.
loc
,
"%s: alpha texture too complex for BasicTextureEvaluator "
"(need fallback path). Ignoring for now."
,
alphaTexName
);
alphaTexture
Handle
=
nullptr
;
alphaTexture
=
nullptr
;
}
return
alphaTexture
Handle
;
return
alphaTexture
;
}
static
int
getOptixGeometryFlags
(
bool
isTriangle
,
FloatTexture
alphaTexture
Handle
,
Material
material
Handle
)
{
if
(
material
Handle
&&
materialHandle
.
HasSubsurfaceScattering
())
static
int
getOptixGeometryFlags
(
bool
isTriangle
,
FloatTexture
alphaTexture
,
Material
material
)
{
if
(
material
&&
material
.
HasSubsurfaceScattering
())
return
OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL
;
else
if
((
alphaTexture
Handle
&&
isTriangle
)
||
(
material
Handle
&&
materialHandle
.
IsTransparent
()))
else
if
((
alphaTexture
&&
isTriangle
)
||
(
material
&&
material
.
IsTransparent
()))
// Need anyhit
return
OPTIX_GEOMETRY_FLAG_NONE
;
else
...
...
@@ -312,8 +312,8 @@ OptixTraversableHandle GPUAccel::createGASForTriangles(
const
auto
&
shape
=
shapes
[
shapeIndex
];
FloatTexture
alphaTexture
Handle
=
getAlphaTexture
(
shape
,
floatTextures
,
alloc
);
Material
material
Handle
=
getMaterial
(
shape
,
namedMaterials
,
materials
);
FloatTexture
alphaTexture
=
getAlphaTexture
(
shape
,
floatTextures
,
alloc
);
Material
material
=
getMaterial
(
shape
,
namedMaterials
,
materials
);
OptixBuildInput
input
=
{};
...
...
@@ -331,7 +331,7 @@ OptixTraversableHandle GPUAccel::createGASForTriangles(
input
.
triangleArray
.
indexBuffer
=
CUdeviceptr
(
mesh
->
vertexIndices
);
triangleInputFlags
[
buildIndex
]
=
getOptixGeometryFlags
(
true
,
alphaTexture
Handle
,
materialHandle
);
getOptixGeometryFlags
(
true
,
alphaTexture
,
material
);
input
.
triangleArray
.
flags
=
&
triangleInputFlags
[
buildIndex
];
input
.
triangleArray
.
numSbtRecords
=
1
;
...
...
@@ -344,8 +344,8 @@ OptixTraversableHandle GPUAccel::createGASForTriangles(
HitgroupRecord
hgRecord
;
OPTIX_CHECK
(
optixSbtRecordPackHeader
(
intersectPG
,
&
hgRecord
));
hgRecord
.
triRec
.
mesh
=
mesh
;
hgRecord
.
triRec
.
material
=
material
Handle
;
hgRecord
.
triRec
.
alphaTexture
=
alphaTexture
Handle
;
hgRecord
.
triRec
.
material
=
material
;
hgRecord
.
triRec
.
alphaTexture
=
alphaTexture
;
hgRecord
.
triRec
.
areaLights
=
{};
if
(
shape
.
lightIndex
!=
-
1
)
{
// Note: this will hit if we try to have an instance as an area
...
...
@@ -417,16 +417,16 @@ OptixTraversableHandle GPUAccel::createGASForBLPs(
*
gasBounds
=
Union
(
*
gasBounds
,
shapeBounds
);
Material
material
Handle
=
getMaterial
(
shape
,
namedMaterials
,
materials
);
FloatTexture
alphaTexture
Handle
=
getAlphaTexture
(
shape
,
floatTextures
,
alloc
);
Material
material
=
getMaterial
(
shape
,
namedMaterials
,
materials
);
FloatTexture
alphaTexture
=
getAlphaTexture
(
shape
,
floatTextures
,
alloc
);
flags
.
push_back
(
getOptixGeometryFlags
(
false
,
alphaTexture
Handle
,
materialHandle
));
flags
.
push_back
(
getOptixGeometryFlags
(
false
,
alphaTexture
,
material
));
HitgroupRecord
hgRecord
;
OPTIX_CHECK
(
optixSbtRecordPackHeader
(
intersectPG
,
&
hgRecord
));
hgRecord
.
bilinearRec
.
mesh
=
mesh
;
hgRecord
.
bilinearRec
.
material
=
material
Handle
;
hgRecord
.
bilinearRec
.
alphaTexture
=
alphaTexture
Handle
;
hgRecord
.
bilinearRec
.
material
=
material
;
hgRecord
.
bilinearRec
.
alphaTexture
=
alphaTexture
;
hgRecord
.
bilinearRec
.
areaLights
=
{};
if
(
shape
.
lightIndex
!=
-
1
)
{
auto
iter
=
shapeIndexToAreaLights
.
find
(
shapeIndex
);
...
...
@@ -477,17 +477,17 @@ OptixTraversableHandle GPUAccel::createGASForQuadrics(
std
::
vector
<
unsigned
int
>
flags
;
for
(
size_t
shapeIndex
=
0
;
shapeIndex
<
shapes
.
size
();
++
shapeIndex
)
{
const
auto
&
s
hape
=
shapes
[
shapeIndex
];
if
(
s
hape
.
name
!=
"sphere"
&&
shape
.
name
!=
"cylinder"
&&
shape
.
name
!=
"disk"
)
const
auto
&
s
=
shapes
[
shapeIndex
];
if
(
s
.
name
!=
"sphere"
&&
s
.
name
!=
"cylinder"
&&
s
.
name
!=
"disk"
)
continue
;
pstd
::
vector
<
Shape
>
shape
Handle
s
=
Shape
::
Create
(
s
hape
.
name
,
shape
.
renderFromObject
,
shape
.
objectFromRender
,
s
hape
.
reverseOrientation
,
shape
.
parameters
,
&
shape
.
loc
,
alloc
);
if
(
shape
Handle
s
.
empty
())
pstd
::
vector
<
Shape
>
shapes
=
Shape
::
Create
(
s
.
name
,
s
.
renderFromObject
,
s
.
objectFromRender
,
s
.
reverseOrientation
,
s
.
parameters
,
&
s
.
loc
,
alloc
);
if
(
shapes
.
empty
())
continue
;
CHECK_EQ
(
1
,
shape
Handle
s
.
size
());
Shape
shape
Handle
=
shapeHandl
es
[
0
];
CHECK_EQ
(
1
,
shapes
.
size
());
Shape
shape
=
shap
es
[
0
];
OptixBuildInput
buildInput
=
{};
memset
(
&
buildInput
,
0
,
sizeof
(
buildInput
));
...
...
@@ -499,7 +499,7 @@ OptixTraversableHandle GPUAccel::createGASForQuadrics(
buildInputs
.
push_back
(
buildInput
);
Bounds3f
shapeBounds
=
shape
Handle
.
Bounds
();
Bounds3f
shapeBounds
=
shape
.
Bounds
();
OptixAabb
aabb
=
{
shapeBounds
.
pMin
.
x
,
shapeBounds
.
pMin
.
y
,
shapeBounds
.
pMin
.
z
,
shapeBounds
.
pMax
.
x
,
shapeBounds
.
pMax
.
y
,
shapeBounds
.
pMax
.
z
};
shapeAABBs
.
push_back
(
aabb
);
...
...
@@ -507,17 +507,17 @@ OptixTraversableHandle GPUAccel::createGASForQuadrics(
*
gasBounds
=
Union
(
*
gasBounds
,
shapeBounds
);
// Find alpha texture, if present.
Material
material
Handle
=
getMaterial
(
shape
,
namedMaterials
,
materials
);
FloatTexture
alphaTexture
Handle
=
getAlphaTexture
(
shape
,
floatTextures
,
alloc
);
flags
.
push_back
(
getOptixGeometryFlags
(
false
,
alphaTexture
Handle
,
materialHandle
));
Material
material
=
getMaterial
(
s
,
namedMaterials
,
materials
);
FloatTexture
alphaTexture
=
getAlphaTexture
(
s
,
floatTextures
,
alloc
);
flags
.
push_back
(
getOptixGeometryFlags
(
false
,
alphaTexture
,
material
));
HitgroupRecord
hgRecord
;
OPTIX_CHECK
(
optixSbtRecordPackHeader
(
intersectPG
,
&
hgRecord
));
hgRecord
.
quadricRec
.
shape
=
shape
Handle
;
hgRecord
.
quadricRec
.
material
=
material
Handle
;
hgRecord
.
quadricRec
.
alphaTexture
=
alphaTexture
Handle
;
hgRecord
.
quadricRec
.
shape
=
shape
;
hgRecord
.
quadricRec
.
material
=
material
;
hgRecord
.
quadricRec
.
alphaTexture
=
alphaTexture
;
hgRecord
.
quadricRec
.
areaLight
=
nullptr
;
if
(
s
hape
.
lightIndex
!=
-
1
)
{
if
(
s
.
lightIndex
!=
-
1
)
{
auto
iter
=
shapeIndexToAreaLights
.
find
(
shapeIndex
);
// Note: this will hit if we try to have an instance as an area
// light.
...
...
@@ -525,7 +525,7 @@ OptixTraversableHandle GPUAccel::createGASForQuadrics(
CHECK_EQ
(
iter
->
second
->
size
(),
1
);
hgRecord
.
quadricRec
.
areaLight
=
(
*
iter
->
second
)[
0
];
}
hgRecord
.
quadricRec
.
mediumInterface
=
getMediumInterface
(
s
hape
,
media
,
alloc
);
hgRecord
.
quadricRec
.
mediumInterface
=
getMediumInterface
(
s
,
media
,
alloc
);
intersectHGRecords
.
push_back
(
hgRecord
);
...
...
src/pbrt/gpu/pathintegrator.cpp
浏览文件 @
fb1c4106
...
...
@@ -124,18 +124,18 @@ GPUPathIntegrator::GPUPathIntegrator(Allocator alloc, const ParsedScene &scene)
const
auto
&
areaLightEntity
=
scene
.
areaLights
[
shape
.
lightIndex
];
AnimatedTransform
renderFromLight
(
*
shape
.
renderFromObject
);
pstd
::
vector
<
Shape
>
shape
Handle
s
=
pstd
::
vector
<
Shape
>
shapes
=
Shape
::
Create
(
shape
.
name
,
shape
.
renderFromObject
,
shape
.
objectFromRender
,
shape
.
reverseOrientation
,
shape
.
parameters
,
&
shape
.
loc
,
alloc
);
if
(
shape
Handle
s
.
empty
())
if
(
shapes
.
empty
())
continue
;
Medium
outsideMedium
=
findMedium
(
shape
.
outsideMedium
,
&
shape
.
loc
);
pstd
::
vector
<
Light
>
*
lightsForShape
=
alloc
.
new_object
<
pstd
::
vector
<
Light
>>
(
alloc
);
for
(
Shape
sh
:
shape
Handle
s
)
{
for
(
Shape
sh
:
shapes
)
{
if
(
renderFromLight
.
IsAnimated
())
ErrorExit
(
&
shape
.
loc
,
"Animated lights are not supported."
);
DiffuseAreaLight
*
area
=
DiffuseAreaLight
::
Create
(
...
...
src/pbrt/lightsamplers.h
浏览文件 @
fb1c4106
...
...
@@ -24,7 +24,7 @@ namespace pbrt {
// LightHash Definition
struct
LightHash
{
PBRT_CPU_GPU
size_t
operator
()(
Light
light
Handle
)
const
{
return
Hash
(
lightHandle
.
ptr
());
}
size_t
operator
()(
Light
light
)
const
{
return
Hash
(
light
.
ptr
());
}
};
// UniformLightSampler Definition
...
...
src/pbrt/materials.cpp
浏览文件 @
fb1c4106
...
...
@@ -538,19 +538,19 @@ Material Material::Create(const std::string &name,
else
if
(
name
==
"subsurface"
)
material
=
SubsurfaceMaterial
::
Create
(
parameters
,
normalMap
,
loc
,
alloc
);
else
if
(
name
==
"mix"
)
{
std
::
vector
<
std
::
string
>
materials
=
parameters
.
GetStringArray
(
"materials"
);
if
(
materials
.
size
()
!=
2
)
std
::
vector
<
std
::
string
>
material
Name
s
=
parameters
.
GetStringArray
(
"materials"
);
if
(
material
Name
s
.
size
()
!=
2
)
ErrorExit
(
"Must provide two values for
\"
string materials
\"
for mix material."
);
Material
material
Handle
s
[
2
];
Material
materials
[
2
];
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
auto
iter
=
namedMaterials
.
find
(
materials
[
i
]);
auto
iter
=
namedMaterials
.
find
(
material
Name
s
[
i
]);
if
(
iter
==
namedMaterials
.
end
())
ErrorExit
(
"%s: named material not found."
,
materials
[
i
]);
material
Handle
s
[
i
]
=
iter
->
second
;
ErrorExit
(
"%s: named material not found."
,
material
Name
s
[
i
]);
materials
[
i
]
=
iter
->
second
;
}
material
=
MixMaterial
::
Create
(
material
Handle
s
,
parameters
,
loc
,
alloc
);
material
=
MixMaterial
::
Create
(
materials
,
parameters
,
loc
,
alloc
);
}
else
ErrorExit
(
loc
,
"%s: material type unknown."
,
name
);
...
...
src/pbrt/util/spectrum.cpp
浏览文件 @
fb1c4106
...
...
@@ -122,8 +122,7 @@ pstd::optional<Spectrum> PiecewiseLinearSpectrum::Read(const std::string &fn,
lambda
.
push_back
(
vals
[
2
*
i
]);
v
.
push_back
(
vals
[
2
*
i
+
1
]);
}
Spectrum
handle
=
alloc
.
new_object
<
PiecewiseLinearSpectrum
>
(
lambda
,
v
,
alloc
);
return
handle
;
return
Spectrum
(
alloc
.
new_object
<
PiecewiseLinearSpectrum
>
(
lambda
,
v
,
alloc
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录