Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Keywords to enable/disable features of VFX graph

Discussion in 'Visual Effect Graph' started by cp-, Aug 30, 2022.

  1. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    78
    Hi,

    as the VFX graph gets compiled to a shader I wonder if it'd be possible to also use keywords to enable/disable certain features, like having shader variants.

    This way we could author a single feature-packed base graph and tick features on/off without the performance penalties of having all features in it.

    Right now I'm using my feature-packed graph as a base and manually cut features from it and save it the resulting graph "variants".
     
    Marie_G likes this.
  2. Marie_G

    Marie_G

    Unity Technologies

    Joined:
    Mar 9, 2021
    Posts:
    69
  3. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    324
    Hi as Marie said there's no keyword support in the graph UI yet but you should be able to enable/disable Shader graph keywords on renderer's material or as global keywords by script. For compute, using the boolean ports from 2022.2 can allow to efficiently skip some blocks.
     
    Last edited: Sep 19, 2022
  4. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    78
    Hi and thanks for your replies. Great to see there's partial support in future versions as @JulienF_Unity mentioned.
    If I understand the short paragraph in the release notes correctly the boolean ports can disable system nodes. Would this also disable evaluation of other nodes linked to the inputs of the disabled system nodes e.g. already create different variants?
     
  5. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    324
    Boolean ports are not creating variants. It's still a uber shader but the computation for disabled nodes are skipped (including evaluation of all nodes linkeds to their inputs). But the code is still there, just not executed. When done per vfx component, it's pretty efficient as the test is not divergent (the same path is taken by all particles in the system). Boolean port will only strip code, if a block is disabled statically (disabled in graph and enable state known at compil time so not exposed...)
     
    xiangshushu and cp- like this.