Weather, Rain
Moderator: Moderators
Re: Weather, Rain
Hmm. Maybe.
I was thinking that every few gameframes, it could check the current camera position, and if ~= to the old one, then spawn raindrops from a random location X,Z based on the camera's position X,Z, so that if the user moves their camera rapidly enough, they'll get "ahead" of the rain, but only for a few fractions of a second. Since this is all happening on the unsynced side, it won't affect other players, obviously, and slower camera motions won't make it very obvious.
The alternative is to do it with DrawScreen or DrawScreenEffects, and have it literally draw in the POV only. Maybe that's the way to go, but the source of the rain needs to update to reflect the current camera position, so that all droplets are now positioned relative to the camera, while still appearing to fall.
Almost done with my hack-job... just cleaning up the thunder / lightning a bit more...
I was thinking that every few gameframes, it could check the current camera position, and if ~= to the old one, then spawn raindrops from a random location X,Z based on the camera's position X,Z, so that if the user moves their camera rapidly enough, they'll get "ahead" of the rain, but only for a few fractions of a second. Since this is all happening on the unsynced side, it won't affect other players, obviously, and slower camera motions won't make it very obvious.
The alternative is to do it with DrawScreen or DrawScreenEffects, and have it literally draw in the POV only. Maybe that's the way to go, but the source of the rain needs to update to reflect the current camera position, so that all droplets are now positioned relative to the camera, while still appearing to fall.
Almost done with my hack-job... just cleaning up the thunder / lightning a bit more...
Re: Weather, Rain
on draw screen functions, the drops would have to be rotated, and scaled a lot, but that is not a problem.
to make such effect using draw world functions, it would have to check the angle of the camera, the angle between the drop and the camera position, and move the drops that aren't on the view, to a new point in the view.
to make such effect using draw world functions, it would have to check the angle of the camera, the angle between the drop and the camera position, and move the drops that aren't on the view, to a new point in the view.
Re: Weather, Rain
Actually, I found a faster way to do it... I just move the origin points of the raindrops, so that they're near to the camera XYZ...
Anyhow, here's my modification of everything... Gadget coded, faster lightning, cleaner playback of sound (directional wasn't working very well, imo) and rain that follows the camera's position, allowing for far fewer particles. Coupled with a good map scene setup, this ought to work fairly well, at a low performance hit.
Any chance of getting a GLSL version of this? I can't get rid of the performance hit of checking the camera's position, etc., but it'd be nice if the actual drawing process could be accelerated, for users who have modern hardware...
Anyhow, here's my modification of everything... Gadget coded, faster lightning, cleaner playback of sound (directional wasn't working very well, imo) and rain that follows the camera's position, allowing for far fewer particles. Coupled with a good map scene setup, this ought to work fairly well, at a low performance hit.
Any chance of getting a GLSL version of this? I can't get rid of the performance hit of checking the camera's position, etc., but it'd be nice if the actual drawing process could be accelerated, for users who have modern hardware...
- Attachments
-
- unit_rain.lua
- Modified Rain Code.
- (10.42 KiB) Downloaded 42 times
Re: Weather, Rain
tip: use shaders
tip2: if you don't know how to write those or want support for older hardware, make (horizontal) layers with 100-500 raindrops and save them into displaylists (so you have ~10 layers) , instead of handling 1k drops one by one ...
PS: you wouldn't need to write a shader version, trepan already did
tip2: if you don't know how to write those or want support for older hardware, make (horizontal) layers with 100-500 raindrops and save them into displaylists (so you have ~10 layers) , instead of handling 1k drops one by one ...
PS: you wouldn't need to write a shader version, trepan already did

