Search Unity

Resolved Using custom shaders on VFX Graph

Discussion in 'SRP Dev Blitz Day 2022 - Q&A' started by GeriB, Sep 28, 2022.

  1. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    193
    This question may also not belong here. But in any case: Why does VFX Graph only support Shader Graph custom shaders?

    I understand the shader needs some specific data/structure or whatever. But why don't give a sample and open the doors to custom hand written shaders too?

    Why keep the doors closed? It's okay if some people can't figure it out. Many people will, just like with any other feature. But keeping it closed to Shader Graph unless there's a big reason for it is very disappointing and limiting (I want to adapt my complex hand written shaders of my assets to work on VFX Graph).

    Thanks :)
     
    sabojako likes this.
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,

    This question can be compare to the question related to the support of surface shader in SRP. Writting a full custom shader for SRP or VFX can become quite complex (Really really complex) and in particular it make it non upgradable with more recent version in case we change internal of shaders between version. To allow to write custom shader and keep upgradability we need similar system then surface shader but for SRP and VFX. This is what is currently plan (you can get information from the other question in the others thread about this new surface shader system).
     
    GeriB likes this.
  3. Matjio

    Matjio

    Unity Technologies

    Joined:
    Dec 1, 2014
    Posts:
    108
    Hi @GeriB ,

    In shuriken, the CPU is directly providing an output mesh and a few specific parameters, and using a custom shader on this kind of geometry is pretty convenient and equivalent with shader on a general mesh.
    In the case of VFX, the input for rendering is simply a byte address buffer and some generated code (which comes from blocks declared in VisualEffect). The sampling of byteaddressbuffer use a complex layout which relies on attribute usage in VFX. For these reasons, the usage of custom shader in VFX can't be done easily.
    We are aware of users using a fully custom SRP or modifying the current one, adding new output (see template and output), but it relies on internal classes and it's completely undocumented at the moment.

    Maybe an interim solution is to use Shader Graph but with Custom Function Nodes to add the most complex hand written parts of your shader (on VFX Graph side we are working on custom HLSL blocks to more easily use hand written code inside of VFX Graph).

    On the long term, we are working on Block Shaders to streamline the workflow for authoring hand written shaders.

    It would be great if you could provide some use cases of what kind of functionalities you want to achieve that require complex hand written shaders? -Don't get me wrong, willing to use hand written shaders is already a very valid use case but the more concrete examples the more we have chances to improve the right things!

    -Mathieu
     
    GeriB likes this.