virtueone            
  home     support     info  

 


                
Creating Environments in Unity: The Backstory - Posted on: 8/27/2016   [Uncategorized]



I had an idea for a game that would feature many different environments, but it was too ambitious - I didn't have time to create everything by hand, so I wondered...

"Would it be possible to generate the environments randomly?". I knew it would be challenging, but if possible, it could save hundreds of hours of production time.

I wasn't interested in creating an entire universe like the game No Man's Sky. Though the idea of procedurally generated environments was very appealing and it would be perfect for what I needed. Well, I didn't figure out how to generate infinite terrains, but I did figure out how to make a large terrain randomly.

Unity has great built-in tools for creating terrains and I found a resource which demonstrated how to create them via script. There are many variables - it's quite complicated - it took me several months to customize and really wrap my head around the technical aspects.

The basic concept...
  • Declare all the terrain settings.
  • Create the terrain data.
  • Create the terrain object.
  • Fill the terrain object with the terrain data.
Skybox, Lighting, Fog, Wind, Particles, and Camera FX - these are all things that will enhance the scene and give life to the environment.

The techniques...

Here are some examples of the conditions and techniques I'm using to create the environments:
  • Terrain size is generally 2048x2048, with matching detail map for thick grass, and alpha map at half size.
  • 4 different alpha maps (terrain textures), which are drawn according to the terrain's slope and height: ground, hill, snow cap, and water basin.
  • 3 different grass details using 3 random frequencies and sizes. Height constraints to keep the grass from being drawn near shoreline or above snow caps.
  • Only rocks and grass are placed in low height (water basin) regions.
  • Gradient fall-off formula applied to terrain height data for an "island effect".
  • Water plane, Particles, and Perimeter are all scaled automatically to match the terrain size.
In addition to the terrain functions, I made a separate function that handles normal game objects - it's for objects that have scripts or shaders that can't be attached to the terrain. Like, dust or wind particles.

Other customizations...
  • Terrain material supports specular lighting and normal maps.
  • Custom height-map texture is optional.
  • Blur effect smooths out rough terrain edges.
  • Tree prototypes created from dynamic array.
  • "Oasis" option forces trees to be placed only near shoreline.
  • Terrain object colliders are enabled.
Resources...

Most of the resources used in this project are Standard Assets from Unity. Other textures and 3d models created by me. Additional resources can be found here:



<< Back to main news page


     
PATREON RESOURCES/LINKS 10/28/2023
PATREON RESOURCES/LINKS
Tropical Scene 8/1/2023
I made a tropical scene in Unity, just for fun.
Skybox AI 6/26/2023
I heard about this AI skybox generator and did a few tests in Unity.
Bobsled Game 3/7/2022
I recently watched the olympic bobsled event and got inspired to make a bobsledding game...
3D Viewer 1/1/2022
I made a simple program in Unity for viewing my 3d objects.
New 3d scene... 8/10/2021
A new scene I made in Blender3D...
Blender... 8/3/2021
I made some trees...
3d scene... 7/27/2021
A landscape scene I made in Blender...
Blender grass... 7/16/2021
An updated image of the different types of grass I made in Blender.
Grass... 7/14/2021
Different styles of grass...
Site created and maintained by kreediddy. © 2010-2024. kreediddy.