|
@@ -129,112 +129,24 @@ export default class XMaterialComponent {
|
|
|
}
|
|
|
|
|
|
let VideoTexture = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)
|
|
|
- if(VideoTexture != null){
|
|
|
- VideoTexture.update(stream)
|
|
|
- VideoTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
|
-
|
|
|
- }
|
|
|
//(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
|
|
|
//(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
|
|
|
|
if(window.testPlane != null){
|
|
|
- // if(window.testPlane.material == null){
|
|
|
-
|
|
|
- BABYLON.Effect.ShadersStore['customVertexShader'] = houseShader.vertex
|
|
|
- // `
|
|
|
- // precision highp float;
|
|
|
- // attribute vec2 uv;
|
|
|
- // attribute vec3 position;
|
|
|
- // varying vec2 vUV;
|
|
|
- // uniform mat4 view;
|
|
|
- // uniform mat4 projection;
|
|
|
- // uniform mat4 world;
|
|
|
- // uniform mat4 worldViewProjection;
|
|
|
- // void main()
|
|
|
- // {
|
|
|
- // vUV = uv;
|
|
|
- // gl_Position = projection * view * world * vec4(position , 1.0);
|
|
|
- // }
|
|
|
- // `;
|
|
|
- BABYLON.Effect.ShadersStore["customFragmentShader"]= houseShader.fragment
|
|
|
- // `
|
|
|
- // precision highp float;
|
|
|
- // varying vec2 vUV;
|
|
|
- // uniform sampler2D chrominanceYTexture;
|
|
|
- // void main()
|
|
|
- // {
|
|
|
- // vec2 uv = vUV;
|
|
|
- // vec3 color = vec3(0,0,0);
|
|
|
- // color = texture2D(chrominanceYTexture, uv).rgb;
|
|
|
-
|
|
|
- // // const mat4 YUV2RGB = mat4
|
|
|
- // // (
|
|
|
- // // 1.1643828125, 0, 1.59602734375, -.87078515625,
|
|
|
- // // 1.1643828125, -.39176171875, -.81296875, .52959375,
|
|
|
- // // 1.1643828125, 2.017234375, 0, -1.081390625,
|
|
|
- // // 0, 0, 0, 1
|
|
|
- // // );
|
|
|
-
|
|
|
- // // vec4 result = vec4(
|
|
|
- // // texture2D( chrominanceYTexture, vec2( uv.x, uv.y * 0.666666 + 0.333333 ) ).x,
|
|
|
- // // texture2D( chrominanceYTexture, vec2( uv.x * 0.5, uv.y * 0.333333 ) ).x,
|
|
|
- // // texture2D( chrominanceYTexture, vec2( 0.5 + uv.x * 0.5, uv.y * 0.333333 ) ).x,
|
|
|
- // // 1
|
|
|
- // // ) * YUV2RGB;
|
|
|
-
|
|
|
- // // color = clamp(result.rgb, 0.0, 1.0);
|
|
|
-
|
|
|
- // gl_FragColor = vec4( color, 1.0);
|
|
|
- // }
|
|
|
- // `;
|
|
|
-
|
|
|
- window.testPlane.material = new BABYLON.ShaderMaterial(
|
|
|
- 'customShader',
|
|
|
- this.scene,
|
|
|
- {
|
|
|
- vertex: "custom",
|
|
|
- fragment: "custom",
|
|
|
- },
|
|
|
- {
|
|
|
- attributes: ['uv', 'position'],
|
|
|
- uniforms: houseShader.uniforms //['view', 'projection', 'worldViewProjection', 'world'],
|
|
|
- },
|
|
|
- )
|
|
|
-
|
|
|
- window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
|
|
|
- null,
|
|
|
- planeWidth,
|
|
|
- planeHeight,
|
|
|
- this.scene,
|
|
|
- false,
|
|
|
- true,
|
|
|
- )
|
|
|
-
|
|
|
- // window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
|
|
|
-
|
|
|
- window.testPlane.material.setTexture('texture_video', window._videoRawYTexture)
|
|
|
- window.testPlane.material.setFloat('isYUV', 1)
|
|
|
- window.testPlane.material.setVector3('focal_width_height', new BABYLON.Vector3(772.022491, planeWidth, planeHeight / 1.5))
|
|
|
-
|
|
|
|
|
|
- // window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
|
|
|
- // window.testPlane.material.diffuseTexture = window._videoRawYTexture
|
|
|
-
|
|
|
- window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
|
|
|
-
|
|
|
- // window.updateTexture( new Uint8Array(window.generateRandomArray()) );
|
|
|
- ++sub
|
|
|
- if(sub< renderCount)
|
|
|
- {
|
|
|
+ // window.updateTexture( new Uint8Array(window.generateRandomArray()) );
|
|
|
+ ++sub
|
|
|
+ if(sub< renderCount)
|
|
|
+ {
|
|
|
+ if(VideoTexture != null){
|
|
|
window._videoRawYTexture.update(stream)
|
|
|
window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
|
+
|
|
|
+ VideoTexture.update(stream)
|
|
|
+ VideoTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
|
}
|
|
|
-
|
|
|
- // this.scene.meshes.forEach(mesh => {
|
|
|
- // mesh.material != window.testPlane.material && (mesh.material = window.testPlane.material)
|
|
|
- // })
|
|
|
}
|
|
|
- // }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
);
|
|
@@ -358,6 +270,44 @@ export default class XMaterialComponent {
|
|
|
window.testPlane.position.y = 3;
|
|
|
window.testPlane.position.z = -20;
|
|
|
window.testPlane.position.x = 15;
|
|
|
+
|
|
|
+
|
|
|
+ BABYLON.Effect.ShadersStore['customVertexShader'] = houseShader.vertex
|
|
|
+ BABYLON.Effect.ShadersStore["customFragmentShader"]= houseShader.fragment
|
|
|
+
|
|
|
+ window.testPlane.material = new BABYLON.ShaderMaterial(
|
|
|
+ 'customShader',
|
|
|
+ this.scene,
|
|
|
+ {
|
|
|
+ vertex: "custom",
|
|
|
+ fragment: "custom",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attributes: houseShader.attributes, // ['uv', 'position'],
|
|
|
+ uniforms: houseShader.uniforms // ['view', 'projection', 'worldViewProjection', 'world'],
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
|
|
|
+ null,
|
|
|
+ planeWidth,
|
|
|
+ planeHeight,
|
|
|
+ this.scene,
|
|
|
+ false,
|
|
|
+ true,
|
|
|
+ )
|
|
|
+
|
|
|
+ // window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
|
|
|
+
|
|
|
+ window.testPlane.material.setTexture('texture_video', window._videoRawYTexture)
|
|
|
+ window.testPlane.material.setFloat('isYUV', 1)
|
|
|
+ window.testPlane.material.setVector3('focal_width_height', new BABYLON.Vector3(772.022491, planeWidth, planeHeight / 1.5))
|
|
|
+
|
|
|
+ // window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
|
|
|
+ // window.testPlane.material.diffuseTexture = window._videoRawYTexture
|
|
|
+
|
|
|
+ window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
|
|
|
+
|
|
|
}
|
|
|
|
|
|
stopYUVUpdate() {
|
|
@@ -652,4 +602,55 @@ var houseShader = {
|
|
|
gl_FragColor = vec4(shadow * color * 1.0, 1.0);
|
|
|
}
|
|
|
`
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// `
|
|
|
+// precision highp float;
|
|
|
+// attribute vec2 uv;
|
|
|
+// attribute vec3 position;
|
|
|
+// varying vec2 vUV;
|
|
|
+// uniform mat4 view;
|
|
|
+// uniform mat4 projection;
|
|
|
+// uniform mat4 world;
|
|
|
+// uniform mat4 worldViewProjection;
|
|
|
+// void main()
|
|
|
+// {
|
|
|
+// vUV = uv;
|
|
|
+// gl_Position = projection * view * world * vec4(position , 1.0);
|
|
|
+// }
|
|
|
+// `;
|
|
|
+
|
|
|
+
|
|
|
+// `
|
|
|
+// precision highp float;
|
|
|
+// varying vec2 vUV;
|
|
|
+// uniform sampler2D chrominanceYTexture;
|
|
|
+// void main()
|
|
|
+// {
|
|
|
+// vec2 uv = vUV;
|
|
|
+// vec3 color = vec3(0,0,0);
|
|
|
+// color = texture2D(chrominanceYTexture, uv).rgb;
|
|
|
+
|
|
|
+// // const mat4 YUV2RGB = mat4
|
|
|
+// // (
|
|
|
+// // 1.1643828125, 0, 1.59602734375, -.87078515625,
|
|
|
+// // 1.1643828125, -.39176171875, -.81296875, .52959375,
|
|
|
+// // 1.1643828125, 2.017234375, 0, -1.081390625,
|
|
|
+// // 0, 0, 0, 1
|
|
|
+// // );
|
|
|
+
|
|
|
+// // vec4 result = vec4(
|
|
|
+// // texture2D( chrominanceYTexture, vec2( uv.x, uv.y * 0.666666 + 0.333333 ) ).x,
|
|
|
+// // texture2D( chrominanceYTexture, vec2( uv.x * 0.5, uv.y * 0.333333 ) ).x,
|
|
|
+// // texture2D( chrominanceYTexture, vec2( 0.5 + uv.x * 0.5, uv.y * 0.333333 ) ).x,
|
|
|
+// // 1
|
|
|
+// // ) * YUV2RGB;
|
|
|
+
|
|
|
+// // color = clamp(result.rgb, 0.0, 1.0);
|
|
|
+
|
|
|
+// gl_FragColor = vec4( color, 1.0);
|
|
|
+// }
|
|
|
+// `;
|