In development: Water with depth

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
jfs
Tycoon
Tycoon
Posts: 1760
Joined: 08 Jan 2003 23:09
Location: Denmark

In development: Water with depth

Post by jfs »

I'm currently experimenting with a patch that adds depth to water. PR#7924 on GitHub.

Water with depth adds lots of possibilities, mainly in three categories: Construction costs, construction restrictions, and ship movement.

The first thing I did was make a simple construction restriction, only allowing ship depots to be built at shallow depths, which typically means near the shore. That's pretty much just a proof of concept, I don't know if that's interesting at all, maybe it's not worth the effort to have in.

Next was making the cost of clearing water tiles depend on depth, squared. Depth is a 4 bit value ranging from 0 to 15, with 0 being "shallow" and 15 something like 300 m deep or more. By multiplying the cost of demolishing water by the square of depth, clearing the deepest water is 225x more expensive. On the "low" construction costs setting, that means a little over £7200 for clearing water near the shore, but almost £1.7 million for clearing deep ocean.
This makes large bodies of water much less attractive to fill in and build land bridges across, even making a few small artificial islands for bridges can cost many millions. Long bridge segments, taking the long way around, or transferring to ships can become the more attractive options with this.

More possibilities include letting NewGRF industries query water depth, so some industries can require certain depths to be built.

Right now there is some logic in the water tile loop to make water depth adjust over time, forming an even gradient out from the coast. I'd rather not have that, since it will also smooth out any intentional depth choices made by map authors. If anything, it should take decades or centuries for meaningful changes to happen. Right now it's mostly there to cause depth to happen at all, since there aren't any scenario editor tools to change it.

Help wanted
  • Drawing: New water tile sprites representing different depth levels would be a great help for players to make choices.
    I would really appreciate if someone can paint new water tile variations that somehow show that the water is deeper or shallower.
  • Code: Terrain generators need to be reworked to account for depth and generate interesting water bodies.
    In particular, they should be able to make shallow lakes, deep lakes, shelves of shallow areas near coast, sudden drops into much deeper ocean, and possibly do more interesting things with rivers.
Diesel Power
Traffic Manager
Traffic Manager
Posts: 222
Joined: 18 Jun 2016 19:05

Re: In development: Water with depth

Post by Diesel Power »

Great idea! The water depth will also make bridge building more restrictive and expensive. Bridge pylons in deep water could be more expensive. The ship pathfinder could also query water depth. Adding a minimum and maximum water depth for each size of ship. Big tankers in GRFs like Redfish could only use deep water and barges could only use rivers and have a Max depth.
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1354
Joined: 15 Feb 2003 17:32
Location: Vergezac, France

Re: In development: Water with depth

Post by MagicBuzz »

Sounds good :)

How do you manage depth ?

Is there a flag property on the water tile ?
Or do you manage underwater relief ?

First approach sounds much simple to manage, but does actually give only functionality to water tile itself : no eyecandy, and no advanced function like "realistic" tunnel under water or even Archimedes bridges. https://en.wikipedia.org/wiki/Submerged_floating_tunnel
Second approach sounds pretty harder to manage, but actually should need less landscape generator rework ("just" generate the map like now with higher depth, then mark the first x levels under water). For graphics, it's also quite simple : just change the grass to blue tiles, rocks by... blue rocks, and bush by seaweed. The only "big" matter is to represent easily the depth... should be quite boring to produce X different blues according to the depth. At last, for terraforming, the player would take account of the whole situation like when building in mountains to keep lower building prices.
User avatar
jfs
Tycoon
Tycoon
Posts: 1760
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: In development: Water with depth

Post by jfs »

The depth is just stored as separate value on the tile. There are plenty of free bits on water tiles in the map arrays, so I could even have taken 8 bits instead of 4, but I don't think any more than that would really add any interesting gameplay.

Because the water depth is separate from the tile height, this also means that rivers and lakes can have a depth. Even canals can have depth, and it might also be interesting to let players build deeper canals, at a higher cost.

I don't think adding an actual underwater view would be worth the trouble, but you're right that an underwater tunnel feature could definitely also take depths into account.
In fact, tunnels through mountains with deep lakes/rivers on them should maybe also take it into account.
In my opinion, depth of water tiles should not be something that changes a whole lot during regular play, so having only different tile graphics variations as hint to depth should be fine. (You can still get the actual value with the land query tool.) For scenario editor, the depth should be editable, and I think perhaps just a numeric overlay on the water tiles would be sufficient.
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1354
Joined: 15 Feb 2003 17:32
Location: Vergezac, France

