Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Terrain Fun

Discussion in 'Made With Unity' started by Per, Mar 22, 2010.

  1. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Finally had time to play with Unity, for sure missing breakpoints in this baby but still I quickly slapped together a runtime terrain generation algorithm based on Olsen, yesterday and today.

    Still working on the procedural texture placement and a few other bits and bobs. Then maybe I'll add particle cloud flyoff from the highest peaks once I've added the snow generation and so on.



    Couple of variants


    Getting some snow and sand on there


    What I'd like to see in the Unity Terrain object is some control over the individual shaders. Basically like the "textures" but just a stack for materials, I'd rather not have to implement that myself if possible. Also more API access and documentation. If UT needs to change the API in the future then just create new hooks at the end of the libraries and rename the previous ones as Old, or Ex or something, the old callback will continue to function while keeping a new one in place, then ditch out anything older than 1 whole number version.

    Also a warning for others, the function TerrainData::GetSteepness(float x,float y) has swapped arguments, i.e. it's y,x rather than x,y. I'm hoping that's not to deter use.

    From here I'm going to be in general improving it, adding a vignette/mask texture slot to create islands out of it, more texture work (how do you create new alpha layers via scripting?). Then on to the dynamic object placement.
     
  2. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
  3. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    cool stuff :)

    keep us up to date!
     
  4. LeFishy

    LeFishy

    Joined:
    Feb 11, 2009
    Posts:
    87
    Wait you can do terrain stuff at runtime?

    I didn't even know that was possible. This looks awesome btw and exactly what I need for a future project.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,334
  6. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    I just used the inbuilt functions and my own algorithms, didn't see that before now, I'll give it a look, thanks for the link!
     
  7. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,209
    Yes, you can do almost anything to the terrain at run time.

    Looks nice. Though I'm personally not a fan of reinventing the wheel and would always generate my terrain and textures in an existing 3rd party tool instead of trying to come up with all that code myself.
     
  8. ChrisBolton

    ChrisBolton

    Joined:
    Nov 19, 2008
    Posts:
    41
    Hey Per, liking the terrains! Will like to follow this thread.

    By the way, I don't suppose your the same Per from Turntool are you?

    Chris
     
  9. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Hi,

    @Tom - Thanks. Ah, but you see I needed a better wheel!

    In this case I didn't find anything suitable. I need "infinite" playable terrains built relatively fast in-game at true run-time and on demand, so having a only a few hand-built beforehand and imported is really out of the question. Bear in mind that run-time doesn't mean when Unity GUI is running but rather when the game itself is running. That takes most unity gui plugins out of the picture, it also needs to be pretty speedy, no-one wants to wait around for that long!

    @ChrisBolton - Thanks. Sorry nope, I frequent CGTalk and CGHub but that's about it.
     
  10. Mirage

    Mirage

    Joined:
    Jan 13, 2010
    Posts:
    230
    Great work! May I make a suggestion though; would it be possible to do this, but only to a select portion of the terrain? I was thinking of something along the lines of using a paint selection brush, and applying the algorithim to the selected region? Great work, just a suggestion for future versions. :D
     
unityunity