5.8 Preview - Toon BSDF - Shadows cast on surface are blurry

Toon BSDF based materials cause fuzzy shadow appearance for shadows that land on Toon surfaces.

[Attachment Removed]

Hello,

Yes, we have by default in engine the shadow value that is squared to make it look less blurry, or to give it a “more reasonable look artistically” as commented on the super old ApplyPCFOverBlurCorrection function that has always been there it seems.

The problem is that this is applied to the transmittance function too since shadow in UE is in fact Visibility x Transmittance. And I did not like that since transmittance would otherwise not what it should be (less light would travel further into the mesh). Please note that this is actually the case in all of UE: what should be a physically based transmittance is actually not respected.

I wanted toon to have a correct transmittance so I decided to not apply that subjective and arbitrary correction factor. check out bApplyPCFOverBlurCorrection in ShadowProjectionPixelShader.usf. You can always set that to true if you want the same behavior everywhere.

[Attachment Removed]

With bApplyPCFOverBlurCorrection forced to true: [Image Removed]Current toon [Image Removed]

[Attachment Removed]

Hello,

I have clarified and fixed all that in https://github.com/EpicGames/UnrealEngine/commit/eef3f0de5c050521fd19362c6089abddcbc59445\. (it also fixes transmittance on toon to match between CSM and VSM)

I guess that is the CL you want to take, and always enable (or disable) ApplyPCFOverBlurCorrection for the shadow to match between toon and non toon.

[Attachment Removed]

Thank you! Ill pass this to our team see if its worth it

[Attachment Removed]

Hello!

We tried this in our build of 5.8 preview and did not get any change to the shadows like you’ve demonstrated.

Around line 331 in ShadowProjectionPixelShader.usf

[Image Removed]We did not see a difference, even forcing the bApplyPCFOverBlurCorrection to be true in all blocks resulted in no change.

We were only able to see a difference by using this cvar:

r.Shadow.Virtual.SubsurfaceShadowMinSourceAngle 0

Is there a step we missed?

[Attachment Removed]

Hi,

It looks like this is because you are using VirtualShadowMap and I forgot to check that. I had a look at it and I cam up with a fix:

[Image Removed]This will prevent to go a path where the light source is artificially enlarged in VirtualShadowMapProjection.usf:

		// Increases light source radius for subsurface material as the opacity reduces to emulates light diffusion.
		// TODO: Does something similar make sense for local lights?
		// Substrate: this approximation has no concrete foundation so it is currently skipped for Substrate using PerPixel SSS, e.g. when bDataIsOpacity==false and data is MFP.
		if (SubsurfaceOpacityMFP.bDataIsOpacity && SubsurfaceOpacityMFP.Data < 1.0f) 
		{
			const float SubsurfaceOpacity = SubsurfaceOpacityMFP.Data;
			Light.SourceRadius = max(Light.SourceRadius, (1.0f - SubsurfaceOpacity) * SubsurfaceMinSourceRadius);
		}

Right now I believe it is for the best to not have that for toon. So thank you for reporting!

Please note that this is not checked in yet since I noticed another visual difference between SM and VSM I also want to fix when I find the time.

I hope this helps

[Attachment Removed]

Do you think that fix will be in 5.8 release or upcoming hotfix?

And could if its possible to get a CL when the fix is in ?

If its planned to be fixed we can just wait and not mod it in

Oops I missed your reply outside this comment thread

[Attachment Removed]

Yes sorry for the confusion.

That is the CL yes. It is not going into 5.8 patch since toon is experimental and there is no crash or completely broken feature. But you can take that same change we have.

Thanks for your help!

[Attachment Removed]

Hello all, I’m struggling with this as well, but I see attachments have been removed from the solution. Anyway someone could explain what needs to be done? Thanks