OSVR-Unity-Rendering icon indicating copy to clipboard operation
OSVR-Unity-Rendering copied to clipboard

Strange shadow artifacts show up in VR HMD

Open ccll opened this issue 9 years ago • 7 comments

We're a VR HMD manufacturer and we've been connected our own headset to the OSVR with a custom plugin. When we use the OSVR-Unity package to develop a demo content, we inspected some shadow artifacts only showing up in the headset.

This image is the preview window in Unity, and there are no artifacts. preview

The same scene shot through the headset's lens, there are shadows on the cloud. bad1

And even stranger, when the headset pitches up gradually, the shadows disappear one-by-one, as below. bad2 bad3 bad4

Our server config:

{
    "display": "displays/xxxx.json",

    "server": {
        "sleep": 1 
    },

    "renderManagerConfig": {
        "meta": {
            "schemaVersion": 1
        },
        "renderManagerConfig": {
            "directModeEnabled": false,
            "directDisplayIndex": 0,
            "directHighPriorityEnabled": true,
            "numBuffers": 2,
            "verticalSyncEnabled": true,
            "verticalSyncBlockRenderingEnabled": false,
            "renderOverfillFactor": 1.0,

            "window": {
                "title": "xxxx",
                "fullScreenEnabled": true,
                "xPosition": 1920,
                "yPosition": 0
            },

            "display": {
                "rotation": 0,
                "bitsPerColor": 8
            },

            "timeWarp": {
                "enabled": true,
                "asynchronous": false,
                "maxMsBeforeVSync": 5
            }
        }
    }
}

Our display config:

{
  "meta": {
    "schemaVersion": 1
  },
  "hmd": {
    "device": {
      "vendor": "xxxx",
      "model": "xxxx",
      "num_displays": 1,
      "Version": "1.0",
      "Note": ""
    },
    "field_of_view": {
      "monocular_horizontal": 100.0,
      "monocular_vertical": 112.5,
      "overlap_percent": 100,
      "pitch_tilt": 0
    },
    "resolutions": [
      {
        "width": 2560,
        "height": 1440,
        "video_inputs": 1,
        "display_mode": "horz_side_by_side",
        "swap_eyes": 0
      }
    ],
    "distortion": {
        "type": "rgb_symmetric_polynomials",
        "distance_scale_x": 1,
        "distance_scale_y": 1.125,
        "polynomial_coeffs_red":   [ xxxx ],
        "polynomial_coeffs_green": [ xxxx ],
        "polynomial_coeffs_blue":  [ xxxx ]
    },
    "rendering": {
      "right_roll": 0,
      "left_roll": 0
    },
    "eyes": [
      {
        "center_proj_x": 0.6,
        "center_proj_y": 0.5,
        "rotate_180": 0
      },
      {
        "center_proj_x": 0.4,
        "center_proj_y": 0.5,
        "rotate_180": 0
      }
    ]
  }
}

Spec:

i7-4790k NVIDIA GTX970 Windows 7 64bit Unity3D 5.3.1f1 OSVR-Unity-v0.6.8-with-core-v0.6-1186-gacfbf41-build369

ccll avatar Apr 22 '16 10:04 ccll

Hi @ccll, Does this happen on other HMDs, or just the one you are manufacturing? It looks like a far clipping plane issue in Unity. I would narrow in on the differences between the preview camera and the eye cameras. You can set the clipping planes for the eye cameras: https://github.com/OSVR/OSVR-Unity/blob/master/OSVR-Unity/Assets/OSVRUnity/src/DisplayController.cs#L205

Given this information, I don't think there's an issue with the rendering plugin or config files. It's probably something in Unity.

DuFF14 avatar Apr 27 '16 01:04 DuFF14

@DuFF14 I've found out how to reproduce this. I've tested with our own HMD, an Oculus Rift DK2, and a third party Rift DK2 compatible HMD, all 3 HMDs behave the same if center_proj_x is the same.

0.5/0.5 == NO artifacts values other than 0.5/0.5 (for example 0.51/0.49) == ARTIFACTS!!

Our own HMD has a center_proj_x approximately at 0.6/0.4, while DK2 is 0.5/0.5, so in previous test the artifacts only show up in our own HMD, until I messed with DK2 settings.

I don't know the internals of COP handling, but I suppose it affects projection matrix, and I recall some articles mentioned that custom projection matrix can break shadows in Unity3D. Is that relevant here?

ccll avatar Apr 29 '16 04:04 ccll

Aha, thanks for the info. I hadn't heard about that custom projection matrix problem, but it sounds like it could be related. I will look into it..

DuFF14 avatar Apr 29 '16 13:04 DuFF14

See https://github.com/OSVR/OSVR-Docs/blob/master/Configuring/projectionAndViewMatrices.md for a description of the OSVR RenderManager transformations. Details of the meanings for center of projection, fields of view, overlap percentage and so forth are in https://github.com/OSVR/OSVR-Docs/blob/master/Configuring/distortion.md and to see how to programmatically set them from a new HMD along with distortion correction, see https://github.com/OSVR/distortionizer/blob/master/angles_to_config/doc/anglesToConfig.md

russell-taylor avatar May 02 '16 20:05 russell-taylor

Just discovered that the shadow artifacts only show up in dynamic lighting, when we bake all lights into static lightmaps there are no artifacts.

ccll avatar May 24 '16 08:05 ccll

@ccll Are you using forward or deferred rendering? Can you test if the other option gives you the same artifacts?

DuFF14 avatar May 24 '16 16:05 DuFF14

@DuFF14 Confirmed that both forward and deferred rendering produces the artifacts.

ccll avatar May 26 '16 03:05 ccll