Page 1 of 1

ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Thu Sep 01, 2022 2:57 pm
by ZZYZX
fragments.png

Here's a POC script I made to test the limits of dynamic map generation.

On each level load the script will assemble the parts found in MAP01.wad into a map that makes sense (i.e. all parts are used and areas are matching).

Terminology:
1. Fragment — a single section/prefab; closed group of sectors
2. Area — a semi-closed group of fragments (may have connections to other areas)
3. Fragment portal — a line of certain size (width x height) and texture (TPLAREA# where # is 1-6). The line is converted into a line portal, so it must have empty space behind.

Fragments will be connected by fragment portals with matching areas. This allows making areas behind key doors, as illustrated in the sample.

Modes:
1. Static portals mode (currently default): will move sectors around physically and rotate them
2. Dynamic portals mode (can be switched by setting GENERATE_STATIC_PORTALS to zero): will create simple teleporters

Limitations:
- Dynamic lights are broken if two sectors occupy the same 2D space as a result of static portal linking (caused by GZDoom)

Supports:
- Slopes
- 3D floors
- Rotated / scaled surfaces

I believe even without fancy sector features this is already great for a nice gameplay experience, but I can't see myself mapping anything complicated anytime soon, so I'm releasing it as a resource and not as a level :)

This code can be reused freely with or without credits and you don't have to contact me about it (MIT)

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Mon Sep 05, 2022 10:12 am
by ZZYZX
Update! The new version will correctly handle texture scale, rotation and offsets on floors and ceilings of rotated static portals.

Slopes will still have issues because the pull request to enable fixing them is not there.

Also due to the same pull request texture coordinates will be completely wrecked, but hopefully this can be fixed even if the slopes are not merged.

I also fixed calculation of the center of a fragment, which heavily affected rotation of fragments (they were not where you'd expect them to be looking at the map, and could intersect with each other creating invalid geometry).

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Sat Oct 08, 2022 8:09 pm
by Zemakat
I've played through the map a few times, and I love it! I think it functions neatly and I haven't encountered bugs. Beautiful concept and feature, I hope this map becomes popular!

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Sun Oct 16, 2022 9:59 am
by janiform
This is really cool! I wanted to mention that I've noticed a few limitations with the static portals in this script that aren't usually a problem with static portals - reflective floors have visual glitches, dynamic lights don't pass through the portals, and I've seen the tops of some midtextured linedefs on the other side of a portal sort of cutting off when approached.

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Mon Oct 24, 2022 1:54 pm
by ZZYZX
janiform wrote: Sun Oct 16, 2022 9:59 am This is really cool! I wanted to mention that I've noticed a few limitations with the static portals in this script that aren't usually a problem with static portals - reflective floors have visual glitches, dynamic lights don't pass through the portals, and I've seen the tops of some midtextured linedefs on the other side of a portal sort of cutting off when approached.
Haven't tested dynamic lights, midtextured linedefs definitely should not break though, that's weird.

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Mon Aug 07, 2023 6:11 pm
by ZZYZX
Update (suddenly)

I added plane slope rotation and enabled vertex offsets since latest GZDoom version allows those. Vertex slopes and 181 special slopes should work normally. Plane copy slopes will probably break if planes refer to different fragments (but that is expected).

1st post contains the new version.

Saw the dynamic light issue, it seems to be a generic issue with portals that are occupying the same XY space. The only good solution to this is using 3D shadowmaps which are not available yet :roll:
Or attempting to make levels in a way that they never can intersect (e.g. only doing straight passageways).
I think the script could attempt resolving portal connections in a way that 2D geometry never overlaps, by using a blockmap or so. The problem with this is that while possible it could easily cause unrecoverable "missing piece" problems, if the only possible solution is to overlap.
Easier is to introduce some kind of a custom dynamic light that only renders when you directly see it (or the fragment it's in). And then it will be pretty much like Build where you get visual artifacts if you see two sides of a portal at once.

3D floors cannot be added because 3D floors are not yet filled into the sector during preprocessing, and even sector tags are not available, so it's not possible to manually resolve 160 specials either.
Requires GZDoom patch.


UPD: Worked around this. Updated the archive yet again.

Re: ZDoom-Templated (map randomized at runtime from prefabs)

Posted: Tue Aug 08, 2023 1:55 am
by Redneckerz
Interesting development, ZZYZX!