Trying to implement Shadow Mapping

For people working on the C++ code.
Post Reply
Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Trying to implement Shadow Mapping

by Liso » Post

Hello everyone,
I spent some time reading the codebase and things about Irrlitch3d and after some tests I started to get
how it works.

After a few days of testing I can show you something, but I want to know if the implementation of Shadow Mapping ( CSM in a near future) could be welcome in the project.
Spoiler
Image


Image

Image
New Images Image
Image
Image
Attachments
test_shadows4.jpg
test_shadows4.jpg (401.92 KiB) Viewed 3661 times
test_shadows3.jpg
test_shadows3.jpg (611.09 KiB) Viewed 3661 times
test_shadows2.png
test_shadows2.png (869.2 KiB) Viewed 3661 times
Last edited by Liso on Wed Dec 09, 2020 12:03, edited 3 times in total.
Liso. - My twitter -

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

Re: is Shadow mapping desired?

by rubenwardy » Post

Shadow mapping would be welcome. There have been previous attempts, but they've failed due to various glitches and problems
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

Yes, I faced some of those problem.

The major problem is, obviously, the Irrlicht3d. There is no way to do more than one shader pass in a easy way. Also the map rendering generates a lot of problems, but IMHO they could be solve with some workarounds until a new 3d Engine come ;).

I'm going to continue testing this and I hope Minetest will have Shadows in a near future :).

Image

Thank you.
Attachments
test_shadows5.jpg
test_shadows5.jpg (308.45 KiB) Viewed 3661 times
Liso. - My twitter -

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: is Shadow mapping desired?

by Lone_Wolf » Post

YES. It would be a much appreciated addition to this engine
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
StarNinjas
Member
Posts: 411
Joined: Wed Mar 14, 2018 00:32
GitHub: starninjas
IRC: StarNinjas
In-game: J1
Location: Terrarca
Contact:

Re: is Shadow mapping desired?

by StarNinjas » Post

Nice going, hopefully this will evolve into something amazing!
Don't go to bed tonight, without knowing what would happen if you died. https://thegospelfilm.org/

User avatar
Agura
New member
Posts: 3
Joined: Sun Jul 07, 2019 15:18
GitHub: Agura
IRC: Agura
In-game: Agura

Re: is Shadow mapping desired?

by Agura » Post

I'm more than interested! Great Job! well done.

User avatar
Zughy
Member
Posts: 301
Joined: Thu Mar 26, 2020 18:23
GitHub: belongs_to_microsoft
In-game: Zughy
Location: Italy
Contact:

Re: is Shadow mapping desired?

by Zughy » Post

Big thumbs up. Ignorant suggestion: would something like IrrlichtBAW fix those problems?

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

First of all, Thank you everyone for your words of support :). I'll do my best to make this work.
Zughy wrote:
Sun Oct 25, 2020 21:44
Big thumbs up. Ignorant suggestion: would something like IrrlichtBAW fix those problems?
Hi Zughy, obviously change irrlitch3d (Last functional update was in 2012) for something more modern will help a lot with the rendering .

The most logical option could be IrrlitchBAW or Antartica (custom Irrlitch from STK) because the supposed compatibility and similarity of the API.

But... IDK if this supposed similarity is real.

Also, Irrlitch3d supports lots of different systems. From Software Renderer to OGL, DX, AmigaOS, Android, iOS?, ...

will these other engines support that wide range of systems?

I don't know the roadmap and plans of the core developers. But I can say that changing to another 3d engine will cost a lot of effort. ( Believe me, I already take a look on that ;) )

Maybe an option could be to completely split up the rendering part from Minetest engine, and do different code&build for "modern hardware" rendering.

But as I said before, IDK the plans for Minetest and all I said is just talking for talking's sake.
Liso. - My twitter -

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

Re: is Shadow mapping desired?

by jp » Post

I was the first to attempt to add realtime shadows back in 2017 using OpenGL framebuffers, but the implementation was dirty and I couldn't figure out some things like the occlusion code.

Cascaded SM is the way to go for a voxel game. I'm eager to see the end result of your work.
And I hope some toxic core-dev will abstain from nitpicking to death.

BTW, IrrlichtBAW is not a drop-in replacement for Irrlicht. I asked the author personally. Antarctica is a more serious alternative to consider.

User avatar
Andrey01
Member
Posts: 2574
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: is Shadow mapping desired?

by Andrey01 » Post

