Search Unity

Getting particle strip vertex color in Shader Graph for VFX Graph

Discussion in 'Visual Effect Graph' started by customphase, May 6, 2020.

  1. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    For regular particles you can get particle color by using vertex colors (at least according to this https://forum.unity.com/threads/how-use-vertex-colors-with-vfxgrapth.834481/, havent tried myself), however for particles strips this doesnt work. Judging by the generated code, the color is stored as a separate attribute, and vertex colors are simply blank. How should i go about getting the strip color in the shader graph? Im on version 7.3.1
     
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    vertex color fetch in shader graph would be vertex colors stored in the vertex buffer in the mesh used in the mesh output, it's not the color set in the particle color attribute. If you want to pass the particle color attribute to the shader graph, you need to expose a property in your shader graph which will automatically create a slot in your output in vfx graph, then just plug the particle color attribute to it (or whatever you want)
     
  3. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    Awesome, didnt know about that, managed to get it working. Thanks for the quick reply!

    If anyone else is having troubles, heres the setup

    upload_2020-5-6_20-26-14.png
     
    Last edited: May 6, 2020
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    Just stumbled upon this problem, I thought that vfx color is a vertex color, but it looks like it is not.

    So how it is done in build in vfx shaders ?
    It would be advisable to add node that would get VFX color to vfx shader graph, so we can just swap shaders without reconnecting nodes or even thinking about color.
     
  5. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    Hi, we don't use vertex color for particle color as in case of mesh particles, you may still want to acess vertex and particle color. At the moment to pass particle attributes to shader graph, you have to do it explicitely as explained above. The only thing that is implictely passed per particle to shader graph is the local transform (which is the particle transform). We have plans to improve the workflow in the future. We still have to discuss the best way. Could be some naming convention in SG exposed properties or some more UI onvolved solution
     
    Last edited: Mar 1, 2022
    koirat likes this.