Random dither for Desert and Rocks in Scenario Editor
Moderator: OpenTTD Developers
Random dither for Desert and Rocks in Scenario Editor
Hi. To avoid serious RSI on the Africa scenario, I needed a patch to allow drag/drop of a random pattern of desert and rock tiles.
This patch does that. In the scenario editor, the terraforming panel now has a density number from 1 to 8. This is the chance that a tile will be turned into desert or rocks.
This works both on placement and CTRL- removal for desert. Its great for painting a larger patch of desert, then use random dithered removal to get the edge appearance you want.
So 1:1 paints all tiles, 1:2 paints roughly half, 1:3 roughly a third. As it is a random 1 in 3 chance on button 3, it is theoretically possible that all tiles will be painted. However, the odds are low. As with all things random, its the sample size that matters.
Paint a whole 1024x1024 map at 1:4, and you will probably have 1/4 of the tiles painted. Paint only 8 tiles, and the variation will be more obvious.
Note to dev team: I needed to pass the _terraform_desertratio from main_gui.c to terraform.c, so I put the var in variables.h. Is that the prefered method, or is there a better way to pass the value between modules?
This patch does that. In the scenario editor, the terraforming panel now has a density number from 1 to 8. This is the chance that a tile will be turned into desert or rocks.
This works both on placement and CTRL- removal for desert. Its great for painting a larger patch of desert, then use random dithered removal to get the edge appearance you want.
So 1:1 paints all tiles, 1:2 paints roughly half, 1:3 roughly a third. As it is a random 1 in 3 chance on button 3, it is theoretically possible that all tiles will be painted. However, the odds are low. As with all things random, its the sample size that matters.
Paint a whole 1024x1024 map at 1:4, and you will probably have 1/4 of the tiles painted. Paint only 8 tiles, and the variation will be more obvious.
Note to dev team: I needed to pass the _terraform_desertratio from main_gui.c to terraform.c, so I put the var in variables.h. Is that the prefered method, or is there a better way to pass the value between modules?
- Attachments
-
- dither_desert_rocks.patch
- Random dither of desert and rocks in the scenario editor.
- (7.16 KiB) Downloaded 296 times
-
- After a few drags at 1:4 and 1:6
- screenshot #2.png (32.81 KiB) Viewed 7479 times
-
- Before
- screenshot #1.png (29.87 KiB) Viewed 7473 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
- webfreakz.nl
- Director
- Posts: 627
- Joined: 11 Aug 2005 08:22
- Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
- Contact:
Im thinking of adding the same feature to the trees menu, so you can blend in large areas of trees.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
-
- Tycoon
- Posts: 11501
- Joined: 20 Sep 2004 22:45
Oh yeah! Im getting together a whole load of scenario related patches. This random patch, and Ive further improved the random trees patch to give more obvious clumps of trees.MeusH wrote:Amazing! That's a really great work from you, I hope you will continue it
Once Ive got all the features I want, Ill release a scenario patch that includes all the extras.
Just as a taster... try my river...
- Attachments
-
- Added a river to the map autogen. I need to improve the sinuosity and create a gui before its usable.
- screenshot #3.png (32.66 KiB) Viewed 7375 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Because its part of my Africa scenario, and that is the Darfur plateau.Mr. X wrote:why is there a sign in there named: 'Darfur' ?![]()


OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
- webfreakz.nl
- Director
- Posts: 627
- Joined: 11 Aug 2005 08:22
- Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
- Contact:
How does that have anything to do with it?webfreakz.nl wrote:You live in Africa?richk67 wrote:Because its part of my Africa scenario, and that is the Darfur plateau.Mr. X wrote:why is there a sign in there named: 'Darfur' ?![]()
![]()

Please, try harder to stay on topic, lately a couple of people are just starting random discussions.
GoneWacko. Making [url=irc://irc.oftc.net/tycoon]#tycoon[/url] sexy and exciting since 1784.
Yeah its code... bit clunky, and uses sin waves, and all params are hardcoded... there WILL be a river at that location whatever the terrain. (In mountains, it eats its way down to water level.)MeusH wrote:Do you mean... you haven't done it with landscaping tools... you've coded it? Have you coded automatic river generation?Just as a taster... try my river...
/me runs wildly and eats a grapefruit
Im toying with using a fractal generator to create a river from places within the fractal space near x=-1.2, y=0.25. See the pic here: http://www.geocities.com/CapeCanaveral/5003/howmand.htm.
But that might be a couple of generations down the road.. or river...
Two more random gens for you...
- Attachments
-
- Cutting down through the mountains.
- screenshot #5.png (33.04 KiB) Viewed 7337 times
-
- Mountainous temperate
- screenshot #4.png (26.41 KiB) Viewed 7332 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Talking about the river... I may use squig curves, with about 4/5 generations. They're really interesting... have a read of this .pdf http://algorithmicbotany.org/papers/mountains.gi93.pdf (about page 3 onwards).
Squig is great for upper rivers, but not so good for meanders. In my code, Ive used a sin wave, with decreasing amplitude as it goes along the river. However meanders are really pairs of circles, where the river loops up over one, and down under the next. Lots of formulae out there, so its just a matter of picking one to implement.
River branching is the tricky bit (comparatively), but I may use Fibionacci numbers. ie. a massive river has 5 branches, each of which has 3 branches each of which has 2 branches. This will avoid the potential for infinite looping.
Squig is great for upper rivers, but not so good for meanders. In my code, Ive used a sin wave, with decreasing amplitude as it goes along the river. However meanders are really pairs of circles, where the river loops up over one, and down under the next. Lots of formulae out there, so its just a matter of picking one to implement.
River branching is the tricky bit (comparatively), but I may use Fibionacci numbers. ie. a massive river has 5 branches, each of which has 3 branches each of which has 2 branches. This will avoid the potential for infinite looping.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Squig curves sound good, perhaps even a modified version of Koch curves could also work.
Using the Mandelbrot set might not always give river-like results.
The best way might be erosion/sedimentation models, although that would be computationally expensive.
Using the Mandelbrot set might not always give river-like results.
The best way might be erosion/sedimentation models, although that would be computationally expensive.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
An easiest first experiment is to get a working subdivision algorithm. That does give quite good results. The big limitation with OTTD is that the map can only change by 1 level from square to square. Roll on the new map...CobraA1 wrote:Squig curves sound good, perhaps even a modified version of Koch curves could also work.
Using the Mandelbrot set might not always give river-like results.
The best way might be erosion/sedimentation models, although that would be computationally expensive.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Who is online
Users browsing this forum: No registered users and 12 guests