N_WeatherFog

A picture is worth a thousand words. And an animated one is worth a thousand pictures:
fog.gif


N_WeatherFog gives you procedurally generated fog (using perlin noise).

What does that mean?
  • No need to spend time creating fog textures or looking for them on the internet.
  • Natural-looking animations.
  • Customizable fog rendering quality.
  • The fog can seamlessly cover infinite ground (on looping maps).

You can get this plugin (and more) on GitHub: https://github.com/Nolonar/RM_Plugins-WeatherFog
Just in case you can't find the download link: https://github.com/Nolonar/RM_Plugins-WeatherFog/releases/latest/download/N_WeatherFog.js

Terms of use
MIT License

In short: you're free to use it on any project (commercial or not) or modify it as you wish, as long as you won't remove the license and the copyright from the plugin.
Everything works great when walking around on the maps but I get the error message:

TypeError
Cannot read property 'Origin' of undefined

Whenever my party goes into battle. (Even if the fog is not in use when the battle begins.) Turned off the plugin and everything works fine again.
Not gonna watch that picture. You want me to watch a million words?

Pretty cool! How many layers of perlin did you combine for the effect?
Aaaah shader ♥ me likey!
Everything works great when walking around on the maps but I get the error message:

TypeError
Cannot read property 'Origin' of undefined

Whenever my party goes into battle. (Even if the fog is not in use when the battle begins.) Turned off the plugin and everything works fine again.
I can't reproduce this. Maybe the issue has been fixed in the newest release (1.2.0)?
If not, could you press F8 or F12 when the error happens, then switch to the "Console" tab and provide me with a screenshot of the window?

It looks kind of like this:

Spoiler
track-exceptions-exception-stack-trace.jpg

You'll probably only see the bottom part, which is fine. As long as the right side is visible (the part that says: "hovercard.js:218" in the screenshot, I'll know which line of code I'm looking at.

This is just a guess, but what if you opened N_WeatherFog.js and searched for
Code:
                this.tilemap.origin.x
                this.tilemap.origin.y

and replaced it with
Code:
                this.tilemap?.origin.x
                this.tilemap?.origin.y

Does the problem still occur?
These lines should be in 2 places: Lines 135-136 and lines 175-176.

Not gonna watch that picture. You want me to watch a million words?

Pretty cool! How many layers of perlin did you combine for the effect?
Aaaah shader ♥ me likey!
That depends on what you choose for "Fog quality". You can go from 1 layer all the way to 8 layers.

The gif uses the default of 4 layers.
@GalacticGod
Everything works great when walking around on the maps but I get the error message:

TypeError
Cannot read property 'Origin' of undefined

Whenever my party goes into battle. (Even if the fog is not in use when the battle begins.) Turned off the plugin and everything works fine again.
After some investigation, I believe the crash happens because you might have a plugin that allows for weather during battles. I've released version 1.2.1 which should (hopefully) fix the bug.

The download link (posted above) should always point to the latest version.
Very nice, I like how the fog looks and that I don't have to create any graphics.

Only one thing I've discovered, which I don't know, if that is intended:
If I create two save files, one before fog is added and one after the fog is added, the following situations may occur:
1. I just restart by pressing F5 or go back to title screen from the main menu and not closing the game and load the save from before the fog has been applied, the fog will still be there.
2. If I completely close the game, reopen it and load the save from after the fog has been applied, it is gone.

I've modified the version I've downloaded already to include a save feature. I just wanted to let you know.
would this work on MV too or only MZ?
would this work on MV too or only MZ?

It uses PluginManager.registerCommand(), which is only available in MZ. Other than that, I believe it should probably work with MV, though I'd have to test it to be sure.

I'll see if I can't make it compatible, although I officially don't support MV anymore. I should have an update ready within 3 or 4 days.
I don really need plugin command, although it migh be easy to add.
parameters se once is good as well for a scriptcall otherwise.

if it doesn't work, no biggy 🙂 it looks really good 🙂
Hello everyone. As promised, here is version 1.3.0, which adds compatibility to RPG Maker MV.

There are no changes for MZ users who are already using version 1.2.2, so there is no need to download 1.3.0 unless you use MV.

Spoiler: Post Mortem (lots of technical blabla ahead)
Making the plugin MV-compatible turned out to be more difficult than initially expected.

What I expected:
  • MV uses a completely different API for plugin commands. Adapting the existing MZ API for MV was very easy.

  • The NWJS version used in MV is too old to support the "optional chaining" operator (?.). Very easy to work around.

  • MZ introduced the Array.remove() function, which is very useful, but not standard JavaScript. Backporting it to MV was as easy as copy-pasting the code over.

What I didn't expect:
  • MV executes weather-related code as part of the map scene's spritesheet creation process.

    This plugin uses shaders, which are known as "filters" in PIXI (the WebGL rendering engine of RPG Maker MV and MZ), and filters belong to the spritesheet in both MV and MZ. As a result, RPG Maker MV crashed as the plugin tried to access a spritesheet that hasn't been fully created yet.

    The fix was easy enough, but understanding why the plugin kept crashing took hours.


  • MV uses PIXI version 4, while MZ uses PIXI version 5. This change caused the following incompatibilities:
    • The PIXI filters list in version 4 is immutable. This means that shaders can't be added to or removed from the list, unlike in version 5. Instead, a new filters list must be created to replace the old one. Another easy fix that took hours to identify.


    • Uniforms are defined differently in versions 4 and 5. Uniforms are variables shared between CPU and GPU, and are necessary for communication between the two.

      For this plugin, uniforms are used to tell the GPU how intense the fog needs to be, how much time has passed, as well as the player's current location. This allows the GPU to render and animate the fog properly.

      Unlike the other problems, this was the only one I couldn't fix without explicitly looking for PIXI version 4. This means that if you ever update to PIXI version 6 or later, and if the new version changes how uniforms are handled, the plugin is very likely to break.

Enjoy your fog.
I tested it, but I get 2 errors.

1) if I have a few plugins of mine is active I get:
unexpected token in position 1 (the same thing I had in BoMV plugin)
which fixed as adding an extended array (not sure in yours).

2) when I turn of the plugin mentioned, it run, but after running the
plugin command,

TypeError, this.wait is not a function.

so I dont know about this one though.
I tested it, but I get 2 errors.

1) if I have a few plugins of mine is active I get:
unexpected token in position 1 (the same thing I had in BoMV plugin)
which fixed as adding an extended array (not sure in yours).
I can try and fix this, but I'll need more information. A screenshot of the developer console would be helpful. Alternatively, if you know which plugin causes problems with mine, that would be even more helpful (just keep in mind that I won't be able to access paid plugins).

2) when I turn of the plugin mentioned, it run, but after running the
plugin command,

TypeError, this.wait is not a function.

so I dont know about this one though.
Sorry about that. It appears I didn't test the "wait" option in MV (this.wait() is only used when the [wait] option is set to true). This has been fixed in version 1.3.1, which I've just released.
I DM you my DR plugin and GetAllItems as it get the error and Olivia_MetaControls.
GetAllItems is a small plugin I made for debug and my itemScene testing.

the image is in BoMV post [here], on 1 page before is the syntax
of JSON of position 1 error.

it isn't direct related to your plugin, but it's the same list.
olivia_MetaControls is free, but it's goes to a .call function.

I hope you can figure it out as BoMV did it 🙂

but I cannot tell if it work with other plugins as this is a mechanic project
for my main project, if it does work there, than mostly my main project too.
I've just released version 1.3.2
This new version only affects RPG Maker MV.

Version 1.3.2

Fixed
  • Plugin parameters rendering incorrectly in MV, making it impossible to set yScale in the RPG Maker MV editor. Please edit the yScale parameter after updating to 1.3.2, and replace the value true with a number. The default value for yScale is 150.
I retest it, and it seems to work, with all on, except DR, I look
later into that in your function to get it to work, as that one
is the only one unexpected JSON token of position 1 error.
Very nice, I like how the fog looks and that I don't have to create any graphics.

