Marathon replication project

Discuss and unveil current Marathon projects.
Post Reply
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I would like to make a Marathon Unity port.

I don't know how Aleph One works exactly, but I have some idea how to make Marathon in Unity.
Player and monster sizes and other values can be obtained from Aleph One code.
Aleph One is a portal engine and I read what I can find on how they work.
I have ideas to design this Unity project around portal rendering.
With my limited understanding of how 5D space works, I made something like it using the stencil buffer and changing layers.
How it works is there are two ways for rendering the map, portal rendering and normal rendering.
Most of the map is rendered normally and only the overlapping spaces are rendered by portals.
Monster sprites will carry a material shader that can switch from portal to normal rendering.
When the player enters a portal room the items, scenery and monsters switch to normal rendering.
Hiding anything that is inside the portal space is the plan.
The player and monsters all change layers to that portal room layer when going inside the portal room.
The 5D space rooms are different layers and the settings are changed to not collide with each other.
Doors and platforms can be hidden with portal rendering.
Portals will have to be turned off and on with the more extreme uses of 5D space.
Layers can be used to block monsters and teleporting.
The maps are separated into sectors and trigger sectors will be a mesh that is not rendered that checks when the player enters.
The map will be a prefab with everything in place with skill level that gets loaded into a scene.
I checked the maps for Marathon 1 and all can work with only two layers for the portals.

I've made three maps with 5D space in Unity already.

Two Hallways
https://youtu.be/tXidFtsSTyE

Hypercube
https://youtu.be/jcsXnpgNiBw

5-D space
https://youtu.be/oZgejqIr7o8

Original Marathon maps with 3D models for monsters and items would be great.
User avatar
Meerjel01
Mjolnir Mark IV
Posts: 422
Joined: Nov 4th '17, 09:59

You must be really good at Unity to make this.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I'm learning more about Unity and improving at C# programming while I work on this.

Unity and blender map making removes the limits I had in Weland map editor.
I imported the map Aye Mak Sicur to blender and made a 3D edit to make the 5D space bridge really move up and down.
Make the map in Weland first then export to obj model and texture it in blender or Forge plus can export to FBX model.
A fast way to texture and edit a Marathon map is to use Forge plus and blender.
https://github.com/deramscholzara/ForgePlus/releases

I focused on 5D space first and developed it so I can make Marathon maps in Unity.
The code on how to make 5D space in Unity is in this Unity forum post.
https://forum.unity.com/threads/sharing ... ct.986004/

The other way I thought about making this project was to convert Aleph One code from C++ to C# and build around that.

Unreal engine 4 is the other possibility to use C++ Aleph One code in.
User avatar
Meerjel01
Mjolnir Mark IV
Posts: 422
Joined: Nov 4th '17, 09:59

I really never knew about ForgePlus. Might use it.

Alot
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I tried raycasting and linecasting and it did not work that well.
Maybe it was a bad idea to fire 64 rays from the camera every update and linecast didn't work like I wanted it to because the sector blocked the portal vertices.
I don't know the proper way to use raycasts with Unity.
What I did find to work good was portal occlusion culling.
I can use view frustums to know what sector is visible with portals and sectors.

How it works is the camera is in the current sector and that sector is always visible.
The current sector changes when entering a new sector.
When a portal is in the view frustum, the sector is visible and another view frustum is made for the portal.
The portal has a target sector.
The portal view frustum then finds a target sector portal and this repeats until there are no visible portals.
The original frustum only has access to the current sector and portals can only access its target sector.
Portals are part of the sector.

In Unity I can use GeometryUtility.CalculateFrustumPlanes for the original view frustum and GeometryUtility.TestPlanesAABB for the portals.
A portal has a axis aligned bounding box and the view frustum planes finds the AABB.
I know how to make a view frustum for the portal.
Take the edge of the portal, that is two vertices and the main camera point and from those 3 points make a plane.
Make a plane for each edge then there are the planes that make a view frustum for the portal.
The view frustum can be used to do clipping too.
The portals can only clip it's target sector and the original frustum can only clip the current sector.

I need to make a map importer to load a level into a scene.
It is difficult to edit a complex 5D space map in blender.
Importing the map to Unity with portal polygons would be easier with the polygons put into sectors.
Not having to make portals or move anything would be great and I wont have to rely on the stencil buffer.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I've made some progress on this.

https://www.youtube.com/watch?v=_SjYeNLr0Jo

