The International Simutrans Forum

Development => Extension Requests => Topic started by: dschr on October 16, 2014, 03:56:36 PM

Title: diagonal slope tiles
Post by: dschr on October 16, 2014, 03:56:36 PM
Hello,

i miss diagonal slope tiles, similar to old versions of rollercoraster tycoon, see here:
http://www.clarkchart.com/wp-content/uploads/2013/03/RollerCoasterTycoon-2.jpg

with those vertical slope tiles, it would be possible to have vertical slope rails and with this it would be possible to build rails more as a bee line, instead of orthogonal networks.
Title: Re: vertical slope tiles
Post by: Vladki on October 16, 2014, 06:39:09 PM
There are vertical walls in simutrans. Just search the slope tools and try them out. But they are limited in max height. But I dont understand how would they improve way building. You cannot have a vertical road or railway. But I would like to have the possibility of tunnel entrance in verical wall.

Sent using recycled electrons.

Title: Re: vertical slope tiles
Post by: gauthier on October 16, 2014, 08:15:18 PM
I think he is talking about diagonal slopes since making "vertical slope tracks" doesn't make any sense. Indeed this would be a great improvement to the gameplay, but it looks very (very) hard to implement.
By the way, this request is not specific to pak128 so this thread should be moved to the general extension request section of the forum.
Title: Re: vertical slope tiles
Post by: Sarlock on October 16, 2014, 11:02:10 PM
I think that height data is stored on a per grid point basis, which allows that kind of method.  We are storing our height data per tile instead, which makes that style of slope very difficult to implement.
Title: Re: diagonal slope tiles
Post by: dschr on October 17, 2014, 09:37:57 AM
i am sorry, that was my fault: i ment indeed diagonal slope tiles and i've correct my mistakes.
Title: Re: diagonal slope tiles
Post by: DrSuperGood on October 17, 2014, 12:09:27 PM
The main problem I imagine is that Simutrans does not have any idea of a "diagonal". All ways that appear to be going at a diagonal are actually forming a step 2 tiles wide and high. Although it looks diagonal and is treated as straight it can be viewed as a series of continuously alternating curves. If it was truly diagonal then it would be running from corner to corner of a tile however this creates all sorts of other issues since it has to do the curving inside a corner tile.

OpenTTD had some idea of diagonals in a different way to Simutrans. Although it still used the stepped approach for diagonals it did not use the entire tile. This meant that two diagonal tracks could share part of the same tile. The result was you could go at a diagonal a lot more densely than in Simutrans with the required width being N+1 (where N is number of tracks wide) as opposed to Simutrans with 2N. The main problem with this approach was that mixing different types of rails at a diagonal was impossible or if they were owned by different people it was impossible. This caused so much irritation to so many players.

As nice as diagonal ways going up hill would be, I just do not think it would be worth making the huge changes required.
Title: Re: diagonal slope tiles
Post by: Leartin on December 14, 2014, 02:42:54 AM
Actually, diagonal slopes already exist with half heights. If you have flat ground and heighten one point twice, and the two points below (south and east) once, the tile which border those three points IS a diagonal slope. Works in other directions the same way.

But it's hard to utilize them, since you need to build them carefully by hand. This is because of how the heighten tool works. Like this:

If you click on a point on flat ground, it raises one layer, everything else stays the same. So far so good.
Click again. Now it raises another layer, while all the others still stay the same (using half heights, of course)
Click again. It raises another layer, and all eight surrounding points raise one layer.
With this, you will always get square mountains. which do not utilize the existing diagonal slope.

I think the behaviour could be changed like this:
First click raises only that one point.
Second click raises that point and the four straight adjacent points (north east south west). We already got four tiles with diagonal slopes.
If you continue clicking like that, you again get a square hill, but this time the square is rotated by 45 degree. So that's not really special.
However, if you raised a square of four, nine or more points, the hill gets an octagonal shape and should look smother.