Only one thing I've discovered, which I don't know, if that is intended:
If I create two save files, one before fog is added and one after the fog is added, the following situations may occur:
1. I just restart by pressing F5 or go back to title screen from the main menu and not closing the game and load the save from before the fog has been applied, the fog will still be there.
2. If I completely close the game, reopen it and load the save from after the fog has been applied, it is gone.

I've modified the version I've downloaded already to include a save feature. I just wanted to let you know.
Sorry, it seems I've completely missed your comment.

Thank you very much for the report. I've reproduced the issue and will have an update ready to fix this soon.
I've just released version 1.3.4

After publishing 1.3.3, I realized that the bug it was supposed to fix was still around if a project used N_TitleMap (another plugin of mine). Version 1.3.4 fixes that bug, but also requires N_TitleMap to be updated to version 1.0.4 for it to work.

Version 1.3.3

Fixed

  • Fog did not save. If players saved the game while the fog is active and closed the game, then the fog would be gone when they loaded the save game.
  • Fog did not clear when exiting the game. If players used the "Return to Title" option while the fog is active, then the fog would remain active even if they started a new game.

Version 1.3.4

Fixed

  • Bug when using N_TitleMap. Please update N_TitleMap to v1.0.4 or later.
Hello everyone. Today marks the release of version 1.4.0, which is the biggest feature update so far.

Version 1.4.0
New

  • Notetags to force fog on or off depending on the map. <noFog> is useful for indoor maps, where there should be no fog, even if the weather is foggy.
  • It is now possible to specify a color for the fog. If not specified, the default color is white. CSS colors are supported, such as:
    • salmon
    • #ABCDEF
    • rgb(0, 128, 255)
Changed
  • Fog is now independent from the rest of the weather effects. It is now possible to have fog active during rain, storm, or snow.
that one is sweet 😛 need to test that part out 🙂

small edit:
I tested teh <fog: 1 #00FF00> for greenish color, when -1 (dark) it becomes dark pink.
but if I do <fog: 1> it is bright fog, but on <fog: -1> dark, the map looks cool, but also
visible.

I specially notice if use even 0.5 or 1 and a color, the map is really visible.
as I want a bit more yellowish color (desert part as some kind of sand fog)
that the visibility is tighter when on 1 (even if color is used).

is there something to do about that?
it works furter more really nice, as I had map 1 (normal one by plugin command),
map 2 map notetag, and switching still works, map 1 has default by plugin command),
even after saving which is sweet =)

I hope you can make it tighter on mist if it's 1, or -1 on darker?
if no possible, it's okey 🙂.

I test later with fog and rain/snow/storm =)
I tested teh <fog: 1 #00FF00> for greenish color, when -1 (dark) it becomes dark pink.
but if I do <fog: 1> it is bright fog, but on <fog: -1> dark, the map looks cool, but also
visible.

This is because of how the shader is implemented. I'm generating a noise map (the fog), where each pixel is between 0 (black) and 1 (white), multiply (*) it by the intensity, and add (+) it to the screen. As a result, the screen becomes brighter where the fog is white, and it remains unchanged where the fog is black. That's assuming the intensity is positive.

This also means that you can't make black fog, since black is invisible in this case. So to allow for black fog, I decided to allow negative intensity. With negative intensity, the fog is subtracted (-) from the screen, which means the fog's color becomes inverted. A white fog makes the screen darker, a blue fog turns it yellowish, and a green fog becomes pinkish.

I'd love to make this more intuitive (as in, if you choose a black color, the fog would actually be black), but I'm still trying to figure out the proper math to get it working.

Sorry about that.


I specially notice if use even 0.5 or 1 and a color, the map is really visible.
as I want a bit more yellowish color (desert part as some kind of sand fog)
that the visibility is tighter when on 1 (even if color is used).

is there something to do about that?

You could try and use an intensity greater than 1. I know I wrote "not recommended", but that's because the fog becomes too thick for the map to be visible. In your case, the fog is still not thick enough at intensity 1, so using a higher intensity would probably help.

I'll try and make the intensity more consistent across colors, but as I said before, I'm still working out the math to solve this properly.

Original thread: https://forums.rpgmakerweb.com/threads/n_weatherfog.127256/