Source:
public void applyParameters(Material program) { super.applyParameters(program); DisplayResolutionDependentFBOs displayResolutionDependentFBOs = CoreRegistry.get(DisplayResolutionDependentFBOs.class); WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class); BackdropProvider backdropProvider = CoreRegistry.get(BackdropProvider.class); FBO sceneOpaqueFbo = displayResolutionDependentFBOs.get(new ResourceUrn("engine:sceneOpaque")); int texId = 0; if (sceneOpaqueFbo != null) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaqueFbo.bindTexture(); program.setInt("texScene", texId++, true); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaqueFbo.bindDepthTexture(); program.setInt("texDepth", texId++, true); } program.setFloat("density", density, true); program.setFloat("exposure", exposure, true); program.setFloat("weight", weight, true); program.setFloat("decay", decay, true); if (worldRenderer != null) { Vector3f sunDirection = backdropProvider.getSunDirection(true); Camera activeCamera = worldRenderer.getActiveCamera(); Vector4f sunPositionWorldSpace4 = new Vector4f(sunDirection.x * 10000.0f, sunDirection.y * 10000.0f, sunDirection.z * 10000.0f, 1.0f); Vector4f sunPositionScreenSpace = new Vector4f(sunPositionWorldSpace4); activeCamera.getViewProjectionMatrix().transform(sunPositionScreenSpace); sunPositionScreenSpace.x /= sunPositionScreenSpace.w; sunPositionScreenSpace.y /= sunPositionScreenSpace.w; sunPositionScreenSpace.z /= sunPositionScreenSpace.w; sunPositionScreenSpace.w = 1.0f; program.setFloat("lightDirDotViewDir", activeCamera.getViewingDirection().dot(sunDirection), true); program.setFloat2("lightScreenPos", (sunPositionScreenSpace.x + 1.0f) / 2.0f, (sunPositionScreenSpace.y + 1.0f) / 2.0f, true); } }

Target:
public void applyParameters(Material program) { super.applyParameters(program); DisplayResolutionDependentFBOs displayResolutionDependentFBOs = CoreRegistry.get(DisplayResolutionDependentFBOs.class); WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class); BackdropProvider backdropProvider = CoreRegistry.get(BackdropProvider.class); FBO sceneOpaqueFbo = displayResolutionDependentFBOs.get(READONLY_GBUFFER); int texId = 0; if (sceneOpaqueFbo != null) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaqueFbo.bindTexture(); program.setInt("texScene", texId++, true); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaqueFbo.bindDepthTexture(); program.setInt("texDepth", texId++, true); } program.setFloat("density", density, true); program.setFloat("exposure", exposure, true); program.setFloat("weight", weight, true); program.setFloat("decay", decay, true); if (worldRenderer != null) { Vector3f sunDirection = backdropProvider.getSunDirection(true); Camera activeCamera = worldRenderer.getActiveCamera(); Vector4f sunPositionWorldSpace4 = new Vector4f(sunDirection.x * 10000.0f, sunDirection.y * 10000.0f, sunDirection.z * 10000.0f, 1.0f); Vector4f sunPositionScreenSpace = new Vector4f(sunPositionWorldSpace4); activeCamera.getViewProjectionMatrix().transform(sunPositionScreenSpace); sunPositionScreenSpace.x /= sunPositionScreenSpace.w; sunPositionScreenSpace.y /= sunPositionScreenSpace.w; sunPositionScreenSpace.z /= sunPositionScreenSpace.w; sunPositionScreenSpace.w = 1.0f; program.setFloat("lightDirDotViewDir", activeCamera.getViewingDirection().dot(sunDirection), true); program.setFloat2("lightScreenPos", (sunPositionScreenSpace.x + 1.0f) / 2.0f, (sunPositionScreenSpace.y + 1.0f) / 2.0f, true); } }