vec2 getVelocity() {
	vec3 previousRDWorld = (inverse(gbufferPreviousModelView) * vec4(0, 0, -1, 0)).xyz;
	return worldToView(previousRDWorld).xy;
}

float getFlashlight(vec2 coord, float depth, out float visibility) {
    coord -= clamp(getVelocity(), -1.0, 1.0)*0.012*FLASHLIGHT_LAG_AMOUNT/frameTime;
    #if (FLASHLIGHT_MODE == 1)
    float flashLightOn = float(night > 0.4);
    #else
    float flashLightOn = float(heldItemId == 1 || heldItemId2 == 1);
    #endif
    float dist = distance(coord*resolution, vec2(0.5)*resolution)/resolution.x * 3.8 / FLASHLIGHT_WIDTH / gbufferProjection[1][1];
    visibility = max((-pow2(dist + 0.2) + 1.0)*(cos(12.5*dist)*0.35+0.75), 0.0);
    return flashLightOn*rcp(depth*depth + 5.0)*2.0;
}

vec3 flashLightCol = blackbody(FLASHLIGHT_TEMP)*FLASLIGHT_BRIGHTNESS;