OCASM / SSMS

Screen space multiple scattering for Unity.
705 stars 84 forks source link

Fix artifacts appearing on objects using distance fog #5

Closed Chikanz closed 6 years ago

Chikanz commented 6 years ago

Hi! I absolutely love this effect, thanks for making and releasing it for free! I'm not sure if you still maintain it but I'd love to add a small fix for a problem I had.

When I first imported it I got some wicked artifacts appearing on close objects using distance fog only: artifacts

Stepping through the frame debugger I found that the fog render texture wasn't rendering at the same size as the camera, causing it to be up-scaled, causing huge artifacts. frame debugger

I think this is because the effect is rendering in scene view and the size of the RT is being cached. I then made the scene maximize on play, causing the view port to be sized differently.

To fix this I've simply set the fogRT variable to create a new instance when the RT's size is less than the source texture's size. Pretty tiny fix but it drove me nuts for like 3 hours lol. I've also recompiled the Unity package with the new script for download. You can verify that only the script has been changed.

Also sorry the formatting is a little messed up, it's my first PR! I can try fix it if you'd like though it shows up fine in Visual Studio for me ¯\_(ツ)_/¯

Cheers!

OCASM commented 6 years ago

Thanks for the fix!