cancel
Showing results for 
Search instead for 
Did you mean: 

Mesh Edges Flickering?

Rezzolution
Level 2
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!
20 REPLIES 20

drash
Level 7
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.

Rezzolution
Level 2
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!

drash
Level 7
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?

cybereality
Level 15
Can you take a video of the problem? I'm not sure I have heard of this before.

Rezzolution
Level 2
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?

Rezzolution
Level 2
Yeah sure I'll see if I can get a little video up here (unless that last post gives away what's going on..?)

Rezzolution
Level 2
Okay here's a little video showing the flickering:

http://www.youtube.com/watch?v=KLV5Xg4mglM&feature=youtu.be

Rezzolution
Level 2
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!

boone188
Level 2
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;
}