Archived

This topic is now archived and is closed to further replies.

The_Fallen

Clouds again

Recommended Posts

The_Fallen    122
Hi, I''m currently implementing clouds for my sky, and there are some problems... I''m doing it like this: http://freespace.virgin.net/hugo.elias/models/m_clouds.htm The only difference in my implementation is, that I use the graphics hardware for blending the four perlin maps together. It looks like this: http://www.husser.de/clouds.jpg In the corners there are the 4 perlin maps (have a look in the paper to see how they are created). The left one in the middle is the blended texture with all the four perlin maps. But how to create the "filter" function (would be the image middle right), that is described in the paper? I don''t have access to the blended texture, do I? Can I do the same effect using some blending? I think you could do it with pixel shader, but my gf2mx doesn''t support that... Can anyone help? thx, fallen

Share this post


Link to post
Share on other sites
unknownnick    122
Well, I don't know how you would do it in your case, but I'd rather blend them together "physicaly" (add each pixel (on image) together and divide it by 4 , and you get the average pixel).

finalImage[x][y] = (first[x][y]+second[x][y]+third[x][y]+fourth[x][y])/4; // final image pixel
// X & Y are the coordinates of the pixel on map

You then have one texture and you can throw other four away.

But this takes you some time, to compute the image.


[edited by - unknownnick on May 27, 2003 9:35:42 AM]

Share this post


Link to post
Share on other sites
The_Fallen    122
Yeah, I''ve already thought about that. But at the moment the stretching and smoothing of the textures is done by OpenGL. Blending by myself would mean, that I would have to stretch and smooth by myself, too...
So this isn''t really an option I think...

Share this post


Link to post
Share on other sites
coelurus    259
This "filter" function you mention,is this for the cloud-cover subtraction and exponential? It seems you have already blended the octaves and it''s time to transform them.
I don''t think you can do the exp in HW on a GF2, you need texture lookups for it. The two ways I can see are to make the blending and "filter" pass in SW, or, buy a new GFX card

Share this post


Link to post
Share on other sites
unknownnick    122
I think he didn''t use the same texture four times, but he created different ones.

So there isn''t a question about stretching (I don''t know what did you mean by smoothing). You hust create four textures, and every next one is the half of the first one.

Than you have to do the tiling, and blending. All by yourself.

But again, this is very slow!

Share this post


Link to post
Share on other sites
coelurus    259
Amost chatting this...

You want to blend textures and at the same time scale them, bilinearly I guess?
Copy the highest octave into the final buffer and scale the buffer by 2. Blend the next octave and scale by 2. Repeat for all octaves.
This scaling should be done using bilinear filter, atleast.


  
/* Block of 4 texels in buffer */
ab
cd

/* Scaled */

a-b-
|\|\
c-d-
|\|\


You must fill in the missing space between the texels by interpolating the values beside, in this 2x case, just a simple average. Note that the diagonal average should be the average of 4 texels.

Share this post


Link to post
Share on other sites
unknownnick    122
hum... SW smoothing?

I''ve been reading some topics about perlin noise and such... the topic should be here--> http://www.gamedev.net/community/forums/topic.asp?topic_id=158235

Smoothing included. I hope this is what you want.


...humm does the rest of the world sleep or is this european forum?

Share this post


Link to post
Share on other sites
ApochPiQ    23005
Fractal perlin textures are a pain in the neck because you just can't cheat and come up with good results.

The Hugo Elias article is extremely popular, but IMHO it doesn't properly explain the concept. Here's how perlin textures work.

1. For the point x,y,z, find the perlin noise value
2. Set our weight value to 1
3. Multiply x,y,z by some factor
4. Multiply weight value by some factor
5. Find perlin noise, multiply it by weight value
6. Add perlin noise to total
7. Repeat steps 3-6 some number of times

By changing the number of repeats (octaves), the scaling factor from step 3 (lambda) and the weighting factor in step 4 (omega) we can get many many different patterns. Somewhere in there is a nice cloud pattern.

So you're not actually creating multiple textures; you're creating one texture by doing some crazy math on it. It's also very very slow if you use too many iterations. I suggest trying to stay under 5 octaves if at all possible.


[edit] I misunderstood the original question...

