Get the latest Blender, older versions, or experimental builds.
Stay up-to-date with the new features in the latest Blender releases.
Access production assets and knowledge from the open movies.
Documentation on the usage and features in Blender.
Latest development updates, by Blender developers.
Guidelines, release notes and development docs.
A platform to collect and share results of the Blender Benchmark.
The yearly event that brings the community together.
Support core development with a monthly contribution.
Perform a single donation with more payment options available.
/* Convert depth to Mist factor */
uniform vec3 mistSettings;
#define mistStart mistSettings.x
#define mistInvDistance mistSettings.y
#define mistFalloff mistSettings.z
out vec4 fragColor;
void main()
{
vec2 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0)).xy;
vec2 uvs = gl_FragCoord.xy * texel_size;
float depth = textureLod(depthBuffer, uvs, 0.0).r;
vec3 co = get_view_space_from_depth(uvs, depth);
float zcor = (ProjectionMatrix[3][3] == 0.0) ? length(co) : -co.z;
/* bring depth into 0..1 range */
float mist = saturate((zcor - mistStart) * mistInvDistance);
/* falloff */
mist = pow(mist, mistFalloff);
fragColor = vec4(mist);
// if (mist > 0.999) fragColor = vec4(1.0);
// else if (mist > 0.0001) fragColor = vec4(0.5);
// else fragColor = vec4(0.0);
}