Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
aa2b1390
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,体验更适合开发者的 AI 搜索 >>
提交
aa2b1390
编写于
12月 26, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up.
上级
58962a0d
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
131 addition
and
135 deletion
+131
-135
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
...rers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
+6
-6
src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
...enderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
+34
-34
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
...erers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
+18
-18
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
...rs/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
+20
-20
src/renderers/shaders/ShaderChunk/lights_template.glsl
src/renderers/shaders/ShaderChunk/lights_template.glsl
+16
-16
src/renderers/shaders/ShaderChunk/packing.glsl
src/renderers/shaders/ShaderChunk/packing.glsl
+6
-10
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
...enderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
+3
-3
src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl
src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl
+3
-3
src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl
src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl
+3
-3
src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl
...derers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl
+10
-10
src/renderers/shaders/ShaderLib/normal_frag.glsl
src/renderers/shaders/ShaderLib/normal_frag.glsl
+1
-1
src/renderers/shaders/ShaderLib/normal_vert.glsl
src/renderers/shaders/ShaderLib/normal_vert.glsl
+2
-2
src/renderers/shaders/ShaderLib/shadow_frag.glsl
src/renderers/shaders/ShaderLib/shadow_frag.glsl
+1
-1
src/renderers/shaders/UniformsLib.js
src/renderers/shaders/UniformsLib.js
+8
-8
未找到文件。
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
浏览文件 @
aa2b1390
...
...
@@ -63,32 +63,32 @@ vec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {
if
(
face
==
0
)
{
r
=
vec3
(
direction
.
x
,
-
direction
.
z
,
direction
.
y
);
offset
=
vec2
(
0
.
0
+
mipOffset
,
0
.
75
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
1
)
{
r
=
vec3
(
direction
.
y
,
direction
.
x
,
direction
.
z
);
offset
=
vec2
(
scale
+
mipOffset
,
0
.
75
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
2
)
{
r
=
vec3
(
direction
.
z
,
direction
.
x
,
direction
.
y
);
offset
=
vec2
(
2
.
0
*
scale
+
mipOffset
,
0
.
75
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
3
)
{
r
=
vec3
(
direction
.
x
,
direction
.
z
,
direction
.
y
);
offset
=
vec2
(
0
.
0
+
mipOffset
,
0
.
5
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
else
if
(
face
==
4
)
{
r
=
vec3
(
direction
.
y
,
direction
.
x
,
-
direction
.
z
);
offset
=
vec2
(
scale
+
mipOffset
,
0
.
5
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
else
{
r
=
vec3
(
direction
.
z
,
-
direction
.
x
,
direction
.
y
);
offset
=
vec2
(
2
.
0
*
scale
+
mipOffset
,
0
.
5
*
rcpPowScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
r
=
normalize
(
r
);
float
texelOffset
=
0
.
5
*
cubeUV_rcpTextureSize
;
...
...
src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl
浏览文件 @
aa2b1390
// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/
vec4
LinearToLinear
(
in
vec4
value
)
{
return
value
;
return
value
;
}
vec4
GammaToLinear
(
in
vec4
value
,
in
float
gammaFactor
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
gammaFactor
)
),
value
.
w
);
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
gammaFactor
)
),
value
.
w
);
}
vec4
LinearToGamma
(
in
vec4
value
,
in
float
gammaFactor
)
{
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
1
.
0
/
gammaFactor
)
),
value
.
w
);
return
vec4
(
pow
(
value
.
xyz
,
vec3
(
1
.
0
/
gammaFactor
)
),
value
.
w
);
}
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
.
w
);
}
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
.
w
);
}
vec4
RGBEToLinear
(
in
vec4
value
)
{
return
vec4
(
value
.
rgb
*
exp2
(
value
.
a
*
255
.
0
-
128
.
0
),
1
.
0
);
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
);
return
vec4
(
value
.
rgb
/
exp2
(
fExp
),
(
fExp
+
128
.
0
)
/
255
.
0
);
float
maxComponent
=
max
(
max
(
value
.
r
,
value
.
g
),
value
.
b
);
float
fExp
=
clamp
(
ceil
(
log2
(
maxComponent
)
),
-
128
.
0
,
127
.
0
);
return
vec4
(
value
.
rgb
/
exp2
(
fExp
),
(
fExp
+
128
.
0
)
/
255
.
0
);
// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );
}
// 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
.
xyz
*
value
.
w
*
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
;
return
vec4
(
value
.
rgb
/
(
M
*
maxRange
),
M
);
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
;
return
vec4
(
value
.
rgb
/
(
M
*
maxRange
),
M
);
}
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
vec4
RGBDToLinear
(
in
vec4
value
,
in
float
maxRange
)
{
return
vec4
(
value
.
rgb
*
(
(
maxRange
/
255
.
0
)
/
value
.
a
),
1
.
0
);
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
);
return
vec4
(
value
.
rgb
*
(
D
*
(
255
.
0
/
maxRange
)
),
D
);
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
);
return
vec4
(
value
.
rgb
*
(
D
*
(
255
.
0
/
maxRange
)
),
D
);
}
// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
...
...
@@ -55,24 +55,24 @@ vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
// M matrix, for encoding
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
));
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
;
return
vResult
;
vec3
Xp_Y_XYZp
=
value
.
rgb
*
cLogLuvM
;
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
;
return
vResult
;
}
// Inverse M matrix, for decoding
const
mat3
cLogLuvInverseM
=
mat3
(
6
.
0014
,
-
2
.
7008
,
-
1
.
7996
,
-
1
.
3320
,
3
.
1029
,
-
5
.
7721
,
0
.
3008
,
-
1
.
0882
,
5
.
6268
);
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
.
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
);
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
.
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
);
}
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
浏览文件 @
aa2b1390
...
...
@@ -17,29 +17,29 @@ struct BlinnPhongMaterial {
};
#if NUM_RECT_AREA_LIGHTS > 0
void
RE_Direct_RectArea_BlinnPhong
(
const
in
RectAreaLight
rectAreaLight
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
void
RE_Direct_RectArea_BlinnPhong
(
const
in
RectAreaLight
rectAreaLight
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
vec3
matDiffColor
=
material
.
diffuseColor
;
vec3
matSpecColor
=
material
.
specularColor
;
vec3
lightColor
=
rectAreaLight
.
color
;
vec3
matDiffColor
=
material
.
diffuseColor
;
vec3
matSpecColor
=
material
.
specularColor
;
vec3
lightColor
=
rectAreaLight
.
color
;
float
roughness
=
BlinnExponentToGGXRoughness
(
material
.
specularShininess
);
float
roughness
=
BlinnExponentToGGXRoughness
(
material
.
specularShininess
);
// Evaluate Lighting Equation
vec3
spec
=
Rect_Area_Light_Specular_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
,
roughness
,
ltcMat
,
ltcMag
);
vec3
diff
=
Rect_Area_Light_Diffuse_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
);
// Evaluate Lighting Equation
vec3
spec
=
Rect_Area_Light_Specular_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
,
roughness
,
ltcMat
,
ltcMag
);
vec3
diff
=
Rect_Area_Light_Diffuse_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
);
// TODO (abelnation): note why division by 2PI is necessary
reflectedLight
.
directSpecular
+=
lightColor
*
matSpecColor
*
spec
/
PI2
;
reflectedLight
.
directDiffuse
+=
lightColor
*
matDiffColor
*
diff
/
PI2
;
// TODO (abelnation): note why division by 2PI is necessary
reflectedLight
.
directSpecular
+=
lightColor
*
matSpecColor
*
spec
/
PI2
;
reflectedLight
.
directDiffuse
+=
lightColor
*
matDiffColor
*
diff
/
PI2
;
}
}
#endif
void
RE_Direct_BlinnPhong
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
...
...
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
浏览文件 @
aa2b1390
...
...
@@ -22,26 +22,26 @@ float clearCoatDHRApprox( const in float roughness, const in float dotNL ) {
}
#if NUM_RECT_AREA_LIGHTS > 0
void
RE_Direct_RectArea_Physical
(
const
in
RectAreaLight
rectAreaLight
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
vec3
matDiffColor
=
material
.
diffuseColor
;
vec3
matSpecColor
=
material
.
specularColor
;
vec3
lightColor
=
rectAreaLight
.
color
;
float
roughness
=
material
.
specularRoughness
;
vec3
spec
=
Rect_Area_Light_Specular_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
,
roughness
,
ltcMat
,
ltcMag
);
vec3
diff
=
Rect_Area_Light_Diffuse_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
);
reflectedLight
.
directSpecular
+=
lightColor
*
matSpecColor
*
spec
;
reflectedLight
.
directDiffuse
+=
lightColor
*
matDiffColor
*
diff
;
}
void
RE_Direct_RectArea_Physical
(
const
in
RectAreaLight
rectAreaLight
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
vec3
matDiffColor
=
material
.
diffuseColor
;
vec3
matSpecColor
=
material
.
specularColor
;
vec3
lightColor
=
rectAreaLight
.
color
;
float
roughness
=
material
.
specularRoughness
;
vec3
spec
=
Rect_Area_Light_Specular_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
,
roughness
,
ltcMat
,
ltcMag
);
vec3
diff
=
Rect_Area_Light_Diffuse_Reflectance
(
geometry
,
rectAreaLight
.
position
,
rectAreaLight
.
halfWidth
,
rectAreaLight
.
halfHeight
);
reflectedLight
.
directSpecular
+=
lightColor
*
matSpecColor
*
spec
;
reflectedLight
.
directDiffuse
+=
lightColor
*
matDiffColor
*
diff
;
}
#endif
void
RE_Direct_Physical
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
...
...
src/renderers/shaders/ShaderChunk/lights_template.glsl
浏览文件 @
aa2b1390
/
/
// This is a template that can be used to light a material, it uses pluggable RenderEquations (RE)
//
for specific lighting scenarios.
//
//
Instructions for use:
//
- Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined
//
- If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???
//
- Create a material parameter that is to be passed as the third parameter to your lighting functions.
//
//
TODO:
//
- Add area light support.
//
- Add sphere light support.
//
- Add diffuse light probe (irradiance cubemap) support.
/
/
/
**
* This is a template that can be used to light a material, it uses pluggable
* RenderEquations (RE)
for specific lighting scenarios.
*
*
Instructions for use:
*
- Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined
*
- If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???
*
- Create a material parameter that is to be passed as the third parameter to your lighting functions.
*
*
TODO:
*
- Add area light support.
*
- Add sphere light support.
*
- Add diffuse light probe (irradiance cubemap) support.
*
/
GeometricContext
geometry
;
...
...
@@ -125,7 +125,7 @@ IncidentLight directLight;
#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )
// TODO, replace 8 with the real maxMIPLevel
irradiance
+=
getLightProbeIndirectIrradiance
(
/*lightProbe,*/
geometry
,
8
);
irradiance
+=
getLightProbeIndirectIrradiance
(
/*lightProbe,*/
geometry
,
8
);
#endif
...
...
@@ -143,7 +143,7 @@ IncidentLight directLight;
#else
vec3
clearCoatRadiance
=
vec3
(
0
.
0
);
#endif
RE_IndirectSpecular
(
radiance
,
clearCoatRadiance
,
geometry
,
material
,
reflectedLight
);
#endif
src/renderers/shaders/ShaderChunk/packing.glsl
浏览文件 @
aa2b1390
vec3
packNormalToRGB
(
const
in
vec3
normal
)
{
return
normalize
(
normal
)
*
0
.
5
+
0
.
5
;
return
normalize
(
normal
)
*
0
.
5
+
0
.
5
;
}
vec3
unpackRGBToNormal
(
const
in
vec3
rgb
)
{
return
1
.
0
-
2
.
0
*
rgb
.
xyz
;
return
1
.
0
-
2
.
0
*
rgb
.
xyz
;
}
const
float
PackUpscale
=
256
.
/
255
.;
// fraction -> 0..1 (including 1)
...
...
@@ -15,31 +15,27 @@ const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const
float
ShiftRight8
=
1
.
/
256
.;
vec4
packDepthToRGBA
(
const
in
float
v
)
{
vec4
r
=
vec4
(
fract
(
v
*
PackFactors
),
v
);
r
.
yzw
-=
r
.
xyz
*
ShiftRight8
;
// tidy overflow
return
r
*
PackUpscale
;
}
float
unpackRGBAToDepth
(
const
in
vec4
v
)
{
return
dot
(
v
,
UnpackFactors
);
}
// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions
float
viewZToOrthographicDepth
(
const
in
float
viewZ
,
const
in
float
near
,
const
in
float
far
)
{
return
(
viewZ
+
near
)
/
(
near
-
far
);
return
(
viewZ
+
near
)
/
(
near
-
far
);
}
float
orthographicDepthToViewZ
(
const
in
float
linearClipZ
,
const
in
float
near
,
const
in
float
far
)
{
return
linearClipZ
*
(
near
-
far
)
-
near
;
return
linearClipZ
*
(
near
-
far
)
-
near
;
}
float
viewZToPerspectiveDepth
(
const
in
float
viewZ
,
const
in
float
near
,
const
in
float
far
)
{
return
((
near
+
viewZ
)
*
far
)
/
((
far
-
near
)
*
viewZ
);
return
((
near
+
viewZ
)
*
far
)
/
((
far
-
near
)
*
viewZ
);
}
float
perspectiveDepthToViewZ
(
const
in
float
invClipZ
,
const
in
float
near
,
const
in
float
far
)
{
return
(
near
*
far
)
/
(
(
far
-
near
)
*
invClipZ
-
far
);
return
(
near
*
far
)
/
(
(
far
-
near
)
*
invClipZ
-
far
);
}
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
浏览文件 @
aa2b1390
...
...
@@ -21,9 +21,9 @@
#endif
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): create uniforms for area light shadows
#endif
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): create uniforms for area light shadows
#endif
float
texture2DCompare
(
sampler2D
depths
,
vec2
uv
,
float
compare
)
{
...
...
src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl
浏览文件 @
aa2b1390
...
...
@@ -21,10 +21,10 @@
#endif
#if NUM_RECT_AREA_LIGHTS > 0
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): uniforms for area light shadows
// TODO (abelnation): uniforms for area light shadows
#endif
#endif
#endif
src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl
浏览文件 @
aa2b1390
...
...
@@ -30,10 +30,10 @@
#endif
#if NUM_RECT_AREA_LIGHTS > 0
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): update vAreaShadowCoord with area light info
// TODO (abelnation): update vAreaShadowCoord with area light info
#endif
#endif
#endif
src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl
浏览文件 @
aa2b1390
...
...
@@ -6,15 +6,15 @@ uniform float toneMappingWhitePoint;
// exposure only
vec3
LinearToneMapping
(
vec3
color
)
{
return
toneMappingExposure
*
color
;
return
toneMappingExposure
*
color
;
}
// source: https://www.cs.utah.edu/~reinhard/cdrom/
vec3
ReinhardToneMapping
(
vec3
color
)
{
color
*=
toneMappingExposure
;
return
saturate
(
color
/
(
vec3
(
1
.
0
)
+
color
)
);
color
*=
toneMappingExposure
;
return
saturate
(
color
/
(
vec3
(
1
.
0
)
+
color
)
);
}
...
...
@@ -22,18 +22,18 @@ vec3 ReinhardToneMapping( vec3 color ) {
#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )
vec3
Uncharted2ToneMapping
(
vec3
color
)
{
// John Hable's filmic operator from Uncharted 2 video game
color
*=
toneMappingExposure
;
return
saturate
(
Uncharted2Helper
(
color
)
/
Uncharted2Helper
(
vec3
(
toneMappingWhitePoint
)
)
);
// John Hable's filmic operator from Uncharted 2 video game
color
*=
toneMappingExposure
;
return
saturate
(
Uncharted2Helper
(
color
)
/
Uncharted2Helper
(
vec3
(
toneMappingWhitePoint
)
)
);
}
// source: http://filmicgames.com/archives/75
vec3
OptimizedCineonToneMapping
(
vec3
color
)
{
// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
color
*=
toneMappingExposure
;
color
=
max
(
vec3
(
0
.
0
),
color
-
0
.
004
);
return
pow
(
(
color
*
(
6
.
2
*
color
+
0
.
5
)
)
/
(
color
*
(
6
.
2
*
color
+
1
.
7
)
+
0
.
06
),
vec3
(
2
.
2
)
);
// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
color
*=
toneMappingExposure
;
color
=
max
(
vec3
(
0
.
0
),
color
-
0
.
004
);
return
pow
(
(
color
*
(
6
.
2
*
color
+
0
.
5
)
)
/
(
color
*
(
6
.
2
*
color
+
1
.
7
)
+
0
.
06
),
vec3
(
2
.
2
)
);
}
src/renderers/shaders/ShaderLib/normal_frag.glsl
浏览文件 @
aa2b1390
...
...
@@ -2,7 +2,7 @@
uniform
float
opacity
;
#if defined( FLAT_SHADED
) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
varying
vec3
vViewPosition
;
...
...
src/renderers/shaders/ShaderLib/normal_vert.glsl
浏览文件 @
aa2b1390
#define NORMAL
#if defined( FLAT_SHADED
) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
varying
vec3
vViewPosition
;
...
...
@@ -41,7 +41,7 @@ void main() {
#include <project_vertex>
#include <logdepthbuf_vertex>
#if defined( FLAT_SHADED
) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
vViewPosition
=
-
mvPosition
.
xyz
;
...
...
src/renderers/shaders/ShaderLib/shadow_frag.glsl
浏览文件 @
aa2b1390
...
...
@@ -9,6 +9,6 @@ uniform float opacity;
void
main
()
{
gl_FragColor
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
opacity
*
(
1
.
0
-
getShadowMask
()
)
);
gl_FragColor
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
opacity
*
(
1
.
0
-
getShadowMask
()
)
);
}
src/renderers/shaders/UniformsLib.js
浏览文件 @
aa2b1390
...
...
@@ -152,13 +152,13 @@ var UniformsLib = {
groundColor
:
{}
}
},
// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
rectAreaLights
:
{
value
:
[],
properties
:
{
color
:
{},
position
:
{},
width
:
{},
height
:
{},
}
}
// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
rectAreaLights
:
{
value
:
[],
properties
:
{
color
:
{},
position
:
{},
width
:
{},
height
:
{}
}
}
},
...
...
@@ -175,4 +175,4 @@ var UniformsLib = {
};
export
{
UniformsLib
};
\ No newline at end of file
export
{
UniformsLib
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录