Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d1135bc4
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,发现更多精彩内容 >>
提交
d1135bc4
编写于
12月 18, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLDeferredRenderer: swapped order of color and normalDepth passes.
This is because we'll be needing normals in the color pass.
上级
53e71d21
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
40 deletion
+31
-40
examples/js/renderers/WebGLDeferredRenderer.js
examples/js/renderers/WebGLDeferredRenderer.js
+31
-40
未找到文件。
examples/js/renderers/WebGLDeferredRenderer.js
浏览文件 @
d1135bc4
...
...
@@ -80,9 +80,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
}
);
var
defaultNormalDepthMaterialWireframe
=
defaultNormalDepthMaterial
.
clone
();
defaultNormalDepthMaterialWireframe
.
wireframe
=
true
;
//
var
initDeferredMaterials
=
function
(
object
)
{
...
...
@@ -250,18 +247,9 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
}
);
if
(
originalMaterial
.
morphTargets
)
{
normalDepthMaterial
.
morphTargets
=
originalMaterial
.
morphTargets
;
normalDepthMaterial
.
morphNormals
=
originalMaterial
.
morphNormals
;
}
if
(
originalMaterial
.
skinning
)
{
normalDepthMaterial
.
skinning
=
originalMaterial
.
skinning
;
}
normalDepthMaterial
.
morphTargets
=
originalMaterial
.
morphTargets
;
normalDepthMaterial
.
morphNormals
=
originalMaterial
.
morphNormals
;
normalDepthMaterial
.
skinning
=
originalMaterial
.
skinning
;
if
(
originalMaterial
.
bumpMap
)
{
...
...
@@ -275,16 +263,19 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
}
normalDepthMaterial
.
wireframe
=
originalMaterial
.
wireframe
;
deferredMaterials
.
normalDepthMaterial
=
normalDepthMaterial
;
}
else
{
deferredMaterials
.
normalDepthMaterial
=
originalMaterial
.
wireframe
?
defaultNormalDepthMaterialWireframe
:
defaultNormalDepthMaterial
;
var
normalDepthMaterial
=
defaultNormalDepthMaterial
.
clone
()
;
}
normalDepthMaterial
.
wireframe
=
originalMaterial
.
wireframe
;
normalDepthMaterial
.
vertexColors
=
originalMaterial
.
vertexColors
;
deferredMaterials
.
normalDepthMaterial
=
normalDepthMaterial
;
//
deferredMaterials
.
transparent
=
originalMaterial
.
transparent
;
return
deferredMaterials
;
...
...
@@ -548,13 +539,13 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
scaledWidth
=
Math
.
floor
(
scale
*
width
);
scaledHeight
=
Math
.
floor
(
scale
*
height
);
compColor
.
setSize
(
scaledWidth
,
scaledHeight
);
compNormalDepth
.
setSize
(
scaledWidth
,
scaledHeight
);
compColor
.
setSize
(
scaledWidth
,
scaledHeight
);
compLight
.
setSize
(
scaledWidth
,
scaledHeight
);
compFinal
.
setSize
(
scaledWidth
,
scaledHeight
);
comp
NormalDepth
.
renderTarget2
.
shareDepthFrom
=
compColor
.
renderTarget2
;
compLight
.
renderTarget2
.
shareDepthFrom
=
comp
Color
.
renderTarget2
;
comp
Color
.
renderTarget2
.
shareDepthFrom
=
compNormalDepth
.
renderTarget2
;
compLight
.
renderTarget2
.
shareDepthFrom
=
comp
NormalDepth
.
renderTarget2
;
for
(
var
i
=
0
,
il
=
lightMaterials
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -653,9 +644,9 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
this
.
renderer
.
autoUpdateScene
=
false
;
scene
.
updateMatrixWorld
();
// 1) g-buffer
color
pass
// 1) g-buffer
normals + depth
pass
scene
.
traverse
(
setMaterial
Color
);
scene
.
traverse
(
setMaterial
NormalDepth
);
// clear shared depth buffer
...
...
@@ -670,17 +661,17 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
gl
.
stencilFunc
(
gl
.
ALWAYS
,
1
,
0xffffffff
);
gl
.
clearStencil
(
0
);
comp
Color
.
render
();
comp
NormalDepth
.
render
();
// just touch foreground pixels (stencil == 1)
// both in
normalDepth
and light passes
// both in
color
and light passes
gl
.
stencilFunc
(
gl
.
EQUAL
,
1
,
0xffffffff
);
gl
.
stencilOp
(
gl
.
KEEP
,
gl
.
KEEP
,
gl
.
KEEP
);
// 2) g-buffer
normals + depth
pass
// 2) g-buffer
color
pass
scene
.
traverse
(
setMaterial
NormalDepth
);
scene
.
traverse
(
setMaterial
Color
);
// must use clean slate depth buffer
// otherwise there are z-fighting glitches
...
...
@@ -690,7 +681,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
this
.
renderer
.
autoClearDepth
=
true
;
this
.
renderer
.
autoClearStencil
=
false
;
comp
NormalDepth
.
render
();
comp
Color
.
render
();
// 3) light pass
...
...
@@ -759,14 +750,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
rtLight
.
generateMipmaps
=
false
;
rtFinal
.
generateMipmaps
=
false
;
// color composer
passColor
=
new
THREE
.
RenderPass
();
passColor
.
clear
=
true
;
compColor
=
new
THREE
.
EffectComposer
(
_this
.
renderer
,
rtColor
);
compColor
.
addPass
(
passColor
);
// normal + depth composer
passNormalDepth
=
new
THREE
.
RenderPass
();
...
...
@@ -775,7 +758,15 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
compNormalDepth
=
new
THREE
.
EffectComposer
(
_this
.
renderer
,
rtNormalDepth
);
compNormalDepth
.
addPass
(
passNormalDepth
);
compNormalDepth
.
renderTarget2
.
shareDepthFrom
=
compColor
.
renderTarget2
;
// color composer
passColor
=
new
THREE
.
RenderPass
();
passColor
.
clear
=
true
;
compColor
=
new
THREE
.
EffectComposer
(
_this
.
renderer
,
rtColor
);
compColor
.
addPass
(
passColor
);
compColor
.
renderTarget2
.
shareDepthFrom
=
compNormalDepth
.
renderTarget2
;
// light composer
...
...
@@ -789,7 +780,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
compLight
.
addPass
(
passLightFullscreen
);
compLight
.
addPass
(
passLightProxy
);
compLight
.
renderTarget2
.
shareDepthFrom
=
comp
Color
.
renderTarget2
;
compLight
.
renderTarget2
.
shareDepthFrom
=
comp
NormalDepth
.
renderTarget2
;
// final composer
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录