Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
bf6d1f11
T
three.js
项目概览
fktz008
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
bf6d1f11
编写于
9月 24, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'tapio/shader-extras' into dev
上级
cdcca53e
47435c77
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
134 addition
and
7 deletion
+134
-7
examples/js/ShaderExtras.js
examples/js/ShaderExtras.js
+134
-7
未找到文件。
examples/js/ShaderExtras.js
浏览文件 @
bf6d1f11
...
...
@@ -5,15 +5,15 @@
*
* ShaderExtras currently contains:
*
*
screen
*
convolution
*
film
*
bokeh
*
screen
*
convolution
*
film
*
bokeh
* sepia
*
dotscreen
*
vignette
*
dotscreen
*
vignette
* bleachbypass
*
basic
*
basic
* dofmipmap
* focus
* triangleBlur
...
...
@@ -23,6 +23,8 @@
* fxaa
* luminosity
* colorCorrection
* brightnessContrast
* hueSaturation
* normalmap
* ssao
* colorify
...
...
@@ -1340,6 +1342,131 @@ THREE.ShaderExtras = {
},
/* -------------------------------------------------------------------------
// Brightness and contrast adjustment
// https://github.com/evanw/glfx.js
// brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
// contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
------------------------------------------------------------------------- */
'
brightnessContrast
'
:
{
uniforms
:
{
"
tDiffuse
"
:
{
type
:
"
t
"
,
value
:
null
},
"
brightness
"
:
{
type
:
"
f
"
,
value
:
0
},
"
contrast
"
:
{
type
:
"
f
"
,
value
:
0
}
},
vertexShader
:
[
"
varying vec2 vUv;
"
,
"
void main() {
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
"
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:
[
"
uniform sampler2D tDiffuse;
"
,
"
uniform float brightness;
"
,
"
uniform float contrast;
"
,
"
varying vec2 vUv;
"
,
"
void main() {
"
,
"
gl_FragColor = texture2D( tDiffuse, vUv );
"
,
"
gl_FragColor.rgb += brightness;
"
,
"
if (contrast > 0.0) {
"
,
"
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;
"
,
"
} else {
"
,
"
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;
"
,
"
}
"
,
"
}
"
].
join
(
"
\n
"
)
},
/* -------------------------------------------------------------------------
// Hue and saturation adjustment
// https://github.com/evanw/glfx.js
// hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc.
// saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
------------------------------------------------------------------------- */
'
hueSaturation
'
:
{
uniforms
:
{
"
tDiffuse
"
:
{
type
:
"
t
"
,
value
:
null
},
"
hue
"
:
{
type
:
"
f
"
,
value
:
0
},
"
saturation
"
:
{
type
:
"
f
"
,
value
:
0
}
},
vertexShader
:
[
"
varying vec2 vUv;
"
,
"
void main() {
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
"
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:
[
"
uniform sampler2D tDiffuse;
"
,
"
uniform float hue;
"
,
"
uniform float saturation;
"
,
"
varying vec2 vUv;
"
,
"
void main() {
"
,
"
gl_FragColor = texture2D( tDiffuse, vUv );
"
,
// hue
"
float angle = hue * 3.14159265;
"
,
"
float s = sin(angle), c = cos(angle);
"
,
"
vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
"
,
"
float len = length(gl_FragColor.rgb);
"
,
"
gl_FragColor.rgb = vec3(
"
,
"
dot(gl_FragColor.rgb, weights.xyz),
"
,
"
dot(gl_FragColor.rgb, weights.zxy),
"
,
"
dot(gl_FragColor.rgb, weights.yzx)
"
,
"
);
"
,
// saturation
"
float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;
"
,
"
if (saturation > 0.0) {
"
,
"
gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));
"
,
"
} else {
"
,
"
gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);
"
,
"
}
"
,
"
}
"
].
join
(
"
\n
"
)
},
/* -------------------------------------------------------------------------
// Normal map shader
// - compute normals from heightmap
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录