Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Topic started by: afwbkbc on January 12, 2023, 06:37:19 PM

Title: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 12, 2023, 06:37:19 PM
Hi all, I just started an effort to recreate/remaster SMAC (Sid Meier's Alpha Centauri) to let it run on modern systems, and especially to have working, stable, reliable multiplayer. It's still at very early stage, but feel free to subscribe, review, discuss and maybe even participate. I estimate a playable version to come in a month or so.
The idea is to use existing resources and game logic of SMAC (to preserve the feel) while having a modern, multi-threaded, bug-free game client. Once this step is done I will move further and add modding support, better graphics, various online services and more.
Code repository is located at https://github.com/afwbkbc/glsmac , it contains more details, discord link and also some ubuntu-compatible binaries if somebody is too lazy to compile.
It will be nice to have consistent feedback while development goes, to make sure I do everything right :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on January 12, 2023, 06:40:07 PM
 :D   ;b; ;b; ;b;
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Secundus on January 13, 2023, 05:06:34 PM
Awesome work! One thing for sure I watch your project with great interest ;belal
You should also consider sharing r/alphacentauri to reach more people for feedback
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Alpha Centauri Bear on January 16, 2023, 04:59:18 AM
Nice attempt.
Is this first in the history or someone else tried it before? How about OpenSMACX?

Practical question - are you going to rewrite all the code there or borrow it from original?
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on January 17, 2023, 08:55:51 PM
The Facebook post this morning about this on AC2's page, and shared in the Alpha Centauri group, are burning up with 'likes', 'loves', and comments...

Let me know if you get hung up on any graphics issues.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: bvanevery on January 18, 2023, 06:36:38 PM
To quote a dead Vulcan, "fascinating".

Your README says:
Quote
What will be same between GLSMAC and original game?

Models, images, movies, texts, lore, factions, game rules (such as tech trees, types of armor/weapons etc), UI

To my knowledge, nobody has cracked / reverse engineered the proprietary 3rd party voxel format that the SMAC 3d models use.  Someone got as far as making a tool that could texture map those models, but that's about it.  The company that made the voxel renderer is defunct, I think.  Do you have some special insight / knack for this problem?  As otherwise, recreating all the 3d models from scratch in a more modern, known format, would seem to be the saner course.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on January 19, 2023, 09:58:50 AM
Great to see you on the forum again Yotzi and great to see such an ambitious project that's made so much progress already :D

@bvanery, I think Ford Prefect worked out the voxel format. And even if not, working out the last bits of it may well be easier than recreating all of those models and animations.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on January 19, 2023, 10:18:48 AM
FordPrefect and PlotinusRedux worked at reverse engineering the voxel model and animation format (caviar). There are pretty detailed notes here: https://alphacentauri2.info/wiki/Caviar and an open source python project is linked from there that can repaint caviar models.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 19, 2023, 10:49:48 AM
Hey, sorry I'm not here often, busy with coding  ;roze;

Awesome work! One thing for sure I watch your project with great interest ;belal
You should also consider sharing r/alphacentauri to reach more people for feedback
Good idea :)

Nice attempt.
Is this first in the history or someone else tried it before? How about OpenSMACX?
OpenSMACX is about decompilation from what I see, so it's different thing. There's also OpenSMAC but it's certainly less ambitious and is unfinished for some reason.

Practical question - are you going to rewrite all the code there or borrow it from original?
100% written from scratch, only SMAC assets like textures and sounds are loaded in runtime (hence it requires existing SMAC installation, basically a drop-in terranx.exe replacement).

To my knowledge, nobody has cracked / reverse engineered the proprietary 3rd party voxel format that the SMAC 3d models use.  Someone got as far as making a tool that could texture map those models, but that's about it.  The company that made the voxel renderer is defunct, I think.  Do you have some special insight / knack for this problem?  As otherwise, recreating all the 3d models from scratch in a more modern, known format, would seem to be the saner course.
It seems to be already reverse engineered - https://alphacentauri2.info/wiki/Caviar , I haven't tried it yet tho.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 19, 2023, 10:53:13 AM
Approximate roadmap:

Versions 0.x: replicating original SMAC gameplay as closely as possible (but without bugs)​
0.1: fundamental engine functions, such as: rendering, UI, netcode, sound system
0.2: basic map functions, such as: tiles, mapgen, creating/saving/loading games, map rendering
0.3: basic multiplayer: ability to host and join games, lobby, save/load games with same players. multiplayer support will be maintained during further steps from now on
0.4: game processing, such as: game turns, units, buildings, technologies, building of bases, terraforming, basic combat, victory by conquest
0.5: all remaining SMAC units, buildings, terraformings, tech, etc
0.6: all remaining victory types
0.7: AI (computer opponents, cities automation, units automation, etc) and diplomacy
0.8: alien lifeforms, ecology
0.9: all remaining in-game UI, including game settings
0.10: non-crucial things like movies, interludes
0.11: final polishing and bugfixing
Versions 1.x: fixing bugs, adding optional small features that weren't present in original SMAC but won't change it's gameplay drastically. See 'GLSMAC 1.x features' section on discord​
Versions 2.x: adding all kinds of features, as long as they are worth the time. See 'GLSMAC 2.x features' section on discord​

So game will become somewhat playable at version 0.4, I think it will happen in few months. Multiplayer will come before single player so you should have some friends tho :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Ford_Prefect on January 21, 2023, 05:20:54 AM
To my knowledge, nobody has cracked / reverse engineered the proprietary 3rd party voxel format that the SMAC 3d models use.  Someone got as far as making a tool that could texture map those models, but that's about it.  The company that made the voxel renderer is defunct, I think.  Do you have some special insight / knack for this problem?  As otherwise, recreating all the 3d models from scratch in a more modern, known format, would seem to be the saner course.
It seems to be already reverse engineered - https://alphacentauri2.info/wiki/Caviar , I haven't tried it yet tho.

