Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
9fdd1419
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9fdd1419
编写于
1月 06, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added check for pixel being behind light frustum in shadow map shader.
上级
be761428
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
61 deletion
+70
-61
build/Three.js
build/Three.js
+1
-1
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+1
-1
src/renderers/WebGLShaders.js
src/renderers/WebGLShaders.js
+68
-59
未找到文件。
build/Three.js
浏览文件 @
9fdd1419
...
@@ -207,7 +207,7 @@ lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition =
...
@@ -207,7 +207,7 @@ lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition =
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
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\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
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\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
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\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
"
,
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 vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\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
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
vec3 shadowColor = vec3( 1.0 );
\n
float fDepth;
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
shadowCoord.z += shadowBias[ i ];
\n
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
if ( all( shadowTest ) ) {
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
vec3 shadowColor = vec3( 1.0 );
\n
float fDepth;
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
if ( shadowCoord.z <= 1.0 ) {
\n
shadowCoord.z += shadowBias[ i ];
\n
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
if ( all( shadowTest ) ) {
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
}
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
=
0
;
b
<
a
.
length
;
b
++
)
for
(
c
in
d
=
this
.
clone
(
a
[
b
]),
d
)
e
[
c
]
=
d
[
c
];
return
e
},
clone
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
in
a
)
for
(
c
in
e
[
b
]
=
{},
a
[
b
])
d
=
a
[
b
][
c
],
e
[
b
][
c
]
=
d
instanceof
THREE
.
Color
||
d
instanceof
THREE
.
Vector2
||
d
instanceof
THREE
.
Vector3
||
d
instanceof
THREE
.
Vector4
||
d
instanceof
THREE
.
Matrix4
||
d
instanceof
THREE
.
Texture
?
d
.
clone
():
d
instanceof
Array
?
d
.
slice
():
d
;
return
e
}};
THREE
.
UniformsUtils
=
{
merge
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
=
0
;
b
<
a
.
length
;
b
++
)
for
(
c
in
d
=
this
.
clone
(
a
[
b
]),
d
)
e
[
c
]
=
d
[
c
];
return
e
},
clone
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
in
a
)
for
(
c
in
e
[
b
]
=
{},
a
[
b
])
d
=
a
[
b
][
c
],
e
[
b
][
c
]
=
d
instanceof
THREE
.
Color
||
d
instanceof
THREE
.
Vector2
||
d
instanceof
THREE
.
Vector3
||
d
instanceof
THREE
.
Vector4
||
d
instanceof
THREE
.
Matrix4
||
d
instanceof
THREE
.
Texture
?
d
.
clone
():
d
instanceof
Array
?
d
.
slice
():
d
;
return
e
}};
...
...
build/custom/ThreeWebGL.js
浏览文件 @
9fdd1419
...
@@ -160,7 +160,7 @@ lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition =
...
@@ -160,7 +160,7 @@ lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition =
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
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\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
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\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
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\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
"
,
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 vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\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
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
vec3 shadowColor = vec3( 1.0 );
\n
float fDepth;
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
shadowCoord.z += shadowBias[ i ];
\n
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
if ( all( shadowTest ) ) {
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
vec3 shadowColor = vec3( 1.0 );
\n
float fDepth;
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
if ( shadowCoord.z <= 1.0 ) {
\n
shadowCoord.z += shadowBias[ i ];
\n
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
if ( all( shadowTest ) ) {
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
}
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
THREE
.
UniformsUtils
=
{
merge
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
=
0
;
b
<
a
.
length
;
b
++
)
for
(
c
in
d
=
this
.
clone
(
a
[
b
]),
d
)
e
[
c
]
=
d
[
c
];
return
e
},
clone
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
in
a
)
for
(
c
in
e
[
b
]
=
{},
a
[
b
])
d
=
a
[
b
][
c
],
e
[
b
][
c
]
=
d
instanceof
THREE
.
Color
||
d
instanceof
THREE
.
Vector2
||
d
instanceof
THREE
.
Vector3
||
d
instanceof
THREE
.
Vector4
||
d
instanceof
THREE
.
Matrix4
||
d
instanceof
THREE
.
Texture
?
d
.
clone
():
d
instanceof
Array
?
d
.
slice
():
d
;
return
e
}};
THREE
.
UniformsUtils
=
{
merge
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
=
0
;
b
<
a
.
length
;
b
++
)
for
(
c
in
d
=
this
.
clone
(
a
[
b
]),
d
)
e
[
c
]
=
d
[
c
];
return
e
},
clone
:
function
(
a
){
var
b
,
c
,
d
,
e
=
{};
for
(
b
in
a
)
for
(
c
in
e
[
b
]
=
{},
a
[
b
])
d
=
a
[
b
][
c
],
e
[
b
][
c
]
=
d
instanceof
THREE
.
Color
||
d
instanceof
THREE
.
Vector2
||
d
instanceof
THREE
.
Vector3
||
d
instanceof
THREE
.
Vector4
||
d
instanceof
THREE
.
Matrix4
||
d
instanceof
THREE
.
Texture
?
d
.
clone
():
d
instanceof
Array
?
d
.
slice
():
d
;
return
e
}};
...
...
src/renderers/WebGLShaders.js
浏览文件 @
9fdd1419
...
@@ -763,101 +763,110 @@ THREE.ShaderChunk = {
...
@@ -763,101 +763,110 @@ THREE.ShaderChunk = {
"
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
"
,
"
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
"
,
"
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
"
,
"
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
"
,
"
shadowCoord.z += shadowBias[ i ];
"
,
// using "if ( all )" for ATI OpenGL shader compiler
// don't shadow pixels behind far plane of light frustum
// "if ( something && something )" breaks it
"
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
"
,
"
if ( shadowCoord.z <= 1.0 ) {
"
,
"
if ( all( shadowTest ) ) {
"
,
"
shadowCoord.z += shadowBias[ i ];
"
,
"
#ifdef SHADOWMAP_SOFT
"
,
// using "if ( all )" for ATI OpenGL shader compiler
// "if ( something && something )" breaks it
// Percentage-close filtering
// don't shadow pixels outside of light frustum
// (9 pixel kernel)
// http://fabiensanglard.net/shadowmappingPCF/
"
float shadow = 0.0
;
"
,
"
bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 )
;
"
,
/*
"
if ( all( shadowTest ) ) {
"
,
// this breaks shader compiler / validator on some ATI cards when using OpenGL
// must enroll loop manually
"for ( float y = -1.25; y <= 1.25; y += 1.25 )",
"
#ifdef SHADOWMAP_SOFT
"
,
"for ( float x = -1.25; x <= 1.25; x += 1.25 ) {",
"vec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );",
// Percentage-close filtering
// (9 pixel kernel)
// http://fabiensanglard.net/shadowmappingPCF/
// doesn't seem to produce any noticeable visual difference compared to simple "texture2D" lookup
"
float shadow = 0.0;
"
,
//"vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );",
"float fDepth = unpackDepth( rgbaDepth );",
/*
// this breaks shader compiler / validator on some ATI cards when using OpenGL
// must enroll loop manually
"if ( fDepth < shadowCoord.z
)",
"for ( float y = -1.25; y <= 1.25; y += 1.25
)",
"shadow += 1.0;
",
"for ( float x = -1.25; x <= 1.25; x += 1.25 ) {
",
"}
",
"vec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );
",
"shadow /= 9.0;",
// doesn't seem to produce any noticeable visual difference compared to simple "texture2D" lookup
//"vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );",
*/
"float fDepth = unpackDepth( rgbaDepth );",
"
const float shadowDelta = 1.0 / 9.0;
"
,
"if ( fDepth < shadowCoord.z )",
"shadow += 1.0;",
"
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
"
,
"}",
"
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
"
,
"
float dx0 = -1.25 * xPixelOffset;
"
,
"shadow /= 9.0;",
"
float dy0 = -1.25 * yPixelOffset;
"
,
"
float dx1 = 1.25 * xPixelOffset;
"
,
"
float dy1 = 1.25 * yPixelOffset;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
"
,
*/
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
"
,
"
const float shadowDelta = 1.0 / 9.0;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) )
;
"
,
"
float xPixelOffset = 1.0 / shadowMapSize[ i ].x
;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta
;
"
,
"
float yPixelOffset = 1.0 / shadowMapSize[ i ].y
;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
"
,
"
float dx0 = -1.25 * xPixelOffset;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
float dy0 = -1.25 * yPixelOffset;
"
,
"
float dx1 = 1.25 * xPixelOffset;
"
,
"
float dy1 = 1.25 * yPixelOffset;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy
) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 )
) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.
0 ) ) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy
0 ) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1
) ) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0
) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1
) ) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0
) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 )
) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy
) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
#else
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
"
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy
);
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) )
);
"
,
"
float fDepth = unpackDepth( rgbaDepth )
;
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta
;
"
,
"
if ( fDepth < shadowCoord.z )
"
,
"
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
"
,
"
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
"
,
// spot with multiple shadows is darker
"
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
"
,
"
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
"
,
"
#else
"
,
// spot with multiple shadows has the same color as single shadow spot
"
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
"
,
"
float fDepth = unpackDepth( rgbaDepth );
"
,
//"shadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );
",
"
if ( fDepth < shadowCoord.z )
"
,
"
#endif
"
,
// spot with multiple shadows is darker
"
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
"
,
// spot with multiple shadows has the same color as single shadow spot
//"shadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );",
"
#endif
"
,
"
}
"
,
"
}
"
,
"
}
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录