Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Small Terrain Scripts

Discussion in 'Made With Unity' started by Kragh, Mar 9, 2010.

  1. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    657
    From time to time I make scripts targeted at the terrain engine, as it's so tedious to work with, using the inbuild tools only. I just resently discovered some extra tools (the terrain toolkit) but haven't looked at it yet, or seen if some of what I do is already present in that kit. I just enjoy making these scripts myself.
    It's mostly to ease my day as a graphics guy, but also just to learn what goes on under the hood of this strange and "secret" system. They aren't very highteck, but they may be of use to some. I wanna use this thread to keep my things together. Hope some will find it useful. I strongly encourage people to post their own scripts in here, if they have any. This is not a showcase of my work, but just a thread to collect useful scripts for terrain purposes :)

    Mass Grass Placer:
    Ever had paint in an even cover of grass on a huge terrain, but only where a specific (or some specific) splat texture was present? I promised myself never to do that again :?
    I did this script instead.
    Note; it is a little non descriptive. Maybe you should test its functionality on a test terrain, if you have doubts how to use it. Or write me a message.
    You need to save this in a folder called "Editor"
    Update: Supports undo now.

    Detail Resolution Changer:
    Ever had to change the detail resolution texture, and then realized all your work will be erased if you change it from the terrain menu? This script will transfer all detail info to your new resolution of choise. You need to save this in a folder called "Editor"
    Update: Supports undo now.
    Note: Over time I'm sure I'll turn this into a more general resolution editor of the terrainData object, without the data loss of the inbuild version.
    Note 2: Going up in resolution may cause the density to have some patterns to it. As the number of grass is in ints, I can't always get the density right, without only putting grass on some pixels. For instance, if you have 3 grass pieces per 512 res. pixel, try making that onto four 1024 res. pixels...
    I have chosen to put one on three of the pixels, to have the same density. Maybe I should randomize which pixel gets empty...
    It works best going down in res.

    SHOW ME THE ATLAS TEXTURE! (now):
    Very simple script which will reveal to you how your detail objects has been packed into one texture. This can both show you why you have these weired floating lines, even though you are SURE you have set the texture to "clamp", but also which textures are too big in resolution. I made it to get insight to the inner workings of Unitys most "secret" inbuild piece of technology, but ended up saving some memory, and finally getting rid of "magical" artifacts.
     

    Attached Files:

    oAzuehT likes this.
  2. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    These are great scripts, Kragh. Thanks for sharing them.

    You should put them up on the wiki. http://www.unifycommunity.com

    Keep up the awesome work! :D
     
  3. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    657
    That's cool :) I want to wait putting them on the wiki until I'm sure they finished enough to deserve it. For instance I just made them support undo, which I had no idea was so easy to implement. And made them have "..." in their tool name, as that is whaty wizards should have.
    As for the resolution changer, I want to wait until it's a more general solution, which can change resolution on splats as well, keeping the painted info. And the heightmap also.
    But hope it saves people some time. I have other scripts, but they are not finished/stable enough for publishing. I have this Cast shadows creator (initially based on forest's shadows script, but with all objects instead of just trees), which renders an image with all cast shadows from all objects on the terrain. That image can then be blended into the Unitys own lightmap (which still doesn't support cast shadows from trees and objects without colliders).

    Only problem is, it makes Unity crash sometimes for some reason :cry:

    But I hope to get a stable version soon, as I know many people are struggling with this.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    that sounds great.
     
  5. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    Sounds great indeed. Thanks for doing these!
     
  6. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    657
    I know I promised to have the shadow calculator finished soon, but haven't had time to look into it in depth, and it still crashes Unity because of some corruptness it adds to the Asset database. Not always. Just sometimes (1 in 6 or something). Really annoying :x

    Added another script for now, which proved really useful, even though it was made mostly just for testing something...
     
  7. DisTrash

    DisTrash

    Joined:
    Feb 2, 2009
    Posts:
    166
    Hello,

    I'm not a coder rather a graphic artist, and it's GREATLY appreciated to have people that create and share excellent scripts and plugins.

    Many Thanks.
    ++
    :wink: :wink: :wink: :wink: :wink: :wink:
     
  8. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Pretty cool, and aside from the grass placement, I don't think anything like this has been published so far.
     
  9. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    657
    Could you point me in the direction of the grass tool you mention? I have not seen one, and would be glad to see how it works :)
     
  10. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Follow the link in my .sig :)
     
  11. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    657
    Oh yeah, surely you have that feature :) Sorry then to compete with my own free version, but yours seem to be a lot more advanced anyways, so I guess mine isn't an alternative to the real deal. Great job on the toolset, seems very well designed...!
     
  12. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Thanks, and I don't mind the competition, in fact I think your tool serves a different purpose and will have different users.
     
  13. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360