Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Set velocity from sample texture 2d node

Discussion in 'Visual Effect Graph' started by youngsangcho, Jan 9, 2022.

  1. youngsangcho

    youngsangcho

    Joined:
    Jul 6, 2018
    Posts:
    4
    hello,
    I'm trying to set velocity from a series of optical flow textures created externally.
    I made the textures to default to 0.5 gray pixel as below so I expected to get 0 velocity by adding (-0.5, -0.5) to the sampled pixel color.


    These are my nodes. (I'm only using x and y axis on 2d)


    But once I apply this vector to 'Set Velocity' node in the Initialize Particle block, I get this diagonally moving particles. Instead, I expected them to stay still at the center.



    If I change the Add node value from -0.5 to -0.2 or something, it looks almost staying at the center, but it doesn't make sense to me. I even try to log the textures' pixel color in the script and it's 0.502. (-0.502 doesn't work either of course.)

    I think there must be some very silly mistake in my logic. Any idea?

    Best regards,
    Y
     

    Attached Files:

    Last edited: Jan 9, 2022
  2. peeweekVFX

    peeweekVFX

    Joined:
    Oct 19, 2015
    Posts:
    13
    Hello

    Your texture is most likely imported as sRGB (used to gamma correct color images) can you check that the sRGB checkbox is not enabled in tour texture asset inspector?
     
  3. youngsangcho

    youngsangcho

    Joined:
    Jul 6, 2018
    Posts:
    4
    Hello, thanks.

    Yes, it was imported as sRGB.
    I disabled the option but it still doesn't work as I expected.

    Attached is one of the optical flow image sequence I'm trying to read in VFX.

    Any idea?

    Best regards,
    Y
     

    Attached Files:

  4. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    Maybe it has something to do with texture compression? You can try disabling it.
     
  5. youngsangcho

    youngsangcho

    Joined:
    Jul 6, 2018
    Posts:
    4
    Thanks for the idea.
    I tried it, but it still doesn't work.

    I ended up sampling the 0.5, 0.5 color pixel at the corner and using it as mid value.
    It seems to work, but I still wonder what went wrong with the initial approach.