/** * GLSL shaders for dual fisheye projection. * * A dual fisheye texture contains two circular fisheye images side by side: * - Left circle: front hemisphere (z >= 0) * - Right circle: back hemisphere (z < 0) * * For stereo content (SBS or TB), the entire dual-fisheye pair is packed * into a sub-region of the texture. Uniforms uScaleX/uScaleY/uOffsetX/uOffsetY * select the appropriate region per eye. */ /** Fisheye vertex shader -- passes world position to fragment shader */ export declare const fisheyeVertexShader = "\nvarying vec3 vWorldPosition;\n\nvoid main() {\n vec4 worldPos = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPos.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; /** * Dual fisheye fragment shader -- maps sphere surface to circular fisheye UV. * * Stereo uniforms allow selecting a sub-region of the texture: * - uScaleX / uScaleY: scale factor applied to the final UV (1.0 = full, 0.5 = half) * - uOffsetX / uOffsetY: offset added after scaling (0.0 or 0.5 for stereo halves) */ export declare const fisheyeFragmentShader = "\nuniform sampler2D map;\nuniform float uScaleX;\nuniform float uScaleY;\nuniform float uOffsetX;\nuniform float uOffsetY;\nuniform float uLensFov; // capture-lens angle in RADIANS (WS-F, 120-250 deg)\n\nvarying vec3 vWorldPosition;\n\nconst float PI = 3.14159265359;\n\nvoid main() {\n vec3 dir = normalize(vWorldPosition);\n\n // Determine which hemisphere: front (z >= 0) or back (z < 0)\n bool isFront = dir.z >= 0.0;\n float faceSign = isFront ? 1.0 : -1.0;\n\n // Polar angle from the hemisphere pole (0 at pole, PI/2 at equator)\n float theta = acos(clamp(abs(dir.z), -1.0, 1.0));\n\n // Azimuthal angle around the hemisphere pole\n float phi = atan(dir.y, dir.x * faceSign);\n\n // Map to circular fisheye UV using equidistant projection.\n // r = 1 at the lens edge (uLensFov/2 from the pole). For lenses wider than\n // 180 deg the hemisphere uses only the inner part of the circle; for\n // narrower lenses r can exceed 1 \u2014 clamp to the edge (looks better than\n // holes; decided by visual test).\n float r = min(theta / (uLensFov * 0.5), 1.0);\n\n // Convert polar (r, phi) to cartesian circle coordinates, centered at (0.5, 0.5)\n vec2 circleUV = vec2(r * cos(phi), r * sin(phi)) * 0.5 + 0.5;\n\n // Place front hemisphere in left half of the dual-fisheye region,\n // back hemisphere in right half\n float xOffset = isFront ? 0.0 : 0.5;\n vec2 uv = vec2(circleUV.x * 0.5 + xOffset, circleUV.y);\n\n // Apply stereo region selection\n uv = vec2(uv.x * uScaleX + uOffsetX, uv.y * uScaleY + uOffsetY);\n\n gl_FragColor = texture2D(map, uv);\n}\n"; /** * Single-fisheye fragment shader (WS-F "spherical" / true VR180). * * Unlike the dual-fisheye shader there is NO hemisphere split: the texture * (or per-eye sub-region for stereo) holds ONE circular fisheye image whose * optical axis is the forward (+z after sphere inversion) direction, covering * uLensFov degrees. Directions beyond the lens edge clamp to it. */ export declare const sphericalFragmentShader = "\nuniform sampler2D map;\nuniform float uScaleX;\nuniform float uScaleY;\nuniform float uOffsetX;\nuniform float uOffsetY;\nuniform float uLensFov; // capture-lens angle in RADIANS\n\nvarying vec3 vWorldPosition;\n\nvoid main() {\n vec3 dir = normalize(vWorldPosition);\n\n // Angle from the forward optical axis (0 straight ahead). The camera\n // controller's default view (lat 0, lon 0) looks along +x, so that is the\n // content center for VR180 footage.\n float theta = acos(clamp(dir.x, -1.0, 1.0));\n\n // Azimuth around the axis: +z is screen-right at the default view, +y up.\n float phi = atan(dir.y, dir.z);\n\n // Equidistant mapping; clamp beyond the lens edge.\n float r = min(theta / (uLensFov * 0.5), 1.0);\n\n vec2 circleUV = vec2(r * cos(phi), r * sin(phi)) * 0.5 + 0.5;\n\n // Stereo region selection (full texture for mono).\n vec2 uv = vec2(circleUV.x * uScaleX + uOffsetX, circleUV.y * uScaleY + uOffsetY);\n\n gl_FragColor = texture2D(map, uv);\n}\n"; //# sourceMappingURL=fisheye.glsl.d.ts.map