6. Given $f(x)=(\sin x+4 \sin \theta+4)^{2}+(\cos x$ $-5 \cos \theta)^{2}$, the minimum value of $f(x)$ is $g(\theta)$. Then the maximum value of $g(\theta)$ is
6. 49.

For $f(x)$, expanding and rearranging yields
$$
\begin{aligned}
f(x) & =8(1+\sin \theta) \sin x-10 \cos \theta \cdot \cos x \\
& -9 \sin ^{2} \theta+32 \sin \theta+42 \\
& =\sqrt{64(1+\sin \theta)^{2}+100 \cos ^{2} \theta} \\
& \cdot \sin (x+\varphi)-9 \sin ^{2} \theta+32 \sin \theta \\
& +42 . \\
g(\theta) & =-\sqrt{6} 4(1+\sin \theta)^{2}+100 \cos ^{2} \theta \\
& \cdots-9 \sin ^{2} \theta+32 \sin \theta+42 \\
& =-2 \sqrt{-9 \sin \theta+32 \sin \theta+41} \\
& -9 \sin ^{2} \theta+32 \sin \theta+42 .
\end{aligned}
$$

Let $t=\sqrt{-9 \sin ^{2} \theta+32 \sin \theta+41}$,
then $0 \leqslant t \leqslant 8$.
$$
g(\theta)=t^{2}-2 t+1=(t-1)^{2}, 0 \leqslant t \leqslant 8 .
$$

Thus, $g(\theta)_{\max }=(8-1)^{2}=49$.