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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

VFX Graph Question. Creating Drag effect with clouds

Discussion in 'General Graphics' started by Joshua_strawchildgames, Dec 20, 2018.

  1. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    Hello everyone, I've been exploring the new visual effects graph. So far I've been able to get some slick looking stuff. Basically I have an object that's supposed to be cold and emits fog, similar to liquid nitrogen. I've got the look down pretty well, except for when the object moves, the illusion is then broken.

    When the object moves, you can tell particles are spawning in, and is just ugly to see. I've been thinking through how to do it, and I believe if I can calculate the distance between the particle effect and it's originating position and it's target position, I'll be able to tell the object is moving, and use that resultant vector to either scale or add angular velocity, creating a drag effect. However, it seems I can't figure out which attribute to use, if there is one, to do this operation. I've tried "Get Attribute: position (Source)" but that doesn't seem to work because it can only be used in the Initialize context.

    So it seems that perhaps I'm missing something, or I just need another approach. What would you guys suggest I do to achieve the drag effect?
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,235
    We will be adding support for custom attributes in the future, so you will be able to define your own.

    For now, you are probably best hijacking an unused attribute for your needs, eg:

    - at the end of your Initialize, set the oldPosition attribute using position as the input
    - now you can access oldPosition in your update/output contexts, and it will contain the particle's initial position
     
  3. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    I tried this actually, but doesn't seem to have the effect that I was expecting. I guess now that I think about it, what I actually want is the originating point relative to the object at the time of update.

    For instance, the tip of a sword as a character swings it around (or any point of the sword that the particle spawns from, using a line position). I want to be able to get the relative distance between the spot on the sword the particle spawned from and the particle itself, then calculate the distance from the same point to the target position. With that information I can tell if the sword moved, and generate some velocity or scale effect to make the smoke look like it's smearing.

    I'll work on it a bit more again today, but any advice on that would be helpful.
     
  4. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    have you just tried emitting particles in world space and velocity inheritance?

    initial inheritance with over life curve or velocity dampen
    vs
    current inheritance (with steep drop off)

    either might allow you to draw interesting ribbons to emit atmospheric textures
    add noise module for increasing turbulence over time
     
  5. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    hmm, not sure if I understand what you are proposing. I'm not sure how inheriting velocity would solve this issue. Inherit what velocity? The source?
     
  6. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,235
    I think @Torbach78 was inadvertently giving advice about how to use the Particle System component, not the new Visual Effect Graph :)
     
  7. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    So I'm seeing a lot of things that just don't work the way I thought they would. For example, Spawn Event over Distance. I would expect that it would spawn over distance based on the emitter's position. But instead it's default position values is 0, 0, 0. Setting the position with "Get Attribute: Position" doesn't work either.

    Some documentation on how this works would be great, but all I can find is on github and it leaves much to be wanted. Unless there's some documentation that I'm not aware of.
     
  8. Joshua_strawchildgames

    Joshua_strawchildgames

    Joined:
    May 27, 2017
    Posts:
    60
    Okay, so I figured some things out. I found out that by using LocalToWorld builtin, I can get the position of the object. I figured this out by applying it to set or add velocity, and noticing that it doesn't move at 0, 0, 0, but at 0, 0, 1, the particles move in that direction. Interesting!

    This is a step in the right direction for me, so next I need to figure out how to store that position for the next update function, which is another problem. I couldn't think about how to store this data except for in the old position. If I set the old position before using it in the update function, it seems to work as intended. However setting the OldPosition at the end, by the next execution the OldPosition will be a different value. You can test this bet setting OldPosition to 0,0,0, put it at the end of update. Before the OldPosition, set or add velocity using the OldPosition. Notice that there is velocity.

    So it seems I still have a bit to go.