How do i get a black night sky in the BP_Sky_Sphere ?

Hi everybody,

In the first person template, the night sky is black.

When i go to night in my game (also using the engine BP_Sky_Sphere), i get a purple sky at night.

In the first person template, i can switch between black and purple sky by (un)checking “use as atmosphere sunlight” (which i outlined in the first screenshot, bottom right).

But in my project, putting this variable to true/false doesn’t make any difference:

YagSunLight = ObjectInitializer.CreateDefaultSubobject<UDirectionalLightComponent>(this, TEXT("Sun light"));
YagSunLight->AttachParent = RootComponent;
YagSunLight->SetLightColor(FLinearColor(1.f, 1.f, .8f, 1.f));
YagSunLight->SetIntensity(0.f);
YagSunLight->SetCastShadows(true);
YagSunLight->SetMobility(EComponentMobility::Movable);
YagSunLight->bUsedAsAtmosphereSunLight = true;

Yet, the rotation of the sun is handled correctly. I use the BP_SkySphere provided with the engine, which i have modified to take my UDirectionalLightComponent instead of its native directional light actor.

I have also tried to use a directional light actor variable (ADirectionalLight), but the sky is always purple, and there is no bUsedAsAtmosphereSunLight parameter available for the actor directional light.

So obviously i am missing something. I tried world and relative rotation, i tried component and actor, but no way to get this nice black sky.

Any idea anyone ?

Thanks

Cedric

Will you accept a non-C++ answer?

If so, you can go to the default sunlight actor and change it’s rotation pointing in a more upward direction, then go to the BP-skysphere and click the check box that I think says refresh material. That should move the sun based on the light actor. This is how I move my sun position/day or night time.

Hi Gunnar0,

Thanks for your answer, but this is how to do it manually.

I do not have any sun light actor defined at construct time. My sun light actor is defined during runtime, then modified through c++.

I have modified the BP_Sky_Sphere so it takes this runtime light into account and it seems to work: the sun is moving in the sky, the shadows are moving with it.

The only thins that doesn’t work is the night colors update.

Cheers

Cedric

Ok, understood !

I was inclining the sun above the horizon, and hence it didn’t go down deep enough so that the “sun height” parameter could hit the right values in the color curves defined in the skydome.

All clear.

Oh, I’ve never created a Timed sun, I only use still suns.

Hi,

Not much more difficult, you just rotate your directional light in real time, et voilà. The directional light must have the bUsedAsAtmosphereSunLight checked (or set to true if in c++).

The only thing is it can be costly: i have to reconstruct the hole skydome every frame (tick function). My game can afford it because it’s not too heavy on the visuals, but this must be thought carefully (or tested^^). If it’s needed, then you should have to go inside the guts of the skydome graphs to refresh only what you need. I didn’t do it yet.

Cheers

Cedric