{"id":19186137,"url":"https://github.com/pschraut/unityocclusionlensflare","last_synced_at":"2025-05-08T01:17:01.134Z","repository":{"id":110113040,"uuid":"345192591","full_name":"pschraut/UnityOcclusionLensFlare","owner":"pschraut","description":"A Lens Flare effect for Unity that doesn't require Physics.","archived":false,"fork":false,"pushed_at":"2021-03-07T17:37:40.000Z","size":610,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T01:16:55.012Z","etag":null,"topics":["unity","vfx"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pschraut.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-06T20:51:29.000Z","updated_at":"2024-11-18T09:16:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"ffa74286-82df-4618-a65c-887c4a9647dd","html_url":"https://github.com/pschraut/UnityOcclusionLensFlare","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschraut%2FUnityOcclusionLensFlare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschraut%2FUnityOcclusionLensFlare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschraut%2FUnityOcclusionLensFlare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschraut%2FUnityOcclusionLensFlare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pschraut","download_url":"https://codeload.github.com/pschraut/UnityOcclusionLensFlare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978811,"owners_count":21834920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["unity","vfx"],"created_at":"2024-11-09T11:13:31.529Z","updated_at":"2025-05-08T01:17:01.124Z","avatar_url":"https://github.com/pschraut.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Occlusion Lens Flare for Unity\n\nThe Occlusion Lens Flare package provides the ability to use Unity's built-in [Lens Flare](https://docs.unity3d.com/Manual/class-LensFlare.html) Component without Physics raycasts.\nIt was created to be used with Unity's built-in Render Pipeline.\n\nPlease see the following video for a quick introduction,\n[![](http://img.youtube.com/vi/zaN5TLIMcFs/0.jpg)](http://www.youtube.com/watch?v=zaN5TLIMcFs \"\")\n\nUnity's built-in Lens Flare requires the Physics engine by default, \nbecause it uses a Physics raycast to determine whether the sun is blocked by another object. \nHere is the relevant quote from the [documentation](https://docs.unity3d.com/Manual/class-LensFlare.html):\n\u003e Lens Flares are blocked by Colliders. A Collider in-between the Flare GameObject and the Camera will hide the Flare, even if the Collider does not have a Mesh Renderer.\n\nThere can be reasons why you might not want to use Unity's Physics engine and in this case, the built-in Lens Flare stops working.\n\nThis Occlusion Lens Flare package does not require Physics, it renders an occlusion texture instead. The occlusion texture contains the sun and any object in-between the sun and camera. The occlusion texture is then used to determine how many pixels are occluded from the sun, to control the Lens Flare opacity.\n\nThis approach comes with its own benefits and drawbacks:\n* Benefit: The Occlusion Lens Flare knows more than on/off, it actually knows how much it's occluded and can adjust its opacity accordingly. Unity's Lens Flare only knows if a \"single pixel\" is occluded or not and tries to compensate the on/off flicker by introducing a fade setting.\n* Benefit: It uses Unity's built-in Lens Flare Component to render the Flare, thus you can use all the existing Lens Flare assets that have been created for Unity already and of course create your own assets too.\n* Drawback: The Occlusion Lens Flare requires to render an occlusion texture, which increases the number of draw-calls. However, the occlusion view frustum is small and it only renders objects that are inside the frustum. The occlusion texture itself is small as well, 64x64 pixels is sufficient already. Unity's Lens Flare does not add further draw-calls on the other hand.\n* Drawback: The Occlusion Lens Flare supports a single Lens Flare only.\n* Drawback: The editor Scene View integration does not work.\n* Benefit\u0026Drawback: The Occlusion Lens Flare is targeted to lower-end hardware. I created it in particular for mobile, thus it's not an actual simulation of a camera lens flare effect that you'd expect from high fidelity visuals. It's the same level of fidelity as Unity's built-in Lens Flare though.\n \n# Installation\n\nAs of Unity 2019.3, Unity supports to add packages from git through the Package Manager window. \nIn Unity's Package Manager, choose \"Add package from git URL\" and insert one of the Package URL's you can find below.\n\n## Package URL's\n\n| Version  |     Link      |\n|----------|---------------|\n| 1.1.0 | https://github.com/pschraut/UnityOcclusionLensFlare.git#1.1.0 |\n| 1.0.0 | https://github.com/pschraut/UnityOcclusionLensFlare.git#1.0.0 |\n\n# Credits\n\nIf this package is useful to you, please mention my name in your credits screen.\nSomething like \"Occlusion Lens Flare by Peter Schraut\" or \"Thanks to Peter Schraut\" would be very much appreciated.\n\n# Honorable mentions\n\nThanks to bgolus and KokkuHub from the Unity forums for helping me getting this working.\n\nYou can read the discussion here: https://forum.unity.com/threads/how-to-create-a-lens-flare-effect-without-physics.1053590/\n\n# Integration\n\n## Override the built-in Lens Flare shader\nOpen ```Edit \u003e Project Settings...``` and select the ```Graphics``` tab. \nScroll down to the ```Built-in Shader Settings``` section and change the ```Lens Flare``` setting\nfrom ```Built-in shader``` to ```Custom shader```.\n\nDrag\u0026drop the ```Shaders/OcclusionLensFlare.shader``` asset from the Occlusion Lens Flare package folder in Lens Flare shader setting.\n\n![alt text](Documentation~/images/graphics_settings.png \"Lens Flare shader setting\")\n\n\n# Example\n\nOnce you have overridden the built-in Lens Flare shader as mentioned in the ```Integration``` section, you can either just continue with Sample or follow all further integration steps below.\n\nThe Sample requires Unity's Cinemachine package, but the actual Occlusion Lens Flare does not.\n\n* Open ```Window \u003e Package Manager``` and install ```Cinemachine``` package from the ```Unity Registry```.\n* Import the ```Occlusion Lens Flare Sample.unitypackage``` file found in the ```Occlusion Lens Flare/Samples~``` directory.\n* Open ```Occlusion Lens Flare Scene``` and press ```Play```.\n\nYou should see this now:\n![alt text](Documentation~/images/sample.png \"Occlusion Lens Flare Sample\")\n\nHold down the right mouse button and move the mouse to rotate the camera.\nWhen the sun goes behind one of those green boxes, the Lens Flare should fade out.\n\n# Integration step by step\n\nIn this section I describe how to replicate the Occlusion Lens Flare Sample.\n\nTODO\n\n\n# How it works\n\nTODO\n\nIn this video I go into more detail how it actually works.\n[![](http://img.youtube.com/vi/d-0M50W1byk/0.jpg)](http://www.youtube.com/watch?v=d-0M50W1byk \"\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschraut%2Funityocclusionlensflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpschraut%2Funityocclusionlensflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschraut%2Funityocclusionlensflare/lists"}