|
@@ -139,9 +139,61 @@ export default class XMaterialComponent {
|
|
//(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
//(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
|
|
|
|
if(window.testPlane != null){
|
|
if(window.testPlane != null){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BABYLON.Effect.ShadersStore['customVertexShader'] = `
|
|
|
|
+ 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"]=`
|
|
|
|
+ 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;
|
|
|
|
+
|
|
|
|
+ gl_FragColor = vec4( color, 1.0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ `;
|
|
|
|
+
|
|
if(window.testPlane.material == null){
|
|
if(window.testPlane.material == null){
|
|
- window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
|
|
|
|
- window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
|
|
|
|
|
|
+ //window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
|
|
|
|
+ window.testPlane.material = new BABYLON.ShaderMaterial(
|
|
|
|
+ 'customShader',
|
|
|
|
+ this.scene,
|
|
|
|
+ {
|
|
|
|
+ vertex: "custom",
|
|
|
|
+ fragment: "custom",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ attributes: ['uv', 'position'],
|
|
|
|
+ uniforms: ['view', 'projection', 'worldViewProjection', 'world'],
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
|
|
window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
|
|
window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
|
|
null,
|
|
null,
|
|
@@ -152,8 +204,9 @@ export default class XMaterialComponent {
|
|
true,
|
|
true,
|
|
)
|
|
)
|
|
|
|
|
|
- window.testPlane.material.diffuseTexture = window._videoRawYTexture
|
|
|
|
-
|
|
|
|
|
|
+ //window.testPlane.material.diffuseTexture = window._videoRawYTexture
|
|
|
|
+ window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
|
|
|
|
+ window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
|
|
window.setInterval( ()=>{
|
|
window.setInterval( ()=>{
|
|
window.updateTexture( new Uint8Array(window.generateRandomArray()) );
|
|
window.updateTexture( new Uint8Array(window.generateRandomArray()) );
|
|
}, 60);
|
|
}, 60);
|