You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This note explains how the freeform stretching and rotate with stretch features in Unity's Shuriken ("Legacy") particle system work. It may be useful for those who want to duplicate the effect on the GPU, via Unity's VFX Graph or otherwise. These formulas were obtained through experimentation and, while they seem algebraically equivalent to what Shuriken does, are not the exact operations that Unity uses.
Vector projection of $V$ onto $U$ is notated as $\mathrm{proj}_U(V) = U\frac{V \cdot U}{U \cdot U}$. The magnitude of a vector $V$ is denoted with $||V|| = \sqrt{V \cdot V}$. A normalized vector is notated with $\hat V = \frac{V}{||V||}$.
All these operations are in particle space. That is, we assume that the particle is centered at the origin $(0, 0, 0)$, with its normal facing the +Z direction, with +Y being the particle "up" vector (i.e. $-v$ in $uv$ texture space with the origin at the upper left corresponds with +Y in particle space). If necessary, rotate and translate the camera as necessary to move it from world space to particle space before beginning. Assume particle space has an orthonormal basis.
Let $C$ be the position of the camera relative to the origin (i.e. relative to the particle center). Let $U$ be the up vector for the camera (which may not be $(0, 1, 0)$ if the particle has been rotated around its normal). Then define the basis vector $Z_0$:
$$
\begin{align*}
Z_0 &= -\hat C \\
\end{align*}
$$
Let $s$ be the size of the particle and $\ell$ be the length scale of the particle. Then the basis vector $Z$ is:
$$
Z = s^2(\ell Z_{0x}, \ell Z_{0y}, Z_{0z})
$$
If rotate-with-stretch mode is not enabled, then define the vectors $X_0$ and $Y_0$ as follows: