Shadow Generation Using Diffusion Model with Geometry Prior

Haonan Zhao, Qingyang Liu, Xinhao Tao, Li Niu, Guangtao ZhaiCVPR 2025 · DOI

TL;DR

This paper introduces GPSDiffusion, a novel method that significantly improves the geometric realism of shadows generated by diffusion models for image composition. By incorporating predicted bounding box and shape priors into a ControlNet architecture, GPSDiffusion achieves state-of-the-art results in generating shadows that are not only visually plausible but also geometrically accurate.

What Problem Does This Paper Address?

Image composition, the process of seamlessly integrating a foreground object into a background image, is crucial for applications like filmmaking and digital art. A key challenge in achieving realistic composite images is the generation of accurate shadows for the inserted foreground object. While recent diffusion-based methods have excelled at generating visually appealing shadows, they often struggle with geometric accuracy, leading to unnatural shadows in complex scenarios. This paper aims to bridge this gap by enhancing diffusion models with explicit geometric priors to produce more geometrically faithful shadows.

Methods

The proposed method, GPSDiffusion, operates in two stages:

  1. Geometry Prior Prediction: A multi-task geometry encoder is employed to predict two types of geometric information for the foreground shadow:
  2. Rotated Bounding Box Regression: Instead of a simple axis-aligned box, the encoder predicts a rotated bounding box that better captures the orientation of the shadow. This is achieved by learning regression coefficients that map the foreground object's bounding box to the shadow's bounding box.
  3. Matched Shadow Shape Retrieval: To address the difficulty of directly predicting complex shadow shapes, the method converts this into a retrieval problem. A shape auto-encoder is trained to reconstruct shadow shapes, and its bottleneck features are clustered. For a given foreground object, the encoder predicts probabilities for these clusters, allowing for the retrieval of the top-K most plausible shadow shapes.
  4. Geometry-Guided Diffusion Model: The predicted geometry priors are then integrated into a diffusion model, specifically using ControlNet as the base.
  5. The rotated bounding box is converted into a binary mask and concatenated with the input image, guiding the ControlNet encoder.
  6. The retrieved shadow shape embeddings are injected into the denoising U-Net via new cross-attention layers, informing the generation process with specific shape characteristics.

Datasets

  • DESOBAv2: Used for both training and evaluation. This dataset is described as having drawbacks compared to DESOBA, but is used here for consistency with prior work. It includes both BOS (background object-shadow pairs) and BOS-free images.
  • Real composite images: Used for qualitative evaluation, constructed from backgrounds and foregrounds from the DESOBA test set.

Key Insights and Ideas

  • Geometry is Key for Realistic Shadows: The paper strongly emphasizes that while appearance is important, geometric accuracy is the primary bottleneck for realistic shadow generation, especially in challenging cases.
  • Shadow Shape as a Retrieval Problem: Framing shadow shape generation as a retrieval task, rather than direct prediction, is an effective way to handle the inherent ambiguity and complexity of shadow shapes.
  • Leveraging ControlNet for Geometric Guidance: Integrating geometric priors (bounding box and shape embeddings) into ControlNet's architecture provides a powerful mechanism to guide the diffusion process towards geometrically accurate outputs.
  • Rotated Bounding Boxes Matter: Explicitly predicting rotated bounding boxes, rather than axis-aligned ones, significantly improves shadow localization and alignment.

Key Results

  • Quantitative Improvements: GPSDiffusion achieves state-of-the-art results on the DESOBAv2 dataset, particularly outperforming baselines on BOS-free images, indicating its robustness even without explicit object-shadow pairs. It shows superior scores in Global BER (GB) and Local BER (LB), suggesting more accurate shadow masks.
  • Qualitative Superiority: Visual comparisons (Figure 3 and Figure 6) demonstrate that GPSDiffusion generates shadows with more precise geometry, better alignment, and more delicate details compared to existing methods, which often produce shadows with imprecise geometry.
  • User Study Validation: A user study with 50 human raters indicated that GPSDiffusion generates the most reasonable shadows and aligns best with human visual perception.
  • Ablation Studies: Experiments confirm the effectiveness of each component: the rotated bounding box prior is superior to a non-rotated one, and the shadow shape embeddings significantly contribute to the overall performance.

Limitations and Future Work

  • Limitations: The paper acknowledges that while diffusion models are powerful, they can still struggle with complex cases. The effectiveness of the geometry encoder relies on the quality of the training data and the learned prototypical shapes.
  • Future Work: The paper implicitly suggests that further exploration of more sophisticated geometry priors or more advanced integration mechanisms with diffusion models could lead to even greater improvements. The current work focuses on improving geometric accuracy, and future work could explore finer control over shadow appearance attributes in conjunction with geometry.

Summary updated

BibTeX
@inproceedings{zhao2025shadow,
  author = {Haonan Zhao and Qingyang Liu and Xinhao Tao and Li Niu and Guangtao Zhai},
  title = {{Shadow Generation Using Diffusion Model with Geometry Prior}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00712},
}
Figure