# Moving Cloud

This topic is 4000 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
Oh, I remember that demo
pretty cool stuff

As far as I know, he doesn't 'move' the clouds. He just interpoplates from one noise function to another over time.
The smooth blend from one to the next fools your eyes into seeing motion.

##### Share on other sites
Yes. I want to know if my interpoplation is correct. I don't get good results. (very bad results). Did you implement that demo?

##### Share on other sites
I think he adds an offset (or velocity...)* to the clouds.

--------------------------------------------
*I am pretty bad in english :)

##### Share on other sites
I think I will use the third dimension to get those movements. Perhaps later I will understand the idea

##### Share on other sites
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?

##### Share on other sites
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.