Hi.  I was one of the guys who figured out the format a bit. :-D  Wrote the paint program.   Been a long time since I did anything with SMAC but I'm glad someone is working on it. 

The cvr was surprisingly elegant in storing a voxel shape with as little space as possible.  I was surprised to figure out that the units were in 3d.

I also looked into the music format a bit... and the format looks like someone based it off of middi... or at least the idea of middi. Never tested to see if they actually used the same values for notes and timings as the middi file format or someone decided on something "custom".   
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 21, 2023, 11:28:14 AM
Oh wait, so those are voxel models? Converting them to vertexes and polygons will be fun challlenge then  :)
And yes, good job decoding it  ;b;

About dynamic music - it will be hard or impossible to copy exact algorithm, but sounds are there and I can improvise.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on January 21, 2023, 12:17:34 PM
Ford, what I wonder is - could I paste in images from a more sophisticated graphics editor?  That would make all the difference.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on January 21, 2023, 02:03:44 PM
All of the units (except native life) and unit parts are 3D models, represented as one or more chains of voxels, with each voxel having a single colour and each chain having a location and orientation. The models can also be animated. If they are, then each chain of voxels can be moved, rotated or hidden in each animation frame.

BUncle, do you mean that you want to texture the existing 3D models or that you'd like to use 2D images instead of the 3D models? The 3D models are used to let units face different directions and to allow unit parts to be visually combined.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on January 21, 2023, 02:16:26 PM
For what I specifically have in mind, 2D with the colors I pasted in working.  The 3D thing would really be nice for a lot of SMACX modding purposes we've never been able to do even badly, but at least a single 2D frame...
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Ford_Prefect on January 21, 2023, 03:17:32 PM
Oh wait, so those are voxel models? Converting them to vertexes and polygons will be fun challlenge then  :)
And yes, good job decoding it  ;b;

About dynamic music - it will be hard or impossible to copy exact algorithm, but sounds are there and I can improvise.

Not really sure the music is dynamic.  The .amb files have multiple tracks and really looked like midi at first glance other than the references to the sound files at the start.  I just never got around to finding a good library for changing the pitch and playing wav files before I lost interest.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 26, 2023, 09:22:20 AM
Not really sure the music is dynamic.
If you go afk then after a while music stops playing. Then as soon as you move mouse - it continues. It also seem to depend on your situation (i.e. if you are at war or not). So it's at least a bit dynamic (but made from predefined pieces).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 28, 2023, 12:47:37 PM
For those not on discord - I updated README with more information and added possible 1.x+ and 2.x+ features, come have a look - https://github.com/afwbkbc/glsmac  8)
Current status: v0.1 is released, working on map functions now.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 29, 2023, 01:01:05 AM
Made some progress with maps  :) Water and rivers coming soon.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 30, 2023, 04:25:50 PM
Added some water, it looks a bit different from SMAC but hopefully not too bad. Replicating exact SMAC water algorithm is too much effort, I'll focus on other things first.
Not the final version of water, it will be improved further, but for now I'll be focusing on reaching some playable state.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on January 30, 2023, 05:18:57 PM
-Design note:  GIFs.  .PCX is a pain to work with and .FLCs are impossible.  Do it all with .GIFs and modders will beat a path to your door.


-Also, a little leaderhead animation would then be feasible.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 30, 2023, 05:55:43 PM
-Design note:  GIFs.  .PCX is a pain to work with and .FLCs are impossible.  Do it all with .GIFs and modders will beat a path to your door.


-Also, a little leaderhead animation would then be feasible.

I know, when modding support is done it will accept any format, 32-bit color and different resolutions. For now I'm focusing on game itself.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 31, 2023, 02:45:08 AM
Added some light and shadows, looks better imo
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on January 31, 2023, 09:59:55 PM
Fixed 'half-submerged tiles' problem. Still working on coasts, this isn't final look :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Vidsek on February 01, 2023, 01:14:36 AM
  Step by step, better and better!  Can't wait to see how stable it is in gameplay  ;lol   I'm rooting for you, keep up the good work!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 01, 2023, 03:49:11 AM
Better water, sea fungus, smoother map generation  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 01, 2023, 03:51:55 AM
Some 160x160 aswell :) ~2600FPS, map generation + loading takes around 3 seconds (release build)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 01, 2023, 09:00:19 AM
I wonder if it's feasible for a single person to complete such project in a reasonable timeframe, hopefully more than disassembling and recreating the original code 1:1 in C++ ;)

Anyway, impressive speed of progress, only smooth tile edges left to make land look almost like the original.

You should be able to lift some code from "thinker" mod like AI, or map generation, hope you guys are in contact.

Please consider for v1.0 an option for simultaneous turns in multiplayer like in Freeciv, turn times close to singleplayer makes all sillyness involved worth it.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 01, 2023, 04:39:03 PM
I wonder if it's feasible for a single person to complete such project in a reasonable timeframe, hopefully more than disassembling and recreating the original code 1:1 in C++ ;)

Anyway, impressive speed of progress, only smooth tile edges left to make land look almost like the original.

You should be able to lift some code from "thinker" mod like AI, or map generation, hope you guys are in contact.

Please consider for v1.0 an option for simultaneous turns in multiplayer like in Freeciv, turn times close to singleplayer makes all sillyness involved worth it.
Simultaneous turns is something that was in original SMAC, so of course they will be implemented :)
About "thinker" mod - actually I'm hoping it's author can merge stuff from it to GLSMAC once it's more mature (and has all necessary APIs etc)  ::) :) But I can probably do it myself, it's just that I'll be busy with other things first.

