qqdarren Posted June 12, 2015 Share Posted June 12, 2015 I'm adding a VolumetricLightScatteringPostProcess on mouse click, and there is a noticeable screen flash when I do this. It is the screen going all black for one frame. I am actually adding two of them (one each to two different meshes), and the flash is longer (at least twice as long). (So I tried adding some more, and it gets longer and longer - but the FPS is plummeting by this point, so harder to be objective.) Previously I was actually adding them at app initialization, with decay set to 0, then just setting decay when they were needed. But I realized they still use CPU in that case, so I am now not creating the object until it is needed. BTW, the CPU load is quite significant: I'm getting 45 to 55fps before, then with one VolumetricLightScatteringPostProcess added it drops to 30-35fps, and with two of them it drops to 18-22fps. (i.e. 50 -> 33 -> 20) (Not a problem as they only run for a few seconds; but it is a problem if they run all the time.) So, my first question is if the screen flash is a bug that can be fixed, or just tough? And, if tough, is there a way to pre-create the objects (so I can have the screen flash when it does not matter), but still not have them use any CPU until I am ready?P.S. I guess I mean GPU, not CPU, as according to 'top' the load average does not change, nor do the CPU% shown by Firefox or Xorg. But when I add the effect the FPS goes down and the CPU core temperatures go up!! I'm developing on a nothing-special notebook, i7-4702MQ with integrated Intel HD Graphics 4600. julien-moreau 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 12, 2015 Share Posted June 12, 2015 Hi Q! Hey, how does this demo look/act for you? http://www.babylonjs-playground.com/#1BAPRM#18Click on those mesh, if you please. The VLS rays should project from the bullet holes. I had 20 VLS bullet hole beams clicked onto the mesh, and still at 59 fps. But, all the VLS/godrays in the above demo... are instances of a "papa" godray-diator, which is located way out in the country. (pan camera a bit... you'll see tiny dot flashes from papa godray). You might not be using instances, so your mileage may vary. Is it possible for you to create a playground scene that shows the issue, Q? thx. Quote Link to comment Share on other sites More sharing options...
qqdarren Posted June 12, 2015 Author Share Posted June 12, 2015 The difference is I don't create the godrays until the first click. I've hacked your demo, and I can see the flash on the first click: http://www.babylonjs-playground.com/#1BAPRM#27 I added a wireframe grid to make it easier to see, though it is literally just one frame. Also because the background gets lighter, it is hard to spot.BTW, I get 35-50fps on your demo (http://www.babylonjs-playground.com/#1BAPRM#18) in Firefox. It does not change however bullet holes I shoot in the crate. But if I change so the godrays are not created then I get 60fps, and then it drops to the 35-50fps rate after the first click. Conclusion: the god rays are what are taking the time. Under Chromium I get 60fps either way. (My own code also has notably better FPS under Chromium...) Conclusion: Chrome is quicker than Firefox for WebGL stuff! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 12, 2015 Share Posted June 12, 2015 hunh, interesting. *scratch scratch* Thanks for showing me/us that, Q. Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 16, 2015 Share Posted June 16, 2015 Hi qqdarren !For your questions : "So, my first question is if the screen flash is a bug that can be fixed, or just tough?"I can't reproduce the bug and I can't see the bug in the demo provided in this topic And, if tough, is there a way to pre-create the objects (so I can have the screen flash when it does not matter), but still not have them use any CPU until I am ready ?The method should be to unattach the post-process from the camera. Then, it'll save performances.The post-process is CPU and GPU computed. When the post-process is created, an internal pass is rendered every frame into a render target texture. Also, if the post-process is attached to a camera, the GPU will execute the post-process on every pixel, even if decay = 0.0;. qqdarren 1 Quote Link to comment Share on other sites More sharing options...
qqdarren Posted June 16, 2015 Author Share Posted June 16, 2015 Thanks for the idea. I tried passing camera as null, to set it later, but instantly get a JavaScript error This line: https://github.com/BabylonJS/Babylon.js/blob/d7d3c34b15166bc2198c988e49896b08283826ef/Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js#L52 I then tried creating the object, then setting camera to null:godrays = new BABYLON.VolumetricLightScatteringPostProcess('godrays',1, camera, Q, 50, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, true);godrays.camera = null;But that seems to have no effect, as the objects are still glowing. ...a bit more searching, and I suspect you are telling me to use one of the functions described here? https://github.com/BabylonJS/Babylon.js/wiki/How-to-use-PostProcessRenderPipeline However I don't explicitly have a PostProcessRenderPipelineManager: do I need to create one, or is one already existing behind the scenes? Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 16, 2015 Share Posted June 16, 2015 I think "detachPostProcess" and "attachPostProcess" are better : http://doc.babylonjs.com/page.php?p=24457By passing the "godrays" reference to the functions qqdarren 1 Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 16, 2015 Share Posted June 16, 2015 Oh, and I'll fix the constructor to enable this post-process for rendering pipelines. This is an error from me Quote Link to comment Share on other sites More sharing options...
qqdarren Posted June 16, 2015 Author Share Posted June 16, 2015 Thanks, Luaacro - camera.detachPostProcess() and camera.attachPostProcess() did work. But they cause the camera to give a nasty jerk; I might be out of time for a few days, but I will try to set up a playground minimal example. Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 23, 2015 Share Posted June 23, 2015 Fixed, you can now use the post-process in a rendering pipeline.If "camera" is undefined or null, you must provide the "scene" reference into the constructor 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.