/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{addCameraPosition as e}from"./util/View.glsl.js";import{FloatBindUniform as r}from"../shaderModules/FloatBindUniform.js";import{FloatPassUniform as i}from"../shaderModules/FloatPassUniform.js";import{glsl as o}from"../shaderModules/glsl.js";function n(n,c){if(!c.screenSizeEnabled)return;const t=n.vertex;e(t,c),t.uniforms.add(new r("perScreenPixelRatio",e=>e.camera.perScreenPixelRatio),new i("screenSizeScale",e=>e.screenSizeScale)).code.add(o`float computeRenderPixelSizeAt( vec3 pWorld ){
vec3 viewForward = - vec3(view[0][2], view[1][2], view[2][2]);
float viewDirectionDistance = abs(dot(viewForward, pWorld - cameraPosition));
return viewDirectionDistance * perScreenPixelRatio;
}
vec3 screenSizeScaling(vec3 position, vec3 anchor){
return position * screenSizeScale * computeRenderPixelSizeAt(anchor) + anchor;
}`)}export{n as ScreenSizeScaling};
