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 [SOLVED] How to get VFX blocks parameters in custom VFX shader?

Discussion in 'Shader Graph' started by sergiusz308, Jan 26, 2020.

  1. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    234
    Hi there, I created a custom VFX Graph shader with Shader Graph but I can't access VFX block parameters in there.

    For example, there's a "Set Alpha" block in VFX graph which is completely ignored when using custom shader.

    In order to get alpha fading out over life time I need to manually re-create it in the custom shader, in Shader Graph.

    Is this a way to go or I am missing something?

    upload_2020-1-27_0-27-36.png

    Thanks,
    S.
     
  2. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    234
    Anyone? Is there any other way to access VFX blocks parameters from custom shader?

    @alexandral_unity C'mon guys, little help, considering very basic documentation...
     
  3. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    VFX blocks are not accessible from the Shader Graph. To do what you want, you need to expose a property on the blackboard and plug it in to the alpha, then perform your calculations in the VFX graph and feed the output to the shader (the slots will appear where you see the texture 2d slots).
     
    sergiusz308 likes this.
  4. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    234
    OK, so for everyone looking for this, based on Alexandra reply I did it following way:

    upload_2020-2-6_14-33-56.png

    There's built-in alpha control block from VFX, where I set up particle-wise parameters for alpha, i.e. "Set Alpha over Life"

    Then there's "Get Attribute" for alpha, which is connected to the property exposed in my shader, i.e. "In Alpha over Lifetime"
     
    makkenr95 and Ohmydumbledear like this.
  5. Ohmydumbledear

    Ohmydumbledear

    Joined:
    May 16, 2017
    Posts:
    7
    Hey! Thank you so much for following up on this post, was a huge help for me today! Crazy, cause it's pretty straightforward, but I would have never thought of doing that, so thank you!