xushiting 3 years ago
parent
commit
8133281249
1 changed files with 19 additions and 15 deletions
  1. 19 15
      src/XMaterialComponent.js

+ 19 - 15
src/XMaterialComponent.js

@@ -4,19 +4,19 @@ import Logger from "./Logger.js"
 
 window.generateRandomArray = ()=>{
     var rnd=[];
-      for(let i=0;i< 720*1728;i++)
-      {
-          rnd[i] = Math.floor(Math.random()*255);
-      }
-      return rnd;
+    for(let i=0;i< 512*1024;i++)
+    {
+        rnd[i] = Math.floor(Math.random()*255);
+    }
+    return rnd;
 }
 
 window.updateTexture = (yuv)=>
 {
-        let Y = yuv.subarray(0, 1728*720);
-        window._videoRawYTexture.update(Y)
-        window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
-        Y = undefined;
+    let Y = yuv.subarray(0, 512*1024);
+    window._videoRawYTexture.update(Y)
+    window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+    Y = undefined;
 }
 const yuv = new Uint8Array(window.generateRandomArray())
 
@@ -140,7 +140,7 @@ export default class XMaterialComponent {
 
                 if(window.testPlane != null){
                     if(window.testPlane.material == null){
-                        
+                        /*
                         BABYLON.Effect.ShadersStore['customVertexShader'] = `
                             precision highp float; 
                             attribute vec2 uv;
@@ -169,7 +169,7 @@ export default class XMaterialComponent {
                             }
                         `;
 
-                        // window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
+                        
                         window.testPlane.material = new BABYLON.ShaderMaterial(
                             'customShader',
                             this.scene,
@@ -182,19 +182,23 @@ export default class XMaterialComponent {
                               uniforms: ['view', 'projection', 'worldViewProjection', 'world'],
                             },
                         )
+                        window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
+                        */
+                       
+                        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._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
                             null,
-                            1728,
-                            720,
+                            512,
+                            1024,
                             this.scene,
                             true,
                             true,
                           )
 
-                        // window.testPlane.material.diffuseTexture = window._videoRawYTexture
-                        window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
+                         window.testPlane.material.diffuseTexture = window._videoRawYTexture
+
 
                         window.setInterval( ()=>{
                             window.updateTexture( new Uint8Array(window.generateRandomArray()) );