Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Globally suppress pow(f,e) negative f warning

Discussion in 'Universal Render Pipeline' started by CianNoonan, Sep 3, 2020.

  1. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    How can I suppress this warning, I get many of them spammed on each compilation of my shaders.

    The warning even says it is only a suggestion, in many cases, I'm not concerned with negative values and don't wish to add an abs here.

    Shader warning in 'ShaderName': pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them at line XXXX (on d3d11)
     
    bobbaluba likes this.
  2. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    164
    Hey!
    Are you getting those warnings from your own custom shaders or?
     
  3. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    Yeah, these are from custom shaders I have authored using AmplifyShaderEditor. I have attached a culprit
     

    Attached Files:

  4. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    164
    I see. Well you can follow what the warning gives you and place a abs() around the first parameter put into the pow() function calls (I count 7 pow() calls in that shader) if you're sure it won't break anything.
     
  5. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    That's a pretty poor suggestion as it changes the semantics of the shader.

    I can make my own copy of the template file from ASE, then recompile all my shaders via ASE to updating it to the abs/clamped etc input. Though in this case, I do not care about negative values, the warning even says "if you expect them" which I don't.

    Ideally, Unity wouldn't implement developer assists that can result is so much crap going into the console with no straight forward option to take. In this case, the ideal solution is to exclude this warning from ever logging, something I can do in c# but not shaders
     
    PrimalCoder and bobbaluba like this.
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    Hi!
    Can you try adding #pragma warning (disable : 3571) in an include file?
     
  7. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    Yep, that has suppressed the warning immediately, perfect!
     
    aleksandrk likes this.
  8. UBayir

    UBayir

    Joined:
    Feb 4, 2015
    Posts:
    24
    I had no idea we could suppress warnings like this. You're a life lifesaver.
    Many Thanks
     
  9. UBayir

    UBayir

    Joined:
    Feb 4, 2015
    Posts:
    24
    Is there any chance you also know the "Implicit Truncation of vector type" warning code to disable.
    I searched but couldn't find it on the internet.
     
  10. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Just to add that abs() has zero cost in shaders, because it isn't an actual instruction but a flag passed to other instructions which tells them to drop the sign. Same for saturate().
     
    adamgryu likes this.
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    I wouldn't suggest doing that - it hides potential bugs.
    But if you really want it - sure, it's warning 3206.
     
    UBayir likes this.
  12. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    @aleksandrk is there somewhere list of all warning codes?
     
  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    Likely :)
    It should be somewhere in Microsoft docs. You can try and search for FXC and/or DXC warnings list.
     
    UBayir and rz_0lento like this.
  14. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
  15. Dustyroom

    Dustyroom

    Joined:
    Sep 23, 2015
    Posts:
    108
    Is there a way to suppress warnings coming from a shader graph?

    I've tried out creating a custom node with `#pragma warning disable` but no luck.
     
  16. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    You have to put these in an include file.
     
  17. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437

    hello sir
    similar subject
    do you have one to disable "automatically setting target of LOD_FADE_CROSSFADE to 3.0"

    cheers
     
  18. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    Nope :)
    This one comes from Unity, not from the HLSL compiler we use.
    However, you can set
    #pragma target 3.0
    in the pass code - it will stop complaining then.
     
  19. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437

    yup i know its harmless
    in 2019.4.14 standard even setting shader model 3.0 does not stop it :(
     
  20. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    Oh, yeah, I see, it's added unconditionally...
    If it really bothers you, please submit a bug report, and we'll fix this.
     
    DEEnvironment likes this.
  21. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437

    thank you it is filed in Case 1358042


    cheers thank !!!
     
    aleksandrk likes this.
  22. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    705
    How would I include that in Shadergraphs?
     
  23. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    I don't know if Shadergraph has such functionality out of the box. Try searching the forums or asking in the subforum for Shadergraph.
     
  24. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    in SG i would suspect if it does not have a way to add it you could just use a saturate or a few max nodes to insure it does not nan
     
    Moritz5thPlanet likes this.
  25. UBayir

    UBayir

    Joined:
    Feb 4, 2015
    Posts:
    24
    Thank you for the error code and the warning itself. If I use it, I will only use when I finished the shader and also when I am sure the truncation is not a problem anyway.
    Thanks again
     
  26. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437

    a follow up to show progress
    they will close the ticket without fixing as they say we can clear the warning thru the clear option in console
    I only wish Unity had more people like you sir,, as some of them just don't seam to have pride in the work at the same level ... thank you for trying to help, Cheers

    --------------------------
    Hi,

    This warning, just like it says in the information you sent, is harmless. This warning is meant to show what is happening upon activating LOD Crossfade for the first time. If you turn it on and press Play, you will get that warning, but if you clear the console and leave Play mode, you won't get that same warning anymore. However, I've attached a video showcasing how you can stop warnings from showing up on your console. It's a toggleable option so you can turn it on and off on your whim. That being said, we will be closing this case and if the solution does not suffice regarding your issue, don't hesitate to contact us again and we will reopen this case. That being said best of luck with your projects!

    Thanks,
    xxxxxxxxxxxxxxxx
    Customer QA Team
    --------------------------
     
  27. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040
    O_O
    Can you please give me the case number? :)
     
    sabojako likes this.
  28. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    if its still open Case # 1358042
     
  29. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,040