Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
c2903521
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,发现更多精彩内容 >>
提交
c2903521
编写于
10月 20, 2015
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify light factories.
上级
8c8f538f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
28 deletion
+24
-28
src/renderers/shaders/ShaderChunk/lights.glsl
src/renderers/shaders/ShaderChunk/lights.glsl
+16
-4
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
+4
-12
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
+4
-12
未找到文件。
src/renderers/shaders/ShaderChunk/lights.glsl
浏览文件 @
c2903521
...
...
@@ -10,11 +10,14 @@ uniform vec3 ambientLightColor;
uniform
DirectionalLight
directionalLights
[
MAX_DIR_LIGHTS
];
void
getDirectionalDirectLight
(
const
in
DirectionalLight
directionalLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
directLight
)
{
IncidentLight
getDirectionalDirectLight
(
const
in
DirectionalLight
directionalLight
,
const
in
GeometricContext
geometry
)
{
IncidentLight
directLight
;
directLight
.
color
=
directionalLight
.
color
;
directLight
.
direction
=
directionalLight
.
direction
;
return
directLight
;
}
#endif
...
...
@@ -31,8 +34,10 @@ uniform vec3 ambientLightColor;
uniform
PointLight
pointLights
[
MAX_POINT_LIGHTS
];
void
getPointDirectLight
(
const
in
PointLight
pointLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
directLight
)
{
IncidentLight
getPointDirectLight
(
const
in
PointLight
pointLight
,
const
in
GeometricContext
geometry
)
{
IncidentLight
directLight
;
vec3
lightPosition
=
pointLight
.
position
;
vec3
lVector
=
lightPosition
-
geometry
.
position
;
...
...
@@ -41,6 +46,7 @@ uniform vec3 ambientLightColor;
directLight
.
color
=
pointLight
.
color
;
directLight
.
color
*=
calcLightAttenuation
(
length
(
lVector
),
pointLight
.
distance
,
pointLight
.
decay
);
return
directLight
;
}
#endif
...
...
@@ -60,8 +66,10 @@ uniform vec3 ambientLightColor;
uniform
SpotLight
spotLights
[
MAX_SPOT_LIGHTS
];
void
getSpotDirectLight
(
const
in
SpotLight
spotLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
directLight
)
{
IncidentLight
getSpotDirectLight
(
const
in
SpotLight
spotLight
,
const
in
GeometricContext
geometry
)
{
IncidentLight
directLight
;
vec3
lightPosition
=
spotLight
.
position
;
vec3
lVector
=
lightPosition
-
geometry
.
position
;
...
...
@@ -73,6 +81,7 @@ uniform vec3 ambientLightColor;
directLight
.
color
=
spotLight
.
color
;
directLight
.
color
*=
(
spotEffect
*
calcLightAttenuation
(
length
(
lVector
),
spotLight
.
distance
,
spotLight
.
decay
)
);
return
directLight
;
}
#endif
...
...
@@ -88,14 +97,17 @@ uniform vec3 ambientLightColor;
uniform
HemisphereLight
hemisphereLights
[
MAX_HEMI_LIGHTS
];
void
getHemisphereIndirectLight
(
const
in
HemisphereLight
hemiLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
indirectLight
)
{
IncidentLight
getHemisphereIndirectLight
(
const
in
HemisphereLight
hemiLight
,
const
in
GeometricContext
geometry
)
{
IncidentLight
directLight
;
float
dotNL
=
dot
(
geometry
.
normal
,
hemiLight
.
direction
);
float
hemiDiffuseWeight
=
0
.
5
*
dotNL
+
0
.
5
;
indirectLight
.
color
=
mix
(
hemiLight
.
groundColor
,
hemiLight
.
skyColor
,
hemiDiffuseWeight
);
indirectLight
.
direction
=
geometry
.
normal
;
return
indirectLight
;
}
#endif
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
浏览文件 @
c2903521
...
...
@@ -10,9 +10,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_POINT_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getPointDirectLight
(
pointLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getPointDirectLight
(
pointLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
frontReflectedLight
);
...
...
@@ -30,9 +28,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_SPOT_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getSpotDirectLight
(
spotLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getSpotDirectLight
(
spotLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
frontReflectedLight
);
...
...
@@ -50,9 +46,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_DIR_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
frontReflectedLight
);
...
...
@@ -70,9 +64,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
IncidentLight
indirectLight
;
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
,
indirectLight
);
IncidentLight
indirectLight
=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
);
BRDF_Lambert
(
indirectLight
,
geometry
,
diffuse
,
frontReflectedLight
);
...
...
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
浏览文件 @
c2903521
...
...
@@ -25,9 +25,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_POINT_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getPointDirectLight
(
pointLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getPointDirectLight
(
pointLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight );
...
...
@@ -42,9 +40,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_SPOT_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getSpotDirectLight
(
spotLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getSpotDirectLight
(
spotLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight );
...
...
@@ -59,9 +55,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_DIR_LIGHTS
;
i
++
)
{
IncidentLight
directLight
;
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
,
directLight
);
IncidentLight
directLight
=
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight );
...
...
@@ -76,9 +70,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
IncidentLight
indirectLight
;
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
,
indirectLight
);
IncidentLight
indirectLight
=
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
);
BRDF_Lambert
(
indirectLight
,
geometry
,
diffuse
,
indirectReflectedLight
);
//BRDF_OrenNayar( indirectLight, geometry, diffuse, 0.5, indirectReflectedLight );
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录