Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
dc9ddfae
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,发现更多精彩内容 >>
提交
dc9ddfae
编写于
4月 10, 2016
作者:
W
WestLangley
提交者:
Mr.doob
4月 10, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MeshDepthMaterial: Added displacement map support (#8586)
上级
e5c2fbe8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
86 addition
and
13 deletion
+86
-13
examples/webgl_materials_channels.html
examples/webgl_materials_channels.html
+52
-8
src/materials/MeshDepthMaterial.js
src/materials/MeshDepthMaterial.js
+12
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+8
-0
src/renderers/shaders/ShaderLib.js
src/renderers/shaders/ShaderLib.js
+9
-5
src/renderers/shaders/ShaderLib/depth_vert.glsl
src/renderers/shaders/ShaderLib/depth_vert.glsl
+5
-0
未找到文件。
examples/webgl_materials_channels.html
浏览文件 @
dc9ddfae
...
...
@@ -78,6 +78,9 @@
var
height
=
500
;
// of camera frustum
var
SCALE
=
2.436143
;
// from original model
var
BIAS
=
-
0.428408
;
// from original model
init
();
animate
();
initGui
();
...
...
@@ -159,45 +162,86 @@
materialStandard
=
new
THREE
.
MeshStandardMaterial
(
{
color
:
0xffffff
,
metalness
:
0.5
,
roughness
:
0.6
,
displacementMap
:
displacementMap
,
displacementScale
:
2.436143
,
// from original model
displacementBias
:
-
0.428408
,
// from original model
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
aoMap
:
aoMap
,
normalMap
:
normalMap
,
normalScale
:
new
THREE
.
Vector2
(
1
,
-
1
),
side
:
THREE
.
DoubleSide
}
);
materialDepthAuto
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
AutoDepthFormat
,
depthPacking
:
THREE
.
LinearDepthPacking
depthPacking
:
THREE
.
LinearDepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialDepthAutoRGBA
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
AutoDepthFormat
,
depthPacking
:
THREE
.
RGBADepthPacking
depthPacking
:
THREE
.
RGBADepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialDepthLinearClipZ
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
LinearClipZDepthFormat
,
depthPacking
:
THREE
.
LinearDepthPacking
depthPacking
:
THREE
.
LinearDepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialDepthLinearClipZRGBA
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
LinearClipZDepthFormat
,
depthPacking
:
THREE
.
RGBADepthPacking
depthPacking
:
THREE
.
RGBADepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialDepthInvClipZ
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
InvClipZDepthFormat
,
depthPacking
:
THREE
.
LinearDepthPacking
depthPacking
:
THREE
.
LinearDepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialDepthInvClipZRGBA
=
new
THREE
.
MeshDepthMaterial
(
{
depthFormat
:
THREE
.
InvClipZDepthFormat
,
depthPacking
:
THREE
.
RGBADepthPacking
depthPacking
:
THREE
.
RGBADepthPacking
,
displacementMap
:
displacementMap
,
displacementScale
:
SCALE
,
displacementBias
:
BIAS
,
side
:
THREE
.
DoubleSide
}
);
materialNormal
=
new
THREE
.
MeshNormalMaterial
();
...
...
src/materials/MeshDepthMaterial.js
浏览文件 @
dc9ddfae
...
...
@@ -6,6 +6,10 @@
* parameters = {
* opacity: <float>,
*
* displacementMap: new THREE.Texture( <Image> ),
* displacementScale: <float>,
* displacementBias: <float>,
*
* wireframe: <boolean>,
* wireframeLinewidth: <float>
* }
...
...
@@ -23,6 +27,10 @@ THREE.MeshDepthMaterial = function ( parameters ) {
this
.
skinning
=
false
;
this
.
morphTargets
=
false
;
this
.
displacementMap
=
null
;
this
.
displacementScale
=
1
;
this
.
displacementBias
=
0
;
this
.
wireframe
=
false
;
this
.
wireframeLinewidth
=
1
;
...
...
@@ -43,6 +51,10 @@ THREE.MeshDepthMaterial.prototype.copy = function ( source ) {
this
.
skinning
=
source
.
skinning
;
this
.
morphTargets
=
source
.
morphTargets
;
this
.
displacementMap
=
source
.
displacementMap
;
this
.
displacementScale
=
source
.
displacementScale
;
this
.
displacementBias
=
source
.
displacementBias
;
this
.
wireframe
=
source
.
wireframe
;
this
.
wireframeLinewidth
=
source
.
wireframeLinewidth
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
dc9ddfae
...
...
@@ -1998,6 +1998,14 @@ THREE.WebGLRenderer = function ( parameters ) {
m_uniforms
.
mFar
.
value
=
camera
.
far
;
m_uniforms
.
opacity
.
value
=
material
.
opacity
;
if
(
material
.
displacementMap
)
{
m_uniforms
.
displacementMap
.
value
=
material
.
displacementMap
;
m_uniforms
.
displacementScale
.
value
=
material
.
displacementScale
;
m_uniforms
.
displacementBias
.
value
=
material
.
displacementBias
;
}
}
else
if
(
material
instanceof
THREE
.
MeshNormalMaterial
)
{
m_uniforms
.
opacity
.
value
=
material
.
opacity
;
...
...
src/renderers/shaders/ShaderLib.js
浏览文件 @
dc9ddfae
...
...
@@ -169,13 +169,17 @@ THREE.ShaderLib = {
'
depth
'
:
{
uniforms
:
{
uniforms
:
THREE
.
UniformsUtils
.
merge
(
[
"
mNear
"
:
{
type
:
"
1f
"
,
value
:
1.0
},
"
mFar
"
:
{
type
:
"
1f
"
,
value
:
2000.0
},
"
opacity
"
:
{
type
:
"
1f
"
,
value
:
1.0
}
THREE
.
UniformsLib
[
'
displacementmap
'
],
},
{
"
mNear
"
:
{
type
:
"
1f
"
,
value
:
1.0
},
"
mFar
"
:
{
type
:
"
1f
"
,
value
:
2000.0
},
"
opacity
"
:
{
type
:
"
1f
"
,
value
:
1.0
}
}
]
),
vertexShader
:
THREE
.
ShaderChunk
[
'
depth_vert
'
],
fragmentShader
:
THREE
.
ShaderChunk
[
'
depth_frag
'
]
...
...
src/renderers/shaders/ShaderLib/depth_vert.glsl
浏览文件 @
dc9ddfae
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
...
...
@@ -12,9 +14,12 @@
void
main
()
{
#include <uv_vertex>
#include <skinbase_vertex>
#include <begin_vertex>
#include <displacementmap_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录