Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
839e964e
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,发现更多精彩内容 >>
提交
839e964e
编写于
9月 07, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7126 from tschw/SkinTangents
Skin shader: Removed uniform uPixelSize.
上级
bfac0c9c
e35a4ed6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
25 deletion
+10
-25
examples/js/ShaderSkin.js
examples/js/ShaderSkin.js
+9
-13
examples/webgl_materials_skin.html
examples/webgl_materials_skin.html
+1
-12
未找到文件。
examples/js/ShaderSkin.js
浏览文件 @
839e964e
...
@@ -357,9 +357,7 @@ THREE.ShaderSkin = {
...
@@ -357,9 +357,7 @@ THREE.ShaderSkin = {
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
uRoughness
"
:
{
type
:
"
f
"
,
value
:
0.15
},
"
uRoughness
"
:
{
type
:
"
f
"
,
value
:
0.15
},
"
uSpecularBrightness
"
:
{
type
:
"
f
"
,
value
:
0.75
},
"
uSpecularBrightness
"
:
{
type
:
"
f
"
,
value
:
0.75
}
"
uPixelSize
"
:
{
type
:
"
f
"
,
value
:
0.01
}
}
}
...
@@ -387,7 +385,6 @@ THREE.ShaderSkin = {
...
@@ -387,7 +385,6 @@ THREE.ShaderSkin = {
"
uniform sampler2D tBeckmann;
"
,
"
uniform sampler2D tBeckmann;
"
,
"
uniform float uNormalScale;
"
,
"
uniform float uNormalScale;
"
,
"
uniform float uPixelSize;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec2 vUv;
"
,
...
@@ -463,22 +460,21 @@ THREE.ShaderSkin = {
...
@@ -463,22 +460,21 @@ THREE.ShaderSkin = {
// normal mapping
// normal mapping
"
vec2 uz = vec2( vUv.x, vViewPosition.z );
"
,
"
vec4 posAndU = vec4( -vViewPosition, vUv.x );
"
,
"
vec2 uzDx = dFdx( uz ), uzDy = dFdy( uz );
"
,
"
vec4 posAndU_dx = dFdx( posAndU ), posAndU_dy = dFdy( posAndU );
"
,
"
vec2 tangent2D = normalize( vec2( uzDx.x, uzDy.x ) );
"
,
"
vec3 tangent = posAndU_dx.w * posAndU_dx.xyz + posAndU_dy.w * posAndU_dy.xyz;
"
,
"
vec2 zVec2D = vec2( uzDx.y, uzDy.y );
"
,
"
vec3 normal = normalize( vNormal );
"
,
"
vec3 tangent = vec3( tangent2D * uPixelSize, dot( tangent2D, zVec2D ) );
"
,
"
vec3 binormal = normalize( cross( tangent, normal ) );
"
,
"
vec3 binormal = normalize( cross( vNormal, tangent ) );
"
,
"
tangent = cross( normal, binormal );
"
,
// no normalization required
"
tangent = cross( binormal, vNormal );
"
,
"
mat3 tsb = mat3( tangent, binormal, normal );
"
,
"
mat3 tsb = mat3( tangent, binormal, vNormal );
"
,
"
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
"
,
"
vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;
"
,
"
normalTex.xy *= uNormalScale;
"
,
"
normalTex.xy *= uNormalScale;
"
,
"
normalTex = normalize( normalTex );
"
,
"
normalTex = normalize( normalTex );
"
,
"
vec3 finalNormal = tsb * normalTex;
"
,
"
vec3 finalNormal = tsb * normalTex;
"
,
"
normal = normalize( finalNormal );
"
,
"
vec3 normal = normalize( finalNormal );
"
,
"
vec3 viewerDirection = normalize( vViewPosition );
"
,
"
vec3 viewerDirection = normalize( vViewPosition );
"
,
// point lights
// point lights
...
...
examples/webgl_materials_skin.html
浏览文件 @
839e964e
...
@@ -87,8 +87,6 @@
...
@@ -87,8 +87,6 @@
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
pixelSizeUniform
=
{
type
:
'
f
'
,
value
:
0.001
};
var
firstPass
=
true
;
var
firstPass
=
true
;
init
();
init
();
...
@@ -142,9 +140,6 @@
...
@@ -142,9 +140,6 @@
uniforms
[
"
tNormal
"
].
value
=
uniformsUV
[
"
tNormal
"
].
value
;
uniforms
[
"
tNormal
"
].
value
=
uniformsUV
[
"
tNormal
"
].
value
;
uniforms
[
"
passID
"
].
value
=
1
;
uniforms
[
"
passID
"
].
value
=
1
;
// let those refer to the same object for central control
uniformsUV
[
"
pixelSize
"
]
=
pixelSizeUniform
;
uniforms
[
"
pixelSize
"
]
=
pixelSizeUniform
;
var
parameters
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShader
,
uniforms
:
uniforms
,
lights
:
true
,
derivatives
:
true
};
var
parameters
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShader
,
uniforms
:
uniforms
,
lights
:
true
,
derivatives
:
true
};
var
parametersUV
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShaderUV
,
uniforms
:
uniformsUV
,
lights
:
true
,
derivatives
:
true
};
var
parametersUV
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShaderUV
,
uniforms
:
uniformsUV
,
lights
:
true
,
derivatives
:
true
};
...
@@ -162,10 +157,9 @@
...
@@ -162,10 +157,9 @@
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
false
}
);
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
false
}
);
renderer
.
setClearColor
(
0x050505
);
renderer
.
setClearColor
(
0x050505
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
autoClear
=
false
;
renderer
.
autoClear
=
false
;
onWindowResize
();
// sets size
container
.
appendChild
(
renderer
.
domElement
);
container
.
appendChild
(
renderer
.
domElement
);
// STATS
// STATS
...
@@ -274,11 +268,6 @@
...
@@ -274,11 +268,6 @@
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
camera
.
updateProjectionMatrix
();
var
projection00
=
camera
.
projectionMatrix
.
elements
[
0
];
// == 1 / windowHalfX, in view space, assuming near == 1
pixelSizeUniform
.
value
=
1
/
(
projection00
*
windowHalfX
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录