Re: In development: Water with depth

Post by MagicBuzz »

About depth in lakes and channel, it would be very nice to include the possibility to build docks on lakes or channels.
Currently we can't use channels to give access to inner cities or industries to sea as we can't build docks...

This makes the rivers pretty useless as we can't use them with boats.

Actually we can find ports at several hundreds kilometers from sea :
Exemple : Port de Lyon (France)
http://www.portdelyon.fr/
https://www.google.com/maps/place/Port+ ... d4.8352827
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: In development: Water with depth

Post by wallyweb »

jfs wrote: 12 Jan 2020 00:31 Drawing: New water tile sprites representing different depth levels would be a great help for players to make choices.
I would really appreciate if someone can paint new water tile variations that somehow show that the water is deeper or shallower.
What about the water cycle colours? Can they be manipulated somehow to reflect depth?
WaterCycle.png
WaterCycle.png (1.18 KiB) Viewed 5671 times
On another note ... OpenTTD differentiates between sea water (ogfx1_base) and river water (ogfxe_extra), although they both use the same water cycle colours.That's a lot of new tiles to be added to where :?:

On yet one more note ... There are no diagonal river tiles. Would this be an opportunity to add them in? (Also diagonal canal tiles?)
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: In development: Water with depth

Post by Zephyris »

wallyweb wrote: 12 Jan 2020 10:43 What about the water cycle colours? Can they be manipulated somehow to reflect depth?
No, sadly not. I'd say the best option would be just to use a dithered overlay. Assuming that depth will be modified by the normal raise/lower tools then you'd need a full slope set for underwater really... Perhaps a sea floor set of terrain sprites which are dithered on top of the normal water or only visible in an underwater transparency mode?
User avatar
jfs
Tycoon
Tycoon
Posts: 1760
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: In development: Water with depth

Post by jfs »

Yes full underwater terrain is a very bad can of worms, I don't want to do that. I want the depth to stay semi-abstract, and also not be limited to smooth gradients. The water depth should allow steep cliffs.
That's why I also imagine the depth only being represented by about 3 variations in water tile colour: Shallow, medium, and deep.
User avatar
kamnet
Moderator
Moderator
Posts: 8584
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: In development: Water with depth

Post by kamnet »

MagicBuzz wrote: 12 Jan 2020 10:29 About depth in lakes and channel, it would be very nice to include the possibility to build docks on lakes or channels.
Currently we can't use channels to give access to inner cities or industries to sea as we can't build docks...
You can, you just have to build up a bank for the dock to build on. Which leads to my biggest peeve, rivers should be be built in a channel in order to provide river banks for docks to be built.

The other issue is that water-based industries cannot build on rivers because they require sea water. If we had rivers with proper banks then we could put them on rivers.
wallyweb wrote: 12 Jan 2020 10:43 On yet one more note ... There are no diagonal river tiles. Would this be an opportunity to add them in? (Also diagonal canal tiles?)
This would be good. :)
User avatar
jfs
Tycoon
Tycoon
Posts: 1760
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: In development: Water with depth

Post by jfs »

Yeah, someone did talk about making halftile river tiles in IRC yesterday. I think Andy and Eddi. It would definitely help in making rivers look less weird.

I just did some experimenting with having TerraGenesis also produce depth in the water, as opposed to just automatic smooth gradients that original generator and heightmaps get. Ideally heightmaps should also have a way to specify water depth.
I've attached a screenshot showing a TerraGenesis map with water depths shown as numbers, just for debugging purposes. The interesting part is how the bay has a large flat-ish area before it falls into a deeper trench. There are also some non-smooth gradients.
Attachments
openttd_2020-01-12_16-20-05.jpg
(1.17 MiB) Not downloaded yet
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: In development: Water with depth

Post by wallyweb »

jfs wrote: 12 Jan 2020 15:32 Yeah, someone did talk about making halftile river tiles in IRC yesterday. I think Andy and Eddi. It would definitely help in making rivers look less weird.
I wonder if much of the code already exists with sea coasts, only awaiting somebody to copy/port it to rivers ...

I may have a solution to those depth related water tile graphics ... work is in progress ... announcement later today if the graphics works as intended.
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: In development: Water with depth

Post by wallyweb »

