Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Particle casts full quad shadow when shader graph is used

Discussion in 'Visual Effect Graph' started by Qriva, Jun 26, 2023.

  1. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Unity 2022.3.3 URP - My custom shader provides alpha based on texture and some calculations. As you can see it works as smoke is correctly rendered, however when "cast shadows" is enabled in the vfx graph, it renders full quads to shadow map. This happens for both lit and unlit.

    upload_2023-6-26_18-18-58.png upload_2023-6-26_18-22-3.png
    On sidenote what is the correct way to enable/disable particle 'receive shadows' for unlit shaders? When shader is Lit there is checkbox in output context, but I wanted to use custom lighting and this checkbox is not there for Unlit shaders. Is it hardcoded or there is some keyword to make it work?
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,393
    Not sure about the shadow casting issue, but to receive shadows in unlit you need to use MAIN_LIGHT enums
     
  3. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    If you mean this one it's already there:
    upload_2023-6-26_19-17-46.png

    Also the funny part is that actually default Lit Quad without shader graph has no option to disable "receive shadows", but it's there if you plug Lit shader graph...
    In addition for some reason some options are sometimes visible and sometimes not - as example if you unplug output from the system half of the options disappear. I am really confused.
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,393
    I used this to receive shadows in my asset (could not read the exact entries).
    If that does not work I am not sure what is happening
    upload_2023-6-26_19-29-20.png
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    DevDunk likes this.
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,393
    Maybe a bug report gets a reply :/
    Or someone else drops by with a solution
     
  7. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Ok, something is really messed up, I made new default graph today using project context menu Create Visual Effect Graph. Sorting mode is missing.
    We added new Quad Output in that graph and connected exactly the same things and this is the result:
    image1.png image.png
    The first (B) output is the new one and it has sort mode available (and revert sorting checkbox), but "indirect draw" checkbox is missing for some reason xD
    On top of that the old (A) has "Cast Shadows" option twice, in two separate sections.
     
  8. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    134
    This setup looks unexpected and probably an issue with VFX & Shader Graph Integration.
    If you still have it, can you share this VisualEffectAsset and this Smoke Particle ShaderGraph ?

    Also, you can inspect the difference of VFX Planar Outpout using inspector debug mode the materialSettings content, this is an array of serialized property.
    upload_2023-6-27_10-25-44.png

    The status of these array is probably a good hint about the root cause of this issue.
     
    Qriva and DevDunk like this.
  9. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Correct, they are not the same, one has only two queue params, while the other has like 15, but in addition the first one has this:
    upload_2023-6-27_13-30-26.png

    I attached the package with the graph and stripped version of shader [URP 2022.3.3].
    To summarize, it should present following bugs:

    1. Particle casts quad shadow when shader graph is used
    2. Default Lit Quad without shader graph has no option to disable "receive shadows".
    3. Unplugged output (from update) loses a lot of options in the inspector (might be by design)
    4. Sometimes graph outputs are messed up, possibly caused by creation method - in result various options are missing, and in this specific demo: "indirect draw", "sort mode", "revert sort", or options are displayed twice like "cast shadows".
    5. There is no option to enable "receive shadows" when Unlit graph is connected, what make sense for standard unlit shader, but does not allow to implement custom light (even if correct keywords are added), or at least I don't know how to do it properly.
     

    Attached Files:

    PaulDemeulenaere likes this.
  10. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    134
    This "ghost" Sub Output is from HDRP (see this guid)
    upload_2023-6-27_15-43-57.png
    Have this file been migrated from HDRP to URP ? Or maybe in a project supporting both ?

    About 3., this is by design, VisualEffectAsset needs a live material to be able edit these settings, it isn't ideal in term of feedback, we are working on improving this.
    Otherwise, thanks for the exhaustive description, it looks like a bug, we are going to investigate.

    I'm not fully aware about the URP capabilities, you can compare the behavior with the same ShaderGraph applied on basic plane in the scene, if you observe the same behavior with a classic mesh renderer, it's either a bug in URP or an expected behavior. If VFX Output isn't consistent with the material displayed in scene, then, this is an issue you can report here.
     
    Last edited: Jun 27, 2023
    Qriva likes this.
  11. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    No, this project is only URP, the only thing that changed is the unity version, however I am 99% sure this graph was made in current version like 1-2 days ago.
    Makes sense, in this case the shadow shape might be simply caused by disabled alpha clip, but the receive shadows thingy is broken I guess. It looks like that unlit with my keywords receives shadows from other objects by default, but I want to disable this. There is keyword:
    #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
    , I assume this is the proper way to disable shadows, when I add this exposed in the graph it actually works for simple quad with renderer and material - I can turn on and off shadows. However exactly the same shader as particle produces black particles, but on top of that it completely breaks the inspector:
    upload_2023-6-27_16-51-19.png

    The thing is I suspect that even if inspector was not broken, I would not be able to mark the keyword checkbox to disable them.
     
  12. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Should I create bug report about inspector and shadows stuff, or it is already noted?
     
  13. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    134
    Hello,
    Sorry for the delay, it took me a while to understand what could have happened with your data but I finally nailed down the repro:
    • Open an URP project with VFX package installed
    • Create VisualEffectAsset
    • Create SG & enable "Support VFX Graph", save it.
    • Assign this SG to VFX Output
    • Observe empty "Surface Options" as expected in inspector of VFX Output
    • Go back to SG and now toggle the option "Allow Material Override", save it.
    • In VFX Output, observe "cast shadow" is appearing twice.
    This behavior has been fixed by a workflow improvement in 23.2 but still, this behavior is an issue for 22.2.
    You can track it here. As long as I'm at it, you have to be aware there are also a loss of data issue while switching pipeline in this version (see this issue)

    About your specific problem, you should be able to workaround changing any surface option and restore it.



    N.B.: The link I shared are not available yet ⏳
     
    Last edited: Jul 10, 2023
    Qriva likes this.
  14. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Thank you! Yes, changing blending in fact fixed the inspector. In this case there is only one issue left about the "receive shadows" option. Or actually not only shadows, but probably keywords in general.
    Is there way to make that work?
     
  15. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    134
    If I understand correctly this additional detail:
    This is about usage of not exposed shader keyword in shaderGraph when used in VFX, is it correct ?

    In that case, this is a known limitation you can track here (and if you are curious, this resolution was already in progress when Graphics repository was public, see here)
     
  16. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Well, it does not matter if this keyword is exposed or not.
    Is there any way to make it work, or at least is there any fix for this one on horizon?
     
  17. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    134
    The idea of this fix was to support, at least, not exposed keyword. In case of usage of global keyword or directly changing the local keyword on material, it can be helpful.

    The internal discussion about this change is still going on, we can't provide any ETA but so far, the resolution of this issue is still targeting 2023.2 and 2022.3.
     
  18. shaikhkaif157

    shaikhkaif157

    Joined:
    Apr 2, 2021
    Posts:
    1
    To not cast shadow just disable the "Allow Material Override" checkbox in shadergraph Graph Setting. This works for me.