All Projects → ColinLeung-NiloCat → Unityurp Billboardlensflareshader

ColinLeung-NiloCat / Unityurp Billboardlensflareshader

Licence: mit
(1)Add a new Quad GameObject (2)Use this shader (3)Done! Now you have billboard lens flare shader for URP!

Projects that are alternatives of or similar to Unityurp Billboardlensflareshader

Raindropeffect
RainDropEffect for the Unity Asset Store
Stars: ✭ 320 (+128.57%)
Mutual labels:  unity, shader, shaderlab
Temporalreprojectionexample
Temporal reprojection example for Unity
Stars: ✭ 82 (-41.43%)
Mutual labels:  unity, shader, shaderlab
Unityurpunlitscreenspacedecalshader
Unity unlit screen space decal shader for URP. Just create a new material using this shader, then assign it to a new unity cube GameObject = DONE, now you have unlit decal working in URP
Stars: ✭ 455 (+225%)
Mutual labels:  unity, shader, shaderlab
Depthinverseprojection
An example showing how to inverse-project depth samples into the view/world space in Unity.
Stars: ✭ 296 (+111.43%)
Mutual labels:  unity, shader, shaderlab
Lwrpshaders
A collection of high customizable unlit shaders for Lightweight Render Pipeline
Stars: ✭ 125 (-10.71%)
Mutual labels:  unity, shader, shaderlab
Configurableshaders
Showing off the power of shader properties in Unity
Stars: ✭ 304 (+117.14%)
Mutual labels:  unity, shader, shaderlab
Inkpainter
Texture-Paint on Unity.
Stars: ✭ 849 (+506.43%)
Mutual labels:  unity, shader, shaderlab
Awesome Unity Shader
⛵ 关于炫酷的Unity3D Shader | About Cool Unity3D Shaders
Stars: ✭ 2,658 (+1798.57%)
Mutual labels:  unity, shader, shaderlab
Unity Grabsquares Effect
Unity GrabSquares Effect
Stars: ✭ 39 (-72.14%)
Mutual labels:  unity, shader, shaderlab
Packedrgbmshader
32-bit packed color format with RGBM encoding for shader use
Stars: ✭ 39 (-72.14%)
Mutual labels:  unity, shader, shaderlab
Unityurp Mobilescreenspaceplanarreflection
Reusable RendererFeature of MobileScreenSpacePlanarReflection
Stars: ✭ 260 (+85.71%)
Mutual labels:  unity, shader, mobile
Nnao
Neural Network Ambien Occlusion based on http://theorangeduck.com/page/neural-network-ambient-occlusion
Stars: ✭ 57 (-59.29%)
Mutual labels:  unity, shader, shaderlab
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (+41.43%)
Mutual labels:  unity, shader, shaderlab
Unity Ui Rounded Corners
This components and shaders allows you to add rounded corners to UI elements!
Stars: ✭ 307 (+119.29%)
Mutual labels:  unity, shader, shaderlab
Unitywatersurface
Water Surface Simulation using CutomRenderTexture in Unity 2017.1
Stars: ✭ 190 (+35.71%)
Mutual labels:  unity, shader, shaderlab
Unitypcss
Nvidia's PCSS soft shadow algorithm implemented in Unity
Stars: ✭ 533 (+280.71%)
Mutual labels:  unity, shader, shaderlab
Nvjob Water Shader Simple And Fast
#NVJOB Simple Water Shaders. Free Unity Asset.
Stars: ✭ 172 (+22.86%)
Mutual labels:  unity, shader, shaderlab
Isaura
An attempt at making a aura thingie with a isoline shader.
Stars: ✭ 187 (+33.57%)
Mutual labels:  unity, shader, shaderlab
Testbedhdrp
Testbed project for Unity HDRP (High Definition Render Pipeline)
Stars: ✭ 859 (+513.57%)
Mutual labels:  unity, shader, shaderlab
X Postprocessing Library
Unity Post Processing Stack Library | Unity引擎的高品质后处理库
Stars: ✭ 1,079 (+670.71%)
Mutual labels:  unity, shader, shaderlab

