/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{BooleanBindUniform as e}from"../../shaderModules/BooleanBindUniform.js";import{glsl as l}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as n}from"../../shaderModules/Texture2DBindUniform.js";import{blurSizePixels as i}from"../../../effects/globalIllumination/GlobalIllumination.js";function o(o,r){r.receiveGlobalIllumination?(o.uniforms.add(new e("hasGlobalIlluminationTexture",e=>null!=e.globalIllumination),new n("globalIlluminationTexture",e=>e.globalIllumination?.getTexture())),o.constants.add("blurSizePixelsInverse","float",1/i),o.code.add(l`vec3 readGlobalIlluminationOcclusionInverse() {
if (!hasGlobalIlluminationTexture) {
return vec3(1.0);
}
ivec2 texel = ivec2(gl_FragCoord.xy * blurSizePixelsInverse);
return vec3(texelFetch(globalIlluminationTexture, texel, 0).a);
}
vec3 readGlobalIlluminationOcclusion() {
return 1.0 - readGlobalIlluminationOcclusionInverse();
}
vec4 readGlobalIlluminationEmissionInverse() {
if (!hasGlobalIlluminationTexture) {
return vec4(1.0);
}
ivec2 texel = ivec2(gl_FragCoord.xy * blurSizePixelsInverse);
return 1.0 - vec4(texelFetch(globalIlluminationTexture, texel, 0).rgb, 0.0);
}
vec4 readGlobalIlluminationEmission() {
return max((1.0 - readGlobalIlluminationEmissionInverse() - 0.01) / 0.99, 0.0);
}`)):o.code.add(l`vec3 readGlobalIlluminationOcclusionInverse() { return vec3(1.0); }
vec3 readGlobalIlluminationOcclusion() { return vec3(0.0); }
vec4 readGlobalIlluminationEmissionInverse() { return vec4(1.0); }
vec4 readGlobalIlluminationEmission() { return vec4(0.0); }`)}export{o as ReadGlobalIllumination};
