Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
671b5079
T
three.js
项目概览
fktz008
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
671b5079
编写于
9月 23, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLRenderer: MeshPhongMaterial was overriding the alpha chanel of textures.
上级
9441e74a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
6 deletion
+6
-6
build/Three.js
build/Three.js
+2
-2
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+2
-2
src/renderers/WebGLShaders.js
src/renderers/WebGLShaders.js
+2
-2
未找到文件。
build/Three.js
浏览文件 @
671b5079
...
...
@@ -195,7 +195,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
"
,
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_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( vec3( 0.0 ), 1.0 );
\n
vec4 pointSpecular = vec4( vec3( 0.0 ), 1.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 + 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( vec3( 0.0 ), 1.0 );
\n
vec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 + viewPosition );
\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 totalDiffuse = vec4( vec3( 0.0 ), opacity );
\n
vec4 totalSpecular = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
gl_FragColor
= gl_FragColor * totalDiffuse + totalSpecular
;
"
,
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( vec3( 0.0 ), 1.0 );
\n
vec4 pointSpecular = vec4( vec3( 0.0 ), 1.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 + 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( vec3( 0.0 ), 1.0 );
\n
vec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 + viewPosition );
\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 totalDiffuse = vec4( vec3( 0.0 ), opacity );
\n
vec4 totalSpecular = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
gl_FragColor
.xyz = gl_FragColor.xyz * totalDiffuse.xyz + totalSpecular.xyz
;
"
,
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
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform float shadowDarkness;
\n
uniform float shadowBias;
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
float unpackDepth( const in vec4 rgba_depth ) {
\n
const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
\n
float depth = dot( rgba_depth, bit_shift );
\n
return depth;
\n
}
\n
#endif
"
,
...
...
@@ -214,7 +214,7 @@ THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.Shad
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( diffuse, opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
"
gl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );
"
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:[
"
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
THREE
.
ShaderChunk
.
lights_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,
THREE
.
UniformsLib
.
shadowmap
,{
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
}}]),
fragmentShader
:[
"
uniform vec3 diffuse;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vLightWeighting,
1.0
);
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vLightWeighting,
opacity
);
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:[
"
#define PHONG
\n
varying vec3 vLightWeighting;
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
\n
vec3 transformedNormal = normalize( normalMatrix * normal );
\n
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
)},
particle_basic
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
particle
,
THREE
.
UniformsLib
.
shadowmap
]),
fragmentShader
:[
"
uniform vec3 psColor;
\n
uniform float opacity;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_particle_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( psColor, opacity );
"
,
THREE
.
ShaderChunk
.
map_particle_fragment
,
...
...
build/custom/ThreeWebGL.js
浏览文件 @
671b5079
...
...
@@ -152,7 +152,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
"
,
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_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( vec3( 0.0 ), 1.0 );
\n
vec4 pointSpecular = vec4( vec3( 0.0 ), 1.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 + 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( vec3( 0.0 ), 1.0 );
\n
vec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 + viewPosition );
\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 totalDiffuse = vec4( vec3( 0.0 ), opacity );
\n
vec4 totalSpecular = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
gl_FragColor
= gl_FragColor * totalDiffuse + totalSpecular
;
"
,
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( vec3( 0.0 ), 1.0 );
\n
vec4 pointSpecular = vec4( vec3( 0.0 ), 1.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 + 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( vec3( 0.0 ), 1.0 );
\n
vec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 + viewPosition );
\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 totalDiffuse = vec4( vec3( 0.0 ), opacity );
\n
vec4 totalSpecular = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
gl_FragColor
.xyz = gl_FragColor.xyz * totalDiffuse.xyz + totalSpecular.xyz
;
"
,
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
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform float shadowDarkness;
\n
uniform float shadowBias;
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
float unpackDepth( const in vec4 rgba_depth ) {
\n
const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
\n
float depth = dot( rgba_depth, bit_shift );
\n
return depth;
\n
}
\n
#endif
"
,
...
...
@@ -171,7 +171,7 @@ THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.Shad
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( diffuse, opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
"
gl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );
"
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:[
"
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
THREE
.
ShaderChunk
.
lights_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,
THREE
.
UniformsLib
.
shadowmap
,{
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
}}]),
fragmentShader
:[
"
uniform vec3 diffuse;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vLightWeighting,
1.0
);
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vLightWeighting,
opacity
);
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertexShader
:[
"
#define PHONG
\n
varying vec3 vLightWeighting;
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
\n
vec3 transformedNormal = normalize( normalMatrix * normal );
\n
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
)},
particle_basic
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
particle
,
THREE
.
UniformsLib
.
shadowmap
]),
fragmentShader
:[
"
uniform vec3 psColor;
\n
uniform float opacity;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_particle_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( psColor, opacity );
"
,
THREE
.
ShaderChunk
.
map_particle_fragment
,
...
...
src/renderers/WebGLShaders.js
浏览文件 @
671b5079
...
...
@@ -408,7 +408,7 @@ THREE.ShaderChunk = {
"
#endif
"
,
"
gl_FragColor
= gl_FragColor * totalDiffuse + totalSpecular
;
"
"
gl_FragColor
.xyz = gl_FragColor.xyz * totalDiffuse.xyz + totalSpecular.xyz
;
"
].
join
(
"
\n
"
),
...
...
@@ -1138,7 +1138,7 @@ THREE.ShaderLib = {
"
void main() {
"
,
"
gl_FragColor = vec4( vLightWeighting,
1.0
);
"
,
"
gl_FragColor = vec4( vLightWeighting,
opacity
);
"
,
THREE
.
ShaderChunk
[
"
map_fragment
"
],
THREE
.
ShaderChunk
[
"
alphatest_fragment
"
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录