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

How To Use SetAlphaFromMap

Discussion in 'Visual Effect Graph' started by Glurth, Jul 29, 2020.

  1. Glurth

    Glurth

    Joined:
    Dec 29, 2014
    Posts:
    109
    Basically, I'm having trouble getting the alpha channel from my attribute map texture.
    I'm using the SetAlphaFromMap block (in the initialize context)... but it seems to use the Red channel of the attribute map's texture, rather than the Alpha channel. How can I make it such that it uses the Alpha channel instead?

    Attempted workarounds
    : I've tried to use my own "spawnIndex to UV" functions to generate an input for the SampleTexture block, so I could PICK the channel to use... but I kept running into weird problems. A reference to a known good one would be a good workaround for this question!

    Details of what I have:
    Here is the simple diagram of the current VFX graph. (which doesn't work exactly right- positioning is great, but alpha is based on R, rather than A).

    upload_2020-7-29_11-23-5.png

    The input texture "PosTex" holds the XYZ of a normalized direction vector in the RGB channels, and another value, "brightness", in the A channel. For testing though, I just set this A value to 0.5f for each pixel of the texture.

    As you can see in this shot of the output... the alpha has the same value as (pre-bias)X, not the 0.5f I put in as a test.

    upload_2020-7-29_11-26-48.png
     
  2. Glurth

    Glurth

    Joined:
    Dec 29, 2014
    Posts:
    109
    Extra info: here is my attempt at generating a UV from a spawnIndex.
    upload_2020-7-29_12-37-47.png

    I'm not sure why- but it looks like it's generating an already-used UV for SOME spawnIndexes:
    upload_2020-7-29_12-44-26.png
     
  3. Glurth

    Glurth

    Joined:
    Dec 29, 2014
    Posts:
    109
    Edit: I found the problem with my index to UV function... I needed to add half a texture-pixel worth of UV for it to map properly (found on another post)
    upload_2020-7-29_14-33-59.png