/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as t}from"../../../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float2BindUniform as i}from"../../shaderModules/Float2BindUniform.js";import{Float4BindUniform as a}from"../../shaderModules/Float4BindUniform.js";import{glsl as f}from"../../shaderModules/glsl.js";function c(r){r.fragment.uniforms.add(new a("projInfo",r=>n(r.camera))),r.fragment.uniforms.add(new i("zScale",r=>m(r.camera))),r.fragment.code.add(f`vec3 reconstructPosition(vec2 fragCoord, float depth) {
return vec3((fragCoord * projInfo.xy + projInfo.zw) * (zScale.x * depth + zScale.y), depth);
}`)}function n(r){const o=r.projectionMatrix;return 0===o[11]?t(s,2/(r.fullWidth*o[0]),2/(r.fullHeight*o[5]),(1+o[12])/o[0],(1+o[13])/o[5]):t(s,-2/(r.fullWidth*o[0]),-2/(r.fullHeight*o[5]),(1-o[8])/o[0],(1-o[9])/o[5])}const s=e();function m(o){return 0===o.projectionMatrix[11]?r(l,0,1):r(l,1,0)}const l=o();export{c as CameraSpace,n as getProjectionInfo,m as getZScale};
