Drawing rain on the screen

Started by TheMagician, Tue 21/11/2006 08:06:27

Previous topic - Next topic

TheMagician

Hi everybody.

I'm programming a small custom rain algorythm (I need some stuff that the plugin can't do).
My problem is: what is the best solution to draw the rain on the screen? RawDraw has the great set of functions but as I see it, there is no way to draw the rain in front of characters or objects?

Overlays don't work because there are too few.

Perhaps Characters?

The ony other possibility I can think of are Dynamic Sprites.

What would you choose?

Many thanks in advance!
Stefan

SSH

For the Simple Rain module, I drew various rain "drops" on some dynamic sprites, then made overlays from those dynamic sprites and moved them down the screen. It means that various drops move in sync, but it is not really noticeable, I think.


http://ssh.me.uk/moddoc/SimpleRain
12

GarageGothic

My way of doing it, which is admittedly somewhat slow, is to clear the background to RGB(255,0,255), rawdraw all particles without translucency, creating a DynamicSprite from the background, restore the background and assigning the DynamicSprite to a near-fullscreen transparent GUI. Alternately you could RawDraw some of the drops directly to the background for a sense of depth (player walks in front of some and behind others).

If CJ would only allow tint/light manipulation of DynamicSprites a (CPU wise) faster solution would be to RawDraw everything to screen based on baselines, including characters and objects.

TheMagician

Thanks for your comments!

SSH, your module is great, but GarageGothic's approach works better for my particular particle system.

A very clever idea to clear the screen to (255,0,255). I didn't know that this color is seen as transparent when you create a dynamic sprite from it.
It works like a charm.
The only question: As you said, the system might be a bit slow (I use 200 particles and a fullscreen GUI in 320x240 resolution). Now, on my new computer I don't notice any slowdowns. Do you think this could be the case with older machines?

Thanks again!
Stefan

GarageGothic

I think at 320x240 you should be fine on most systems. I run in 640x480 (32 bit color) and there the framerate sometimes dips below 35. BTW, the slowdown doesn't come from the number of particles but rather from the fullscreen DynamicSprite, so there's not much you can do to optimize the process.

fovmester

The best way to do it (performance wise) would be to write a plugin. I know that there already is one, but what I always missed in that one, was that the rain was drawn on top of everything. Wouldn't it be nice to be able to have rain that falls at all distances, and so are drawn behind some walkbehinds and objects? I haven't looked closely at the plugin API so I don't know if it is possible to do this, but if it is then it would be great!

Of course you would be sacrificing compatibility with other OS than Win32. But who cares...:o

Janik

I have done this in a plugin but I haven't released it yet. There were a couple of things I was unhappy with ... the snow flakes didn't look right, and it didn't support changing resolutions very well. One nice thing though is that the rain was drawn on so that if there is lateral wind, the rain drops look slanted - it looks good.

If enough people are interested I may finish it for public consumption.
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Candle

Can always use more plugins Janik :)

TheMagician

I'd also have a look at your plugin, Janik  :)

If I remember correctly another issue with the rain plugin was that it always started raining from the top of the screen. So, you couldn't just switch the rain on or off in the entire room ... but that really only was a minor issue.

In the rain module I'm working on for a game right now you can define a region (or regions) which will be used to detect areas where the rain hits the ground which adds a nice effect.
It can also render snow, and that way the snowflake can hit the ground, lie there for a few seconds and slowly melt / fade away  :)


Rui 'Trovatore' Pires

QuoteIf I remember correctly another issue with the rain plugin was that it always started raining from the top of the screen. So, you couldn't just switch the rain on or off in the entire room ... but that really only was a minor issue.

Yeah, that can be seen on a couple of games that use the plugin... but from my own experiments, that was really mis-use of the plugin. It did allow the behaviour you mean.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SMF spam blocked by CleanTalk