Placeholder-Software / WetSurfaceDecals

14 stars 2 forks source link

Sparkling / Framebuffer flickering on MacOS #8

Closed hariedo closed 6 years ago

hariedo commented 6 years ago

Context

Upon initial installation into a fresh project on a fast MacOS i7, in Unity 2018.2.1f1 build, every demo suffers a strong flickering effect, where the front and back buffers are getting different results. It's not quite like 100% dry, 100% wet cycling, but it's obvious there's some kind of timing or clearing issue with this setup.

I double-checked the camera settings all say "Deferred" and the default quality settings are high. Will try other settings if suggested.

Expected Behavior

Expected flicker-free consistency in the lighting and affected "wet" areas where the decals are applied.

Actual Behavior

Framebuffer-based flickering in decal-affected areas of all demos.

Your Environment

TomGillen commented 6 years ago

Have you been able to reproduce this on any other machine, or with different Unity versions? Does the flickering occur in edit mode and play mode, or only in one?

As I have not seen this myself on my own Mac, I may need you to do a little investigating for me:

image

image

This should hopefully at least narrow down where the problem is being introduced.

hariedo commented 6 years ago

At the moment I only have Unity on one machine. I will try installing it on an older MacBook Pro, but I don't have any non-Mac devices.

Captured this unlisted video which I think includes what you're asking for.

https://www.youtube.com/watch?v=q3nvD3rMGbo

-- [ e d @ h a l l e y . c c ]

On Sep 4, 2018, at 2:35 AM, Thomas Gillen notifications@github.com wrote:

Have you been able to reproduce this on any other machine, or with different Unity versions? Does the flickering occur in edit mode and play mode, or only in one?

As I have not seen this myself on my own Mac, I may need you to do a little investigating for me:

Open the 1. Puddle demo scene. Open the frame debugger (Window -> Frame Debugger), and pause rendering for both cases (effect on and off). For both cases, take a screenshot of the game view for both of these rendering events: https://user-images.githubusercontent.com/534054/44997670-f800c780-afa7-11e8-90fb-f62b03f05d43.png https://user-images.githubusercontent.com/534054/44997677-05b64d00-afa8-11e8-80c9-d06e1dd3dfa4.png This should hopefully at least narrow down where the problem is being introduced.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/WetSurfaceDecals/issues/8#issuecomment-418167046, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKtLN-ZKtVyyg9QUFxKEZwGUZBk1Efoks5uXWh1gaJpZM4WWZwo.

TomGillen commented 6 years ago

Thanks for that, this helps a lot. It is clearly an issue with the saturation calculations, rather than with the application of the effect. I'll do some investigating on my end and hopefully come back with something (probably more questions) soon.

hariedo commented 6 years ago

No problem at all, glad to help. I have seen people saying there's issues with other decal shaders in recent Unity builds, but I hope that's not the case here.

-- [ e d @ h a l l e y . c c ]

On Sep 5, 2018, at 10:15 PM, Thomas Gillen notifications@github.com wrote:

Thanks for that, this helps a lot. It is clearly an issue with the saturation calculations, rather than with the application of the effect. I'll do some investigating on my end and hopefully come back with something (probably more questions) soon.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/WetSurfaceDecals/issues/8#issuecomment-418726169, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKtLCfY9Jn8gQDLt8IEcrNVHQGc94D7ks5uX85-gaJpZM4WWZwo.

TomGillen commented 6 years ago

An update on this: I am still investigating, and have reproduced on a Mac. The issue seems to be greater than the symptoms reported, as there are also some bizarre bugs related to a full screen quad not rendering in the correct location and Unity binding incorrect transforms to shaders (via internal shader variables). I have reproduced this in Unity 2017.3-2018.2, so it is not a regression in Unity as we were certainly working correctly in 2017.3 on Mac.

hariedo commented 6 years ago

Appreciate the update-- hope it finds a fix in time the 2018.3 or 2018.4 LTS. :)

-- [ e d @ h a l l e y . c c ]

On Sep 15, 2018, at 12:04 AM, Thomas Gillen notifications@github.com wrote:

An update on this: I am still investigating, and have reproduced on a Mac. The issue seems to be greater than the symptoms reported, as there are also some bizarre bugs related to a full screen quad not rendering in the correct location and Unity binding incorrect transforms to shaders (via internal shader variables). I have reproduced this in Unity 2017.3-2018.2, so it is not a regression in Unity as we were certainly working correctly in 2017.3 on Mac.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/WetSurfaceDecals/issues/8#issuecomment-421387794, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKtLIKdsuF3q0p4RHaW-Gzn-oUqc8wMks5ua8V6gaJpZM4WWZwo.

TomGillen commented 6 years ago

I have narrowed this down to some kind of problem with shader parameter passing for instanced shader variables. I am still not sure exactly what is going wrong here - and certainly why it would only be broken on mac. However, it does at least mean that there is a workaround that will allow the project to render correctly; we can disable instancing on macOS.

The setting for this is not exposed in the GUI, but if you want to implement the workaround yourself, replace the property for RenderSettings.EnableInstancing (Assets/Plugins/PlaceholderSoftware/WetStuff/Core/Rendering/RenderSettings.cs:18) with the following:

public bool EnableInstancing
{
    get
    {
        var mac = Application.platform == RuntimePlatform.OSXEditor ||
                        Application.platform == RuntimePlatform.OSXPlayer
        return !mac && !_disableInstancing;
    }
    set { _disableInstancing = !value; }
}

I'll be putting together a new release soon, and will either include this workaround or a proper fix in that release.

hariedo commented 6 years ago

I just tried every scene with the workaround, and it looks good! Of course, losing instancing on Mac is not ideal but it's no show-stopper.

Have you worked with anyone at Unity to see why the Mac is behaving badly with regards to the instancing or the parameter passing?

-- [ e d @ h a l l e y . c c ]

On Sep 19, 2018, at 11:16 AM, Thomas Gillen notifications@github.com wrote:

I have narrowed this down to some kind of problem with shader parameter passing for instanced shader variables. I am still not sure exactly what is going wrong here - and certainly why it would only be broken on mac. However, it does at least mean that there is a workaround that will allow the project to render correctly; we can disable instancing on macOS.

The setting for this is not exposed in the GUI, but if you want to implement the workaround yourself, replace the property for RenderSettings.EnableInstancing (Assets/Plugins/PlaceholderSoftware/WetStuff/Core/Rendering/RenderSettings.cs:18) with the following:

public bool EnableInstancing { get { var mac = Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer return !mac && !_disableInstancing; } set { _disableInstancing = !value; } } I'll be putting together a new release soon, and will either include this workaround or a proper fix in that release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/WetSurfaceDecals/issues/8#issuecomment-422624495, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKtLOMQCiUOTHFpbXc2f3kdZ_aPhRLVks5ucajzgaJpZM4WWZwo.

martindevans commented 6 years ago

Wet Stuff 1.0.2 just went live on the asset store with a fix for this issue. I'll close this issue now, don't hesitate to re-open it if the issue persists :)