Recommended Posts

I've been working on computer generated Lego landscapes and I thought I'd share my progress here.  This landscape was generated in Python 3.7, which created the LDraw file which was then rendered in Studio 2 -  Hope you like the images 

48819685172_ddf233d4d4_b.jpg

48819173593_f291c8223e_b.jpg

48819685502_7cf81dc729_b.jpg

48819533111_180c9faaca_b.jpg

48819173928_0f717b09b5_b.jpg

48819685817_e2151de4bc_b.jpg

 

 

Share this post


Link to post
Share on other sites

Nice! Out of curiosity, is it buildable? (I mean, are all elements properly attached?)

Share this post


Link to post
Share on other sites

Hi Philo,  Yes - absolutely, every element (brick and plate) is properly placed and attached and connected by at least one stud (so there are no intersections) - some of the colours may not be available for some bricks.  I just chose some colours that looked nice - the code then randomly applies the colours to bricks (with the exception of transparency where I do force correct brick selection) but from a brick placement point of view the model is physically accurate.  Tile placement is also physically accurate and calculating stud availability for the placement of tile elements was a challenge!

Share this post


Link to post
Share on other sites
Posted (edited)

Nice.

Your post reminded me of a script I made a few years ago that generated cliff landscapes like this one:

falaise.small.png

(higher resolution)

I translated it in Javascript (for portability) and it’s available here (licence GPL 3+).

Edited by SylvainLS
Oops. Errors, errors…

Share this post


Link to post
Share on other sites
Posted (edited)

Ah yes, it doesn’t seem to work on Chromium/Webkit browsers. I only tested in Firefox :grin:

Looking into it ASAP.

EDIT: Guh, I found the (stupid) problem: I had not correctly removed a useless parameter.  New version uploaded.

Edit 2: Needless to say, it didn’t work in Firefox either, it was a last minute, untested because so simple and hence fatal, change :blush:

Edited by SylvainLS

Share this post


Link to post
Share on other sites

Really great (and very fast)! Could you make a post on LDraw forum?

Share this post


Link to post
Share on other sites
5 hours ago, SylvainLS said:

Nice.

Your post reminded me of a script I made a few years ago that generated cliff landscapes like this one:

falaise.small.png

(higher resolution)

I translated it in Javascript (for portability) and it’s available here (licence GPL 3+).

This doesnt work on chrome on mac but it does in Safari just an FYI

Also would it be possible to choose 2 colors for the rock and assign a weight to one one color over the other? I am thinking for Dark Blue Gray and Light Blue Gray but I want more Dark than light gray

Share this post


Link to post
Share on other sites

@Philo Thanks.  I’ll try :grin:

The algorithms are actually quite simple.
The main one goes column by column, piling bricks on top of each other, and checking it idoesn’t go too far (“bumpiness”) from the neighbour columns.  It’s mostly linear (in O(height×width)).
Making a path is just “pushing” a column to the back (pushing the neighbours a bit too), then advance, maybe turn, maybe climb, until we reach the top. 
Making a cave is making a hole and smoothing its borders.
The Pebble line is a simplified, horizontal version, and the sea line is even simpler.

I never tried really big cliffs because the LDraw programs can’t load them (not enough memory, especially for LDView) :tongue:

It might go all wrong (and just doesn’t produce anything) depending on the parameters (which aren’t really checked).  But the result is generally buildable (maybe a glitch here or there).

The result could also be simplified by replacing/merging bricks.

@supertruper1988 Durn! Javascript already has a lot of pitfalls but adding browsers peculiarities makes me ask “Why? Oh why?” so many times :grin:

Share this post


Link to post
Share on other sites
22 minutes ago, supertruper1988 said:

@SylvainLS Did you see the added comment about two colors for the cliffs?

I just saw it.  But why stop at 2 colours?  It would add several parameters (a list of colours and altitudes) but it should be doable in a short time.  I’ll look into it this week-end.

Now mind, there are many other options that could be added (objects, plants…) or parameters to manipulate (all the probabilities to tweak…) but I think there are many options as it is, so I’ll let the courageous ones tinker with the code.

@pennyforge Sorry for the thread-jacking :grin:

Share this post


Link to post
Share on other sites

