Kilombo Posted June 4, 2014 Share Posted June 4, 2014 Hello everyone, I've been trying for the past few hours to put out a lens flare that would fade away if the camera was more then at certain distance from the light. When I check the babylon.lensFlare.js it appears that the solution is on the borderlimit variable. Although, somehow if i put the borderlimit bigger then one the lensflare never disapear from the screen. And if i put him negative or zero, it doesn't appear at all. Anyone worked around with this already ? (Delta, I'll test the mipmap in this evening no worry, I promise you ) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 4, 2014 Share Posted June 4, 2014 Did you have a look at this demo:https://github.com/BabylonJS/Samples/blob/master/Scenes/Customs/lensFlares.js Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 4, 2014 Author Share Posted June 4, 2014 Indeed mate. You see, it happens the same in the demo, you can zoom out of the skybox but the lens flare are still visible. I need somehow to limit that to a view distance limit or else fade out. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 4, 2014 Share Posted June 4, 2014 Sounds simple to do. In render function, the intensity could be multiplied by the range to the light (Same for the isVisible. If light.pos - cam.pos> range, then return false) Thoughts? Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 5, 2014 Author Share Posted June 5, 2014 Hello Delta, I thought about it, and almost implemented something like that, although when I checked the babylon.lensflare.js file, I saw a this method (LensFlareSystem.prototype.render = function ()), it has one intensity property that works with two away vars (awayX and awayY), but this doesn't seem to be working properly. And I want to understand if i'm doing something wrong or if this is not supposed to work the way I'm thinking. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 5, 2014 Share Posted June 5, 2014 I think you should just have to set intensity to a lower value to reduce intensity? Am I wrong? Do you have your experiment somewhere I can see it? Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 13, 2014 Author Share Posted June 13, 2014 Sorry to reactivet DK, but I come back to this today. The problem is the same. I think you are talking about the light. But I'm talking about the particleSystem.In particleSystem.js I don't see any reference to distance. Anyway, I tried do do dispose if distance from emitter or bigger then the light range, and if not it would render again. It happens that this doesn't work has visible or not visible, it has to be instanciated again. Is it possible to had a setVisible(true/false) that would change the private visible var in the class, and that would rather turn visible or not the particleSystem ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2014 Share Posted June 13, 2014 You were talking about lensflares I'm not sure to understand what do you want then Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 13, 2014 Author Share Posted June 13, 2014 I want to turn the lens flare not visible when the distance from the emitter is bigger then the light range. This could be solved with a turn visible/not visible method or private var. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2014 Share Posted June 13, 2014 Yes but why do you speak about particleSystem then ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2014 Share Posted June 13, 2014 BTW I've just added a LensFlareSystem.isEnabled property Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 13, 2014 Author Share Posted June 13, 2014 Yes but why do you speak about particleSystem then ?Well..... What can I say.... My brain just burned out or something. Lol...... Thanks for the feature. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2014 Share Posted June 13, 2014 My pleasure Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 13, 2014 Author Share Posted June 13, 2014 Sorry to bother again DK. But it's not working. In the example in the URL the lensflare should be _enabled = false (has it is), although it still draws.The distance is bigger then 18000 (has i defined) so it runs the method disposeParticle() (and in the console.log returns false).There's the class and in the end is the function. Do you find anything wrong or weird ?function system(posx,posz,planet1,planet2,planet3){ //luzes this.planet1 = planet1; this.planet2 = planet2; this.planet3 = planet3; this.posx = posx; this.posz = posz; this.light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(this.posx, 0, this.posz), scene); this.lightSphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 64, 40, scene); this.lensFlareSystem1 = new BABYLON.LensFlareSystem("lensFlareSystem", this.light0, scene); this.lightSphere0.position = this.light0.position; this.flare00 = new BABYLON.LensFlare(0.1, 0, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", this.lensFlareSystem1); this.flare01 = new BABYLON.LensFlare(0.3, 0.1, new BABYLON.Color3(0.5, 0.5, 1), "Assets/lens4.png", this.lensFlareSystem1); this.flare02 = new BABYLON.LensFlare(0.1, 0.5, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", this.lensFlareSystem1); this.flare03 = new BABYLON.LensFlare(0.2, 0.2, new BABYLON.Color3(1, 0.5, 1), "Assets/Flare.png", this.lensFlareSystem1); this.flare04 = new BABYLON.LensFlare(0.05, 0.3, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", this.lensFlareSystem1); this.flare05 = new BABYLON.LensFlare(0.2, 0.4, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", this.lensFlareSystem1); this.light0.range; this.light0.intensity;}system.prototype.activateLens = function(){ this.lensFlareSystem1._isEnabled = true;};system.prototype.disposeLens = function(){ console.log("entra no desligador"); this.lensFlareSystem1._isEnabled = false; console.log(this.lensFlareSystem1._isEnabled);};system.prototype.setSun = function(range,intensity){ this.lightSphere0.material = new BABYLON.StandardMaterial("white", scene); this.lightSphere0.material.diffuseColor = new BABYLON.Color3(1, 1, 1); this.lightSphere0.material.specularColor = new BABYLON.Color3(1, 1, 1); this.lightSphere0.material.emissiveColor = new BABYLON.Color3(1, 1, 1); this.lensFlareSystem1.borderLimit = 10; this.lensFlareSystem1.render; this.light0.range = range; this.light0.intensity = intensity;};system.prototype.getSunRange = function(){ return this.light0.range;};system.prototype.getSunIntensity = function(){ return this.light0.intensity;};system.prototype.getSunPositionX = function(){ return this.lightSphere0.position.x;};system.prototype.getSunPositionZ = function(){ return this.lightSphere0.position.z;};system.prototype.setPlanets = function (){ var temp = this; BABYLON.SceneLoader.ImportMesh(this.planet1, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) { newMeshes[0].scaling.x = 500; newMeshes[0].scaling.y = 500; newMeshes[0].scaling.z = 500; newMeshes[0].position.x = (temp.posx)/2; newMeshes[0].position.y = 0; newMeshes[0].position.z = temp.posz/2; newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL); newMeshes[0].actionManager = new BABYLON.ActionManager(scene); newMeshes[0].checkCollisions = true; newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(newMeshes[0]); }); BABYLON.SceneLoader.ImportMesh(this.planet2, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) { newMeshes[0].scaling.x = 300; newMeshes[0].scaling.y = 300; newMeshes[0].scaling.z = 300; newMeshes[0].position.x = (temp.posx/2)+(temp.posx); newMeshes[0].position.y = 0; newMeshes[0].position.z = temp.posz/2; newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL); newMeshes[0].actionManager = new BABYLON.ActionManager(scene); newMeshes[0].checkCollisions = true; newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(newMeshes[0]); }); BABYLON.SceneLoader.ImportMesh(this.planet3, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) { newMeshes[0].scaling.x = 750; newMeshes[0].scaling.y = 750; newMeshes[0].scaling.z = 750; newMeshes[0].position.x = temp.posx; newMeshes[0].position.y = 0; newMeshes[0].position.z = temp.posz/2; newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL); newMeshes[0].actionManager = new BABYLON.ActionManager(scene); newMeshes[0].checkCollisions = true; newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(newMeshes[0]); });};function calculateSunDistance(system,camera){ distancex = Math.abs((camera.target.x)-(system.getSunPositionX())); distancez = Math.abs((camera.target.z)-(system.getSunPositionZ())); console.log(distancex, " ",distancez); if ((distancex > system.getSunRange())||(distancez > system.getSunRange())){ system.setSun(system.getSunRange(),0); system.disposeLens(); console.log("desligou"); } else{ system.setSun(system.getSunRange(),1); system.activateLens(); console.log("ligou"); } }; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2014 Share Posted June 13, 2014 I created a property isEnabled so you can just call lensFlareSystem.isEnabled = false It should work btw, could you confirm that you are using the right version? Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 14, 2014 Author Share Posted June 14, 2014 Yap it works, I didn't had my forked babylon sincronized. Thanks DK 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.