Directional Light and the Sun

So just a quick question here. I’m slowly (emphasis on the slow part) working on a space game. There’ll be a lot of traveling around etc which got me to thinking about the Sun. Naturally one should use Directional Lighting to quickly create sunlight. But if you’re changing location super-dee-duper fast (technical term) does it make sense to say calculate the vector of the directional light in relation to your position to the sun?

As it says in the documentation that you create directional light using this

[java]DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());

So should I update that vector in real time as I cruise around?

Side note I don’t have code to effectively test this out. Just asking. Random thought while I was at the office.

If you travel super-dee-duper fast, do you pass several suns?
If so, how about a PointLight for each?

Good point. I was under the impression though that point lights at distance is not the greatest idea though. I could be wrong.

I wonder how fast is “super-dee-duper fast”. Or what your general scale is.

So, in “real life”, the nearest star is 4.3 light years away. So even traveling at the speed of light (pretty darned fast) it would take 4.3 years to reach it.

I only bring this up because “super-dee-duper fast” must be several orders of magnitude faster than the speed of light in order for light direction to matter much beyond “yes it’s fine to just change light direction”. Or who knows what light looks like when you are traveling that fast so you can make it up anyway. :slight_smile:

Unless you are talking about just tooling around in the solar system “pretty fast”… in which case, directional light with dynamic direction may still be a great way. Geometry scale will be your biggest issue anyway.

A point light could work but you’d probably be treating it like it had infinite distance but I think it would still be calculating distance for fall-off and stuff. I don’t think we have an infinite point light.

So, back to your game scale, is it high level planet-to-planet stuff or even higher level system-to-system stuff… do you ever go intra-atmosphere or are planets always just marbles?

@pspeed said: I wonder how fast is "super-dee-duper fast". Or what your general scale is.

First: Thanks for the reply!

So onto the rest. Scale… is going to be a bit flexible here. Like any fun space opera/saga/something-a the speed of the craft is more to ensure you don’t get bored waiting to go from point a to b. So things that’ll be to scale (or at least what I’m going to attempt anyways) include planets, asteroids, moons and stars. Things that won’t be will be their distances from each other. So I’m planning on designing a large solar system of sorts that doesn’t really follow what we’d consider normal. You won’t find Earth or Mars here is basically what it’ll boil down to.

Speed wise the user will be able to get from 1 edge to another in a reasonable amount of time and possibly with the aid of a gate or rail gun like ship speed “aid”.

Part of the goal is to capitalize on some of the fine work done in the forums here by various peeps. So things like the jMEPlanet and the recent planet rendering stuff done by @aaronperkins here: jmeplanet

Infinite zoom that @normen did here: for things like asteroid belts, moons, and rings.

etc. I don’t really want to announce this as an official project as life has a habit of jamming the brakes on whenever I get my coding, modeling groove on (i.e. Last time I was working on a model I was trying to teach myself the mysteries of UV Wrapping in Blender when my furnace went boom…).

So ya. The planets, moons etc won’t be marbles per say is what I’m getting at I guess. Planet to planet to other spacial bodies but mostly within a single solar system.

PointLight would make sense if the light direction (or intensity) varied across the lit objects in the scene. For instance, if you render multiple planets big enough to show discs and phases spread out around the sun.

Otherwise, I think it makes more sense to use a DirectionalLight and alter its direction (and possibly its intensity) as the player moves around.

As a point of reference, consider that the direction of sunlight varies by just 0.005 degrees across the face of the Earth, and by at most 0.15 degrees between the Earth and its moon. Such slight variations in light direction are unlikely to affect shading in a perceptible way.

hmmm. Perhaps I’ll try creating a test scene with a sun and a few planets to see performance with a point light then.