Search Unity

Decal Angle Fade not working

Discussion in 'High Definition Render Pipeline' started by ventz, Jan 20, 2021.

  1. ventz

    ventz

    Joined:
    Sep 12, 2017
    Posts:
    3
    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 :)
     
    Camarent likes this.
  2. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    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.
     
  3. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    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.
     
    DGordon, chap-unity and Camarent like this.
  4. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    We should probably add it to the little warning too I guess. Thanks for pointing it out.
     
  5. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    650
    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.
     
    Last edited: May 6, 2021
  6. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    135
    Settings in HDRP are always a bit scattered... Hope this helps.
     

    Attached Files:

    Last edited: Jan 9, 2022
    Draganovaaa likes this.
  7. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    80
    In 2022.3.0f1, I found that Angle Fade only works if the projector has its Scale Mode set to Scale Invariant.
     
  8. kuo_minghsun

    kuo_minghsun

    Joined:
    Dec 5, 2022
    Posts:
    1
    In ShaderPassDecal.hlsl, the decalNormal should be normalized before calculating dotAngle.
    Code (CSharp):
    1.  
    2. if (angleFade.y < 0.0f) // if angle fade is enabled
    3. {
    4.     half3 decalNormal = normalize(half3(normalToWorld[0].z, normalToWorld[1].z, normalToWorld[2].z));
    5.     half dotAngle = dot(normalWS, decalNormal);
    6.     // See equation in DecalCreateDrawCallSystem.cs - simplified to a madd mul add here
    7.     angleFadeFactor = saturate(angleFade.x + angleFade.y * (dotAngle * (dotAngle - 2.0)));
    8. }
    9.  
     
    Liam2349 likes this.
  9. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    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.
     
  10. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,
    This problem with angle fade have already be fixed in latest version of 22.3 and 21.3
    thanks for the notification