hit2501 Posted April 25, 2017 Share Posted April 25, 2017 Hi, I'm playing with lens effects through this example: var lensEffect = new BABYLON.LensRenderingPipeline('lens', { edge_blur: 1.0, chromatic_aberration: 1.0, distortion: 0.5, dof_focus_distance: 100, dof_aperture: 1.0, grain_amount: 1.0, dof_pentagon: false, dof_gain: 1.0, dof_threshold: 1.0, dof_darken: 0 }, scene, 1.0, camera); And now I want to change only distortion with a slider that calls a function like this: function adjust_distortion(value){ console.log(value); lensEffect = new BABYLON.LensRenderingPipeline('lens', { distortion:value }, scene, 1.0, camera); } But the distortion increases even if I change the slider to a zero value. Can anybody show me a sample to achieve it with the dynamic "value"? Thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 25, 2017 Share Posted April 25, 2017 You should not recreate the effect but instead update it: https://www.babylonjs-playground.com/#1FTDJ6#9 Look line #75 Quote Link to comment Share on other sites More sharing options...
hit2501 Posted April 25, 2017 Author Share Posted April 25, 2017 Thanks Delta, I saw in 75 line: camera.radius = 400 + (-150 + 150 * Math.sin(time / 10)); Which works to move the camera near and far according to a math formula but I must keep the camera with a static radius from object, Or am I missing something? Please help btw, beautiful playground. Quote Link to comment Share on other sites More sharing options...
hit2501 Posted April 26, 2017 Author Share Posted April 26, 2017 I found the solution, it was a silly thing: scene.registerBeforeRender(function() { window.lensEffect.setEdgeDistortion(some_variable); }); Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 27, 2017 Share Posted April 27, 2017 lol 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.