Closed Sungray closed 7 years ago
Direction depends a lot from the light source position, not all the objects have the same position therefore the light direction is different.
You shouldn't have issues using the 'Star' object because it only uses a Canvas the size of the screen. It updates when you move the camera or a object moves, since you can't make too big canvases.
If you placed the light very far, and in a very high position you should achieve that day effect.
Well I've noticed a very big performance hit when updating a star everytime the cam moves. I'll try optimizing, maybe I'm just working with too many bodies (a few thousands). Having a static star with only light direction would help a lot, since I wouldn't have to update it's position everytime the camera moves. So instead of calculating the direction from the star, you could just do star.getLightDirection() ?
The point is exactly that, to have every objects get the light in a similar direction, not depending on their position.
I don't seem to be able to achieve that day effect no matter where I put the star - the light gets weaker as soon as it leaves the star, so I can't get to full light.
Hi ! May I have your insight about this issue ? I'm unable to get a day effect using stars, and would prefer to have distinct light type for this, since it's quite different in it's use as the stars.
I would never need more than 1 of this light source, so it could even be included into LightWorld as the Ambiant Light, with color, alpha, direction and Z, point being to simulate day/night cycle.
Ambient color is just a rect with a custom color. The trick I'm using to achieve such effects is using a canvas with a light, and paint the shadows over the light.
This is impossible to do without a Canvas unless I use a stencil containing the shadows, I don't know if this is going to be efficient at all.
I see, then what about a "directional light" object, which would be similar to Star, except the shadows direction and length aren't calculated from the star position and the body position, but obtained by directionalLight.getDirection() / directionalLight.getShadowLength() ?
That's not the actual issue, the issue are Canvas switches. I just tried to use the Star as a Light object and realized that there are even more issues, one of these issues is the normal maps.
If I stop relying on Canvases, we won't be able to use normal maps with stars. Why is this? I'm using the same technique to darken the Canvas with normal maps, unfortunately stencils won't help at all when using this because stencils are designed only for shapes, and normal maps are textures.
If there was a way to copy the content of a CGI image to another one then I would probably use it.
Apparently I forgot to deactivate the normal map shader after painting some stuff, could you try the engine again? The performance could've changed.
I'm not sure this is already achievable or not.
I'd like to be able to simulate day/night cycle. For this I'd need to create a light object with only direction, color and strength/alpha (no position), affecting all bodies the same way no matter their positions. Full strength would mean no darkness whatsoever, zero strength would mean total darkness.
Right now I'm just setting a star quite far away, but I can't achieve the "no darkness whatsoever" part, and I think this is more demanding than what would be a static (but updateable) star object with no position.
PS. Right now updating a star position is very costly. Adding an additional light type with only direction/color/strength(alpha) would help a lot for performances :)