2. The difference between the maximum and minimum values of the function $f(x)=|\sin x|+\sin ^{4} 2 x+|\cos x|$ is $\qquad$ .
2. $\sqrt{2}$.
$$
\begin{array}{l}
\text { Given } f\left(\frac{\pi}{4}+x\right) \\
=\left|\sin \left(\frac{\pi}{4}+x\right)\right|+\sin ^{4}\left(\frac{\pi}{2}+2 x\right)+ \\
=\left|\cos \left(\frac{\pi}{4}+x\right)\right| \\
=f\left(\frac{\pi}{4}-x\right) \left\lvert\,+\sin ^{4}\left(\frac{\pi}{2}-2 x\right)+\right. \\
=
\end{array}
$$

we know that the graph of $f(x)$ is symmetric about the line $x=\frac{\pi}{4}$.
It is also easy to see that the smallest positive period of $f(x)$ is $\frac{\pi}{2}$, so we only need to consider the case where $0 \leqslant x \leqslant \frac{\pi}{4}$.
When $x \in\left[0, \frac{\pi}{4}\right]$,
$$
\begin{aligned}
f(x) & =\sin x+\sin ^{4} 2 x+\cos x \\
& =\sin ^{4} 2 x+\sqrt{2} \sin \left(x+\frac{\pi}{4}\right) .
\end{aligned}
$$

Since $\sin ^{4} 2 x$ and $\sin \left(x+\frac{\pi}{4}\right)$ are both increasing functions on $\left[0, \frac{\pi}{4}\right]$, then $f(x)$ is an increasing function on $\left[0, \frac{\pi}{4}\right]$. Therefore,
$$
f(x)_{\max }-f(x)_{\min }=f\left(\frac{\pi}{4}\right)-f(0)=\sqrt{2}
$$