Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Supershandy · May 26, 2015 at 04:50 PM · texturetexture2dunity4planetperlin noise

Creating random planet textures

Hi Everyone,

I feel I may be out of my depth here but I'm wondering if someone can explain to me how to random planet textures? No meshes, just a simple, randomised texture that makes every planet unique.

I want to avoid having to spend hours using planetGen and bulking up projects with thousands of textures, I've heard of Perlin Noise, but everywhere I look creates meshes and deforms it to create raised terrain as well which I don't require, I'm just looking for something simple to create a texture based on snow, mountains, hills, sand, grass and water, randomise the lot and create a single texture that will wrap around a sphere and as the player will not be able to land on planets and will instead burn up in the atmosphere if they get too close (think the X-Series of games, though that's not what i'm trying to create) I don't require raised terrain and all that malarky.

Cheers,

Supershandy

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Jessespike · May 26, 2015 at 06:40 PM

Perlin noise is just an algorithm, so it can applied to almost anything. The Unity documentation has an example for textures: http://docs.unity3d.com/ScriptReference/Mathf.PerlinNoise.html

 using UnityEngine;
 
 public class GeneratePerlinTexture : MonoBehaviour {
     public int pixWidth = 1024;
     public int pixHeight = 1024;
     public float xOrg;
     public float yOrg;
     public float scale = 20.0F;
     private Texture2D noiseTex;
     private Color[] pix;
     private Renderer rend;
 
     void Start() {
         rend = GetComponent<Renderer>();
         noiseTex = new Texture2D(pixWidth, pixHeight);
         pix = new Color[noiseTex.width * noiseTex.height];
         rend.material.mainTexture = noiseTex;
     }
 
     void CalcNoise() {
         int y = 0;
         while (y < noiseTex.height) {
             int x = 0;
             while (x < noiseTex.width) {
                 float xCoord = xOrg + (float)x / noiseTex.width * scale;
                 float yCoord = yOrg + (float)y / noiseTex.height * scale;
                 float sample = Mathf.PerlinNoise(xCoord, yCoord);
                 pix[y * noiseTex.width + x] = new Color(sample, sample, sample);
                 x++;
             }
             y++;
         }
         noiseTex.SetPixels(pix);
         noiseTex.Apply();
     }
 
     void Update() {
         CalcNoise();
     }
 }


Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Supershandy · May 26, 2015 at 06:47 PM 0
Share

Ok that makes sense, so how would you go about doing the different gradients? I understand you can use Texture2D to apply the sand, water, grass textures etc, but how do you layer them so it looks more like a planet?

avatar image AMU4u Supershandy · Feb 25, 2017 at 05:40 PM 0
Share

I know this was years ago, but check this out.

http://www.jgallant.com/procedurally-generating-wrapping-world-maps-in-unity-csharp-part-1/#intro

avatar image
1

Answer by Warcel · May 26, 2015 at 07:41 PM

Hello, you can try to adapt one of these tutorials...

http://catlikecoding.com/unity/tutorials/

they are very well explained, i like this site a lot

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by AMU4u · May 26, 2015 at 09:55 PM

Hey, superhans! Love you in peepshow!

One way that I instantly come to would be creating objects out of terrain identifying objects, if that makes sense. So you would have a large set of differently drawn cliffs, lakes, trees, and different settings. You would then be able to arrange them according to their boimes, and then have those biomes randomly selected as well as their contents inside. So your generator would be given a variable needing to be filled (a planet) with 4 different biomes all containing a certain amount of biome elements.

This would drastically remove the overhead of actually creating meshes randomly.

Defining how the elements of the biome would be placed would require (I ASSUME, someone might have a better idea) some kind of either drawn or randomly computer drawn bitmap with empty spaces vs spaces containing biome elements. That is beyond me, sadly, but I have seen it done before and know it also severely reduces overhead vs storing thousands of possible biomes or settings, etc.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Procedual Terrain 1 Answer

Unity changes pixel colors 2 Answers

Texture Compression format for UWP,Texture 0 Answers

Blending two Texture2D 1 Answer

EncodetoPNG and all other file types leaves the image in the wrong color space 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges