A Sun

Is it possible to have something like a visible and movable Sun in a infinitely large world, and have it so that it is coming from above (so that if I’m inside a building with no light source, it’s completely dark)? What I’m asking for is basicly a cross between a DirectionalLight (infinite and evenly spread out) and a PointLight (has a position).

Few points.
Visual representation of light (white/yellow circle in the sky) has nothing to do with the light. You have to manage it separately.
Light ‘at infinity’ is exactly DirectionalLight - it can be used to simulate sun.
Neither DirectionalLight nor PointLight is smart enough to be blocked by walls/ceilings. You can simulate it by adding one of the shadow implementations, but I doubt if it will do what you expect - it will cast shadows even if you have different sources of light inside building.

The way to do that is to have an “outside” node and an “inside” node and only add the sun to the “outside” one.

You will also need some magic to do things like light coming in through windows etc.

<cite>@zarch said:</cite> The way to do that is to have an "outside" node and an "inside" node and only add the sun to the "outside" one.

You will also need some magic to do things like light coming in through windows etc.

Okay, that would of worked, it it weren’t for the basis of my game. I’m making a Minecraft clone, and I’m trying to implement the sun for it. And if you’re surrounded by blocks, it should be completely dark (which is not the case with DirectionalLight). So I’m not exactly sure I’d do that. Also, I’ve tried shadows but because of the number of Geometries it cuts my fps from 250 to 10.

Oh and as a side note, DirectionalLight is VERY buggy in my game for some reason. It keeps changing the intensity whenever I click on something.

Ahh, lighting in box worlds… That’s a big subject.

:slight_smile:

Start off getting the boxes working, then worry about the lighting.

Have you seen the cubes framework on these forums? It’s an open source starting point for box worlds.

<cite>@zarch said:</cite> Ahh, lighting in box worlds... That's a big subject.

:slight_smile:

Start off getting the boxes working, then worry about the lighting.

Have you seen the cubes framework on these forums? It’s an open source starting point for box worlds.

Yeah I’m already done the majority of it. I’ve basicly got Minecraft creative mode + crafting finished and mining, auto-generated terriain finished. This is one of the last few things I need to add. So it’s a little too late to use it ): . Did the person who made it implement a sun? If they did, do you know how they did that?

AFAIK Lighting in voxel worlds should use a voxel light approach. You probably should not use the jme lighting approach at all. Instead you could propagate your lighting information trough ‘Empty voxels’ and update the mesh of the solid world according. It all comes down how fast your mesh generator is and how fast you can perform the light propagation algorithm.

There is a video in this forum of a guy implementing this.
http://hub.jmonkeyengine.org/forum/topic/moebius-a-minecraft-like-scifi-game/#post-170694

Simplest way is to store light intensity at each vertex of your mesh and then have the shader interpolate between them.

You don’t get “hard” shadows but it should work pretty well I expect.

<cite>@zarch said:</cite> Simplest way is to store light intensity at each vertex of your mesh and then have the shader interpolate between them.

You don’t get “hard” shadows but it should work pretty well I expect.

Is this possible if I batched by cube’s meshes?

So long as you are doing your own batching you can store whatever you like at those vertices…