Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3c9e00fe
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,发现更多精彩内容 >>
提交
3c9e00fe
编写于
10月 20, 2015
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get skin, tone mapping and terrain examples working with new BSDF and light structures.
上级
bbc81cdb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
113 addition
and
147 deletion
+113
-147
examples/js/ShaderSkin.js
examples/js/ShaderSkin.js
+18
-43
examples/js/ShaderTerrain.js
examples/js/ShaderTerrain.js
+11
-33
examples/webgl_shaders_tonemapping.html
examples/webgl_shaders_tonemapping.html
+6
-3
src/renderers/shaders/ShaderChunk/bsdfs.glsl
src/renderers/shaders/ShaderChunk/bsdfs.glsl
+0
-18
src/renderers/shaders/ShaderChunk/common.glsl
src/renderers/shaders/ShaderChunk/common.glsl
+18
-0
src/renderers/shaders/ShaderChunk/lights.glsl
src/renderers/shaders/ShaderChunk/lights.glsl
+16
-18
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
+21
-15
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
+23
-17
未找到文件。
examples/js/ShaderSkin.js
浏览文件 @
3c9e00fe
...
...
@@ -200,7 +200,7 @@ THREE.ShaderSkin = {
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
,
"
vec3 dirVector = directionalLight[ i ].direction;
"
,
"
vec3 dirVector = directionalLight
s
[ i ].direction;
"
,
"
float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );
"
,
"
float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );
"
,
...
...
@@ -208,8 +208,8 @@ THREE.ShaderSkin = {
"
float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );
"
,
"
totalDiffuseLight += directionalLight[ i ].color * dirDiffuseWeight;
"
,
"
totalSpecularLight += directionalLight[ i ].color * ( dirSpecularWeight * specularStrength );
"
,
"
totalDiffuseLight += directionalLight
s
[ i ].color * dirDiffuseWeight;
"
,
"
totalSpecularLight += directionalLight
s
[ i ].color * ( dirSpecularWeight * specularStrength );
"
,
"
}
"
,
...
...
@@ -369,19 +369,10 @@ THREE.ShaderSkin = {
"
uniform vec3 ambientLightColor;
"
,
"
#if MAX_DIR_LIGHTS > 0
"
,
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
,
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
,
"
#endif
"
,
"
#if MAX_POINT_LIGHTS > 0
"
,
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
,
"
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
"
,
"
#endif
"
,
"
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
lights
"
],
THREE
.
ShaderChunk
[
"
fog_pars_fragment
"
],
"
float fresnelReflectance( vec3 H, vec3 V, float F0 ) {
"
,
...
...
@@ -464,11 +455,12 @@ THREE.ShaderSkin = {
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
vec3 pointVector = normalize( vPointLight[ i ].xyz );
"
,
"
float attenuation = vPointLight[ i ].w;
"
,
"
vec3 pointVector = normalize( pointLights[ i ].direction );
"
,
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );
"
,
"
totalDiffuseLight += pointLightColor[ i ] * ( pointDiffuseWeight * attenuation );
"
,
"
if ( passID == 1 ) {
"
,
...
...
@@ -489,17 +481,18 @@ THREE.ShaderSkin = {
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
,
"
vec3 dirVector = directionalLight
Direction[ i ]
;
"
,
"
vec3 dirVector = directionalLight
s[ i ].direction
;
"
,
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
,
"
totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;
"
,
"
totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;
"
,
"
if ( passID == 1 ) {
"
,
"
float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );
"
,
"
totalSpecularLight += directionalLight
Color[ i ]
* mSpecular.xyz * dirSpecularWeight;
"
,
"
totalSpecularLight += directionalLight
s[ i ].color
* mSpecular.xyz * dirSpecularWeight;
"
,
"
}
"
,
...
...
@@ -580,19 +573,10 @@ THREE.ShaderSkin = {
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
#if MAX_POINT_LIGHTS > 0
"
,
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
"
,
"
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
"
,
"
#endif
"
,
"
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
lights
"
],
"
void main() {
"
,
...
...
@@ -612,9 +596,9 @@ THREE.ShaderSkin = {
"
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
"
,
"
vec3 lVector = pointLight
Position[ i ]
- vViewPosition;
"
,
"
vec3 lVector = pointLight
s[ i ].position
- vViewPosition;
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
Distance[ i ], pointLightDecay[i]
);
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
s[ i ].distance, pointLights[ i ].decay
);
"
,
"
lVector = normalize( lVector );
"
,
...
...
@@ -648,19 +632,10 @@ THREE.ShaderSkin = {
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
#if MAX_POINT_LIGHTS > 0
"
,
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
"
,
"
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
"
,
"
#endif
"
,
"
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
lights
"
],
"
void main() {
"
,
...
...
@@ -680,9 +655,9 @@ THREE.ShaderSkin = {
"
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
"
,
"
vec3 lVector = pointLight
Position[ i ]
- vViewPosition;
"
,
"
vec3 lVector = pointLight
s[ i ].position
- vViewPosition;
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
Distance[ i ], pointLightDecay[i]
);
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
s[ i ].distance, pointLights[ i ].decay
);
"
,
"
lVector = normalize( lVector );
"
,
...
...
examples/js/ShaderTerrain.js
浏览文件 @
3c9e00fe
...
...
@@ -86,33 +86,11 @@ THREE.ShaderTerrain = {
"
uniform vec3 ambientLightColor;
"
,
"
#if MAX_DIR_LIGHTS > 0
"
,
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
,
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
,
"
#endif
"
,
"
#if MAX_HEMI_LIGHTS > 0
"
,
"
uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
"
,
"
uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
"
,
"
uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
"
,
"
#endif
"
,
"
#if MAX_POINT_LIGHTS > 0
"
,
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
,
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
"
,
"
uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
"
,
"
#endif
"
,
"
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
bsdfs
"
],
THREE
.
ShaderChunk
[
"
lights
"
],
THREE
.
ShaderChunk
[
"
shadowmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_pars_fragment
"
],
...
...
@@ -168,9 +146,9 @@ THREE.ShaderTerrain = {
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
vec3 lVector = pointLight
Position[ i ]
+ vViewPosition.xyz;
"
,
"
vec3 lVector = pointLight
s[ i ].position
+ vViewPosition.xyz;
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
Distance[ i ], pointLightDecay[i]
);
"
,
"
float attenuation = calcLightAttenuation( length( lVector ), pointLight
s[ i ].distance, pointLights[ i ].decay
);
"
,
"
lVector = normalize( lVector );
"
,
...
...
@@ -181,8 +159,8 @@ THREE.ShaderTerrain = {
"
float pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );
"
,
"
totalDiffuseLight += attenuation * pointLight
Color[ i ]
* pointDiffuseWeight;
"
,
"
totalSpecularLight += attenuation * pointLight
Color[ i ]
* specular * pointSpecularWeight * pointDiffuseWeight;
"
,
"
totalDiffuseLight += attenuation * pointLight
s[ i ].color
* pointDiffuseWeight;
"
,
"
totalSpecularLight += attenuation * pointLight
s[ i ].color
* specular * pointSpecularWeight * pointDiffuseWeight;
"
,
"
}
"
,
...
...
@@ -197,7 +175,7 @@ THREE.ShaderTerrain = {
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
,
"
vec3 dirVector = directionalLight
Direction[ i ]
;
"
,
"
vec3 dirVector = directionalLight
s[ i ].direction
;
"
,
"
vec3 dirHalfVector = normalize( dirVector + viewPosition );
"
,
"
float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
"
,
...
...
@@ -205,8 +183,8 @@ THREE.ShaderTerrain = {
"
float dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );
"
,
"
totalDiffuseLight += directionalLight
Color[ i ]
* dirDiffuseWeight;
"
,
"
totalSpecularLight += directionalLight
Color[ i ]
* specular * dirSpecularWeight * dirDiffuseWeight;
"
,
"
totalDiffuseLight += directionalLight
s[ i ].color
* dirDiffuseWeight;
"
,
"
totalSpecularLight += directionalLight
s[ i ].color
* specular * dirSpecularWeight * dirDiffuseWeight;
"
,
"
}
"
,
...
...
@@ -228,7 +206,7 @@ THREE.ShaderTerrain = {
"
float dotProduct = dot( normal, lVector );
"
,
"
float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
"
,
"
totalDiffuseLight += mix( hemisphereLight
GroundColor[ i ], hemisphereLightSkyColor[ i ]
, hemiDiffuseWeight );
"
,
"
totalDiffuseLight += mix( hemisphereLight
s[ i ].groundColor, hemisphereLights[ i ].skyColor
, hemiDiffuseWeight );
"
,
// specular (sky light)
...
...
@@ -246,7 +224,7 @@ THREE.ShaderTerrain = {
"
float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;
"
,
"
hemiSpecularWeight += specularTex.r * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );
"
,
"
totalSpecularLight += specular * mix( hemisphereLight
GroundColor[ i ], hemisphereLightSkyColor[ i ]
, hemiDiffuseWeight ) * hemiSpecularWeight * hemiDiffuseWeight;
"
,
"
totalSpecularLight += specular * mix( hemisphereLight
s[ i ].groundColor, hemisphereLights[ i ].skyColor
, hemiDiffuseWeight ) * hemiSpecularWeight * hemiDiffuseWeight;
"
,
"
}
"
,
...
...
examples/webgl_shaders_tonemapping.html
浏览文件 @
3c9e00fe
...
...
@@ -37,7 +37,7 @@
<div
class=
"label"
style=
"position: absolute;left: 80%;bottom: 5%;"
>
Adaptive Tone Mapping
</div>
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"../build/three.
min.
js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/dat.gui.min.js"
></script>
...
...
@@ -158,6 +158,9 @@
fragmentShader
:
[
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
bsdfs
"
],
THREE
.
ShaderChunk
[
"
lights
"
],
THREE
.
ShaderChunk
[
"
lights_phong_pars_fragment
"
],
"
void main() {
"
,
...
...
@@ -169,12 +172,12 @@
"
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
"
,
"
vec4 lDirection = viewMatrix * vec4( directionalLight
Direction[ i ]
, 0.0 );
"
,
"
vec4 lDirection = viewMatrix * vec4( directionalLight
s[i].direction
, 0.0 );
"
,
"
vec3 dirVector = normalize( lDirection.xyz );
"
,
"
float dotProduct = dot( viewPosition, dirVector );
"
,
"
dotProduct = 1.0 * max( dotProduct, 0.0 ) + (1.0 - max( -dot( normal, dirVector ), 0.0 ));
"
,
"
dotProduct *= dotProduct;
"
,
"
dirDiffuse += max( 0.5 * dotProduct, 0.0 ) * directionalLight
Color[ i ]
;
"
,
"
dirDiffuse += max( 0.5 * dotProduct, 0.0 ) * directionalLight
s[i].color
;
"
,
"
}
"
,
"
#endif
"
,
...
...
src/renderers/shaders/ShaderChunk/bsdfs.glsl
浏览文件 @
3c9e00fe
//#define ENERGY_PRESERVING_MONOCHROME
struct
IncidentLight
{
vec3
color
;
vec3
direction
;
};
struct
ReflectedLight
{
vec3
specular
;
vec3
diffuse
;
};
struct
GeometricContext
{
vec3
position
;
vec3
normal
;
vec3
viewDir
;
};
void
BRDF_Lambert
(
const
in
IncidentLight
incidentLight
,
const
in
GeometricContext
geometryContext
,
const
in
vec3
diffuseColor
,
inout
ReflectedLight
reflectedLight
)
{
float
lambertianReflectance
=
saturate
(
dot
(
geometryContext
.
normal
,
incidentLight
.
direction
)
);
...
...
src/renderers/shaders/ShaderChunk/common.glsl
浏览文件 @
3c9e00fe
...
...
@@ -10,6 +10,24 @@
float
average
(
const
in
vec3
color
)
{
return
dot
(
color
,
vec3
(
0
.
3333
)
);
}
struct
IncidentLight
{
vec3
color
;
vec3
direction
;
};
struct
ReflectedLight
{
vec3
specular
;
vec3
diffuse
;
};
struct
GeometricContext
{
vec3
position
;
vec3
normal
;
vec3
viewDir
;
};
vec3
transformDirection
(
in
vec3
normal
,
in
mat4
matrix
)
{
return
normalize
(
(
matrix
*
vec4
(
normal
,
0
.
0
)
).
xyz
);
...
...
src/renderers/shaders/ShaderChunk/lights.glsl
浏览文件 @
3c9e00fe
...
...
@@ -22,10 +22,10 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec
uniform
DirectionalLight
directionalLights
[
MAX_DIR_LIGHTS
];
void
getDir
IncidentLight
(
const
in
DirectionalLight
directionalLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
inciden
tLight
)
{
void
getDir
ectionalDirectLight
(
const
in
DirectionalLight
directionalLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
direc
tLight
)
{
inciden
tLight
.
color
=
directionalLight
.
color
;
inciden
tLight
.
direction
=
directionalLight
.
direction
;
direc
tLight
.
color
=
directionalLight
.
color
;
direc
tLight
.
direction
=
directionalLight
.
direction
;
}
...
...
@@ -43,15 +43,15 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec
uniform
PointLight
pointLights
[
MAX_POINT_LIGHTS
];
void
getPoint
IncidentLight
(
const
in
PointLight
pointLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
inciden
tLight
)
{
void
getPoint
DirectLight
(
const
in
PointLight
pointLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
direc
tLight
)
{
vec3
lightPosition
=
pointLight
.
position
;
vec3
lVector
=
lightPosition
-
geometry
.
position
;
inciden
tLight
.
direction
=
normalize
(
lVector
);
direc
tLight
.
direction
=
normalize
(
lVector
);
inciden
tLight
.
color
=
pointLight
.
color
;
inciden
tLight
.
color
*=
calcLightAttenuation
(
length
(
lVector
),
pointLight
.
distance
,
pointLight
.
decay
);
direc
tLight
.
color
=
pointLight
.
color
;
direc
tLight
.
color
*=
calcLightAttenuation
(
length
(
lVector
),
pointLight
.
distance
,
pointLight
.
decay
);
}
...
...
@@ -72,18 +72,18 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec
uniform
SpotLight
spotLights
[
MAX_SPOT_LIGHTS
];
void
getSpot
IncidentLight
(
const
in
SpotLight
spotLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
inciden
tLight
)
{
void
getSpot
DirectLight
(
const
in
SpotLight
spotLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
direc
tLight
)
{
vec3
lightPosition
=
spotLight
.
position
;
vec3
lVector
=
lightPosition
-
geometry
.
position
;
inciden
tLight
.
direction
=
normalize
(
lVector
);
direc
tLight
.
direction
=
normalize
(
lVector
);
float
spotEffect
=
dot
(
spotLight
.
direction
,
inciden
tLight
.
direction
);
float
spotEffect
=
dot
(
spotLight
.
direction
,
direc
tLight
.
direction
);
spotEffect
=
saturate
(
pow
(
saturate
(
spotEffect
),
spotLight
.
exponent
)
);
inciden
tLight
.
color
=
spotLight
.
color
;
inciden
tLight
.
color
*=
(
spotEffect
*
calcLightAttenuation
(
length
(
lVector
),
spotLight
.
distance
,
spotLight
.
decay
)
);
direc
tLight
.
color
=
spotLight
.
color
;
direc
tLight
.
color
*=
(
spotEffect
*
calcLightAttenuation
(
length
(
lVector
),
spotLight
.
distance
,
spotLight
.
decay
)
);
}
...
...
@@ -100,15 +100,13 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec
uniform
HemisphereLight
hemisphereLights
[
MAX_HEMI_LIGHTS
];
void
getHemisphereIn
cidentLight
(
const
in
HemisphereLight
hemiLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
inciden
tLight
)
{
void
getHemisphereIn
directLight
(
const
in
HemisphereLight
hemiLight
,
const
in
GeometricContext
geometry
,
out
IncidentLight
indirec
tLight
)
{
float
dotNL
=
dot
(
geometry
.
normal
,
hemiLight
.
direction
);
float
hemiDiffuseWeight
=
0
.
5
*
dotNL
+
0
.
5
;
incidentLight
.
color
=
mix
(
hemiLight
.
groundColor
,
hemiLight
.
skyColor
,
hemiDiffuseWeight
);
incidentLight
.
direction
=
geometry
.
normal
;
indirectLight
.
color
=
mix
(
hemiLight
.
groundColor
,
hemiLight
.
skyColor
,
hemiDiffuseWeight
);
indirectLight
.
direction
=
geometry
.
normal
;
}
...
...
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
浏览文件 @
3c9e00fe
vec3
diffuse
=
vec3
(
1
.
0
);
IncidentLight
incidentLight
;
GeometricContext
geometry
=
GeometricContext
(
mvPosition
.
xyz
,
normalize
(
transformedNormal
),
normalize
(
-
mvPosition
.
xyz
)
);
GeometricContext
backGeometry
=
GeometricContext
(
geometry
.
position
,
-
geometry
.
normal
,
geometry
.
viewDir
);
...
...
@@ -12,13 +10,15 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_POINT_LIGHTS
;
i
++
)
{
getPointIncidentLight
(
pointLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
directLight
;
getPointDirectLight
(
pointLights
[
i
],
geometry
,
directLight
);
BRDF_Lambert
(
inciden
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
BRDF_Lambert
(
direc
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
#ifdef DOUBLE_SIDED
BRDF_Lambert
(
inciden
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
BRDF_Lambert
(
direc
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
#endif
...
...
@@ -30,13 +30,15 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_SPOT_LIGHTS
;
i
++
)
{
getSpotIncidentLight
(
spotLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
directLight
;
getSpotDirectLight
(
spotLights
[
i
],
geometry
,
directLight
);
BRDF_Lambert
(
inciden
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
BRDF_Lambert
(
direc
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
#ifdef DOUBLE_SIDED
BRDF_Lambert
(
inciden
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
BRDF_Lambert
(
direc
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
#endif
...
...
@@ -48,13 +50,15 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_DIR_LIGHTS
;
i
++
)
{
getDirIncidentLight
(
directionalLights
[
i
],
geometry
,
incidentLight
)
;
IncidentLight
directLight
;
BRDF_Lambert
(
incidentLight
,
geometry
,
diffuse
,
frontReflectedLight
);
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
,
directLight
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
frontReflectedLight
);
#ifdef DOUBLE_SIDED
BRDF_Lambert
(
inciden
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
BRDF_Lambert
(
direc
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
#endif
...
...
@@ -66,15 +70,17 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) );
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
getHemisphereLightIndirect
(
hemisphereLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
indirectLight
;
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
,
indirectLight
);
BRDF_Lambert
(
in
ciden
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
BRDF_Lambert
(
in
direc
tLight
,
geometry
,
diffuse
,
frontReflectedLight
);
#ifdef DOUBLE_SIDED
getHemisphereIn
cidentLight
(
hemisphereLights
[
i
],
backGeometry
,
inciden
tLight
);
getHemisphereIn
directLight
(
hemisphereLights
[
i
],
backGeometry
,
indirec
tLight
);
BRDF_Lambert
(
in
ciden
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
BRDF_Lambert
(
in
direc
tLight
,
backGeometry
,
diffuse
,
backReflectedLight
);
#endif
...
...
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
浏览文件 @
3c9e00fe
...
...
@@ -16,8 +16,6 @@ vec3 diffuse = diffuseColor.rgb;
#endif
IncidentLight
incidentLight
;
GeometricContext
geometry
=
GeometricContext
(
-
vViewPosition
,
normal
,
normalize
(
vViewPosition
)
);
ReflectedLight
directReflectedLight
=
ReflectedLight
(
vec3
(
0
.
0
),
vec3
(
0
.
0
)
);
...
...
@@ -27,12 +25,14 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_POINT_LIGHTS
;
i
++
)
{
getPointIncidentLight
(
pointLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
directLight
;
getPointDirectLight
(
pointLights
[
i
],
geometry
,
directLight
);
BRDF_Lambert
(
inciden
tLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar(
inciden
tLight, geometry, diffuse, 0.5, directReflectedLight );
BRDF_Lambert
(
direc
tLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar(
direc
tLight, geometry, diffuse, 0.5, directReflectedLight );
BRDF_BlinnPhong
(
inciden
tLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
BRDF_BlinnPhong
(
direc
tLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
}
...
...
@@ -42,12 +42,14 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_SPOT_LIGHTS
;
i
++
)
{
getSpotIncidentLight
(
spotLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
directLight
;
getSpotDirectLight
(
spotLights
[
i
],
geometry
,
directLight
);
BRDF_Lambert
(
inciden
tLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar(
inciden
tLight, geometry, diffuse, 0.5, directReflectedLight );
BRDF_Lambert
(
direc
tLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar(
direc
tLight, geometry, diffuse, 0.5, directReflectedLight );
BRDF_BlinnPhong
(
inciden
tLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
BRDF_BlinnPhong
(
direc
tLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
}
...
...
@@ -57,12 +59,14 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_DIR_LIGHTS
;
i
++
)
{
getDirIncidentLight
(
directionalLights
[
i
],
geometry
,
incidentLight
)
;
IncidentLight
directLight
;
BRDF_Lambert
(
incidentLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar( incidentLight, geometry, diffuse, 0.5, directReflectedLight );
getDirectionalDirectLight
(
directionalLights
[
i
],
geometry
,
directLight
);
BRDF_BlinnPhong
(
incidentLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
BRDF_Lambert
(
directLight
,
geometry
,
diffuse
,
directReflectedLight
);
//BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight );
BRDF_BlinnPhong
(
directLight
,
geometry
,
specular
,
shininess
,
directReflectedLight
);
}
...
...
@@ -72,10 +76,12 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 )
for
(
int
i
=
0
;
i
<
MAX_HEMI_LIGHTS
;
i
++
)
{
getHemisphereIncidentLight
(
hemisphereLights
[
i
],
geometry
,
incidentLight
);
IncidentLight
indirectLight
;
getHemisphereIndirectLight
(
hemisphereLights
[
i
],
geometry
,
indirectLight
);
BRDF_Lambert
(
in
ciden
tLight
,
geometry
,
diffuse
,
indirectReflectedLight
);
//BRDF_OrenNayar( in
ciden
tLight, geometry, diffuse, 0.5, indirectReflectedLight );
BRDF_Lambert
(
in
direc
tLight
,
geometry
,
diffuse
,
indirectReflectedLight
);
//BRDF_OrenNayar( in
direc
tLight, geometry, diffuse, 0.5, indirectReflectedLight );
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录