OgreWater

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

syedhs wrote: 1) Reflection is not following the water wave ie terrain is reflected on the water as if the water is super-cool or not moving at all..
Because there are no waves, it's all just one big plane. ;)

I have a projected grid test working, that has real geometry. However, it's just flatshaded still and need some work before it can be released. But sadly, my time is quite limited at the moment. :(
syedhs wrote: 2) Quite minor I must say.. if anti aliasing factor is set to 8 for an example, reflection image is not AA-ed.
Render textures can't be anti-aliased, afaik (unless you do it yourself in a shader?)
User avatar
thebluefish
Gremlin
Posts: 170
Joined: Tue Apr 05, 2011 1:55 am
x 10

Re: OgreWater

Post by thebluefish »

lingfors wrote:
syedhs wrote:
syedhs wrote: 2) Quite minor I must say.. if anti aliasing factor is set to 8 for an example, reflection image is not AA-ed.
Render textures can't be anti-aliased, afaik (unless you do it yourself in a shader?)
It *can* be done, but it isn't a pretty pipeline to work with. Essentially you'd need to render to back buffer then copy that to your texture. All Anti-Aliasing will be applied to the texture, though I haven't found a good way to organize this outside of a small tech demo.
During the code inspection, a couple of minor points were noticed: -

Function inlining was critical to performance.
For MSVC, at least, a "delete 0" caused execution of 11 assembly instructions, including a function call. So in cases where performance is at an absolute premium it can be worth inserting the extra manual test.
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

Just a small video showing what I've been up to lately:

This water is based on Tessendorf's paper, and uses Cuda (through OgreCuda) to do all the work (projected grid, FFTs, normal image, etc.) on the GPU.

The shader is still a work in progress...

User avatar
DavlexDesign
Orc
Posts: 400
Joined: Thu Apr 23, 2009 7:23 am
Location: Australia
x 19

Re: OgreWater

Post by DavlexDesign »

Very nice mate, Like your work.

Alex
User avatar
OpenMW
Halfling
Posts: 48
Joined: Thu Feb 09, 2012 7:40 pm
x 65

Re: OgreWater

Post by OpenMW »

That is beautiful work. If only the ground looked wet after the water passed over it, it'd be hard to tell it was cg.
OpenMW is an ambitious project and with your help we can help make it a reality. To join us head over to http://openmw.org/forum/ and register, announce yourself to the team and grab a coding assignment.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136

Re: OgreWater

Post by spacegaier »

OpenMW wrote:That is beautiful work. If only the ground looked wet after the water passed over it, it'd be hard to tell it was cg.
Yes, I thought the same in regards to the rock on the right side that from time to time is above the water line. Some sort of water residue / wet look and perhaps (not sure if that would happen in reality) but some wrinkles or such on the last inches where water touches the rock, because I imagine that the water gets a bit "compressed" there due to the near rock, resulting in some sort of small waves. Hard to articulate with words right now ;) .

But overall: Looking great!
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Shtuka
Greenskin
Posts: 146
Joined: Mon Jan 10, 2011 7:39 pm
x 9

Re: OgreWater

Post by Shtuka »

Do you provide source code?
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: OgreWater

Post by scrawl »

he posted it some pages before:

https://bitbucket.org/lingfors/ogrewater/

although it doesn't seem to be updated, last update is somewhere in 2011.
Alexiss
Halfling
Posts: 74
Joined: Wed Aug 10, 2011 2:11 pm
x 11

Re: OgreWater

Post by Alexiss »

Awesome, like usual. I was recently wondering if you had any plan on adding more features to OgreWater, I suppose I got my answer !
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

Source code will be provided under MIT license once I've had some time to clean up the code.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: OgreWater

Post by syedhs »

Look very nice.. how is the FPS? I imagined using CUDA would not cause much burden on CPU.. :)
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: OgreWater

Post by Beauty »

Very nice water simulation. :D
lingfors wrote:uses Cuda (through OgreCuda)
As far as I know CUDA is only supported on newer NVidia cards.
What happens when a user has an AMD card or an older nVidia card without CUDA support?

lingfors wrote:I assume you've found how to change reflection/refraction etc? Otherwise:

Image
Your visualisation looks great and would be fine for my underwater simulation application.
Do you still have the configuration settings on your PC?

