HugoMcPhee Posted October 2, 2014 Share Posted October 2, 2014 Resizing the window when there is no post process means the views aspect ratio gets updated when the engine.resize() function is used.However resizing the window while a postprocess is enabled means the view gets stretched even while the engine.resize() function is running.The "engine.resize()" function still updates the resolution if there is a post process, since there are no stretched or blurry pixels, it's just the aspect ratio that doesn't change.Everything works if the window is resized and then the page is refreshed but it would be nice for it to update without a refresh (using the "pass" postProcess) Is there a way to update the postprocess ratio when the window is resized? PostProcess code:postProcess0 = new BABYLON.PassPostProcess("Scene copy", 1.0, camera); Quote Link to comment Share on other sites More sharing options...
HugoMcPhee Posted October 2, 2014 Author Share Posted October 2, 2014 Got it workingTo get it working I made this function, which loops through all of the post process textures (there's probably a better way to do this) and then sets their width and height based on the canvas width and heightfunction refreshTextureRatios() { var loadedTextures = engine.getLoadedTexturesCache(); console.log(loadedTextures); for (var index = 0; index < loadedTextures.length ; index++) { if (loadedTextures[index].__smartArrayFlags != null) { loadedTextures[index]._width = canvas.width; loadedTextures[index]._height = canvas.height; } }} To apply it to just a single postProcess you can do this:function refreshTextureRatio(postProcessName) { postProcessName._textures.data[0]._width = canvas.width; postProcessName._textures.data[0]._height = canvas.height;}And then I ran the function inside the resize event after the engine.resize() functionwindow.addEventListener("resize", function () { engine.resize(); refreshTextureRatios();}and now all of the post process's aren't stretched Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 2, 2014 Share Posted October 2, 2014 You can also ask the postprocess to handle it for you by using postprocess.width = -1 HugoMcPhee 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.