Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
e6f08bda
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,发现更多精彩内容 >>
提交
e6f08bda
编写于
8月 28, 2017
作者:
T
Tentone
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed code and added some documentation.
上级
468d0f1f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
69 addition
and
16 deletion
+69
-16
examples/js/postprocessing/SSAOPass.js
examples/js/postprocessing/SSAOPass.js
+64
-11
examples/webgl_postprocessing_ssao.html
examples/webgl_postprocessing_ssao.html
+5
-5
未找到文件。
examples/js/postprocessing/SSAOPass.js
浏览文件 @
e6f08bda
'
use strict
'
;
/*
/*
*
* Screen-space ambient occlusion pass.
*
* Has the following parameters
* - radius
* - Ambient occlusion shadow radius (numeric value).
* - onlyAO
* - Display only ambient occlusion result (boolean value).
* - aoClamp
* - Ambient occlusion clamp (numeric value).
* - lumInfluence
* - Pixel luminosity influence in AO calculation (numeric value).
*
* To output to screen set renderToScreens true
*
* @author alteredq / http://alteredqualia.com/
* @author tentone
* @class SSAOPass
*/
THREE
.
SSAOPass
=
function
(
scene
,
camera
,
width
,
height
)
{
if
(
THREE
.
SSAOShader
===
undefined
)
{
console
.
warn
(
'
THREE.SSAOPass depends on THREE.SSAOShader
'
);
if
(
THREE
.
SSAOShader
===
undefined
)
{
console
.
warn
(
'
THREE.SSAOPass depends on THREE.SSAOShader
'
);
return
new
THREE
.
ShaderPass
();
}
THREE
.
ShaderPass
.
call
(
this
,
THREE
.
SSAOShader
);
this
.
width
=
(
width
!==
undefined
)
?
width
:
512
;
this
.
height
=
(
height
!==
undefined
)
?
height
:
512
;
this
.
height
=
(
height
!==
undefined
)
?
height
:
256
;
this
.
renderToScreen
=
false
;
...
...
@@ -39,7 +45,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
//Depth render target
this
.
depthRenderTarget
=
new
THREE
.
WebGLRenderTarget
(
this
.
width
,
this
.
height
,
{
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
}
);
this
.
depthRenderTarget
.
texture
.
name
=
'
SSAOShader.rt
'
;
//
this.depthRenderTarget.texture.name = 'SSAOShader.rt';
//Shader uniforms
this
.
uniforms
[
'
tDepth
'
].
value
=
this
.
depthRenderTarget
.
texture
;
...
...
@@ -58,22 +64,22 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
radius
:
{
get
:
function
()
{
return
this
.
uniforms
[
'
radius
'
].
value
;
},
set
:
function
(
value
)
{
this
.
uniforms
[
'
radius
'
].
value
=
value
;
}
set
:
function
(
value
)
{
this
.
uniforms
[
'
radius
'
].
value
=
value
;
}
},
onlyAO
:
{
get
:
function
()
{
return
this
.
uniforms
[
'
onlyAO
'
].
value
;
},
set
:
function
(
value
)
{
this
.
uniforms
[
'
onlyAO
'
].
value
=
value
;
}
set
:
function
(
value
)
{
this
.
uniforms
[
'
onlyAO
'
].
value
=
value
;
}
},
aoClamp
:
{
get
:
function
()
{
return
this
.
uniforms
[
'
aoClamp
'
].
value
;
},
set
:
function
(
value
)
{
this
.
uniforms
[
'
aoClamp
'
].
value
=
value
;
}
set
:
function
(
value
)
{
this
.
uniforms
[
'
aoClamp
'
].
value
=
value
;
}
},
lumInfluence
:
{
get
:
function
()
{
return
this
.
uniforms
[
'
lumInfluence
'
].
value
;
},
set
:
function
(
value
)
{
this
.
uniforms
[
'
lumInfluence
'
].
value
=
value
;
}
set
:
function
(
value
)
{
this
.
uniforms
[
'
lumInfluence
'
].
value
=
value
;
}
},
});
...
...
@@ -81,18 +87,65 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
THREE
.
SSAOPass
.
prototype
=
Object
.
create
(
THREE
.
ShaderPass
.
prototype
);
/**
* Render using this pass.
*
* @method render
* @param {WebGLRenderer} renderer
* @param {WebGLRenderTarget} writeBuffer Buffer to write output.
* @param {WebGLRenderTarget} readBuffer Input buffer.
* @param {Number} delta Delta time in milliseconds.
* @param {Boolean} maskActive Not used in this pass.
*/
THREE
.
SSAOPass
.
prototype
.
render
=
function
(
renderer
,
writeBuffer
,
readBuffer
,
delta
,
maskActive
)
{
//Render depth into depthRenderTarget
this
.
scene2
.
overrideMaterial
=
this
.
depthMaterial
;
renderer
.
render
(
this
.
scene2
,
this
.
camera2
,
this
.
depthRenderTarget
,
true
);
//Render renderPass and SSAO shaderPass
this
.
scene2
.
overrideMaterial
=
null
;
//SSAO shaderPass
THREE
.
ShaderPass
.
prototype
.
render
.
call
(
this
,
renderer
,
writeBuffer
,
readBuffer
,
delta
,
maskActive
);
};
/**
* Change scene to be renderer by this render pass.
*
* @method setScene
* @param {Scene} scene
*/
THREE
.
SSAOPass
.
prototype
.
setScene
=
function
(
scene
)
{
this
.
scene2
=
scene
;
};
/**
* Set camera used by this render pass.
*
* @method setCamera
* @param {Camera} camera
*/
THREE
.
SSAOPass
.
prototype
.
setCamera
=
function
(
camera
)
{
this
.
camera2
=
camera
;
this
.
uniforms
[
'
cameraNear
'
].
value
=
this
.
camera2
.
near
;
this
.
uniforms
[
'
cameraFar
'
].
value
=
this
.
camera2
.
far
;
};
/**
* Set resolution of this render pass.
*
* @method setSize
* @param {Number} width
* @param {Number} height
*/
THREE
.
SSAOPass
.
prototype
.
setSize
=
function
(
width
,
height
)
{
this
.
width
=
width
;
...
...
examples/webgl_postprocessing_ssao.html
浏览文件 @
e6f08bda
...
...
@@ -121,15 +121,15 @@ Spiral sampling http://web.archive.org/web/20120421191837/http://www.cgafaq.info
// Init gui
var
gui
=
new
dat
.
GUI
();
gui
.
add
(
postprocessing
,
"
enabled
"
);
gui
.
add
(
postprocessing
,
'
enabled
'
);
gui
.
add
(
postprocessing
,
"
onlyAO
"
,
false
).
onChange
(
function
(
value
)
{
ssaoPass
.
onlyAO
=
value
;
}
);
gui
.
add
(
postprocessing
,
'
onlyAO
'
,
false
).
onChange
(
function
(
value
)
{
ssaoPass
.
onlyAO
=
value
;
}
);
gui
.
add
(
postprocessing
,
"
radius
"
).
min
(
0
).
max
(
64
).
onChange
(
function
(
value
)
{
ssaoPass
.
radius
=
value
;
}
);
gui
.
add
(
postprocessing
,
'
radius
'
).
min
(
0
).
max
(
64
).
onChange
(
function
(
value
)
{
ssaoPass
.
radius
=
value
;
}
);
gui
.
add
(
postprocessing
,
"
aoClamp
"
).
min
(
0
).
max
(
1
).
onChange
(
function
(
value
)
{
ssaoPass
.
aoClamp
=
value
;
}
);
gui
.
add
(
postprocessing
,
'
aoClamp
'
).
min
(
0
).
max
(
1
).
onChange
(
function
(
value
)
{
ssaoPass
.
aoClamp
=
value
;
}
);
gui
.
add
(
postprocessing
,
"
lumInfluence
"
).
min
(
0
).
max
(
1
).
onChange
(
function
(
value
)
{
ssaoPass
.
lumInfluence
=
value
;
}
);
gui
.
add
(
postprocessing
,
'
lumInfluence
'
).
min
(
0
).
max
(
1
).
onChange
(
function
(
value
)
{
ssaoPass
.
lumInfluence
=
value
;
}
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录