Skip to content

Stereoscopy in VR mode? #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmarco2000 opened this issue Mar 26, 2020 · 4 comments
Closed

Stereoscopy in VR mode? #593

jmarco2000 opened this issue Mar 26, 2020 · 4 comments

Comments

@jmarco2000
Copy link

I have started developing some simple VR examples, and I realized that the is not stereoscopy effect in VR; I mean, both left eye and right eye images are exactly the same, no matter objects are placed at different distances from the camera (parallax effect), thus, I don't have depth perception of distances (image looks flat).
I read in the VR introduction, and it says that Processing does all eye transformations in Stereo Mode; hovewer it seems to me that it just duplicates the same render to both eyes. am I right?

Thanks!

@puran1999
Copy link

I am also having the same issue

@jmarco2000
Copy link
Author

jmarco2000 commented Mar 29, 2020

I have developed a short code that moves the camera between eyes, so this gives you stereoscopy.
Hope this may be usefull to you and other developers:

import processing.vr.*;

int eyedist = 50;

VRCamera cam;

float angulo=0;

float cx, cz;
float px, pz;
float ang;
float orbita = 400;
float vorbita = 0.01;

// eye matrix
PMatrix3D eyeMat = new PMatrix3D();

boolean ciclo = false;  //test witch eye is beign draw
float orientacion;

void setup() {
  fullScreen(VR);
  cameraUp();
  rectMode(CENTER);
  cam = new VRCamera(this);
  cam.setNear(10);
  cam.setFar(2500);

  //posicion planeta
  //centro
  cx=width/2;
  cz=-200;
  ang=0;
}

void draw() {
  ciclo = !ciclo;

  background(0);
  lights();
  if (!ciclo) {
    getEyeMatrix(eyeMat);
    orientacion = acos(eyeMat.m00);
    if (eyeMat.m02 < 0) orientacion =- orientacion;
    println(degrees(orientacion));
  }
  if (ciclo) {
    cam.setPosition(+(eyedist/2) * cos(orientacion), 100, 500 + (eyedist/2) * sin(orientacion));
  } else {
    cam.setPosition(-(eyedist/2) * cos(orientacion), 100, 500 - (eyedist/2) * sin(orientacion));
  }
  
  pushMatrix();
  px = cx + cos(ang) * orbita;
  pz = cz + sin(ang) * orbita;
  translate(px, 100, pz);
  ang = ang + vorbita;
  rotateY(1.25);
  rotateX(-0.4);
  rotateZ(angulo); //angulo=angulo+0.01;
  noStroke();
  fill(251, 100, 10);
  box(100);
  popMatrix();

  pushMatrix();
  translate(width/2, 100, cz);
  rotateY(1.25);
  rotateX(-0.4);
  rotateZ(angulo); //angulo=angulo+0.01;
  noStroke();
  fill(0, 200, 10);
  sphere(70);
  popMatrix();
}

void mousePressed() {
  vorbita = 0;
}

void mouseReleased() {
  vorbita = 0.01;
}

@codeanticode
Copy link
Contributor

@jmarco2000 thanks for posting this code, I think it can make a good example to add to the mode :-)

@codeanticode
Copy link
Contributor

Added with this commit: 407c2f8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants