Clouds

Miscellaneous Forums/General Discussion/Clouds

Anyone worked with real clouds ?

When I photograph clouds and mask them and put
them in a game they don't look like real clouds anymore.
More like ugly pieces og cotton or something.

I've been playing a lot with alpha and antialias but they
still look bad...

I can make smoke, no sweat, but clouds are a whole different game.

Not looking for skybox/dome, but single clouds as sprite or whatever.

Both 2D and 3D thoughts are very welcome :o)

Any ideas ?

Anyone worked with real clouds ?
I catch them in jars, but somehow the pesky things always escape.

Seriously, what's wrong with Terragen or something?

Never tried terragen, but I guess I will now :o)
thx

But you won't try catching them in jars too? You're no fun.

Someone did a cloud 'system' a short while back that was pretty nifty. Can't remember if the source was released or not, though. I think it's in the showcase somewhere.

I think it was DarkHalf (darkheart?)

Nothing matches "cloud" in the archives...

BTW: Terragen don't seem to do the trick any better than a real photography ;(

Yeah, it's by dark Half.

It's not in the archives. It's in the showcase. Here:
http://www.blitzbasic.com/Community/posts.php?topic=50405#563870

Looks like it might have disappeared, though. :/
Maybe email the man to see what's happened to it.

Has anyone a good link about how realtime volumetric clouds are done?

Looks like it might have disappeared, though. :/

Just changed the format of the site and it was buried in directories.... thats all, here you go.








Full version (wasnt intended for full release, but no one was really interested, so its free to use) with full docs and source is here:
http://www.kcstudios.net/ezcloud/KCS_EZCloud_v1.zip

They are single surface camera displaced from a alphaed image (I dont think I used a png though, one could always change it to a png). [EDIT] ahhh, yeah its a png :-).

If you use it in anything comercial, please let me know. No big deal, just like to see it in action :-)

Sorted, wedoe! Nice one Dark Half. I seem to remember the demo was very good.

Very nice Dark Half, great in fact! :)

Dabz

Did you check out Filax's new clouds generator inside TerraEd Pro? They are real time clouds - and work very well - your entire sky moves in a beautiful, fully configurable manner.

Nice one Filax,

IPete2.

Excellent work, Dark Half. You did say the doc and source were in the package? When I downloaded the zip, the only thing in it is the executable (and data files). I'd like to play with the source a little, if you didn't mind, as you may have solved an issue I'm having. Anyway, the clouds are pretty darn good for as little overhead as they have!

Grrrreat stuff Dark Half :oD
Thanx a million !!

Now I only need to know how to convert the
clouds to a 3D-file or a PNG (saving the alpha) ??

(There's no docs in there and no source as stated...)

hey..this is cool..but how to use this EZC files with B3D?

Hello Dark Half, please respond :o)

oooooo crap....

www.kcstudios.net/ezcloud/EZCloud_full_v1.zip

That should be everything except the source for the editor (cause it uses purchased gui I believe). I dont remember if I was in the process of rewritting that one (I just recompiled it from the source), so the docs might (might) not be completely accurate to the lib. Should be, but I can't guarantee anything. You might have to look at the source to get a feel on how a new function works.

The system is old, and out dated, there are many things I would have done better (much better) looking back on some of the source. Just the overall layout of the source bothers me (hind-sight is always 20/20). Although the system is fast, it's not as efficient as it could be.

The cloud image is a png, so dont worry about that (its actually encoded in the cloudpack.ctp file I believe).

I could probably rewrite the whole thing faster, and easier to use, but I have a ton on my plate at the moment. sorry.

Have fun with it.

The link is wrong. It gives "page not found" error.

This is the correct link:

www.kcstudios.net/ezcloud/EZCloud_full_v1.zip

Barney


Best cloud ever!

Dark Half:

Thanks for full file but what are "CLF"-files ?
And how are "EZC"-files coded ?

The cloud image is a png, so dont worry about that (its actually encoded in the cloudpack.ctp file I believe).
What ".ctp"-file ?

Feedback would be very much arpreciated ! :o)

From the help file:
Cloud_TemplateFile$

This var holds the Cloud Data Pack which has our Cloud Textures stored in it. It is set to 'cloudpack.ctp' by default. This means that the cloudpack.ctp file must be in the working directory of your application. This var is set for you to use incase you want to rename the cloudpack.ctp file or store it somewhere else in the system. Simply change this var to the directory/path of the cloudpack.ctp file.




