sebastianhein / msaa-shadow-fix

A little fix for the directional shadows with msaa enabled in Unity3d.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unity MSAA shadow fix

Description

MSAA multisampling is essential to create stable, non-flickering images for VR applications. Shadowmapping however is not working correctly with MSAA, resulting in hard edges where lit objects overlap shadowed areas.

The basic idea of this fix is to apply FXAA to the shadowmask in order to smooth edges. This solution uses a GrabPass in the shader and might not be the most efficient, but it works fine and allows alternative shadows like NGSS.

Example Pics

No MSAA:

no MSAA

MSAA - no fix:

MSAA - no fix

MSAA - no fix:

MSAA - fix applied

Usage

Add MsaaShadowFix to any directional light. A commandbuffer is added on enable.

Notes

Great thanks to mattdesl for providing the fxaa shader code here: https://github.com/mattdesl/glsl-fxaa

About

A little fix for the directional shadows with msaa enabled in Unity3d.

License:MIT License


Languages

Language:ShaderLab 72.5%Language:C# 27.5%