satoshinm / NetCraft

Web-based fork of fogleman/Craft ⛺
https://satoshinm.github.io/NetCraft/
MIT License
56 stars 13 forks source link

Add resolution-dependent VR parameters for DK1 support. Closes GH-185 #185

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago

For supporting other VR headsets, DK1, DK2. The goal is to support Cardboard. These demos work (polyfilled): https://webvr.info/samples/ - port what they are doing over to this project.

satoshinm commented 7 years ago

Skeptical of using WebVR https://webvr.info/samples/ , the samples feel laggier than native, without browser support requires a large polyfill in JavaScript - why not use the existing non-WebVR distortion shader, and adjust it for Google Cardboard.

Found some parameters on https://github.com/toji/webvr.info/blob/e00559c5b8bd1bc7ad050e9be07991ccf8c986ad/samples/js/third-party/webvr-polyfill.js#L2279:

// Fallback Android device (based on Nexus 5 measurements) for use when
// we can't recognize an Android device.
var DEFAULT_ANDROID = new Device({
  widthMeters: 0.110,
  heightMeters: 0.062,
  bevelMeters: 0.004
});

// Fallback iOS device (based on iPhone6) for use when
// we can't recognize an Android device.
var DEFAULT_IOS = new Device({
  widthMeters: 0.1038,
  heightMeters: 0.0584,
  bevelMeters: 0.004
});

var Viewers = {
  CardboardV1: new CardboardViewer({
    id: 'CardboardV1',
    label: 'Cardboard I/O 2014',
    fov: 40,
    interLensDistance: 0.060,
    baselineLensDistance: 0.035,
    screenLensDistance: 0.042,
    distortionCoefficients: [0.441, 0.156],
    inverseCoefficients: [-0.4410035, 0.42756155, -0.4804439, 0.5460139,
      -0.58821183, 0.5733938, -0.48303202, 0.33299083, -0.17573841,
      0.0651772, -0.01488963, 0.001559834]
  }),
  CardboardV2: new CardboardViewer({
    id: 'CardboardV2',
    label: 'Cardboard I/O 2015',
    fov: 60,
    interLensDistance: 0.064,
    baselineLensDistance: 0.035,
    screenLensDistance: 0.039,
    distortionCoefficients: [0.34, 0.55],
    inverseCoefficients: [-0.33836704, -0.18162185, 0.862655, -1.2462051,
      1.0560602, -0.58208317, 0.21609078, -0.05444823, 0.009177956,
      -9.904169E-4, 6.183535E-5, -1.6981803E-6]

but these don't clearly correspond to the OculusRiftEffect based shader parameters:

        hScreenSize = 0.14976;
        vScreenSize = 0.0936;
        interpupillaryDistance = 0.064;
        lensSeparationDistance = 0.064;
        eyeToScreenDistance = 0.041;
        distortionK[0] = 1.0;
        distortionK[1] = 0.22;
        distortionK[2] = 1.24;
        distortionK[3] = 0.0;
        chromaAbParameter[0] = 0.996;
        chromaAbParameter[1] = -0.004;
        chromaAbParameter[2] = 1.014;
        chromaAbParameter[3] = 0.0;
satoshinm commented 7 years ago

Not supporting cardboard, but merging what I have so far