A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by tatoforever, Nov 8, 2016.
now shadow party started
What am I doing wrong if frustum shadows completely disappear at exactly the shadow distance limit for me? It's like they can't be displayed anywhere but over distance range shadowmaps are already cover, which doesn't seem to be the intended behaviour.
It means you are using ContactShadows instead of FrustumShadows.
What NGSS version are you on? Last one is 2.2.4 (2.2.5 is being reviewed).
I'm attaching frustum shadows component to the camera - however, it previously had the contact shadows component attached. Should I remove or disable the contact shadows component?
On top of infinite shadows FrustumShadows can do what ContactShadows do faster and better so yes remove it, you won't need it anymore.
Thanks, that makes sense! It would perhaps be useful to update the documentation to indicate that (and perhaps also do a gameObject.GetComponent on initialization of frustum shadows to post a log warning if two components are present).
I have removed Contact Shadows component from my camera and I still don't see frustum shadows anywhere but as a tiny change making shadows thicker within the traditional shadow mapping radius. What else might be preventing them from working properly, extending from shadowmap limit out into the distance?
Are you using deferred or forward? FrustumShadows only work on deferred (I'm adding support to forward now).
Do you have a picture of your scene with frustumshadows?
Yes, I'm using deferred. The scene looks like this: no change outside of standard shadow mapping radius:
Show me your NGSS_FrustumShadows settings?
PS: Did you installed the latest NGSS libraries?
NGSS v2.2.5 is out. It fixes a FrustumShadows near plane fade-in bug. If you where on v2.2.4 I suggest to upgrade to v2.2.5. You don't have to re-install the libraries, only download the package to your project.
I updated to 2.2.5. Libraries are updated, full reimport was done after clearing all shadow cache. The issue still persists. To be absolutely sure, I loaded your own sample scene, and it shows exact same behaviour - no visible frustum shadows, only traditional shadow maps are noticeable and they fade at a standard distance:
Here is the GIF of it
Here are the settings from your scene:
Here are my project settings, pretty standard stuff there:
We're using DX11/linear. If that's relevant, we're using Unity 2019.2f1 - maybe there was some change vs. 2019.1 that breaks your frustum rendering?
Do you have multiple Unity installs? I'm pretty sure you installed the NGSS libraries in the wrong Unity (thus wrong directory). FrustumShadows and NGSS shadows works fine on all Unity versions (up to the latest 2019).
Yes, I am absolutely sure everything is installed correctly because everything else like PCSS works perfectly and because I never manually navigate to Unity installs, I use Unity Hub to directly jump to install directories.
Go to your program files and look for the Unity 2019 directory (or the path where you installed Unity). Navigate to Editor/Data/CGIncludes/ and compare the three libraries files (UnityShadowLibrary, AutoLight and UnityDeferredLibrary) to the ones provided by NGSS, if they are different then yes it means you installed NGSS in a different Unity version.
You can always install the NGSS libraries manually by replacing the CGInclude files in Unity Editor/Data/CGIncludes/ directory with the ones provided by NGSS then delete your project Library/ShaderCache folder and restart the Editor.
Just put them into a diff checker to be sure and they are identical. There is "NGSS FRUSTUM SHADOWS" section inside UnityDeferredLibrary.cginc and everything else is in place.
I always install libraries by closing the editor, removing all shader cache files from the library and manually copying the 3 libraries because making Unity launch in administrator mode to make install buttons work is a pain when you use the Hub. Trust me, the install is solid, we're constantly migrating to new Unity releases and I work on several machines, so I've done this dozens of times before. The problem is with something else.
Can you show me the line 93 of your UnityDeferredLibrary.cginc file? The one installed in the Unity/Editor/Data/CGIncludes directory.
Open NGSS_FrustumShadows.cs and comment line 323 and see if it works now?
If nothing works, can you please provide me a small repro project with Unity 2019.2 and send it to support? I will take a look at.
It doesn't seem to change anything. Looking at isolating the repro project.
I figured out what it was - I totally missed the fact that our project settings had deferred shader replacement. In our case, the project is using Advanced Foliage Shader that gives us modified deferred pipeline with wrap shading and translucency for vegetation.
I'll look at merging AFS stuff into your deferred library since AFS doesn't seem to modify much. Interesting how I never noticed it, since all other functionality seemed to work well before.
Wait, if this library can be replaced in project settings, couldn't this part of NGSS be installed by just linking a file in project settings instead of replacing the deferred library in Unity install? I suppose you didn't do that because you didn't want to also replace the deferred .shader file itself (project settings don't give you an option to just replace the UnityDeferredLibrary.cginc)?
And on another note, if it's not too much trouble, could you wrap all modifications to UnityDeferredLibrary.cginc into "// NGSS" comments to make it easier to merge multiple deferred modifications?
We don't do any change to that file (Internal-DeferredShading.shader). The one we change in the CGIncludes folder is deferred shadows, the one you are changing is lighting. xD
Maybe your custom shaders uses a custom UnityDeferredLibrary.cginc file.
Can you try a switching back and fort with a default standard shader and see if it shows the FrustumShadows?
Nah, that's the thing - the AFS includes a copy of this exact .cginc library, but it doesn't require replacing it in the Unity install because the #include clause in the shader points to in-project file instead of a built-in one. This makes built-in deferred library .cginc completely ignored by all compiled shaders - only the in-project version is actually referenced.
Now that I notice it, that's a neat trick - although it's probably not appropriate for NGSS since NGSS has no need to modify anything in the core deferred shader.
Switch to a built-in Standard shader and If FrustumShadows shows it means your custom shader is using an other UnityDeferredLibrary.cginc (instead of the default one located at Unity path/Editor/Data/CGIncludes which is replaced with NGSS libraries).
Yep, that's exactly what I observed - frustum shadows started working immediately after the switch in project setttings. Which led me to hunting how the deferred shader can affect the include, which led to discovering that in-project copy of deferred library include file, which led me to currently merging it with NGSS one to get functionality from both assets.
I've asked Lars to comment on what specific lines AFS needs modified to be completely sure I'm moving everything to NGSS version of the library, but the changes seem simple so far.
Edit: Merged everything, AFS just relied on an additional out parameter in
UnityDeferredCalculateLightParams that contained shadow strength (I suppose it's useful for masking translucency from backlighting?). Yay!
Let me know how it ends (and how it looks in your game)!
Next-Gen Soft Shadows used in Frontline Zed:
The default Unity contact shadows were very poor - with a large gap between eg. moving characters and the environment. As soon as I installed NGSS, the realism level increased dramatically. There was a small performance improvement as well.
Until HDRP is fully ready, NGSS is still an essential component for any realistic 3D game using the default renderer.
I would suggest having the global light settings adjusted via an Editor Window UI, instead of attached to a gameobject though. I missed a shadow distance master override attached to a single light, and I was struggling to figure it out for a while...
Beautiful rendering, specially the lighting and shadows, smooth and crisp! Kudos!
Hi @tatoforever ,
i think you answered me similar question some time ago, but let me ask this now just to be sure.
I care mostly about shadows distances and may be performance compared to Unity shadow maps.
I would want to eventually use NGSS for 25 square km ( 5 x 5 km ) terrain populated with vegetation using Vegetation Studio Pro.
I saw you have done some amazing work on shadows in distance but can i expect to have vegetation shadowed i far distances in my case. Is there some limit to your system. May be not the whole 5x5 km terrains distance but let's say 1 km may be good distance. Am i going to be able to have shadows that far ?
P.S. - of course the "soft" part of the system will be a bonus in my case !
The frustum shadows work off of screen-space information, so they have no concrete distance limit. Whether something is a mountain 5km away or a boulder 100m away makes almost no difference to the algorithm, which is awesome!
Speaking of which, I'd love an option to configure maximum distance similarly to minimum distance. The reason for that is that I'm sometimes using objects with depth-writing materials positioned right under my sky dome, very close to the maximum render distance. Those objects are similar to what's done in Destiny skyboxes and consist of flat distant mountains, megastructures etc., and having frustum shadows on those is very undesirable since they don't produce meaningful results on flat distant geometry like that and just add noise and stripe artifacts there.
As bac9 said, there's no limitation with FrustumShadows (hence the name), anything that is in view will cast shadows, no matter how far it is. And your drawcalls won't add up as is not scene dependant, it only needs camera depth to compute shadow rays.
I'll add an option for max FrustumShadows distance in v2.3. So min and max. :V
Thanks a lot! Really happy with the system overall!
I'll get proper screenshots soon, just got to fix a few regressions in our game preventing it from looking its best
I'm leaving tomorrow for vacations, will be back August the 15th. So no work or support email before the 15th but I'll try to read your messages and reply in the forums with a 48h buffer.
Hi @tatoforever , wish you a great vacation !
Meanwhile if you can read this and find the time to answer will be great.
I am looking into buying this asset - Tropical Forest Pack, but it also requires some custom deferred shaders. I also asked on the other thread if both NGSS and the tropical packs could be somehow combined. Any input on this is really much appreciated ! Thanks !
In our project we use UBER - Standard Shader Ultra. Unfortunately, Frustum Shadows does not work if Uber is selected as custom deferred shader. Maybe somebody has an idea how to solve this. Thanks!
It looks like the asset was built for compatibility with AFS - if you are using that, you will need a custom merged version of deferred library .cginc file, like one I had to make. Not sure about built-in replacement shaders the asset includes out of the box, but they work in a similar way since there aren't that many different ways to implement vegetation specific deferred changes like translucency.
I don't think there is a way to merge these kinds of assets without going into the shader files and combining them.
If your project uses a custom deferred library you need to manually add 4 lines of code in order for Frustum shadows to work:
//Add these uniforms before the UnityDeferredCalculateLightParams function
uniform float NGSS_FRUSTUM_SHADOWS_ENABLED = 0;
uniform float NGSS_FRUSTUM_SHADOWS_OPACITY = 0;
uniform sampler2D NGSS_FrustumShadowsTexture;
//Add this line inside the UnityDeferredCalculateLightParams function after computing all lights attenuations
atten = NGSS_FRUSTUM_SHADOWS_ENABLED > 0.0 ? min(atten, saturate(tex2D(NGSS_FrustumShadowsTexture, uv).r + NGSS_FRUSTUM_SHADOWS_OPACITY)) : atten;
For AFS I can provide a custom DeferredLibraray that already have these changes + the denoiser code and will work out of the box.
Couple of comparison GIFs showing the frustum shadows. It's incredible how much they allow us to turn down the rendering distance of traditional shadow maps - I'm sure we can get away with something even more conservative, like 80 meters, and even make this a great adjustable quality setting.
Beautiful lighting and shadows.
Indeed, FrustumShadows allows us to turn off completely Cascaded Shadows and set the Directional shadows distance to about 70. The massive drawcall reduction and the basic directional shadows drastically improved performance a ton. Probably like ~50%.
With a distance like that, is there any point in using cascades if the camera never gets into a first-person perspective? I feel that the transition zones between cascades and objects crossing multiple cascades cause a disproportional number of drawcalls that could be avoided.
Great, It works with Uber. Thank you very much!
I just installed the new NGSS but I get this error : Assets/Psychose Interactive/NGSS/Scripts/NGSS_FrustumShadows.cs(43,6): error CS0246: The type or namespace name `Min' could not be found. Are you missing an assembly reference?
I copied the files in NGSS/libraries into my Editor\Data\CGIncludes, closed and reopened Unity as it recompiled some shaders but I still get the error.
Can I please get a response to this? All the shadows in every scene have dissapeared and I can't view my scenes now.
What version of Unity are you using? The error simply states that NGSS fails to compile because an attribute called Min could not be found - but NGSS is not responsible fothat's not a custom functionality added by NGSS, that's a built-in Unity attribute. It should be present in any relatively recent Unity release. Either you have a Unity release without it or something else preventing compilation, I'd wager.
Edit: It looks like the docs only added a page for that attribute in 2018.3, so fixing it is a matter of wrapping that Min attribute in an appropriate precompiler directive. Alternatively, just comment it out for now and simply not set that value below 0 - it should compile fine.
Thank you, commenting out the "min" line solved the compiling issue temporarily, atleast I have the shadows back.
Btw when you used the frustum shadows in the scene you posted above, did you lose the translucency of the tree leaves?
I do not lose translucency, but my setup might be different from yours - I'm using a modified version of AFS where the deferred library is swapped for one from NGSS, but still contains a new out argument AFS deferred shader relies on for translucency masking.
After playing around with Shader forge and NGSS a little, I got them to work. Frustum shadows are also a big help.
Sorry for the late reply folks I'm still on vacations till August the 16th.
You can push the frustum shadows start distance so nearby vegetation still displays it's default translucency or reduce the backface opacity (fragments facing away from lights) with frustum shadows.
You can also integrate frustum shadows into your own custom rendering using the 4 lines of code I posted above.
Let me know if everything is OK?
PS: About the error, not sure why the shader compiler says 'Min', it's 'min' and that's probably a Unity bogus misspelling. I'll investigate more when I get back this week.
Frustum shadows also creates artifacts when using multiple directional lights. I tried playing around with deferred backface options and all but no luck.