Sunrise effect

how can i create a sunrise effect, i know it has something to do with DirectionalLight but i dont know how to set its direction to make this happen.

thank you

Hi, I’m new here, so excuse me if I say something stupid. ^_^. I don’t know exactly what kind of effect do you want. In my case to get a sunset effect I just made a sky texture in photoshop with the “sunset colors” and in jMonkey I put a Bloom filter in the scene. To give the yellow color to the scene I added an addtional yellow Directinal Light. Hope it helps.

Do you mean Light Scattering ? if so, have you taken a look at in the jME Tests ?

my mistake for not explaining it.

  1. i want to make the scene have lighting depending on the time, e.g starting from “day light” going to “afternoon light” and at the end “night without lights”.

    I can achieve an estimation of this if i darken the color of the directional light.

    Should i use setDirection() ? to simulate the fact that the sun “moves” from east to west when it is rising ? If how would i calculate sun position, direction?
  2. the skybox and lightScattering @dadrian and @toucher mentioned are part of the solution to make it better looking.

I actually did work on something similar very recently. The relevant code is spread across multiple files, but here are the significant bits:

The sun position and light direction are calculated based on two parameters, azimuth and elevation (in radians). So, you would just need to update the colors and position of the sun on each tick.

  • ryan
1 Like

thank you for your contribution,

you must be really good at maths to be able to do all that.

Truth be told, I’m absolutely horrible at math. :slight_smile: By far, my worst subject in school. I was just able to find the equations I was looking for on some math professor’s website! Just gotta know what to search for, I guess.

  • ryan

All that being said, really the basic trig used there is extremely fundamental stuff. I highly recommend that any developer who wants to do well in 3D graphics spend some time getting their head around the uses of cos, sin, and right triangles. Knowing that angle a is the same as vector(cos(a), sin(a)) is the cornerstone of so many things.