From 4ecfb215e2af8ab824eb634915da2fc8ec54db98 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 18 Oct 2013 23:44:25 +0000 Subject: [PATCH] Fix: ensure cycles mist pass stays in range 0..1, it could have values out of this range due to sampling noise. Side note: I looked into the mist pass because it was apparently not calculating mist correctly on characters with transparent hair. Turns out this is just sampling noise that goes away with more samples. This noise is because the ray will randomly go to the next transparency layer or get reflected, the path tracing integrator will not branch the path and only pick one of the two directions each time. Branched path tracing however will shade all transparent layers for each AA sample, which means this source of noise is eliminated. --- intern/cycles/render/buffers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 5fb648cec5f..44a050ca530 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -184,6 +184,12 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int pixels[0] = (f == 0.0f)? 1e10f: f*scale_exposure; } } + else if(type == PASS_MIST) { + for(int i = 0; i < size; i++, in += pass_stride, pixels++) { + float f = *in; + pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f); + } + } else { for(int i = 0; i < size; i++, in += pass_stride, pixels++) { float f = *in;