wallyweb wrote: 12 Jan 2020 16:38I may have a solution to those depth related water tile graphics ... work is in progress ... announcement later today if the graphics works as intended.
A day late, but it seems to work ...
It's just objects, but the tar contains the screenshot, a scenario, the grf, nfo code, and a spritesheet.
Water Cycle for Depth.png
Water Cycle for Depth.png (94.6 KiB) Viewed 1541 times
The secret sauce is the wave portion of the water cycle. It can be drawn with different densities of wave action.
Enjoy.
Attachments
Wave Cycle for Depth.tar
(131 KiB) Downloaded 105 times
User avatar
jfs
Tycoon
Tycoon
Posts: 1760
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: In development: Water with depth

Post by jfs »

Sorry, I can barely tell any difference between the three shallow/medium/deep sprites. Is it at all possible to mix some other colours in between the palette cycled ones to get slightly more green-ish or dark-feeling tiles?
But I'll see if I can add a NewGRF feature for water tiles, or maybe rather extend the existing feature for rivers and canals, so the sprites can get in the game properly.
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: In development: Water with depth

Post by wallyweb »

jfs wrote: 13 Jan 2020 20:36 Sorry, I can barely tell any difference between the three shallow/medium/deep sprites. Is it at all possible to mix some other colours in between the palette cycled ones to get slightly more green-ish or dark-feeling tiles?
But I'll see if I can add a NewGRF feature for water tiles, or maybe rather extend the existing feature for rivers and canals, so the sprites can get in the game properly.
The colours are set within the game code. As noted above, I can get a better variation of the wave densities. The Deep sprite is about as dense as I dare. The Normal is what we have in the current game. I can play with the density between Normal and Deep.
Wait a minute! Yes! I can add some green pixels. They won't be active, but the dithering should give some interesting shades of blue/green. Give me a day or two to work on it.
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: In development: Water with depth

Post by Andrew350 »

Adding in different colors will be difficult for OpenGFX, since the whole sprite is one rolling wave effect with the water cycle. It would likely need to be redone entirely to make this work cleanly, but will need some experimenting to find out. :) It would be a lot easier if we could use a 32bpp overlay to simply darken the wave cycle colors...but that probably isn't something we want for the 8bpp base sets I'm guessing?
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1354
Joined: 15 Feb 2003 17:32
Location: Vergezac, France

Re: In development: Water with depth

Post by MagicBuzz »

kamnet wrote: 12 Jan 2020 14:25 You can, you just have to build up a bank for the dock to build on. Which leads to my biggest peeve, rivers should be be built in a channel in order to provide river banks for docks to be built.
Bank ? Like the industry that produces valuables ? ?(
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: In development: Water with depth

Post by planetmaker »

MagicBuzz wrote: 14 Jan 2020 13:34
kamnet wrote: 12 Jan 2020 14:25 You can, you just have to build up a bank for the dock to build on. Which leads to my biggest peeve, rivers should be be built in a channel in order to provide river banks for docks to be built.
Bank ? Like the industry that produces valuables ? ?(
https://en.wikipedia.org/wiki/Bank_(geography)
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: In development: Water with depth

Post by wallyweb »

Andrew350 wrote: 14 Jan 2020 13:26 Adding in different colors will be difficult for OpenGFX, since the whole sprite is one rolling wave effect with the water cycle. It would likely need to be redone entirely to make this work cleanly, but will need some experimenting to find out. :) It would be a lot easier if we could use a 32bpp overlay to simply darken the wave cycle colors...but that probably isn't something we want for the 8bpp base sets I'm guessing?
Overlay might be difficult. The wave action and the action colours are embedded deep withing the OTTD code. All OpenGFX does is provide the sprites, and yes, it needs 8bpp or old sets break. The experiment continues ...
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: In development: Water with depth

Post by Andrew350 »

wallyweb wrote: 14 Jan 2020 13:47 Overlay might be difficult. The wave action and the action colours are embedded deep withing the OTTD code. All OpenGFX does is provide the sprites, and yes, it needs 8bpp or old sets break. The experiment continues ...
Overlay was perhaps a bad choice of word, I really just meant "do it in 32bpp". i.e. make the sprites darker in 32bpp color depth so when applying the water cycle colors as a mask they will be slightly darker but otherwise look the same. Basically the same way I did with NightGFX (but obviously not with the same amount of darkness :P)

It would be trivial to do this way, but obviously it requires going 32bpp for these particular sprites, which may not be desired in the "base" base sets, if that makes sense.
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1354
Joined: 15 Feb 2003 17:32
Location: Vergezac, France

Re: In development: Water with depth

Post by MagicBuzz »

Hmpf ! 8o

Oh My God ! :shock:

It works ! :bow:

If you're looking for me, I'm already outside
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 17 guests