提交 0f77e12b 编写于 作者: J Jerome Etienne

fix shader again

上级 9af95411
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
ringHighMesh.rotation.z = Math.random()*2*Math.PI ringHighMesh.rotation.z = Math.random()*2*Math.PI
onRenderFcts.push(function(delta){ onRenderFcts.push(function(delta){
ringHighMesh.rotation.z += 2*Math.PI*delta / 5 ringHighMesh.rotation.z -= 2*Math.PI*delta / 5
}) })
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
......
...@@ -167,51 +167,51 @@ THREEx.ArMarkerCloak = function(videoTexture){ ...@@ -167,51 +167,51 @@ THREEx.ArMarkerCloak = function(videoTexture){
// Shaders // Shaders
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
THREEx.ArMarkerCloak.markerSpaceShaderFunction = '' + THREEx.ArMarkerCloak.markerSpaceShaderFunction = '\n'+
' vec2 transformUvToMarkerSpace(vec2 originalUv){'+ ' vec2 transformUvToMarkerSpace(vec2 originalUv){\n'+
' vec3 transformedUv;'+ ' vec3 transformedUv;\n'+
' // set transformedUv - from UV coord to clip coord'+ ' // set transformedUv - from UV coord to clip coord\n'+
' transformedUv.x = originalUv.x * 2.0 - 1.0;'+ ' transformedUv.x = originalUv.x * 2.0 - 1.0;\n'+
' transformedUv.y = originalUv.y * 2.0 - 1.0;'+ ' transformedUv.y = originalUv.y * 2.0 - 1.0;\n'+
' transformedUv.z = 0.0;'+ ' transformedUv.z = 0.0;\n'+
''+ '\n'+
' // apply modelViewMatrix and projectionMatrix'+ ' // apply modelViewMatrix and projectionMatrix\n'+
' transformedUv = (projectionMatrix * modelViewMatrix * vec4( transformedUv, 1.0 ) ).xyz;'+ ' transformedUv = (projectionMatrix * modelViewMatrix * vec4( transformedUv, 1.0 ) ).xyz;\n'+
''+ '\n'+
' // apply perspective'+ ' // apply perspective\n'+
' transformedUv.x /= transformedUv.z;'+ ' transformedUv.x /= transformedUv.z;\n'+
' transformedUv.y /= transformedUv.z;'+ ' transformedUv.y /= transformedUv.z;\n'+
''+ '\n'+
' // set back from clip coord to Uv coord'+ ' // set back from clip coord to Uv coord\n'+
' transformedUv.x = transformedUv.x / 2.0 + 0.5;'+ ' transformedUv.x = transformedUv.x / 2.0 + 0.5;\n'+
' transformedUv.y = transformedUv.y / 2.0 + 0.5;'+ ' transformedUv.y = transformedUv.y / 2.0 + 0.5;\n'+
''+ '\n'+
' // return the result'+ ' // return the result\n'+
' return transformedUv.xy;'+ ' return transformedUv.xy;\n'+
' }' ' }'
THREEx.ArMarkerCloak.vertexShader = THREEx.ArMarkerCloak.markerSpaceShaderFunction + THREEx.ArMarkerCloak.vertexShader = THREEx.ArMarkerCloak.markerSpaceShaderFunction +
' varying vec2 vUv;'+ ' varying vec2 vUv;\n'+
''+ '\n'+
' void main(){'+ ' void main(){\n'+
' // pass the UV to the fragment'+ ' // pass the UV to the fragment\n'+
' #if (updateInShaderEnabled == 1)'+ ' #if (updateInShaderEnabled == 1)\n'+
' vUv = transformUvToMarkerSpace(uv);'+ ' vUv = transformUvToMarkerSpace(uv);\n'+
' #else'+ ' #else\n'+
' vUv = uv;'+ ' vUv = uv;\n'+
' #endif'+ ' #endif\n'+
''+ '\n'+
' // compute gl_Position'+ ' // compute gl_Position\n'+
' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );'+ ' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n'+
' gl_Position = projectionMatrix * mvPosition;'+ ' gl_Position = projectionMatrix * mvPosition;\n'+
' }'; ' }';
THREEx.ArMarkerCloak.fragmentShader = ''+ THREEx.ArMarkerCloak.fragmentShader = '\n'+
' varying vec2 vUv;'+ ' varying vec2 vUv;\n'+
' uniform sampler2D texture;'+ ' uniform sampler2D texture;\n'+
''+ '\n'+
' void main(void){'+ ' void main(void){\n'+
' vec3 color = texture2D( texture, vUv ).rgb;'+ ' vec3 color = texture2D( texture, vUv ).rgb;\n'+
''+ '\n'+
' gl_FragColor = vec4( color, 1.0);'+ ' gl_FragColor = vec4( color, 1.0);\n'+
' }' ' }'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册