Skip to main content
Up and Coming
November 21, 2013

Mesh Edges Flickering?

Hey guys! Hoping to get a little help with a bit of a problem I've been having on my project for quite some time now and have had no success in figuring out.. the problem is that many of the models of buildings that I import from 3dsmax have this flickering happening on many of the mesh's edges. It's rather consistent, though for some reason when looking straight on with a wall or something seems to minimize the flickering..? What's even weirder to me is that it only happens when I have OVR mode enabled in my game. Using just a normal camera looks just fine. I'm just so lost with this one I'm not even sure where I should be looking..

My OVR camera setup is using 3 cameras - one with very low near and far clip planes for my Player layer, one very far for my sky layer, and the other for everything else. Not sure if that helps really.. =/

Thanks in advance for your time and suggestions!
    This topic has been closed for replies.

    20 replies

    Inspiring
    November 21, 2013
    The behavior kinda sounds like depth-fighting, with surfaces/polys that are too close to each other depth-wise for the clipping planes you're using. But, if it's only happening when using Rift cameras? I'm not sure.

    Are you sure the clipping planes involved are the same for Rift cameras vs nonRift cameras? Maybe verify the values on the Cameras themselves, not just the OVRCameraControllers. Some have reported issues with the clipping plane values at the OVRCameraController not being propagated down to the Cameras themselves at runtime.
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Up and Coming
    November 21, 2013
    Yeah I was thinking depth fighting too but it actually looks perfectly fine while not using OVR cameras so I guess it can't be that.. so yeah I went ahead and made sure that the clip values were changing properly and they are.. I'll give a little more info on how exactly I've got all of the cameras set up:

    Main Camera - No OVR - Works great!

    Clear Flags: Skybox
    Near clip: 0.15
    Far clip: 1500

    OVR Camera 1 - Player Camera

    Clear Flags : Depth Only
    Near clip: 0.01
    Far clip: 2.5
    Depth Values : Left = 4, Right = 5

    OVR Camera 2 - Skybox Camera (using custom skybox solution)

    Clear Flags : Depth Only
    Near clip: 1000
    Far Clip: 5000
    Depth Values : Left = 0, Right = 1

    OVR Camera 3 - Everything else Camera

    Clear Flags : Depth Only
    Near Clip : 2.5
    Far Clip : 1500
    Depth Values : Left = 2, Right = 3

    I hope this gives a little more direction!
    Inspiring
    November 21, 2013
    Just realized you said mesh edges. Are these meshes drawn with a specular shader of some kind with MSAA thrown on top? That can make some nasty white/shimmery edges show up, and is pretty obvious in the Rift with lens correction applied.

    If that's not it, then hmm... which camera rigs are repsonsible for drawing the meshes with the flickering problem?
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Inspiring
    November 22, 2013
    Can you take a video of the problem? I'm not sure I have heard of this before.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    November 22, 2013
    No none of my textures are using any fancy shaders at all right now all of them are just diffuse. HOWEVER! After doing some fiddling around, I think I'm making some progress... So the third camera is what is responsible for rendering the buildings that are flickering.. but what I've discovered is that if I disable this camera game object while in Play mode and then turn it back on, it doesn't flicker!! This is great, but I'm really not sure why this is. I guess I can just script the camera to refresh itself like that when the level loads, but it still seems a bit off that I would even have to do that!

    Thoughts?
    Up and Coming
    November 22, 2013
    Yeah sure I'll see if I can get a little video up here (unless that last post gives away what's going on..?)
    Up and Coming
    November 22, 2013
    Okay here's a little video showing the flickering:

    http://www.youtube.com/watch?v=KLV5Xg4mglM&feature=youtu.be
    Up and Coming
    November 22, 2013
    OKAY! I think I may have figured this all out..... after banging my head against this all day I tried going ahead and manually setting the hard values for each OVR camera clip plane (before I was just setting it in the parent object and letting the camera script change the values at runtime - which it actually was, it just seems that doing it at runtime was the problem). After making sure that the values are set where I need them individually beforehand, the problem no longer persists. Hope this helps out anyone else who encounters this problem!
    Up and Coming
    November 22, 2013
    Glad to hear you found the fix.

    But it seems it's really important to get this fix into the next release. I've had to post this in 4 different threads. All that needs to happen is that OVRCameraController needs to modify the clip plane before modifying the perspective matrix :

    bool ConfigureCamera(ref Camera camera, float distOffset, float perspOffset, float eyePositionOffset)
    {
    Vector3 PerspOffset = Vector3.zero;
    Vector3 EyePosition = EyeCenterPosition;

    // Vertical FOV
    camera.fieldOfView = VerticalFOV;

    // Aspect ratio
    camera.aspect = AspectRatio;

    // Centre of lens correction
    camera.GetComponent<OVRLensCorrection>()._Center.x = distOffset;
    ConfigureCameraLensCorrection(ref camera);

    // Clip Planes
    camera.nearClipPlane = NearClipPlane;
    camera.farClipPlane = FarClipPlane;

    // Perspective offset for image
    PerspOffset.x = perspOffset;
    camera.GetComponent<OVRCamera>().SetPerspectiveOffset(ref PerspOffset);

    // Set camera variables that pertain to the neck and eye position
    // NOTE: We will want to add a scale vlue here in the event that the player
    // grows or shrinks in the world. This keeps head modelling behaviour
    // accurate
    camera.GetComponent<OVRCamera>().NeckPosition = NeckPosition;
    EyePosition.x = eyePositionOffset;

    camera.GetComponent<OVRCamera>().EyePosition = EyePosition;

    // Background color
    camera.backgroundColor = BackgroundColor;

    return true;
    }
    Inspiring
    November 22, 2013
    OK, I will have one of our Unity developers take a look into this.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV