jerome Posted January 21, 2016 Share Posted January 21, 2016 Hi, I don't exactly know how the _gl.clear function works, but I would like that each frame to be redrawn ontop the former one on a transparent background. This would make each moving mesh let some kind of trace on the screen. What I did : http://www.babylonjs-playground.com/#DC40G Look at the line 4, I just set a clear color as a Color4 with an alpha value lower than 1. Now, I set the scene autoClear property to false : http://www.babylonjs-playground.com/#DC40G#1 Well, something happens, but not what I expected ... Does someone know how to achieve what I wanted then ? and could someone also explain what happened in this PG ? Quote Link to comment Share on other sites More sharing options...
jerome Posted January 21, 2016 Author Share Posted January 21, 2016 any idea anybody ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 When autoClear = false, only depth buffer is cleared. But because buffer is not preserved between frames a new frame is provided (and cleared) You can initialize the engine with var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer = true }) to keep the buffer between frames Quote Link to comment Share on other sites More sharing options...
jerome Posted January 21, 2016 Author Share Posted January 21, 2016 yeeaaahhh !!! I will test this ! thanks Quote Link to comment Share on other sites More sharing options...
chg Posted January 21, 2016 Share Posted January 21, 2016 2 minutes ago, Deltakosh said: When autoClear = false, only depth buffer is cleared. But because buffer is not preserved between frames a new frame is provided (and cleared) You can initialize the engine with var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer = true }) to keep the buffer between frames NB: preserveDrawingBuffer is Chrome (maybe Safari) only and not looking likely to be standardised to other browsers. As an alternative maybe use render to texture and keep a cicular buffer that you combine to produce your effect? Quote Link to comment Share on other sites More sharing options...
jerome Posted January 22, 2016 Author Share Posted January 22, 2016 too bad we can't tweak the engine within the PG code Quote Link to comment Share on other sites More sharing options...
jerome Posted January 22, 2016 Author Share Posted January 22, 2016 Just tested here with both chrome and FF : this doesn't change anything on my scene, even with a clearColor with an alpha :-( [EDIT] : I took a look at the engine constructor code here : https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.engine.ts#L571 Actually this option seems to not be used, nor stored in any of the Engine instance properties (I just searched for "preserveDrawingBuffer"). Maybe for a further use ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 22, 2016 Share Posted January 22, 2016 It is used here: https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.engine.ts#L584 inside the getContext function Quote Link to comment Share on other sites More sharing options...
jerome Posted January 22, 2016 Author Share Posted January 22, 2016 ouch, you're right note to myself : to not read the code directly in the github webpage when the lines are longer than the window width. GameMonetize 1 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.