Problem with Area shadows (for stationary lights)

Hi there,

So I started using the new “Area shadow for stationary lights” feature in 4.9 and started seeing some weird behavior. I have a landscape in my scene that serves as a floor to the entire level and when I turned on the area shadows feature I noticed that some other light sources would not light the landscape any more. They would light other objects, just not the landscape.

Steps to reproduce:

  1. Place an object in the scene to act as a floor.
  2. Place three light sources (Direction, Point or Spot light doesn’t matter) so that each light illuminates some part of the floor object.
  3. Enable “Use area shadows for stationary light” on one of the lights.
  4. Build the lighting.

When the lighting is finished, one or more of the lights will no longer illuminate the floor object. If you add more lights (that also illuminate the floor object), other lights will stop working as well. One workaround for now is to keep adding lights until all the original lights are still lit after building the lighting, and then setting the unwanted lights to not affect world.

Is there any way to get around this?

Hello Hejden,

Thank you for reporting this and the reproduction steps.

I followed your steps and I did not see any of the other lights no longer illuminate the floor.

This was what I see.

As you can see the middle light is set to Use Area Shadows for Stationary Light.

I have a couple of questions to try and see if this is project specific.

1.) Does this happen in a new clean project?
2.) Does this happen in 4.9.2 or .1?
3.) If you could link me your DxDiag I can try and see if there are any compatibility/performance issues there.

After I have this information I should be able to further narrow down what is causing this.

Hi ,

  1. I did not do this in a clean project, but a clean map using only starter content.
  2. I was using 4.9.2
  3. I’ll see if I can figure out how to PM in this forum :slight_smile:

I should add that I tried to reproduce the effect using the steps I outlined, and for some reason I didn’t get the same result. But if I duplicated a few lights so that the total of lights were seven instead of three, one of the lights turned off. So I guess you could keep adding more lights and recompute the lighting to see if it’s the same on your end.

Anders

Hey Hejden,

You can go to our forums and go to the advanced tab. From there you can look for me in the looking for employee section. From there you can send me a private message.

Hi again,

I’ve sent you a PM with a link to my Dxdiag file now.

Anders

Hey Anders,

Your Dxdiag and specs are well within the suggested for UE4.

I did not duplicate any lights, maybe that was the issue. You can right click when you have the light selected in your Modes > Lights > ( Whatever Light) and place actor.

I will see if that is what caused it.

Hey Anders,

I have confirmed that duplicating the lights and changing one to " Use Area Shadows for Stationary Light " does turn other lights off. For now place actor or individually place your lights.

I will look into this further.

Hey Anders,

I have entered a bug for this issue.

The bug number is UE-21835.

Thank you for reporting this issue and I will keep you up to date on this bugs progress.

Thank you !

It’s really helpful to know the cause of it. I’ll avoid duplicating lights for now then.

Anders

We found a similar issue with area shadows, but it wasn’t related to duplicating lights.
The issue is that shadow map that use area shadows option have a coverage on every samples of the shadow map, instead of only on pixels that are influenced by the light. Then in the merging of shadow maps per channel, everything will be overiden by that area shadowed light, so other lights affected to this channel are invisible. In the sample shown above, the 3 lights are next to each other, so they are on separate channel and dont have the issue.
Our temporary fix is to take the light with the highest influence instead of replacing only based on coverage.
Here is the fix that worked for us : ShadowMap.cpp in FShadowMap2D::EncodeSingleTexture

// DNE BEGIN - Fix Area shadows erasing every other lights in the same channel (AZA)
FLightmassLightSettings LightMassSettings = ShadowMapPair.Key->GetLightmassSettings();
// DNE END

// Copy the raw data for this light-map into the raw texture data array.
for (int32 Y = Allocation.MappedRect.Min.Y; Y < Allocation.MappedRect.Max.Y; ++Y)
{
	for (int32 X = Allocation.MappedRect.Min.X; X < Allocation.MappedRect.Max.X; ++X)
	{
		int32 DestY = Y - Allocation.MappedRect.Min.Y + Allocation.OffsetY;
		int32 DestX = X - Allocation.MappedRect.Min.X + Allocation.OffsetX;

		FFourDistanceFieldSamples& DestSample = (*TopMipData)[DestY * TextureSizeX + DestX];
		const FQuantizedSignedDistanceFieldShadowSample& SourceSample = SourceSamples[Y * Allocation.TotalSizeX + X];

		if ( SourceSample.Coverage > 0 )
		{
			// Note: multiple lights can write to different parts of the destination due to channel assignment
			// DNE BEGIN - Fix Area shadows erasing every other lights in the same channel (AZA)
			if (LightMassSettings.bUseAreaShadowsForStationaryLight)
			{
				// We only replace sample if it has more influence
				if(DestSample.Samples[ChannelIndex].Distance<SourceSample.Distance)
				{
					DestSample.Samples[ChannelIndex] = SourceSample;
				}
			}
			else
			{
				DestSample.Samples[ChannelIndex] = SourceSample;
			}
			// DNE END
		}
#if WITH_EDITOR
		if ( SourceSample.Coverage > 0 )
		{
			GNumShadowmapMappedTexels++;
		}
		else
		{
			GNumShadowmapUnmappedTexels++;
		}
#endif
	}
}