Freeciv-Web WebGL/Three.js prototype

Web version of freeciv. Please mention the site you're using, if speaking things other than general freeciv-web codebase.
louis94
Hardened
Posts: 270
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Freeciv-Web WebGL/Three.js prototype

Post by louis94 »

Hello,

Do you think it's worth building a city on this volcano ?
Spectacle.X29285.png
Still missing trees, though…
AndreasR wrote:How much memory do you have? You can modify the amount of memory allocated to the virtual machine by changing v.memory in the Vagrantfile file. If you get swapping, then reduce it. There is a script called build-js.sh which builds the JavaScript only, and is quite fast.
7.26 Go available to the kernel. I reduced the VM's memory from 6 Go to 2 Go, and it's far better. build-js.sh even takes advantage of multiple CPU cores :)

Louis
louis94
Hardened
Posts: 270
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Freeciv-Web WebGL/Three.js prototype

Post by louis94 »

I found the rendering is broken on my tablet (badly on FF, passable on Chrome). I think it's because it uses too many TUs, but I'm not 100% sure.
In the meantime I got this working (patch to come one day or the other):
Spectacle.ab1173.png
Spectacle.ab1173.png (85.43 KiB) Viewed 14792 times
Louis
AndreasR
Elite
Posts: 754
Joined: Thu May 02, 2013 10:26 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by AndreasR »

The updated terrain rendering and trees you created are great. I have given you commit access to the Freeciv-web repository so you can commit directly. Feel free to do whatever you want to improve the WebGL support. Update and commit frequently to avoid merge conflicts. I have added basic support for preloading the textures and models today.

One important thing to figure out is how to update the terrain map as the game goes on. Initially all the map tiles are unknown and hidden, and the map tiles is updated as the game progresses. So we might need to update the map and terrain incrementally as the player explores the map. At the moment the full terrain is only updated on game-start and not updated later. The creation of the map terrain takes 3 seconds on my system.
Or we could decide that updating the map terrain is too complex/slow to do incrementally, and just "cheat" and reveal the whole map to the browser, and only create the map terrain model once on game start. What do you think?

What kind of tablet do you have? It works on my Android mobile phone.
vasc
Posts: 2
Joined: Sat Nov 12, 2016 10:52 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by vasc »

IIRC the map generator on the server uses a heightmap as a baseline to generate the map. If you could use those values to compute terrain height values, instead of deriving them from the simplified terrain, perhaps it would look smoother?
vasc
Posts: 2
Joined: Sat Nov 12, 2016 10:52 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by vasc »

As for 3D units there were also these 3D units someone made in Blender several years ago:
http://download.gna.org/freeciv/contrib ... animation/
louis94
Hardened
Posts: 270
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Freeciv-Web WebGL/Three.js prototype

Post by louis94 »

AndreasR wrote:One important thing to figure out is how to update the terrain map as the game goes on. […] What do you think?
I haven't tried yet, but I think incremental updates can be done. The only non-local (thus harder to update) parameter is the map height, which is currently computed using a really inefficient recursive function. Maybe it can be made faster by using a loop instead, but incremental updates will be faster. We'll need to measure, but I'd prefer not to cheat.
I'm more afraid of scalability with big maps (think Europe); I think we'll need to break them down into chunks of a few thousand tiles.
AndreasR wrote: What kind of tablet do you have? It works on my Android mobile phone.
It's an Intel Atom Z3560-based Android system with 2GB RAM and a PowerVR Rogue G6430 GPU. I'll investigate the problem further.
vasc wrote:IIRC the map generator on the server uses a heightmap as a baseline to generate the map. If you could use those values to compute terrain height values, instead of deriving them from the simplified terrain, perhaps it would look smoother?
There are several map generators, all of them working differently. And user-made scenarii/maps don't have height information. Actually the map can be made much smoother just by tweaking a few numbers; high mountains is a desired effect.

Louis
AndreasR
Elite
Posts: 754
Joined: Thu May 02, 2013 10:26 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by AndreasR »

The latest version of the WebGL renderer has been pushed to production now, which updates such as better mountains, tundra and swamps. I'm currently working on rendering units and cites. Louis, perhaps you have some ideas for things to improve?
louis94
Hardened
Posts: 270
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Freeciv-Web WebGL/Three.js prototype

Post by louis94 »

Hi Andreas,
AndreasR wrote:Louis, perhaps you have some ideas for things to improve?
Here is a list of what I know needs improvements. I'll try to find some time this week-end to work on this.
  • The map will be invisible if there is no (known) sea tile, because then the heightmap is first initialized at 10000 and never touched again.
  • The height-based rock shader will appear on some regular tiles far from the sea.
  • (Related to the previous) We really want to know the terrain on a per-triangle basis. I'm unsure whether we should draw everything at once or do one draw call per terrain type (would allow using different shaders instead of conditionals).
  • (Related to the previous) Blending on the tiles' edges. We'll need to know the neighbor tile's terrain too!
  • (Related to the previous) Tile corners might sometimes be given to other tiles (to solve the V-shaped mountains corners)
  • Trees next mountains aren't rendered very well. They also need more diversity (using very simple models instead of mere spheres?).
  • (Related to the previous) We'll need functions to compute the elevation and normal vector at a given (x,y).
  • I'd like to swap the GL y and z coordinates.
  • Fog and darkness!
Louis
AndreasR
Elite
Posts: 754
Joined: Thu May 02, 2013 10:26 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by AndreasR »

Cool, those are all great improvements. I'm focusing on units and cities.
AndreasR
Elite
Posts: 754
Joined: Thu May 02, 2013 10:26 pm

Re: Freeciv-Web WebGL/Three.js prototype

Post by AndreasR »

I have added some initial support for rendering cities, units and flags. The production server has also been updated with the new WebGL version.

Image
Post Reply