Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2c1e6a13
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,发现更多精彩内容 >>
提交
2c1e6a13
编写于
12月 21, 2010
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Forgot to remove hardcoded fog color in shader.
上级
76a56f2f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
6 addition
and
7 deletion
+6
-7
build/Three.js
build/Three.js
+1
-1
build/ThreeDebug.js
build/ThreeDebug.js
+1
-1
build/ThreeExtras.js
build/ThreeExtras.js
+1
-1
examples/geometry_minecraft_ao.html
examples/geometry_minecraft_ao.html
+2
-2
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+1
-2
未找到文件。
build/Three.js
浏览文件 @
2c1e6a13
...
...
@@ -152,7 +152,7 @@ e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 v
k
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
k
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
k
?
"
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
"
:
""
,
k
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
k
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
k
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
k
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
k
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
k
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
k
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
k
?
"
pointDiffuse += mColor * pointDiffuseWeight;
"
:
""
,
k
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
k
?
"
}
"
:
""
,
e
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
e
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
e
?
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
:
""
,
e
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
e
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
e
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
e
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
e
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
e
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
e
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
e
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
e
?
"
dirDiffuse += mColor * dirDiffuseWeight;
"
:
""
,
e
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
e
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
e
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
k
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
1.0, 1.0, 1.0
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
fogColor
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
g
=
b
(
n
,
g
,
i
);
c
.
useProgram
(
g
);
h
(
g
,[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
,
"
enableLighting
"
,
"
ambientLightColor
"
,
"
material
"
,
"
mColor
"
,
"
mAmbient
"
,
"
mSpecular
"
,
"
mShininess
"
,
"
mOpacity
"
,
"
enableMap
"
,
"
tMap
"
,
"
enableCubeMap
"
,
"
tCube
"
,
"
mixEnvMap
"
,
"
mReflectivity
"
,
"
mRefractionRatio
"
,
"
useRefract
"
]);
i
&&
h
(
g
,[
"
fogColor
"
,
"
fogDensity
"
]);
e
&&
h
(
g
,[
"
directionalLightNumber
"
,
"
directionalLightColor
"
,
"
directionalLightDirection
"
]);
k
&&
h
(
g
,[
"
pointLightNumber
"
,
"
pointLightColor
"
,
"
pointLightPosition
"
]);
c
.
uniform1i
(
g
.
uniforms
.
enableMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
tMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
enableCubeMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
tCube
,
1
);
c
.
uniform1i
(
g
.
uniforms
.
mixEnvMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
useRefract
,
0
);
j
(
g
,[
"
position
"
,
"
normal
"
,
"
uv
"
]);
return
g
}(
D
.
directional
,
D
.
point
,
fog
);
this
.
setSize
=
function
(
e
,
k
){
o
.
width
=
e
;
o
.
height
=
k
;
c
.
viewport
(
0
,
0
,
o
.
width
,
o
.
height
)};
this
.
clear
=
function
(){
c
.
clear
(
c
.
COLOR_BUFFER_BIT
|
c
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
e
,
k
){
var
i
,
g
,
n
,
l
,
p
,
r
=
[],
u
=
[],
E
=
[];
l
=
[];
p
=
[];
c
.
uniform1i
(
e
.
uniforms
.
enableLighting
,
k
.
length
);
i
=
0
;
for
(
g
=
k
.
length
;
i
<
g
;
i
++
){
n
=
k
[
i
];
if
(
n
instanceof
THREE
.
AmbientLight
)
r
.
push
(
n
);
else
if
(
n
instanceof
THREE
.
DirectionalLight
)
E
.
push
(
n
);
else
n
instanceof
THREE
.
PointLight
&&
u
.
push
(
n
)}
i
=
n
=
l
=
p
=
0
;
for
(
g
=
r
.
length
;
i
<
g
;
i
++
){
n
+=
r
[
i
].
color
.
r
;
l
+=
r
[
i
].
color
.
g
;
p
+=
r
[
i
].
color
.
b
}
c
.
uniform3f
(
e
.
uniforms
.
ambientLightColor
,
n
,
l
,
p
);
l
=
[];
p
=
[];
i
=
0
;
for
(
g
=
E
.
length
;
i
<
g
;
i
++
){
n
=
E
[
i
];
l
.
push
(
n
.
color
.
r
*
n
.
intensity
);
l
.
push
(
n
.
color
.
g
*
n
.
intensity
);
l
.
push
(
n
.
color
.
b
*
...
...
build/ThreeDebug.js
浏览文件 @
2c1e6a13
...
...
@@ -153,7 +153,7 @@ e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 v
l
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
l
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
l
?
"
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
"
:
""
,
l
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
l
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
l
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
l
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
l
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
l
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
l
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
l
?
"
pointDiffuse += mColor * pointDiffuseWeight;
"
:
""
,
l
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
l
?
"
}
"
:
""
,
e
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
e
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
e
?
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
:
""
,
e
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
e
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
e
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
e
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
e
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
e
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
e
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
e
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
e
?
"
dirDiffuse += mColor * dirDiffuseWeight;
"
:
""
,
e
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
e
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
e
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
l
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
1.0, 1.0, 1.0
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
fogColor
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
g
=
b
(
n
,
g
,
i
);
c
.
useProgram
(
g
);
h
(
g
,[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
,
"
enableLighting
"
,
"
ambientLightColor
"
,
"
material
"
,
"
mColor
"
,
"
mAmbient
"
,
"
mSpecular
"
,
"
mShininess
"
,
"
mOpacity
"
,
"
enableMap
"
,
"
tMap
"
,
"
enableCubeMap
"
,
"
tCube
"
,
"
mixEnvMap
"
,
"
mReflectivity
"
,
"
mRefractionRatio
"
,
"
useRefract
"
]);
i
&&
h
(
g
,[
"
fogColor
"
,
"
fogDensity
"
]);
e
&&
h
(
g
,[
"
directionalLightNumber
"
,
"
directionalLightColor
"
,
"
directionalLightDirection
"
]);
l
&&
h
(
g
,[
"
pointLightNumber
"
,
"
pointLightColor
"
,
"
pointLightPosition
"
]);
c
.
uniform1i
(
g
.
uniforms
.
enableMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
tMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
enableCubeMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
tCube
,
1
);
c
.
uniform1i
(
g
.
uniforms
.
mixEnvMap
,
0
);
c
.
uniform1i
(
g
.
uniforms
.
useRefract
,
0
);
k
(
g
,[
"
position
"
,
"
normal
"
,
"
uv
"
]);
return
g
}(
D
.
directional
,
D
.
point
,
fog
);
this
.
setSize
=
function
(
e
,
l
){
o
.
width
=
e
;
o
.
height
=
l
;
c
.
viewport
(
0
,
0
,
o
.
width
,
o
.
height
)};
this
.
clear
=
function
(){
c
.
clear
(
c
.
COLOR_BUFFER_BIT
|
c
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
e
,
l
){
var
i
,
g
,
n
,
m
,
p
,
r
=
[],
v
=
[],
E
=
[];
m
=
[];
p
=
[];
c
.
uniform1i
(
e
.
uniforms
.
enableLighting
,
l
.
length
);
i
=
0
;
for
(
g
=
l
.
length
;
i
<
g
;
i
++
){
n
=
l
[
i
];
if
(
n
instanceof
THREE
.
AmbientLight
)
r
.
push
(
n
);
else
if
(
n
instanceof
THREE
.
DirectionalLight
)
E
.
push
(
n
);
else
n
instanceof
THREE
.
PointLight
&&
v
.
push
(
n
)}
i
=
n
=
m
=
p
=
0
;
for
(
g
=
r
.
length
;
i
<
g
;
i
++
){
n
+=
r
[
i
].
color
.
r
;
m
+=
r
[
i
].
color
.
g
;
p
+=
r
[
i
].
color
.
b
}
c
.
uniform3f
(
e
.
uniforms
.
ambientLightColor
,
n
,
m
,
p
);
m
=
[];
p
=
[];
i
=
0
;
for
(
g
=
E
.
length
;
i
<
g
;
i
++
){
n
=
E
[
i
];
m
.
push
(
n
.
color
.
r
*
n
.
intensity
);
m
.
push
(
n
.
color
.
g
*
n
.
intensity
);
m
.
push
(
n
.
color
.
b
*
...
...
build/ThreeExtras.js
浏览文件 @
2c1e6a13
...
...
@@ -152,7 +152,7 @@ j?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 v
p
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
p
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
p
?
"
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
"
:
""
,
p
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
p
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
p
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
p
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
p
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
p
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
p
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
p
?
"
pointDiffuse += mColor * pointDiffuseWeight;
"
:
""
,
p
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
p
?
"
}
"
:
""
,
j
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
j
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
j
?
"
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
"
:
""
,
j
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
j
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
j
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
j
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
j
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
j
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
j
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
j
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
j
?
"
dirDiffuse += mColor * dirDiffuseWeight;
"
:
""
,
j
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
j
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
j
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
p
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
1.0, 1.0, 1.0
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
""
,
"
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
\n
}
\n
} else if ( material == 1 ) {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
\n
} else {
\n
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
\n
}
\n
} else {
\n
if ( mixEnvMap ) {
\n
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
\n
} else {
\n
gl_FragColor = mColor * mapColor * cubeColor;
\n
}
\n
}
\n
#ifdef USE_FOG
\n
const float LOG2 = 1.442695;
\n
float z = gl_FragCoord.z / gl_FragCoord.w;
\n
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
\n
fogFactor = clamp( fogFactor, 0.0, 1.0 );
\n
gl_FragColor = mix( vec4(
fogColor
, 1.0 ), gl_FragColor, fogFactor );
\n
#endif
\n
}
"
].
join
(
"
\n
"
);
m
=
b
(
r
,
m
,
n
);
c
.
useProgram
(
m
);
f
(
m
,[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
,
"
enableLighting
"
,
"
ambientLightColor
"
,
"
material
"
,
"
mColor
"
,
"
mAmbient
"
,
"
mSpecular
"
,
"
mShininess
"
,
"
mOpacity
"
,
"
enableMap
"
,
"
tMap
"
,
"
enableCubeMap
"
,
"
tCube
"
,
"
mixEnvMap
"
,
"
mReflectivity
"
,
"
mRefractionRatio
"
,
"
useRefract
"
]);
n
&&
f
(
m
,[
"
fogColor
"
,
"
fogDensity
"
]);
j
&&
f
(
m
,[
"
directionalLightNumber
"
,
"
directionalLightColor
"
,
"
directionalLightDirection
"
]);
p
&&
f
(
m
,[
"
pointLightNumber
"
,
"
pointLightColor
"
,
"
pointLightPosition
"
]);
c
.
uniform1i
(
m
.
uniforms
.
enableMap
,
0
);
c
.
uniform1i
(
m
.
uniforms
.
tMap
,
0
);
c
.
uniform1i
(
m
.
uniforms
.
enableCubeMap
,
0
);
c
.
uniform1i
(
m
.
uniforms
.
tCube
,
1
);
c
.
uniform1i
(
m
.
uniforms
.
mixEnvMap
,
0
);
c
.
uniform1i
(
m
.
uniforms
.
useRefract
,
0
);
g
(
m
,[
"
position
"
,
"
normal
"
,
"
uv
"
]);
return
m
}(
l
.
directional
,
l
.
point
,
fog
);
this
.
setSize
=
function
(
j
,
p
){
i
.
width
=
j
;
i
.
height
=
p
;
c
.
viewport
(
0
,
0
,
i
.
width
,
i
.
height
)};
this
.
clear
=
function
(){
c
.
clear
(
c
.
COLOR_BUFFER_BIT
|
c
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
j
,
p
){
var
n
,
m
,
r
,
q
,
v
,
A
=
[],
D
=
[],
I
=
[];
q
=
[];
v
=
[];
c
.
uniform1i
(
j
.
uniforms
.
enableLighting
,
p
.
length
);
n
=
0
;
for
(
m
=
p
.
length
;
n
<
m
;
n
++
){
r
=
p
[
n
];
if
(
r
instanceof
THREE
.
AmbientLight
)
A
.
push
(
r
);
else
if
(
r
instanceof
THREE
.
DirectionalLight
)
I
.
push
(
r
);
else
r
instanceof
THREE
.
PointLight
&&
D
.
push
(
r
)}
n
=
r
=
q
=
v
=
0
;
for
(
m
=
A
.
length
;
n
<
m
;
n
++
){
r
+=
A
[
n
].
color
.
r
;
q
+=
A
[
n
].
color
.
g
;
v
+=
A
[
n
].
color
.
b
}
c
.
uniform3f
(
j
.
uniforms
.
ambientLightColor
,
r
,
q
,
v
);
q
=
[];
v
=
[];
n
=
0
;
for
(
m
=
I
.
length
;
n
<
m
;
n
++
){
r
=
I
[
n
];
q
.
push
(
r
.
color
.
r
*
r
.
intensity
);
q
.
push
(
r
.
color
.
g
*
r
.
intensity
);
q
.
push
(
r
.
color
.
b
*
...
...
examples/geometry_minecraft_ao.html
浏览文件 @
2c1e6a13
...
...
@@ -10,8 +10,8 @@
font-size
:
13px
;
text-align
:
center
;
background-color
:
#bfd1e5
;
background-color
:
#
fff
;
/* background-color: #bfd1e5; */
background-color
:
#fff
fff
;
margin
:
0px
;
overflow
:
hidden
;
}
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
2c1e6a13
...
...
@@ -1117,8 +1117,7 @@ THREE.WebGLRenderer = function ( scene ) {
"
float z = gl_FragCoord.z / gl_FragCoord.w;
"
,
"
float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );
"
,
"
fogFactor = clamp( fogFactor, 0.0, 1.0 );
"
,
//"gl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );",
"
gl_FragColor = mix( vec4( 1.0, 1.0, 1.0, 1.0 ), gl_FragColor, fogFactor );
"
,
"
gl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );
"
,
"
#endif
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录