Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
a954381f
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a954381f
编写于
8月 26, 2018
作者:
M
Mr.doob
提交者:
GitHub
8月 26, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14792 from WestLangley/dev-encodings_cleanup
encodings_pars_fragment: clean up
上级
1e2136af
97d4a9c3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
16 deletion
+21
-16
src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
...enderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
+21
-16
未找到文件。
src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
浏览文件 @
a954381f
...
...
@@ -5,22 +5,25 @@ vec4 LinearToLinear( in vec4 value ) {
}
vec4
GammaToLinear
(
in
vec4
value
,
in
float
gammaFactor
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
gammaFactor
)
),
value
.
w
);
return
vec4
(
pow
(
value
.
rgb
,
vec3
(
gammaFactor
)
),
value
.
a
);
}
vec4
LinearToGamma
(
in
vec4
value
,
in
float
gammaFactor
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
1
.
0
/
gammaFactor
)
),
value
.
w
);
return
vec4
(
pow
(
value
.
rgb
,
vec3
(
1
.
0
/
gammaFactor
)
),
value
.
a
);
}
vec4
sRGBToLinear
(
in
vec4
value
)
{
return
vec4
(
mix
(
pow
(
value
.
rgb
*
0
.
9478672986
+
vec3
(
0
.
0521327014
),
vec3
(
2
.
4
)
),
value
.
rgb
*
0
.
0773
993808
,
vec3
(
lessThanEqual
(
value
.
rgb
,
vec3
(
0
.
04045
)
)
)
),
value
.
w
);
return
vec4
(
mix
(
pow
(
value
.
rgb
*
0
.
9478672986
+
vec3
(
0
.
0521327014
),
vec3
(
2
.
4
)
),
value
.
rgb
*
0
.
0773
993808
,
vec3
(
lessThanEqual
(
value
.
rgb
,
vec3
(
0
.
04045
)
)
)
),
value
.
a
);
}
vec4
LinearTosRGB
(
in
vec4
value
)
{
return
vec4
(
mix
(
pow
(
value
.
rgb
,
vec3
(
0
.
41666
)
)
*
1
.
055
-
vec3
(
0
.
055
),
value
.
rgb
*
12
.
92
,
vec3
(
lessThanEqual
(
value
.
rgb
,
vec3
(
0
.
003130
8
)
)
)
),
value
.
w
);
return
vec4
(
mix
(
pow
(
value
.
rgb
,
vec3
(
0
.
41666
)
)
*
1
.
055
-
vec3
(
0
.
055
),
value
.
rgb
*
12
.
92
,
vec3
(
lessThanEqual
(
value
.
rgb
,
vec3
(
0
.
003130
8
)
)
)
),
value
.
a
);
}
vec4
RGBEToLinear
(
in
vec4
value
)
{
return
vec4
(
value
.
rgb
*
exp2
(
value
.
a
*
255
.
0
-
128
.
0
),
1
.
0
);
}
vec4
LinearToRGBE
(
in
vec4
value
)
{
float
maxComponent
=
max
(
max
(
value
.
r
,
value
.
g
),
value
.
b
);
float
fExp
=
clamp
(
ceil
(
log2
(
maxComponent
)
),
-
128
.
0
,
127
.
0
);
...
...
@@ -30,12 +33,13 @@ vec4 LinearToRGBE( in vec4 value ) {
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
vec4
RGBMToLinear
(
in
vec4
value
,
in
float
maxRange
)
{
return
vec4
(
value
.
xyz
*
value
.
w
*
maxRange
,
1
.
0
);
return
vec4
(
value
.
rgb
*
value
.
a
*
maxRange
,
1
.
0
);
}
vec4
LinearToRGBM
(
in
vec4
value
,
in
float
maxRange
)
{
float
maxRGB
=
max
(
value
.
x
,
max
(
value
.
g
,
value
.
b
)
);
float
M
=
clamp
(
maxRGB
/
maxRange
,
0
.
0
,
1
.
0
);
M
=
ceil
(
M
*
255
.
0
)
/
255
.
0
;
float
maxRGB
=
max
(
value
.
r
,
max
(
value
.
g
,
value
.
b
)
);
float
M
=
clamp
(
maxRGB
/
maxRange
,
0
.
0
,
1
.
0
);
M
=
ceil
(
M
*
255
.
0
)
/
255
.
0
;
return
vec4
(
value
.
rgb
/
(
M
*
maxRange
),
M
);
}
...
...
@@ -43,10 +47,11 @@ vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
vec4
RGBDToLinear
(
in
vec4
value
,
in
float
maxRange
)
{
return
vec4
(
value
.
rgb
*
(
(
maxRange
/
255
.
0
)
/
value
.
a
),
1
.
0
);
}
vec4
LinearToRGBD
(
in
vec4
value
,
in
float
maxRange
)
{
float
maxRGB
=
max
(
value
.
x
,
max
(
value
.
g
,
value
.
b
)
);
float
D
=
max
(
maxRange
/
maxRGB
,
1
.
0
);
D
=
min
(
floor
(
D
)
/
255
.
0
,
1
.
0
);
float
maxRGB
=
max
(
value
.
r
,
max
(
value
.
g
,
value
.
b
)
);
float
D
=
max
(
maxRange
/
maxRGB
,
1
.
0
);
D
=
min
(
floor
(
D
)
/
255
.
0
,
1
.
0
);
return
vec4
(
value
.
rgb
*
(
D
*
(
255
.
0
/
maxRange
)
),
D
);
}
...
...
@@ -56,12 +61,12 @@ vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
const
mat3
cLogLuvM
=
mat3
(
0
.
2209
,
0
.
3390
,
0
.
4184
,
0
.
1138
,
0
.
6780
,
0
.
7319
,
0
.
0102
,
0
.
1130
,
0
.
2969
);
vec4
LinearToLogLuv
(
in
vec4
value
)
{
vec3
Xp_Y_XYZp
=
value
.
rgb
*
cLogLuvM
;
Xp_Y_XYZp
=
max
(
Xp_Y_XYZp
,
vec3
(
1e-6
,
1e-6
,
1e-6
)
);
Xp_Y_XYZp
=
max
(
Xp_Y_XYZp
,
vec3
(
1e-6
,
1e-6
,
1e-6
)
);
vec4
vResult
;
vResult
.
xy
=
Xp_Y_XYZp
.
xy
/
Xp_Y_XYZp
.
z
;
float
Le
=
2
.
0
*
log2
(
Xp_Y_XYZp
.
y
)
+
127
.
0
;
vResult
.
w
=
fract
(
Le
);
vResult
.
z
=
(
Le
-
(
floor
(
vResult
.
w
*
255
.
0
))
/
255
.
0
)
/
255
.
0
;
vResult
.
w
=
fract
(
Le
);
vResult
.
z
=
(
Le
-
(
floor
(
vResult
.
w
*
255
.
0
)
)
/
255
.
0
)
/
255
.
0
;
return
vResult
;
}
...
...
@@ -70,9 +75,9 @@ const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5
vec4
LogLuvToLinear
(
in
vec4
value
)
{
float
Le
=
value
.
z
*
255
.
0
+
value
.
w
;
vec3
Xp_Y_XYZp
;
Xp_Y_XYZp
.
y
=
exp2
(
(
Le
-
127
.
0
)
/
2
.
0
);
Xp_Y_XYZp
.
y
=
exp2
(
(
Le
-
127
.
0
)
/
2
.
0
);
Xp_Y_XYZp
.
z
=
Xp_Y_XYZp
.
y
/
value
.
y
;
Xp_Y_XYZp
.
x
=
value
.
x
*
Xp_Y_XYZp
.
z
;
vec3
vRGB
=
Xp_Y_XYZp
.
rgb
*
cLogLuvInverseM
;
return
vec4
(
max
(
vRGB
,
0
.
0
),
1
.
0
);
return
vec4
(
max
(
vRGB
,
0
.
0
),
1
.
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录