River using the PostProcessWater(ocean/lake)

Hello everyone I am currently in a bad position. I m trying to make a river in my game using the Post Process Water but first it doesn’t support polygonal form and second it need to be able to support the Y(height) render. SO if my river is in a small downhill it would render lower and lower to follow the height I ve given to the Polygonal form (Using Vector3f if possible).

Actually I’m asking if anyone did something similar and would like to share it code for the Shaders and an exemple how to set it up ^^. I know i should probably start to learn how to do shader but it quite long and i don’t have the brain set on learn this since I m quite lazy xD.

Note: every different y level means a different reflection rendering.

I would have no idea how to implement this (or even the specifics of the math involved), but, to anyone who does a possible method for doing it could be to transform the entire 3D world by some number of degrees (in ram, not in the final render) such that the angled water plane becomes horizontal in relation to the rotated world. Then, as it renders, refer to the rotated world (or rotate individual parts of it during render to save on memory) rather than the unrotated world.

Alright so this is no simple mater, then the first solution would be to make a geometry instead? I don’t mind not having reflection since reflection are quite rare in river water(since they move a lot it become blurry). But if it s too hard to implements any kind of post process because of the angle, I will use a plane with animated texture instead.

Thank you for the tip.

It might make more sense to look into having some particles flow in the direction of the water to give a 3D look rather than a simple flat plane.

If it were me… I’d have a strip of triangles form the river’s course where the y texture coordinates roughly maps to distance along the river and x maps to river width. Then animate a texture by offsetting y by time. The texture would include bump/normal maps, etc… The nice thing about this approach is that if you are clever modeler then you can tweak the texture coordinates to have the texture widen and narrow, flow faster in some places than others, etc… By adding a little variance in the y texture offsets you can even avoid having it look like just a texture sliding along a river.

Particle effects are also good anywhere you’d want to simulate rougher water like around rocks and stuff,

For really advanced effects, tessellate the river triangles more and animate some of the vertexes up and down a bit.

Or maybe just use a cubemap for the reflection (like in Serious Sam 2). Of course, add some normal perturbance and maybe some other shader tricks. The tesselated and animated triangles can look interesting - I’ve seen such things 10 years before on hardware that today is ancient. Since vertex operations are almost free and number of triangles is only still relevant on mobile devices, this might look quite good. One might also try to (mis)use parallax mapping or one of its advanced modifications…

@John01dav: i ve though of doing a particle water system, but particle are expensive.

@pspeed: I cant do the model my self, it will be procedural depending on the map generated. I m not quite good with generating triangle my self but the the idea I had in mind was this one(but the moving pixel for animation). I could probably give it a try again and base the bump map of the texture under the river.

@Ogli: I will ignore the reflection map for now, since it quite a lot of work. But as you said I will give a try on making @pspeed idea for now!

IF it turn out correctly and the engine it self need a river system i will do my best to make the code portable and easy to implement for future user. It will be implemented to work with the actual Heighmap.

@androlo did a bunch of work on a flowing river system thing, I only have vague memories of it as it wasn’t something I needed, so I never looked deep into his work much, possible a good starting point.

well the post process water was not designed for that and you’ll have to hack it around to make it work for that use case… and for a bad result.

@pspeed approach sounds pretty good.

Hi,
have a look at http://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf or Screen Space Fluids Paper.
I already implemented this using OpenCL and DirectX with C++, I will port this to jME3, as part of my OpenCL-library (see OpenCL for jME3 ).

This is how it looks in my implementation (reflections are still missing):

4 Likes

You are awesome .
So can we have such great scene with water in JME in real time !?:open_mouth:

I am encouraged to learn those stuffs …:yum:

1 Like

nice, i’ve read that paper countless times now, good work with your implementation, probably a tad overkill for OP’s requirements :wink:

I don’t mean to be a buzz kill, but a) that looks like total ass, and b) this kind of tech is next to useless in a game dev environment, unless one is making a fluid sim based game like Mercury Meltdown or the countless falling sand style games.

My first goal would have been particle fluid with physic but the problem here is it need to be started else my river wont have fluid until the fluid arrive each time you move in the infinite map.

But i have to say I m quite impress with the result you got. It should probably be part of the engine!

Well, in my opinion, the engine needs LESS things and more plugins. It’s already too bloated with crap that no one maintains.

1 Like

Product is about saying no :slight_smile: Something I have to fight for every single work day

You could also try to use the “projected grid water” from jME 2. Someone had ported it to jME 3. That water uses a dynamic mesh and you can define height points. Problem with the reflection map remains (again, I recommend a cubemap - a pre-rendered one which captures the overall characteristics of the scene).

Yes, you are right. It only runs at approx. 20 FPS and nothing else is included except the water simulation.

Maybe this would be another possible solution:

Source and description is here: http://vterrain.org/Water/

2 Likes