Jump to content

Problem with HemisphericLight-Animation


skalibran
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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:

hemiproblem.png

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?

Link to comment
Share on other sites

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 :D

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 :D

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...