All Projects → ColinLeung-NiloCat → Unityurpunlitscreenspacedecalshader

ColinLeung-NiloCat / Unityurpunlitscreenspacedecalshader

Licence: mit
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

Projects that are alternatives of or similar to Unityurpunlitscreenspacedecalshader

Testbedhdrp
Testbed project for Unity HDRP (High Definition Render Pipeline)
Stars: ✭ 859 (+88.79%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Lwrpshaders
A collection of high customizable unlit shaders for Lightweight Render Pipeline
Stars: ✭ 125 (-72.53%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Nnao
Neural Network Ambien Occlusion based on http://theorangeduck.com/page/neural-network-ambient-occlusion
Stars: ✭ 57 (-87.47%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Unitypcss
Nvidia's PCSS soft shadow algorithm implemented in Unity
Stars: ✭ 533 (+17.14%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Packedrgbmshader
32-bit packed color format with RGBM encoding for shader use
Stars: ✭ 39 (-91.43%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Temporalreprojectionexample
Temporal reprojection example for Unity
Stars: ✭ 82 (-81.98%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Depthinverseprojection
An example showing how to inverse-project depth samples into the view/world space in Unity.
Stars: ✭ 296 (-34.95%)
Mutual labels:  unity, unity3d, graphics, shader, shaderlab
Spheredissolve
Customizable procedural spherical dissolve shader for Unity3D, for all your customizable procedural spherical dissolve needs!
Stars: ✭ 311 (-31.65%)
Mutual labels:  unity, unity3d, graphics, shader
Rimlight
Customizable rimlight shader for Unity that includes pulsation and noise scrolling. Give your scenes that extra oomph!
Stars: ✭ 170 (-62.64%)
Mutual labels:  unity, unity3d, graphics, shader
Nvjob Water Shader Simple And Fast
#NVJOB Simple Water Shaders. Free Unity Asset.
Stars: ✭ 172 (-62.2%)
Mutual labels:  unity, unity3d, shader, shaderlab
Skyboxplus
Basic skybox extensions for Unity
Stars: ✭ 324 (-28.79%)
Mutual labels:  unity, unity3d, graphics, shader
Unity Dithered Transparency Shader
Unity material and shader for applying clipped, dithered transparency
Stars: ✭ 174 (-61.76%)
Mutual labels:  unity, unity3d, graphics, shaderlab
Retro3dpipeline
A minimal example of a custom render pipeline with the Retro3D shader.
Stars: ✭ 354 (-22.2%)
Mutual labels:  unity, unity3d, graphics, shader
Computestochasticreflections
Compute Stochastic Screen Space Reflections for unity post processing
Stars: ✭ 163 (-64.18%)
Mutual labels:  unity, unity3d, graphics, shader
Noiseball3
A Unity example that shows how to use the new implementation of DrawProcedural.
Stars: ✭ 147 (-67.69%)
Mutual labels:  unity, unity3d, graphics, shader
Miniengineao
SSAO image effect from Microsoft MiniEngine, ported to Unity.
Stars: ✭ 448 (-1.54%)
Mutual labels:  unity, unity3d, graphics, shader
Rcam
Real time volumetric video capture for live visuals
Stars: ✭ 128 (-71.87%)
Mutual labels:  unity, unity3d, graphics, shaderlab
Kinovision
Frame visualization utility for Unity
Stars: ✭ 177 (-61.1%)
Mutual labels:  unity, unity3d, graphics, shader
Noiseball2
A small example of procedural modeling with compute shaders.
Stars: ✭ 215 (-52.75%)
Mutual labels:  unity, unity3d, graphics, shader
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (-56.48%)
Mutual labels:  unity, unity3d, shader, shaderlab

UnityURP-Unlit ScreenSpaceDecal Shader(SRP batcher compatible)

Before adding decal screenshot

After adding decal screenshot

Before adding decal screenshot

After adding decal(multiply blend mode) screenshot

Each decal is just a unity cube GameObject, using material of this shader, nothing else. screenshot

Before adding decal screenshot

After adding decal: (alpha blending) screenshot (additive) screenshot (multiply) screenshot (alpha blending, tint to HDR red, extra multiply alpha to rgb in shader) screenshot (opaque) screenshot (each decal is just a unity cube GameObject) screenshot (multiply) screenshot (additive, blue tint) screenshot

(no tiling) screenshot (add 4x4 tiling) screenshot (add 4x4 tiling , alpha * 2 - 1) screenshot (add 4x4 tiling , alpha * 4 - 3) screenshot (add 4x4 tiling , alpha * 10 - 9) screenshot

When should I use this shader?

if you need to render bullet holes, dirt/logo on wall, 3D projected UI, explosion dirt mark, blood splat, projected texture fake shadow(blob shadow) ..... and the receiver surface is not flat(can't use a flat transparent quad to finish the job), try using this shader.

How to use this shader in my project?

  1. clone the shader to your project
  2. First, you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project)
  3. First, you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project)
  4. First, you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project)
  5. First, you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project)
  6. First, you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project) screenshot
  7. create a new material using that shader (right click on the shader->Create->Material)
  8. assign any texture to material's Texture slot
  9. create a new unity default cube GameObject in scene (in Hierarchy window, click +/3D Object/Cube)
  10. apply that material to Cube Gameobject's MeshRenderer component's material slot (drag material on the cube)
  11. edit the GameObject's transform so the local forward vector (blue Z arrow) is pointing to scene objects, and the cube is intersecting scene objects
  12. you should now see your new decal cube is rendering correctly(projecting alpha blending texture to scene objects correctly)
  13. (optional)edit _Color / BlendingOption, according to your needs
  14. (optional)finally make the cube as thin/small as possible to improve GPU rendering performance

Requirement when using this shader

  • Forward rendering in URP
  • _CameraDepthTexture is already rendering by unity (toggle on DepthTexture in your Universal Render Pipeline Asset)
  • For mobile, you need at least OpenGLES3.0 (#pragma target 3.0 due to ddx() & ddy())

Editor System Requirements

  • Unity 2019.1 or later (due to "shader_feature_local"). But you can replace to "shader_feature" if you want to use this shader in older unity versions

I can see decal in scene window, but not in game window

you must enable depth texture in URP's setting (search UniversalRP-HighQuality in your project)
If it still doesn't work, try adding an empty renderer feature.

I can see decal in editor(both scene and game window), but not in mobile build

search "UniversalRP-MediumQuality" and "UniversalRP-LowQuality" in your project, turn on depth texture. screenshot

My Game use orthographic camera, but the decal shader doesn't work

enable toggle "_SupportOrthographicCamera" in material

I can see decal renders correctly, but which BlendMode should I use in the material inspector?

Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency

Blend One OneMinusSrcAlpha // Premultiplied transparency

Blend One One // Additive

Blend OneMinusDstColor One // Soft Additive

Blend DstColor Zero // Multiplicative

Blend DstColor SrcColor // 2x Multiplicative

https://docs.unity3d.com/Manual/SL-Blend.html

Is this shader optimized for mobile?

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

Also, this shader moved all matrix mul() inside the fragment shader to vertex shader, so you can put lots of decals in scene without hurting GPU performance too much, as long as they are thin, small and don't overlap(overdraw).

I need LOTs of decals in my game, is there performance best practice?

  • make all decal cube as thin/small as possible
  • don't overlap decals too much for each pixel(overdraw)
  • If your camera never goes into decal's cube volume, you should set ZTest to LessEqual, and Cull to Back in the material inspector, doing this will improve GPU performance a lot! (due to effective early-Z, GPU only need to render visible decals)
  • disable _ProjectionAngleDiscardEnable, doing this will improve GPU performance a lot!
  • enable "generate mipmap" for your decal texture, else a high resolution decal texture will make your game slow due to cache miss in GPU memory

if you do every optimzations listed above, and your game is still slow due to this decal shader, please send me an issue, I will treat it as bug.

Implementation Reference

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

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

Screen Space Decals in Warhammer 40,000: Space Marine

https://www.slideshare.net/blindrenderer/screen-space-decals-in-warhammer-40000-space-marine-14699854?fbclid=IwAR2X6yYeWmDiz1Ho4labx3zA3GATpC7fi5qNkzjEj-MYTOBpXnkIsnA3T-A

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].