Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
be81bf75
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,发现更多精彩内容 >>
提交
be81bf75
编写于
1月 10, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add "invert" option for image textures
上级
6e8627ce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
22 deletion
+37
-22
src/pbrt/textures.cpp
src/pbrt/textures.cpp
+16
-9
src/pbrt/textures.h
src/pbrt/textures.h
+21
-13
未找到文件。
src/pbrt/textures.cpp
浏览文件 @
be81bf75
...
...
@@ -345,7 +345,7 @@ SampledSpectrum SpectrumImageTexture::Evaluate(TextureEvalContext ctx,
// Lookup filtered RGB value in _MIPMap_
RGB
rgb
=
scale
*
mipmap
->
Filter
<
RGB
>
(
st
,
dstdx
,
dstdy
);
rgb
=
ClampZero
(
rgb
);
rgb
=
ClampZero
(
invert
?
(
RGB
(
1
,
1
,
1
)
-
rgb
)
:
rgb
);
// Return _SampledSpectrum_ for RGB image texture value
if
(
const
RGBColorSpace
*
cs
=
mipmap
->
GetRGBColorSpace
();
cs
!=
nullptr
)
{
...
...
@@ -364,13 +364,15 @@ SampledSpectrum SpectrumImageTexture::Evaluate(TextureEvalContext ctx,
}
std
::
string
SpectrumImageTexture
::
ToString
()
const
{
return
StringPrintf
(
"[ SpectrumImageTexture mapping: %s scale: %f mipmap: %s ]"
,
mapping
,
scale
,
*
mipmap
);
return
StringPrintf
(
"[ SpectrumImageTexture mapping: %s scale: %f invert: %s mipmap: %s ]"
,
mapping
,
scale
,
invert
,
*
mipmap
);
}
std
::
string
FloatImageTexture
::
ToString
()
const
{
return
StringPrintf
(
"[ FloatImageTexture mapping: %s scale: %f mipmap: %s ]"
,
mapping
,
scale
,
*
mipmap
);
return
StringPrintf
(
"[ FloatImageTexture mapping: %s scale: %f invert: %s mipmap: %s ]"
,
mapping
,
scale
,
invert
,
*
mipmap
);
}
std
::
string
TexInfo
::
ToString
()
const
{
...
...
@@ -405,6 +407,7 @@ FloatImageTexture *FloatImageTexture::Create(const Transform &renderFromTexture,
if
(
!
wrapMode
)
ErrorExit
(
"%s: wrap mode unknown"
,
wrapString
);
Float
scale
=
parameters
.
GetOneFloat
(
"scale"
,
1.
f
);
bool
invert
=
parameters
.
GetOneBool
(
"invert"
,
false
);
std
::
string
filename
=
ResolveFilename
(
parameters
.
GetOneString
(
"filename"
,
""
));
const
char
*
defaultEncoding
=
HasExtension
(
filename
,
"png"
)
?
"sRGB"
:
"linear"
;
...
...
@@ -412,7 +415,7 @@ FloatImageTexture *FloatImageTexture::Create(const Transform &renderFromTexture,
ColorEncodingHandle
encoding
=
ColorEncodingHandle
::
Get
(
encodingString
,
alloc
);
return
alloc
.
new_object
<
FloatImageTexture
>
(
map
,
filename
,
filterOptions
,
*
wrapMode
,
scale
,
encoding
,
alloc
);
scale
,
invert
,
encoding
,
alloc
);
}
SpectrumImageTexture
*
SpectrumImageTexture
::
Create
(
...
...
@@ -438,6 +441,7 @@ SpectrumImageTexture *SpectrumImageTexture::Create(
if
(
!
wrapMode
)
ErrorExit
(
"%s: wrap mode unknown"
,
wrapString
);
Float
scale
=
parameters
.
GetOneFloat
(
"scale"
,
1.
f
);
bool
invert
=
parameters
.
GetOneBool
(
"invert"
,
false
);
std
::
string
filename
=
ResolveFilename
(
parameters
.
GetOneString
(
"filename"
,
""
));
const
char
*
defaultEncoding
=
HasExtension
(
filename
,
"png"
)
?
"sRGB"
:
"linear"
;
...
...
@@ -445,7 +449,8 @@ SpectrumImageTexture *SpectrumImageTexture::Create(
ColorEncodingHandle
encoding
=
ColorEncodingHandle
::
Get
(
encodingString
,
alloc
);
return
alloc
.
new_object
<
SpectrumImageTexture
>
(
map
,
filename
,
filterOptions
,
*
wrapMode
,
scale
,
encoding
,
spectrumType
,
alloc
);
scale
,
invert
,
encoding
,
spectrumType
,
alloc
);
}
// MarbleTexture Method Definitions
...
...
@@ -1047,9 +1052,10 @@ GPUSpectrumImageTexture *GPUSpectrumImageTexture::Create(
TextureMapping2DHandle
::
Create
(
parameters
,
renderFromTexture
,
loc
,
alloc
);
Float
scale
=
parameters
.
GetOneFloat
(
"scale"
,
1.
f
);
bool
invert
=
parameters
.
GetOneBool
(
"invert"
,
false
);
return
alloc
.
new_object
<
GPUSpectrumImageTexture
>
(
mapping
,
texObj
,
scale
,
isSingleChannel
,
colorSpace
,
spectrumType
);
mapping
,
texObj
,
scale
,
i
nvert
,
i
sSingleChannel
,
colorSpace
,
spectrumType
);
}
GPUFloatImageTexture
*
GPUFloatImageTexture
::
Create
(
...
...
@@ -1148,8 +1154,9 @@ GPUFloatImageTexture *GPUFloatImageTexture::Create(
TextureMapping2DHandle
::
Create
(
parameters
,
renderFromTexture
,
loc
,
alloc
);
Float
scale
=
parameters
.
GetOneFloat
(
"scale"
,
1.
f
);
bool
invert
=
parameters
.
GetOneBool
(
"invert"
,
false
);
return
alloc
.
new_object
<
GPUFloatImageTexture
>
(
mapping
,
texObj
,
scale
);
return
alloc
.
new_object
<
GPUFloatImageTexture
>
(
mapping
,
texObj
,
scale
,
invert
);
}
#endif // PBRT_BUILD_GPU_RENDERER
...
...
src/pbrt/textures.h
浏览文件 @
be81bf75
...
...
@@ -526,8 +526,8 @@ class ImageTextureBase {
// ImageTextureBase Public Methods
ImageTextureBase
(
TextureMapping2DHandle
mapping
,
std
::
string
filename
,
MIPMapFilterOptions
filterOptions
,
WrapMode
wrapMode
,
Float
scale
,
ColorEncodingHandle
encoding
,
Allocator
alloc
)
:
mapping
(
mapping
),
scale
(
scale
)
{
bool
invert
,
ColorEncodingHandle
encoding
,
Allocator
alloc
)
:
mapping
(
mapping
),
scale
(
scale
)
,
invert
(
invert
)
{
// Get _MIPMap_ from texture cache if present
TexInfo
texInfo
(
filename
,
filterOptions
,
wrapMode
,
encoding
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
textureCacheMutex
);
...
...
@@ -556,6 +556,7 @@ class ImageTextureBase {
// ImageTextureBase Protected Members
TextureMapping2DHandle
mapping
;
Float
scale
;
bool
invert
;
MIPMap
*
mipmap
;
private:
...
...
@@ -569,8 +570,9 @@ class FloatImageTexture : public ImageTextureBase {
public:
FloatImageTexture
(
TextureMapping2DHandle
m
,
const
std
::
string
&
filename
,
MIPMapFilterOptions
filterOptions
,
WrapMode
wm
,
Float
scale
,
ColorEncodingHandle
encoding
,
Allocator
alloc
)
:
ImageTextureBase
(
m
,
filename
,
filterOptions
,
wm
,
scale
,
encoding
,
alloc
)
{}
bool
invert
,
ColorEncodingHandle
encoding
,
Allocator
alloc
)
:
ImageTextureBase
(
m
,
filename
,
filterOptions
,
wm
,
scale
,
invert
,
encoding
,
alloc
)
{}
PBRT_CPU_GPU
Float
Evaluate
(
TextureEvalContext
ctx
)
const
{
#ifdef PBRT_IS_GPU_CODE
...
...
@@ -582,7 +584,8 @@ class FloatImageTexture : public ImageTextureBase {
// Texture coordinates are (0,0) in the lower left corner, but
// image coordinates are (0,0) in the upper left.
st
[
1
]
=
1
-
st
[
1
];
return
scale
*
mipmap
->
Filter
<
Float
>
(
st
,
dstdx
,
dstdy
);
Float
v
=
scale
*
mipmap
->
Filter
<
Float
>
(
st
,
dstdx
,
dstdy
);
return
invert
?
std
::
max
<
Float
>
(
0
,
1
-
v
)
:
v
;
#endif
}
...
...
@@ -599,10 +602,10 @@ class SpectrumImageTexture : public ImageTextureBase {
// SpectrumImageTexture Public Methods
SpectrumImageTexture
(
TextureMapping2DHandle
mapping
,
std
::
string
filename
,
MIPMapFilterOptions
filterOptions
,
WrapMode
wrapMode
,
Float
scale
,
ColorEncodingHandle
encoding
,
Float
scale
,
bool
invert
,
ColorEncodingHandle
encoding
,
SpectrumType
spectrumType
,
Allocator
alloc
)
:
ImageTextureBase
(
mapping
,
filename
,
filterOptions
,
wrapMode
,
scale
,
encoding
,
alloc
),
:
ImageTextureBase
(
mapping
,
filename
,
filterOptions
,
wrapMode
,
scale
,
invert
,
encoding
,
alloc
),
spectrumType
(
spectrumType
)
{}
PBRT_CPU_GPU
...
...
@@ -624,11 +627,12 @@ class SpectrumImageTexture : public ImageTextureBase {
class
GPUSpectrumImageTexture
{
public:
GPUSpectrumImageTexture
(
TextureMapping2DHandle
mapping
,
cudaTextureObject_t
texObj
,
Float
scale
,
bool
isSingleChannel
,
Float
scale
,
bool
i
nvert
,
bool
i
sSingleChannel
,
const
RGBColorSpace
*
colorSpace
,
SpectrumType
spectrumType
)
:
mapping
(
mapping
),
texObj
(
texObj
),
scale
(
scale
),
invert
(
invert
),
isSingleChannel
(
isSingleChannel
),
colorSpace
(
colorSpace
),
spectrumType
(
spectrumType
)
{}
...
...
@@ -651,6 +655,8 @@ class GPUSpectrumImageTexture {
float4
tex
=
tex2D
<
float4
>
(
texObj
,
st
[
0
],
1
-
st
[
1
]);
rgb
=
scale
*
RGB
(
tex
.
x
,
tex
.
y
,
tex
.
z
);
}
if
(
invert
)
rgb
=
ClampZero
(
RGB
(
1
,
1
,
1
)
-
rgb
);
if
(
spectrumType
==
SpectrumType
::
Unbounded
)
return
RGBUnboundedSpectrum
(
*
colorSpace
,
rgb
).
Sample
(
lambda
);
else
if
(
spectrumType
==
SpectrumType
::
Albedo
)
{
...
...
@@ -673,7 +679,7 @@ class GPUSpectrumImageTexture {
TextureMapping2DHandle
mapping
;
cudaTextureObject_t
texObj
;
Float
scale
;
bool
isSingleChannel
;
bool
i
nvert
,
i
sSingleChannel
;
const
RGBColorSpace
*
colorSpace
;
SpectrumType
spectrumType
;
};
...
...
@@ -681,8 +687,8 @@ class GPUSpectrumImageTexture {
class
GPUFloatImageTexture
{
public:
GPUFloatImageTexture
(
TextureMapping2DHandle
mapping
,
cudaTextureObject_t
texObj
,
Float
scale
)
:
mapping
(
mapping
),
texObj
(
texObj
),
scale
(
scale
)
{}
Float
scale
,
bool
invert
)
:
mapping
(
mapping
),
texObj
(
texObj
),
scale
(
scale
)
,
invert
(
invert
)
{}
PBRT_CPU_GPU
Float
Evaluate
(
TextureEvalContext
ctx
)
const
{
...
...
@@ -694,7 +700,8 @@ class GPUFloatImageTexture {
Point2f
st
=
mapping
.
Map
(
ctx
,
&
dstdx
,
&
dstdy
);
// flip y coord since image has (0,0) at upper left, texture at lower
// left
return
scale
*
tex2D
<
float
>
(
texObj
,
st
[
0
],
1
-
st
[
1
]);
Float
v
=
scale
*
tex2D
<
float
>
(
texObj
,
st
[
0
],
1
-
st
[
1
]);
return
invert
?
std
::
max
<
Float
>
(
0
,
1
-
v
)
:
v
;
#endif
}
...
...
@@ -709,6 +716,7 @@ class GPUFloatImageTexture {
TextureMapping2DHandle
mapping
;
cudaTextureObject_t
texObj
;
Float
scale
;
bool
invert
;
};
#else // PBRT_BUILD_GPU_RENDERER && __NVCC__
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录