Add Contact Shadows
Add realistic ground shadows to your 3D scenes with the ContactShadows component. Soft, performant shadows that enhance visual quality. Works in Unity and Blender.
Add realistic, soft shadows where objects meet the ground for enhanced depth and realism.
:::tip Works with Unity and Blender The ContactShadows component is available for both Unity and Blender integrations. :::
What You Can Do
Realistic Ground Shadows - Soft shadows where objects touch surfaces
Auto-Fit to Scene - Automatically size shadows to cover your entire scene
Customizable Appearance - Control darkness, opacity, and blur
Performant - Efficient rendering without heavy shadow mapping
Easy Setup - Add via component or HTML attribute
Perfect for:
Product showcases and configurators
Architectural visualizations
Character and vehicle displays
Any scene needing enhanced depth perception
Lightweight shadow alternative
Quick Start
Via HTML Attribute (Easiest)
Add contact shadows to your entire scene with one line:
The value (0.7) controls both opacity and darkness. Higher values = stronger shadows.
Via Component in Unity/Blender
In Unity or Blender:
Create an empty object in your scene
Add the
ContactShadowscomponentEnable Auto Fit to cover the whole scene
Export and view - shadows appear automatically!
Programmatically
Create contact shadows from code:
Settings
Auto Fit
Automatically size shadows to fit the entire scene
false
Darkness
How dark the shadows appear (0 = invisible, 1 = black)
0.5
Opacity
Transparency of the shadow plane (0 = transparent, 1 = opaque)
0.5
Blur
Softness of shadow edges (higher = softer)
4.0
Occlude Below Ground
Hide objects below the shadow plane
false
Backface Shadows
Cast shadows from backfaces of objects
true
Manual Update
Only update shadows when manually triggered
false
How It Works
ContactShadows renders your scene from below using an orthographic camera:
Objects are rendered as black silhouettes
The silhouettes are blurred for soft edges
The result is projected onto a ground plane
Only the area near objects shows shadows (contact area)
This creates realistic "contact shadows" without expensive real-time shadow mapping.
Examples
Product Display
Enhance product visualization with ground shadows:
Via HTML:
Via Component:
Add
ContactShadowscomponent to your sceneEnable Auto Fit
Set Darkness to
0.6and Opacity to0.5Set Blur to
5.0for very soft shadows
Architectural Visualization
Add depth to building models:
Custom Shadow Area
Control exactly where shadows appear:
In Unity/Blender:
Create a plane where you want shadows
Scale the plane to define the shadow area
Add
ContactShadowscomponentDisable Auto Fit
The shadow area matches the object's scale
Dynamic Scenes
Update shadows when objects move:
Advanced Features
Auto-Fit with Custom Parameters
Control how shadows fit to your scene:
Manual Shadow Updates
For static scenes, update shadows only when needed:
This improves performance in scenes where objects don't move frequently.
Fitting Shadows
Manually fit shadows to specific objects or the whole scene:
Occlude Below Ground
Hide parts of objects below the shadow plane:
Useful for:
Cutting off reflected objects below mirrors
Hiding underground parts in architectural models
Creating water surface effects
Backface Shadows
Control whether object backsides cast shadows:
Disabling this can reduce shadow artifacts but may make shadows look less complete.
Common Questions
How do contact shadows differ from regular shadows? Contact shadows are soft, ground-plane-only shadows that enhance depth perception. They don't cast onto other objects like traditional shadow mapping does.
Do contact shadows work in VR/AR? Yes! Contact shadows render correctly in WebXR environments.
Can I have multiple ContactShadows in one scene? Generally you should only have one ContactShadows instance per scene. Use ContactShadows.auto() which creates only one instance.
Why are my shadows not appearing? Check that objects have visible geometry and aren't marked as transparent or wireframe. Use ?debugcontactshadows URL parameter for diagnostics.
How do I adjust shadow size? If using Auto Fit, shadows automatically cover the scene. Otherwise, scale the GameObject to define the shadow area.
Are contact shadows expensive? They're more efficient than full shadow mapping but do require rendering the scene from below each frame. Use Manual Update for static scenes to improve performance.
Can contact shadows follow moving objects? Yes, shadows update automatically by default. For moving objects in otherwise static scenes, use manual updates and trigger needsUpdate when objects move.
Performance Tips
Static Scenes: Enable manual updates and only update when needed:
Reduce Texture Size: Shadows use a 512×512 render target by default. This is hardcoded but provides good quality/performance balance.
Adjust Blur: Lower blur values render faster. Start with blur: 2.0 and increase only if needed.
Selective Rendering: Objects marked with certain properties (wireframe, colorWrite:false) are automatically excluded from shadow rendering.
Debugging
Enable debug mode by adding ?debugcontactshadows to your URL:
This logs:
Shadow creation and initialization
Fitting operations and bounding boxes
Render pipeline details
More Information
Live Example:
Contact Shadows Sample - Interactive demo with controls
API Documentation:
ContactShadows API - Complete technical reference
Related Components:
Light - Traditional lighting and shadows
GroundProjectedEnv - Ground-projected environment reflections
Last updated