Cycles: mist pass added, with start/depth/falloff control. If the pass is
enabled in a render layer a Mist Pass panel will be shown in the world properties.
This commit is contained in:
@@ -86,6 +86,31 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float
|
||||
L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput;
|
||||
if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT))
|
||||
L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput;
|
||||
|
||||
if(flag & PASS_MIST) {
|
||||
/* bring depth into 0..1 range */
|
||||
float mist_start = kernel_data.film.mist_start;
|
||||
float mist_inv_depth = kernel_data.film.mist_inv_depth;
|
||||
|
||||
float depth = camera_distance(kg, sd->P);
|
||||
float mist = clamp((depth - mist_start)*mist_inv_depth, 0.0f, 1.0f);
|
||||
|
||||
/* falloff */
|
||||
float mist_falloff = kernel_data.film.mist_falloff;
|
||||
|
||||
if(mist_falloff == 1.0f)
|
||||
;
|
||||
else if(mist_falloff == 2.0f)
|
||||
mist = mist*mist;
|
||||
else if(mist_falloff == 0.5f)
|
||||
mist = sqrtf(mist);
|
||||
else
|
||||
mist = powf(mist, mist_falloff);
|
||||
|
||||
/* modulate by transparency */
|
||||
float3 alpha = throughput*(make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd));
|
||||
L->mist += (1.0f - mist)*average(alpha);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -128,6 +153,8 @@ __device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float
|
||||
shadow.w = kernel_data.film.pass_shadow_scale;
|
||||
kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, sample, shadow);
|
||||
}
|
||||
if(flag & PASS_MIST)
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_mist, sample, L->mist);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user