You can get Voxel Farm now. For more information click here.

Tuesday, June 5, 2012

Dude where is my castle?

I have been writing some new grammars lately. I realized that if my system was any good, it had to be able to do romantic castles like Neuschwanstein, Disneyland, etc. I don't really like this style, but there was no way to avoid it.

So here are a few screens of procedural kitsch:







Note there are no materials or texturing. This should help you see the grammar output clearly.

This is the same castle from different angles. It sits on top of a series of boxes which were produced by an earlier stage, when city blocks are created. It is not required for the boxes to be aligned, although they are in this particular instance.

The interior is properly connected by a system of doors and stairs. Even the round towers have spiral stairs. You could go in and fool around inside this structure.

Most of what you see here is parametric, which means very different castles can arise from the same grammar rules. The basic components that you find instanced many times over, like windows, doorways, ledges, can also be replaced.

If you have been following this blog for a while now you will realize that this castle is built out the same elements of the church I posted more than a year ago. As you can see it takes little effort on the modeling side. I have been very lazy about creating new basic components.

As usual there is a lot of room for improvement. I want to add little windows in the rooftops, gargoyles, better doors and windows, balconies, etc. I will probably revisit this style later, for now I will move to the next cliche, maybe a Mayan temple or a Japanese Castle. If you have one type of architecture that you think will prove unsolvable, please drop me a comment.

