Giter Site home page Giter Site logo

themasonx / unitypcss Goto Github PK

View Code? Open in Web Editor NEW
722.0 62.0 81.0 104.99 MB

Nvidia's PCSS soft shadow algorithm implemented in Unity

License: MIT License

C# 74.58% ShaderLab 25.42%
unity unity3d unity-asset unity-shader shadow shadow-mapping shader shaderlab pcss soft-shadows

unitypcss's Introduction

UnityPCSS

Nvidia's PCSS soft shadow algorithm implemented in Unity3D.

Description

"PCSS" or "Percentage Closer Soft Shadows" is a shadow sampling algorithm invented by Nvidia in 2005 (Original Whitepaper). The intent is to simulate a more realistic falloff where the shadows get progressively softer the further the receiver is from the caster.

This effect is easy to spot in real life, such as when looking at tree shadows: alt text

I thought this photo was really cool, so I did a quick recreation as a test: alt text

Current Limitations

Currently only works with "Directional" light sources, as it's primarily an override of the "Screen Space Shadows" shader in the graphics settings, but I'm looking into the possibility of directly overriding the actual "UnityShadowLibrary.cginc" to affect "Spot" and "Point" lights if possible.

Version Compatibility

Currently working in 2019, though the shadows themselves should still work with 5.5, 5.6, 2017, and 2018 (no modifications necessary, it automatically detects and adapts to any version), but as this is now a Unity 2019.2 project, the materials in the demo scene do not import correctly in earlier versions. There are only 3 or so materials that need their albedo/metallic/specular textures assigned from the nearby "Textures" folder, so it's not that bad, but if anybody has any ideas to fix this, please let me know! :)

Future Development

This asset and any improvements will remain free (both as in beer and speech), but if you wish to support me spending extra time on this, you can donate to me through PayPal. NOTE: Please do not feel pressured to donate it's just an option if anyone wishes to support me spending more time on this, and less on my game, which I can't even use it for.

I obviously didn't do this to make money though; instead, I'd prefer support in the form of you guys contributing back any fixes/improvements, so that we can all benefit :) I made it Open Source rather than just a free asset because I believe that if we work together, we can create something truly amazing. Thanks for the interest, and I hope you guys get some good use out of it! Let me know if you have any issues or ideas, and I'll respond to pull requests ASAP.

unitypcss's People

Contributors

themasonx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unitypcss's Issues

When making a build, it does not work any more:

When I build the project, I dont get the PCSS, but it seems as if the shadows fall back to the Unity standard soft shadows.

When we remove the function: ResetShadowMode(), the shadows work also in the build. Could you isolate and solve the problem?

Not working

Shaders are giving error in unity 5.6.0f1!!

Directional Shadows Messed Up

After adding PCSS and turning on realtime GI shadows started changing resolution randomly and light started bleeding frequently. When I turn camera at some specific angle shadows become blurry and very low res no matter the quality settings.

I can't return shadows back to normal even when I remove PCSS folder and disable GI. This also affects all projects including new empty ones so I'd like to know how to restore default directional shadows. Point and spot lights are normal.

Link to Youtube https://www.youtube.com/watch?v=xRB6QEwvwgE

HDRP

Hey there! Do you think it would be possible to integrate this into HDRP? Not as an asset, but inside HDRP itself.

lack of unitypackage in the release tab

Hope I'm not passing as a jerk but I find the presence of the unitypackage in the release tab a must for unity assets.
Thank you for considering ^^ and kudos on the awesome asset anyway
cheers

PCSS doesn't work in builds

We've tested this in several versions of Unity (5.5, 5.6.0, 5.6.4, 2017.3) and it looks like PCSS is never applied in builds - only standard Unity shadows are visible. All references are correct at runtime (RT is non null, same light is shadow casting in same mode, etc.), and are no errors raised in the logs, so we're a bit stumped as to how to debug this. What might be the reason for shadows working perfectly in editor but disappearing in the final application?

In case that's relevant: we're using Windows 10, Nvidia GPUs, DX11, linear lighting and deferred rendering with aforementioned versions of Unity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.