Search Unity

Bug Problems using shader graph in VFX graph in URP (no vertex shader + lighting on unlit shader)

Discussion in 'Visual Effect Graph' started by canmom, May 15, 2023.

  1. canmom

    canmom

    Joined:
    Nov 6, 2022
    Posts:
    7
    Hi, I'm having some difficulties with the shader graph integration in the VFX graph while using the Universal Render Pipeline.

    I have a shader graph with a vertex and fragment shader. The shader is set to target Universal, with "Support VFX Graph" toggled. From the documentation, this means I should have support for vertex shaders. There is an example in the VFX graph samples that has a working vertex shader in the VFX graph, though this is in HDRP, not URP.
    upload_2023-5-15_13-8-26.png

    In the VFX graph, I'm using this with a 'render particle URP lit mesh' node. When I add the shader graph to this node, the text at the top changes to 'Output Particle Unlit Mesh'.
    upload_2023-5-15_13-12-21.png

    I've encountered a number of problems.

    Firstly, although the shader is opaque, I must have alpha and alpha clip threshold alpha outputs, or the particle output does not compile. This is annoying but can be worked around.

    Secondly, the vertex shader stage, which is applying a displacement effect, does not seem to be working at all. Particles are rendered as if they do not have a vertex shader.

    Thirdly, while the fragment shader appears to run, the particle appears to have diffuse Lambertian lighting applied to it, even though the shader is supposed to be unlit. It is as if the output of the shader is treated as a URP base colour, and not the overall shader output.

    (I also tried starting with 'Output Particle Mesh'. This results in neither the fragment shader or vertex shader working, which is not surprising since I assume this output is for non-URP rendering.)

    Here is an example. On the left is a regular GameObject with the shader graph applied, with vertex displacement and cel shading. On the right is a single particle with the same model output by the VFX graph.
    upload_2023-5-15_13-17-46.png
    The model on the right has additional lighting and no vertex shader.

    Curiously, when I use the Output Mesh node, both the fragment and vertex shader appear to work correctly. Sadly, this output can't be used to render particles, which is what I need.

    I have experimented with various combinations of settings. For example, turning GPU instancing on or off. I have not yet found any combination of settings that gets the vertex shader to work, or the lighting to render unlit.

    I believe this is a Unity bug, but if anyone has seen this behaviour before and knows a combination of settings that will make the particles render properly, I would be very grateful to know about it! Otherwise I'll file a bug report.
     
  2. canmom

    canmom

    Joined:
    Nov 6, 2022
    Posts:
    7
    To make matters even stranger, while I was fiddling with shader graph nodes, the vertex shader abruptly started working. I am genuinely not sure what change made the difference, but it mighth have had something to do with getting the camera position and the screen position in the shader. I am now using a URP lit shader, but at first, the vertex shader was not working as before. I will keep testing and attempt to figure out what it is that makes the vertex shader activate.