[patch] new fog shader

Everything about development and the OpenMW source code.
Post Reply
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

[patch] new fog shader

Post by visvaldas »

Edit: Port to OSG version: viewtopic.php?f=6&t=2905&start=20#p38328
Edit: newest version: https://gitlab.com/vrresto/openmw/tree/ ... er-cleanup

----------------------------------------

Hi !

This comes probably a bit late with the port to OSG taking place now - anyway here it is. :-)
Probably some of it can be used/ported.

This patch adds a more realistic looking fog shader where the fog density decreases with increasing altitude.

Some screenshots:
screenshot123.jpg
screenshot153.jpg
screenshot135.jpg
Feel free to ask questions, but please not about the mathematical basis of the calculations - this was mostly guesswork + try & error. :mrgreen:

Edit: add patch against 0.36.0 and patchless version

For this to look good you also need to set "distant land = true" and "viewing distance" to a high value (e.g. 500000 for 5km) in settings.cfg.

Patchless version:
Extract this into your resources/materials folder - apparently the location of this can vary.
jirka642 wrote: On my Linux PC is correct folder located in /usr/share/games/openmw/resources/materials/ , but it can be at the same place as your openmw executable depending on how you installed openmw.
You also may need to empty your openmw cache directory (~/.cache/openmw on my system) for the changes to take effect.
Since this version takes no density parameter from the engine you have to manually edit the parameters at the beginning of fog.h to change the density etc.
Attachments
fog-shader.zip
version that requires no patching
(16.32 KiB) Downloaded 1106 times
new-fog-shader.patch
patch against 0.36.0
(31.46 KiB) Downloaded 1191 times
Last edited by visvaldas on 11 Jul 2018, 20:17, edited 7 times in total.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: [patch] new fog shader

Post by scrawl »

Looks great. Is that Mountainous Red Mountain in the background?

Ideally, this kind of modification wouldn't require C++ code. I'm thinking post-1.0 we should offer a way for modders to define new weather settings, and pass the current values to a modified shader, all without engine changes.
Last edited by scrawl on 24 May 2015, 23:02, edited 1 time in total.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: [patch] new fog shader

Post by psi29a »

That's pretty nifty! :D
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: [patch] new fog shader

Post by visvaldas »

Thanks :)
@scrawl: Yep - thats Red Mountain.
Actually I programmed this a while ago (yes I could have submitted this much earlier :oops: ), so my memory of why I did what is already a bit rusty.
The C++ is at least partially to improve performace: some values only need to be calculated once when the fog parameters change, also some arithmetic operations might be impossible/to expensive on shader units (not sure about this - I'm not an experienced shader programmer).
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: [patch] new fog shader

Post by scrawl »

@scrawl: Yep - thats Red Mountain.
Yeah, I was just wondering if that's vanilla or modded. If it's vanilla, then that fog sure does make the mountain seem a lot higher than usual :)
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: [patch] new fog shader

Post by raevol »

That's so gorgeous... will we see this in OpenMW?
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: [patch] new fog shader

Post by Chris »

Hopefully it can be configurable, probably as an added weather property. As pretty as it can look, low-lying fog isn't a constant thing. It's generally caused by warm ground meeting the cold air, and vice versa, creating condensation and mist. The time of day (mornings and evenings are more likely to have it) and season (summer and winter are less likely to have it) also plays a part.
User avatar
Okulo
Posts: 672
Joined: 05 Feb 2012, 16:11

Re: [patch] new fog shader

Post by Okulo »

Oof! That is beautiful! Please, please make this work well and add this to the main branch. I think we haven't seen eye-candy like that since Scrawl's Shiny shader.
Cramal
Posts: 186
Joined: 19 Sep 2014, 13:37

Re: [patch] new fog shader

Post by Cramal »

If you can make configurable decrease/increase with altitude (even if its not through in game menu) i think it would open a lot of cool possibilities
visvaldas
Posts: 35
Joined: 24 May 2015, 20:31

Re: [patch] new fog shader

Post by visvaldas »

scrawl wrote:
@scrawl: Yep - thats Red Mountain.
Yeah, I was just wondering if that's vanilla or modded. If it's vanilla, then that fog sure does make the mountain seem a lot higher than usual :)
It's vanilla :)
Chris wrote:Hopefully it can be configurable, probably as an added weather property. As pretty as it can look, low-lying fog isn't a constant thing. It's generally caused by warm ground meeting the cold air, and vice versa, creating condensation and mist. The time of day (mornings and evenings are more likely to have it) and season (summer and winter are less likely to have it) also plays a part.
I've thought of local variations too, but unfortunately the way the shader works this is impossible. Global variation depending on time of day is possible of course.
Currently all parameters are derived from a a single density parameter (ground fog only starts to appear above a certain density) - have a look at Fog.cpp/.h. This could theoretically be fine-tuned by the weather manager.
Okulo wrote:Oof! That is beautiful! Please, please make this work well and add this to the main branch. I think we haven't seen eye-candy like that since Scrawl's Shiny shader.
Well, unfortunately I'm unsure whether I have time for this in the near future. But it probably depends on how much work is required to port this to whatever shader system OSG uses. As I'm a shader newbie I probably could use some help there.
Post Reply