Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
59911107
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,发现更多精彩内容 >>
提交
59911107
编写于
7月 24, 2019
作者:
O
Olli Etuaho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use onBeforeCompile to customize instanced depth material
上级
2b528282
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
54 deletion
+48
-54
examples/webgl_buffergeometry_instancing_lambert.html
examples/webgl_buffergeometry_instancing_lambert.html
+48
-54
未找到文件。
examples/webgl_buffergeometry_instancing_lambert.html
浏览文件 @
59911107
...
...
@@ -34,65 +34,58 @@
import
{
OrbitControls
}
from
'
./jsm/controls/OrbitControls.js
'
;
import
{
Curves
}
from
'
./jsm/curves/CurveExtras.js
'
;
var
customDepthToRGBAShader
=
{
// this is a cut-and-paste of the depth shader -- modified to accommodate instancing for this app
uniforms
:
THREE
.
ShaderLib
.
depth
.
uniforms
,
vertexShader
:
`
// instanced
#ifdef INSTANCED
attribute vec3 instanceOffset;
attribute float instanceScale;
#endif
// this is a cut-and-paste of the depth shader -- modified to accommodate instancing for this app
var
customDepthVertexShader
=
`
// instanced
#ifdef INSTANCED
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
attribute vec3 instanceOffset;
attribute float instanceScale;
void main() {
#endif
#include <uv_vertex>
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#include <skinbase_vertex>
void main() {
#ifdef USE_DISPLACEMENTMAP
#include <uv_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#include <skinbase_vertex>
#endif
#ifdef USE_DISPLACEMENTMAP
#include <begin_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
// instanced
#ifdef INSTANCED
#endif
transformed *= instanceScale;
transformed = transformed + instanceOffset;
#include <begin_vertex>
#endif
// instanced
#ifdef INSTANCED
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
transformed *= instanceScale;
transformed = transformed + instanceOffset;
}
`
,
#endif
fragmentShader
:
THREE
.
ShaderChunk
.
depth_frag
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
};
}
`
;
// this is a cut-and-paste of the lambert shader -- modified to accommodate instancing for this app
var
customLambertVertexShader
=
...
...
@@ -286,27 +279,28 @@
}
);
material
.
onBeforeCompile
=
function
(
shader
)
{
shader
.
vertexShader
=
customLambertVertexShader
;
};
material
.
defines
=
material
.
defines
||
{};
material
.
defines
[
'
INSTANCED
'
]
=
""
;
// custom depth material - required for instanced shadows
var
uniforms
=
THREE
.
UniformsUtils
.
clone
(
customDepthToRGBAShader
.
uniforms
);
var
customDepthMaterial
=
new
THREE
.
MeshDepthMaterial
(
);
var
customDepthMaterial
=
new
THREE
.
ShaderMaterial
(
{
customDepthMaterial
.
onBeforeCompile
=
function
(
shader
)
{
defines
:
{
'
INSTANCED
'
:
""
,
'
DEPTH_PACKING
'
:
THREE
.
RGBADepthPacking
},
uniforms
:
uniforms
,
vertexShader
:
customDepthToRGBAShader
.
vertexShader
,
fragmentShader
:
customDepthToRGBAShader
.
fragmentShader
shader
.
vertexShader
=
customDepthVertexShader
;
}
);
};
customDepthMaterial
.
depthPacking
=
THREE
.
RGBADepthPacking
;
customDepthMaterial
.
defines
=
material
.
defines
||
{};
customDepthMaterial
.
defines
[
'
INSTANCED
'
]
=
""
;
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录