12. The maximum value of the function $f(x)=\sqrt{x^{4}-3 x^{2}-6 x+13}-\sqrt{x^{4}-x^{2}+1}$ is
$$
\begin{array}{l}
f(x)=\sqrt{x^{4}-3 x^{2}-6 x+13}-\sqrt{x^{4}-x^{2}+1} \\
=\sqrt{\left(x^{2}-2\right)^{2}+(x-3)^{2}}-\sqrt{\left(x^{2}-1\right)^{2}+x^{2}} .
\end{array}
$$

Let $P\left(x, x^{2}\right), A(3,2), B(0,1)$, then $f(x)=|P A|-|P B| \leqslant|A B|=\sqrt{10}$.
The equality holds when, solving the system $\left\{\begin{array}{l}y=x^{2}, \\ x-3 y+3=0\end{array} \Rightarrow 3 x^{2}-x-3=0 \Rightarrow x=\frac{1-\sqrt{37}}{6}\right.$.
Therefore, the maximum value of $f(x)$ is $\sqrt{10}$.