Decal Angle Fade not working

Hi, I’m using Unity 2020.2.1f1 with the new Decal Projector feature to do angle fading based on the angle between the decals direction and the surface. I need this feature to prevent incorrect projection of decals on surfaces like in the image I sent.

I’ve enabled Decal Layers in my HDRP asset which allows me to use the Angle Fade slider, however when I adjust this slider I see nothing happen. The decal always still projects fully in all directions, this happens with any decal material including the default one.

Not sure if this is a bug or if I’m missing something, help would be appreciated thanks :slight_smile:

1 Like

I’m seeing the same, no matter what I change the Angle Fade slider to I can’t see any difference, also have enabled layers in the HDRP asset.

Works here for me, do make sure you also have Decal Layers enabled on your frame settings. You have to enable it on both HDRP asset and the frame settings!

To change this for all cameras, go to Project Settings → HDRP Default Settings and it’s listed quite quickly in Default Frame Settings for Rendering.

3 Likes

We should probably add it to the little warning too I guess. Thanks for pointing it out.

Any way to get this working in a custom decal shader?
Angle Fade works for me, when using the default decal shader, but in my custom shader, the slider does not affect the alpha.

Edit: if I turn the max value way down, it seems to be working, I have no idea why but I am fine with it.
If I increase the max value of the slider, everything becomes visible, min value on 0 of course.

Settings in HDRP are always a bit scattered… Hope this helps.


1 Like

In 2022.3.0f1, I found that Angle Fade only works if the projector has its Scale Mode set to Scale Invariant.

In ShaderPassDecal.hlsl, the decalNormal should be normalized before calculating dotAngle.

if (angleFade.y < 0.0f) // if angle fade is enabled
{
    half3 decalNormal = normalize(half3(normalToWorld[0].z, normalToWorld[1].z, normalToWorld[2].z));
    half dotAngle = dot(normalWS, decalNormal);
    // See equation in DecalCreateDrawCallSystem.cs - simplified to a madd mul add here
    angleFadeFactor = saturate(angleFade.x + angleFade.y * (dotAngle * (dotAngle - 2.0)));
}
2 Likes

Thanks for reporting and fixing it.
This indeed seems legit, I logged this so it can be fixed in all the appropriate versions.

You can track it there.

Hi,
This problem with angle fade have already be fixed in latest version of 22.3 and 21.3
thanks for the notification

I am still having this problem even with 6.0.41f. To be clear, the issue is specifically that decal angle fade is broken when using ‘Inherit from Hierarchy’. @kuo_minghsun fix seems to fix the issue, I’m curious if I’m doing something weird or if this does indeed still exist as an issue?

Thanks, I’ll have a look ! :slight_smile:

Do you have a simple repro on hands ? I tried looking at it (given that the “normalize” is still not in the code) but didn’t managed to repro on a simple case. On my side inherit or scale Invariant gives the same result.

Sorry, missed this! I’ll try and get a simple repro going

1 Like

Yeah, I’m seeing this not working with hierarchy scaling either.

Unity 6000.1.2f1. URP.