Sayfalar (23)Lens flare occlusion
- Overview
- Installation
- Getting started
- Quick Start window
- System overview
- Easy Weather Manager
- Time Module
- Celestial Module
- Cloud Module
- Volumetric clouds
- Cloud shadows
- Fog
- Detail Module
- Weather Effects Module
- Weather presets
- Events Module
- Lens flare occlusion
- Helper components
- Demo scene
- Scripting guide
- Troubleshooting
- FAQ
- Changelog
Lens flare occlusion
Son güncelleme: 6 Ekim 2026
Bu sayfa henüz Türkçeye çevrilmedi, İngilizcesi gösteriliyor.
Two scripts that make the sun's Lens Flare (SRP) fade correctly when something moves in front of the sun. They read the depth buffer instead of casting rays, so they need no colliders and they see alpha clipped geometry: a flare fades behind tree leaves out of the box.
| Script | Role |
|---|---|
LensFlareDepthOcclusionFeature | URP renderer feature. Samples scene depth in a ring around the sun's screen position and reads the result back without stalling the GPU |
LensFlareSmoothOcclusion | Component on the sun light. Turns that visibility into the flare's intensity through two independent fade channels |
Setup
- Add Lens Flare Depth Occlusion Feature to your URP Renderer asset (Add Renderer Feature). The Quick Start window flags it as missing as soon as a scene uses the component, and adds it with one click.
- Its Shader field finds
Hidden/LensFlareDepthOcclusionby itself. Assign it by hand only if you renamed the shader. - Enable Depth Texture on the URP asset.
- Add a Lens Flare (SRP) component to the sun light. A ready made flare is included at
Content/Flare/LensFlare.asset. - Add Lens Flare Smooth Occlusion to the same object.
The Celestial Module finds the component and fades it with the sun height and the cloud cover (Auto Lens Flare).
The two fade channels
The reason a flare disappears matters, so the component keeps the two causes apart:
| Channel | Behaviour |
|---|---|
| Obstacle | A leaf, rock or building moves in front of the sun: the intensity is cut at once, because a real obstacle blocks light at once. When it clears, the flare fills back in over fadeInDuration |
| Screen edge | The sun leaves the view with nothing in the way: the flare fades out smoothly across screenEdgeFadeMargin, reaching zero before the sun crosses the border |
intensity = maxIntensity * easing(obstacle visibility) * screen edge fade * VisibilityMultiplierSettings
| Setting | Default | Description |
|---|---|---|
lensFlare, viewCamera | Fall back to the component on the same object and to the main camera | |
sampleRadius | 0.012 | Depth sampling radius around the sun in screen UV. Larger softens the occlusion edge |
sampleCount | 8 | Ring samples. More give smoother partial occlusion |
fadeInDuration | 0.35 | Seconds to return to full brightness |
instantOcclude | on | An obstacle cuts the flare at once. Off, it fades out as well |
easing | ease in and out | Curve applied to the smoothed obstacle visibility |
screenEdgeFadeMargin | 0.15 | Fade band along the screen border, as a fraction of the screen height. 0 cuts the flare hard at the border |
fadeOutDuration | 0.5 | Rate limit for the screen edge fade, so a fast camera turn does not pop |
maxIntensity | 0 | Intensity at full visibility. 0 takes the flare's own value on Awake |
API
| Member | Description |
|---|---|
float MaxIntensity | Target brightness at full visibility. The component writes lensFlare.intensity every frame, so change this instead |
float VisibilityMultiplier | Runtime dimmer on top of everything else, not saved. The Celestial Module drives it |
float SunVisibility | Last visibility read back from the depth pass: 0 blocked, 1 clear |
The occlusion pass runs for Game cameras only, so the Scene view always shows the flare unoccluded. Like the fog, it is recorded through Render Graph only. The component also switches off the flare's own occlusion option, because it manages occlusion itself.
Bu sayfaya bağlantı veren sayfalar
Hâlâ takıldınız mı?
Unity sürümünüzü, render pipeline bilginizi ve sorunun ekran görüntüsünü gönderin.

