Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ce22ecc9
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,发现更多精彩内容 >>
提交
ce22ecc9
编写于
10月 21, 2015
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perfect backwards compatibility for envmap_fragment for phong.
上级
89b3dac2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
39 deletion
+50
-39
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
+3
-3
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
+42
-32
src/renderers/shaders/ShaderChunk/lights_pars.glsl
src/renderers/shaders/ShaderChunk/lights_pars.glsl
+1
-1
src/renderers/shaders/ShaderLib.js
src/renderers/shaders/ShaderLib.js
+4
-3
未找到文件。
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl
浏览文件 @
ce22ecc9
...
...
@@ -47,15 +47,15 @@
#ifdef ENVMAP_BLENDING_MULTIPLY
indirectReflectedLight
.
specular
=
mix
(
indirectReflectedLight
.
specular
,
indirectReflectedLight
.
specular
*
envColor
.
xyz
,
specularStrength
*
reflectivity
);
outgoingLight
=
mix
(
outgoingLight
,
outgoingLight
*
envColor
.
xyz
,
specularStrength
*
reflectivity
);
#elif defined( ENVMAP_BLENDING_MIX )
indirectReflectedLight
.
specular
=
mix
(
indirectReflectedLight
.
specular
,
envColor
.
xyz
,
specularStrength
*
reflectivity
);
outgoingLight
=
mix
(
outgoingLight
,
envColor
.
xyz
,
specularStrength
*
reflectivity
);
#elif defined( ENVMAP_BLENDING_ADD )
indirectReflectedLight
.
specular
+=
envColor
.
xyz
*
specularStrength
*
reflectivity
;
outgoingLight
+=
envColor
.
xyz
*
specularStrength
*
reflectivity
;
#endif
...
...
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
浏览文件 @
ce22ecc9
...
...
@@ -3,22 +3,19 @@ vec3 diffuse = vec3( 1.0 );
GeometricContext
geometry
=
GeometricContext
(
mvPosition
.
xyz
,
normalize
(
transformedNormal
),
normalize
(
-
mvPosition
.
xyz
)
);
GeometricContext
backGeometry
=
GeometricContext
(
geometry
.
position
,
-
geometry
.
normal
,
geometry
.
viewDir
);
ReflectedLight
frontReflectedLight
=
ReflectedLight
(
vec3
(
0
.
0
),
vec3
(
0
.
0
)
);
ReflectedLight
backReflectedLight
=
ReflectedLight
(
vec3
(
0
.
0
),
vec3
(
0
.
0
)
);
#if MAX_POINT_LIGHTS > 0
for
(
int
i
=
0
;
i
<
MAX_POINT_LIGHTS
;
i
++
)
{
IncidentLight
directLight
=
getPointDirectLight
(
pointLights
[
i
],
geometry
);
float
dotNL
=
dot
(
geometry
.
normal
,
directLight
.
direction
);
frontReflectedLight
.
diffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
float
dotNL
=
saturate
(
dot
(
geometry
.
normal
,
directLight
.
direction
)
);
vLightFront
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
#ifdef DOUBLE_SIDED
float
dotNLBack
=
dot
(
-
geometry
.
normal
,
directLight
.
direction
);
backReflectedLight
.
diffuse
+=
dotNLBack
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
float
backDotNL
=
saturate
(
dot
(
-
geometry
.
normal
,
directLight
.
direction
)
);
vLightBack
+=
backDotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
#endif
...
...
@@ -32,13 +29,13 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
IncidentLight
directLight
=
getSpotDirectLight
(
spotLights
[
i
],
geometry
);
float
dotNL
=
dot
(
geometry
.
normal
,
directLight
.
direction
);
frontReflectedLight
.
diffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
float
dotNL
=
saturate
(
dot
(
geometry
.
normal
,
directLight
.
direction
)
);
vLightFront
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
#ifdef DOUBLE_SIDED
float
dotNLBack
=
dot
(
-
geometry
.
normal
,
directLight
.
direction
);
backReflectedLight
.
diffuse
+=
dotNLBack
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
float
backDotNL
=
saturate
(
dot
(
-
geometry
.
normal
,
directLight
.
direction
)
);
vLightBack
+=
backDotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
#endif
}
...
...
@@ -51,13 +48,13 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
IncidentLight
directLight
=
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
);
float
dotNL
=
dot
(
geometry
.
normal
,
directLight
.
direction
);
frontReflectedLight
.
diffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
float
dotNL
=
saturate
(
dot
(
geometry
.
normal
,
directLight
.
direction
)
);
vLightFront
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
#ifdef DOUBLE_SIDED
float
dotNLBack
=
dot
(
-
geometry
.
normal
,
directLight
.
direction
);
backReflectedLight
.
diffuse
+=
dotNLBack
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
float
backDotNL
=
saturate
(
dot
(
-
geometry
.
normal
,
directLight
.
direction
)
);
vLightBack
+=
backDotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
#endif
...
...
@@ -65,32 +62,45 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
#endif
#if MAX_HEMI_LIGHTS > 0
{
IncidentLight
frontIndirectLight
;
frontIndirectLight
.
direction
=
geometry
.
normal
;
frontIndirectLight
.
color
=
ambientLightColor
;
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
#ifdef DOUBLE_SIDED
IncidentLight
backIndirectLight
;
backIndirectLight
.
direction
=
-
geometry
.
normal
;
backIndirectLight
.
color
=
ambientLightColor
;
IncidentLight
indirectLight
=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
);
#endif
float
dotNL
=
dot
(
geometry
.
normal
,
directLight
.
direction
);
frontReflectedLight
.
diffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
geometry
,
diffuse
);
#if MAX_HEMI_LIGHTS > 0
#ifdef DOUBLE_SIDED
indirectLight
=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
backGeometry
);
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
float
dotNLBack
=
dot
(
-
geometry
.
normal
,
directLight
.
direction
);
backReflectedLight
.
diffuse
+=
dotNLBack
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
directLight
,
backGeometry
,
diffuse
);
frontIndirectLight
.
color
+=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
).
color
;
#endif
}
#ifdef DOUBLE_SIDED
backIndirectLight
.
color
+=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
backGeometry
).
color
;
#endif
#endif
}
vLightFront
=
frontReflectedLight
.
diffuse
;
#endif
#ifdef DOUBLE_SIDED
float
frontDotNL
=
saturate
(
dot
(
geometry
.
normal
,
frontIndirectLight
.
direction
)
);
vLightFront
+=
frontDotNL
*
frontIndirectLight
.
color
*
BRDF_Diffuse_Lambert
(
frontIndirectLight
,
geometry
,
diffuse
);
vLightBack
=
backReflectedLight
.
diffuse
;
#ifdef DOUBLE_SIDED
float
backDotNL
=
saturate
(
dot
(
-
geometry
.
normal
,
backIndirectLight
.
direction
)
);
vLightBack
+=
backDotNL
*
backIndirectLight
.
color
*
BRDF_Diffuse_Lambert
(
backIndirectLight
,
backGeometry
,
diffuse
);
#endif
#endif
\ No newline at end of file
}
\ No newline at end of file
src/renderers/shaders/ShaderChunk/lights_pars.glsl
浏览文件 @
ce22ecc9
...
...
@@ -122,7 +122,7 @@ uniform vec3 ambientLightColor;
#endif
#if
def USE_ENVMAP
#if
defined( USE_ENVMAP ) && defined( PHYSICAL )
IncidentLight
getSpecularLightProbeIndirectLight
(
/*const in SpecularLightProbe specularLightProbe,*/
const
in
GeometricContext
geometry
,
const
in
float
lodLevel
)
{
...
...
src/renderers/shaders/ShaderLib.js
浏览文件 @
ce22ecc9
...
...
@@ -101,14 +101,13 @@ THREE.ShaderLib = {
"
ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), diffuse );
"
,
THREE
.
ShaderChunk
[
"
aomap_fragment
"
],
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_fragment
"
],
"
indirectReflectedLight.diffuse *= shadowMask;
"
,
"
vec3 outgoingLight = indirectReflectedLight.diffuse;
"
,
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_fragment
"
],
"
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
"
,
...
...
@@ -241,6 +240,8 @@ THREE.ShaderLib = {
"
#endif
"
,
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_fragment
"
],
...
...
@@ -388,7 +389,6 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
lightmap_fragment
"
],
// modulation
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
aomap_fragment
"
],
"
vec3 shadowMask = vec3( 1.0 );
"
,
...
...
@@ -406,6 +406,7 @@ THREE.ShaderLib = {
"
#endif
"
,
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_fragment
"
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录