Re: Weather, Rain
I can see the merits of that.tip2: if you don't know how to write those or want support for older hardware, make (horizontal) layers with 100-500 raindrops and save them into displaylists (so you have ~10 layers) , instead of handling 1k drops one by one ...
Sooooo... how do I build such a list? If you can give me an example, I'll code that in right now... this is almost a non-sucky Gadget, imo, I'd just like to get performance up.
Yeah, I know, his fancy particle demo, which I still haven't gotten around to, along with that thingamabob that might be good for normal maps. I've been trying to get P.U.R.E. done, since World Builder's release is whenever P.U.R.E.'s is.PS: you wouldn't need to write a shader version, trepan already did
Re: Weather, Rain
Ok, taught myself display lists tonight, yay...
[EDIT] Released revision no. 3. No. 2 was buggy, sorry to anybody who wasted their time.[/EDIT]
This is probably my last revision, unless somebody cares to take a swipe at writing a shader version. I'd really like one, because I think I have natural-feeling rain here, but it's still not as fast as it should be, imo. Still, this one's good, and it's now set up for use with World Builder- unless I get a better piece of code, this is what will be in the release, as I need to get back to work on P.U.R.E.
[EDIT] Released revision no. 3. No. 2 was buggy, sorry to anybody who wasted their time.[/EDIT]
This is probably my last revision, unless somebody cares to take a swipe at writing a shader version. I'd really like one, because I think I have natural-feeling rain here, but it's still not as fast as it should be, imo. Still, this one's good, and it's now set up for use with World Builder- unless I get a better piece of code, this is what will be in the release, as I need to get back to work on P.U.R.E.
- Attachments
-
- unit_rain3.lua
- Revision 3
- (10.16 KiB) Downloaded 48 times
Re: Weather, Rain
i will post here trepan rain shader gadget.
to make it work, it needs a few image files, you have to make them yourself, i don't know where to find them.
to make it work, it needs a few image files, you have to make them yourself, i don't know where to find them.
- Attachments
-
- precipitation.lua
- (6.81 KiB) Downloaded 33 times
Re: Weather, Rain
Hmm.
It needs to use GL.LINES, like yours does, and to use yours as the fallback method, imo. Lemme see what I can do about all of that, I am not very confident I will be able to figure out the shader stuff, but I'll give it a try.
[EDIT]Ok, I've got it doing lines, but it's doing something funky with scale... dunno how to fix it yet.[/EDIT]
It needs to use GL.LINES, like yours does, and to use yours as the fallback method, imo. Lemme see what I can do about all of that, I am not very confident I will be able to figure out the shader stuff, but I'll give it a try.
[EDIT]Ok, I've got it doing lines, but it's doing something funky with scale... dunno how to fix it yet.[/EDIT]
Re: Weather, Rain
try editing the line:
Code: Select all
local rainScale = 5000
Re: Weather, Rain
No, the problem is that with GL.LINES, it's doing something weird, because of the camera angles, which makes them quit drawing right.
Meh... I'll just use yours with my modifications, the speed hit after setting up the display list isn't that bad anyhow.
Meh... I'll just use yours with my modifications, the speed hit after setting up the display list isn't that bad anyhow.
Re: Weather, Rain
you should remove the text commands for the gadget version, or people will be able to set the gravity to a negative value, and stop the rain.
Re: Weather, Rain
Yeah, I am, among other last-second tweaks...
Re: Weather, Rain
http://www.youtube.com/watch?v=G0Nb-TSMttA vudea with rain and fog widget modified.
Re: Weather, Rain
i will make a new fog effect version soon, it should use a different shape, since i got functions to draw most of the known shapes.
because on some maps the spheres will look clipped, but on others it won't, resulting on a really bad look, or a really good look.
another problem is the density don't looks good at low very smooth alpha values.
argh, are you going to use fog effect widget on that project?
because on some maps the spheres will look clipped, but on others it won't, resulting on a really bad look, or a really good look.
another problem is the density don't looks good at low very smooth alpha values.
argh, are you going to use fog effect widget on that project?
Re: Weather, Rain
I made a setting for the fog widget, that makes the fog look very realistic, without a lot of performance hit, but the problem is that it is that it gets limited to only the white color and alpha.
The problem on the fog widget, is performance and detail, to have a good detail, performance won't be good, to have good performance, detail won't be good.
I think that the sphere drawing function causes those performance issues, my idea is to change the sphere, to a different shape, that looks better, and has less vertex than the current sphere, there are many of them, and i am close to having the functions for drawing them.
The problem on the fog widget, is performance and detail, to have a good detail, performance won't be good, to have good performance, detail won't be good.
I think that the sphere drawing function causes those performance issues, my idea is to change the sphere, to a different shape, that looks better, and has less vertex than the current sphere, there are many of them, and i am close to having the functions for drawing them.
Re: Weather, Rain
in my opinion rain is on its final version for now.
i have an unreleased version of fog and ground fog, both aren't final.
i have the new function for fog almost done, it should be like 5 to 10 times faster.
argh, which of those widgets(or effects) are you going to use on that project?
i have an unreleased version of fog and ground fog, both aren't final.
i have the new function for fog almost done, it should be like 5 to 10 times faster.
argh, which of those widgets(or effects) are you going to use on that project?
Re: Weather, Rain
I'm already using a modified version of the rain Gadget code I posted, with a few tweaks for final feel and polish (for example, I set up multiple display lists, so that you have lots of sets of randomized rain particles, etc.). I am definitely using that, it ran great once I used display lists, and with the tweaks I made in a few other areas... trust me, it's an incredible experience- I've never seen anything like it in a RTS before. I can't thank you enough, for getting it working to the point I could clean it up and make it fast, I know I cut a lot of your code, but you'll see that the results totally justified the changes.
I would like to test your new fog, and see how well it works. I am an idiot, and seem to have broken Trepan's fog, trying to make it a Gadget, and I didn't back it up first (yes, I'm stupid), so if I want fog, I'm going to need either Trepan's code again, and try to make it work as a Gadget again, or your fog.
If it's 10X faster, it may perform well enough that I can just use it instead- I'd like to use your fog if possible on the demo map, after testing it a bit. It ran plenty fast, except when near enough to the ground that the spheres were involved, so I suspect it'll probably be efficient enough.
I would like to test your new fog, and see how well it works. I am an idiot, and seem to have broken Trepan's fog, trying to make it a Gadget, and I didn't back it up first (yes, I'm stupid), so if I want fog, I'm going to need either Trepan's code again, and try to make it work as a Gadget again, or your fog.
If it's 10X faster, it may perform well enough that I can just use it instead- I'd like to use your fog if possible on the demo map, after testing it a bit. It ran plenty fast, except when near enough to the ground that the spheres were involved, so I suspect it'll probably be efficient enough.
Re: Weather, Rain
if you really need trepan ground fog widget, then i will PM you a copy of it.
for the ground fog, my new idea is to use only one display list to draw all the layers.
the problem on both ground fog and fog, is terrain cliping, but i am trying to fix it.
i say it will be that faster, because it will use only 1 begin - end, and less vertex, the current fog sphere is using quads, the new sphere will be using triangles.argh wrote:If it's 10X faster, it may perform well enough that I can just use it instead- I'd like to use your fog if possible on the demo map, after testing it a bit. It ran plenty fast, except when near enough to the ground that the spheres were involved, so I suspect it'll probably be efficient enough.
for the ground fog, my new idea is to use only one display list to draw all the layers.
the problem on both ground fog and fog, is terrain cliping, but i am trying to fix it.
Re: Weather, Rain
If you use a display list, like I did for the changed version of the rain Gadget (it was easy, just look at how I set it up- I only wish GLSL was that simple, but meh, I'm having a lot of trouble with it) it should speed up considerably. Then you can just draw the quads across the whole map all the time, and use 30-40 layers without major problems...
I have an idea about the sphere, though... instead of a sphere, you could use GL.TEXTRECT, and adjust the alpha level according to a height threshold... iow, over Y, don't draw, below Y, draw with alpha growing from nothing to some threshold... it'll be cheap and dirty hax, compared to a truely depth-based treatment, but it should work OK.
The other solution is to do the same thing, but with quads that are transformed so that they're always in front of the camera, for a layered look for superior feel... the quads could be one display list, transformed in one operation, to keep it fast.
It'd probably look better and act better than a sphere, which is a waste, imo, since you're not seeing most of the facets, but you're still drawing them. There's a method in Lua to get the current POV, Spring.GetCameraVectors, which should supply the corners, but I dunno how to do the algorithm for doing each following layer, but you should be able to find that, or something like it, either at Nehe or via Google...
I have an idea about the sphere, though... instead of a sphere, you could use GL.TEXTRECT, and adjust the alpha level according to a height threshold... iow, over Y, don't draw, below Y, draw with alpha growing from nothing to some threshold... it'll be cheap and dirty hax, compared to a truely depth-based treatment, but it should work OK.
The other solution is to do the same thing, but with quads that are transformed so that they're always in front of the camera, for a layered look for superior feel... the quads could be one display list, transformed in one operation, to keep it fast.
It'd probably look better and act better than a sphere, which is a waste, imo, since you're not seeing most of the facets, but you're still drawing them. There's a method in Lua to get the current POV, Spring.GetCameraVectors, which should supply the corners, but I dunno how to do the algorithm for doing each following layer, but you should be able to find that, or something like it, either at Nehe or via Google...