Coastlines is still work in progress, getting close :)
Also check this out - :) All map is actually in 3D, and water is transparent and you can see texture and objects on it's bottom like rockyness, monoliths (youtube screwed quality a bit tho so it's not visible there).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 01, 2023, 06:23:54 PM
SMAC has simultaneous turns ? I didn't knew, lol, a way to reveal I've never played SMAC multi.

Do people here play over IP multi, or is it all PBEM ?
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 02, 2023, 01:45:30 AM
If I remember correctly - SMAC was the first 4x strategy that had simultaneous turns :)
Last time we managed to play by IP was in like 2015 (and had to use some specific VPN), after some point of time it just never worked again. Network protocol is very old and based on ancient DirectPlay (Windows 95 technology iirc).
One of reasons why I'm making GLSMAC is that multiplayer in original SMAC is just impossible now.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Sardaukar on February 02, 2023, 03:50:38 AM
3D map looking great.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 02, 2023, 10:53:03 PM
Improved coasts a bit (not final version yet)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Sardaukar on February 03, 2023, 09:10:01 PM
I like the vertical feel. Know it's not the original game but I have, for some time, yearned for an actual 3D globe with north-south icecaps that you can only cross by airpower.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 04, 2023, 12:06:33 AM
Globe idea is doable, just not before 1.0, need to do original SMAC first  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 06, 2023, 03:26:37 AM
Smoothed and normalized map - added removing of overly sharp slopes (sharper than 1km elevation per tile), now every tile is visible and clickable. Also fixed map zoomout and scrolling - it's not possible to drag it off screen anymore or zoomout further once it already fits whole in viewport. It's possible to zoomout map of any size to make it fit. Also implemented map saving and loading (no menus for it yet, just for debugging). And many bugfixes of course :)
Started working on UI, it will be responsive and adapt to (almost) any resolution, it can already be displayed in window as narrow as 640px, with some work it can fit in 300-400 pixels ( in case GLSMAC will be ported to smartphones  ;lol ). On wide resolutions empty area in the middle will be filled with information panels like charts, relative strengths, etc. 1920 will probably fit all panels at same time.
Next steps - adding horizontal infinite scrolling, then some more UI, then putting sprite-based units on map, then model-based units (CVR).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 07, 2023, 01:41:23 AM
Small map demo :)
Update: fixed that water glitch
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Sardaukar on February 07, 2023, 05:11:39 PM
Man, that's sweet.

Getting excited about this project.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 09, 2023, 04:39:56 PM
I'm really impressed by how quickly you're developing this!

I had another look at the voxel models today because I wanted to see if it would be practical to convert them to a better known voxel format. As far as I can tell, there isn't a well known voxel format that supports smooth rotations in their animations like Caviar (the format SMAC's models are in) does. There's the Vengi format, but it's not well known.

For conversions to a mesh format, glTF looks like an okay destination because it's an open format that supports the right kinds of animations and blender is able to import and export it (so it's good for modders and making new content).

One possible route for converting the existing models would be to add a loader for the Caviar format to the open source Vengi VoxConvert tool, then use their converter to generate glTF files. Another would be to write a direct caviar -> glTF conversion tool, possibly reusing some of the existing (separate) libraries for writing glTF and converting voxels to meshes.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 10, 2023, 03:23:02 AM
Thanks, doing what I can :)

About CVRs - for now the plan is to decode them and load as 3D textures (with different angles/positions) into OpenGL. If FPS will be bad (which I doubt) - then I'll try to optimize them and maybe convert them into polygons. They key thing is - they'll need to be converted in runtime without any intermediate files, because it won't be possible to ship modified or converted SMAC resources due to copyright reasons. That applies to all SMAC resources, for example images and sound upscaling, if it happens, will have to work in runtime (during loading of original SMAC assets). It's possible to save them to some cache on user's computer later for quicker loading.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 10, 2023, 11:42:33 AM
What do you mean by 3D textures? Maybe a texture with colour and a heoghtmap that you then render onto a plane (with the heoghtmap displacing the pixels off the plane for 3D)?

Are you open to contributions? I might be able to write some C++ for loading the CVRs at runtime or as something that occurs on first run.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 10, 2023, 12:13:41 PM
In OpenGL there's GL_TEXTURE_3D target and, I guess, corresponding shader processing. I haven't tried them yet but they exist.
It's always better to use things already implemented in OpenGL, they are much faster than improvising.

About contributions - generally yes, but I want to do CVR myself, because to load them one must also know how to store them internally and how to load into OpenGL, etc, it's all very interconnected. Generally I'd prefer coding core functions myself and accept contributions only for modules (something that is not hardwired to other parts and can coexist with alternatives), for example, mapgen, later maybe AI and custom mods. Something that user will be able to select in game settings from list of alternatives (i.e. which AI to use for faction, which mapgen to use, etc).
But if I'll get stuck with CVRs somewhere then I won't mind some help  :)
Also, generally it's better to not create any extra files, so that GLSMAC.exe could just sit in user's SMAC directory and be launchable as alternative to terranx.exe, and also to move easily between PCs. Caching something on disk only makes sense if initial processing makes loading way too long (for example if it's some AI-based upscaling of texture or video).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 11, 2023, 01:42:49 AM
I'd not heard of GL_TEXTURE_3D before, thanks for naming it, it's been interesting reading about different ways of rendering voxels and volumes on GPUs.

For anyone else interested, I found these two resources most helpful: https://developer.nvidia.com/gpugems/gpugems/part-vi-beyond-triangles/chapter-39-volume-rendering-techniques (for an intro) and these slides for more advanced techniques and much better visual references: https://cgl.ethz.ch/teaching/scivis_common/stuff/StuttgartCourse/VIS-Slides-06-Direct_Volume_Rendering.pdf

Sounds like a good policy for contributions. It's important to know what you want. Good luck!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 12, 2023, 04:24:31 AM
Added tile preview under map (also tiles are selectable with mouse now). Thinking of extending area towards bottom, to make sure all terraforming and other things fit and be readable. There's way too much space for units anyway on modern resolutions.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 12, 2023, 08:36:00 AM
As for map rendering, the surface geometry should be far more detailed, in the original tiles have smooth surface with tile borders connected with tangent, no sharp edges.

As for UI, with so much space to play with, there is a one easy and no brainer thing to add:
Clickable icons with commands from action and terraform menus, with keyboard shortcut displayed in the corner of the icons and unavailable actions faded out.
Not having essential actions hidden under two levels of list menus would make the game more accessible for new, young players that grew up playing modern civ games.
I'm sure that some forum member would eventually design you nice minimalistic SMAC style icons for unit actions, while simple squares with keyboard shortcuts in the corner would do until then.
I'd add them as two separate pannels for action and terraform menus on infopannel area and arrange icons in two rows within the pannels.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 12, 2023, 09:36:14 AM
Tiles in SMAC aren't very smooth, IMO. They're always formed of 4 triangles and you can often see the distortion in the texture if the heights of the corners are different enough.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 12, 2023, 10:08:09 AM
I think in the vanilla texture stretch happens only on the edge of the map and it's an issue with mapgen, that everywhere else avoids more than 1000m elevation difference, but it doesn't take into account that the edge of the map is treated as 0m elevation for rendering purpose. This vanilla issue could be either solved on mapgen level, or on rendering level by calculating the map edge elevation for rendering purpose based on neighbouring tiles elevation, but 0m elevation of the map edges assures bottom and top tile corners of the map edges being alligned in a straight line, so mapgen solution would look nicer.

But it's not what I was talking about at all. On the glsmac screenshots, the rendered surface of the tiles has just two triangles geometry, while in the original it has much more detailed geometry, where tiles borders are connected by tangent, not by angle, tops have convex surface, bottoms concave surface, etc. Yes, the square grid has simple geometry with straight lines connecting corners, but the rendered surface is smooth. Rendering smooth surface from a low resolution heightmap is something commonly done in games since early 90s, so it's not something autor would have to make himself probably, most likely there are free to use solutions available.

Hard to tell if it's the case in vanilla, but to potentially make it easier the smooth surface could be generated from the square grid corners and then the original square grid could be rendered on top of it, so the grid geometry wouldn't match precisely the visually rendered surface. Additionally sharp edges do exist on some landmarks geometry, like crater, or mesa, but I don't think they happen on geometry generated on regular tiles.

I understand it's only an eyecandy, but it'd be a shame if the map looked less nice in the remake, than in the original game.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 12, 2023, 12:37:45 PM
Yes I'll add smoothing between tiles soon (after minimap probably).
There are many things that can be done to improve the look and I'm aware of them, I just want to get to game play first without spending too much time on eyecandy. Don't worry, when it's finished - it will look much better than original :) Maybe even better than last civ games.

Clickable command icons - yes, definetely enough space for them. Maybe I'll find some icons in SMAC's PCX too. Also, I can just put icons with capital letters (first letter of action), maybe this will work too. I need to add units first tho.

Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 13, 2023, 12:11:39 AM
> Don't worry, when it's finished - it will look much better than original :)
Doubt many people would care much beyond getting it close to the original, gameplay first indeed.

> Maybe even better than last civ games.
What do you mean, it always looked better than any civ game ;)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 13, 2023, 05:23:05 AM
> Maybe even better than last civ games.
What do you mean, it always looked better than any civ game ;)
Oh, I meant graphical fidelity like resolution of textures, lighting complexity, some cool visual effects, etc. Not art style of course  ;lol

Ok so I added some blending to rainy tiles to make edges smoother, I think it looks slightly better now. Maybe I should decrease it a bit, I'll experiment a bit in coming days.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 13, 2023, 10:43:50 AM
Ok this will do for now :) Moving to minimap.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 13, 2023, 02:47:54 PM
Here are some examples showing some texture stretch in original SMAC and how each tile was drawn with 4 triangles: each tile has five vertices, it's corners and its center. You can see this most clearly in the second image below.

When you're zoomed out, I think these distortions make the game look better because the terrain appears more varied with fewer visibly repeating textures (last image, the two tiles pointed to by arrows use the same terrain sprite, but the large distortion on the one on the left means that they look visually distinct).

When the textures end up quite misaligned then it can look a little strange (first pic), but I don't know if it's worth doing anything about that.

For a remake, it might be neat to try some full colour textures with normal (bump) mapping and maybe roughness, but I think it would take quite a lot of work to make something that looks good and also fits in with the other graphics.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 13, 2023, 05:39:55 PM
 ;b; I see. I'll experiment with it after minimap, it's actually quite easy to stretch textures in OpenGL, center vertex can also be moved a bit in different directions if needed (should be done carefully though to not disrupt geometry too much).
Bump mapping is a bit more time consuming, so better postpone it.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 13, 2023, 07:10:43 PM
@DrazharLn It looks like you were right, there is four triangles geometry for each tile, but the shading makes it somehow look smooth and unnoticeable when zoomed out due to high resolution.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 14, 2023, 12:58:17 AM
Added random texture stretching and random center vertex offsets, it looks better but sometimes has these abrupt texture ends, I don't know if I have time to fix them now.
Looks like coastlines is the main thing holding everything back, I'll try to finish them this week.
About tile preview - you can see it's square topdown, it's experimental thing, there are some reasons why I think it will be better:
1) SMAC was designed for very tight resolutions like 800x600 so they made tile preview shorter to give space for unit list. At modern resolutions unit list is huge already, so there's no point. Also UI looks more symmetrical now.
2) In SMAC tile preview frame was too small and could not fit all lines if there was much terraforming on tile. Now it can fit everything (tile image will shrink as needed to fit all text lines below, it's only big when there's enough space). At same time, most tiles won't have many lines so keeping tile image small would create too much empty space, not looking good
3) At modern resolution default SMAC tile image size can be too small to look at. Also when I tried it it got too blurry (because it was topdown tile that was skewed by vertical axis, hence losing quality). Original top-down view displays tile at original scale, so it keeps all detail. It actually gives more visual information about tile than player may see on map (because there it's under ~45 degrees angle).
4) Currently there is no way to display actual 3D tile in UI, so the only way is taking topdown texture and warping it, it makes it look blurry and inaccurate (because it really is topdown). Also it makes it look like tile is flat, while in reality it isn't. Once 3D-inside-UI functionality is implemented (probably somewhere around base management UI time) I'll try orthographic 3D view of tile there, along with it's elevations, then maybe it will look good.

I tested different map sizes today, so far maps up to 200x120 tiles work already, maps up to 1000x1000 'almost work' (they are generated, shape works but terrain texture doesn't so it's just black screen where I can click and select tiles and they appear in preview with text lines), I'll need to split terrain texture into several and then 1000x1000 should be possible with maybe ~100 FPS. I got ~300 FPS at 640x480 map (it's like 16x larger than 'huge' in SMAC, or 32x?), FPS improves once you zoom in so if zoomout level will be limited then maybe even larger maps will be possible (next bottleneck will be available RAM).

p.s. Lore question - Alpha Centauri is triple star system, right? Won't it make sense to add 3 directional lights then instead of 1? It will also remove those weird straight lines appearing because of shadows, also I can make lights of slightly different color (and later maybe slowly rotate around map or even day-night cycle).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on February 14, 2023, 02:04:50 AM
It's closer to a binary w/ a distant companion - Proxima is small, and ISTR 1/3rd of a light year out.  Two lights would fit the lore...
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 14, 2023, 04:17:55 PM
I have a new theory on how the smooth map look is done in the original.

I think the shadowmap is blurred, so the sharp angles of geometry are not visible as steep differences in shading and it creates an illusion that geometry is smoother than it is.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on February 14, 2023, 05:26:39 PM
As a game-art artist, that scans for me...
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 14, 2023, 11:39:31 PM
Not that I think it matters to make the terrain look great right now, but here's a screenshot of what I think is some nice shading in SMAC. The shadows looks like they're quite diffuse, it also helps that SMAC is doing some climate modeling so the rainy areas are in consistent places, which is giving some nice visual variation in the same kind of places as the shadows.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 15, 2023, 12:44:15 AM
There are many things that can be done, but let's not forget that original SMAC was in development for 3 years (4 with expansion) by a team of people that also had experience in developing civilization and maybe also had some usable code and parts of engine when they started.
So I have no choice but to 'cut corners' sometimes. That means that I will only add visual improvements in two cases: 1) if it looks absolutely terrible without it (such as coastlines now, still not finished) 2) if it takes low effort to add them.
For now my goal is to quickly make all core functions so that others could join in development (including developing visual improvements).
So patience, please  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 15, 2023, 01:05:38 AM
Blurring the shadowing would probably fall under low effort.

But we hear you, it's just that you show us the map rendering, so we are commenting on the map rendering, nothing more to it, prioritize as you see fit.

Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 15, 2023, 01:23:45 AM
Sorry if I came across as nagging or demanding, I was having some fun trying to understand what I liked about SMAC's map appearance and maybe derailed things a bit!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 15, 2023, 02:46:44 AM
All good :)
Made some changes to lighting, maybe it looks a bit better, not sure.

Blurring shadows may be easy, yes, I'll research it tomorrow.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 15, 2023, 12:59:02 PM
I'll leave lighting like this for now.
I didn't find simple way to blur shadows, they are generated in shaders from interaction between lights and terrain geometry, each tile consists from just 5 vertexes ( center, left, top, right, bottom ) so can't be smoothed much physically. Adding more vertexes would be terrible for fps, so it's a no. Usually other techniques are used to smooth edges in 3D games (without actually modifying geometry), if somebody knows exact formula you can try modifying shaders here - https://github.com/afwbkbc/glsmac/blob/main/src/graphics/opengl/shader_program/Orthographic.cpp
Once terrain edges are smoothed - shadows from them will smooth too and that's the right way.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 15, 2023, 01:24:30 PM
Sure, it looks good enough already, move on if you want to.

I'll just add, that I've made a mistake, I've meant lightmap, not shadowmap. Prebaked lighting is faster than realtime and it possibly could be done in a way were you could get a single lightmap texture for the entire map geometry, then a blur filter could be applied to it, to smooth the shading and I imagine the result could look at least simillar to the original, if not outright being the same. I'm not a programmer, or 3D graphic artist, so I may be wrong, I'm just throwing an idea to consider somewhere down the line.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 15, 2023, 01:58:13 PM
> Prebaked lighting is faster than realtime
Yes, at some day I'll do that. My approach is to not apply any optimizations until they are needed, I determine that by checking FPS, for now it's around 3000-4000 FPS on fullscreen map which seems good enough  ;lol
For example, UI was rendered in realtime at first, then I noticed that it started lowering FPS a lot (depending on number of UI elements) so I made framebuffer and redraw only when something changes. Same will be done about lighting - as soon as I notice FPS drop I'll start doing optimizations.
Yes, with prebaked lighting it should be easier to blur too (in theory), good point. I'd like to put some sprite and voxel units on map first (and maybe cities), at least to be able to test it, for example if I do all lighting stuff now later it may turn out it's not compatible and needs to be reworked. Better to focus on lighting when everything else is already there.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 17, 2023, 02:02:25 AM
Ok, I managed to blur it now  8) And water looks smoother too. Ok, moving to coastlines for real  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on February 17, 2023, 02:18:06 AM
That almost-plaid pattern in the fugus is going to need some jiggering, of course.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 17, 2023, 02:58:26 AM
That looks pretty good!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 17, 2023, 12:02:23 PM
Improved fungus pattern a bit. Lines can still be seen but that's hard to eliminate completely (without cutting big part of texture off and stretching other one which loses quality too much)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 18, 2023, 12:52:32 AM
Worked on coastlines a bit (not final version yet)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 18, 2023, 03:12:46 AM
Nice start!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 19, 2023, 03:42:02 PM
Blur on shadows and water looks great, but I'd try to maybe make it a bit less intense for both, I feel like smaller bumps on terrain almost loose shadowing, I'd also make the coastline a bit less rugged, but if you disagree with any of these suggestions, then it's perfectly satisfactory to me as it is.

I'd like a graphic option, rather disabled by default, to use a simple nearest neighbour interpolation instead of texture filtering, for the original sharp grainy look. It may be a preference not shared by most, but I think these low res textures in old games are designed in a way that every pixel counts and hints at something, so these textures feel to me somehow less detailed and defined after filtering.

(https://i.postimg.cc/jdkFkbt5/Screenshot-2023-02-13-12-42-08.png)


Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 19, 2023, 07:04:37 PM
> but I'd try to maybe make it a bit less intense for both
Shadows are just consequence of terrain sharpness, if you compare land elevations then they look a lot more flat in SMAC. Also in SMAC water is generally less deep, except for few places. Current mapgen in GLSMAC is just quickly thrown together to test things, it's possible that mapgens won't generate that much mountains so problem won't be seen. Mapgens will play big role in how world is seen.
Other difference is that SMAC uses 55-60 degrees 'camera angle', in GLSMAC it's currently 45, but I'll change to SMAC-like if SMAC sprites won't look good at 45.
So many things will change with rendering still.

> I feel like smaller bumps on terrain almost loose shadowing
There will be bumpmapping later which will solve it

> I'd also make the coastline a bit less rugged
Yes I'm still playing with numbers trying to find optimal ratio.

> for the original sharp grainy look
There will be 'sharpening' post-processing filters later, amongst others (maybe even 256-color filter just in case). And there will be many settings once settings UI is done  :)

> but if you disagree with any of these suggestions
Actually I agree, it's just a matter of priorities :) For now I won't focus on graphics too much, need gameplay first. Coastlines are last time-consuming visual thing before I move to sprite and CVR units.
And yes, as I said - SMAC was in development 3-4 years so they had time to align every pixel perfectly :) I need to find balance to be able to make it playable within reasonable time.
There's also possibility of somebody joining project later and working on improving graphics here and there while I continue with main things.

And I think I almost finished with coastlines for now (just maybe need to draw small border at edge, but maybe it's already good as it is).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on February 19, 2023, 07:14:48 PM
It sure ain't bad at all, as-is.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 19, 2023, 09:43:33 PM
Added small border, I think this is it for now, maybe I'll get more ideas later. Maybe you have some ideas (that aren't too hard to implement) too.
Not 100% sure about how fungus looks - when it goes from land to water and vice versa it makes coastline less visible, maybe I'll draw thicker border there, in SMAC land fungus is always separate from sea fungus and couldn't traverse coastlines like that, but I like how it looks, it's also more realistic.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 19, 2023, 10:22:02 PM
Definitely looks solid enough even for a final release, you can safely move on to more important things.

Introducing at some point a thin beach outline would be nice, though. I like that the land and sea fungus is connected too, even if there will be a beach outline it shouldn't separate the fungus.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 19, 2023, 10:54:59 PM
Added some beach
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: dino on February 19, 2023, 11:25:33 PM
Awesome, it isn't even noticeable it separates the fungus, but it makes the change from blue to pink less abrupt and easier on the eye.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Sardaukar on February 23, 2023, 08:55:54 PM
Coastlines getting nice and jagged.  ;b;
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 25, 2023, 02:56:23 AM
Working on rivers, not final version yet (need to erase beaches on river exits and improve river generation algorithm).
Did some improvement to terrain textures too, but mainly focused on map controls and there wasn't much to screenshot about them (but I'll make video after finishing rivers and resource bonuses).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 27, 2023, 01:53:02 AM
 8)
(not final version of resources probably)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on February 27, 2023, 02:54:51 AM
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on February 27, 2023, 04:29:11 AM
Looks really good! I'm still super impressed by your productivity!

If you're interested in map generation code, Thinker has a bunch already written in C++ and open sourced.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 03, 2023, 09:24:44 PM
Working on minimap for now, took some kungfu inside engine to make it 'screenshot' world into texture, but now it's done and can be reused for base UI and maybe something else later.
This is first version, a bit blurry and without extra details. Open to suggestions  ::) For now I'll be fixing bugs and moving to adding frame and map controls to it, later it will have extra overlays (toggleable by player) such as elevations, faction territories, ecology, etc. I'll see if there's easy way to sharpen it.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 03, 2023, 09:27:39 PM
Some full screens with minimap.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 04, 2023, 11:32:35 AM
Hmm I just found out SMAC had this strange alternative minimap mode. It kinda 'zooms in' and you can scroll in minimap window same as in main viewport.
Is it useful for something? If not maybe it's better to replace these two buttons with map overlay buttons (where user can switch to see elevations, territories, ecology, maybe terraforming or something else, or return to default 'satellite' map).
Please tell me if you are/were using this alternative minimap mode actively, and for what purpose.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 04, 2023, 12:03:20 PM
I don't use it and I think using the space for more buttons makes sense. The most used overlay in PRACX is the one that shows the resource yield of tiles (current yield or best yield with terraforming).
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: pblur on March 04, 2023, 12:54:14 PM
I've used it on occasion to look at unit dispositions in a diplo screen. Not THAT useful.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 04, 2023, 05:41:21 PM
Added some stuff, looks a bit less blurry when aspect ratio matches that of map. Now just need screen frame.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on March 04, 2023, 05:55:36 PM
Do you need something made for a frame or can you patch something together?
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 04, 2023, 05:58:58 PM
Nah, it's just white lines basically  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Buster's Uncle on March 04, 2023, 06:07:14 PM
Okydoke.

-But if you need graphics fiddled some way, I'm your huckleberry - provided you catch me in the mood, and possibly even not...
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 09, 2023, 02:49:28 AM
Minimap done (for now)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 14, 2023, 11:57:39 PM
Last week I've been doing a lot of bugfixing and optimizations (improved FPS by 30-50% by removing all unneeded redraws/resizes/realigns/etc), then focused more on UI and middle section of bottombar.
This scrollbar also took a while - :)
But it's high quality and can be used for other UI later on. Most time still went to fixing/improving UI code to allow it and not scrollbar itself.
Now I'll add some empty info panels and then move to map editor, I decided that it must be finished before v0.2 because it's important part of map. Map editor will be last big thing before v0.2, I'll try to make it look and work in same way as in SMAC. Then also saving/loading of maps but it's already implemented, just need to add menus. Ok, maybe also landmarks :) but they are easy too.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: mrStoun on March 15, 2023, 11:04:20 AM
Looks very cool! When is a playable version planned?
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 15, 2023, 05:33:25 PM
First playable - I think a month or two from now. Yes yes I already gave this estimate before  ;lol sometimes things go a bit slower than planned, but I don't want to sacrifice quality and release some buggy laggy mess (that would need to be fixed later anyway).
You can also check the most up-to-date info on development progress here https://github.com/afwbkbc/glsmac/commits/main . Next big milestone is map editor and small things like adding menus, saving/loading game, etc. After that I'll move to multiplayer, then units, and then - big obstacle - CVRs. Once(if) it's done then next step is turn processing and that's where gameplay comes in.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 19, 2023, 12:39:09 AM
Map editor UI done, one difference from SMAC is 'Cover Map' button replaced by 'Moisture' button which seems much more useful, especially for testing. Yes in SMAC there's weather algorithm and it will be implemented too at some point, but ability to edit moisture directly gives more control over map. Also, removing map cover (fog of war) selectively belongs to scenario, not map, and later there will be separate scenario editor anyway. 'Moisture' icon is loaded from same interface.pcx as all other icons, it seems to be unfinished and unused in original SMAC. Later I'll add some workaround to draw lines in it more bold way, then it won't differ from others that much.
Slightly renamed brush names to make more sense.
Texts will be multicolored and look like in SMAC later, tooltips on hover later too, now moving to actual map editing logic.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 19, 2023, 10:53:42 PM
Elevations editor, first version 8)
 
( it will be optimized better, dw )
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 20, 2023, 04:09:44 AM
Amazing progress!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 21, 2023, 01:08:02 AM
FPS improvements :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 21, 2023, 11:16:16 PM
Added SMAC brushes, more will come in future (i.e. round ones), maybe also 'intensity' or 'speed' sliders, variable brush size slider, etc.
 It's a bit laggy with 9x9 brush, but that's 81 tiles to update and reload on every iteration (and there are like 10-15 per second). Once map loading/reloading will be multithreaded it may become 5x-7x faster so lags won't be noticeable anymore. Smaller brushes are already fast.
Now I just need to add other tools (elevations was the hardest btw) and minimap update, and map editor kinda done.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 23, 2023, 12:35:09 AM
Added other stuff and terraforming (except for roads/magtubes). I'll resize/align them better a bit later.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 24, 2023, 10:30:09 PM
Nice!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 27, 2023, 03:00:17 AM
Added some menus and file browser UI - 8)
Took a while (UI is always time-consuming when element needs to be done for first time), but I like how it looks/feels. v0.2 is very close now, all functionality is there, just need to do some optimizations and map saving/loading, so just a couple more days :)

Update: more cool features
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 28, 2023, 09:35:36 PM
Map saving / loading done
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 28, 2023, 11:17:38 PM
Congrats! Good luck with the weather algorithm and getting sprites up :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 29, 2023, 01:23:35 AM
You probably meant CVRs, because sprites are already there (bonus resources and some terraforming are sprites)  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 29, 2023, 12:40:26 PM
I had just forgotten about the terrain improvements because I was thinking about the sprites for bases and native life :D

As you've made a start on saving bits of game state, here are some of my personal pain points with SMAC's existing saves:

- settings and mods are not always saved with the rest of the game state, which makes it a pain to play saves using different mods
- saves are not rewindable, which can make debugging and development a pain. Saving info for rewinding would also allow some fun replay options when the game ends (or maybe you can trigger a replay of the last few turns as a recap, idk)

Here's a demo of Tomorrow Corporation's Dev tools:
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 29, 2023, 12:58:13 PM
Replays are planned after v1.0, they will be separate from saves, which makes sense because somebody may want only saves but not replays, and other will want to record replay but not make saves every turn.
There will be a big difference in savegame format and replay format.
Savegame will contain full state.
Replay will contain initial map state on turn 1, and then every turn it will add all changes and actions by players and AIs.
Each is better for own use cases (replays are better optimized for every-turn updates but would be ridiculously slow to load from, savegames are better optimized for loading but making full savegame file every turn would be slower and waste of disk space).
Maybe replays will also record things like mouse movements and timings of actions, to be able to replay precisely later (exactly as player played it).

About "settings and mods are not always saved with the rest of the game state, which makes it a pain to play saves using different mods" - if it was a bug in SMAC then of course it won't be carried over  :)

Checked video, I think it will be overkill - implementing 'rewind' will take much more time than it will save later. For debugging a normal save is enough, and it will be possible to enable 'autosave each turn' and that's it. In debug builds it's also possible to save or load a full dump. So, if, as in video, I had null pointer somewhere, I can just put breakpoints where needed, then load save (or dump) of previous turn and get same result.
Also, debug build is already slow, adding rewind will make it even slower and memory-hungry (because it will also record history of everything).
Interesting approach tho.

Replays will have this rewind functionality, but they'll come after v1.0. Idk if it will be possible to rewind after actual exception or crash tho, maybe, if I'll find easy way to do it. Time spent on debugging tools should not exceed amount of time saved by them  :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 29, 2023, 02:30:01 PM
> About "settings and mods are not always saved with the rest of the game state, which makes it a pain to play saves using different mods" - if it was a bug in SMAC then of course it won't be carried over  :)

It's more a questionable design decision than a bug (tho there was also a bug but thinker fixes it). Scenarios embed the alphax.txt (and maybe some other files?) that are active at the time they're created. AFAIK, normal saves don't.

And then SMACX doesn't have a notion of mods really beyond that. You just have to overwrite the base files.

Re: rewinding/replay, I think an event log with occasional checkpoints would be an okay format (which seems to be how the tomorrow corporation version works) and would be handy for dev and modding, but I'm not the one writing it!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 30, 2023, 12:25:19 AM
Did some sprite optimizations today, then tried to kill FPS with terraforming  ;lol

Average PC - ~200000 sprites, ~75 FPS
Low-end VM - ~65000 sprites, ~59 FPS
There are more possible optimizations (such as lazy rendering) but for now it looks fast enough  8)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 30, 2023, 09:08:35 AM
Nice. I think a good performance test is whether it makes an old laptop noisy (from the fans spinning up). Unmodded SMAC does because it polls windows for events in a busy loop rather than waiting politely, tho this is fixed in thinker and by the smac-cpu-fix mod.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 30, 2023, 09:28:22 AM
How old is 'old laptop'? I sometimes test it on ASUS Zenbook UX302LG, I think it's from 2014 so 9 years old. GLSMAC uses around 15% of one CPU core when idle, on average standard map with some terraforming, I can hear fans but not much (they are louder if I compile something or watch youtube or just browsing, there's probably some dust requires cleaning too).
Supporting really old computers by specific optimizations is possible, but time-consuming, so it will be postponed, for now I'm targeting my zenbook (with integrated GPU and not NVidia) as lowest supported hardware specs. That, and virtual machine with 3GB of RAM, 2 cores of AMD A8 7600 and NVidia GT710 (it runs it on par with my laptop usually).
Later it should be possible to support even retro computers from 90s, as long as they have OpenGL 3  card.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 31, 2023, 03:51:35 PM
Added proper handling of map settings: ocean coverage, erosive forces, native lifeforms, cloud cover. Map generator is still basic but generates map with requested settings accurately.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 31, 2023, 06:30:22 PM
Sounds old enough to me! Good job with the map generator :)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 31, 2023, 08:29:52 PM
Just had issue where moons in main menu overlapped 'Sid' word, then it turned out they screwed SMACX background so it happens in original SMACX too.
However, this doesn't happen with original logo.
Then I also gave it some thought - and it really makes sense to put logo with name of actual game (Alpha Centauri) than of expansion, right? For example we don't want to confuse new players to think the game is called 'Alien Crossfire'.
Original logo also looks good with moons.
Are there any reasons to use Alien Crossfire text in main menu? For now I think - why not use original 'Alpha Centauri' logo but with Alien Crossfire theme. Also, logo color itself may be changed by opengl into something other than blue. Colors of menus and UI can be modified too. What do you think?
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 31, 2023, 08:58:39 PM
As a SMACX disparager, I don't see any need to implement any of SMACX ;)
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 31, 2023, 09:04:44 PM
Later there can be some easy selection/option added when starting game.
Can I find a full list of differences between SMAC and SMACX somewhere? Just to get the idea of how hard would it be to implement in universal way (if differences are only content like units and technologies - then fairly easy).
I actually played SMACX like 99% of time, barely remember how it was before expansion.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on March 31, 2023, 10:06:40 PM
Added planet/moon effects as in SMAC
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on March 31, 2023, 10:11:07 PM
You can read about the changes here: https://github.com/DrazharLn/smac-in-smax

 Most of the changes are content rather than mechanical, might be a nice test case for mod/plugin support, idk.
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on April 03, 2023, 12:46:04 AM
v0.2 is out  8)

Changelog: https://github.com/afwbkbc/glsmac/blob/main/CHANGELOG.md#v02---2023-04-03

And small demo
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: DrazharLn on April 03, 2023, 09:23:24 AM
Congratulations 🎉🎉 You've made really fast progress and the output quality seems really high!
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: Secundus on April 03, 2023, 03:30:38 PM
Indeed, amazing progress afwbkbc ;b;
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: aphellyon on April 07, 2023, 12:22:05 AM
This looks quite promising and I'm looking forward to playing this version when it's done.  Please keep up the good work and know that your efforts are appreciated.    :);b;
Title: Re: GLSMAC - Open-source OpenGL/SDL2 remaster of SMAC
Post by: afwbkbc on April 10, 2023, 12:42:44 PM
Doing some serious refactoring rn, so not much to show.
Big leap forward was moving map processing to separate thread, so it doesn't freeze UI anymore and proper loaders can be added . It was also needed for networking.
Also small heads up - I got new job starting from tomorrow so I'll focus on it to make good performance, I'll still work on GLSMAC every day, just not 24/7 as usually ;lol Except for weekends.
Also I'll configure automatic builds for linux, freebsd, windows and (maybe)macos soon so non-programmers will be able to download and test it too  :)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 33 - 892KB. (show)
Queries used: 19.

[Show Queries]