Basically, whenever a point is raised so it's two layers higher than an adjacent point, raise that point too. Or rather, before a point is raised a layer, all 4 adjacent points must be at the same level or one level higher. If they are not, they are raised first. If they can't, it needs to be checked wether the four diagonal adjacent points are already 2 layers lower and try to raise them if they are, otherwise just raise the point. Thus, you'll get only hills with soft slopes, except for wherever an obstacle is, which allow for octagonal shapes.


I think with the right kind of lightmap, it should look a lot better than hills right now. For gameplay, if ways can only go on soft slopes it would be better if those are the ones that get generated by default anyway.
If it was somehow possible to add diagonal steep slopes, it would not even be nessecary to check diagonal adjecent points.
Title: Re: diagonal slope tiles
Post by: Ters on December 14, 2014, 09:41:10 AM
Diagonal slopes in the terrain is one thing, having roads running up them is another. You don't seem to address this second part, which I believe is the real issue.
Title: Re: diagonal slope tiles
Post by: Leartin on December 14, 2014, 11:00:39 AM
I agree, it's two totally different things. But you can't have ways on diagonal slopes without diagonal slopes, wheras you can have diagonal slopes without ways on them.

However, I don't really see the problem with ways on diagonal slopes once they would work the way I described. Each diagonal slope would have two possible ways on it, which one it is is determined by the side a way enters the tile, and the other possibility is forbidden once the other is in place. Similarly with corners, although they can depict three possible ways for three diagonals, where one diagonal is 'flat' and thus prefered over the others if the way ends on that tile. However, with corners, you could even allow intersections, as a combination of one of the sloped diagonals and a straight diagonal.
Diagonal slopes would not require new vehicle graphics, and of the 24 new way graphics only 4 are truly new, the rest is composition. You could even make those way graphics optional, kinda like the steep slopes, and only give it to ways which are supposed to be good for mountainous terrain, like narrow gauge. - This also means that the change does not require anyone to update anything unless they want to use it - except for the height generation, which would probably need to switch between old and proposed behaviour.

Title: Re: diagonal slope tiles
Post by: Ters on December 14, 2014, 11:30:04 AM
Ways tend to be almost perfectly horizontal in the transverse direction. (Apart from minor things like banking, and that roads are higher in the middle so that water runs off to either side.) Furthermore, ways in Simutrans basically cross tile edges perpendicularly, that means ways can only cross edges that are horizontal. Unless there is some form of geometry that escapes me, no tile can have two horizontal edges at different heights without being a straight slope.

Diagonal ways can perhaps cross an edge that is sloped, if the slope is just right. That might be a bit confusing, and look very odd without a new set of way images for transitions between straight and diagonal. (The latter would actually be a visual benefit beyond just diagonal slopes, if it turns out that we can afford it.)
Title: Re: diagonal slope tiles
Post by: Leartin on December 14, 2014, 01:29:09 PM
The way itself will be horizontal, just as it is with normal slopes right now. Take a looke at the attached images: The first tile shows how a slope corner is usually depicted in simutrans - with two slopes meeting in the middle. The second tile is what i propose, a tile that's half flat and half sloped. Note that the edges of those two tiles are the same, the only difference is the graphical representation.
The third tile shows how a rail could pass the corner diagonally without going over the slope. It's just a common diagonal tile.
The fourth finally shows the beginning of a diagonal sloped way. You are right that it is different to all ways currently possible in that the north edge is not horizontal. However, it does not matter, since the way itself is horizontal, but cut diagonally. The tile to the north is bound to contain a way from south to west edge. Actually, the way can only go straight in north-west direction (alternating between SW and NE way tiles) until it hits an 'inverted corner', I depicted that in the second image. Note that the way the mountain looks is already possible with simutrans as it is now, just that with the textures we currently have, it's all bumpy.
Title: Re: diagonal slope tiles
Post by: Ters on December 14, 2014, 02:40:14 PM
I forgot about that possibility, despite it being the most obvious, because I was caught up with the idea that ways in Simutrans by default goes straight across a tile (imagine building a track only part way up). There doesn't seem to be any doubt as to which way the way must go across such a diagonal slope, although I guess it takes some special handling of ways ending on such a slope, or vehicles with a waypoint will move in a strange direction before turning around (odd place for a waypoint, though).
Title: Re: diagonal slope tiles
Post by: prissi on December 14, 2014, 09:10:04 PM
THis is the way OpenTTD handles slopes. However, it lead to severe (or at least ugly) slopes whenever the full range of slopes is used. OpenTTD cheats by only using 20 sloeps (although including the diagonal ones). Lot at the old pakTTD for an example.
Title: Re: diagonal slope tiles
Post by: Leartin on December 15, 2014, 06:56:31 PM
I'm not sure I understand what severe ugly slopes are, and which range of twenty you mean.

I think this needs to be viewed as two seperated, although connected, issues:

1.) Landscape diagonal slopes
To allow the look of diagonal slopes, you pretty much only need a fitting lightmap for the ground. There are 3 Issues:
1.1) There are no diagonal slopes spanning 4 heights diagonally. If we would allow them, the number of slope tiles raises from 65 to 85, which is nothing compared to the amount of new slopes we got with the half heights (13 -> 65 IIRC). Tiles which can be used to build ways on (flat, straight slopes) would not change, since it is already possible to raise ground 4 layers (half height). See attached image - why shouldn't there be a slope that can occupy the space in the middle so it lines up nicely with the other slopes?

1.2) raising/lowering land always raises/lowers rings/squares around the point you actually want to raise instead of diamonds, so diagonal slopes don't come up naturally. (Same could be said for map generation, but I have even less Idea how that works...)

1.3) you get half-flat tile which you are not allowed to build a diagonal way on. This would need to be allowed on all 16 possible slopes (4 corners, 4 inverted corners, same for double height). However, it would not need any new way tiles or behaviour.

Those changes require each other to make any sense, and require a new lightmap for the ground. So all of those changes should be turned on and off by the same checkbox, something like "diagonal slopes". Changing older games to allow those slopes should work just fine, but you can't change them back, or at least lose all ways on corners.

2.) ways on diagonal slopes
IF above landscape changes are made and activated, and IF a way contains the 24 new way graphics needed, only then it should be possible to build that way on diagonal slopes. I'd imagine the diagonal slopes would work pretty much like normal slopes, the hard part could be to tell them to only connect EITHER north-east OR south-west, since otherwise you get crossings. I said earlier that I would allow crossings on corners, but I think that's harder to do for not much benefit, so each non-straight slope would have only one diagonal way on it.



I just wonder, is this really that huge a change? It seems small in comparison to half heights, but maybe I'm totally wrong...
Title: Re: diagonal slope tiles
Post by: prissi on December 15, 2014, 09:10:33 PM
Here is the diagonal tile approach from pak.ttd. Especially two connected mountains hare a diagonal divider.

See here the same hill (mine is missing after reload in pak64).
Title: Re: diagonal slope tiles
Post by: kierongreen on December 22, 2014, 05:54:44 PM
Quote from: Leartin on December 15, 2014, 06:56:31 PM
1.1) There are no diagonal slopes spanning 4 heights diagonally. If we would allow them, the number of slope tiles raises from 65 to 85, which is nothing compared to the amount of new slopes we got with the half heights (13 -> 65 IIRC). Tiles which can be used to build ways on (flat, straight slopes) would not change, since it is already possible to raise ground 4 layers (half height). See attached image - why shouldn't there be a slope that can occupy the space in the middle so it lines up nicely with the other slopes?
4 diagonal direction each having 5 combinations does give 20 more tiles to be drawn for lightmaps, but there are 7 climates giving 140 extra for textures alone, plus 20x15 = 300 for climate transition, plus 4x1+3x4 = 16 for snow transitions. So that's almost 500 extra images. As mentioned that includes 20 new lightmaps which are fiddly to draw, and also 7 extra snow transitions which are just as fiddly.
A bigger problem potentially is that slopes are stored as 8 bit integers. Originally only 4 bits were used - with the corners being bits 0, 1, 2 and 3. Double height slopes gave 3 possibilities for each corner which are stored using 3,9,27 and 81 as mod value, using 81 out of 256 possible values (of which 65 are valid). Using the same method of converting slopes to values triple height slopes would use 256 values (I think 175 would be valid), quadruple height slopes would use 625 values (of which 369 would be valid, although limiting to diagonals only would take it down to 85). With the current way of implementing slopes quadruple heights would be necessary to give the diagonal slopes you want - presumably with restrictions placed so that the other quadruple height slopes couldn't be created. Extending the number of slopes to 16 bit seems likely to cause problems, so the likely solution is a slope lookup table, use of which would probably be flagged by bit 7, giving 128 potential extra non standard slopes, including the 20 mentioned here. This would slow the game down, not sure by how much.
Title: Re: diagonal slope tiles
Post by: isidoro on December 23, 2014, 01:24:22 AM
Excuse my ignorance, but wouldn't it be easier if climate transitions would be done by combination of two masks and two full tiles of each climate?

Even if it was more time consuming, climate borders are only linear in a map, while general tiles are quadratic...

Title: Re: diagonal slope tiles
Post by: gauthier on December 23, 2014, 12:20:41 PM
Quote from: isidoro on December 23, 2014, 01:24:22 AM
Excuse my ignorance, but wouldn't it be easier if climate transitions would be done by combination of two masks and two full tiles of each climate?

I assume this is already done that way since I never found such images in pak128 sources (only climate textures and slopes lightmaps).
Title: Re: diagonal slope tiles
Post by: kierongreen on December 23, 2014, 02:50:49 PM
They are indeed - however you still need a full set of slopes to be created for each climate, and then 15 climate transitions for each slope, another 15 water transitions, plus a set of transitions for snow. Well, that's how the code works at present - that way the image transformations are done in advance, leaving only blending to be done in real time. It would be possible for the image transformations to be done in real time but that would slow things down more. If lightmaps were also done in realtime then you'd effectively be able to have a fully customerisable 3d landscape - but the speed would probably be insufficient for use in game (unless you offloaded calculations to a standalone graphics card).
Title: Re: diagonal slope tiles
Post by: moritz on December 27, 2014, 03:05:40 PM
As of now, lightmaps are drawn using grey colours. For example, to have the texture appear with the same colours as in the ClimateTexture file, one would use a 50% grey in the lightmap.
Maybe we can use the three different colour channels (i.e. red=127, blue=127 and green=127) to indicate which texture should be selected
"red=63, blue=0, green=0" could mean "take the lower texture with 50% brightness for this pixel", or another example "red=0, blue=191, green=0" would mean "take the upper texture and have 150% brightness".
Pixel with a non-zero value in more than one colour could be assigned a default texture (maybe the lower climate) to provide backwards compatibility with the old lightmaps.
This would make SlopeTrans and ShoreTrans files obsolete and would not require overall more graphics needed for a pakset. However, all lightmaps would have to be redrawn to preserve smooth slope transitions.
Title: Re: diagonal slope tiles
Post by: kierongreen on December 27, 2014, 03:21:34 PM
That would give more flexibility, and would get rid of the need for Slope and ShoreTrans but would also require 65*15=975 lightmaps to replace SlopeTrans alone...
Title: Re: diagonal slope tiles
Post by: moritz on December 27, 2014, 08:09:19 PM
I am not quite sure how you got this number... I thought of having the usual lightmap (max 81 images) and instead of using shades of grey, one could use shades of red for the areas near a level 0 corner, green for level 1 and blue for level 2. All this would be expressed in the same 81 images which, of course, would need to be redrawn. Here is a small illustration of what I mean (image=59):
Title: Re: diagonal slope tiles
Post by: kierongreen on December 28, 2014, 05:05:34 AM
Climates aren't limited to 1 per level now, you can have any combination, potentially giving up to 4 different transitions on one tile... Hence you need all the different transitions for all different slope directions.