Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


[SOLVED] Problem applying 3D simplex noise to an icosphere


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Buckslice   Members   -  Reputation: 128

Like
0Likes
Like

Posted 16 March 2014 - 05:02 PM

Hello gamedev.net,
 
I'm programming a 3D space game in Unity using c# and I've run into a bit of a problem with my planet generation. I have code right now that generates on icosphere and applies simplex noise to it, it looks pretty good but I'm getting weird noise striations along the side of the planet. It looks like the noise is getting stretched along parts of the planet.
 
I'm using this implementation of simplex noise http://cabbynode.net/downloads/Noise.cs

 

Here's the relevant code. it just loops through each vertex i in vertices[] which are all unit length along a subdivided icosphere and applies some noise to it. They end up ranging from about 0.85f - 1.15f afterwards and then I just scale it up for however big I want the planet to be.

float random = Random.Range(100f, 1000f);

for(int i = 0; i < vertices.length; i++){
  float noiseDensity = 2f;
  Vector3 v = vertices[i];
  v.Scale(new Vector3(noiseDensity, noiseDensity, noiseDensity));
  float scale = .25f;
  float noise1 = Noise.Noise.GetOctaveNoise(v.x + random, v.y + random, v.z + random, 4) * scale;
  float factor = 1f - (scale / 2f) + noise1;
  vertices[i] = Vector3.Scale(vertices[i], new Vector3(factor, factor, factor));
}

I tried sampling the noise in multiple spots and average them together to try to smooth it out but I couldn't get it looking good really. I'm quite new to noise and such but I thought if I used 3D noise it wouldn't matter what shape I applied it to, but perhaps the icosphere is the problem because you can't really map a grid to it without distortions. I really don't want to use a normal sphere though because their triangles aren't as consistent of a size. If you guys have any ideas on how I could fix this problem that would be great! I wasn't sure if this was the right forum to post on but it seemed more about the math of applying noise than about rendering or graphics. Thanks!

 

Here's a few pictures of how it looks:

 

looks good here

Unity 2014-03-16 15-44-06-31.png

 

turn the planet a little and you can see the weird stretching I'm talking about

Unity 2014-03-16 15-45-29-03.png

 

on the left it looks good but then to the right you can see the stretching

Unity 2014-03-16 15-48-28-65.png

 



Sponsor:

#2 Javier Meseguer de Paz   Members   -  Reputation: 371

Like
1Likes
Like

Posted 18 March 2014 - 10:00 AM

With so little data I cannot say much, but just a question in case it leads you somewhere: can it be related to passing negative values to Noise.Noise.GetOctaveNoise? I'd try moving the sphere and see what happens...

 

PS: Cool little planet!

 

PSS: By the way, I imagine you are tuning parameters or something, because I found your 'factor' value pretty weird. It goes in the range [-0.125, 1.875]...


Edited by Javier Meseguer de Paz, 18 March 2014 - 10:03 AM.

“We should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil” -  Donald E. Knuth, Structured Programming with go to Statements

 

"First you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Ken Beck, Twitter


#3 Álvaro   Crossbones+   -  Reputation: 13658

Like
2Likes
Like

Posted 18 March 2014 - 10:35 AM

value += GetNoise(pX * currentDouble, pY * currentDouble, pZ) * currentHalf;

 

Why is pZ not multiplied by currentDouble?



#4 Buckslice   Members   -  Reputation: 128

Like
0Likes
Like

Posted 18 March 2014 - 04:53 PM

 

value += GetNoise(pX * currentDouble, pY * currentDouble, pZ) * currentHalf;

 

Why is pZ not multiplied by currentDouble?

 

 

Thanks so much Alvaro! that was definitely the problem. I just noticed that the distortion was only happening when using the octaves function as well. I can't believe I didn't see that!

 

Also you're right Javier I have been just fiddling around with values to get it looking how I want. Definitely need to clean it up though. Ty for input!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS