skalibran Posted February 18, 2015 Share Posted February 18, 2015 Hey there, I started doing WebGL-stuff yesterday and did the PlayPen-Tutorials till "Animations". For a scene I created (http://perditio.com/babylontest/index.html) I want to animate a sunrise using a Hemisoherical Light and its Vector3-positions.The Problem: It simply doesn't work. The light does not move / travel to the location. You can find the code here:http://www.babylonjs-playground.com/#11ZVTO It would be great if anyone can help. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 18, 2015 Share Posted February 18, 2015 Hello and welcome The Hemispheric light does not have a position. You should use a point light instead:http://www.babylonjs-playground.com/#11ZVTO#3 (I fixed several other issues as well) Quote Link to comment Share on other sites More sharing options...
skalibran Posted February 18, 2015 Author Share Posted February 18, 2015 Hello and welcome The Hemispheric light does not have a position. You should use a point light instead:http://www.babylonjs-playground.com/#11ZVTO#3 (I fixed several other issues as well) Hey, thanks for the answer! Unfortunetaly, the pointlight does not make the light the hemispheric light does on long distances. Yesterday after I was done with the Lights-Tutorial I tried out to to simulate sunshine with pointlights and I had to use up to five pointlights to make something that looks similar to the light cone I've created with the hemispheric light. A single point light cone is too thin on long distances and if I put the point light a few meters in front of the camera it doesn't look like it's origin is from the sun. I created a graphic to visualize my problem:I could count a variable inside the registerBeforeRender-function to simulate the day cycle, but I'm unsure how often it loops. Is it related to the performance of the pc? Or is it a fixed rate, lets say registerBeforeRender refreshes 60 times a second? Quote Link to comment Share on other sites More sharing options...
iiceman Posted February 19, 2015 Share Posted February 19, 2015 Hi and welcome Did you try to just increase the intensity on the pointlight? http://www.babylonjs-playground.com/#11ZVTO#4 Quote Link to comment Share on other sites More sharing options...
skalibran Posted February 19, 2015 Author Share Posted February 19, 2015 Hi and welcome Did you try to just increase the intensity on the pointlight? http://www.babylonjs-playground.com/#11ZVTO#6 Thanks. No, I didn't. It's a bit embarrasing, but until now I thought the intensity could be 1 at maximum :S Unfortunetaly, in this case it can't help that much, but I can use the effect for general lightning (I have two lights, one (the sunlight I'm talking about) is to look good and the other one is to actually light up the enviroment).Using the registerBeforeRender, I created a sunset like I want it to be. Note: I didn't make the dawn looking nice yet http://www.babylonjs-playground.com/#11ZVTO#6 I'm still unsure if this sunset will be much quicker on better pc's because they can make more refreshes of the registerBeforeRender. Do you have an idea of how often the registerBeforeRender refreshes and if it is relative to the performance of the computer? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2015 Share Posted February 19, 2015 beforeRender function is called on every frame so ideally 60 times per second Quote Link to comment Share on other sites More sharing options...
skalibran Posted February 19, 2015 Author Share Posted February 19, 2015 beforeRender function is called on every frame so ideally 60 times per second So there is a 60 FPS lock? Can I increase it? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2015 Share Posted February 19, 2015 This lock is done by the browser itself unfortunately Quote Link to comment Share on other sites More sharing options...
skalibran Posted February 19, 2015 Author Share Posted February 19, 2015 This lock is done by the browser itself unfortunately Alright, makes things easier for me (noone can complain they only have 60 FPS ). So thank you guys for the help, I think all the questions are answered. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2015 Share Posted February 19, 2015 Good news..happy user-->happy developer Quote Link to comment Share on other sites More sharing options...
jerome Posted February 20, 2015 Share Posted February 20, 2015 btw, some 2D games implement a two loose coupling loop design pattern : - one loop for computing things as fast as possible (may use webworkers) : the logic loop- another loop, the one you know, to render things : the render loop, driven by the browser requestAnimationFrame calls Well, the logic loops computes things at its own rythm and updates some variables.Beside it, the render loop then just uses these variables or any kind of share memory with the logic loop and is dedicated only to clear and draw things. So you can still have a 60 fps rendering and a 200 fps (or 5 ) speed for, say, physic computations or anything else you want.Obviously this pattern works (for logic loop speed > 60 fps) only if your rendering time is quite short compared to the 16ms delay between two requestAnimationFrame calls because of the JS VM monothread. 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.