Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
3ca76ecd
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
3ca76ecd
编写于
2月 20, 2016
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make encodings.glsl more reusable.
上级
7c2ffd14
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
74 addition
and
57 deletion
+74
-57
src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl
src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl
+1
-1
src/renderers/shaders/ShaderChunk/encodings.glsl
src/renderers/shaders/ShaderChunk/encodings.glsl
+69
-52
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
+1
-1
src/renderers/shaders/ShaderChunk/lights_pars.glsl
src/renderers/shaders/ShaderChunk/lights_pars.glsl
+2
-2
src/renderers/shaders/ShaderChunk/map_fragment.glsl
src/renderers/shaders/ShaderChunk/map_fragment.glsl
+1
-1
未找到文件。
src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl
浏览文件 @
3ca76ecd
...
...
@@ -2,7 +2,7 @@
vec4
emissiveColor
=
texture2D
(
emissiveMap
,
vUv
);
emissiveColor
.
rgb
=
texelDecode
(
emissiveColor
,
emissiveMapEncoding
).
rgb
;
emissiveColor
.
rgb
=
EncodingToLinear
(
emissiveColor
,
emissiveMapEncoding
).
rgb
;
totalEmissiveLight
*=
emissiveColor
.
rgb
;
...
...
src/renderers/shaders/ShaderChunk/encodings.glsl
浏览文件 @
3ca76ecd
...
...
@@ -9,79 +9,96 @@
#define ENCODING_RGBM16 3005
//#define ENCODING_RGBM16 3007
vec4
texelDecode
(
in
vec4
encodedTexel
,
in
int
encoding
)
{
vec4
LinearToLinear
(
in
vec4
value
)
{
return
value
;
}
// Q: should we use a switch statement here instead of a set of ifs?
vec4
sRGBToLinear
(
in
vec4
value
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
float
(
GAMMA_FACTOR
)
)
),
value
.
w
);
}
if
(
encoding
==
ENCODING_Linear
)
{
return
encodedTexel
;
}
vec4
RGBEToLinear
(
in
vec4
value
)
{
return
vec4
(
value
.
xyz
*
exp2
(
value
.
w
*
256
.
0
-
128
.
0
),
1
.
0
)
;
}
if
(
encoding
==
ENCODING_sRGB
)
{
return
vec4
(
pow
(
encodedTexel
.
xyz
,
vec3
(
float
(
GAMMA_FACTOR
)
)
),
encodedTexel
.
w
);
}
vec4
RGBM7ToLinear
(
in
vec4
value
)
{
return
vec4
(
value
.
xyz
*
value
.
w
*
7
.
0
,
1
.
0
);
}
if
(
encoding
==
ENCODING_RGBE
)
{
return
vec4
(
encodedTexel
.
xyz
*
exp2
(
encodedTexel
.
w
*
256
.
0
-
128
.
0
)
,
1
.
0
);
}
vec4
RGBM16ToLinear
(
in
vec4
value
)
{
return
vec4
(
value
.
xyz
*
value
.
w
*
16
.
0
,
1
.
0
);
}
// TODO, see here http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
//if( encoding == ENCODING_LogLuv ) {
//
}
vec4
LinearTosRGB
(
in
vec4
value
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
1
.
0
/
float
(
GAMMA_FACTOR
)
)
),
value
.
w
);
}
if
(
encoding
==
ENCODING_RGBM7
)
{
return
vec4
(
encodedTexel
.
xyz
*
encodedTexel
.
w
*
7
.
0
,
1
.
0
);
}
vec4
LinearToRGBE
(
in
vec4
value
)
{
float
maxComponent
=
max
(
max
(
value
.
r
,
value
.
g
),
value
.
b
);
float
fExp
=
ceil
(
log2
(
maxComponent
)
);
return
vec4
(
value
.
rgb
/
exp2
(
fExp
),
(
fExp
+
128
.
0
)
/
255
.
0
);
}
if
(
encoding
==
ENCODING_RGBM16
)
{
return
vec4
(
encodedTexel
.
xyz
*
encodedTexel
.
w
*
16
.
0
,
1
.
0
);
}
vec4
EncodingToLinear
(
in
vec4
value
,
in
int
fromEncoding
)
{
switch
(
fromEncoding
)
{
case
ENCODING_Linear
:
return
value
;
// TODO
//if( encoding == ENCODING_RGBD ) {
//}
case
ENCODING_sRGB
:
return
LinearTosRGB
(
value
);
// return red when encoding not supported
//case ENCODING_LogLuv:
// return LinearToLogLuv( value );
case
ENCODING_RGBE
:
return
LinearToRGBE
(
value
);
case
ENCODING_RGBM7
:
return
LinearToRGBM7
(
value
);
case
ENCODING_RGBM16
:
return
LinearToRGBM16
(
value
);
//case ENCODING_RGBD:
// return LinearToRGBD( value );
default:
return
vec4
(
1
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
}
}
vec4
texelEncode
(
in
vec4
linearRgba
,
in
int
e
ncoding
)
vec4
LinearToEncoding
(
in
vec4
value
,
in
int
toE
ncoding
)
{
switch
(
toEncoding
)
{
// Q: should we use a switch statement here instead of a set of ifs?
case
ENCODING_Linear
:
return
value
;
if
(
encoding
==
ENCODING_Linear
)
{
return
linearRgba
;
}
case
ENCODING_sRGB
:
return
sRGBToLinear
(
value
);
if
(
encoding
==
ENCODING_sRGB
)
{
return
vec4
(
pow
(
linearRgba
.
xyz
,
vec3
(
1
.
0
/
float
(
GAMMA_FACTOR
)
)
),
linearRgba
.
w
);
}
//case ENCODING_LogLuv:
// return LogLuvToLinear( value );
if
(
encoding
==
ENCODING_RGBE
)
{
float
maxComponent
=
max
(
max
(
linearRgba
.
r
,
linearRgba
.
g
),
linearRgba
.
b
);
float
fExp
=
ceil
(
log2
(
maxComponent
)
);
return
vec4
(
linearRgba
.
rgb
/
exp2
(
fExp
),
(
fExp
+
128
.
0
)
/
255
.
0
);
}
case
ENCODING_RGBE
:
return
RGBEToLinear
(
value
);
// TODO, see here http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
//if( encoding == ENCODING_LogLuv ) {
//}
//case ENCODING_RGBM7:
// return RGBM7ToLinear( value );
// TODO
//if( encoding == ENCODING_RGBM7 ) {
//}
//case ENCODING_RGBM16:
// return RGBM16ToLinear( value );
// TODO
//if( encoding == ENCODING_RGBM16 ) {
//}
//case ENCODING_RGBD:
// return RGBDToLinear( value );
// TODO
//if( encoding == ENCODING_RGBD ) {
//}
// return red when encoding not supported
default:
return
vec4
(
1
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
}
}
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
浏览文件 @
3ca76ecd
...
...
@@ -43,7 +43,7 @@
vec4
envColor
=
texture2D
(
envMap
,
reflectView
.
xy
*
0
.
5
+
0
.
5
);
#endif
envColor
=
texelDecode
(
envColor
,
envMapEncoding
);
envColor
=
EncodingToLinear
(
envColor
,
envMapEncoding
);
#ifdef ENVMAP_BLENDING_MULTIPLY
...
...
src/renderers/shaders/ShaderChunk/lights_pars.glsl
浏览文件 @
3ca76ecd
...
...
@@ -186,7 +186,7 @@
#endif
envMapColor
.
rgb
=
texelDecode
(
envMapColor
,
envMapEncoding
).
rgb
;
envMapColor
.
rgb
=
EncodingToLinear
(
envMapColor
,
envMapEncoding
).
rgb
;
return
PI
*
envMapColor
.
rgb
*
envMapIntensity
;
...
...
@@ -278,7 +278,7 @@
#endif
envMapColor
.
rgb
=
texelDecode
(
envMapColor
,
envMapEncoding
).
rgb
;
envMapColor
.
rgb
=
EncodingToLinear
(
envMapColor
,
envMapEncoding
).
rgb
;
return
envMapColor
.
rgb
*
envMapIntensity
;
...
...
src/renderers/shaders/ShaderChunk/map_fragment.glsl
浏览文件 @
3ca76ecd
...
...
@@ -2,7 +2,7 @@
vec4
texelColor
=
texture2D
(
map
,
vUv
);
texelColor
=
texelDecode
(
texelColor
,
mapEncoding
);
texelColor
=
EncodingToLinear
(
texelColor
,
mapEncoding
);
diffuseColor
*=
texelColor
;
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录