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

Resolved Color over lifetime not getting alpha

Discussion in 'Visual Effect Graph' started by raaan127, Aug 25, 2022.

  1. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    Hello, I am looking for a way to replicate VFX in VFX graph (which originally created using particle system) and stuck on this step:

    I add "Color over Life" module and set it to multiply
    but it seems to affect only the color of particle. and no transparency:

    upload_2022-8-25_15-40-44.png

    I use the same shader on both normal particle system and VFX graph:
    Here's the results: the bottom is normal particle and the top is made with VFX graph
    vfxgraph.gif
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    183
    Hey could You show you're ShaderGraph ? As it might be related to how you set up your ShaderGraph.
    Or you can share a small package with your VFXGraph so that I can take a look.
     
  3. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    Yes, please take a look
    deletedAttachment
     
    Last edited: Aug 25, 2022
  4. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    183
    Okay so I'm not totally sure of myself, but my quickly looking at it.
    You got a "Color" property in you Shader that you use to drive your particles.
    This Color property got 4 components. The first 3 define the color and the 4th is setting the Alpha.
    The VFXGraph part seems correct , but in your ShaderGraph you don't use the Fourth component of you color Property.

    You should use it somewhere in the "Alpha" part of your SGraph.
    Does it make sense?
     
  5. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    Ah yes. You're absolutely right!!!

    In particle system it get alpha from Vertex color (but I don';t know how to affect vertex color in VFX Graph so I modify the Color variable)

    Thank you very much. This solve the problem.
     
  6. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    183
    upload_2022-8-25_13-2-56.png upload_2022-8-25_13-3-51.png
    Here Are a very simple setup that might help you.
    As you can see the Color Property Wire Change Color from Pink to yellow.
    It means that the the Data is "Converted". Here From 4Float vector to 3F vector when going to the Base Color.
    The Fourth Component, that is Link to the Alpha Attribute in VFXGraph needs to be put in the "Alpha" output of the ShaderGraph.

    Hope this quick example help.
     

    Attached Files:

    Qriva and raaan127 like this.
  7. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    183
    Glad to hear that your problem is solve.
    VertexColor node should allow you to access the VertexColor of your Mesh.
    By default if you didn't created any VColor on your Mesh, this should Default to VertexColor of Pure White and Alpha 1.

    Here is a plane that have been subdivided. I've setup random Color and Alpha in the VertexColors in my DCC.
    I can Access this data in ShaderGraph and/or VFXGraph by using this VertexColor Node.
    upload_2022-8-25_13-24-34.png
    upload_2022-8-25_13-24-57.png

    my Plane Mesh in my DCC:
    upload_2022-8-25_13-25-56.png
     
  8. raaan127

    raaan127

    Joined:
    Dec 9, 2019
    Posts:
    31
    I got 1 more question that I forgot to ask:
    When I only put the shader above to a new Simple particle system (which using Output particle quad) and leave everything else as default, nothing is rendered

    It somehow only works on Output particle mesh + a quad mesh

    upload_2022-8-25_18-47-10.png
     
  9. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    183
    So the output particle Quad will "Render" Quad on your Particles position.
    This Quad have VertexColor = (0,0,0,0).
    So this is why it's not showing.
    In your ShaderGraph, you're using the VertexColor.Alpha and multiply other inputs by it to put in the Alpha.
    As the "Default" VFXG Quad have vertexColor of (0,0,0,0) , you're quad Won't Show...
    But with the Mesh Output, the "Quad" mesh seems to have vertexColor of (1,1,1,1).
     

    Attached Files:

    raaan127 likes this.