# Stereoscopy in VR

**URL:** <https://discourse.processing.org/t/stereoscopy-in-vr/19030>\
**Category:** Processing for Android\
**Created:** [March 26, 2020, 10:14am UTC](https://discourse.processing.org/t/stereoscopy-in-vr/19030 "2020-03-26T10:14:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMarco](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@JMarco](https://discourse.processing.org/u/JMarco)\
**Post date:** [March 26, 2020, 10:14am UTC](https://discourse.processing.org/t/stereoscopy-in-vr/19030/1 "2020-03-26T10:14:36Z")

</div>

Hi!

I am not new in Processing, but I am new in VR mode.

I have started developing some simple 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.  
I have calibrated my VR glasses, I have stereo effect in other comercial VR Apps.

What am I doing wrong?

Thanks!  
Javi

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [March 26, 2020, 10:30am UTC](https://discourse.processing.org/t/stereoscopy-in-vr/19030/2 "2020-03-26T10:30:10Z")

</div>

I definitely have to buy VR glasses to try out this stuff.  
I would place an issue on P4A on Github [here](https://github.com/processing/processing-android/issues).

---

<div class="post-metadata">

**Author:** ![JMarco](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@JMarco](https://discourse.processing.org/u/JMarco)\
**Post date:** [March 29, 2020, 3:52pm UTC](https://discourse.processing.org/t/stereoscopy-in-vr/19030/3 "2020-03-29T15:52:40Z")

</div>

Since it seems stereoscopy is not implemented in Processing VR, I have developed a short code that does the trick. Hope this may be usefull to other developers.

```auto
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;

//e
PMatrix3D eyeMat = new PMatrix3D();

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;
 

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

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;
}

```
