Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
0f77e12b
A
AR.js
项目概览
cqiang1993
/
AR.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AR.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f77e12b
编写于
3月 18, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix shader again
上级
9af95411
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
43 deletion
+43
-43
three.js/examples/businesscard.html
three.js/examples/businesscard.html
+1
-1
three.js/threex-armarkercloak.js
three.js/threex-armarkercloak.js
+42
-42
未找到文件。
three.js/examples/businesscard.html
浏览文件 @
0f77e12b
...
...
@@ -292,7 +292,7 @@
ringHighMesh
.
rotation
.
z
=
Math
.
random
()
*
2
*
Math
.
PI
onRenderFcts
.
push
(
function
(
delta
){
ringHighMesh
.
rotation
.
z
+
=
2
*
Math
.
PI
*
delta
/
5
ringHighMesh
.
rotation
.
z
-
=
2
*
Math
.
PI
*
delta
/
5
})
//////////////////////////////////////////////////////////////////////////////////
...
...
three.js/threex-armarkercloak.js
浏览文件 @
0f77e12b
...
...
@@ -167,51 +167,51 @@ THREEx.ArMarkerCloak = function(videoTexture){
// Shaders
//////////////////////////////////////////////////////////////////////////////
THREEx
.
ArMarkerCloak
.
markerSpaceShaderFunction
=
'
'
+
'
vec2 transformUvToMarkerSpace(vec2 originalUv){
'
+
'
vec3 transformedUv;
'
+
'
// set transformedUv - from UV coord to clip coord
'
+
'
transformedUv.x = originalUv.x * 2.0 - 1.0;
'
+
'
transformedUv.y = originalUv.y * 2.0 - 1.0;
'
+
'
transformedUv.z = 0.0;
'
+
''
+
'
// apply modelViewMatrix and projectionMatrix
'
+
'
transformedUv = (projectionMatrix * modelViewMatrix * vec4( transformedUv, 1.0 ) ).xyz;
'
+
''
+
'
// apply perspective
'
+
'
transformedUv.x /= transformedUv.z;
'
+
'
transformedUv.y /= transformedUv.z;
'
+
''
+
'
// set back from clip coord to Uv coord
'
+
'
transformedUv.x = transformedUv.x / 2.0 + 0.5;
'
+
'
transformedUv.y = transformedUv.y / 2.0 + 0.5;
'
+
''
+
'
// return the result
'
+
'
return transformedUv.xy;
'
+
THREEx
.
ArMarkerCloak
.
markerSpaceShaderFunction
=
'
\n
'
+
'
vec2 transformUvToMarkerSpace(vec2 originalUv){
\n
'
+
'
vec3 transformedUv;
\n
'
+
'
// set transformedUv - from UV coord to clip coord
\n
'
+
'
transformedUv.x = originalUv.x * 2.0 - 1.0;
\n
'
+
'
transformedUv.y = originalUv.y * 2.0 - 1.0;
\n
'
+
'
transformedUv.z = 0.0;
\n
'
+
'
\n
'
+
'
// apply modelViewMatrix and projectionMatrix
\n
'
+
'
transformedUv = (projectionMatrix * modelViewMatrix * vec4( transformedUv, 1.0 ) ).xyz;
\n
'
+
'
\n
'
+
'
// apply perspective
\n
'
+
'
transformedUv.x /= transformedUv.z;
\n
'
+
'
transformedUv.y /= transformedUv.z;
\n
'
+
'
\n
'
+
'
// set back from clip coord to Uv coord
\n
'
+
'
transformedUv.x = transformedUv.x / 2.0 + 0.5;
\n
'
+
'
transformedUv.y = transformedUv.y / 2.0 + 0.5;
\n
'
+
'
\n
'
+
'
// return the result
\n
'
+
'
return transformedUv.xy;
\n
'
+
'
}
'
THREEx
.
ArMarkerCloak
.
vertexShader
=
THREEx
.
ArMarkerCloak
.
markerSpaceShaderFunction
+
'
varying vec2 vUv;
'
+
''
+
'
void main(){
'
+
'
// pass the UV to the fragment
'
+
'
#if (updateInShaderEnabled == 1)
'
+
'
vUv = transformUvToMarkerSpace(uv);
'
+
'
#else
'
+
'
vUv = uv;
'
+
'
#endif
'
+
''
+
'
// compute gl_Position
'
+
'
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
'
+
'
gl_Position = projectionMatrix * mvPosition;
'
+
'
varying vec2 vUv;
\n
'
+
'
\n
'
+
'
void main(){
\n
'
+
'
// pass the UV to the fragment
\n
'
+
'
#if (updateInShaderEnabled == 1)
\n
'
+
'
vUv = transformUvToMarkerSpace(uv);
\n
'
+
'
#else
\n
'
+
'
vUv = uv;
\n
'
+
'
#endif
\n
'
+
'
\n
'
+
'
// compute gl_Position
\n
'
+
'
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
'
+
'
gl_Position = projectionMatrix * mvPosition;
\n
'
+
'
}
'
;
THREEx
.
ArMarkerCloak
.
fragmentShader
=
''
+
'
varying vec2 vUv;
'
+
'
uniform sampler2D texture;
'
+
''
+
'
void main(void){
'
+
'
vec3 color = texture2D( texture, vUv ).rgb;
'
+
''
+
'
gl_FragColor = vec4( color, 1.0);
'
+
THREEx
.
ArMarkerCloak
.
fragmentShader
=
'
\n
'
+
'
varying vec2 vUv;
\n
'
+
'
uniform sampler2D texture;
\n
'
+
'
\n
'
+
'
void main(void){
\n
'
+
'
vec3 color = texture2D( texture, vUv ).rgb;
\n
'
+
'
\n
'
+
'
gl_FragColor = vec4( color, 1.0);
\n
'
+
'
}
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录