4. There is a light source at point $P$ on the ceiling of the room, and the projection of $P$ on the ground is $Q$. A square pyramid $S-A B C D$ (with base $A B C D$ touching the ground) is placed on the ground. It is known that the height of the square pyramid $S-A B C D$ is $1 \mathrm{~m}$, the side length of the base $A B C D$ is $\frac{1}{2} \mathrm{~m}$, $Q$ lies on the line $A C$, and the distance from $Q$ to the center $O$ of the square $A B C D$ is $3 \mathrm{~m}$, and $P Q=3 \mathrm{~m}$. Then the area of the shadow of the pyramid is
4. $\frac{3 \sqrt{2}-1}{8} \mathrm{~m}^{2}$.

As shown in Figure 2, connect $P S$ and extend it to intersect line $A C$ at point $R$, then connect $R B$ and $R D$.

Thus, the concave quadrilateral $R B A D$ is the shape of the shadow, and its area is the area of the shadow we are looking for.
Given $S O=1, P Q=3, O Q=3$, we can get $R O=\frac{3}{2}$.
Then $R A=R O-O A=\frac{3}{2}-\frac{1}{2} \times \frac{\sqrt{2}}{2}=\frac{6-\sqrt{2}}{4}$.
Therefore, $S_{\text {quadrilateralRRAD }}=2 S_{\triangle R R A}$
$$
=2 \cdot \frac{1}{2} R A \cdot A B \sin 135^{\circ}=\frac{3 \sqrt{2}-1}{8} \text {. }
$$