55 comments:

  1. I personally like practical castles more than the pretty ones. This one is quite pretty though XD.

    Anyway, on the subject of procedurally generated castles.
    Castles (the practical type atleast) are usually build in such a way that they are easily defendable, their positioning is in a strategical location, they are all unique to the environment and what enemy they are up against at the time of construction.

    So I was wondering if you could make some systems to make an actual properly defensible castle, which tries to get the best possible defence, taking into account the terrain around it.

    It would really add a lot to the world you are making, as it seems like the castles are actually build to be defended to those who know what to look for =D. I think it would also be a nice challenge for a procedural programmer as yourself.

    ReplyDelete
  2. To distinguish these two types of castles, a strategic stronghold for war and a place for the summer vacation of the king, we have in germane two different words to describe this "Burg" and "Schloß". I was surprised that there does no such word exist in English :)

    btw, Neuschwanstein was build in the late 19th century by the mad Bavarian king. A time were castles weren't used for military strategies anymore.

    ReplyDelete
    Replies
    1. I guess "castle" and "palace" do something of the same job, though the context is probably a little different.

      Delete
    2. Right, these were built long after the age of the canon, which made the castle as a fortress pretty much impractical.

      They are romantic as they look back and borrow from medieval themes with some sort of nostalgia. In this sense, even if real like Neuschwanstein, they are closer to a fantasy. Neuschwanstein was designed by Wagner's opera set designer, not an architect.

      Delete
  3. For difficult architecture challenges, how about something like Kowloon walled city, Shibam, or Pueblo buildings--basically a big mass of connected buildings.

    ReplyDelete
    Replies
    1. I dont think that would be much more difficult than a normal building, but I would like to see it though

      Delete
    2. Thanks, some gold nuggets there.

      Delete
    3. The qalat is another common structure that I think would lend itself to a procedural grammar. In fact, construction of qalats follows a set of (social) rules.

      (1) Build a mud brick wall around the area in which you want your family to live.
      (2) Add a house for the men and another for the women. Add a third for any livestock, ideally at the other end of the compound.
      (3) When your children reach the age of majority, knock a door into one wall and let them build next door on your land. Ideally the door will be near your living quarters and their house will share a wall with yours.
      (4) If you have too many children or not enough farmland to spare for housing, you may instead build another building inside your walls, taking care not to cover up doors created during #3.

      Here's a typical village, outside Kandahar:
      https://maps.google.com/maps?q=afghanistan&ll=31.649217,65.847555&spn=0.007297,0.009645&hnear=Afghanistan&gl=us&t=h&z=17

      ...and here's Kunday, outside of Khowst:
      https://maps.google.com/maps?q=afghanistan&ll=33.346501,69.994025&spn=0.007457,0.009645&hnear=Afghanistan&gl=us&t=h&z=17

      Delete
    4. Thanks, I did not know about these qalats.

      A while ago I saw this talk a TED about similar structures: Fractal African villages. http://www.ted.com/talks/ron_eglash_on_african_fractals.html

      Delete
    5. This comment has been removed by the author.

      Delete
    6. Oh wow...I've flown over that village outside Kandahar in a helicopter while deployed there.

      MCeperoG, your stuff is amazing. I had no idea any of this was even possible tonight. I just wanted to learn to make procedurally generated, destructible terrain for games. Now I have to figure out what voxels are!

      Delete
  4. I think it'd be interesting to generate a normal city, and then based on proximity to a nearby border and importance (width) of the nearby roads, procedurally add normal city walls and gradually tack on brick fortifications, earthworks, ditches, moats, ravelins, and so on.

    In cities like these it was also normal for wooden structures to be built on rowhouse-style plans with the city wall comprising their back wall.

    Speaking of rowhouses, an *easy* grammar might be the narrow-but-very-tall rowhouses of Amsterdam. Those near canals have a pulley-and-beam at the top for directly handling cargo from a barge.

    ReplyDelete
    Replies
    1. Sounds good, I will be experimenting with full villages later in the summer.

      Delete
  5. Looks great. Do you think you would write an 'aged' or 'destruction' pass after the building is completed to make it look real and also help mask the cookie-cutter nature of procedural buildings?
    Would those passes have to be unique to each building type?

    ReplyDelete
    Replies
    1. Procedural buildings are created with the same techniques used for very organic shapes like trees, plants and living creatures. It is how much time you spend building entropy into the rules and the basic components.

      I do plan to add a voxel-based entropy phase. I have posted some results in the past, you can click on the tag "ruins" to see some results.

      And you also have the texturing, which can give you cues about the age and deterioration. I have planned a water and humidity simulation over the buildings, so portions of walls where water flows or drips will become darker and more eroded. My problem with this is I still need to pack all this architecture into a very tight budget. I may have not enough room now for a material entropy layer.

      Delete
  6. To add to Scott's idea about aged passes... perhaps a pre-construction phase or during-construction phase, complete with medival cranes and partially gathered rough stone etc.

    http://www.radio.cz/en/section/curraffrs/man-powered-medieval-crane-at-prague-castle

    With everything being procedural, you could generate different "ages" of the world.

    ReplyDelete
    Replies
    1. In theory yes. I may have not enough time to go into this amount of detail.

      Delete
  7. I showed this to my wife. After a suitable amount of squeeing at the beautiful Disney princess castle, she suggested a particularly difficult form of architecture: The modern, artsy curved sheet metal architecture, as seen in structures like the Guggenheim Museum or the Walt Disney Concert Hall.

    The part that I would expect to make this difficult is the inclusion of solid, smooth complex curves. I don't see an easy way to build those out of uniform smaller pieces.

    ReplyDelete
    Replies
    1. Especially if you want it to look structurally sound.

      Delete
    2. I agree with your wife. Most of Frank Gehry's work is very difficult to program for me. They are closer to sculptures than to traditional buildings.

      It is not about the curved surfaces, which can be generated from repeating curved components, it is about the flow of the resulting shapes. Even Gehry does not get this right all the time. Some of his projects look like someone forgot to pick up after his dog (checkout his Music Project in Seattle)

      I do plan to have a city with large curved surfaces. It will borrow from Gerhy.

      Delete
  8. I would think that the works of Antoni Gaudí might be a little difficult to generate. In particular the Sagrada Família.

    ReplyDelete
    Replies
    1. The Sagrada Familia in particular would not be hard, although I better not say without trying first. Gaudi has other buildings that would be very difficult, or would required a lot of hand-made basic components. It is a good suggestion, I will think about it.

      Delete
  9. Not sure if that would be difficult for you, but perhaps symmetrical castle, like Versailles (garden included :-).

    ReplyDelete
    Replies
    1. Making something symmetrical isn't more difficult than making a building semi-randomly. you basically make one half, make sure where necessary, it connects with the ''other (non existing))'' side in terms of hallways etc. And then just copy and mirror it.

      Delete
  10. My mind is blown. Every time I come and visit this blog I only get more impressed each time. Absolutely amazing stuff!

    ReplyDelete
  11. Dwarfen Fortress!

    Honestly, that's what i'd like to see most.

    What makes this especially cool is that you have full 3 Dimensions in which the fortress or city can expand.


    Another interesting but propably to difficult thing would be elven villages. A whole village only in the trees. Connected by swing bridges that would be pretty cool, too. However, fitting this into the trees would be quite a difficult job...

    Architecture wise i think, as others said before, it would be great if the castle would "fit" into the terrain.

    ReplyDelete
    Replies
    1. I would love that too, but I chose not to go into that direction. http://procworld.blogspot.ca/2012/03/what-would-you-like-to-come-out-of-this.html

      Delete
    2. From your old post, I got the impression that your decision not to make a Dwarf Fortress clone was more about not copying the underlying game, not about avoiding the concept of dwarven fortresses?

      I too think an underground civilization would be really cool, though I think it's not a huge challenge. Once you have some sort of subterranean features like natural caves or mines, you just need to generate a more vertically-enabled variant of a pueblo cluster and hollow out the rooms.

      For something tricky, I think location-dependent structures like docks in a seaside town or any sort of treetop village sound hard.

      Delete
    3. Yes, a subterranean fortress would not be hard to do. It is the depth of the simulation in DF what I am discouraged to clone.

      Delete
    4. Cant you just go in depth to some degree? You wont have to go quite as deep down as DF, but I would love to see people going about their lives, countries going to war perhaps, and your procedural world seems just about perfect for that sort of stuff.

      Delete
    5. The first game I will make will feature a static world. Think of Skyrim, WOW, etc. Most likely it will be some kind of shooter/RPG.

      Delete
  12. http://en.wikipedia.org/wiki/Khmer_Empire

    It may not be unsolvable for you, but I think it is definitely a different style than your current buildings.

    ReplyDelete
    Replies
    1. The Angkor Wat would be a similar but specific example.

      Delete
    2. This is what I am currently writing. I do love this style.

      Delete
    3. Certainly, their way of constructing temples is quite nice. However most of their normal buildings were just wooden houses =3.

      Anyway, the Khmer were also quite brilliant water-workers, they had quite a heap of reservoirs and canals to tame the water-cycles.

      Delete
  13. Bridges would be a cool structure to add since they always present interesting architectural problems with how they fit into the landscape around them. Taking into consideration things like size and supports and if they connect to roads (probably). Also they can look interesting when in a state of decay or completely ruined.

    I don't know if you have anything for them to cross yet though. Water is a beast in and of itself especially once you try to start it flowing. Though now that I think of it rivers would be cool to add. You probably already have a plan for this though or have made a decision on whether or not to do it.

    Also along the lines of what some people have suggested would be more decorative structures like Versailles. Maybe some sort of landscaping or complex gardens. Or large public structures like roman forums and theaters. You probably have most of the work you need for these already written.

    ReplyDelete
  14. Some previous comments reminded me, I heard in the developers of the game Dragon Age: Origins, that they made the capital city look like it actually had history, with buildings being basically old buildings, which crumbled down partially, then were build upon, then destroyed again, and build up again (AKA, one wall or tower would have 3 different architectural styles, one of solid (plastered?) stone, one of normal stone, and one of wood I believe.

    Anyway, would it be possible to build buildings with existing ruins, using a different architectural style? I believe it would give an interesting effect.

    ReplyDelete
  15. This is all very interesting for me, as I've always dreamed about making an entirely procedural generated videogame.
    Above all, what takes my curiosity most is: where do you find the time? I mean, I sense you are one of those very quick people, but how can you have a job, a family, maybe a garden, and still find the time to grow such hobby so quickly? How many hours you dedicate to this daily? When I come back home, after 11-12 hours spent for work, I hardly can cope with making a decent dinner and wash my dishes. But I'd love doing the same things you do. So please tell me, what is your secret?

    ReplyDelete
    Replies
    1. I don't cook dinner, that's probably it :)

      In reality there are two sides to this issue.

      First most of the progress you see is an illusion. If you check out what has changed over a year or more you will see I am pretty much still in the same place. In Feb 2011 I posted the first architecture results. In the summer of 2011 I was already doing staircases, building interiors, etc. This system has changed very little since then. The castle you see here it just new rules using that system. Even the 3D elements I used are the same from that original church.

      The other side is that I religiously put one hour or two every night, from 11 PM to 1 AM approximately. Instead of watching TV or reading, this is all the entertainment I get. I don't have to force myself into doing it, I really prefer this to movies, books, playing games etc.

      I do all the work laying bed, while the kids and wife are already asleep. This hobby takes little from my family time. I use an iPad to connect remotely to my dev PC. I use LogmeIn, which is quite fast and runs OpenGL programs almost like you were there.

      You may think developing from an iPad would be slow. In my case I am not fast at typing with a real keyboard anyway. Also when you code most of the time goes into thinking, only a faction of it is typing.

      So that is the secret: Two hours every night is around 10 hours a week. When you do it consistently, and build on top of what you create, it does add up.

      Delete
  16. Fabulous! I would throw my hat in with those that suggested trying to replicate the more "realistic" aspects of buildings like this, in your grammars. I love high fantasy, but I think one of the most beautiful aspects of your work is the care you take to fidelity of the output... and form usually does follow function in the real world :)

    Since someone commented on water, I have to say that in my opinion, even a VERY rudimentary water algorithm (even as basic as providing scattered lake depressions and filling them) will be far preferable to a water-less world.

    The care you've taken to create such a vibrant landscape will be poorly served if water is left completely out of the picture.

    (http://www.madgene.com/data/media/8/mountains_reflected_in_lake.jpg)

    I love to see you tackling more architecture, can't wait to get "inside" those buildings!

    PS: Fantasy has it's place, and though it may be cliche, watching Lord of the Rings again for inspiration can't hurt when searching for things to "try out" via new grammars.

    Thanks for the post!

    ReplyDelete
  17. This is really impressive. I'd love to try my own hand at writing architecture grammars too. Do you or anyone know of any software out there? Open source would be nice, but even a downloadable product would work.

    ReplyDelete
    Replies
    1. The only one I know is CityEngine, a commercial package, but I have not used it. I don't know if there is a free version. I think the guys of Introversion also developed a similar system, but I am not sure if it is available in any form. I'm sure others will be more informed, I went straight into implementing my own... you know, why not double the fun?

      Delete
    2. Introversions city generator was released as part of the introversion humble bundle.
      http://forums.introversion.co.uk/introversion/viewtopic.php?t=1837
      https://dl.dropbox.com/u/6026058/CityGeneratorDemoRC5.zip


      Also for making top-down buildings there's: http://christophermpark.blogspot.fi/2011/07/old-avww-top-down-interior-generator.html

      Delete
    3. I found http://www.contextfreeart.org/ which should give me and anyone else interested a go at L-Systems without having to roll our own :) It looks like it's 2D only, but I think it will help me grasp the main concepts and see if I do want to roll my own 3D one.

      Delete
  18. This is a really interesting coincidence -- I also use Neuschwanstein as the basis for study of my procedural generation with buildings. I have not actually written much with building generation (besides back in 2004). I am also working on a voxel engine (which you can see at gavanw.com). Anyway, keep up the good work!

    ReplyDelete
  19. "If you have one type of architecture that you think will prove unsolvable, please drop me a comment."

    A few years ago I implemented a roof skeleton algorithm (based on Felkel's work). Basically, it's a complete mess, especially for degenerated cases, which, sadly, happen all the time (90° angles everywhere)

    Even with the added knowledge of the grammar, I'm not sure that building roofs in your context will be very easy. Could you maybe post the results of building a grammar for some cases presented here : http://twak.blogspot.fr/2009/05/engineering-weighted-straight-skeleton.html ? Meybe even the simple one : http://www.flickr.com/photos/twak/3491011875/

    Thanks for sharing your work !

    ReplyDelete
    Replies
    1. Like CityEngine, I developed a roof primitive. It can take a series of scopes and build a straight roof skeleton over them. It works for most simple cases. In general I avoid using this primitive as it may produce wacky subscopes. I have opted for less clean but simpler intersections, and managed to conceal their defects by making the troubled sections hidden and non accessible. It is hard to explain it without a concrete example, I'll try to cover this in the future.

      Delete
  20. You should do more videos of your grammar programming, I really enjoyed watching this one: http://www.youtube.com/watch?v=V04dswEIcQU&feature=channel&list=UL

    Perhaps you should create an ongoing video diary of all the projects you make with voxel studio, buildings in particular. Very interesting stuff seeing it come together :)

    ReplyDelete
  21. Another lovely architect to perhaps consider writing stuff for: Hundertwasser

    It is very colourful and has a nice flow which I think will be quite hard to capture in a simple grammar

    ReplyDelete
    Replies
    1. Did not know this guy. Beautiful stuff. Thanks for the suggestion. Looks impossible!

      Delete
    2. hehe, it is what you asked for! I have been trying to come up with a formal language to generate such structures, but a simple CFG would never suffice. I think many of his larger structures consist of layers (either all horizontal or all vertical) and each layer seems to have a slight offset/skeweredness.

      Love your work btw!

      Delete
    3. Right. I thought of a way this can be done. I would need a new concept in the grammars: a space warp. The grammar scopes and instanced geometry would remain fairly simple, the space warp would take care of creating the organic shapes. The tricky part will be defining the warp as a series of warp volumes in a way that will warp only the areas you want. For instance, you do not want floors to warp vertically.

      I should make some time and try this. It will open a new set of possibilities.

      Delete
    4. You could segment the floors at a certain threshold and put a staircase in between. This would make it easier to follow the slopes and also give quite interesting interiors. I believe this is how Hundertwasser also does his interiors.

      Another key element is slightly random placement of pillars consisting out of various primitives.

      I have been thinking about this non-stop for the past day or two and I just love the possibilities. I am a master student in artificial intelligence and I love generative models, would love to contribute to this project.

      Delete

There was an error in this gadget