Render Loop

Passing Render Textures To The SDK

Once the scene and the cameras are setup, in your render loop , you'll have to pass the render textures of the cameras to the SDK. This render texture passing logic has to run every frame , so this has to be part of the render loop.

    render() {
      
      /* cameras - cams setup using SDK positions and projection matrices, 
      rtWidth and rtHeight - render texture width and height taken from the SDK */
    
      const tempBuffer = new Uint8Array(rtWidth * rtHeight * 4);
    
      cameras.forEach((camera,index) =>
      {
        renderer.clear();
        renderer.setRenderTarget(renderTarget);
        renderer.render(scene, camera);

        renderer.readRenderTargetPixels(renderTarget, 0, 0, rtWidth, rtHeight, tempBuffer);
        RenderController.saveTexture(tempBuffer, index, rtWidth, rtHeight, gl); 
      });
      
      ...
    }

Update Render Controller

Once the render textures are passed onto the SDK using RenderController.saveTexture(...), The update method from the Render Controller has to be called to process and render the final output onto the canvas specified.

render() {
    ...
    
    
    RenderController.update(gl);
}

Last updated

Copyright © 2023 Leia Inc. All Rights Reserved