I have two 256 degree lenses. I put them side to side to create wide angle stereoscopic videos. I want to show them on VR. Right now I am using sphere geometry to show videos but it has some problems. I need a good texture mapping. I could found only for 180 degree videos which does not work for 256 degree.
The texture mapping I am using is below.
var faceVertexUvsleft = geometryleft.faceVertexUvs[0];
for (var i = 0; i < faceVertexUvsleft.length; i++) {
var uvs = faceVertexUvsleft[i];
var face = geometryleft.faces[i];
for (var j = 0; j < 3; j++) {
var x = face.vertexNormals[j].x;
var y = face.vertexNormals[j].y;
var z = face.vertexNormals[j].z;
var currentRadius = (1 - y) * radius; //(1 - y) goes from 0 to 2
var correction = (x === 0 && z === 0) ? 1 : Math.acos(y) / (Math.PI / 2) / Math.sqrt(x * x + z * z);
if ((1 - y) < 1) {
uvs[j].x = x * 0.5 * radius * correction + 0.5;
uvs[j].y = z * 0.5 * radius * correction + 0.5;
} else {
var radiusOfXZ = Math.sqrt(x * x + z * z);
var newRadius = 1 + 1 - radiusOfXZ;
var newX = x * newRadius / radiusOfXZ;
var newZ = z * newRadius / radiusOfXZ;
uvs[j].x = x * 0.5 * radius * correction + (newX - x) * 0.5 * radius + 0.5;
uvs[j].y = z * 0.5 * radius * correction + (newZ - z) * 0.5 * radius + 0.5;
}
}
}