Nice to see a promising feature, much hoping for it won`t be neglected or rejected finally as it is enough breaking. :) It seems it needs still polishing out. Do you consider also to open a PR on the github repo if it is at least workable for now and can be tested?
jp wrote: And I hope some toxic core-dev will abstain from nitpicking to death.
Do you refer to paramat?

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

Thank you all.
I'm trying to make it the most separated from the base code as I can. The main idea is to append this (and probably other) feature without losing the low-end pc capabilities.

And obviously yes, I'll send the PR to the main repo as soon as I have an alpha version ;).

BTW JP, I saw a reflexions demo in your YT channel (stalker alert xD ) , you did this in Screen Scpace?
Liso. - My twitter -

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

Re: is Shadow mapping desired?

by jp » Post

Liso wrote:
Mon Oct 26, 2020 17:39
I saw a reflexions demo in your YT channel (stalker alert xD ) , you did this in Screen Scpace?
No the water surface is a single plane and it uses a second camera to render reflections. For a voxel game you necessarily need SSR but first we need a clean post-processing framework using the OpenGL buffers.

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: is Shadow mapping desired?

by TumeniNodes » Post

jp wrote:
Mon Oct 26, 2020 13:23
Antarctica is a more serious alternative to consider.
We had a thread in which some of us mentioned Antartica somewhere in this forum a while back, I specifically remember it.
It's just ugh... the work involved switching (shivers)
It would definitely take a group of loyal/dedicated people outside of the core dev team, with the ability to do so, otherwise core devs would become even more bogged down.
Unless all the focus went into that alone, and putting the entire current project at a (possibly) indefinite freeze.
Honestly I'm not sure anyone would do it out of a passion/love for the community alone.
A Wonderful World

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: is Shadow mapping desired?

by v-rob » Post

Actually, I think the main reason we can't use Antarctica is that it's GPL and we're LGPL. Not certain, but that's what I remember.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

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

Re: is Shadow mapping desired?

by rubenwardy » Post

Antarctica has relicensed to a permissive license
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

cuthbertdoublebarrel
Member
Posts: 348
Joined: Tue Apr 14, 2020 16:03
GitHub: cuthbert

Re: is Shadow mapping desired?

by cuthbertdoublebarrel » Post

It is if it does not produce lag . you can have all the eyecandy you desire but if it impacts on the faster paced gameplay then just give us the option to switch it off not everyone here is into snail paced puzzle games ,some of us are cranking up the engine to the max and the wheel have yet to come off . but she aint running too smoothly with the eyecandy as it is .
Project BrutalTest...hide your Petz

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

Re: is Shadow mapping desired?

by Miniontoby » Post

how does this works?
Working on mtctl ---- Check my mod "Doorbell" -- Stay safe

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: is Shadow mapping desired?

by runs » Post

short respond: yes.
long respond: of course.

PD: LOL

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

Hi all!,
I'm still fighting with CMS, it has some upgrades and lots of problems. But, in general, it's on road.

There are new pics in the first post.
Miniontoby wrote:
Tue Nov 03, 2020 08:00
how does this works?

I´m not sure what your question is about. Can you explain it?

Image
Image
Image
Attachments
test_shadows11.JPG
test_shadows11.JPG (269.59 KiB) Viewed 3661 times
test_shadows10.JPG
test_shadows10.JPG (261.29 KiB) Viewed 3661 times
test_shadows9.JPG
test_shadows9.JPG (369.81 KiB) Viewed 3661 times
Liso. - My twitter -

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: is Shadow mapping desired?

by Lone_Wolf » Post

Still looking great. Can't wait until I can try this out for myself
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
Andrey01
Member
Posts: 2574
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: is Shadow mapping desired?

by Andrey01 » Post

A question: can entities also leave their shadows by the same principle? Or does this feature concern exclusively only to nodes?

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

Andrey01 wrote:
Fri Nov 13, 2020 16:53
A question: can entities also leave their shadows by the same principle? Or does this feature concern exclusively only to nodes?
Yes, sure :). Even with the animation.

Image


But it's in an early alpha version. It has lots of artifacts, the code is awful and it's not optimized in any way.
Attachments
test_shadows13.JPG
test_shadows13.JPG (264.01 KiB) Viewed 3661 times
Liso. - My twitter -

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: is Shadow mapping desired?

by philipbenr » Post

The above image got me curious, how are you feeling in regards to partially transparent, or colored things like water or stained glass? I know that keeping a narrow scope at the beginning of a project or part of a project is a good idea and this is certainly more in the light transport realm and less "shadows" I suppose, but I am curious how you feel about it. Being able to handle this would be great, as it would open up a lot of different possibilities for future light expansions in the engine/mods.
But it's in an early alpha version. It has lots of artifacts, the code is awful and it's not optimized in any way.
Isn't that how it always is? ;P It looks great for one person's work.

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

I guess using SM to handle sun's illumination in a more general way could be possible. Right now it's just discarding the transparent pixels. But with the material properties and color, maybe it's possible to do what you suggest.

I'll take a look on it.

Anyway, my personal opinion is to create a base SM system that could be upgraded, or even more...

We can talk about it after the PR, but... Deferred rendering ;) ;)
Liso. - My twitter -

Liso
Member
Posts: 33
Joined: Thu Feb 06, 2020 10:21
GitHub: 0xLiso
In-game: Liso
Location: Valencia - Spain.
Contact:

Re: is Shadow mapping desired?

by Liso » Post

Just to give a more extended explanation.
To do that, we need to handle the SM in the "main" shader, so we should pack the CMS information in one texture, it could be in a 3-4 subfrustums in the texture or using rgba as a shadow depth information, because we can only handle 4 textures(Irrlicht you know), an 2 of them are already been used.
With that information and the sun position ( direction ) plus the material information, we should be able to "modify" the shadow and lighting. Because at the end the actual illumination """is just""" the dot product of the normal with the light direction.

Disclaimer: I'm learning right now about all this stuff, so I have huge lacks of knowledge.
Liso. - My twitter -

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests