When Prompting Can't Fix the Problem
There are composition problems in AI art that prompting cannot solve. The foreground element always ends up centered when you need it left. The horizon keeps landing at the wrong height. Background elements crowd the subject no matter how many descriptors you add. Depth relationships between layers are flat when you need clear separation.
These are structural problems. Text prompts influence what content appears and in what style, but they have limited control over precise spatial arrangement. When you need a specific compositional structure, ControlNet with a depth map is the right tool.
What ControlNet Actually Does
ControlNet is a neural network extension for Stable Diffusion (and SDXL) that conditions the generation on an additional input image, rather than just text. Instead of the model making all spatial decisions from the prompt alone, ControlNet provides a structural reference that constrains the spatial arrangement of the output.
There are several ControlNet types: pose (for figure position), canny edge (for hard structure preservation), lineart, and depth, among others. Depth maps are specifically useful for controlling the three-dimensional layering and spatial arrangement of a scene, which makes them the most relevant type for compositional control of environments, cityscapes, and atmospheric scenes.
What a Depth Map Is
A depth map is a grayscale image where brightness represents distance from the camera. Lighter areas are closer to the viewer. Darker areas are further away. This encoding gives the model a spatial instruction that describes not just where elements are in the 2D frame but how they relate in three-dimensional space.
When you feed a depth map into ControlNet, the model uses it as a structural blueprint. Generated content that is spatially close to the camera will appear in the lighter zones. Background content will appear in the darker zones. The layering, foreground-to-background separation, and depth relationships in the output will broadly follow the depth map.
How to Create a Depth Map for Composition Control
You have three practical options for creating a depth map:
Option 1: Extract a depth map from an existing image. Use the ControlNet preprocessor (MiDaS or ZoeDepth) built into ComfyUI or Automatic1111 to analyze any image and extract its depth structure. This is useful when you have a reference composition you like and want to use its spatial structure while generating completely different content and style.
Option 2: Paint a depth map manually. Open a canvas (Photoshop, Affinity Photo, GIMP, or even a basic paint tool) at the same resolution as your target output. Paint in grayscale: white where you want foreground elements, progressively darker grays for mid and background layers, black for the most distant background. This is faster than it sounds for simple compositional structures and gives you precise control over exactly what you want.
Option 3: Use a 3D scene or reference render. More advanced workflows use simple 3D scenes rendered in Blender or other tools as depth reference sources. This is overkill for most use cases but produces precise spatial control for complex architectural or environmental compositions.
Setting Up a Depth ControlNet Workflow in ComfyUI
The basic workflow structure:
- Load your base model (SDXL or SD 1.5, matching your ControlNet model)
- Add a ControlNet loader node and select the depth-compatible ControlNet model (depth_fp16 or depth-midas for SD1.5; controlnet-depth for SDXL)
- Connect your depth map image as the control image input
- Set the ControlNet conditioning strength. Start between 0.6 and 0.8. Higher values follow the depth map more closely but may constrain the model too tightly. Lower values give the model more freedom but reduce the compositional constraint.
- Connect the ControlNet output into your standard KSampler via the positive conditioning input
- Write your text prompt describing the content and style you want layered onto the depth structure
The depth map tells the model where things are. The text prompt tells the model what they are and what they look like. Used together, you get much more compositionally controlled outputs than either can produce alone.