[Mod] Funny Shadows [shadows]

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

[Mod] Funny Shadows [shadows]

by x2048 » Post

This mod adds more realistic shadows and more natural sunlight propagation, all based on Minetest voxel light, so only consumes CPU when generating the first time and digging/building.

Screenshot:
Image

This is a pure Lua implementation, so expect CPU load and lagged updates of shadows. Playable in MCL2 and Minetest, and is overall unobtrusive. Use configuration parameters to tune for your gameplay, see more in README.md

License: AGPL-v3
Content License: CC0

Github: https://github.com/x2048/shadows/
ContentDB: https://content.minetest.net/packages/x2048/shadows/

Register issues here: https://github.com/x2048/shadows/issues

Current Release: Alpha 3

Previous Releases:
Last edited by x2048 on Sun May 02, 2021 21:48, edited 2 times in total.

User avatar
Devy
Member
Posts: 133
Joined: Sat Jan 21, 2017 02:31
GitHub: DevyHeavy
In-game: devy

Re: [Mod] Funny Shadows [shadows]

by Devy » Post

I just tried this! Looks good for what it is (maybe slightly hacky, but what are you going to do until we get an opportunity for custom modded shaders).

Good job!

User avatar
apercy
Member
Posts: 640
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [Mod] Funny Shadows [shadows]

by apercy » Post

Interesting!
And the good part for me, I disabled it and the effects keep!
This is a mini map for kart race, so it's ok for me to run only one time

Image
Attachments
screenshot_20210413_160812.png
screenshot_20210413_160812.png (522.24 KiB) Viewed 2186 times

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

apercy wrote:
Tue Apr 13, 2021 19:12
Interesting!
And the good part for me, I disabled it and the effects keep!
This is a mini map for kart race, so it's ok for me to run only one time
Yes, it saves the light information into the map, so you don't need the mode running all the time if the map is static. Great to hear that it's already useful for you.

BTW, it is possible to tweak the contrast of the shadows by changing params.a1 and params.a2 at the top of the init.lua file to, say 0.6, if it adds to the gameplay.

And in order to make it regenerate the shadows, you need to increase the generation parameter every time you make a change.

User avatar
jp
Banned
Posts: 947
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith
Location: France

Re: [Mod] Funny Shadows [shadows]

by jp » Post

Obvious performance improvement: https://paste.ubuntu.com/p/hHW9GWGTYR/

Don't forget to save the temp table in the mod storage on server shutdown.

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

jp wrote:
Tue Apr 13, 2021 22:25
Obvious performance improvement: https://paste.ubuntu.com/p/hHW9GWGTYR/
Thanks for the tip, but I doubt it will scale for larger maps. Right now I distribute my state into mapblocks and rely on the engine to save/load each mapblock separately. In-memory table adds memory pressure (10s of MBytes on larger maps) and adds a risk of data corruption on save, which will cause the entire light map to be regenerated.

Currently I'll optimize VoxelManip calls to avoid unnecessary allocations and see if it improves performance.

User avatar
jp
Banned
Posts: 947
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith
Location: France

Re: [Mod] Funny Shadows [shadows]

by jp » Post

x2048 wrote:
Wed Apr 14, 2021 19:00
Currently I'll optimize VoxelManip calls to avoid unnecessary allocations and see if it improves performance.
Take a look at this:
- https://github.com/EvidenceBKidscode/ffiopt
- https://github.com/EvidenceBKidscode/ff ... ipdemo.lua

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Funny Shadows [shadows]

by sorcerykid » Post

Nice job! This is arguably the most impressive mod I've seen this year.

What are the prospects of porting it to CPP? I can only imagine it would be significantly more efficient if implemented as an alternative to the engine's existing lighting algorithm. After all, we have different mapgens, so it only makes sense that offering multiple "lightgens" might be a natural step forward as well :)

Anyway huge kudos, I look forward to keeping an eye on this!

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

sorcerykid wrote:
Sat Apr 17, 2021 00:48
Nice job! This is arguably the most impressive mod I've seen this year.

