Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Volumetric Cloud Shader

Author
Message
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Jul 2007 13:54 Edited at: 1st Jul 2007 13:59
Wow haven't posted on this board for ages...

Anyway here is an almost finished volumetric cloud shader that I started making for the nVidia competition.


(ugh that does not do it justice, you have to see it it motion!)

I'm one of those people that is absolutely addicted to clouds and I absolutely hated when they were obviously 2D because their volume is they only thing that makes them awesome, so here's my first effort that is clearly superior to what you normally see in games...

The download contains a cloud model - bCloud.x

To make one of your own, you need to do this:
- Get a 2 poly plane
- Texture it
- Scale it 0%
- Position this 'dot' somewhere
- Repeat

The cloud is made up of those 'dots'.

You can also use this for making 'clouds' of anything - bushes, swarms of bees etc. It is actually, the best way of doing rain I have come up with as well.

In the .dba there is also an important function - DepthSortPlanes() that fixes that long standing DBPro problem of the zordering on alpha-ed objects. You won't need to call this if you are using it for foliage, because the leaves should be 100%/0% alpha, so the zwriting won't break.

The shading of the cloud is currently done by the shader and it is CRAP. Someone please come up with something better for it!!

Anyway, enjoy.

-= Out here in the fields, I fight for my meals =-

Attachments

Login to view attachments
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Jul 2007 13:58
Picture

-= Out here in the fields, I fight for my meals =-

Attachments

Login to view attachments
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 1st Jul 2007 15:32
That's pretty awesome Chris K. You could use that for all sorts of stuff. Nice work!

[center]

Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Jul 2007 16:56
That was cool.

Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 1st Jul 2007 17:01
Aww.. Can u make it ps 1.4 compatible?


[B] - LINKIN PARK - [/B]
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Jul 2007 17:08
Yes, I imagine you can, just change the shader to compile in 1.4 rather than 2.0

-= Out here in the fields, I fight for my meals =-
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 1st Jul 2007 21:22
Dint work :S


[B] - LINKIN PARK - [/B]
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Jul 2007 22:23
Well all the shader does is literally shade the image, if you change the image to something else, then change the pixel shader to just texture it, it will compile in 1.4 I'm sure.

I don't actually know what its doing which means it has to be 2.0...

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jul 2007 02:17
It doesn't compile in PS1.4

I think it might if you tidied up the shader code a bit ...

But I think you know this already:

Quote: "The shading of the cloud is currently done by the shader and it is CRAP. Someone please come up with something better for it!!"


You never know - someone might help you out.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 2nd Jul 2007 03:15
interesting, could do with some better lighting. cool you got this working though

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jul 2007 19:37
The Full Metal Coder Roxas

The following should work in PS1.4 :



As Raven says - the lighting needs sorting out. But it's a great start. Chris K's sorting trick works well.

I've removed the lighting code from the above snippet because it wasn't doing anything. I've also removed some other stuff that wasn't used.

Chris K

You might be able to improve the lighting a bit if you used the "sun"'s position rather than direction. That way you can alter the lighting according to the cloud's orientation to the light (at the moment, the normals are all pointing the same way in OBJECT space and all the dot products will be the same). You could use something like (in pseudo-code):



But the "flatness" of the cloud plains could still be a problem.
Another solution is to use a normal bump map for the clouds - so cloudnormal would be read from the normal map. Might be quite effective and cheap because no awkward transforming needs to be done (I think ).

One thing to watch if you're trying to use PS1.4 is that it doesn't support the normalize function in the pixel shader (OK in the vertex shader though).
Wendox
17
Years of Service
User Offline
Joined: 19th Dec 2006
Location:
Posted: 8th Jul 2007 19:42
Hiho

I saw your volumetric Cloud and thought how I can do the same thing without shaders, here's my Code:


PS:"cloud.png" is your cloud image



Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 27th Jul 2007 01:23
Yes that's the same technique, the problem was always getting it to run fast enough!

-= Out here in the fields, I fight for my meals =-
Try
19
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 27th Jul 2007 12:40
Chris K,
Hey that's pretty cool, I like the cartoonish style.

I'm waiting for more realistic lighting though, still needs some improvements to compete with Crysis

I'm sure some people are willing to help for any improvements on your shader.

Cheers,
-Try
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 27th Jul 2007 20:21
I'll aim to get it finished by the end of the summer.

I have found some papers on sub-surface scattering, and I am pretty such I will be able to get it working.

-= Out here in the fields, I fight for my meals =-
Try
19
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 27th Jul 2007 22:11
Chris K,
Quote: "I'll aim to get it finished by the end of the summer."

Nice to hear it, though can't wait for it

Q: oh, Chris, how did you actually made the cloud's model in .x format? I see that you've used Milkshape3D right? but I can't load it in DBP without your shader! Is there anything special about it? Anything you want to mention? Or it's just because you've scaled it down to 0%? Right?

Q: What if I want to change it's shape, bigger, wider, etc.
(Can I make more polygons for it?)

Cheers,
-Try
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 27th Jul 2007 22:15
Yeah, it's just because every plane is scaled down to 0% that you can't see it.

If you want to make your own cloud, you need to follow the steps in the first post

Quote: "To make one of your own, you need to do this:
- Get a 2 poly plane
- Texture it
- Scale it 0%
- Position this 'dot' somewhere
- Repeat

The cloud is made up of those 'dots'."


You can also use a 'puff' image that isn't just pure white, you get better results I think, I was just trying to shade it all in the shader.

Just get a plane in Milkshape, scale it down to a dot, then make a hollow 3D cloud shape out of these by duplicating it and positioning it...

-= Out here in the fields, I fight for my meals =-
Try
19
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 28th Jul 2007 08:24
Thanks Chris.

P.S: I tried to walk inside the clouds, I noted that if you do this, the polys will suddenly be disappeared at certain point! (Near plane clip I think, right? )

I'm at the beginning of shader programming, but I can say something for sure. That your polygons are camera aligned, right? so, here is a quick suggestion:

If you could point your polygons to the camera instead of aligning them, then walking inside them would be much smoother, don't you think?

Cheers,
-Try

Login to post a reply

Server time is: 2024-05-04 17:53:20
Your offset time is: 2024-05-04 17:53:20