styxxx Posted March 15, 2017 Share Posted March 15, 2017 Hi, I'm getting blank screenshots only, meaning: a PNG with full transparency. The size is correct though. //Somewhere a scene is loaded var scene = null; BABYLON.SceneLoader.Load('', 'data/data.babylon', engine, function(newScene){ scene = newScene; // some stuff } //Some features like camera, lights are added... // Finally somwhere the render loop engine.runRenderLoop(function(){ scene.render(); }); // and then manually in the js console or via events the screenshot command is triggered: BABYLON.Tools.CreateScreenshot(scene.getEngine(),scene.activeCamera, {"precision": "1"}); I tried tracing the steps this function does in the babylon.tools.ts and entered the necessary commands into the javascript console: var screenshotCanvas; if (!screenshotCanvas) { screenshotCanvas = document.createElement('canvas'); } screenshotCanvas.width = 630; screenshotCanvas.height = 1366; // checked here and screenshotCanvas is set to '<canvas width=... height=... >' var renderContext = screenshotCanvas.getContext("2d"); renderContext.drawImage(engine.getRenderingCanvas(), 0, 0, 1366, 630); // engine.getRenderingCanvas() returns '<canvas class=".." id=".." width="1366" height="630" >' // it's the correct babylon canvas //Then I checked via renderContext.getImageData(400,300,200,1); // (random values) //if there was any value set to anything else then 0. But no, all the values are 0. For some reason there is no image drawn at renderContext.dawImage(). screenshotCanvas remains blank and I only receive the blank png engine is set (I also used scene.getEngine()), scene is set too (and has a lot of data). So is scene.activeCamera. There are no error messages. This looks like a bug. Although I can't get my head around it. Unfortunately I can't post the whole code since it's work related (and mostly done by a third party company). Would be way too large I guess. But as far as I can tell there's nothing that would explain it. The scene is used to render everything. Babylon v.2.5 is used. And chrome/chromium (the final product will use the chromium embedded framework to display the webgl animation within an native application) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 15, 2017 Share Posted March 15, 2017 Are you creating your engine with preserveDrawingBuffer? Like this: engine = new BABYLON.Engine(canvas, true, {preserveDrawingBuffer: true}); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.