Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
256f9a67
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,发现更多精彩内容 >>
提交
256f9a67
编写于
7月 12, 2011
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix for specular component of Phong and normal map materials. Hope so.
Thanks to @fazeaction for spotting this.
上级
23e315cb
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
11 addition
and
11 deletion
+11
-11
build/Three.js
build/Three.js
+2
-2
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+3
-3
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+1
-1
examples/webgl_geometry_large_mesh.html
examples/webgl_geometry_large_mesh.html
+1
-1
src/extras/ShaderUtils.js
src/extras/ShaderUtils.js
+2
-2
src/renderers/WebGLShaders.js
src/renderers/WebGLShaders.js
+2
-2
未找到文件。
build/Three.js
浏览文件 @
256f9a67
...
@@ -194,7 +194,7 @@ envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position
...
@@ -194,7 +194,7 @@ envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_pars_vertex
:
"
uniform bool enableLighting;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#ifdef PHONG
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_pars_vertex
:
"
uniform bool enableLighting;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#ifdef PHONG
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lights_vertex
:
"
if ( !enableLighting ) {
\n
vLightWeighting = vec3( 1.0 );
\n
} else {
\n
vLightWeighting = ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );
\n
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
\n
}
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
#ifdef PHONG
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
#endif
\n
}
\n
#endif
\n
}
"
,
lights_vertex
:
"
if ( !enableLighting ) {
\n
vLightWeighting = vec3( 1.0 );
\n
} else {
\n
vLightWeighting = ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );
\n
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
\n
}
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
#ifdef PHONG
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
#endif
\n
}
\n
#endif
\n
}
"
,
lights_pars_fragment
:
"
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
vec4 mColor = vec4( diffuse, opacity );
\n
vec4 mSpecular = vec4( specular, opacity );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointDiffuse = vec4( 0.0 );
\n
vec4 pointSpecular = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
ViewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = pow( pointDotNormalHalf, shininess );
\n
pointDiffuse += mColor * pointDiffuseWeight * pointDistance;
\n
pointSpecular += mSpecular * pointSpecularWeight * pointDistance;
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirDiffuse = vec4( 0.0 );
\n
vec4 dirSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + vV
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = pow( dirDotNormalHalf, shininess );
\n
dirDiffuse += mColor * dirDiffuseWeight;
\n
dirSpecular += mSpecular * dirSpecularWeight;
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirDiffuse + dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointDiffuse + pointSpecular;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
lights_pars_fragment
:
"
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
vec4 mColor = vec4( diffuse, opacity );
\n
vec4 mSpecular = vec4( specular, opacity );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointDiffuse = vec4( 0.0 );
\n
vec4 pointSpecular = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
iewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = pow( pointDotNormalHalf, shininess );
\n
pointDiffuse += mColor * pointDiffuseWeight * pointDistance;
\n
pointSpecular += mSpecular * pointSpecularWeight * pointDistance;
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirDiffuse = vec4( 0.0 );
\n
vec4 dirSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + v
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = pow( dirDotNormalHalf, shininess );
\n
dirDiffuse += mColor * dirDiffuseWeight;
\n
dirSpecular += mSpecular * dirSpecularWeight;
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirDiffuse + dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointDiffuse + pointSpecular;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
vColor = color;
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;
\n
#endif
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
vColor = color;
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0, 0.0, 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0, 0.0, 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
b
){
var
c
,
e
,
f
,
g
=
{};
for
(
c
=
0
;
c
<
b
.
length
;
c
++
)
for
(
e
in
f
=
this
.
clone
(
b
[
c
]),
f
)
g
[
e
]
=
f
[
e
];
return
g
},
clone
:
function
(
b
){
var
c
,
e
,
f
,
g
=
{};
for
(
c
in
b
)
for
(
e
in
g
[
c
]
=
{},
b
[
c
])
f
=
b
[
c
][
e
],
g
[
c
][
e
]
=
f
instanceof
THREE
.
Color
||
f
instanceof
THREE
.
Vector3
||
f
instanceof
THREE
.
Texture
?
f
.
clone
():
f
;
return
g
}};
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
b
){
var
c
,
e
,
f
,
g
=
{};
for
(
c
=
0
;
c
<
b
.
length
;
c
++
)
for
(
e
in
f
=
this
.
clone
(
b
[
c
]),
f
)
g
[
e
]
=
f
[
e
];
return
g
},
clone
:
function
(
b
){
var
c
,
e
,
f
,
g
=
{};
for
(
c
in
b
)
for
(
e
in
g
[
c
]
=
{},
b
[
c
])
f
=
b
[
c
][
e
],
g
[
c
][
e
]
=
f
instanceof
THREE
.
Color
||
f
instanceof
THREE
.
Vector3
||
f
instanceof
THREE
.
Texture
?
f
.
clone
():
f
;
return
g
}};
...
@@ -346,7 +346,7 @@ THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy
...
@@ -346,7 +346,7 @@ THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy
if
(
THREE
.
WebGLRenderer
)
THREE
.
ShaderUtils
=
{
lib
:{
fresnel
:{
uniforms
:{
mRefractionRatio
:{
type
:
"
f
"
,
value
:
1.02
},
mFresnelBias
:{
type
:
"
f
"
,
value
:
0.1
},
mFresnelPower
:{
type
:
"
f
"
,
value
:
2
},
mFresnelScale
:{
type
:
"
f
"
,
value
:
1
},
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );
\n
vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );
\n
refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;
\n
refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;
\n
refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;
\n
refractedColor.a = 1.0;
\n
gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
\n
}
"
,
vertexShader
:
"
uniform float mRefractionRatio;
\n
uniform float mFresnelBias;
\n
uniform float mFresnelScale;
\n
uniform float mFresnelPower;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );
\n
vec3 I = mPosition.xyz - cameraPosition;
\n
vReflect = reflect( I, nWorld );
\n
vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );
\n
vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );
\n
vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );
\n
vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
if
(
THREE
.
WebGLRenderer
)
THREE
.
ShaderUtils
=
{
lib
:{
fresnel
:{
uniforms
:{
mRefractionRatio
:{
type
:
"
f
"
,
value
:
1.02
},
mFresnelBias
:{
type
:
"
f
"
,
value
:
0.1
},
mFresnelPower
:{
type
:
"
f
"
,
value
:
2
},
mFresnelScale
:{
type
:
"
f
"
,
value
:
1
},
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );
\n
vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );
\n
refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;
\n
refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;
\n
refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;
\n
refractedColor.a = 1.0;
\n
gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
\n
}
"
,
vertexShader
:
"
uniform float mRefractionRatio;
\n
uniform float mFresnelBias;
\n
uniform float mFresnelScale;
\n
uniform float mFresnelPower;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );
\n
vec3 I = mPosition.xyz - cameraPosition;
\n
vReflect = reflect( I, nWorld );
\n
vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );
\n
vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );
\n
vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );
\n
vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
normal
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,{
enableAO
:{
type
:
"
i
"
,
value
:
0
},
enableDiffuse
:{
type
:
"
i
"
,
value
:
0
},
enableSpecular
:{
type
:
"
i
"
,
value
:
0
},
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
tNormal
:{
type
:
"
t
"
,
value
:
2
,
texture
:
null
},
tSpecular
:{
type
:
"
t
"
,
value
:
3
,
texture
:
null
},
tAO
:{
type
:
"
t
"
,
value
:
4
,
texture
:
null
},
uNormalScale
:{
type
:
"
f
"
,
value
:
1
},
tDisplacement
:{
type
:
"
t
"
,
value
:
5
,
texture
:
null
},
uDisplacementBias
:{
type
:
"
f
"
,
value
:
0
},
uDisplacementScale
:{
type
:
"
f
"
,
value
:
1
},
uDiffuseColor
:{
type
:
"
c
"
,
normal
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,{
enableAO
:{
type
:
"
i
"
,
value
:
0
},
enableDiffuse
:{
type
:
"
i
"
,
value
:
0
},
enableSpecular
:{
type
:
"
i
"
,
value
:
0
},
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
tNormal
:{
type
:
"
t
"
,
value
:
2
,
texture
:
null
},
tSpecular
:{
type
:
"
t
"
,
value
:
3
,
texture
:
null
},
tAO
:{
type
:
"
t
"
,
value
:
4
,
texture
:
null
},
uNormalScale
:{
type
:
"
f
"
,
value
:
1
},
tDisplacement
:{
type
:
"
t
"
,
value
:
5
,
texture
:
null
},
uDisplacementBias
:{
type
:
"
f
"
,
value
:
0
},
uDisplacementScale
:{
type
:
"
f
"
,
value
:
1
},
uDiffuseColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
uSpecularColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
uAmbientColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
uShininess
:{
type
:
"
f
"
,
value
:
30
},
uOpacity
:{
type
:
"
f
"
,
value
:
1
}}]),
fragmentShader
:[
"
uniform vec3 uAmbientColor;
\n
uniform vec3 uDiffuseColor;
\n
uniform vec3 uSpecularColor;
\n
uniform float uShininess;
\n
uniform float uOpacity;
\n
uniform bool enableDiffuse;
\n
uniform bool enableSpecular;
\n
uniform bool enableAO;
\n
uniform sampler2D tDiffuse;
\n
uniform sampler2D tNormal;
\n
uniform sampler2D tSpecular;
\n
uniform sampler2D tAO;
\n
uniform float uNormalScale;
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
"
,
value
:
new
THREE
.
Color
(
15658734
)},
uSpecularColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
uAmbientColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
uShininess
:{
type
:
"
f
"
,
value
:
30
},
uOpacity
:{
type
:
"
f
"
,
value
:
1
}}]),
fragmentShader
:[
"
uniform vec3 uAmbientColor;
\n
uniform vec3 uDiffuseColor;
\n
uniform vec3 uSpecularColor;
\n
uniform float uShininess;
\n
uniform float uOpacity;
\n
uniform bool enableDiffuse;
\n
uniform bool enableSpecular;
\n
uniform bool enableAO;
\n
uniform sampler2D tDiffuse;
\n
uniform sampler2D tNormal;
\n
uniform sampler2D tSpecular;
\n
uniform sampler2D tAO;
\n
uniform float uNormalScale;
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( 1.0 );
\n
vec4 mColor = vec4( uDiffuseColor, uOpacity );
\n
vec4 mSpecular = vec4( uSpecularColor, uOpacity );
\n
vec3 specularTex = vec3( 1.0 );
\n
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
\n
normalTex.xy *= uNormalScale;
\n
normalTex = normalize( normalTex );
\n
if( enableDiffuse )
\n
gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );
\n
if( enableAO )
\n
gl_FragColor = gl_FragColor * texture2D( tAO, vUv );
\n
if( enableSpecular )
\n
specularTex = texture2D( tSpecular, vUv ).xyz;
\n
mat3 tsb = mat3( vTangent, vBinormal, vNormal );
\n
vec3 finalNormal = tsb * normalTex;
\n
vec3 normal = normalize( finalNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointTotal = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
ViewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );
\n
pointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirTotal = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + vV
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );
\n
dirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirTotal;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointTotal;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( 1.0 );
\n
vec4 mColor = vec4( uDiffuseColor, uOpacity );
\n
vec4 mSpecular = vec4( uSpecularColor, uOpacity );
\n
vec3 specularTex = vec3( 1.0 );
\n
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
\n
normalTex.xy *= uNormalScale;
\n
normalTex = normalize( normalTex );
\n
if( enableDiffuse )
\n
gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );
\n
if( enableAO )
\n
gl_FragColor = gl_FragColor * texture2D( tAO, vUv );
\n
if( enableSpecular )
\n
specularTex = texture2D( tSpecular, vUv ).xyz;
\n
mat3 tsb = mat3( vTangent, vBinormal, vNormal );
\n
vec3 finalNormal = tsb * normalTex;
\n
vec3 normal = normalize( finalNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointTotal = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
iewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );
\n
pointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirTotal = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + v
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );
\n
dirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirTotal;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointTotal;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:
"
attribute vec4 tangent;
\n
#ifdef VERTEX_TEXTURES
\n
uniform sampler2D tDisplacement;
\n
uniform float uDisplacementScale;
\n
uniform float uDisplacementBias;
\n
#endif
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
vTangent = normalize( normalMatrix * tangent.xyz );
\n
vBinormal = cross( vNormal, vTangent ) * tangent.w;
\n
vBinormal = normalize( vBinormal );
\n
vUv = uv;
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#ifdef VERTEX_TEXTURES
\n
vec3 dv = texture2D( tDisplacement, uv ).xyz;
\n
float df = uDisplacementScale * dv.x + uDisplacementBias;
\n
vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;
\n
gl_Position = projectionMatrix * displacedPosition;
\n
#else
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
}
"
},
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:
"
attribute vec4 tangent;
\n
#ifdef VERTEX_TEXTURES
\n
uniform sampler2D tDisplacement;
\n
uniform float uDisplacementScale;
\n
uniform float uDisplacementBias;
\n
#endif
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
vTangent = normalize( normalMatrix * tangent.xyz );
\n
vBinormal = cross( vNormal, vTangent ) * tangent.w;
\n
vBinormal = normalize( vBinormal );
\n
vUv = uv;
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#ifdef VERTEX_TEXTURES
\n
vec3 dv = texture2D( tDisplacement, uv ).xyz;
\n
float df = uDisplacementScale * dv.x + uDisplacementBias;
\n
vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;
\n
gl_Position = projectionMatrix * displacedPosition;
\n
#else
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
}
"
},
cube
:{
uniforms
:{
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
vertexShader
:
"
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec3 wPos = cameraPosition - vViewPosition;
\n
gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );
\n
}
"
},
convolution
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
cube
:{
uniforms
:{
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
vertexShader
:
"
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec3 wPos = cameraPosition - vViewPosition;
\n
gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );
\n
}
"
},
convolution
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
uImageIncrement
:{
type
:
"
v2
"
,
value
:
new
THREE
.
Vector2
(
0.001953125
,
0
)},
cKernel
:{
type
:
"
fv1
"
,
value
:[]}},
vertexShader
:
"
varying vec2 vUv;
\n
uniform vec2 uImageIncrement;
\n
void main(void) {
\n
vUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform vec2 uImageIncrement;
\n
uniform float cKernel[KERNEL_SIZE];
\n
void main(void) {
\n
vec2 imageCoord = vUv;
\n
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
\n
for( int i=0; i<KERNEL_SIZE; ++i ) {
\n
sum += texture2D( tDiffuse, imageCoord ) * cKernel[i];
\n
imageCoord += uImageIncrement;
\n
}
\n
gl_FragColor = sum;
\n
}
"
},
value
:
0
,
texture
:
null
},
uImageIncrement
:{
type
:
"
v2
"
,
value
:
new
THREE
.
Vector2
(
0.001953125
,
0
)},
cKernel
:{
type
:
"
fv1
"
,
value
:[]}},
vertexShader
:
"
varying vec2 vUv;
\n
uniform vec2 uImageIncrement;
\n
void main(void) {
\n
vUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform vec2 uImageIncrement;
\n
uniform float cKernel[KERNEL_SIZE];
\n
void main(void) {
\n
vec2 imageCoord = vUv;
\n
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
\n
for( int i=0; i<KERNEL_SIZE; ++i ) {
\n
sum += texture2D( tDiffuse, imageCoord ) * cKernel[i];
\n
imageCoord += uImageIncrement;
\n
}
\n
gl_FragColor = sum;
\n
}
"
},
...
...
build/custom/ThreeExtras.js
浏览文件 @
256f9a67
...
@@ -8,7 +8,7 @@ THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy
...
@@ -8,7 +8,7 @@ THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy
if
(
THREE
.
WebGLRenderer
)
THREE
.
ShaderUtils
=
{
lib
:{
fresnel
:{
uniforms
:{
mRefractionRatio
:{
type
:
"
f
"
,
value
:
1.02
},
mFresnelBias
:{
type
:
"
f
"
,
value
:
0.1
},
mFresnelPower
:{
type
:
"
f
"
,
value
:
2
},
mFresnelScale
:{
type
:
"
f
"
,
value
:
1
},
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );
\n
vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );
\n
refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;
\n
refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;
\n
refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;
\n
refractedColor.a = 1.0;
\n
gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
\n
}
"
,
vertexShader
:
"
uniform float mRefractionRatio;
\n
uniform float mFresnelBias;
\n
uniform float mFresnelScale;
\n
uniform float mFresnelPower;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );
\n
vec3 I = mPosition.xyz - cameraPosition;
\n
vReflect = reflect( I, nWorld );
\n
vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );
\n
vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );
\n
vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );
\n
vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
if
(
THREE
.
WebGLRenderer
)
THREE
.
ShaderUtils
=
{
lib
:{
fresnel
:{
uniforms
:{
mRefractionRatio
:{
type
:
"
f
"
,
value
:
1.02
},
mFresnelBias
:{
type
:
"
f
"
,
value
:
0.1
},
mFresnelPower
:{
type
:
"
f
"
,
value
:
2
},
mFresnelScale
:{
type
:
"
f
"
,
value
:
1
},
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );
\n
vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );
\n
refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;
\n
refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;
\n
refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;
\n
refractedColor.a = 1.0;
\n
gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
\n
}
"
,
vertexShader
:
"
uniform float mRefractionRatio;
\n
uniform float mFresnelBias;
\n
uniform float mFresnelScale;
\n
uniform float mFresnelPower;
\n
varying vec3 vReflect;
\n
varying vec3 vRefract[3];
\n
varying float vReflectionFactor;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );
\n
vec3 I = mPosition.xyz - cameraPosition;
\n
vReflect = reflect( I, nWorld );
\n
vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );
\n
vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );
\n
vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );
\n
vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
normal
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,{
enableAO
:{
type
:
"
i
"
,
value
:
0
},
enableDiffuse
:{
type
:
"
i
"
,
value
:
0
},
enableSpecular
:{
type
:
"
i
"
,
value
:
0
},
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
tNormal
:{
type
:
"
t
"
,
value
:
2
,
texture
:
null
},
tSpecular
:{
type
:
"
t
"
,
value
:
3
,
texture
:
null
},
tAO
:{
type
:
"
t
"
,
value
:
4
,
texture
:
null
},
uNormalScale
:{
type
:
"
f
"
,
value
:
1
},
tDisplacement
:{
type
:
"
t
"
,
value
:
5
,
texture
:
null
},
uDisplacementBias
:{
type
:
"
f
"
,
value
:
0
},
uDisplacementScale
:{
type
:
"
f
"
,
value
:
1
},
uDiffuseColor
:{
type
:
"
c
"
,
normal
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,{
enableAO
:{
type
:
"
i
"
,
value
:
0
},
enableDiffuse
:{
type
:
"
i
"
,
value
:
0
},
enableSpecular
:{
type
:
"
i
"
,
value
:
0
},
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
tNormal
:{
type
:
"
t
"
,
value
:
2
,
texture
:
null
},
tSpecular
:{
type
:
"
t
"
,
value
:
3
,
texture
:
null
},
tAO
:{
type
:
"
t
"
,
value
:
4
,
texture
:
null
},
uNormalScale
:{
type
:
"
f
"
,
value
:
1
},
tDisplacement
:{
type
:
"
t
"
,
value
:
5
,
texture
:
null
},
uDisplacementBias
:{
type
:
"
f
"
,
value
:
0
},
uDisplacementScale
:{
type
:
"
f
"
,
value
:
1
},
uDiffuseColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
uSpecularColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
uAmbientColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
uShininess
:{
type
:
"
f
"
,
value
:
30
},
uOpacity
:{
type
:
"
f
"
,
value
:
1
}}]),
fragmentShader
:[
"
uniform vec3 uAmbientColor;
\n
uniform vec3 uDiffuseColor;
\n
uniform vec3 uSpecularColor;
\n
uniform float uShininess;
\n
uniform float uOpacity;
\n
uniform bool enableDiffuse;
\n
uniform bool enableSpecular;
\n
uniform bool enableAO;
\n
uniform sampler2D tDiffuse;
\n
uniform sampler2D tNormal;
\n
uniform sampler2D tSpecular;
\n
uniform sampler2D tAO;
\n
uniform float uNormalScale;
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
"
,
value
:
new
THREE
.
Color
(
15658734
)},
uSpecularColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
uAmbientColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
uShininess
:{
type
:
"
f
"
,
value
:
30
},
uOpacity
:{
type
:
"
f
"
,
value
:
1
}}]),
fragmentShader
:[
"
uniform vec3 uAmbientColor;
\n
uniform vec3 uDiffuseColor;
\n
uniform vec3 uSpecularColor;
\n
uniform float uShininess;
\n
uniform float uOpacity;
\n
uniform bool enableDiffuse;
\n
uniform bool enableSpecular;
\n
uniform bool enableAO;
\n
uniform sampler2D tDiffuse;
\n
uniform sampler2D tNormal;
\n
uniform sampler2D tSpecular;
\n
uniform sampler2D tAO;
\n
uniform float uNormalScale;
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
"
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( 1.0 );
\n
vec4 mColor = vec4( uDiffuseColor, uOpacity );
\n
vec4 mSpecular = vec4( uSpecularColor, uOpacity );
\n
vec3 specularTex = vec3( 1.0 );
\n
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
\n
normalTex.xy *= uNormalScale;
\n
normalTex = normalize( normalTex );
\n
if( enableDiffuse )
\n
gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );
\n
if( enableAO )
\n
gl_FragColor = gl_FragColor * texture2D( tAO, vUv );
\n
if( enableSpecular )
\n
specularTex = texture2D( tSpecular, vUv ).xyz;
\n
mat3 tsb = mat3( vTangent, vBinormal, vNormal );
\n
vec3 finalNormal = tsb * normalTex;
\n
vec3 normal = normalize( finalNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointTotal = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
ViewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );
\n
pointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirTotal = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + vV
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );
\n
dirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirTotal;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointTotal;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( 1.0 );
\n
vec4 mColor = vec4( uDiffuseColor, uOpacity );
\n
vec4 mSpecular = vec4( uSpecularColor, uOpacity );
\n
vec3 specularTex = vec3( 1.0 );
\n
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
\n
normalTex.xy *= uNormalScale;
\n
normalTex = normalize( normalTex );
\n
if( enableDiffuse )
\n
gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );
\n
if( enableAO )
\n
gl_FragColor = gl_FragColor * texture2D( tAO, vUv );
\n
if( enableSpecular )
\n
specularTex = texture2D( tSpecular, vUv ).xyz;
\n
mat3 tsb = mat3( vTangent, vBinormal, vNormal );
\n
vec3 finalNormal = tsb * normalTex;
\n
vec3 normal = normalize( finalNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointTotal = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
iewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );
\n
pointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirTotal = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + v
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );
\n
dirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirTotal;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointTotal;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:
"
attribute vec4 tangent;
\n
#ifdef VERTEX_TEXTURES
\n
uniform sampler2D tDisplacement;
\n
uniform float uDisplacementScale;
\n
uniform float uDisplacementBias;
\n
#endif
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
vTangent = normalize( normalMatrix * tangent.xyz );
\n
vBinormal = cross( vNormal, vTangent ) * tangent.w;
\n
vBinormal = normalize( vBinormal );
\n
vUv = uv;
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#ifdef VERTEX_TEXTURES
\n
vec3 dv = texture2D( tDisplacement, uv ).xyz;
\n
float df = uDisplacementScale * dv.x + uDisplacementBias;
\n
vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;
\n
gl_Position = projectionMatrix * displacedPosition;
\n
#else
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
}
"
},
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:
"
attribute vec4 tangent;
\n
#ifdef VERTEX_TEXTURES
\n
uniform sampler2D tDisplacement;
\n
uniform float uDisplacementScale;
\n
uniform float uDisplacementBias;
\n
#endif
\n
varying vec3 vTangent;
\n
varying vec3 vBinormal;
\n
varying vec3 vNormal;
\n
varying vec2 vUv;
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
vTangent = normalize( normalMatrix * tangent.xyz );
\n
vBinormal = cross( vNormal, vTangent ) * tangent.w;
\n
vBinormal = normalize( vBinormal );
\n
vUv = uv;
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#ifdef VERTEX_TEXTURES
\n
vec3 dv = texture2D( tDisplacement, uv ).xyz;
\n
float df = uDisplacementScale * dv.x + uDisplacementBias;
\n
vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;
\n
gl_Position = projectionMatrix * displacedPosition;
\n
#else
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
}
"
},
cube
:{
uniforms
:{
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
vertexShader
:
"
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec3 wPos = cameraPosition - vViewPosition;
\n
gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );
\n
}
"
},
convolution
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
cube
:{
uniforms
:{
tCube
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
}},
vertexShader
:
"
varying vec3 vViewPosition;
\n
void main() {
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
uniform samplerCube tCube;
\n
varying vec3 vViewPosition;
\n
void main() {
\n
vec3 wPos = cameraPosition - vViewPosition;
\n
gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );
\n
}
"
},
convolution
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
uImageIncrement
:{
type
:
"
v2
"
,
value
:
new
THREE
.
Vector2
(
0.001953125
,
0
)},
cKernel
:{
type
:
"
fv1
"
,
value
:[]}},
vertexShader
:
"
varying vec2 vUv;
\n
uniform vec2 uImageIncrement;
\n
void main(void) {
\n
vUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform vec2 uImageIncrement;
\n
uniform float cKernel[KERNEL_SIZE];
\n
void main(void) {
\n
vec2 imageCoord = vUv;
\n
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
\n
for( int i=0; i<KERNEL_SIZE; ++i ) {
\n
sum += texture2D( tDiffuse, imageCoord ) * cKernel[i];
\n
imageCoord += uImageIncrement;
\n
}
\n
gl_FragColor = sum;
\n
}
"
},
value
:
0
,
texture
:
null
},
uImageIncrement
:{
type
:
"
v2
"
,
value
:
new
THREE
.
Vector2
(
0.001953125
,
0
)},
cKernel
:{
type
:
"
fv1
"
,
value
:[]}},
vertexShader
:
"
varying vec2 vUv;
\n
uniform vec2 uImageIncrement;
\n
void main(void) {
\n
vUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform vec2 uImageIncrement;
\n
uniform float cKernel[KERNEL_SIZE];
\n
void main(void) {
\n
vec2 imageCoord = vUv;
\n
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
\n
for( int i=0; i<KERNEL_SIZE; ++i ) {
\n
sum += texture2D( tDiffuse, imageCoord ) * cKernel[i];
\n
imageCoord += uImageIncrement;
\n
}
\n
gl_FragColor = sum;
\n
}
"
},
...
@@ -94,8 +94,8 @@ g.position.y==k.position.y&&g.position.z==k.position.z){c[b]=h;e=!0;break}}if(!e
...
@@ -94,8 +94,8 @@ g.position.y==k.position.y&&g.position.z==k.position.z){c[b]=h;e=!0;break}}if(!e
THREE
.
CylinderGeometry
=
function
(
a
,
b
,
c
,
g
,
e
,
h
){
function
f
(
a
,
c
,
b
){
j
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
c
,
b
)))}
THREE
.
Geometry
.
call
(
this
);
var
j
=
this
,
k
,
m
=
Math
.
PI
*
2
,
l
=
g
/
2
;
for
(
k
=
0
;
k
<
a
;
k
++
)
f
(
Math
.
sin
(
m
*
k
/
a
)
*
b
,
Math
.
cos
(
m
*
k
/
a
)
*
b
,
-
l
);
for
(
k
=
0
;
k
<
a
;
k
++
)
f
(
Math
.
sin
(
m
*
k
/
a
)
*
c
,
Math
.
cos
(
m
*
k
/
a
)
*
c
,
l
);
for
(
k
=
0
;
k
<
a
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
k
,
k
+
a
,
a
+
(
k
+
1
)
%
a
,(
k
+
1
)
%
a
));
if
(
c
>
0
){
f
(
0
,
0
,
-
l
-
(
h
||
0
));
for
(
k
=
a
;
k
<
a
+
a
/
2
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
2
*
a
,(
2
*
k
-
2
*
a
)
%
a
,(
2
*
k
-
2
*
a
+
1
)
%
a
,(
2
*
k
-
2
*
a
+
2
)
%
a
))}
if
(
b
>
0
){
f
(
0
,
0
,
l
+
THREE
.
CylinderGeometry
=
function
(
a
,
b
,
c
,
g
,
e
,
h
){
function
f
(
a
,
c
,
b
){
j
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
c
,
b
)))}
THREE
.
Geometry
.
call
(
this
);
var
j
=
this
,
k
,
m
=
Math
.
PI
*
2
,
l
=
g
/
2
;
for
(
k
=
0
;
k
<
a
;
k
++
)
f
(
Math
.
sin
(
m
*
k
/
a
)
*
b
,
Math
.
cos
(
m
*
k
/
a
)
*
b
,
-
l
);
for
(
k
=
0
;
k
<
a
;
k
++
)
f
(
Math
.
sin
(
m
*
k
/
a
)
*
c
,
Math
.
cos
(
m
*
k
/
a
)
*
c
,
l
);
for
(
k
=
0
;
k
<
a
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
k
,
k
+
a
,
a
+
(
k
+
1
)
%
a
,(
k
+
1
)
%
a
));
if
(
c
>
0
){
f
(
0
,
0
,
-
l
-
(
h
||
0
));
for
(
k
=
a
;
k
<
a
+
a
/
2
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
2
*
a
,(
2
*
k
-
2
*
a
)
%
a
,(
2
*
k
-
2
*
a
+
1
)
%
a
,(
2
*
k
-
2
*
a
+
2
)
%
a
))}
if
(
b
>
0
){
f
(
0
,
0
,
l
+
(
e
||
0
));
for
(
k
=
a
+
a
/
2
;
k
<
2
*
a
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
2
*
a
+
1
,(
2
*
k
-
2
*
a
+
2
)
%
a
+
a
,(
2
*
k
-
2
*
a
+
1
)
%
a
+
a
,(
2
*
k
-
2
*
a
)
%
a
+
a
))}
k
=
0
;
for
(
a
=
this
.
faces
.
length
;
k
<
a
;
k
++
){
var
b
=
[],
c
=
this
.
faces
[
k
],
e
=
this
.
vertices
[
c
.
a
],
h
=
this
.
vertices
[
c
.
b
],
l
=
this
.
vertices
[
c
.
c
],
n
=
this
.
vertices
[
c
.
d
];
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
e
.
position
.
x
,
e
.
position
.
y
)
/
m
,
0.5
+
e
.
position
.
z
/
g
));
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
h
.
position
.
x
,
h
.
position
.
y
)
/
m
,
0.5
+
h
.
position
.
z
/
g
));
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
l
.
position
.
x
,
l
.
position
.
y
)
/
m
,
0.5
+
l
.
position
.
z
/
(
e
||
0
));
for
(
k
=
a
+
a
/
2
;
k
<
2
*
a
;
k
++
)
j
.
faces
.
push
(
new
THREE
.
Face4
(
2
*
a
+
1
,(
2
*
k
-
2
*
a
+
2
)
%
a
+
a
,(
2
*
k
-
2
*
a
+
1
)
%
a
+
a
,(
2
*
k
-
2
*
a
)
%
a
+
a
))}
k
=
0
;
for
(
a
=
this
.
faces
.
length
;
k
<
a
;
k
++
){
var
b
=
[],
c
=
this
.
faces
[
k
],
e
=
this
.
vertices
[
c
.
a
],
h
=
this
.
vertices
[
c
.
b
],
l
=
this
.
vertices
[
c
.
c
],
n
=
this
.
vertices
[
c
.
d
];
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
e
.
position
.
x
,
e
.
position
.
y
)
/
m
,
0.5
+
e
.
position
.
z
/
g
));
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
h
.
position
.
x
,
h
.
position
.
y
)
/
m
,
0.5
+
h
.
position
.
z
/
g
));
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
l
.
position
.
x
,
l
.
position
.
y
)
/
m
,
0.5
+
l
.
position
.
z
/
g
));
c
instanceof
THREE
.
Face4
&&
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
n
.
position
.
x
,
n
.
position
.
y
)
/
m
,
0.5
+
n
.
position
.
z
/
g
));
this
.
faceVertexUvs
[
0
].
push
(
b
)}
this
.
computeCentroids
();
this
.
computeFaceNormals
()};
THREE
.
CylinderGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
CylinderGeometry
.
prototype
.
constructor
=
THREE
.
CylinderGeometry
;
g
));
c
instanceof
THREE
.
Face4
&&
b
.
push
(
new
THREE
.
UV
(
0.5
+
Math
.
atan2
(
n
.
position
.
x
,
n
.
position
.
y
)
/
m
,
0.5
+
n
.
position
.
z
/
g
));
this
.
faceVertexUvs
[
0
].
push
(
b
)}
this
.
computeCentroids
();
this
.
computeFaceNormals
()};
THREE
.
CylinderGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
CylinderGeometry
.
prototype
.
constructor
=
THREE
.
CylinderGeometry
;
THREE
.
ExtrudeGeometry
=
function
(
a
,
b
){
function
c
(
a
,
c
,
b
){
k
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
c
,
b
)))}
var
g
=
b
.
amount
!==
void
0
?
b
.
amount
:
100
,
e
=
parameters
.
bezelThickness
!==
void
0
?
parameters
.
bezelThickness
:
10
,
h
=
b
.
bezelEnabled
!==
void
0
?
b
.
bezelEnabled
:
!
1
;
THREE
.
Geometry
.
call
(
this
);
var
f
=
a
.
getPoints
(),
j
=
a
.
triangulate
(),
k
=
this
,
m
=
[],
l
,
n
,
o
=
f
.
length
,
p
=
j
.
length
,
u
=
m
.
length
;
for
(
l
=
0
;
l
<
o
;
l
++
)
n
=
f
[
l
],
c
(
n
.
x
,
n
.
y
,
0
);
for
(
l
=
0
;
l
<
o
;
l
++
)
n
=
f
[
l
],
c
(
n
.
x
,
n
.
y
,
g
);
if
(
h
){
for
(
l
=
0
;
l
<
u
;
l
++
)
h
=
m
[
l
],
c
(
h
.
x
,
h
.
y
,
e
);
for
(
l
=
0
;
l
<
u
;
l
++
)
h
=
THREE
.
ExtrudeGeometry
=
function
(
a
,
b
){
function
c
(
a
,
c
,
b
){
k
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
c
,
b
)))}
var
g
=
b
.
amount
!==
void
0
?
b
.
amount
:
100
,
e
=
b
.
bezelThickness
!==
void
0
?
b
.
bezelThickness
:
10
,
h
=
b
.
bezelEnabled
!==
void
0
?
b
.
bezelEnabled
:
!
1
;
THREE
.
Geometry
.
call
(
this
);
var
f
=
a
.
getPoints
(),
j
=
a
.
triangulate
(),
k
=
this
,
m
=
[],
l
,
n
,
o
=
f
.
length
,
p
=
j
.
length
,
u
=
m
.
length
;
for
(
l
=
0
;
l
<
o
;
l
++
)
n
=
f
[
l
],
c
(
n
.
x
,
n
.
y
,
0
);
for
(
l
=
0
;
l
<
o
;
l
++
)
n
=
f
[
l
],
c
(
n
.
x
,
n
.
y
,
g
);
if
(
h
){
for
(
l
=
0
;
l
<
u
;
l
++
)
h
=
m
[
l
],
c
(
h
.
x
,
h
.
y
,
e
);
for
(
l
=
0
;
l
<
u
;
l
++
)
h
=
m
[
l
],
c
(
h
.
x
,
h
.
y
,
m
[
l
],
c
(
h
.
x
,
h
.
y
,
g
-
e
)}
for
(
l
=
0
;
l
<
p
;
l
++
)
g
=
j
[
l
],
k
.
faces
.
push
(
new
THREE
.
Face3
(
g
[
2
],
g
[
1
],
g
[
0
]));
for
(
l
=
0
;
l
<
p
;
l
++
)
g
=
j
[
l
],
k
.
faces
.
push
(
new
THREE
.
Face3
(
g
[
0
]
+
o
,
g
[
1
]
+
o
,
g
[
2
]
+
o
));
f
.
push
(
f
[
0
]);
for
(
l
=
f
.
length
;
--
l
>
0
;){
for
(
j
=
0
;
j
<
o
;
j
++
)
if
(
f
[
j
].
equals
(
f
[
l
]))
break
;
for
(
p
=
0
;
p
<
o
;
p
++
)
if
(
f
[
p
].
equals
(
f
[
l
-
1
]))
break
;
k
.
faces
.
push
(
new
THREE
.
Face4
(
j
,
p
,
p
+
o
,
j
+
o
))}
this
.
computeCentroids
();
this
.
computeFaceNormals
()};
THREE
.
ExtrudeGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
ExtrudeGeometry
.
prototype
.
constructor
=
THREE
.
ExtrudeGeometry
;
g
-
e
)}
for
(
l
=
0
;
l
<
p
;
l
++
)
g
=
j
[
l
],
k
.
faces
.
push
(
new
THREE
.
Face3
(
g
[
2
],
g
[
1
],
g
[
0
]));
for
(
l
=
0
;
l
<
p
;
l
++
)
g
=
j
[
l
],
k
.
faces
.
push
(
new
THREE
.
Face3
(
g
[
0
]
+
o
,
g
[
1
]
+
o
,
g
[
2
]
+
o
));
f
.
push
(
f
[
0
]);
for
(
l
=
f
.
length
;
--
l
>
0
;){
for
(
j
=
0
;
j
<
o
;
j
++
)
if
(
f
[
j
].
equals
(
f
[
l
]))
break
;
for
(
p
=
0
;
p
<
o
;
p
++
)
if
(
f
[
p
].
equals
(
f
[
l
-
1
]))
break
;
k
.
faces
.
push
(
new
THREE
.
Face4
(
j
,
p
,
p
+
o
,
j
+
o
))}
this
.
computeCentroids
();
this
.
computeFaceNormals
()};
THREE
.
ExtrudeGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
ExtrudeGeometry
.
prototype
.
constructor
=
THREE
.
ExtrudeGeometry
;
THREE
.
IcosahedronGeometry
=
function
(
a
){
function
b
(
a
,
c
,
b
){
var
f
=
Math
.
sqrt
(
a
*
a
+
c
*
c
+
b
*
b
);
return
e
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
/
f
,
c
/
f
,
b
/
f
)))
-
1
}
function
c
(
a
,
c
,
b
,
f
){
f
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
c
,
b
))}
function
g
(
a
,
c
){
var
f
=
e
.
vertices
[
a
].
position
,
g
=
e
.
vertices
[
c
].
position
;
return
b
((
f
.
x
+
g
.
x
)
/
2
,(
f
.
y
+
g
.
y
)
/
2
,(
f
.
z
+
g
.
z
)
/
2
)}
var
e
=
this
,
h
=
new
THREE
.
Geometry
,
f
;
this
.
subdivisions
=
a
||
0
;
THREE
.
Geometry
.
call
(
this
);
a
=
(
1
+
Math
.
sqrt
(
5
))
/
2
;
b
(
-
1
,
a
,
0
);
b
(
1
,
a
,
0
);
b
(
-
1
,
-
a
,
0
);
b
(
1
,
-
a
,
0
);
b
(
0
,
-
1
,
a
);
b
(
0
,
1
,
a
);
b
(
0
,
-
1
,
THREE
.
IcosahedronGeometry
=
function
(
a
){
function
b
(
a
,
c
,
b
){
var
f
=
Math
.
sqrt
(
a
*
a
+
c
*
c
+
b
*
b
);
return
e
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
/
f
,
c
/
f
,
b
/
f
)))
-
1
}
function
c
(
a
,
c
,
b
,
f
){
f
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
c
,
b
))}
function
g
(
a
,
c
){
var
f
=
e
.
vertices
[
a
].
position
,
g
=
e
.
vertices
[
c
].
position
;
return
b
((
f
.
x
+
g
.
x
)
/
2
,(
f
.
y
+
g
.
y
)
/
2
,(
f
.
z
+
g
.
z
)
/
2
)}
var
e
=
this
,
h
=
new
THREE
.
Geometry
,
f
;
this
.
subdivisions
=
a
||
0
;
THREE
.
Geometry
.
call
(
this
);
a
=
(
1
+
Math
.
sqrt
(
5
))
/
2
;
b
(
-
1
,
a
,
0
);
b
(
1
,
a
,
0
);
b
(
-
1
,
-
a
,
0
);
b
(
1
,
-
a
,
0
);
b
(
0
,
-
1
,
a
);
b
(
0
,
1
,
a
);
b
(
0
,
-
1
,
-
a
);
b
(
0
,
1
,
-
a
);
b
(
a
,
0
,
-
1
);
b
(
a
,
0
,
1
);
b
(
-
a
,
0
,
-
1
);
b
(
-
a
,
0
,
1
);
c
(
0
,
11
,
5
,
h
);
c
(
0
,
5
,
1
,
h
);
c
(
0
,
1
,
7
,
h
);
c
(
0
,
7
,
10
,
h
);
c
(
0
,
10
,
11
,
h
);
c
(
1
,
5
,
9
,
h
);
c
(
5
,
11
,
4
,
h
);
c
(
11
,
10
,
2
,
h
);
c
(
10
,
7
,
6
,
h
);
c
(
7
,
1
,
8
,
h
);
c
(
3
,
9
,
4
,
h
);
c
(
3
,
4
,
2
,
h
);
c
(
3
,
2
,
6
,
h
);
c
(
3
,
6
,
8
,
h
);
c
(
3
,
8
,
9
,
h
);
c
(
4
,
9
,
5
,
h
);
c
(
2
,
4
,
11
,
h
);
c
(
6
,
2
,
10
,
h
);
c
(
8
,
6
,
7
,
h
);
c
(
9
,
8
,
1
,
h
);
for
(
a
=
0
;
a
<
this
.
subdivisions
;
a
++
){
f
=
new
THREE
.
Geometry
;
for
(
var
j
in
h
.
faces
){
var
k
=
g
(
h
.
faces
[
j
].
a
,
h
.
faces
[
j
].
b
),
m
=
g
(
h
.
faces
[
j
].
b
,
h
.
faces
[
j
].
c
),
l
=
g
(
h
.
faces
[
j
].
c
,
h
.
faces
[
j
].
a
);
c
(
h
.
faces
[
j
].
a
,
k
,
l
,
f
);
c
(
h
.
faces
[
j
].
b
,
m
,
k
,
f
);
-
a
);
b
(
0
,
1
,
-
a
);
b
(
a
,
0
,
-
1
);
b
(
a
,
0
,
1
);
b
(
-
a
,
0
,
-
1
);
b
(
-
a
,
0
,
1
);
c
(
0
,
11
,
5
,
h
);
c
(
0
,
5
,
1
,
h
);
c
(
0
,
1
,
7
,
h
);
c
(
0
,
7
,
10
,
h
);
c
(
0
,
10
,
11
,
h
);
c
(
1
,
5
,
9
,
h
);
c
(
5
,
11
,
4
,
h
);
c
(
11
,
10
,
2
,
h
);
c
(
10
,
7
,
6
,
h
);
c
(
7
,
1
,
8
,
h
);
c
(
3
,
9
,
4
,
h
);
c
(
3
,
4
,
2
,
h
);
c
(
3
,
2
,
6
,
h
);
c
(
3
,
6
,
8
,
h
);
c
(
3
,
8
,
9
,
h
);
c
(
4
,
9
,
5
,
h
);
c
(
2
,
4
,
11
,
h
);
c
(
6
,
2
,
10
,
h
);
c
(
8
,
6
,
7
,
h
);
c
(
9
,
8
,
1
,
h
);
for
(
a
=
0
;
a
<
this
.
subdivisions
;
a
++
){
f
=
new
THREE
.
Geometry
;
for
(
var
j
in
h
.
faces
){
var
k
=
g
(
h
.
faces
[
j
].
a
,
h
.
faces
[
j
].
b
),
m
=
g
(
h
.
faces
[
j
].
b
,
h
.
faces
[
j
].
c
),
l
=
g
(
h
.
faces
[
j
].
c
,
h
.
faces
[
j
].
a
);
c
(
h
.
faces
[
j
].
a
,
k
,
l
,
f
);
c
(
h
.
faces
[
j
].
b
,
m
,
k
,
f
);
c
(
h
.
faces
[
j
].
c
,
l
,
m
,
f
);
c
(
k
,
m
,
l
,
f
)}
h
.
faces
=
f
.
faces
}
e
.
faces
=
h
.
faces
;
delete
h
;
delete
f
;
this
.
computeCentroids
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
()};
THREE
.
IcosahedronGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
IcosahedronGeometry
.
prototype
.
constructor
=
THREE
.
IcosahedronGeometry
;
c
(
h
.
faces
[
j
].
c
,
l
,
m
,
f
);
c
(
k
,
m
,
l
,
f
)}
h
.
faces
=
f
.
faces
}
e
.
faces
=
h
.
faces
;
delete
h
;
delete
f
;
this
.
computeCentroids
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
()};
THREE
.
IcosahedronGeometry
.
prototype
=
new
THREE
.
Geometry
;
THREE
.
IcosahedronGeometry
.
prototype
.
constructor
=
THREE
.
IcosahedronGeometry
;
...
...
build/custom/ThreeWebGL.js
浏览文件 @
256f9a67
...
@@ -153,7 +153,7 @@ envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3(
...
@@ -153,7 +153,7 @@ envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3(
map_particle_pars_fragment
:
"
#ifdef USE_MAP
\n
uniform sampler2D map;
\n
#endif
"
,
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
"
,
map_particle_pars_fragment
:
"
#ifdef USE_MAP
\n
uniform sampler2D map;
\n
#endif
"
,
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_pars_vertex
:
"
uniform bool enableLighting;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#ifdef PHONG
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_pars_vertex
:
"
uniform bool enableLighting;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#ifdef PHONG
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lights_vertex
:
"
if ( !enableLighting ) {
\n
vLightWeighting = vec3( 1.0 );
\n
} else {
\n
vLightWeighting = ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );
\n
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
\n
}
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
#ifdef PHONG
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
#endif
\n
}
\n
#endif
\n
}
"
,
lights_vertex
:
"
if ( !enableLighting ) {
\n
vLightWeighting = vec3( 1.0 );
\n
} else {
\n
vLightWeighting = ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );
\n
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
\n
}
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
#ifdef PHONG
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
#endif
\n
}
\n
#endif
\n
}
"
,
lights_pars_fragment
:
"
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
vec4 mColor = vec4( diffuse, opacity );
\n
vec4 mSpecular = vec4( specular, opacity );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointDiffuse = vec4( 0.0 );
\n
vec4 pointSpecular = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
ViewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = pow( pointDotNormalHalf, shininess );
\n
pointDiffuse += mColor * pointDiffuseWeight * pointDistance;
\n
pointSpecular += mSpecular * pointSpecularWeight * pointDistance;
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirDiffuse = vec4( 0.0 );
\n
vec4 dirSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + vV
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = pow( dirDotNormalHalf, shininess );
\n
dirDiffuse += mColor * dirDiffuseWeight;
\n
dirSpecular += mSpecular * dirSpecularWeight;
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirDiffuse + dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointDiffuse + pointSpecular;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
lights_pars_fragment
:
"
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
vec4 mColor = vec4( diffuse, opacity );
\n
vec4 mSpecular = vec4( specular, opacity );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointDiffuse = vec4( 0.0 );
\n
vec4 pointSpecular = vec4( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec3 pointVector = normalize( vPointLight[ i ].xyz );
\n
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
iewPosition );
\n
float pointDistance = vPointLight[ i ].w;
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = pow( pointDotNormalHalf, shininess );
\n
pointDiffuse += mColor * pointDiffuseWeight * pointDistance;
\n
pointSpecular += mSpecular * pointSpecularWeight * pointDistance;
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirDiffuse = vec4( 0.0 );
\n
vec4 dirSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + v
iewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = pow( dirDotNormalHalf, shininess );
\n
dirDiffuse += mColor * dirDiffuseWeight;
\n
dirSpecular += mSpecular * dirSpecularWeight;
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirDiffuse + dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointDiffuse + pointSpecular;
\n
#endif
\n
gl_FragColor = gl_FragColor * totalLight;
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
vColor = color;
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;
\n
#endif
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
vColor = color;
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0, 0.0, 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0, 0.0, 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
b
){
var
d
,
e
,
f
,
g
=
{};
for
(
d
=
0
;
d
<
b
.
length
;
d
++
)
for
(
e
in
f
=
this
.
clone
(
b
[
d
]),
f
)
g
[
e
]
=
f
[
e
];
return
g
},
clone
:
function
(
b
){
var
d
,
e
,
f
,
g
=
{};
for
(
d
in
b
)
for
(
e
in
g
[
d
]
=
{},
b
[
d
])
f
=
b
[
d
][
e
],
g
[
d
][
e
]
=
f
instanceof
THREE
.
Color
||
f
instanceof
THREE
.
Vector3
||
f
instanceof
THREE
.
Texture
?
f
.
clone
():
f
;
return
g
}};
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
b
){
var
d
,
e
,
f
,
g
=
{};
for
(
d
=
0
;
d
<
b
.
length
;
d
++
)
for
(
e
in
f
=
this
.
clone
(
b
[
d
]),
f
)
g
[
e
]
=
f
[
e
];
return
g
},
clone
:
function
(
b
){
var
d
,
e
,
f
,
g
=
{};
for
(
d
in
b
)
for
(
e
in
g
[
d
]
=
{},
b
[
d
])
f
=
b
[
d
][
e
],
g
[
d
][
e
]
=
f
instanceof
THREE
.
Color
||
f
instanceof
THREE
.
Vector3
||
f
instanceof
THREE
.
Texture
?
f
.
clone
():
f
;
return
g
}};
...
...
examples/webgl_geometry_large_mesh.html
浏览文件 @
256f9a67
...
@@ -142,7 +142,7 @@
...
@@ -142,7 +142,7 @@
if
(
render_gl
)
{
if
(
render_gl
)
{
try
{
try
{
webglRenderer
=
new
THREE
.
WebGLRenderer
();
webglRenderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
webglRenderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
webglRenderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
webglRenderer
.
domElement
.
style
.
position
=
"
relative
"
;
webglRenderer
.
domElement
.
style
.
position
=
"
relative
"
;
container
.
appendChild
(
webglRenderer
.
domElement
);
container
.
appendChild
(
webglRenderer
.
domElement
);
...
...
src/extras/ShaderUtils.js
浏览文件 @
256f9a67
...
@@ -202,7 +202,7 @@ THREE.ShaderUtils = {
...
@@ -202,7 +202,7 @@ THREE.ShaderUtils = {
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
vec3 pointVector = normalize( vPointLight[ i ].xyz );
"
,
"
vec3 pointVector = normalize( vPointLight[ i ].xyz );
"
,
"
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
V
iewPosition );
"
,
"
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );
"
,
"
float pointDistance = vPointLight[ i ].w;
"
,
"
float pointDistance = vPointLight[ i ].w;
"
,
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
,
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
,
...
@@ -229,7 +229,7 @@ THREE.ShaderUtils = {
...
@@ -229,7 +229,7 @@ THREE.ShaderUtils = {
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
,
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
,
"
vec3 dirVector = normalize( lDirection.xyz );
"
,
"
vec3 dirVector = normalize( lDirection.xyz );
"
,
"
vec3 dirHalfVector = normalize( lDirection.xyz + v
V
iewPosition );
"
,
"
vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );
"
,
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
,
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
,
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
,
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
,
...
...
src/renderers/WebGLShaders.js
浏览文件 @
256f9a67
...
@@ -336,7 +336,7 @@ THREE.ShaderChunk = {
...
@@ -336,7 +336,7 @@ THREE.ShaderChunk = {
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
"
,
"
vec3 pointVector = normalize( vPointLight[ i ].xyz );
"
,
"
vec3 pointVector = normalize( vPointLight[ i ].xyz );
"
,
"
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + v
V
iewPosition );
"
,
"
vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );
"
,
"
float pointDistance = vPointLight[ i ].w;
"
,
"
float pointDistance = vPointLight[ i ].w;
"
,
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
,
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
,
...
@@ -364,7 +364,7 @@ THREE.ShaderChunk = {
...
@@ -364,7 +364,7 @@ THREE.ShaderChunk = {
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
,
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
,
"
vec3 dirVector = normalize( lDirection.xyz );
"
,
"
vec3 dirVector = normalize( lDirection.xyz );
"
,
"
vec3 dirHalfVector = normalize( lDirection.xyz + v
V
iewPosition );
"
,
"
vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );
"
,
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
,
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录