I no longer fall out the map and improved the portal rendering.
Need to get point in polyhedron working.
Need to find more information about portal frustum clipping shaders.
All I have to do is use point in polyhedron to check what sector the player is in.
Check the current sector and the neighboring sectors.
I can't check all sectors, the 5D space would confuse it.
With clipping one or two or more portal frustums are clipping a target sector.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I am using point in polyhedron now so I don't have to use box colliders on portals.
Mathematical planes are added to every triangle in a sector mesh and the portals are added to the mesh planes list.
Distance to plane is used with the camera point to check if the player is inside or outside a sector.
The current sector updates when the player enters a neighboring sector.
The next thing to upgrade is the way it gathers visible sectors.
Need to figure out how to use breadth first search on a directed acyclic graph tree.
It starts at the root sector and adds a sector to a list then puts the sector edges into a queue for next search.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

So I'm still developing 3D portal rendering for a Unity Marathon port.

My Tests show that 3D portal rendering will be the same as 2D portal rendering that Aleph One has, but the floor and ceiling can be portals in 3D.
Upgrading Marathon's portal rendering to 3D using mathematical planes.
The planes represent a view of everything that is visible.

If you want the source code to the video I made using stencil buffer for clipping.

https://github.com/huriettic/portalrend ... nesandaabb

The next thing I'm building is 3d portal rendering with polygon clipping.
Clipping the portal polygon makes the view through planes change size and I made a clipping shader to discard what is outside the planes view.
Clipping portals will be compatible with loading the levels automatically.
First construct polygons from lines and vertices then do the 3d portal rendering.
Use the mathematical planes to clip polygons and the shader uses planes to discard the view outside of the planes.

I got the polygon clipping from a doom 3 project.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

User avatar
Meerjel01
Mjolnir Mark IV
Posts: 422
Joined: Nov 4th '17, 09:59

Why remake/port an already existing game when you can use your talents on an original title?
https://www.youtube.com/watch?v=psMd9DTZY4A&t

Still. Good work.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

Meerjel01 wrote: Sep 23rd '23, 19:43 Why remake/port an already existing game when you can use your talents on an original title?
https://www.youtube.com/watch?v=psMd9DTZY4A&t

Still. Good work.
A new video of a level that was made in Weland.
https://www.youtube.com/watch?v=ABR4kx4DT0c

I had a idea to make a game engine that has new features for Marathon.
This portal rendering could be the start to an advanced engine.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

What if I mix Halo and Marathon together?
https://forums.bungie.org/story/?read=75158

I've begun work on Unity Marathon.
https://github.com/huriettic/ultramarathon

Going to add textures to it.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I've updated the prototype to Unity 2022.3.18f1.

https://github.com/huriettic/portalrend ... siblespace

https://www.youtube.com/watch?v=g1zEmdnR2Ww

Check sectors was changed and now it collects the sectors the player is in contact with.
The portal visibility check was separated from the player contacting sector code.
I think it runs faster now and it has bug fixes from Ultra Marathon.

The third party code MIT license.

Setting planes in camera code, the polygon plane clipping code and plane create code.

https://github.com/Bunny83/UnityWebExamples/tree/master

https://discussions.unity.com/t/project ... ace/169745

Look for VisPortals.
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I'm working on a level converter and the Bisqwit portal rendering tutorial level now has texture coordinates.

https://www.youtube.com/watch?v=BQ13diEJevA

Made a new level format with texture coordinates on github.

https://github.com/huriettic/portalrend ... perimental
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

Look at Bisqwit's video if you want to know more about portal rendering.

https://www.youtube.com/watch?v=HQYsFshbkYw
Qweasy908
Cyborg
Posts: 86
Joined: Jul 18th '18, 22:45

I can explain how the experimental portal rendering works.

Start() and Awake() run one time and Update() runs every frame.
Load() loads the text file containing the level information.
There are three class objects.
Polyhedron contains indexes to a list of Faces.
Polyhedron has planes indexes to check if the player is inside it.
Polyhedron has portals indexes to know which face is a portal.
Polyhedron has render indexes to know what faceMesh to render.
Polyhedron has Collision indexes to know what faceMesh to collide with the player.
Face contain vertices and ints to Plane, portals, rendering and collision.
Face has a int to FaceMesh list.
FaceMesh contain triangles and vector2 UVs for textures.
There is a list of level meshes that match FaceMesh list and a list of level objects from GetlLists().
CreatePolygonPlane() makes a list of mathematical planes that match the list of face objects.
A mathematical plane is made with three vertices going in clockwise order.
Playerstart() gets the player starts and sets the current polyhedron the player is in.
Controller() moves the player and camera.
GetPolyhedrons() checks for the polyhedron the player is in and gathers the polyhedrons the player is in contact with then it does collision.
ReadFrustumPlanes() puts the mathematical planes in the main camera before the GetPortals() function.
GetPortals() has a for loop that renders level mesh objects and gets portals to go to the next polyhedron to render.

In C++ a vector is the same as a C# list.
Post Reply