Here's my suggestion. Start with the initial, basic texture that "looks" the biggest (i.e. is not scaled). Give it an alpha of 1. Reduce the texture by 50%, tile it to cover the same space as the first texture, and layer it on top with an alpha of 0.25. Repeat for the next 2, increasing alpha by 0.25 each time. Change the alpha increment if you need more than 4 octaves.

[edited by - ApochPiQ on May 27, 2003 10:08:24 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
An alternative is to use terragen to make a height map. You can get some pretty nice looking ''clouds'' by saving the height map as an image and using it as a texture(and it even wraps around).

Share this post


Link to post
Share on other sites
The_Fallen    122
quote:
Original post by ApochPiQ
I misunderstood the original question...

Here's my suggestion. Start with the initial, basic texture that "looks" the biggest (i.e. is not scaled). Give it an alpha of 1. Reduce the texture by 50%, tile it to cover the same space as the first texture, and layer it on top with an alpha of 0.25. Repeat for the next 2, increasing alpha by 0.25 each time. Change the alpha increment if you need more than 4 octaves.



That's what I'm currently doing. But the result looks like this:
http://freespace.virgin.net/hugo.elias/models/cldmap1.gif
and not like this:
http://freespace.virgin.net/hugo.elias/models/cldmap2.gif

For that I need some function like this in the paper:


    
function CloudExpCurve(v)
c = v - CloudCover
if c < 0 then c=0

CloudDensity = 255 - ((CloudSharpness c) * 255)
return CloudDensity
end function


So I think I have to do it in software...

[edited by - The_Fallen on May 27, 2003 10:23:41 AM]

Share this post


Link to post
Share on other sites
unknownnick    122
Back on the net... I''ve been tired coz of the school... just another month, and I''m free!

OK, on topic.Well, not much to say... I''ve been using the same function, and this has worked quite well for me, so go into the software:
-by making the four perlin noise images. use the link I gave you
-tile them -some loop will do
- add those tiled and non-tiled images together (pixel by pixel)
- and make clouds with the function you''ve already have

This does take you some time, to calculate four images, tile them and add them, but at the end you only have one...

I''ll probably post some code if I have time... the project I''m on is taking quite a lot of my time.

Share this post


Link to post
Share on other sites
blue_knight    194
Look at this topic, it discussed noise based clouds and proper lighting:

http://www.gamedev.net/community/forums/topic.asp?whichpage=5&pagesize=20&topic_id=86024

Share this post


Link to post
Share on other sites
Yann L    1802
quote:
Original post by blue_knight
Look at this topic, it discussed noise based clouds and proper lighting:

http://www.gamedev.net/community/forums/topic.asp?whichpage=5&pagesize=20&topic_id=86024

Actually the techniques I described in that thread will not work on a GF2, since they require texture shaders for the exponentiation lookup. Those are available on GF3+ only.

OK, here is an idea. Just an idea, it will probably not work out that smooth, but it just crossed my mind. The GF2 has a per-pixel texture lookup facility, but it''s well hidden: in the indexed (paletted) texture hardware. You could abuse that to do the exponentiation on the GPU: load the exponent lookup table into the palette of an indexed texture. Compute your perlin noise octaves as you did before, but render them into a texture. Now comes the problematic part (and this is why this method is probably going to fail): you need to convert the perlin noise (still RGB) into an indexed texture. Ie: RGB = 1 becomes index = 1, etc. That''s trivial on the CPU, but I doubt there is hardware support for this available. You will probably need to readback the texture, and reupload as indices. If you readback as luminance, you don''t even need to do any conversions. But the readout is going to be slow, no matter what.

Once you managed to get an indexed texture, just render it with the exponentiation table in the palette.

Other drawback of this method: the dynamic range is horrible, you''ll probably get a lot of artifacts with high frequency clouds. But well, the GF2 is very limited, when it comes to per-pixel effects.

I guess the best method (for a GF2) is to compute your entire clouds on the CPU, project them either onto a sky-box or a sky-plane, and render that.

Share this post


Link to post
Share on other sites
The_Fallen    122
@ YannL: Hmm, sounds interesting. But how to readback a texture? Sorry, I''ve never done that and I didn''t know, that it is possible...

I''m going to buy a new graphics adapter in summer (NV35 I think), so it won''t be a problem then. But I would really like to implement something right now...

Share this post


Link to post
Share on other sites