Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
79391057
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,发现更多精彩内容 >>
提交
79391057
编写于
10月 29, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7414 from bhouston/cosine_envMap_lod
Cosine-based specular env map LOD selection
上级
0e632df6
6e3c2e88
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
12 deletion
+36
-12
src/renderers/shaders/ShaderChunk/bsdfs.glsl
src/renderers/shaders/ShaderChunk/bsdfs.glsl
+11
-6
src/renderers/shaders/ShaderChunk/common.glsl
src/renderers/shaders/ShaderChunk/common.glsl
+1
-0
src/renderers/shaders/ShaderChunk/lights_pars.glsl
src/renderers/shaders/ShaderChunk/lights_pars.glsl
+21
-3
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
...rs/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
+1
-2
src/renderers/shaders/ShaderChunk/lights_template.glsl
src/renderers/shaders/ShaderChunk/lights_template.glsl
+2
-1
未找到文件。
src/renderers/shaders/ShaderChunk/bsdfs.glsl
浏览文件 @
79391057
float
calcLightAttenuation
(
float
lightDistance
,
float
cutoffDistance
,
float
decayExponent
)
{
float
calcLightAttenuation
(
const
in
float
lightDistance
,
const
in
float
cutoffDistance
,
const
in
float
decayExponent
)
{
if
(
decayExponent
>
0
.
0
)
{
...
...
@@ -36,7 +36,7 @@ vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
// Microfacet Models for Refraction through Rough Surfaces - equation (34)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
float
G_GGX_Smith
(
in
float
alpha
,
in
float
dotNL
,
in
float
dotNV
)
{
float
G_GGX_Smith
(
const
in
float
alpha
,
const
in
float
dotNL
,
const
in
float
dotNV
)
{
// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)
...
...
@@ -54,7 +54,7 @@ float G_GGX_Smith( in float alpha, in float dotNL, in float dotNV ) {
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
float
D_GGX
(
in
float
alpha
,
in
float
dotNH
)
{
float
D_GGX
(
const
in
float
alpha
,
const
in
float
dotNH
)
{
// factor of 1/PI in distribution term omitted as incoming light intensity is scaled up by PI because it is considered a punctual light source
...
...
@@ -93,7 +93,7 @@ vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in Geometric
// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile
vec3
BRDF_Specular_GGX_Environment
(
const
in
GeometricContext
geometry
,
vec3
specularColor
,
float
roughness
)
{
vec3
BRDF_Specular_GGX_Environment
(
const
in
GeometricContext
geometry
,
const
in
vec3
specularColor
,
const
in
float
roughness
)
{
float
dotNV
=
saturate
(
dot
(
geometry
.
normal
,
geometry
.
viewDir
)
);
...
...
@@ -112,7 +112,7 @@ vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, vec3 spe
}
// validated
float
G_BlinnPhong_Implicit
(
/*
in float dotNL,
in float dotNV */
)
{
float
G_BlinnPhong_Implicit
(
/*
const in float dotNL, const
in float dotNV */
)
{
// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
return
0
.
25
;
...
...
@@ -146,4 +146,9 @@ vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in Ge
return
F
*
(
G
*
D
);
}
// validated
\ No newline at end of file
}
// validated
// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html
float
GGXRoughnessToBlinnExponent
(
const
in
float
ggxRoughness
)
{
return
(
2
.
0
/
square
(
ggxRoughness
+
0
.
0001
)
-
2
.
0
);
}
\ No newline at end of file
src/renderers/shaders/ShaderChunk/common.glsl
浏览文件 @
79391057
...
...
@@ -8,6 +8,7 @@
#define saturate(a) clamp( a, 0.0, 1.0 )
#define whiteCompliment(a) ( 1.0 - saturate( a ) )
float
square
(
const
in
float
x
)
{
return
x
*
x
;
}
float
average
(
const
in
vec3
color
)
{
return
dot
(
color
,
vec3
(
0
.
3333
)
);
}
...
...
src/renderers/shaders/ShaderChunk/lights_pars.glsl
浏览文件 @
79391057
...
...
@@ -107,7 +107,21 @@ uniform vec3 ambientLightColor;
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
vec3
getSpecularLightProbeIndirectLightColor
(
/*const in SpecularLightProbe specularLightProbe,*/
const
in
GeometricContext
geometry
,
const
in
float
lodLevel
)
{
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
float
getSpecularMIPLevel
(
const
in
float
blinnShininessExponent
,
const
in
int
maxMIPLevel
)
{
//float envMapWidth = pow( 2.0, maxMIPLevelScalar );
//float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );
float
maxMIPLevelScalar
=
float
(
maxMIPLevel
);
float
desiredMIPLevel
=
maxMIPLevelScalar
-
0
.
79248
-
0
.
5
*
log2
(
square
(
blinnShininessExponent
)
+
1
.
0
);
// clamp to allowable LOD ranges.
return
clamp
(
desiredMIPLevel
,
0
.
0
,
maxMIPLevelScalar
);
}
vec3
getSpecularLightProbeIndirectLightColor
(
/*const in SpecularLightProbe specularLightProbe,*/
const
in
GeometricContext
geometry
,
const
in
float
blinnShininessExponent
,
const
in
int
maxMIPLevel
)
{
#ifdef ENVMAP_MODE_REFLECTION
...
...
@@ -133,15 +147,19 @@ uniform vec3 ambientLightColor;
#ifdef ENVMAP_TYPE_CUBE
vec3
queryReflectVec
=
flipNormal
*
vec3
(
flipEnvMap
*
reflectVec
.
x
,
reflectVec
.
yz
);
#if defined( TEXTURE_CUBE_LOD_EXT )
vec4
envMapColor
=
textureCubeLodEXT
(
envMap
,
flipNormal
*
vec3
(
flipEnvMap
*
reflectVec
.
x
,
reflectVec
.
yz
),
lodLevel
);
float
specularMIPLevel
=
getSpecularMIPLevel
(
blinnShininessExponent
,
maxMIPLevel
);
vec4
envMapColor
=
textureCubeLodEXT
(
envMap
,
queryReflectVec
,
specularMIPLevel
);
#else
vec4
envMapColor
=
textureCube
(
envMap
,
flipNormal
*
vec3
(
flipEnvMap
*
reflectVec
.
x
,
reflectVec
.
yz
)
);
vec4
envMapColor
=
textureCube
(
envMap
,
queryReflectVec
);
#endif
#elif defined( ENVMAP_TYPE_EQUIREC )
...
...
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
浏览文件 @
79391057
...
...
@@ -32,7 +32,6 @@ void PhysicalMaterial_RE_SpecularIndirectLight( const in vec3 indirectSpecularCo
}
// from bhouston - there are other models for this calculation (roughness; not roughnesFactor)
#define Material_LightProbeLOD( material ) (pow( ( material.specularRoughness - 0.5 ) * 2.0, 0.5 ) * 7.0)
#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )
#define Material_RE_IndirectSpecularLight PhysicalMaterial_RE_SpecularIndirectLight
src/renderers/shaders/ShaderChunk/lights_template.glsl
浏览文件 @
79391057
...
...
@@ -83,7 +83,8 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
{
vec3
indirectSpecularColor
=
getSpecularLightProbeIndirectLightColor
(
/*specularLightProbe,*/
geometry
,
Material_LightProbeLOD
(
material
)
);
// TODO, replace 8 with the real maxMIPLevel
vec3
indirectSpecularColor
=
getSpecularLightProbeIndirectLightColor
(
/*specularLightProbe,*/
geometry
,
Material_BlinnShininessExponent
(
material
),
8
);
Material_RE_IndirectSpecularLight
(
indirectSpecularColor
,
geometry
,
material
,
reflectedLight
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录