I meant that this one is okay (though thinking about it, you could just as easily repaint the bricks in a CAD, each line is in its own step) but other requests will have a great chance of being summarily disregarded :tongue:

Share this post


Link to post
Share on other sites

Hi @SylvainLS - wow,that cliff generator is fabulous, the integration of sloped bricks is lovely - really fast too - great work (and no need to apologies for the thread jacking!)  You cliff generator reminds me that one of the things I'm missing is a density function (so that I can increase/decrease the density of bricks on each layer) - I have the outline of a density function but I need to spend a bit more time on it.  I'm also in process of reworking my colour functions as my colour management is a bit cumbersome too. 

Great to see your work - thanks for sharing.

Share this post


Link to post
Share on other sites
Posted (edited)

@pennyforge Simple functions often works wonder.  There’s a lot of landscape generation techniques that are just a very simple action repeated “enough times” and with a bit of randomness. Then, as I said earlier, you can spend your life tweaking a distribution here, a probality there :grin:

@supertruper1988 I found a bit of time “between the pear and the cheese”, corrected a few glitches on paths, and implemented multi-coloured rocks.  You can now give a list of colours, and you can weight them (“L,M,N” means equal strata for L, M, and N; “L,M:2,N” means 25% L, then 50% M, then 25% N).

Edited by SylvainLS

Share this post


Link to post
Share on other sites
Posted (edited)

Another possible addition would be some cliff height variation. While the flat top is useful if you want to build something there, it looks pretty un-natural in itself (while the rest of the cliff and shore really looks great). Some green "pebbling" perhaps?

 

Edited by Philo

Share this post


Link to post
Share on other sites
1 hour ago, Philo said:

it looks pretty un-natural in itself

Never seen Étretat? :wink::tongue:  Well, Étretat’s cliffs have very defined horizontal layers and the top isn’t that flat.  Plus there’s the Needle….  Okay.  You’re right.

Now, “collapsing” areas might give better results than piling things on top but, as most of the features, the grass and the plants were an afterthought, just to better see the cliff, so collapsing will mean rethinking how they work.  Well, I’ll let the idea simmer a bit and see what I can do.

Share this post


Link to post
Share on other sites
17 hours ago, SylvainLS said:

Well, Étretat’s cliffs have very defined horizontal layers and the top isn’t that flat.

Not to make a stink, but a script that works based on tall slopes then perhaps is not the right approach in the first place? It also seems to me that in case of almost perfectly vertical tidal/ fluvial erosion one would emphasize the colors of the sediment layers rather than the physical structure of the cut surfaces, basically meaning you'd stack this up with colored plates with occasional protrusions rather than building it with large 2x and 3x height slopes. Just sayin...

Mylenium

Share this post


Link to post
Share on other sites

@Mylenium :look: That’s exactly what the sentence you quoted says: this script doesn’t make Pays de Caux or Dover-like cliffs, as those have clearly defined horizontal strata and their tops aren’t flat (though the top of this one looks pretty flat to me :tongue:).  Actually, most of the real cliffs anywhere have mostly horizontal or at most oblique strata, very rarely vertical.  But I didn’t invent the vertical slopes technique, it’s a rather common one.  And this script just started as a test to prepare the build of a rock wall / building base with this rather simple technique.  The grass on top and the sea below were added to give some context, and then the ball was rolling and came the path and the caves.  And, in the end, the results look pretty neat, don’t they?  I believe they can even look like the Dover cliffs if you choose the right picture to compare them to :grin: 

Share this post


Link to post
Share on other sites

Height variation option has been added.  A few improvements too (corrections, texts, input, error reporting…).

I’m not happy with the results yet: a flat top may look unnatural (though Lego-like) but a “varied” top looks roof-like, especially without plants (as the plates are all parallel).  I tried to add a bit of simple “noise” but it doesn’t work well often enough. :hmpf_bad:  Of course, one solution would be to make a complete “rolling hills” generator for the top but making a complete world was not the goal of the script :grin:

Share this post


Link to post
Share on other sites
19 minutes ago, SylvainLS said:

Height variation option has been added

Perhaps not perfect, but definitely better! The results with a limited max slope are pretty nice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.