Running water, early video

I think I know how to merge meshes from several branches now as well. I introduced a “mesh segment” class, that keeps track of all the vert locations.

I had a look at your video and I’m not sure the steep drop in the water that you were looking at is a problem. After all rapids/mini waterfalls/whatever are a common feature of rivers. The key is to texture/flow/etc it appropriately there to show it appropriately.



The bit where they got tangled up is more likely to be a problem but I’d actually wait and see what it looks like before you worry - again eddies etc are a common feature on rivers so it may not actually look bad.

This is a cool effect (GPU intensive though)

http://www.gamedev.net/blog/1323/entry-2254101-real-time-local-reflections/



Crysis uses something like this on their water. (In some of the higher graphic settings).

http://www.youtube.com/watch?v=0VrSXAHbCYk



I’m going to try a implementation of this sometime this summer… (yeah I like screen space stuff :P)

@kwando

Really good, thank you. This is exactly the kind of stuff I’m looking for.



@zarch

Yeah I am working on implementing that algorithm now. Looks like it could work. That would remove the folding. As you say, the drops should perhaps be there. Gonna see how it looks before start messing with the heights.

This is what happens with flowmaps when the rivers make too sharp turns.



This is an un-processed map, so it will be evened out a bit more, but you can see what happens to it.



http://www.jamtlandoutdoors.se/images/dist/flowmap_too_sharp.png



EDIT:



Here’s one from a better river:



http://www.jamtlandoutdoors.se/images/dist/flowmap_just_right.png

Just looked at that crysis video and some of the linked ones. What an awesome looking game.



Some new stuff from the shading.



http://www.youtube.com/watch?v=cuWR5wAOdm0

7 Likes

Gonna be possible to do some fun stuff with this.



http://www.jamtlandoutdoors.se/images/dist/river_uphill.png

2 Likes

There’s support for obstacles in the flowmap now. I have been working on the fluid sim as well. Right now the flow vectors are calculated from the graph direction first, then processed again. The processing takes place on a grid and vectors are displaced if the water something is blocking its path. This part I was gonna wait with, but its better to get it over with right away.



The shading is looking better too. I displace the environment map now by distorting the reflection vector just as the projective coordinates are displaced for refraction. I use normal.xyz for the reflection vector and it seems to work fairly well.



Gonna add the mesh normals next (just using normal (0,1,0) now, hence the sharp angles in the picture above).



Been playing around with the idea of using a displacement map later, to make the water look even more real. This could be a high quality alternative. First a couple of extra loops would be added to the mesh (in the running direction), to make it more grid-like, then those would be displaced from inside the shader. This would use vertex texture fetches for lower opengl versions, so it wouldn’t work with old cards. The mesh could just be tesselated with 4.0+ I guess.

2 Likes

Sounds good!

A new video, but it’s a bit old. Took ages for Youtube to process.



- YouTube




Here's the 32x32 flowmap used in the vid (tho I scaled it up to make it show more).

Red is packed X-direction flow (-1,1)

Green is packed Y-direction flow (-1,1)

Blue is relative depth (0,1).

http://www.jamtlandoutdoors.se/images/dist/TestFlowmap.png

EDIT: Embed doesn't seem to work with this vid. Not sure why.
2 Likes

It look more than just OK, as you put it. Its already total awesomeness :slight_smile:



Cant wait to see the “drop” effect you refer to in the vid. But I would use it, as it is now, ofc, it would be better if you work more on it. Cool project.



And. btw. I think you cant embed unlisted videos.

@androlo said:
EDIT: Embed doesn't seem to work with this vid. Not sure why.

You've set the clip as "private" on youtube, that's why the embed does not work

Just saw your video, I think it's going to awesome when it's done :)

Can one sample the flow map in application code? Say I want to add a boat that should just float on the river :)

@kwando

Yes I want that because I want to make fishing possible, so the bobber will be moving with the stream. Maybe just store the flow vector arrays with the river mesh in a j3o objects or something. Put all the data in one place.





Made some new changes btw. all. Wave size is now depent on the running speed of the water (normal is multiplied by this value). This looks more real and it reduces the “blocky stretching” I think happens when tiles right next to eachother has a big difference in speed.



I also added vertex colors depending on the direction of the mesh normal, so that water running downwards becomes more white. This is just one step towards the turbulence stuff. Been analyzing skyrim water for this purpose (their running water looks great in my opinion).



I also added the volume flow param now. This means for example that water will run faster through a narrow passage, and slower where the river is wide.



Gonna put up a new video later, when reflection/refraction works. I set up a google page already, gonna start putting code there very soon.

I know how to deal with refraction now. Gonna do it like they do in this article (but without the outgoing stuff): link.



EDIT: Damn this screen space stuff would be so much easier with deferred rendering. Sure could use a normal buffer for this.

Running water is great video picture quality and water movement is really very lively. I like your creation.

1 Like

Been working on refraction and reflection, and I think it’s good enough for now. I am dealing with water color next.



Water color, or water discoloration to be more exact, is caused by particles and stuff in the water, and by minerals, salt contents etc. This will be treated like in simplewater tho, by using the depth buffer from the refraction scene rendering, and a fog term. A ray is cast from the camera through the pixel and to the depth buffer value. I haven’t added any real refraction (bending of this ray) because that is very hard to even notice. The water is moving too much. Instead the refraction texture is just preturbed by the wave normals (a common method), so it’s a fake sort of refraction.



The depth buffer is already available, but to calculate optical depth I need to calculate how far the camera ray travels through water, and not how far it travels in total. This is done by intersecting it at the water surface. There’s a method to get the 0->1 depth value in the simplewater shader, but I need to get this all into world space (or at least screen space), not clip space as it is now.



It’s not that complicated, but i’m not good at screen/clip space stuff. Gonna take some time.



Btw, again, it’s gonna be possible to make some pretty fun stuff with this system.



http://www.jamtlandoutdoors.se/images/dist/weird_water.png

5 Likes
@aadamgibson said:
Running water is great video picture quality and water movement is really very lively. I like your creation.

Thanks
1 Like

Incredible!

Finally got the flowsim stuff together. I mentioned in the last vid there is a problem. It turned out it wasn’t the flow simulator, it was in a previous step. I was rotating some coordinates wrong when adding the initial flow vectors from the river curve tangents.



Anyways, it works now. Moving on. Next I got to make the flowmap match the mesh a little better (something is wrong with the texture coordinate scaling).

The writing of initial flow values (based on the river curve tangent) is finally finished…



The method used a rectangular area around each point on the river curve (an ordinary nested for loop) and sampled all points in that area, then rotated them based on river direction, then wrote them to the array. This caused a bunch of points to be skipped because of floats being converted to ints.



Here’s a picture of how it could look before (before processing). Note especially how it affects diagonal parts where there is basically no overlapping from frames with other rotations.



http://www.jamtlandoutdoors.se/images/dist/bad_flowmap.png



I added some dithering now, and it works perfectly. Here’s an image of how it looks now (before processing).



http://www.jamtlandoutdoors.se/images/dist/good_flowmap.png



Btw. what happens near the edges are no problem since they are culled anyways in the flowsim step. Also there are lots of smoothing taking place after these images are created, but too much color errors initially caused a visible bias in the flow direction. That bias is completely gone now.

3 Likes