UnityURP-BillboardLensFlare Shader(SRP batcher compatible)

A single file billboard lens flare shader, which is easy to use and mobile optimized for unity URP! You can copy this shader file into your URP project and use it easily.

Shader Result

Imgur


(1) BEFORE(nothing added) screenshot (2) Added a new Quad Gamebject only, apply a random rotation just to prove that it will work with any transform.rotation in step(3) screenshot (3) Now switch Quad's material's shader to THIS lens flare shader -> DONE! Now lens flare will always look at the camera(purely done by shader), you DON'T need a C# script to make the quad look at the camera! It is just a regular MeshRenderer, without any C# / particle system. screenshot

Shader Features

  • auto look at camera (billboard without any C# / particle system)
  • smooth scene depth occlusion (use lens flare's center to do depth test)
  • render on top of everything (a lens flare shader!)
  • smooth fadeout when camera is too close to lens flare
  • (optional)simple flicker animation inside shader, to save you time from setting up simple animation

Why creating this shader?

I need to render lots of small lens flares in URP for mobile (gameplay enemy attack signals, battle vfx, environment light source like lamps...) and it seems that URP doesn't have any official lens flare support, so I write a new shader for this task. This shader's render cost is as low as possible(almost impossible for me to improve it anymore), also generic enough for anyone to use this shader in their project easily.

How to use this shader in my URP project?

  1. Copy this shader into your URP project
  2. Create a new material using this shader (Shader path: Universal Render Pipeline -> NiloCat Extension -> BillBoard LensFlare)
  3. Assign any lens flare texture to this new material's texture slot(lens flare texture's recommend import setting -> alpha = From Gray Scale)
  4. Create a new Quad GameObject in scene
  5. drag the material in step(1) into Quad's MeshRenderer's material slot
  6. make sure you have turned on "Need depth texture" in URP setting asset
  7. Done! Now this Quad GameObject will always look at the camera and will fade out smoothly when the lens flare's center was "blocked" by opaque/alpha test renderers.

Requirement when using this shader

  • Forward rendering in URP
  • _CameraDepthTexture is already rendering by unity (toggle on DepthTexture in your Universal Render Pipeline Asset)

FAQ: My lens flare texture doesn't have an alpha channel, and setting my texture's import setting's alpha = "From Gray Scale" is still not looking correct...What should I do?

try turn OFF "_UsePreMultiplyAlpha" in the material's setting, now shader will only consider RGB in your lens flare texture, and add it directly to screen.

FAQ: I snap my lens flare quad onto a lamp renderer's vertex, now this lens flare is occluded randomly, what should I do?

drag "_DepthOcclusionTestZBias" to a negative number (e.g. -0.1), which makes the DepthOcclusionTest easier to pass, hence more stable.

FAQ: Can I use it for the particle system?

NO, this shader requires object space mesh position data, particle system will break it. To make it works for the particle system, both the particle system and this shader must work together to make it works, which is not included in this shader for simplicity reason.

FAQ: Is this shader optimized for mobile?

This shader is SRP batcher compatible, so you can put lots of lens flares in scene without hurting CPU performance too much(even all lens flares use different materials).

Also, this shader moved almost all calculations from fragment shader to vertex shader, so you can put lots of lens flares in scene without hurting GPU performance too much, as long as they are small and don't overlap with each other(overdraw).

Editor environment requirement

  • URP 7.3.1 or above
  • Unity 2019.3 or above

Hey, I found a bug! / I want some critical features!

send me an issue using GitHub! (don't send it to my email, I may miss it)

Implementation Reference

Low Complexity, High Fidelity: The Rendering of INSIDE's optimized lens flare shader

https://youtu.be/RdN06E6Xn9E?t=3257

credits

model creator in demo images - https://i-fox.club/pcr/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].