Waterfall Shader

Last night while getting my coding feet wet (pun intended) after the long trip away from home, I decided to play with some ideas I had for shader particle effects for rendering waterfalls.



Here are some images I snapped last night of the prototype app running a handful of these water streams:

http://i.imgur.com/cJfkU.png

http://i.imgur.com/Yd13Q.png



And because still shots don’t really show it off that well, here is a video:

http://www.youtube.com/watch?v=2GTrbnF1VuU



The two sets of waterfalls use two different texture atlases as I was playing with different shading. The one on the right is closer to what I want to achieve I think.

The arcing is built into the geometry and not done by the shader. The shader deals with short linear spans and there is a cross-fade the softens the endpoints and allows overlapping. I used a simple differential equation to plot out a few spans into a nice arc.
9 Likes

:o nice!

@pspeed said:
The arcing is built into the geometry and not done by the shader.
So I could make like fountains and such with fair ease as well?

Nice!



How does that translate into a full-fledged Mythruna scene FPS-wise?

1 Like
@erlend_sh said:
So I could make like fountains and such with fair ease as well?


Yeah, sort of. Each "particle" has a direction and a length of time it will fly before starting back at its starting position. (as well as starting size and ending size)... probably if I pointed a stream straight up and had the ending size large enough it would look a little like a small fountain. Otherwise, you'd have to create a bunch of tightly packed arcs pointing nearly straight up and arranged out in a circle.

The larger waterfalls in this test are three "streams" packed together with the center one being larger and the outside ones pointing out a little bit.
@madjack said:
Nice!

How does that translate into a full-fledged Mythruna scene FPS-wise?


I don't know. I haven't tried it over there.

It's a similar effect to what I use for the flames except there are more point sprites in this case and they tend to be larger. The size of the point sprite definitely affects performance.

However, because the geometry is static, it should be nicer on bus-limited hardware than a standard CPU particle effect would be... and I believe this one is general enough to apply to a few different cases (I may try mist at the waterfall base soon). And smoke is another easy one.

BTW, I’ve packaged this prototype into an exe… will be uploading it soon for others to try it.

Here are some download links if anyone wants to try it out:

http://mythruna.com/distros/proto/ParticleTest-20120331-Windows.zip

http://mythruna.com/distros/proto/ParticleTest-20120331-MacOSX.zip

http://mythruna.com/distros/proto/ParticleTest-20120331-Linux.zip



Especially Mac users to see if I forgot a decimal point somewhere. :wink:

Note: I also have not batched the different “stream parts” which is totally doable… I was just lazy. They all share the same material and do not care if they are batched or not.

Can some more Mac users, or AMD Radeon HD 6770M users, test it? On my Mac, the size of the point sprites doesn’t scale well, so the closer I come, the better I see individual sprites, which breaks the illusion. Only from far away it looks like in the screen shots.

kewl!!!