New To The Forum? Click Here To Read The How To Guide. -- Developers Click Here.

[Solved] Weird flickering with Avatars SDK mesh

haydenjamesleehaydenjameslee Posts: 43
Brain Burst
Just started messing with the Avatar SDK and I'm getting weird mesh flickering. Check out the gif. What am I screwing up?

«1

Comments

  • haydenjamesleehaydenjameslee Posts: 43
    Brain Burst
    Using Oculus Utilities 1.8, Oculus SDK 1.8 & Unity 5.4.1p1
  • haydenjamesleehaydenjameslee Posts: 43
    Brain Burst
    edited November 2016
    Think I worked it out. I didn't remove the OvrTouch package before importing OvrAvatars.

    Nope that didn't help.
  • NoughtceratopsNoughtceratops Posts: 8 Oculus Staff
    That looks like z-fighting with the depth prepass used to make the hands appear self-occluding. What kind of graphics card do you have? If we have one handy, I can try to reproduce.
  • haydenjamesleehaydenjameslee Posts: 43
    Brain Burst
    I'm using a Nvidia 980. I found that if I put that shader on other meshes it has the same problem, so definitely seems like that self occluding shader is messed up somehow.

    Also, I just confirmed that it doesn't happen when I load that avatars SDK into a fresh Unity project, so something in our project must be conflicting.
  • NoughtceratopsNoughtceratops Posts: 8 Oculus Staff
    Is there any chance you're doing anything to adjust the resolution of the depth buffer in your render scene?

    One thing you can try is biasing the depth test in the avatar surface shaders to try to cover precision issues. If you go into AvatarSurfaceShaderPBS and AvatarSurfaceShaderSelfOccluding and add a line like:
    Offset -0.1, -1
    before CGPROGRAM, you may be able to offset any precision issues. (Full documentation on shader depth test offsets here: https://docs.unity3d.com/Manual/SL-CullAndDepth.html )
  • haydenjamesleehaydenjameslee Posts: 43
    Brain Burst
    Strangely it doesn't happen in our master scene, only the example scenes, so this isn't a blocking problem for us. Will try out that fix tomorrow just to see if that's the cause.
  • SonderSonder Posts: 5
    NerveGear
    Did you ever figure out the cause or solution to this? I'm having the same problem. 
  • digibixdigibix Posts: 6
    NerveGear
    I fixed a problem similar to that by NOT using the Single Pass Stereo (Unity 5.4) or by using the Stereo Rendering Mode: Multipass (Unity 5.5) on the Players Settings....

    Its seems that the Avatar SDK shaders are not yet compatible with single pass stereo.... 

    You can try on the editor by toogling the option when running the game on the editor.....
  • jlinkjlink Posts: 19
    NerveGear
    edited December 2016
    I am having this issue currently as well, and can confirm that multi pass stereo rendering "fixes" it.

    Edit: I just tried Noughtceratops'es fix, and while offset values of -0.1, -1 didn't work (it made the materials completely invisible), values of 0.1, 1 fix the flickering issue.
  • DorakoDorako Posts: 4
    NerveGear
    I had this issue initially but it fixed itself (yay?). But I have another, probably linked issue where occlusion will randomly be enabled or disabled for the glowy hand shader. On launch I can see my fingers through my hands. If I hit 'start with controllers' and re-play the scene then the shader will be fixed (similar to how it acts in the overlay scene and Home), and if I remove the controller tickmark stuff will be ready to go. Weird.
  • KevinLongtimeKevinLongtime Posts: 281
    Nexus 6
    edited December 2016
    I can confirm that for me on GTX 970 5.5.0p2 turning off stereo single pass rendering solved this issue. 
  • owenwpowenwp Posts: 642
    Art3mis
    That fixed the flickering, but now there is incorrect triangle sorting only on my right hand.  Some random patches of triangles are showing through the back of the hand consistently.
    Sanzaru - Programmer
  • cubic9comcubic9com Posts: 6
    NerveGear
    I found that AvatarSurfaceShaderPBS.shader might cause this.
    So I did a rough workaround.
    I added following code at OvrAvatarRenderComponent.cs:75
    shaderPath = "OvrAvatar/AvatarSurfaceShader";
    There might be a little more better workaround...
    Hardware:
    Model: G-GEAR note N1581J-711/E based on MSI MS-16F4.
    CPU: i7-4712MQ
    Chipset: Intel HM87 Chipset
    GPU: NVIDIA GTX 870M 3GB with Optimus
    Geforce driver: 352.86
    OS: Win7 Home 64bit
    Unity 5.0.2p1
  • IvanAtBestIvanAtBest Posts: 3
    NerveGear
    I'm having this issue as well with Single Pass rendering. Any way we could look deeper into what's causing it?
  • MickyXMickyX Posts: 54
    Hiro Protagonist
    Thought I would add in I have the same issue also using GTX 1070.

    I've had it come up a few times and then it fixed its self, so I tended to just ignore it. But it's been doing it now for around a week. 
  • sunilnayak133sunilnayak133 Posts: 1
    NerveGear
    I have an issue where it's not flickering in the Unity Editor, but it does in the build.
  • chrisnoletchrisnolet Posts: 13
    NerveGear
    edited February 21
    I had the same weird flickering issue. Both solutions mentioned above worked for me: switching to multi-pass, or editing AvatarSurfaceShaderPBS.shader and AvatarSurfaceShaderSelfOccluding.shader and adding `Offset 1, 1` before CGPROGRAM. (My experience was similar to @jlink's: the offset values needed to be positive for this to work. I also had to change the decimal factor to a whole number: `1, 1` instead of `0.1, 1`, because I was still getting some flickering with the decimal.) Editing the shaders seems to be the best solution, performance-wise.

    I was also getting occlusion issues, the same as @owenwp. Sometimes I could see my fingers through my hands, on both hands, or sometimes just on one hand. I fixed this by editing `OvrAvatarRenderComponent.cs` and changing the line: `shaderPath = selfOccluding ? "OvrAvatar/AvatarSurfaceShaderSelfOccluding" : "OvrAvatar/AvatarSurfaceShader";` to simply: `shaderPath = "OvrAvatar/AvatarSurfaceShaderSelfOccluding";`.

    I hope this helps the next person! Also, I hope they fix these issues in OvrAvatar 1.11 :)
  • ColdSpikeColdSpike Posts: 27
    Brain Burst
    I would also like to know how to fix this. I added that line from a few posts above and it mostly solved issues but the hands still look odd with missing parts and now the controllers are invisible...
  • chrisnoletchrisnolet Posts: 13
    NerveGear
    @ColdSpike, does if work if you use `Offset 1, 1` instead of `Offset 0.1, 1`?
  • ColdSpikeColdSpike Posts: 27
    Brain Burst
    @ColdSpike, does if work if you use `Offset 1, 1` instead of `Offset 0.1, 1`?
    Fixed by updating to a stable Unity release. Sorry I'm not sure what the problem was.
  • paw9kpaw9k Posts: 11
    NerveGear
    cubic9com said:
    I found that AvatarSurfaceShaderPBS.shader might cause this.
    So I did a rough workaround.
    I added following code at OvrAvatarRenderComponent.cs:75
    shaderPath = "OvrAvatar/AvatarSurfaceShader";
    There might be a little more better workaround...
    This fixed it for me.  Switching off of Single pass to Multi pass did not fix it.  I was on 5.5.1f1
  • chrisnoletchrisnolet Posts: 13
    NerveGear
    I tried that, too, but I noticed that the meshes were no longer self-occluding. (I could see my fingers through my hands.)
  • YoirglYoirgl Posts: 118
    Art3mis
    I have the same problem with unity 5.6beta and the latest avatar SDK 1.12. i tried all of the above and it didn't work (except the OvrAvatarRenderComponent modification as i can't find a variable named shaderPath anywhere in the file)
    also using gtx980, latest nvidia drivers.
  • chrisnoletchrisnolet Posts: 13
    NerveGear
    edited March 13
    Hi @Yoirgl. You're right: OvrAvatarRenderComponent has completely changed in 1.12. Can you confirm your PBS and self-occluding shaders now look like this?

        ZWrite On
        Cull Off
        ColorMask 0
        Offset 1, 1

        CGPROGRAM
        #pragma vertex vert

    I can confirm that this fix works for me on 1.12 with 5.5.1p4, (as does switching off single-pass stereo).
  • YoirglYoirgl Posts: 118
    Art3mis
    Hi @Yoirgl. You're right: OvrAvatarRenderComponent has completely changed in 1.12. Can you confirm your PBS and self-occulting shaders now look like this?

        ZWrite On
        Cull Off
        ColorMask 0
        Offset 1, 1

        CGPROGRAM
        #pragma vertex vert

    i can confirm that this works for me on 1.12 with 5.5.1p4, (as does switching off single-pass stereo).
    Hello ;-)
    I will check that in 8 hours after my job :p will let you know. However from memory i don't think it looks anywhere like this.
  • BlastoIOBlastoIO Posts: 3
    NerveGear
    edited March 13
    Try changing the two occurrences of mul(UNITY_MATRIX_MVP, v.vertex) to UnityObjectToClipPos(v.vertex)

    Doc Link

    I noticed the texture was moving on the object between draws in the same frame. When I created a variant of the two, I could toggle the effect. I then saw a higher accuracy when using UnityObjectToClipPos (expected vs actual points) when drawing a cube.

    As an added bonus, the vert shader for d3d11 uses 8 ops vs 20 ops when using mul, meaning better performance. Even better, this allows the (unnecessary in this case but enabled by default) d3d9/d3d11_9x variants to compile successfully.

    For me, this works for all the exceptions listed in this thread using Avatar SDK 1.12.0 in both Unity 5.5.2p2 and Unity 5.6.0b11.
  • YoirglYoirgl Posts: 118
    Art3mis
    BlastoIO said:
    Try changing the two occurrences of mul(UNITY_MATRIX_MVP, v.vertex) to UnityObjectToClipPos(v.vertex)

    Doc Link

    I noticed the texture was moving on the object between draws in the same frame. When I created a variant of the two, I could toggle the effect. I then saw a higher accuracy when using UnityObjectToClipPos (expected vs actual points) when drawing a cube.

    As an added bonus, the vert shader for d3d11 uses 8 ops vs 20 ops when using mul, meaning better performance. Even better, this allows the (unnecessary in this case but enabled by default) d3d9/d3d11_9x variants to compile successfully.

    For me, this works for all the exceptions listed in this thread using Avatar SDK 1.12.0 in both Unity 5.5.2p2 and Unity 5.6.0b11.
    Thank you for this elegant and very effective solution. this fixed my problem instantly :)

  • chrisnoletchrisnolet Posts: 13
    NerveGear
    Elegant! Works for me, too :) I think I like this solution the best.
  • metrocubemetrocube Posts: 55 Oculus Staff
    edited March 20
    BlastoIO said:
    For me, this works for all the exceptions listed in this thread using Avatar SDK 1.12.0 in both Unity 5.5.2p2 and Unity 5.6.0b11.
    Edit: After posting this, I removed my Offset 1,1 from the shaders and it's working great with UnityObjectToClipPos.  I need to backtrack and see what else I did.

    For me, this caused some other artifacts in the Unity Game view and the flickering wasn't completely squashed. But adding Offset 1,1 gets rid of the flickering with single-pass stereo for me. Unity 5.4.4f1 with Avatar 1.12.

    Getting the perf gains from switching to UnityObjectToClipPos is great, I'm just saying it didn't fix the z-fighting for me.
  • BlastoIOBlastoIO Posts: 3
    NerveGear
    metrocube said:
    BlastoIO said:
    For me, this works for all the exceptions listed in this thread using Avatar SDK 1.12.0 in both Unity 5.5.2p2 and Unity 5.6.0b11.
    Edit: After posting this, I removed my Offset 1,1 from the shaders and it's working great with UnityObjectToClipPos.  I need to backtrack and see what else I did.

    For me, this caused some other artifacts in the Unity Game view and the flickering wasn't completely squashed. But adding Offset 1,1 gets rid of the flickering with single-pass stereo for me. Unity 5.4.4f1 with Avatar 1.12.

    Getting the perf gains from switching to UnityObjectToClipPos is great, I'm just saying it didn't fix the z-fighting for me.
    I tested it on 5.4.4f1 as well and had no issues with the visual either. However, that Unity version was below min req for dependency SDKs to the Avatar SDK, causing a crash whenever I press any button on my touch controller.

    As for backtracking, yay for friends like source control and text diffs. Good luck!
«1
Sign In or Register to comment.