Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
bc6ed16c
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,发现更多精彩内容 >>
提交
bc6ed16c
编写于
10月 19, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7381 from WestLangley/dev-standard
Inital PR for MeshStandardMaterial
上级
19c1fc27
e5443a18
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
373 addition
and
9 deletion
+373
-9
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+78
-2
src/renderers/shaders/ShaderChunk/common.glsl
src/renderers/shaders/ShaderChunk/common.glsl
+83
-0
src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl
src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl
+1
-1
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl
+1
-1
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl
+1
-1
src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl
src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl
+1
-1
src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl
src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl
+1
-1
src/renderers/shaders/ShaderChunk/uv_vertex.glsl
src/renderers/shaders/ShaderChunk/uv_vertex.glsl
+1
-1
src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl
src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl
+1
-1
src/renderers/shaders/ShaderLib.js
src/renderers/shaders/ShaderLib.js
+165
-0
src/renderers/shaders/UniformsLib.js
src/renderers/shaders/UniformsLib.js
+18
-0
src/renderers/webgl/WebGLProgram.js
src/renderers/webgl/WebGLProgram.js
+10
-0
src/renderers/webgl/WebGLPrograms.js
src/renderers/webgl/WebGLPrograms.js
+5
-0
utils/build/includes/common.json
utils/build/includes/common.json
+7
-0
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
bc6ed16c
...
...
@@ -637,7 +637,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl
.
bindBuffer
(
_gl
.
ARRAY_BUFFER
,
buffers
.
normal
);
if
(
material
.
type
!==
'
MeshPhongMaterial
'
&&
material
.
shading
===
THREE
.
FlatShading
)
{
if
(
material
.
type
!==
'
MeshPhongMaterial
'
&&
material
.
type
!==
'
MeshStandardMaterial
'
&&
material
.
shading
===
THREE
.
FlatShading
)
{
for
(
var
i
=
0
,
l
=
object
.
count
*
3
;
i
<
l
;
i
+=
9
)
{
...
...
@@ -1573,6 +1573,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
material
instanceof
THREE
.
ShaderMaterial
||
material
instanceof
THREE
.
MeshPhongMaterial
||
material
instanceof
THREE
.
MeshStandardMaterial
||
material
.
envMap
)
{
if
(
p_uniforms
.
cameraPosition
!==
undefined
)
{
...
...
@@ -1587,6 +1588,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
material
instanceof
THREE
.
MeshPhongMaterial
||
material
instanceof
THREE
.
MeshLambertMaterial
||
material
instanceof
THREE
.
MeshBasicMaterial
||
material
instanceof
THREE
.
MeshStandardMaterial
||
material
instanceof
THREE
.
ShaderMaterial
||
material
.
skinning
)
{
...
...
@@ -1665,6 +1667,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
material
instanceof
THREE
.
MeshPhongMaterial
||
material
instanceof
THREE
.
MeshLambertMaterial
||
material
instanceof
THREE
.
MeshStandardMaterial
||
material
.
lights
)
{
if
(
_lightsNeedUpdate
)
{
...
...
@@ -1690,7 +1693,8 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
material
instanceof
THREE
.
MeshBasicMaterial
||
material
instanceof
THREE
.
MeshLambertMaterial
||
material
instanceof
THREE
.
MeshPhongMaterial
)
{
material
instanceof
THREE
.
MeshPhongMaterial
||
material
instanceof
THREE
.
MeshStandardMaterial
)
{
refreshUniformsCommon
(
m_uniforms
,
material
);
...
...
@@ -1715,6 +1719,10 @@ THREE.WebGLRenderer = function ( parameters ) {
refreshUniformsPhong
(
m_uniforms
,
material
);
}
else
if
(
material
instanceof
THREE
.
MeshStandardMaterial
)
{
refreshUniformsStandard
(
m_uniforms
,
material
);
}
else
if
(
material
instanceof
THREE
.
MeshDepthMaterial
)
{
m_uniforms
.
mNear
.
value
=
camera
.
near
;
...
...
@@ -1932,6 +1940,74 @@ THREE.WebGLRenderer = function ( parameters ) {
}
function
refreshUniformsStandard
(
uniforms
,
material
)
{
uniforms
.
roughness
.
value
=
material
.
roughness
;
//uniforms.reflectivity.value = material.reflectivity; // part of uniforms common
uniforms
.
metalness
.
value
=
material
.
metalness
;
if
(
material
.
roughnessMap
)
{
uniforms
.
roughnessMap
.
value
=
material
.
roughnessMap
;
}
if
(
material
.
reflectivityMap
)
{
uniforms
.
reflectivityMap
.
value
=
material
.
reflectivityMap
;
}
if
(
material
.
metalnessMap
)
{
uniforms
.
metalnessMap
.
value
=
material
.
metalnessMap
;
}
if
(
material
.
lightMap
)
{
uniforms
.
lightMap
.
value
=
material
.
lightMap
;
uniforms
.
lightMapIntensity
.
value
=
material
.
lightMapIntensity
;
}
if
(
material
.
emissiveMap
)
{
uniforms
.
emissiveMap
.
value
=
material
.
emissiveMap
;
}
if
(
material
.
bumpMap
)
{
uniforms
.
bumpMap
.
value
=
material
.
bumpMap
;
uniforms
.
bumpScale
.
value
=
material
.
bumpScale
;
}
if
(
material
.
normalMap
)
{
uniforms
.
normalMap
.
value
=
material
.
normalMap
;
uniforms
.
normalScale
.
value
.
copy
(
material
.
normalScale
);
}
if
(
material
.
displacementMap
)
{
uniforms
.
displacementMap
.
value
=
material
.
displacementMap
;
uniforms
.
displacementScale
.
value
=
material
.
displacementScale
;
uniforms
.
displacementBias
.
value
=
material
.
displacementBias
;
}
if
(
material
.
envMap
)
{
//uniforms.envMap.value = material.envMap; // part of uniforms common
uniforms
.
envMapIntensity
.
value
=
material
.
envMapIntensity
;
}
}
function
refreshUniformsLights
(
uniforms
,
lights
)
{
uniforms
.
ambientLightColor
.
value
=
lights
.
ambient
;
...
...
src/renderers/shaders/ShaderChunk/common.glsl
浏览文件 @
bc6ed16c
...
...
@@ -99,6 +99,89 @@ vec3 BRDF_BlinnPhong( in vec3 specularColor, in float shininess, in vec3 normal,
}
// 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
)
{
// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)
float
a2
=
alpha
*
alpha
;
float
gl
=
dotNL
+
pow
(
a2
+
(
1
.
0
-
a2
)
*
dotNL
*
dotNL
,
0
.
5
);
float
gv
=
dotNV
+
pow
(
a2
+
(
1
.
0
-
a2
)
*
dotNV
*
dotNV
,
0
.
5
);
return
1
.
0
/
(
gl
*
gv
);
}
// 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
)
{
// factor of 1/PI in distribution term omitted
float
a2
=
alpha
*
alpha
;
float
denom
=
dotNH
*
dotNH
*
(
a2
-
1
.
0
)
+
1
.
0
;
// avoid alpha = 0 with dotNH = 1
return
a2
/
(
denom
*
denom
);
}
// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility
vec3
BRDF_GGX
(
in
vec3
specularColor
,
in
float
roughness
,
in
vec3
normal
,
in
vec3
lightDir
,
in
vec3
viewDir
)
{
// factor of 1/PI in BRDF omitted
float
alpha
=
roughness
*
roughness
;
// UE4's roughness
vec3
halfDir
=
normalize
(
lightDir
+
viewDir
);
float
dotNL
=
saturate
(
dot
(
normal
,
lightDir
)
);
float
dotNV
=
saturate
(
dot
(
normal
,
viewDir
)
);
float
dotNH
=
saturate
(
dot
(
normal
,
halfDir
)
);
float
dotLH
=
saturate
(
dot
(
lightDir
,
halfDir
)
);
vec3
F
=
F_Schlick
(
specularColor
,
dotLH
);
float
G
=
G_GGX_Smith
(
alpha
,
dotNL
,
dotNV
);
float
D
=
D_GGX
(
alpha
,
dotNH
);
return
F
*
G
*
D
;
}
vec3
BRDF_Lambert
(
in
vec3
diffuseColor
)
{
// factor of 1/PI in BRDF omitted
return
diffuseColor
;
}
// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile
vec3
envBRDFApprox
(
vec3
specularColor
,
float
roughness
,
in
vec3
normal
,
in
vec3
viewDir
)
{
float
dotNV
=
saturate
(
dot
(
normal
,
viewDir
)
);
const
vec4
c0
=
vec4
(
-
1
,
-
0
.
0275
,
-
0
.
572
,
0
.
022
);
const
vec4
c1
=
vec4
(
1
,
0
.
0425
,
1
.
04
,
-
0
.
04
);
vec4
r
=
roughness
*
c0
+
c1
;
float
a004
=
min
(
r
.
x
*
r
.
x
,
exp2
(
-
9
.
28
*
dotNV
)
)
*
r
.
x
+
r
.
y
;
vec2
AB
=
vec2
(
-
1
.
04
,
1
.
04
)
*
a004
+
r
.
zw
;
return
specularColor
*
AB
.
x
+
AB
.
y
;
}
vec3
inputToLinear
(
in
vec3
a
)
{
#ifdef GAMMA_INPUT
...
...
src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl
浏览文件 @
bc6ed16c
...
...
@@ -8,7 +8,7 @@
#endif
uniform
float
flipEnvMap
;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|| defined( STANDARD )
uniform
float
refractionRatio
;
...
...
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl
浏览文件 @
bc6ed16c
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
&& ! defined( STANDARD )
varying
vec3
vReflect
;
...
...
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl
浏览文件 @
bc6ed16c
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
&& ! defined( STANDARD )
vec3
cameraToVertex
=
normalize
(
worldPosition
.
xyz
-
cameraPosition
);
...
...
src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl
浏览文件 @
bc6ed16c
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
|| defined( USE_ROUGHNESSMAP ) || defined( USE_REFLECTIVITYMAP ) || defined( USE_METALNESSMAP )
varying
vec2
vUv
;
...
...
src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl
浏览文件 @
bc6ed16c
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
|| defined( USE_ROUGHNESSMAP ) || defined( USE_REFLECTIVITYMAP ) || defined( USE_METALNESSMAP )
varying
vec2
vUv
;
uniform
vec4
offsetRepeat
;
...
...
src/renderers/shaders/ShaderChunk/uv_vertex.glsl
浏览文件 @
bc6ed16c
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
|| defined( USE_ROUGHNESSMAP ) || defined( USE_REFLECTIVITYMAP ) || defined( USE_METALNESSMAP )
vUv
=
uv
*
offsetRepeat
.
zw
+
offsetRepeat
.
xy
;
...
...
src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl
浏览文件 @
bc6ed16c
#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )
#if defined( USE_ENVMAP ) || defined( PHONG ) || defined(
STANDARD ) || defined(
LAMBERT ) || defined ( USE_SHADOWMAP )
#ifdef USE_SKINNING
...
...
src/renderers/shaders/ShaderLib.js
浏览文件 @
bc6ed16c
...
...
@@ -409,6 +409,171 @@ THREE.ShaderLib = {
},
'
standard
'
:
{
uniforms
:
THREE
.
UniformsUtils
.
merge
(
[
THREE
.
UniformsLib
[
"
common
"
],
THREE
.
UniformsLib
[
"
aomap
"
],
THREE
.
UniformsLib
[
"
lightmap
"
],
THREE
.
UniformsLib
[
"
emissivemap
"
],
THREE
.
UniformsLib
[
"
bumpmap
"
],
THREE
.
UniformsLib
[
"
normalmap
"
],
THREE
.
UniformsLib
[
"
displacementmap
"
],
THREE
.
UniformsLib
[
"
roughnessmap
"
],
THREE
.
UniformsLib
[
"
reflectivitymap
"
],
THREE
.
UniformsLib
[
"
metalnessmap
"
],
THREE
.
UniformsLib
[
"
fog
"
],
THREE
.
UniformsLib
[
"
lights
"
],
THREE
.
UniformsLib
[
"
shadowmap
"
],
{
"
emissive
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0x000000
)
},
"
roughness
"
:
{
type
:
"
f
"
,
value
:
0.5
},
"
metalness
"
:
{
type
:
"
f
"
,
value
:
0
},
"
envMapIntensity
"
:
{
type
:
"
f
"
,
value
:
1
}
// temporary
}
]
),
vertexShader
:
[
"
#define STANDARD
"
,
"
varying vec3 vViewPosition;
"
,
"
#ifndef FLAT_SHADED
"
,
"
varying vec3 vNormal;
"
,
"
#endif
"
,
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
uv_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
uv2_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
displacementmap_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
envmap_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
lights_phong_pars_vertex
"
],
// use phong chunk for now
THREE
.
ShaderChunk
[
"
color_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
morphtarget_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
skinning_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
shadowmap_pars_vertex
"
],
THREE
.
ShaderChunk
[
"
specularmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
logdepthbuf_pars_vertex
"
],
"
void main() {
"
,
// STANDARD
THREE
.
ShaderChunk
[
"
uv_vertex
"
],
THREE
.
ShaderChunk
[
"
uv2_vertex
"
],
THREE
.
ShaderChunk
[
"
color_vertex
"
],
THREE
.
ShaderChunk
[
"
beginnormal_vertex
"
],
THREE
.
ShaderChunk
[
"
morphnormal_vertex
"
],
THREE
.
ShaderChunk
[
"
skinbase_vertex
"
],
THREE
.
ShaderChunk
[
"
skinnormal_vertex
"
],
THREE
.
ShaderChunk
[
"
defaultnormal_vertex
"
],
"
#ifndef FLAT_SHADED
"
,
// Normal computed with derivatives when FLAT_SHADED
"
vNormal = normalize( transformedNormal );
"
,
"
#endif
"
,
THREE
.
ShaderChunk
[
"
begin_vertex
"
],
THREE
.
ShaderChunk
[
"
displacementmap_vertex
"
],
THREE
.
ShaderChunk
[
"
morphtarget_vertex
"
],
THREE
.
ShaderChunk
[
"
skinning_vertex
"
],
THREE
.
ShaderChunk
[
"
project_vertex
"
],
THREE
.
ShaderChunk
[
"
logdepthbuf_vertex
"
],
"
vViewPosition = - mvPosition.xyz;
"
,
THREE
.
ShaderChunk
[
"
worldpos_vertex
"
],
THREE
.
ShaderChunk
[
"
envmap_vertex
"
],
THREE
.
ShaderChunk
[
"
lights_phong_vertex
"
],
// use phong chunk for now
THREE
.
ShaderChunk
[
"
shadowmap_vertex
"
],
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:
[
"
#define STANDARD
"
,
"
uniform vec3 diffuse;
"
,
"
uniform vec3 emissive;
"
,
"
uniform float roughness;
"
,
"
uniform float metalness;
"
,
"
uniform float opacity;
"
,
"
uniform float envMapIntensity;
"
,
// temporary
THREE
.
ShaderChunk
[
"
common
"
],
THREE
.
ShaderChunk
[
"
color_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
uv_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
uv2_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
map_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
alphamap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
aomap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
lightmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
emissivemap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
envmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
lights_phong_pars_fragment
"
],
// use phong chunk for now
THREE
.
ShaderChunk
[
"
shadowmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
bumpmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
normalmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
roughnessmap_pars_fragment
"
],
//THREE.ShaderChunk[ "reflectivitymap_pars_fragment" ],
THREE
.
ShaderChunk
[
"
metalnessmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
logdepthbuf_pars_fragment
"
],
"
void main() {
"
,
"
vec3 outgoingLight = vec3( 0.0 );
"
,
"
vec4 diffuseColor = vec4( diffuse, opacity );
"
,
"
vec3 totalAmbientLight = ambientLightColor;
"
,
"
vec3 totalEmissiveLight = emissive;
"
,
"
vec3 shadowMask = vec3( 1.0 );
"
,
THREE
.
ShaderChunk
[
"
logdepthbuf_fragment
"
],
THREE
.
ShaderChunk
[
"
map_fragment
"
],
THREE
.
ShaderChunk
[
"
color_fragment
"
],
THREE
.
ShaderChunk
[
"
alphamap_fragment
"
],
THREE
.
ShaderChunk
[
"
alphatest_fragment
"
],
THREE
.
ShaderChunk
[
"
specularmap_fragment
"
],
THREE
.
ShaderChunk
[
"
roughnessmap_fragment
"
],
//THREE.ShaderChunk[ "reflectivitymap_fragment" ],
THREE
.
ShaderChunk
[
"
metalnessmap_fragment
"
],
THREE
.
ShaderChunk
[
"
normal_phong_fragment
"
],
// use phong chunk for now
THREE
.
ShaderChunk
[
"
lightmap_fragment
"
],
THREE
.
ShaderChunk
[
"
hemilight_fragment
"
],
THREE
.
ShaderChunk
[
"
aomap_fragment
"
],
THREE
.
ShaderChunk
[
"
emissivemap_fragment
"
],
THREE
.
ShaderChunk
[
"
lights_standard_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_fragment
"
],
"
totalDiffuseLight *= shadowMask;
"
,
"
totalSpecularLight *= shadowMask;
"
,
"
outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) + totalSpecularLight + totalEmissiveLight;
"
,
THREE
.
ShaderChunk
[
"
envmap_standard_fragment
"
],
THREE
.
ShaderChunk
[
"
linear_to_gamma_fragment
"
],
THREE
.
ShaderChunk
[
"
fog_fragment
"
],
"
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
"
,
"
}
"
].
join
(
"
\n
"
)
},
'
points
'
:
{
uniforms
:
THREE
.
UniformsUtils
.
merge
(
[
...
...
src/renderers/shaders/UniformsLib.js
浏览文件 @
bc6ed16c
...
...
@@ -64,6 +64,24 @@ THREE.UniformsLib = {
},
roughnessmap
:
{
"
roughnessMap
"
:
{
type
:
"
t
"
,
value
:
null
}
},
reflectivitymap
:
{
"
reflectivityMap
"
:
{
type
:
"
t
"
,
value
:
null
}
},
metalnessmap
:
{
"
metalnessMap
"
:
{
type
:
"
t
"
,
value
:
null
}
},
fog
:
{
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
...
...
src/renderers/webgl/WebGLProgram.js
浏览文件 @
bc6ed16c
...
...
@@ -203,6 +203,9 @@ THREE.WebGLProgram = ( function () {
parameters
.
normalMap
?
'
#define USE_NORMALMAP
'
:
''
,
parameters
.
displacementMap
&&
parameters
.
supportsVertexTextures
?
'
#define USE_DISPLACEMENTMAP
'
:
''
,
parameters
.
specularMap
?
'
#define USE_SPECULARMAP
'
:
''
,
parameters
.
roughnessMap
?
'
#define USE_ROUGHNESSMAP
'
:
''
,
parameters
.
reflectivityMap
?
'
#define USE_REFLECTIVITYMAP
'
:
''
,
parameters
.
metalnessMap
?
'
#define USE_METALNESSMAP
'
:
''
,
parameters
.
alphaMap
?
'
#define USE_ALPHAMAP
'
:
''
,
parameters
.
vertexColors
?
'
#define USE_COLOR
'
:
''
,
...
...
@@ -285,6 +288,8 @@ THREE.WebGLProgram = ( function () {
parameters
.
bumpMap
||
parameters
.
normalMap
||
parameters
.
flatShading
||
material
.
derivatives
?
'
#extension GL_OES_standard_derivatives : enable
'
:
''
,
parameters
.
logarithmicDepthBuffer
&&
renderer
.
extensions
.
get
(
'
EXT_frag_depth
'
)
?
'
#extension GL_EXT_frag_depth : enable
'
:
''
,
parameters
.
envMap
&&
renderer
.
extensions
.
get
(
'
EXT_shader_texture_lod
'
)
?
'
#extension GL_EXT_shader_texture_lod : enable
'
:
''
,
'
precision
'
+
parameters
.
precision
+
'
float;
'
,
'
precision
'
+
parameters
.
precision
+
'
int;
'
,
...
...
@@ -319,6 +324,9 @@ THREE.WebGLProgram = ( function () {
parameters
.
bumpMap
?
'
#define USE_BUMPMAP
'
:
''
,
parameters
.
normalMap
?
'
#define USE_NORMALMAP
'
:
''
,
parameters
.
specularMap
?
'
#define USE_SPECULARMAP
'
:
''
,
parameters
.
roughnessMap
?
'
#define USE_ROUGHNESSMAP
'
:
''
,
parameters
.
reflectivityMap
?
'
#define USE_REFLECTIVITYMAP
'
:
''
,
parameters
.
metalnessMap
?
'
#define USE_METALNESSMAP
'
:
''
,
parameters
.
alphaMap
?
'
#define USE_ALPHAMAP
'
:
''
,
parameters
.
vertexColors
?
'
#define USE_COLOR
'
:
''
,
...
...
@@ -336,6 +344,8 @@ THREE.WebGLProgram = ( function () {
parameters
.
logarithmicDepthBuffer
?
'
#define USE_LOGDEPTHBUF
'
:
''
,
parameters
.
logarithmicDepthBuffer
&&
renderer
.
extensions
.
get
(
'
EXT_frag_depth
'
)
?
'
#define USE_LOGDEPTHBUF_EXT
'
:
''
,
parameters
.
envMap
&&
renderer
.
extensions
.
get
(
'
EXT_shader_texture_lod
'
)
?
'
#define TEXTURE_CUBE_LOD_EXT
'
:
''
,
'
uniform mat4 viewMatrix;
'
,
'
uniform vec3 cameraPosition;
'
,
...
...
src/renderers/webgl/WebGLPrograms.js
浏览文件 @
bc6ed16c
...
...
@@ -8,6 +8,7 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
MeshBasicMaterial
:
'
basic
'
,
MeshLambertMaterial
:
'
lambert
'
,
MeshPhongMaterial
:
'
phong
'
,
MeshStandardMaterial
:
'
standard
'
,
LineBasicMaterial
:
'
basic
'
,
LineDashedMaterial
:
'
dashed
'
,
PointsMaterial
:
'
points
'
...
...
@@ -16,6 +17,7 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
var
parameterNames
=
[
"
precision
"
,
"
supportsVertexTextures
"
,
"
map
"
,
"
envMap
"
,
"
envMapMode
"
,
"
lightMap
"
,
"
aoMap
"
,
"
emissiveMap
"
,
"
bumpMap
"
,
"
normalMap
"
,
"
displacementMap
"
,
"
specularMap
"
,
"
roughnessMap
"
,
"
reflectivityMap
"
,
"
metalnessMap
"
,
"
alphaMap
"
,
"
combine
"
,
"
vertexColors
"
,
"
fog
"
,
"
useFog
"
,
"
fogExp
"
,
"
flatShading
"
,
"
sizeAttenuation
"
,
"
logarithmicDepthBuffer
"
,
"
skinning
"
,
"
maxBones
"
,
"
useVertexTexture
"
,
"
morphTargets
"
,
"
morphNormals
"
,
...
...
@@ -152,6 +154,9 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
bumpMap
:
!!
material
.
bumpMap
,
normalMap
:
!!
material
.
normalMap
,
displacementMap
:
!!
material
.
displacementMap
,
roughnessMap
:
!!
material
.
roughnessMap
,
reflectivityMap
:
!!
material
.
reflectivityMap
,
metalnessMap
:
!!
material
.
metalnessMap
,
specularMap
:
!!
material
.
specularMap
,
alphaMap
:
!!
material
.
alphaMap
,
...
...
utils/build/includes/common.json
浏览文件 @
bc6ed16c
...
...
@@ -75,6 +75,7 @@
"src/materials/MeshBasicMaterial.js"
,
"src/materials/MeshLambertMaterial.js"
,
"src/materials/MeshPhongMaterial.js"
,
"src/materials/MeshStandardMaterial.js"
,
"src/materials/MeshDepthMaterial.js"
,
"src/materials/MeshNormalMaterial.js"
,
"src/materials/MultiMaterial.js"
,
...
...
@@ -124,6 +125,7 @@
"src/renderers/shaders/ShaderChunk/envmap_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/envmap_standard_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/envmap_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/fog_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl"
,
...
...
@@ -136,6 +138,7 @@
"src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/lights_phong_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/lights_standard_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl"
,
...
...
@@ -145,12 +148,16 @@
"src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/normal_phong_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/project_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录