It would be nice if your demo offers the possebility to adjust reflection, refraction and other options.
(Perhaps you still added this options. I don't remember, because my demo test is many months ago.)

Also an other possebility would be fine:
Store all options in a config file, which can be loaded. (e.g. the Caelum add-on offers this option)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

Beauty wrote: As far as I know CUDA is only supported on newer NVidia cards.
What happens when a user has an AMD card or an older nVidia card without CUDA support?
I guess there would have to be some kind of fallback. Perhaps the algorithm could also be implemented in OpenCL or DirectX compute shaders, if there are FFT implementations for them.

Otherwise the same algorithm is also implemented on the CPU (through fftw), but the quality would obviously have to be much lower.

The projected grid could probably be ported to hlsl/glsl instead of Cuda.
Beauty wrote: Your visualisation looks great and would be fine for my underwater simulation application.
Do you still have the configuration settings on your PC?
No, but it's fairly easy to find a setting that looks good.
Beauty wrote: It would be nice if your demo offers the possebility to adjust reflection, refraction and other options.
(Perhaps you still added this options. I don't remember, because my demo test is many months ago.)
Yes, this will be in the demo, and the library supports changing these settings in real time also.
Beauty wrote: Also an other possebility would be fine:
Store all options in a config file, which can be loaded. (e.g. the Caelum add-on offers this option)
Good suggestion, I will look into exporting/importing settings from disk.
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

syedhs wrote:Look very nice.. how is the FPS? I imagined using CUDA would not cause much burden on CPU.. :)
I get ~50FPS for this demo (Intel Core 2 Quad, GTX 560Ti).
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

After being disappointed in how bad "faked" reflection looks when not using a planar water surface, I went ahead and implemented screenspace raytracing:



It was inspired by this video showcasing the new CryEngine, but the implementation is my own.

The implementation is quite simple:

The scene is first rendered without the water to two textures - one containing the actual colors, the other containing the depth info (in a FLOAT_R32 texture).
The scene is then rendered again to the screen, this time with the water.
The water is rendered with a shader, where the magic happens:

In the fragment shader, the geometry position together with the water normal at that position is used to calculate a reflected ray, i.e. the reflection direction.
Steps are then taken along this reflection direction.
For each step, the new position is projected back onto the screen.
This new screen position is used to look up the scene depth at that location.
If the distance between the camera and the position along the reflected ray is greater than the value in the depth buffer, the ray has hit terrain. We then use the screen position to look up the color from the color texture.

Of course, there are some issues, as can be seen in the video, as well as a significant cost (my framerates dropped from 50 FPS to 30 FPS). Mind you, the shader is not optimized yet, but it's unlikely it will be possible to get it back to 50 FPS by shader optimization alone, at least not without losing too much quality in the reflections...

Anyways, feel free to leave your comments.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136

Re: OgreWater

Post by spacegaier »

Looking really good! The only two things I can think of right now that are still missing to make it even better:

Some sort of turbulence around the water borders (where it hits the rocks) and possibly some residue after the water has moved back after each wave giving them impression of the rock being wet (perhaps some specular elements on the rocks that fade out afterwards?).
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: OgreWater

Post by Beauty »

lingfors wrote:It was inspired by this video showcasing the new CryEngine, but the implementation is my own.
It's a 30 minute video. So I avoid watching until today. Now I watched it and it's very impressive. Especially how easy it is to create and modify a scene.
Thanks for pointing to this video. :D
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: OgreWater

Post by scrawl »

Your newest video is very impressive. Congratulations!

A question about your screenspace raycasting technique: It uses the screen colors for reflection, so it's not possible to reflect objects that are not on the screen?
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

scrawl wrote:A question about your screenspace raycasting technique: It uses the screen colors for reflection, so it's not possible to reflect objects that are not on the screen?
Correct.
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: OgreWater

Post by al2950 »

lingfors wrote:After being disappointed in how bad "faked" reflection looks when not using a planar water surface, I went ahead and implemented screenspace raytracing:
That looks phenomenal! I have always thought of doing something similar to this but have never really known where to start! Keep up the good work, looking forward to checking out you code :D
themean
Greenskin
Posts: 104
Joined: Wed Feb 29, 2012 11:50 am
x 1

Re: OgreWater

Post by themean »

@lingfors
Great avatar :)
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

themean wrote:@lingfors
Great avatar :)
Thanks, it was a reaction to the cat avatar invasion of April 1st... ;)
User avatar
alberts
Gremlin
Posts: 177
Joined: Fri Mar 31, 2006 8:43 am
Location: Granada-Cádiz-Jaén, Spain
x 20

Re: OgreWater

Post by alberts »

I’m trying to incorporate this to my project but I’m having some problems. I think it is a problem related to viewports but I cannot find the error.

Code: Select all

OgreWater::Water* w = new OgreWater::Water(SIM->getRenderWindow(), mSceneManager
					, SIM->getCameraControlSytem()->getOgreCamera());
				w->setWaterDustEnabled(true);
				//w->setAirBubblesEnabled(true);
				w->init();
				w->setWaterHeight(0.0);

I have disabled all of the components that could interfere with OgreWater (SkyX, PagedGeometries…) but the problem still persists. There is no errors in the log.
Does anyone know what the problem could be?

Thanks a lot in advance,
Alberto

User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: OgreWater

Post by lingfors »

Sorry for not answering earlier, been really busy...

Without seeing all your code, it's very hard to say exactly what is going wrong... But part of the problem seems to be that the OgreWater camera(s) aren't updated correctly, i.e. copying the position/orientation of the camera you send in.

I just had a look at the code, and it seems that I'm using getPosition/getOrientation instead of getDerivedPosition/getDerivedOrientation... When you control your camera, do you set the camera's position/orientation, or do you set the position/orientation of a node (or a node hierarchy) to which you have attached the camera?
User avatar
alberts
Gremlin
Posts: 177
Joined: Fri Mar 31, 2006 8:43 am
Location: Granada-Cádiz-Jaén, Spain
x 20

Re: OgreWater

Post by alberts »

lingfors wrote:Sorry for not answering earlier, been really busy...
Thanks Lingfors. Don’t worry. I neither haven’t had time to work on this.
lingfors wrote:I just had a look at the code, and it seems that I'm using getPosition/getOrientation instead of getDerivedPosition/getDerivedOrientation... When you control your camera, do you set the camera's position/orientation, or do you set the position/orientation of a node (or a node hierarchy) to which you have attached the camera?
I’m using CCS to deal with cameras (a subproject I released some time ago). The camera is always attached to a node although the actual node hierarchy depends on the selected camera mode. I’ve tried some of them but the problem is still there. The position/orientation of the camera is set by adjusting the position/orientation of a node.

I’m going to disable CCS to confirm the problem is realated to it. I’ll maintain you informed :) .