2d mist shader (color control mist)

There’s a problem with the standard BGE mist, it can’t be changed in game since blender 2.49b.

For anyone who wants to make a weather or time system with dynamic changing mist this is a big hurdle.

I hear that soon we may get back world control settings via python, but until now here’s a quick and dirty hack for realtime GLSL shaded mist.


Here’s the Blend file:
controllable_colored_mist.blend (457 KB)

To test it press the left mouse button to change mist color.

From the discussion thread:

Far and Near are your controls. A higher far setting (about 5.0) will thin the mist towards the horizon. A lower near value (-2.0) will cause the mist to start nearer the camera. If near and far values are close together (-0.2,0.2) you’ll get quite thick mist. Far apart values will give thin mist (-12.0,12.0).

You can set the color with the r,g and b values.

Play around with the settings and see what gives you the best results. I’m not glsl expert so I can’t tell you if this is an optimal solution, but it seems to work OK on my computer.

It’s been a while since I tried this, thanks for sharing :slight_smile:

Very cool! Thanks!

I can’t wait to try this, does it include an option to turn the mist on or off?

You can just enable/disable the 2d filter with logic bricks to turn the effect on/off. Nice filter btw!

Great job!

I’ve been told there might be some issues with ATI cards. I used to have one myself and found lots of 2d filters didnt work at first. I think it has something to do with always explicitly declaring floats. I’ll take a look at it tonight.

EDIT:
Here’s a possible fix, though I can’t test it because I don’t have an ATI card on my computer anymore. :stuck_out_tongue:
updateed_mist.blend (457 KB)

I see you have the same problem I do:
How do you get the near/far to be in blender units where near is the near value and far is the far value? Man, wish I knew.

Cool. Now it works fine for me with “f” . Thanks :smiley:

edit:
on my other ATI card your first file without fix works fine.