Page MenuHome

Cycles - Mist
Closed, ResolvedPublicPATCH

Description

Hi Blender developers, this time I put available a patch that i have tired to finish it today but didn't quite yet, it is usable and stable i think, but lefts improvements in the way it calculate the mist volumes and add a couple of extra features to make it more interesting.

I put this patch here to keep track of it and for anyone that may need render proper mist, this could be useful for them.
I will try to upload a new version and finished in the next days.

Features:
- 3 Types of fallow Fallof.
- Height, min/max distances, intensity.
- Fake Horizon gradient to blend mist better with the background
- Anti-Aliased Mist pass output to the compositor, optional exclude from final render buffer.
- Support for Transparent BSDF (no more transparent alpha leaves parts casting mist! :) )
- Support for glossy and glass BSDF (you can see the mist in the reflections and trough a glass )
- Viewport preview / color adjustable.

Thanks
Agus

Event Timeline

Here is also a blend file and a screen shot of it to test it:

https://dl.dropbox.com/u/65979653/BlenderComunityShare/blends/Cycles-Mist_test.rar

http://www.pasteall.org/pic/show.php?id=33384

This patch breaks GPU compiling:

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(234): error:
class "KernelGlobals" has no member "__data"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(257): error:
class "float3" has no member "mist"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(265): error:
class "KernelGlobals" has no member "__data"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(270): error:
class "float3" has no member "mist"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(303): error:
class "KernelGlobals" has no member "__data"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(304): error:
class "float3" has no member "mist"

d:\blender_dev\code\trunk\intern\cycles\kernel\kernel_accumulate.h(310): error:
class "float3" has no member "mist"

Hi Thomas, thank you for testing it!
I manage to grab some time and give a try to fix it (can't test, don't have proper Cuda card). Could I try to compile to see the errors at least? even if i only have a 1.1 Cuda capable device? I am lazy to try out without being sure.

> I also improve the horizon haze, now it is based on the angle relative to the horizon, and its fallof is a cubic decay, as well the height influence, looks/works MUCH better now.

I Attached the new patch in attachments (CyclesMist_v0.85.patch)

Pics:
http://www.pasteall.org/pic/show.php?id=33443
http://www.pasteall.org/pic/show.php?id=33444

Hi Augustin, there are some errors left:
Compiling CUDA kernel ...
/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(260): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(261): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(262): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(280): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(284): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(292): error: class "float3" has no member "mist"

/daten/branches/bratwurst/build/linux/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(298): error: class "float3" has no member "mist"

7 errors detected in the compilation of "/tmp/tmpxft_0000163e_00000000-4_kernel.cpp4.ii".


I think it make no sense with a cuda 1.1 card because of not working render passes < cuda 2.0.

Thank you for that patch, cheers, mib2berlin

I will take a look at it later, maybe I can fix it.

Attached CyclesMist_v0.86.patch

-UI code cleanup and renamed panel to Mist
-Removed an unneeded define __Mist__ from kernel_accumulate.h, already defined in kernel_types.h

Some general workflow feedback:
* Although it might be nice to be able to exclude Mist from the combined pass, this is not how it should be done. It would also make sense to exclude AO, or Shadow or whatever then. We should not break the consistency here. So -1 for this "Pass Only" option.
I would also treat it like AO, it has a checkbox to enable AO in the panel header, and even if that is disabled you can get an AO pass. Same should apply to Mist imo.

What do you think?
Regards,
Thomas

So basically, having the checkbox disabled in the world panel, but enabling the pass, is your "Pass only" :) (Again, look at AO for reference)

Thank you Thomas for your support, it really helps
Yes thats was a todo, i just found handy put that option there while modifying the addon, but yes, it should be a "Mist" checkbox, so it will enable in the final render, and the mist pass checkbox in render layers should enable the pass buffer.
Regarding the atmosphere panel name it was like that because i was thinking to include more atmospheric effects, not only mist, but i agree that while i am not including more options it can be named mist..
Thanks for 0.86, does it compiles on the GPU?

0.86 causes the following errors on Geforce GTX 470 + CUDA Toolkit 4.1:

Compiling CUDA kernel ...
nvcc warning : Option '--opencc-options (-Xopencc)' is obsolete and ignored, when targeting compute_20, sm_20, or higher
/home/irie/build/blender2.6/cmake/bin/2.63/scripts/addons/cycles/kernel/kernel_accumulate.h(298): error: no operator "[]" matches these operands
operand types are: float4 [ int ]

/home/irie/build/blender2.6/cmake/bin/2.63/scripts/addons/cycles/kernel/kernel_passes.h(131): error: no operator "[]" matches these operands
operand types are: float4 [ int ]

2 errors detected in the compilation of "/tmp/tmpxft_00005b8b_00000000-6_kernel.cpp1.ii".


Anyway, I think the render results don't look realistic because the mist doesn't cast/receive shadows. Cannot Tyndall scattering be simulated?

I attached a 0.87 patch version, wich may fix the issues you got Shinsuke Irie.
Please test it if it works
Regarding the volume shadow, this is a classic mist effect, no scattering effects, the idea is to render long distance mist in no time. for realistic volume shadows you have to wait to proper volume render support.

v0.87 works for me.

This fast/cheap mist is an excellent addition to Cycles even when we get true volumetrics in Cycles this feature will still be welcome and often used.

I nice option would be to enable the mist in all viewing directions.

At the moment the mist seem to only affect the horizon and when looking downward. When the camera is looking upward there is no mist. I am sure this is a feature to blend the fog into the sky but it does cause problems in certain situations(Looking up at a cliff in my case). Perhaps if the "Horizon Haze" option could be set to 180 degrees so that it covers all the viewing angles(looking upwards too), or perhaps a checkbox to disable this behavour would be a good option to have.

I've investigated this patch, but finally don't think it's a good idea to add a custom mist effect to the renderer now. This should wait for volumetrics, if we are adding one particular effect now, it will be difficult to keep it working after we add volumetrics, it adds quite a bit of complexity to the path tracer.

Thomas Dinges (dingto) changed the task status from Unknown Status to Resolved.Apr 1 2013, 12:01 PM

Read Brechts response above, we decided not to include this. Instead you can use Volume rendering now.