Conception for a weather mod

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

Conception for a weather mod

by PilzAdam » Post

Hello everyone!
What do you think about this laggy way to create rain?
http://ompldr.org/vZjVxcQ/weather.zip
Start/stop rain with the command /rain

User avatar
Echo
Member
Posts: 122
Joined: Tue Jul 31, 2012 08:11
Location: Germany

by Echo » Post

Nice effect!
Wouldn't it be enough if it would rain in a smaller cube around the player? Else you get strange moiree / repeating effects.

User avatar
qwrwed
Member
Posts: 326
Joined: Sun Jul 22, 2012 20:56
In-game: qwrwed or Nitro

by qwrwed » Post

It's good, but typing /rain a second time doesnt seem to stop it, and like Echo said, there are lots of repeating effects.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php ... 583#p33583
Last edited by rubenwardy on Sun Aug 19, 2012 21:07, edited 1 time in total.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

leo_rockway
Member
Posts: 211
Joined: Tue Jul 31, 2012 20:37

by leo_rockway » Post

PilzAdam, you rock.
Try Skyblock for MineClone 2
Listen to this sound and music pack!

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

Very impressive! It looks like you're basically replacing all air nodes with an animated rain node. I might suggest adding a small random number to each raindrop's initial X/Z position to get rid of the moire pattern. Also, I would suggest a smoother animation - at least 4x as many frames (but with the same length of time for the loop).
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
Echo
Member
Posts: 122
Joined: Tue Jul 31, 2012 08:11
Location: Germany

by Echo » Post

Is it possible to detect the clouds in the sky? I never tried. If it is possible, then there should be rain only direct under the clouds.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Echo wrote:Is it possible to detect the clouds in the sky? I never tried. If it is possible, then there should be rain only direct under the clouds.
Its not possible.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Echo wrote:Nice effect!
Wouldn't it be enough if it would rain in a smaller cube around the player? Else you get strange moiree / repeating effects.
Thats not easy. But I see what i can do.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

qwrwed wrote:It's good, but typing /rain a second time doesnt seem to stop it, and like Echo said, there are lots of repeating effects.
It needs some time.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

rubenwardy wrote:Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php ... 583#p33583
But how to do this in lua?

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

VanessaE wrote:Very impressive! It looks like you're basically replacing all air nodes with an animated rain node. I might suggest adding a small random number to each raindrop's initial X/Z position to get rid of the moire pattern. Also, I would suggest a smoother animation - at least 4x as many frames (but with the same length of time for the loop).
This is not a mod so the graphics are very basic.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

PilzAdam wrote:
rubenwardy wrote:Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php ... 583#p33583
But how to do this in lua?
isnt there a minetest.drawimageonscreen or similar command?
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

In the minecraft rain and snow effects seems to be just a textures on a 4 plains which "surround" player.
So I suggest following:
- create 4 entities 1x2x0 (plains)
- apply to each of them some animated rain texture on the one side and tranparent texture on the other (see "animated torches" mos)
- make this entities to face the player (see "snow" mod)
- re-place that entities around player on every server time tick
- coordinates should be like so: {-0.5, 0.5, -0.5} for the 1st one, {0.5, 0.5, -0.5} for the second, {-0.5, 0.5, 0.5} for the 3rd and {0.5, 0.5, 0.5} for the last one:

Code: Select all

 __ __ __
|  |  |  |
|__|/\|__|
| /|PP|\ |
|_\|__|/_|
|  |\/|  |
|__|__|__|

I tried to draw 9 blocks, PP = player and the diagonal lines = 4 entities, placed in rhombus-like shape.

This way every player would see animated side of his "raining entity" and would "see" empty "back side" of the other players' "raining entities".

I tried to do this on my own, but I'm not so good at lua or modding for minetest...
Someone with skill may check above things to make lightweight but working weather.
Last edited by 4aiman on Sat Nov 24, 2012 17:11, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

This is a good idea!
I will code it when I have some time (within the next week).

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

I managed to add entity in the player's position, but:
1. animation for texture didn't work, when I write smth like this:

Code: Select all

    textures = {             
             {name="rainanim.png"},
             {name="rainanim.png", animation={type="vertical_frames", aspect_w=48, aspect_h=48, length=3.0}},
},
2. I ended up in need to add "owner" property, so that if player goes offline, entities would be destroyed.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

There is no animation for entity. You have to change the object properties in on_step().

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

Sorry for stupid question, but....
Do I need to change textures property in the on_step() event or I should use set_properties and pass textures table as a parameter? :blush:

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

4aiman wrote:Sorry for stupid question, but....
There are no stupid questions, just stupid answers ;-)
4aiman wrote:Do I need to change textures property in the on_step() event or I should use set_properties and pass textures table as a parameter? :blush:
You cant set the animation as a parameter in set_properties(). You need to setup a timer in on_step() like this:

Code: Select all

timer = 0,
on_step = function(self, dtime)
    self.timer = self.timer + dtime
    if self.timer < 0.25 then 
        return
    end
    self.timer = 0
end,
After this you set the next texture of the animation:

Code: Select all

local animation_frames = 8
[...]
timer = 0,
anim_step = 0,
on_step = function(self, dtime)
    self.timer = self.timer + dtime
    if self.timer < 0.25 then 
        return
    end
    self.timer = 0
    self.anim_step = (self.anim_step+1)%animation_frames
    self.object:set_properties({
        textures = {
            "rain_inside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
            "rain_outside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
        },
    })
end,
Note: This is untested code.
Last edited by PilzAdam on Mon Nov 26, 2012 09:26, edited 1 time in total.

User avatar
Likwid H-Craft
Member
Posts: 1113
Joined: Sun Jan 06, 2013 14:20
Location: Lost in Crypt

by Likwid H-Craft » Post

Hey Adam I made my own rain textures for my, texture pack so if you like use it you can:D
My Domain's/others:
http://likwidtest.hj.cx/ (Not Done)

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

It's better to wait for approval of particle spawners :)

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

by Casimir » Post

@PilzAdam
I tested that code, and it works so far that it is an animation. But it does not show a complete picture but only one horizontal line stretched. To be precise the lines 1 to 8.

It seems to me that those lines are incomplete:
PilzAdam wrote:

Code: Select all

        textures = {
            "rain_inside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
            "rain_outside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
        },
( replace }, at the end of the lines with .."]" to make it work)

edit:
Found it. It has to be

Code: Select all

"rain_inside_animated.png^[verticalframe:"..animation_frames..":"..self.anim_step.."]"
Last edited by Casimir on Thu Feb 14, 2013 17:23, edited 1 time in total.

chase programer
Member
Posts: 117
Joined: Thu Jan 03, 2013 16:56
Location: Everywhere.

by chase programer » Post

i want lava rain for fun =0 [img]dog[/img]
Back and ready to help with this amazing community that i lost.

User avatar
nomohakon
Member
Posts: 219
Joined: Fri Aug 10, 2012 16:34
IRC: nomohakon
In-game: nomohakon
Location: VanessaE's servers

by nomohakon » Post

chase programer wrote:i want lava rain for fun =0 [img]dog[/img]
I guess acid rain will be better.
"To learn who rules over you, simply find out who you are not allowed to criticize." - Voltaire
"Knowledge, like air, is vital to life. Like air, no one should be denied it." - Alan Moore, V for Vendetta
- - -
"To never die... and to conquer all, that is winning." ―Illyria

Josh
Member
Posts: 1146
Joined: Fri Jun 29, 2012 23:11
Location: Victoria, Australia

by Josh » Post

Having rain in the game would be a refreshing idea, expecially the players who have heatwaves in their countries ;)
We could also have lightning which could set fire to trees. And storms which damage the land.
Lightning and storms are probably impossible now. But later on it could be possible :D

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests