Page 2 of 4

Re: Water Tunnels

Posted: 26 Jan 2010 14:19
by Orko
Hi,
After reading this i had to register and get something of my chest.

I drove once throu one of those channal tunnels and its an amazing mysterius experience. Going int that black hole and echoing your machine from the walls. That was a tunnel of the Rhine rone channel.
A quite big one at it too.

also here a list with other channel tunnels http://en.structurae.de/structures/ftyp ... fm?ID=2099

Re: Water Tunnels

Posted: 06 Jan 2013 15:13
by Hyronymus
How feasible are canal tunnels nowadays?

Re: Water Tunnels

Posted: 06 Jan 2013 15:34
by Eddi
there is no technical reason that prevents water tunnels, but the graphics will glitch horribly, because ships are just too big.

Re: Water Tunnels

Posted: 06 Jan 2013 15:40
by Hyronymus
Eddi wrote:there is no technical reason that prevents water tunnels, but the graphics will glitch horribly, because ships are just too big.
With the release of FISH I wonder and it is up to players to decide which ships to send through a tunnel in the end.

Re: Water Tunnels

Posted: 06 Jan 2013 15:50
by Redirect Left
Orko wrote: I drove once throu one of those channal tunnels http://en.structurae.de/structures/ftyp ... fm?ID=2099
I've been on a tour through one of the ones near me It really is a very weird, almost surreal experience being on a tunnel in a boat. Nothing but the echoes of your engine, and the pitch black around you. Would be great if this was ever put into OpenTTD, and definately a feature i'd use. The possible clipping, well i've got used to it. Sadly the devs say its impossible to fix, at least not without rewriting everything or something. But, I wouldn't put off making such a feature based upon a bit of clipping.

Re: Water Tunnels

Posted: 06 Jan 2013 18:44
by SquireJames
I have thought before that canal tunnels would be handy, but as Jolt says I figured there would be issues with ship size and I also (probably wrongly) thought that since I had some up with an idea and no-one had apparently mentioned it yet, it must be impossible to do else someone far cleverer and far more talented than myself would have already done so :)

I never have any good ideas first you see :)

Would it be possible to make ship sprites go translucent like train sprites can when they enter tunnels? Would that perhaps resolve the clipping thing a little, since you wouldn't see which bits were clipping through terrain and which bits weren't?

Re: Water Tunnels

Posted: 06 Jan 2013 20:49
by FLHerne
SquireJames wrote:Would it be possible to make ship sprites go translucent like train sprites can when they enter tunnels? Would that perhaps resolve the clipping thing a little, since you wouldn't see which bits were clipping through terrain and which bits weren't?
I think the problem is that ship sprites are often larger than a tile, so the front starts poking 'through' the terrain behind the tunnel mouth before the rear of the ship has finished moving into the tunnel. So making the front invisible in time to avoid clipping would lead to the rear of the ship 'vanishing'.

Of course, I could be completely wrong as usual... :roll:

Re: Water Tunnels

Posted: 06 Jan 2013 21:13
by SquireJames
Well, hence me suggesting translucent :) Like the "Fake Subway" set, or normal trains when they enter a tunnel. Sort of grey and and shadowt

Re: Water Tunnels

Posted: 06 Jan 2013 23:07
by Eddi
that is not at all what happens when a train enters a tunnel...

Re: Water Tunnels

Posted: 06 Jan 2013 23:30
by Supercheese
Eddi wrote:that is not at all what happens when a train enters a tunnel...
I believe there's a patch (also included in Chill's PP) that has the behavior described: http://dev.openttdcoop.org/projects/cli ... nnels.diff

Re: Water Tunnels

Posted: 07 Jan 2013 03:02
by SquireJames
Ah that would be it. Thanks supercheese.

Re: Water Tunnels

Posted: 07 Jan 2013 11:52
by Hyronymus
Eddi wrote:that is not at all what happens when a train enters a tunnel...
Please, spare us the details :mrgreen: .

How up to date is that diff in regards to 1.3.0?

Re: Water Tunnels

Posted: 08 Jan 2013 16:44
by Roujin
Eddi wrote:there is no technical reason that prevents water tunnels, but the graphics will glitch horribly, because ships are just too big.
Well, since there there is a request for it and I thought I could after long time get into OpenTTD coding again, I wrote a patch. Searching yielded an old patch that did this already, but as that one is quite old I decided to rewrite it from scratch instead of trying to update it.

I made two versions of the .diff, one just uses the road sprites (gui, cursor, 48 tile sprites) for everything, the other adds new sprites, which would require a modified base graphics set with new sprites added.
I made some shoddy sprites based on the opengfx road tunnel sprites and the water tile, but I wasn't able to create a modified opengfx with these sprites added in the appropriate locations. Maybe some graphics wizard could jump in and help me out here? Attached are the sprite sheets with sources (gimp .xcf). The GUI sprites are supposed to be added at the end of SPR_OPENTTD_BASE (after the recently added delete buttons), the tile sprites got their own section after SPR_RAILTYPE_TUNNEL_BASE. See sprites.h in the newsprites-diff.


Anyway, here's a screenshot using the version which uses the road sprites. As predicted there's glitches due to the size of the ship.
water tunnels test 1.png
water tunnels test 1.png (84.32 KiB) Viewed 3227 times
And here's the diffs. You can use the newsprites one, but it will show a warning that sprites are missing and tunnels will look glitchy.
watertunnel_v1_roadsprites_r24893.diff
Version using road sprites.
(15.85 KiB) Downloaded 103 times
watertunnel_v1_newsprites_r24893.diff
Version using new sprites (requires modified base graphics set which does not exist yet).
(18.42 KiB) Downloaded 98 times

Re: Water Tunnels

Posted: 08 Jan 2013 16:49
by Roujin
... and here's the sprites. If someone could make a modified OpenGFX with these added, or even make proper ones that line up with canal tiles, would be greatly appreciated.

Everything's in the zip, added the pngs extra for viewing convenience only.

Re: Water Tunnels

Posted: 08 Jan 2013 17:53
by Redirect Left
That's pretty nice. Although, the sprite glitch isn't exactly overly annoying, really.

Re: Water Tunnels

Posted: 08 Jan 2013 18:10
by Roujin
Well, this screenshot doesn't really convey the whole truth of these graphical problems...

First, the passenger ferry is pretty small, larger ships will obviously show through the ground longer/more.
Also at the point where the vehicle becomes invisible, quite a bit of the ship is still outside, so that sudden vanishing is (much more) noticeable compared to buses / train wagons. Of course that can't be seen on a screenshot. But you can imagine.. on the screenshot with the ferry I think I captured the last frame before the ship becomes invisible.

edit: I lied. The ferry goes in quite a bit more before vanishing. So the vanishing thing isn't that big of a problem, but the "showing through the ground" is worse than as seen on my previous screenshot. I will provide a new screenshot shortly.

edit2: these screenshots show the last frame shown before the ship disappears, for the passenger ferry, and the cargo ship (afaict the biggest ship in OpenGFX), respectively.

Re: Water Tunnels

Posted: 08 Jan 2013 19:04
by Hyronymus
Perhaps a stupid suggestion but will it work if you extend the water tunnel graphics to the tile immediatly behind the tunnel entrance? I.e. extend it with a flat green tile.

Re: Water Tunnels

Posted: 08 Jan 2013 19:15
by planetmaker
Hyronymus wrote:Perhaps a stupid suggestion but will it work if you extend the water tunnel graphics to the tile immediatly behind the tunnel entrance? I.e. extend it with a flat green tile.
That of course will look great, if it's a rail tile, a house tile or an industry tile. Or even a water tile. ;-)

@Roujin: nice to see you back :-)

Wrt tunnels: wouldn't it make sense to implement for water tunnels straight the way we draw newgrf rail tunnels which allow separate drawing of ground, rail, portal and slope. Of course ground and rail would in this case be the water tile - but portals and slope could be a separate sprite which do not contain the water itself. And it could contain an overlay sprite (analogue to rail) which would allow to simulate shaddow on the water.

Re: Water Tunnels

Posted: 08 Jan 2013 20:02
by Hyronymus
planetmaker wrote:
Hyronymus wrote:Perhaps a stupid suggestion but will it work if you extend the water tunnel graphics to the tile immediatly behind the tunnel entrance? I.e. extend it with a flat green tile.
That of course will look great, if it's a rail tile, a house tile or an industry tile. Or even a water tile. ;-)

@Roujin: nice to see you back :-)

Wrt tunnels: wouldn't it make sense to implement for water tunnels straight the way we draw newgrf rail tunnels which allow separate drawing of ground, rail, portal and slope. Of course ground and rail would in this case be the water tile - but portals and slope could be a separate sprite which do not contain the water itself. And it could contain an overlay sprite (analogue to rail) which would allow to simulate shaddow on the water.
As I wrote, perhaps a stupid suggestion (still curious whether it would solve the issue though).

Re: Water Tunnels

Posted: 08 Jan 2013 20:31
by Zuu
Hyronymus wrote:As I wrote, perhaps a stupid suggestion (still curious whether it would solve the issue though).
It sounds like it will cause problems. It might prove easier to experiment with ways to not blit the whole ship. Eg. maybe the portal can define a clip rect for the ship? Assuming the portal is large enough that you can let the one of the two vertical borders of the clip rect go through the portal.

In the upscaled screenshot below, I've added a clip rect in pink that should be able to cut away the part of the ship that is show up after the tunnel portal. However, I haven't had a look on the NE/NW directions which might be more troublesome. But if the graphics are designed such that a clip rect can be placed either with a vertical or horizontal border cutting through portal, that trick may solve this issue.

The issue with ships disappearing before they have fully entered the tunnel is however not solved by adding a clip rect.