Skip to main content
gamedev.net
🔒 Locked

Moving Cloud

Started by glHomeless 5 replies 1.7k views
Original Post
glHomeless
glHomeless
Hello, I am trying to implement movement of clouds with the help of information written on this link: http://freespace.virgin.net/hugo.elias/models/m_clouds.htm But I don't really understand how he moves the clouds. I am using 4 octaves. So I have 4 images ( maps ). The smallest map has a size of 32x32. I have a function to create perlin noise for one image. So here is my code:

void moveClouds(float time)
{
   if(time % 2 == 0)
   {
      map1=map2;
      createPerlinNoise(map2,32*2);
      changeSize(map2,32,32);
   }
   if(time % 4 == 0)
   {
      map2=map3;
      createPerlinNoise(map3,32*2);
      changeSize(map3,32,32);
   }
   if(time % 16 == 0)
   {
      map3=map4;
      createPerlinNoise(map4,32*2);
      changeSize(map4,32,32);
   }
   createCloud();
}

I hope somone can help me.
glHomeless
glHomeless
Yes. I want to know if my interpoplation is correct. I don't get good results. (very bad results). Did you implement that demo?
Gagyi
Gagyi
I think he adds an offset (or velocity...)* to the clouds.

--------------------------------------------
*I am pretty bad in english :)
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
glHomeless
glHomeless
I think I will use the third dimension to get those movements. Perhaps later I will understand the idea
ahw
ahw
mmmh... I dont think u understand what you are doing here. I've never implemented the algorithm, but if you read carefully the article it's actually fairly simple.

what you want to do is "morph" from one perlin noise texture to the next.
now the trick is that your clouds are displayed by combining different noise textures with different "frequencies".

So what you should have is an interpolation routine for each "frequency", independantly of each other. In the article, he shows you the pseudo code for only one such frequency.

One thing he mentions is that you should morph the textures at different rates, depending on which frequency they represent. For example, the highest frequency texture (which represent the smallest details) should be updated often, whereas the lowest frequency texture (which represents the bulk of the cloud) should evolve slowly.

let's say, you have 3 frequencies:
texture1 is 128x128, then from it you get the smaller 64x64 texture2, then from that texture3 which is 32x32.
you would update texture1 every second, texture2 every .5 sec, and texture3 every .25 sec (these are random numbers, but notice that the higher frequencies will be updated more often, as recommanded in the article).

The interpolation is between a given frequency texture and its next incarnation, not between frequencies!
For example, at the update time for texture1, you create texture1b which is the "target" texture. Until the next update for texture1, the actual texture1 that you use to create the overall cloud texture is an interpolation between texture1 and texture1b...

hope this helps?
-----------------------------Sancte Isidore ora pro nobis !
Rand
Rand
I dont think you should be doing a float%2 or any number.

Your time is a float then you do time%2 etc. I've no idea what this will do. Its probably undetermined between different compilers.

I'm sure your time should be an integer. Even an incremented integer each frame as a test.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.