New modder, some questions

Post Reply
nfries88
New member
Posts: 4
Joined: Fri Sep 11, 2020 06:08

New modder, some questions

by nfries88 » Post

Hey everyone, I'm new to minetest/modding but I had a game idea that minetest seemed pretty good for so I'm giving it a try, I just have some questions.

I've already read the modding book and the source of some mods to get a feel for it, and I've already written a mod adding a hud displaying some useful info for making the first few mods I want to work on, which are basically immersive look and feel mods. If you know similar mods already exist, let me know! I'm not trying to reinvent wheels here :)

==Clouds==

The first is I want to do something about minetest's clouds. The ones built into the sky box spawn as a layer one node thick while real world clouds are usually hundreds of meters thick with irregular 3D shapes, and the clouds don't change color vibrantly enough to really capture the beauty of sunset and sunrise. I see there's a default:cloud included with minetest game, but it just uses a flat white texture and doesn't seem to be used for anything.

I know I could spawn it as an ore in air, the problem is with changing the colors of the different faces. Ideally the face most directly getting lit by the sun would be yellow, adjacent faces would be red, and the faces not getting any sunlight would be a slightly purplish dark gray.

It looks like best results would be gotten by registering new nodes for sunrise and sunset clouds based on height so that the correct faces are the right color, and then swapping the individual nodes from default:cloud to the appropriate new cloud node depending on time of day. This has the downside of potentially having to change tens of thousands of cloud nodes in an instant.

But an acceptable compromise would be to simply change the textures of default:cloud to the appropriate sunrise and sunset ones, then change them back for night and day. But I don't see an API for changing the textures of a registered node, would just changing the data in the minetest.registered_nodes table work?

There's also the problem of clipping at the edge of loaded mapblocks. I know there's no way to completely get around this, but with the default loading distance even scaled down clouds that are relatively near the player will get clipped. How can I expand the distance at which mapblocks are loaded, whether in settings or in scripts?


UPDATE: I tried just placing some sunset-colorized clouds on top of stuff and it looks okayish if the blocks are between you and the sunset (although the yellow face isn't visible at all), but it looks awful if you're looking the opposite direction. Seems like to do sunrise/sunset clouds right it needs to be based on the individual player's location, which I have no clue how to do.

==Wind==

I'd also like to add wind that's actually able to knock leaves off trees, kick up sand, etc at high speeds. This doesn't have to match the real-world physics of wind at all, and the wind doesn't need to be super consistent (missing rows of blocks is okay). I kind of imagine this as just spawning entities at random locations which are "wind emitters", and these "wind emitters" in turn spawn "wind" entities that head in random directions, gradually decelerate, cause "wind" and "dust" particles when they pass relevant nodes, and cease to exist when they run out of speed. Is this something feasible? Does anyone know how many actively moving entities will stress the engine?

nfries88
New member
Posts: 4
Joined: Fri Sep 11, 2020 06:08

Re: New modder, some questions

by nfries88 » Post

I've continued dabbling with the clouds and found that making clouds a colorized, nearly opaque liquid node type and using an ABM to change the color based on light level actually produces the desired effect at sunset with a couple caveats:

1) light level is too coarse-grained, so cloud colors change very rapidly and in large groups, making a very weak effect
2) the angle of light from the sun doesn't seem to change as the sun sets, so the bottom nodes change instead of the nodes farthest from the sun

So I think I need to emulate the scattering of light inside the clouds by counting the number of cloud nodes between a particular node and an air node in the direction of the sun, and selecting color based on that count.

This brings me to new questions:
1) Is there an existing way to estimate the position of the sun, or at least a reasonable normal vector towards the sun, based on the game's time-of-day? Or do I just gotta play around with /time and come up with my own estimations?
2) Is there a way for a mod to change the lighting direction for the sun and moon?

This also got me thinking about the skybox; its set from static images, but I didn't see any image composition API available. Seems like a serious limitation for a game engine to not allow programmatic composition of images when textures make up so much of its visuals. I suppose I could roll my own as a mod if Lua has built-in binary file I/O support though.

nfries88
New member
Posts: 4
Joined: Fri Sep 11, 2020 06:08

Re: New modder, some questions

by nfries88 » Post

I have had some success with estimating the sun's unit vector based on time of day, and increasing the range of the palette I'm using for some nicer gradients.

Ofc now that I'm playing with actually having these clouds generate in worlds, it seems that nodes in map blocks without a player don't run ABMs even when they're visible?

Image
clouds.png
(80.63 KiB) Not downloaded yet

User avatar
Nathan.S
Member
Posts: 1023
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: New modder, some questions

by Nathan.S » Post

I'm pretty sure this is how it works.
The abm running is controlled by the

Code: Select all

active_block_range
setting in minetest.conf. Mapblocks that are outside of that range won't have their ABMs run, even if they are visible to players.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

nfries88
New member
Posts: 4
Joined: Fri Sep 11, 2020 06:08

Re: New modder, some questions

by nfries88 » Post

Nathan.S wrote:
Sun Sep 20, 2020 23:07
I'm pretty sure this is how it works.
The abm running is controlled by the

Code: Select all

active_block_range
setting in minetest.conf. Mapblocks that are outside of that range won't have their ABMs run, even if they are visible to players.
considering that my game froze when I set this to 256 I'm thinking that would've worked and I need to do something different. Right now I'm using ABMs with a chance=16 and coloring the clouds with a recursive function (since I have to use get_node() along the sun's vector to calculate the distance sunlight is traveling through the cloud anyway, I figured this would be better than running an abm for every cloud), this was working smoothly on even very large clouds with the default active block range. Thanks, I'll keep playing around!

EDIT: clearly this is talking about map blocks, not nodes, so I set that value ridiculously high. 16 is doing what I was hoping for with only a tiny bit of lag, but how big is a map block?

User avatar
GreenXenith
Member
Posts: 1326
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: New modder, some questions

by GreenXenith » Post

Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

Post Reply

Who is online

Users browsing this forum: Nathan.S and 1 guest