Page 2 of 6

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 4:11 am
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

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 5:08 pm
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 14816 times
Louis

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 7:35 pm
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.

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 10:54 pm
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?

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 11:02 pm
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/

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sat Nov 12, 2016 11:45 pm
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

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Wed Nov 16, 2016 7:46 pm
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?

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Thu Nov 17, 2016 10:04 am
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

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Thu Nov 17, 2016 8:13 pm
by AndreasR
Cool, those are all great improvements. I'm focusing on units and cities.

Re: Freeciv-Web WebGL/Three.js prototype

Posted: Sun Nov 20, 2016 1:40 pm
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