0 like 0 dislike
39 views
The given solution for non-uniformally scaled sprites (ensure the SizeField is a float2) seems to stop working as soon as a sprite's Billboarding mode is set to any of the "Velocity Align" options.

How can I have non-uniformally scaled sprites that are still velocity-aligned? Before you ask, I do not want my sprites to scale relative to velocity (I would prefer to maintain control over my proportions).

Can this be done?

-J
asked by SevenCubed (200 points)
I'm sorry, I've been unclear. Again, I don't want velocity to factor in here.

What I'm looking for is to have particles orient in the direction of their velocity _and_ be able to independently control their X and Y scale.

In this instance, my Billboard mode is set to VelocitySpheroidalAlign, my AxisScale is set to 0 (I don't want to change shape relative to velocity), and my Size is a float2 (1,0.1). It's rendering squares with a size of 1.

The expected behaviour is that it would render rectangles with a size of (1,0.1), orienting the particle in the direction of motion. Are my assumptions incorrect?

-J

1 Answer

1 like 0 dislike

Hi,

The "Velocity*Aligned" billboarding modes are actually a misnomer inherited from old versions of popcorn.

You can specify any axis, not just velocity.

So, to do what you want, just create a new float3 particle field named "StretchAxis" or whatever, add an evolve script after whatever evolvers modify the particle velocity (for example, the physics evolver), and do:

float myStretchFactor = 0.1234;
StretchAxis = safe_normalize(Velocity) * myStretchFactor;

And that should do the trick.

Cheers,

answered by Julien (32.2k points)
The Email may not have notified you of my comment (which posted onto my question but not your response), but your solution doesn't address my initial issue? I want to dynamically adjust X and Y scale independent of velocity, but I still want sprites oriented in the direction of their motion.
Ah sorry, indeed I didn't get any notification.

Yes my solution does adress your issue as I understand it.
It will not change the size based on the *speed*, only keep the direction.
that's what the "safe_normalize(Velocity)" does, it removes the scale from the velocity vector and returns a unit-vector (length=1) which has the same direction as the velocity. (unless the velocity is zero, or extremely small, it doesn't normalize it and returns zero (that's why I used "safe_normalize" and not "normalize", which assumes the input isn't zero))

Therefore, if you set this as the stretch axis of the billboard, it will get aligned along that direction, but with a length of 1.
If you scale back that axis with whatever actual size you want (like, 0.1), you'll get a vector of length 0.1, and with the same direction as your particle is traveling.
if you set the axis scale to zero, it will multiply the stretch axis by zero, giving the billboarders an "axis" vector of value { 0, 0, 0 }, which is, by definition "no direction", so the billboarder will have to make an arbitrary choice in that case on how to billboard it, and you will have _no_ way with an axis scale of zero to tell it which direction to face.

Furthermore, if given a float2 size, the axial billboarders will ignore the 'y' component, and only use the 'x' (so yeah that's not what you'd expect).

That's why the example I gave includes the 'y' axis scale as a multiply after the normalize.

So:
- make sure you set the billboard renderer's "axisScale" to precisely 1
- In your evolve script, do:
    StretchAxis = safe_normalize(Velocity) * myFloat2Size.y;
- in your billboard renderer, reference "StretchAxis" as the "AxisField"
I'm so sorry for the miscommunication! The AxisScale to precisely 1 was the problem I was having; I'd thought the stretch was stuck! I also got confused b/c changing the Y axis means changing the MyStretchFactor variable, which had thrown me.  Thanks again for your help with all of this and your patience!

-J
No problem ! it's not really obvious, and nothing tells you the 'y' component of a float2 size will be ignored :/
...