The cloudpack.ctp is located in the bin directory I believe.

As for an .ezc file, I believe those are only for the editor. You must use File->Export single, or Export Multipler clouds.

Docs:
Exporting a single cloud to an .clf file will compile all cloud groups into a single group keeping the layout and individual particle properties intact.

Note:Due to memory efficiency, the cloud system allows a maximum of 1000 particles to a cloud, thus if the count is over 1000, exporting a single cloud will not be allowed.


Exporting multiple clouds to an .clf file will export each group keeing it's layout and particle properties intact into the file.



Loading them into an engine that uses cloudlib (docs):

Cloud_LoadCloud( FileName$ )

Arguments:
Required:
FileName - Name of a cloud file
Optional:
-none-
Returns:
-none-

Description:

Loads one (or more) clouds from a cloud file. If there are more than one cloud in a file, it will load them all.

Sample:

Graphics3d(640,480)
Setbuffer(backbuffer())
MainCamera = CreateCamera()
Cloud_Init(MainCamera)
Coud_LoadCloud("TestCloud.clf")
While not keydown(1)
Cloud_Update()
Renderworld()
text 0,0,"Cloud particles:"+Num
Flip()
Wend
End
Cloud_Kill_AllClouds()



Sorry for the confusion. I could have made this easier to work with, but no one seemed interested when I came to this stage, so I threw it in the bin.

Thanks again, I should be able to work it out now :o)

(I'll post again if I don't...)

np

why post this in to bin..its gorgeus..I really like it man..

Cause no one really cared for it when I got it to 'testing' phase a while ago (I think I did it about 1 1/2 - 2 years ago).

One guy was interested in testing it out for me, but never got back to me on how it ran for him.....

Oh well :-)

Damn you retro.hack. I just came here to post



:/

That picture is legendarily awesome.

Dark Half.

Dude, um. Was that me? because I downloaded it, ran it, was very impressed, and then err... I dont know, Forgot ^.^

It was Very impressive. I also have a proper PC now.

Seems like a lot more people are interested to see
this finished now, maybe just the timing was bad ?

Wow....very nice clouds. I'd definitely like to see this finished!

I can't get any clouds to save - if anyone does get any decent ones from it then I'd be interested in having them too.

hmmmm, well perhaps it's worth a second thought.

I'd be interested in rewriting the system for ease of use and speed, but I don't have the time to rewrite the editor.

Some things I was going to add when I was originally completting the project:
-Ability to generate a random cloud (just a function to generate a cloud based on a loose number of particles).
-Better LOD (more control over LOD).
-Better formations (Formation of a cloud meaning that edges of the cloud will form after the middle areas, in the editor drag the formation slider to see what I Am talking about).

Like I said, I could probably rewrite the system in a few hours, but there wouldn't be an editor for it, it would all be function calls to make the system work.

Like I said, I could probably rewrite the system in a few hours, but there wouldn't be an editor for it, it would all be function calls to make the system work.
Sounds nice to me :o)

As long as I can end up with a .3DS or .X and .PNG file
from my creations that's all I ever going to need.

well..I successfully export my clouds as a .CLF file, and then I tried to run everything within Blitz3D, and I follow exactly samples from HELP file, but, its not working at all..so, if someone already run this thing within B3D, I'll apprechiate if i can take a look over code...

What is CLF (Google gives me "Common Log File")

CLF is extension of cloud file I export out of editor..so in help file staying that I have to load that as a clouds I create in editor and it should work, there is sample code within help file, but when I try to run within B3D, I got errors and its not working...

..okay, its working fine nowww...Cloudpack.ctp have to be copy/paste in to CloudLib folder (its not initially) and just include cloudlib.bb at begin and things working really fine..cooolllll

Nice but I still need PNG with alpha, is that doable ?

here are some nice fluffy cloud .pngs!

256x256,... free for anyone who wants to use them. Credit would be nice, but not required.

edit: use the code below to see what these look like.

if you want to steel the png from the .ctp file, there is a function somewhere in the cloud lib that loads the template. It should just open the .ctp, offset it, and resave it into the temp folder as a .png (I believe, at work at the moment and the code isnt in front of me).

a good practice would have been to delete it after I load it, I say this because I dont know off hand if I did that or not.

