SSS is affected by Skylight. Shouldn't be

Hello,

Subsurface Scattering shows when it’s hit with direct light. I.E:

In UE4 However, I’ve setup a scene using only a skylight, with flat lighting or ambient lighting, you should only see the diffuse color, not SSS. BUT:

SSS Intensity = 1

SSS Intensity = 10

Skylight influences the SSS way too much!

Engine version: 4.15.1
Repro Steps:

  1. Create a new map.
  2. Remove pre-baked lighting.
  3. Remove directional light.
  4. Add Skylight.
  5. Add PPV, disable auto exposure (just so you see the issue easier).
  6. Add a SSS material to a mesh and change the SSS multiplier.

SSS shouldn’t make a visible difference while in flat ambient lighting condition.

Another test.

Material:

https://i.imgur.com/N84XT42.jpg

Direct + Skylight:

https://i.imgur.com/eWTpOHV.jpg

Skylight only. Since Skylight has Lower Hemisphere being black, it’s only casting light from above hence you see red on the bottom, but it should have been grey all the way since skylight is not a directional light source but is an ambient light.

https://i.imgur.com/EIZHbUf.jpg

Lower Hemisphere is not solid black in this one, should have been grey all the way here too but it’s not.

https://i.imgur.com/imMLkHv.jpg

Please fix this asap. All foliage look wrong in shadows.

Hello Maximum-Dev,

So I asked around to confirm what you are saying, but Skylights are expected to affect Subsurface Scattering. This is because Skylights are still emitting photons whether direct or indirect, it makes no difference. Now, the actual phenomenon in real life outside of video games, the effect can be more visible and pronounced with direct lighting; however, in Unreal we are dealing with calculating emitted photons from all light sources. There is no difference between Skylight photons and Directional Light photons, and in reality there is no difference between direct and indirect light, its only a term we use in rendering since direct lighting is much easier to calculate.

I ran some tests on my end just to see for myself, and its outcome is clear and expected.

Subsurface Material

As you can see I used a completely black input for my base color. I also exposed the opacity input as this determines the amount of simulated light scattered to show the SS effect.

Movable Spotlight

I also made sure to rebuild my lighting before viewing any of my results. You want to make sure you discard all the old indirect lighting.

Movable Skylight with Cubemap

Movable Skylight Captured Scene

In summary the results I am getting are expected because the Skylight is still emitting photons which is going to be picked up by the Subsurface Color. Thanks for taking the time to test the issue, but this is not a bug and just how subsurface scattering works with lighting in the engine.

Cheers,

Andrew Hurley

Hi Andrew,

That’s not quite right. It works a bit different from what you said.
Direct light and indirect light have different density in real life. That’s why when you put a flashlight behind your hand you see your hand getting a red tone, and when you remove the flashlight from the room, even though the room is fully lit by indirect light, you don’t see that red tone on your hand anymore. Let’s take a look at the example below, I believe this helps to better demonstrate the issue.

This is a room lit by indirect light, then there’s a flashlight on the table, and a hand covering the flashlight.

http://uupload.ir/files/ifuu_12.jpg

What you said above essentially means that if we remove the flashlight from the picture above, the hand should still have that red tone because there are still indirect light in the room hitting the hand. That’s wrong because i.e 5000 photons from flashlight hitting the hand is not the same as 1000 photons from indirect light hitting the hand, indirect light is sparse photons and not a photon source focused on one direction like a direct light source, hence, indirect light leaves far less noticeable. The reason you don’t see your whole body being red under overcast sky is because all that indirect light does not equal to the direct light from a tiny flashlight that makes your hand look red.

As you know, the correct behavior would be for the hand to lose all that red tone as soon as the flashlight is removed. Which means, your green looking ball should lose all the green SSS color as soon as the directional light is removed, and under the skylight it should look black (as your base color is) and with a very, very hard to notice dark shade of green to it.

Did I make a mistake by comparing a real life situation to how you handle things in your engine? as far as I know game engines try to replicate real life situations. Your rendering guys might just not be in the mood it seems like because without a flashlight, you neither have a red hand in real life, nor in other game engines. But you do in UE4.

The problem here is that you are comparing a real life situation, with how we handle things in the engine. The information I shared came directly from one of our rendering guys who knows lighting and materials very well. I understand your points about SS in the real life, but what you are seeing as described to me is what is expected. As you are aware, the engine cannot simulate every real life lighting situation as that would be incredibly complex and not really easy to use for games. We use a number of different techniques and features to simulate and fake various effects to try and resemble phenomenons like SSS. This is the beauty of game design, it sometimes doesn’t work out of the box like you would expect, so you will need to find a way to work around the problem if it is that much of an issue, which I am sure you can figure out :slight_smile:

Thank you,

Andrew Hurley

It’s not necessarily an incredibly complex calculation for a game. It’s as simple as reducing Skylight’s power on SSS. I just think they weren’t informed very well of the issue. Can you please possible have him read through this report once?

If this behavior is expected, yet rendering does not reflect the effect properly -
should not this at least be logged into issue tracker?

Indirect lighting SSS is messing with proper direct lighting SSS setup which engine tries to provide. While we can try to find workarounds it does not mean that issue should not be treated like not an issue at all.

It looks like a bug more and more. Here are two scenarios:

Directional Light

  1. Create abovementioned material with SSS color
  2. Create movable Directional light and look how it influence SSS
  3. Change it to Static/Stationary, build lighting and look how it influence SSS
    It works properly and material get proper SSS intensity during built static light and during movable state

Sky Light

  1. Create abovementioned material with SSS color
  2. Create movable Sky light and look how it influence SSS
  3. Change it to Static/Stationary, build lighting and look how it influence SSS
    Material get proper SSS intensity(NONE) only during built static/stationary light and get full 1.0 value during movable state. So either someone forgot to change value for movable state or by design Directional light contributes to SSS properly in all modes, but Sky light works properly only in half of cases.

Also, I might found relevant bit in SkyLighting.usf which responsible for diffuse lighting in Movable mode. Here is code snippet

if (ShadingModelId == SHADINGMODELID_TWOSIDED_FOLIAGE)
		{
			float3 SubsurfaceLookup = GetSkySHDiffuse(-GBuffer.WorldNormal) * View.SkyLightColor.rgb;
			float3 SubsurfaceColor = ExtractSubsurfaceColor(GBuffer);
			Lighting += ScalarFactors * SubsurfaceLookup * SubsurfaceColor;
		}

		if (ShadingModelId == SHADINGMODELID_SUBSURFACE || ShadingModelId == SHADINGMODELID_PREINTEGRATED_SKIN)
		{
			float3 SubsurfaceColor = ExtractSubsurfaceColor(GBuffer);
			// Add subsurface energy to diffuse
			DiffuseColor += SubsurfaceColor;
		}

As you can see - for two sided foliage some scaling applied, however for subsurface there is no logic, it just pure max color without scaling.

1 Like

@AndrewHurley :diamonds::diamonds: That is definitely a bug.
I just compared 4.15 and my build.

4.15 launcher version

My build

As You can see, SSS is localized where maximum skylight passes though the object, unlike on first shot.

Default lit material for comparison

I can’t say right away what was the change I made or when was the bug introduced, but It feels like it was around 4.12

Yeah looked alright in old builds. But even then the effect was exaggerated. The green should be ever more subtle, but anyway, I hope that’s enough evidence to consider this a bug @AndrewHurley :diamonds::diamonds:. Please show your rendering guys Deathrey’s old vs. new build comparison. Thanks.

I can bring Deathrey’s example to the attention of those who know SSS best to see what they think. I’ll return once I have more information.

It is being applied further down, to all sky lighting as a whole, not to SS color in particular. What troubles me is that means that skylight affects diffuse and SSS in a same way. I don’t think it should. I actually added additional sky weighting for SS color in response to my artist’s complaints about not being able to produce consistent look of objects with SSS under various lighting conditions.

Information about 4.12 might have been a bit misleading from me. I’ve implemented a change in response to my artist’s complaints about not being able to get expected look for SSS objects in overcast skies and difference between static and movable skylights. So might not be actually a newly introduced bug. Complaints about skylight overly affecting SSS materials are still fully valid though.

I’ve entered a bug to see what the developers say regarding this issue. You can track and vote on the issue by following the link below.

UE-44851

Thanks,

Andrew H.

Thanks Andrew.
The repro steps on the ticket seem to be wrong though.
If you uncheck affect world on skylight the scene everything goes black and it’s no longer visible how skylight is influencing the SSS.

They are correct, since I set the Skylight on by default in the test project provided. The point is to show the visual influence Skylights have when the are on vs. off so getting them to visualize either state is important. I updated the steps to also add switching between Stationary and Movable and comparing those results.

Actually both Stationary and Movable skylight result in the same wrong behavior so if they do that they wouldn’t see any visual different. As mentioned by @zeOrb only static Skylight with built lighting shows the correct result.