Jump to content

Transparent Clear Color


jerome
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...