What you could do is modify that function to just save it to a local directory as well. And there you have it, the cloud template .png. That is of my creation mind you, but I dont mind if you rip it from there and use it. I created it after watching the microsoft cloud simulator for flight sim 2005 (They showed what their template looked like, but in really bad video quality, so I took out the tablet and drew my own).

Since I usually recode a system someone has donated for public consumption (As they never quite fit my style or project to the Tee), here is a quick run down on how the system functions.:

A. Create a mesh, parent it to the camera (this mesh will hold all the cloud puffs, and it will keep them relative to the camera, so that's nice). Paint the mesh with the cloud template (alpha mapped of course).

B. Create a linked list called cloud or something. In this list, you need to know:
1. A Pivot (This tells us where the cloud particle is in the world)
2. A Mesh (Mesh we are drawing to, this is mostly for speed and expandability)
3. A Surface (the mesh surface, we keep this in the list for speed reasons)
4. Width and Height (of the cloud particle)
5. U and V offset and UV width and height (For the offset of the texture to use)
6. Camera (for speed, we can translate to this camera)
7. X, Y, Z (local coordinates used to draw sprite)

The reason we keep such info in the linked list is because leaving a function when your updating 8,000 some odd particles can cost you dearly! Might as well have the info at hand.

So when we create a cloud particle, we tell it what camera, what mesh (And surface of course), its width, height, and UV offsets (what area of the texture we are needing). Along with a camera of course.
Some of this could be global as well I guess, but for expandability, its smart just to keep it in the list and supply the info as needed.

So, we position the list\pivot where we want the cloud particle to appear. The width and height are set to our width and height needed for the particle. Now lets update the particles:

Now lets create 2 arrays to store the sorting information.
Array1.CLOUD(10000) ;This is for storing our cloud particle refference
Array2#(10000) ;Stores the Z value after the transformation

You could put some of these in their own function, however leaving a function in a loop of 8-10000 gets cpu expensive. just stay in the loop with your calculations if possible:
---update loop:
Transform the pivot x,y,z to the local coordinates of the camera.
If it has a new Z > 0 then it's in front of the camera (< 0 and its behind, and ignore it).
Save the transformed coordinates in our Z,Y,Z of this list
If we can see the particle, add it to the array
CloudCount = CloudCount + 1
Array1.CLOUD(CloudCount) = This.Cloud
Array2#(CloudCount) = NewZ
---End Update looop

K, now lets clear the surface(mesh) of all triangles and verticies. It's easier just to draw new ones than re-use the old ones (specially with alpha sorting involved).

Now use quicksort and sort the arrays. Just sort based on Array2, and when it does a swap of locations, swap Array1 as well (so the refference follows the Z location).

Now loop through the array, smalles to biggest, and draw the particle on the mesh. (remember to stay in the loop, dont call other functions if you can help it).
For ThisCloud = 1 to CloudCount
	ThisWidth#			=Array1(ThisCloud)\Width * .5
	ThisHeight#			=Array1(ThisCloud)\Height * .5
	ThisUWidth#			=Array1(ThisCloud)\UWidth * .5
	ThisVWidth#			=Array1(ThisCloud)\VWidth * .5
	V1				=addvertex(Array1(ThisCloud)\Surface,	Array1(ThisCloud)\X - ThisWidth#, Array1(ThisCloud)\Y + ThisHeight#,Array1(ThisCloud)\Z, 	Array1(ThisCloud)\U,Array1(ThisCloud)\V)
	V1				=addvertex(Array1(ThisCloud)\Surface,	Array1(ThisCloud)\X + ThisWidth#, Array1(ThisCloud)\Y + ThisHeight#,Array1(ThisCloud)\Z, 	Array1(ThisCloud)\U+ThisUWidth#,Array1(ThisCloud)\V)
	V1				=addvertex(Array1(ThisCloud)\Surface,	Array1(ThisCloud)\X + ThisWidth#, Array1(ThisCloud)\Y - ThisHeight#,Array1(ThisCloud)\Z, 	Array1(ThisCloud)\U+ThisUWidth#,Array1(ThisCloud)\V+ThisVWidth#)
	V1				=addvertex(Array1(ThisCloud)\Surface,	Array1(ThisCloud)\X - ThisWidth#, Array1(ThisCloud)\Y - ThisHeight#,Array1(ThisCloud)\Z, 	Array1(ThisCloud)\U,Array1(ThisCloud)\V+ThisVWidth#)
	AddTriangle(Array1(ThisCloud)\Surface, V1, V2, V3)
	AddTriangle(Array1(ThisCloud)\Surface, V3, V4, V1)
Next

And there you have it (pretty much). It's a bit long winded of how simple it really is. You can also add stuff like vertex coloring and alpha to each cloud as well. This is all off the top of my head, so take it for face value.

[/book]

Hello DH

Thanks a lot for the info, it's not always, with my limited
IQ, easy to jump into bigbrain stuff and other peoples code so I will try
to code my own cloud-maker based on your receipt above. I'm very grateful,
there's no way I could have made clouds even close to looking real without this thread :o)

I'll post here or make a new thread when I have something to show.

here is some code to go with the .png images I posted earlier.

place the images in the same directory as the .bb file

here are the .png images needed

; Cloudmaker, by Pongo
; 7.11.06

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Local tmp#

Dim cloudtex(8)
cloudtex(1)=LoadTexture ("cloud1.png",1+2) ; color plus alpha
cloudtex(2)=LoadTexture ("cloud2.png",1+2) ; color plus alpha
cloudtex(3)=LoadTexture ("cloud3.png",1+2) ; color plus alpha
cloudtex(4)=LoadTexture ("cloud4.png",1+2) ; color plus alpha
cloudtex(5)=LoadTexture ("cloud5.png",1+2) ; color plus alpha
cloudtex(6)=LoadTexture ("cloud6.png",1+2) ; color plus alpha
cloudtex(7)=LoadTexture ("cloud7.png",1+2) ; color plus alpha
cloudtex(8)=LoadTexture ("cloud8.png",1+2) ; color plus alpha

;; turn this loop on To make the clouds use additive mixing
;For loop = 1 To 8
;TextureBlend cloudtex(loop),3
;Next

Const cloudcount = 20 ; change this to make more particles per cloud

cloudmaster = CreatePivot()

Dim cloudpuff(cloudcount)

For loop = 1 To cloudcount
	cloudpuff(loop) = CreateSprite(cloudmaster)
	PositionEntity cloudpuff(loop),Rnd(-2.0,2.0),Rnd(-1.0,1.0),Rnd(-2.0,2.0)
	tmp = Rnd(1.0,5.0)
	ScaleSprite cloudpuff(loop),tmp,tmp
	EntityTexture cloudpuff(loop),cloudtex(Rnd(1,8))
	EntityAlpha cloudpuff(loop),.7 ; make the puffs a bit more transparent. helps hipe some of the "popping"
	EntityFX cloudpuff(loop),1 ;fullbright
Next 

cam = CreateCamera()
PositionEntity cam,0,-1,-8
CameraClsColor cam,35,105,185

While Not KeyHit(1)

	If KeyHit(57)
		For loop = 1 To cloudcount
			PositionEntity cloudpuff(loop),Rnd(-2.0,2.0),Rnd(-1.0,1.0),Rnd(-2.0,2.0)
			tmp = Rnd(1.0,3.0)	
			ScaleSprite cloudpuff(loop),tmp,tmp
			EntityTexture cloudpuff(loop),cloudtex(Rnd(1,8))
		Next 
	EndIf


	TurnEntity cloudmaster,0,MouseXSpeed(),0
	MoveEntity cam,0,0,MouseZSpeed()*.25

	UpdateWorld()
	RenderWorld()

	;Text 50,450,"Space to create a new cloud, mouse X to rotate, mouse wheel to zoom"
	
	Flip
Wend

End



Superb Pongo, I'm at work now but I will test your code later :o)

I updated the code so if you grabbed it earlier you may want to get it again. Just a few small tweaks, but they make things a bit nicer.

The "popping" effect visible when turning around the cloud can be eliminated by using an additive blend mode, but then you lose the nice shading. Tweaking the transparency of the puffs can help a bit. Since you are not usually orbiting around a cloud, this is much less of a problem than it appears in this particular code though.

Tested your code Pongo, very nice :o)

How did you mask the example-clouds into .PNG's (they're perfect) ?

Those clouds were made by hand in Photoshop and saved out. The originals are much higher resolution since they were made for a film project not a game, but the same idea works with both.

Just an update,... this time the code is included with the .zip file.

One last time, here is the link!

And some screenies too!








Thanks a LOT Pongo, this is just what I needed :o)
If we ever meet I'll buy you a beer or three !!

Thems some nice clouds, Pongo.

yeah, those are good looking!

Thank's a lot to Dark Half also for all the good info !
Much valued ! :)