What are the prospects of porting it to CPP? I can only imagine it would be significantly more efficient if implemented as an alternative to the engine's existing lighting algorithm.
Thanks for support! I created this mod to experiment with the algorithm before I would implement it in the engine, and I am a bit in doubt right now whether it (and lightmap shadows as a whole) will still be as interesting after shadow mapping is implemented.

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Published on ContentDB after a number of performance improvements (mainly to avoid recalculating blocks that don't need that)

chaosomnium
Member
Posts: 29
Joined: Sat Aug 08, 2020 21:35

Re: [Mod] Funny Shadows [shadows]

by chaosomnium » Post

very nice

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Prototyping further, shadows now respect position of the Sun (click to play on Youtube):

Image

The change is available on Github.

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Funny Shadows [shadows]

by Linuxdirk » Post

This is just great! I'm tempted to use it in my LP world but I'm a bit concerned about shadows being permanent even if the mod was disabled, and also this line of code.

Code: Select all

minetest.get_meta(chain_block_node):set_int("shadows", 0)
It basically adds an unprefixed meta value to all nodes that are ever loaded.

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Hey Linuxdirk
Linuxdirk wrote:
Wed Apr 21, 2021 06:53
This is just great! I'm tempted to use it in my LP world but I'm a bit concerned about shadows being permanent even if the mod was disabled, and also this line of code.

Code: Select all

minetest.get_meta(chain_block_node):set_int("shadows", 0)
It basically adds an unprefixed meta value to all nodes that are ever loaded.
The mod works by modifying the light information that Minetest stores into the map, that's why it's preserved even if you turn it off. If you want to revert to the default light, just disable the mod and run

Code: Select all

/fixlight here <sqradius>
in the affected areas.

The line uses the mod name as the value name, so "formally" it is prefixed, but yeah, I will change this to "shadows_gen" in the next update, thanks for raising.

User avatar
Miniontoby
Member
Posts: 616
Joined: Fri Mar 01, 2019 19:25
GitHub: Miniontoby
IRC: Miniontoby
In-game: Miniontoby
Location: The Netherlands

Re: [Mod] Funny Shadows [shadows]

by Miniontoby » Post

Can there come an client side version of this mod or do I have to do that myself?
Working on mtctl ---- Check my mod "Doorbell" -- Stay safe

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Funny Shadows [shadows]

by sorcerykid » Post

I just took a closer look at ffiopt, and I can foresee many applications for this patch. My Snowfall mod in particular could benefit greatly from the VoxelManip optimizations. Another fine job, as usual!

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Miniontoby wrote:
Wed Apr 21, 2021 17:26
Can there come an client side version of this mod or do I have to do that myself?
To my knowledge, CSM API does not allow manipulation of the rendering process or map information (such as nodes or light). If there is anything I missed, I can move the implementation client-side.

There is work in the engine to add real-time shadows for all objects in the world, see more here.

User avatar
Miniontoby
Member
Posts: 616
Joined: Fri Mar 01, 2019 19:25
GitHub: Miniontoby
IRC: Miniontoby
In-game: Miniontoby
Location: The Netherlands

Re: [Mod] Funny Shadows [shadows]

by Miniontoby » Post

x2048 wrote:
Thu Apr 22, 2021 14:51
Miniontoby wrote:
Wed Apr 21, 2021 17:26
Can there come an client side version of this mod or do I have to do that myself?
To my knowledge, CSM API does not allow manipulation of the rendering process or map information (such as nodes or light). If there is anything I missed, I can move the implementation client-side.

There is work in the engine to add real-time shadows for all objects in the world, see more here.
There is an Raycast object with functions at the csm api, but yeah idk if that could be handy
Working on mtctl ---- Check my mod "Doorbell" -- Stay safe

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Miniontoby wrote:
Sun Apr 25, 2021 16:17
There is an Raycast object with functions at the csm api, but yeah idk if that could be handy
Raycast is good but not for me. I use voxel manipulators heavily, and these are only available server-side.

BTW, I have now pushed Alpha 3 to ContentDB, which improves responsiveness and adds configuration parameters.

With the latest improvements, even shadows Minetest with v7 mapgen are generated quite fast (of course you can still see progressive generation, but it's much faster now).

User avatar
v-rob
Developer
Posts: 970
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: [Mod] Funny Shadows [shadows]

by v-rob » Post

Err, Raycast is certainly available server-side: https://github.com/minetest/minetest/bl ... 6769-L6794.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

User avatar
Miniontoby
Member
Posts: 616
Joined: Fri Mar 01, 2019 19:25
GitHub: Miniontoby
IRC: Miniontoby
In-game: Miniontoby
Location: The Netherlands

Re: [Mod] Funny Shadows [shadows]

by Miniontoby » Post

v-rob wrote:
Mon May 03, 2021 03:38
Err, Raycast is certainly available server-side: https://github.com/minetest/minetest/bl ... 6769-L6794.
Dude, i want this mod as an csm, not server side and probraly as an in my new csm feature.
Working on mtctl ---- Check my mod "Doorbell" -- Stay safe

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Funny Shadows [shadows]

by Linuxdirk » Post

I just had it in a test world, maybe it's me, but aren't the shadows updated when manually setting time?

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Linuxdirk wrote:
Mon May 03, 2021 09:00
I just had it in a test world, maybe it's me, but aren't the shadows updated when manually setting time?
You should enable "Follow Sun" in the settings for the shadows to change with the time. You can use Minetest settings UI to configure it.

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: [Mod] Funny Shadows [shadows]

by x2048 » Post

Miniontoby wrote:
Mon May 03, 2021 08:47
v-rob wrote:
Mon May 03, 2021 03:38
Err, Raycast is certainly available server-side: https://github.com/minetest/minetest/bl ... 6769-L6794.
Dude, i want this mod as an csm, not server side and probraly as an in my new csm feature.
It would require quite a patch to the engine to allow voxel manipulator on the client, which means it will come after 5.5.0 if ever. Current versions of Minetest simply don't support it.

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Funny Shadows [shadows]

by Linuxdirk » Post

x2048 wrote:
Mon May 03, 2021 16:01
You should enable "Follow Sun" in the settings for the shadows to change with the time. You can use Minetest settings UI to configure it.
Ah, there it is. Great, thanks. That adds a lot to the game!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests