Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0f9a9226
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,发现更多精彩内容 >>
提交
0f9a9226
编写于
9月 15, 2015
作者:
M
Mark Kellogg
提交者:
mkkellogg
9月 24, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inlined code from sampleCubeShadowMapPCF() directly into main().
上级
5964cb9b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
62 addition
and
66 deletion
+62
-66
src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl
src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl
+53
-4
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
...enderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
+9
-62
未找到文件。
src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl
浏览文件 @
0f9a9226
...
...
@@ -46,7 +46,31 @@
#if defined( SHADOWMAP_TYPE_PCF )
if
(
isPointLight
){
shadow
=
sampleCubeShadowMapPCF
(
i
,
normalize
(
lightToPosition
),
length
(
lightToPosition
),
cubeTexelSize
,
1
.
5
);
initGridSamplingDisk
();
float
diskRadius
=
1
.
5
;
float
numSamples
=
1
.
0
;
shadow
=
0
.
0
;
vec3
baseDirection
=
normalize
(
lightToPosition
);
float
curDistance
=
length
(
lightToPosition
);
float
dist
=
unpack1K
(
textureCube
(
shadowCube
[
i
],
baseDirection
)
);
if
(
curDistance
>=
dist
)
shadow
+=
1
.
0
;
// evaluate each sampling direction
for
(
int
s
=
0
;
s
<
20
;
s
++
){
vec3
offset
=
gridSamplingDisk
[
s
]
*
diskRadius
*
cubeTexelSize
;
dist
=
unpack1K
(
textureCube
(
shadowCube
[
i
],
vec3
(
baseDirection
+
offset
)
)
);
if
(
curDistance
>=
dist
)
shadow
+=
1
.
0
;
numSamples
+=
1
.
0
;
}
shadow
/=
numSamples
;
}
else
{
// Percentage-close filtering
...
...
@@ -120,7 +144,31 @@
if
(
isPointLight
){
shadow
=
sampleCubeShadowMapPCF
(
i
,
normalize
(
lightToPosition
),
length
(
lightToPosition
),
cubeTexelSize
,
2
.
5
);
initGridSamplingDisk
();
float
diskRadius
=
2
.
5
;
float
numSamples
=
1
.
0
;
shadow
=
0
.
0
;
vec3
baseDirection
=
normalize
(
lightToPosition
);
float
curDistance
=
length
(
lightToPosition
);
float
dist
=
unpack1K
(
textureCube
(
shadowCube
[
i
],
baseDirection
)
);
if
(
curDistance
>=
dist
)
shadow
+=
1
.
0
;
// evaluate each sampling direction
for
(
int
s
=
0
;
s
<
20
;
s
++
){
vec3
offset
=
gridSamplingDisk
[
s
]
*
diskRadius
*
cubeTexelSize
;
dist
=
unpack1K
(
textureCube
(
shadowCube
[
i
],
vec3
(
baseDirection
+
offset
)
)
);
if
(
curDistance
>=
dist
)
shadow
+=
1
.
0
;
numSamples
+=
1
.
0
;
}
shadow
/=
numSamples
;
}
else
{
...
...
@@ -179,7 +227,8 @@
if
(
isPointLight
){
float
dist
=
getCubeShadowMapFloat
(
i
,
normalize
(
lightToPosition
)
);
vec4
data
=
textureCube
(
shadowCube
[
i
],
normalize
(
lightToPosition
)
);
float
dist
=
unpack1K
(
data
);
if
(
length
(
lightToPosition
)
>=
dist
)
shadowColor
=
shadowColor
*
vec3
(
1
.
0
-
realShadowDarkness
);
...
...
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl
浏览文件 @
0f9a9226
...
...
@@ -36,10 +36,16 @@
}
vec3
gridSamplingDisk
[
20
];
int
gridSamplingInitialized
=
0
;
bool
gridSamplingInitialized
=
false
;
void
initGridSamplingDisk
(){
if
(
gridSamplingInitialized
){
return
;
}
gridSamplingDisk
[
0
]
=
vec3
(
1
,
1
,
1
);
gridSamplingDisk
[
1
]
=
vec3
(
1
,
-
1
,
1
);
gridSamplingDisk
[
2
]
=
vec3
(
-
1
,
-
1
,
1
);
...
...
@@ -61,66 +67,7 @@
gridSamplingDisk
[
18
]
=
vec3
(
0
,
-
1
,
-
1
);
gridSamplingDisk
[
19
]
=
vec3
(
0
,
1
,
-
1
);
}
float
getCubeShadowMapFloat
(
const
in
int
cubeIndex
,
in
vec3
baseDirection
){
vec4
data
=
vec4
(
0
,
0
,
0
,
0
);
// This loop may seem silly and unnecessary, but we can't use @cubeIndex to access @shadowCube
// directly, since its bounds are unknown to the compiler. The compiler
// knows the bounds of the loop variable 'i' so we CAN use that to index
// into @shadowCube. The alternative to this is to send the samplerCube directly
// to this function as a parameter, but come drivers don't allow that.
for
(
int
i
=
0
;
i
<
MAX_SHADOWS
;
i
++
)
{
if
(
i
==
cubeIndex
){
data
=
textureCube
(
shadowCube
[
i
],
baseDirection
);
break
;
}
}
float
dist
=
unpack1K
(
data
);
return
dist
;
}
float
sampleCubeShadowMapPCF
(
const
in
int
cubeIndex
,
in
vec3
baseDirection
,
in
float
curDistance
,
in
float
texSize
,
float
softness
){
if
(
gridSamplingInitialized
==
0
){
initGridSamplingDisk
();
gridSamplingInitialized
=
1
;
}
// radius of PCF depending on distance from the light source
float
diskRadius
=
softness
;
float
numSamples
=
0
.
0
;
float
shadowFactor
=
0
.
0
;
float
dist
=
getCubeShadowMapFloat
(
cubeIndex
,
baseDirection
);
if
(
curDistance
>=
dist
)
shadowFactor
+=
1
.
0
;
numSamples
+=
1
.
0
;
// evaluate each sampling direction
for
(
int
i
=
0
;
i
<
20
;
i
++
){
vec3
offset
=
gridSamplingDisk
[
i
]
*
diskRadius
*
texSize
;
dist
=
getCubeShadowMapFloat
(
cubeIndex
,
vec3
(
baseDirection
+
offset
)
);
if
(
curDistance
>=
dist
)
shadowFactor
+=
1
.
0
;
numSamples
+=
1
.
0
;
}
shadowFactor
/=
numSamples
;
return
shadowFactor
;
gridSamplingInitialized
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录