Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
576c6950
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,发现更多精彩内容 >>
提交
576c6950
编写于
10月 27, 2015
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modified struct ReflectedLight
上级
030a41fb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
43 deletion
+38
-43
src/renderers/shaders/ShaderChunk/aomap_fragment.glsl
src/renderers/shaders/ShaderChunk/aomap_fragment.glsl
+1
-1
src/renderers/shaders/ShaderChunk/common.glsl
src/renderers/shaders/ShaderChunk/common.glsl
+6
-4
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
...erers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
+5
-7
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
...rs/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
+7
-11
src/renderers/shaders/ShaderChunk/lights_template.glsl
src/renderers/shaders/ShaderChunk/lights_template.glsl
+5
-5
src/renderers/shaders/ShaderLib.js
src/renderers/shaders/ShaderLib.js
+14
-15
未找到文件。
src/renderers/shaders/ShaderChunk/aomap_fragment.glsl
浏览文件 @
576c6950
#ifdef USE_AOMAP
indirectReflectedLight
.
d
iffuse
*=
(
texture2D
(
aoMap
,
vUv2
).
r
-
1
.
0
)
*
aoMapIntensity
+
1
.
0
;
reflectedLight
.
indirectD
iffuse
*=
(
texture2D
(
aoMap
,
vUv2
).
r
-
1
.
0
)
*
aoMapIntensity
+
1
.
0
;
#endif
src/renderers/shaders/ShaderChunk/common.glsl
浏览文件 @
576c6950
...
...
@@ -12,13 +12,15 @@ float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
struct
IncidentLight
{
vec3
color
;
vec3
direction
;
vec3
color
;
vec3
direction
;
};
struct
ReflectedLight
{
vec3
specular
;
vec3
diffuse
;
vec3
directDiffuse
;
vec3
directSpecular
;
vec3
indirectDiffuse
;
vec3
indirectSpecular
;
};
struct
GeometricContext
{
...
...
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
浏览文件 @
576c6950
...
...
@@ -20,23 +20,21 @@ struct BlinnPhongMaterial {
float
specularStrength
;
};
void
BlinnPhongMaterial_RE_DirectLight
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
directR
eflectedLight
)
{
void
BlinnPhongMaterial_RE_DirectLight
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
r
eflectedLight
)
{
float
dotNL
=
saturate
(
dot
(
geometry
.
normal
,
directLight
.
direction
)
);
directReflectedLight
.
d
iffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
reflectedLight
.
directD
iffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
directReflectedLight
.
s
pecular
+=
dotNL
*
directLight
.
color
*
BRDF_Specular_BlinnPhong
(
directLight
,
geometry
,
material
.
specularColor
,
material
.
specularShininess
)
*
material
.
specularStrength
;
reflectedLight
.
directS
pecular
+=
dotNL
*
directLight
.
color
*
BRDF_Specular_BlinnPhong
(
directLight
,
geometry
,
material
.
specularColor
,
material
.
specularShininess
)
*
material
.
specularStrength
;
}
#define Material_RE_DirectLight BlinnPhongMaterial_RE_DirectLight
void
BlinnPhongMaterial_RE_IndirectDiffuseLight
(
const
in
vec3
indirectDiffuseColor
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
indirectR
eflectedLight
)
{
void
BlinnPhongMaterial_RE_IndirectDiffuseLight
(
const
in
vec3
indirectDiffuseColor
,
const
in
GeometricContext
geometry
,
const
in
BlinnPhongMaterial
material
,
inout
ReflectedLight
r
eflectedLight
)
{
//float dotNL = saturate( dot( geometry.normal, indirectLight.direction ) ); not required because result is always 1.0
indirectReflectedLight
.
diffuse
+=
indirectDiffuseColor
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
reflectedLight
.
indirectDiffuse
+=
indirectDiffuseColor
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
}
...
...
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
浏览文件 @
576c6950
...
...
@@ -6,33 +6,29 @@ struct PhysicalMaterial {
float
clearCoatRoughness
;
};
void
PhysicalMaterial_RE_DirectLight
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
directR
eflectedLight
)
{
void
PhysicalMaterial_RE_DirectLight
(
const
in
IncidentLight
directLight
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
r
eflectedLight
)
{
float
dotNL
=
saturate
(
dot
(
geometry
.
normal
,
directLight
.
direction
)
);
directReflectedLight
.
d
iffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
directReflectedLight
.
s
pecular
+=
dotNL
*
directLight
.
color
*
BRDF_Specular_GGX
(
directLight
,
geometry
,
material
.
specularColor
,
material
.
specularRoughness
);
reflectedLight
.
directD
iffuse
+=
dotNL
*
directLight
.
color
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
reflectedLight
.
directS
pecular
+=
dotNL
*
directLight
.
color
*
BRDF_Specular_GGX
(
directLight
,
geometry
,
material
.
specularColor
,
material
.
specularRoughness
);
}
#define Material_RE_DirectLight PhysicalMaterial_RE_DirectLight
void
PhysicalMaterial_RE_DiffuseIndirectLight
(
const
in
vec3
indirectDiffuseColor
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
indirectR
eflectedLight
)
{
void
PhysicalMaterial_RE_DiffuseIndirectLight
(
const
in
vec3
indirectDiffuseColor
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
r
eflectedLight
)
{
//float dotNL = saturate( dot( geometry.normal, indirectLight.direction ) ); not required because result is always 1.0
indirectReflectedLight
.
diffuse
+=
indirectDiffuseColor
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
reflectedLight
.
indirectDiffuse
+=
indirectDiffuseColor
*
BRDF_Diffuse_Lambert
(
material
.
diffuseColor
);
}
#define Material_RE_IndirectDiffuseLight PhysicalMaterial_RE_DiffuseIndirectLight
void
PhysicalMaterial_RE_SpecularIndirectLight
(
const
in
vec3
indirectSpecularColor
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
indirectReflectedLight
)
{
//float dotNL = saturate( dot( geometry.normal, indirectLight.direction ) ); not required because result is always 1.0
void
PhysicalMaterial_RE_SpecularIndirectLight
(
const
in
vec3
indirectSpecularColor
,
const
in
GeometricContext
geometry
,
const
in
PhysicalMaterial
material
,
inout
ReflectedLight
reflectedLight
)
{
indirectReflectedLight
.
s
pecular
+=
indirectSpecularColor
*
BRDF_Specular_GGX_Environment
(
geometry
,
material
.
specularColor
,
material
.
specularRoughness
);
reflectedLight
.
indirectS
pecular
+=
indirectSpecularColor
*
BRDF_Specular_GGX_Environment
(
geometry
,
material
.
specularColor
,
material
.
specularRoughness
);
}
...
...
src/renderers/shaders/ShaderChunk/lights_template.glsl
浏览文件 @
576c6950
...
...
@@ -21,7 +21,7 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
IncidentLight
directLight
=
getPointDirectLight
(
pointLights
[
i
],
geometry
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
directR
eflectedLight
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
r
eflectedLight
);
}
...
...
@@ -33,7 +33,7 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
IncidentLight
directLight
=
getSpotDirectLight
(
spotLights
[
i
],
geometry
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
directR
eflectedLight
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
r
eflectedLight
);
}
...
...
@@ -45,7 +45,7 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
IncidentLight
directLight
=
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
directR
eflectedLight
);
Material_RE_DirectLight
(
directLight
,
geometry
,
material
,
r
eflectedLight
);
}
...
...
@@ -73,7 +73,7 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
#endif
Material_RE_IndirectDiffuseLight
(
indirectDiffuseColor
,
geometry
,
material
,
indirectR
eflectedLight
);
Material_RE_IndirectDiffuseLight
(
indirectDiffuseColor
,
geometry
,
material
,
r
eflectedLight
);
}
...
...
@@ -85,7 +85,7 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
vec3
indirectSpecularColor
=
getSpecularLightProbeIndirectLightColor
(
/*specularLightProbe,*/
geometry
,
Material_LightProbeLOD
(
material
)
);
Material_RE_IndirectSpecularLight
(
indirectSpecularColor
,
geometry
,
material
,
indirectR
eflectedLight
);
Material_RE_IndirectSpecularLight
(
indirectSpecularColor
,
geometry
,
material
,
r
eflectedLight
);
}
...
...
src/renderers/shaders/ShaderLib.js
浏览文件 @
576c6950
...
...
@@ -98,13 +98,13 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
alphatest_fragment
"
],
THREE
.
ShaderChunk
[
"
specularmap_fragment
"
],
"
ReflectedLight
indirectReflectedLight = ReflectedLight( vec3( 0.0 ), diffuseColor.rgb
);
"
,
"
ReflectedLight
reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), diffuseColor.rgb, vec3( 0.0 )
);
"
,
THREE
.
ShaderChunk
[
"
aomap_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_fragment
"
],
"
indirectReflectedLight.d
iffuse *= shadowMask;
"
,
"
reflectedLight.indirectD
iffuse *= shadowMask;
"
,
"
vec3 outgoingLight =
indirectReflectedLight.d
iffuse;
"
,
"
vec3 outgoingLight =
reflectedLight.indirectD
iffuse;
"
,
THREE
.
ShaderChunk
[
"
envmap_fragment
"
],
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
...
...
@@ -370,8 +370,7 @@ THREE.ShaderLib = {
"
void main() {
"
,
"
vec4 diffuseColor = vec4( diffuse, opacity );
"
,
"
ReflectedLight directReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
vec3 totalEmissiveLight = emissive;
"
,
"
vec3 shadowMask = vec3( 1.0 );
"
,
...
...
@@ -393,16 +392,16 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
aomap_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_fragment
"
],
"
directReflectedLight.d
iffuse *= shadowMask;
"
,
"
directReflectedLight.s
pecular *= shadowMask;
"
,
"
reflectedLight.directD
iffuse *= shadowMask;
"
,
"
reflectedLight.directS
pecular *= shadowMask;
"
,
"
#ifdef METAL
"
,
"
vec3 outgoingLight = ( directReflectedLight.diffuse + indirectReflectedLight.diffuse ) * specular + directReflectedLight.specular + indirectReflectedLight.s
pecular + totalEmissiveLight;
"
,
"
vec3 outgoingLight = ( reflectedLight.directDiffuse + reflectedLight.indirectDiffuse ) * specular + reflectedLight.directSpecular + reflectedLight.indirectS
pecular + totalEmissiveLight;
"
,
"
#else
"
,
"
vec3 outgoingLight = ( directReflectedLight.diffuse + indirectReflectedLight.diffuse ) + directReflectedLight.specular + indirectReflectedLight.s
pecular + totalEmissiveLight;
"
,
"
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectS
pecular + totalEmissiveLight;
"
,
"
#endif
"
,
...
...
@@ -540,7 +539,7 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
fog_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
bsdfs
"
],
THREE
.
ShaderChunk
[
"
lights_pars
"
],
THREE
.
ShaderChunk
[
"
lights_physical_pars_fragment
"
],
// use phong chunk for now
THREE
.
ShaderChunk
[
"
lights_physical_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
bumpmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
normalmap_pars_fragment
"
],
...
...
@@ -552,8 +551,7 @@ THREE.ShaderLib = {
"
void main() {
"
,
"
vec4 diffuseColor = vec4( diffuse, opacity );
"
,
"
ReflectedLight directReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
"
,
"
vec3 totalEmissiveLight = emissive;
"
,
THREE
.
ShaderChunk
[
"
logdepthbuf_fragment
"
],
...
...
@@ -579,10 +577,11 @@ THREE.ShaderLib = {
"
vec3 shadowMask = vec3( 1.0 );
"
,
THREE
.
ShaderChunk
[
"
shadowmap_fragment
"
],
"
directReflectedLight.diffuse *= shadowMask;
"
,
"
directReflectedLight.specular *= shadowMask;
"
,
"
vec3 outgoingLight = directReflectedLight.diffuse + indirectReflectedLight.diffuse + directReflectedLight.specular + indirectReflectedLight.specular + totalEmissiveLight;
"
,
"
reflectedLight.directDiffuse *= shadowMask;
"
,
"
reflectedLight.directSpecular *= shadowMask;
"
,
"
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;
"
,
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录