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: 505
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden

OgreWater

Post by lingfors » Thu Feb 10, 2011 8:21 am

Pulled an all-nighter, and here is the result:

[youtube]KYNoS-so8bI[/youtube]

It's for a course in Computer Graphics at uni, so I'm going to hold on to the source until after the presentation. After that I will hopefully release it.
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: OgreWater

Post by jacmoe » Thu Feb 10, 2011 8:42 am

Awesome! :)
Looking forward to seeing more of it.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland

Re: OgreWater

Post by so0os » Thu Feb 10, 2011 9:00 am

Awesome! I hope it's lightweightier than Hydrax, and if so, I'm looking forward to hijacking your source :P

Best of luck!
0 x
Sos Sosowski :)
http://www.sos.gd

User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
Contact:

Re: OgreWater

Post by Beauty » Thu Feb 10, 2011 5:53 pm

Is this your own water simulation or did you use an add-on like Hydrax, Editable Terrain Manager, etc.?
0 x
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: 505
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden

Re: OgreWater

Post by lingfors » Thu Feb 10, 2011 8:17 pm

Beauty wrote:Is this your own water simulation or did you use an add-on like Hydrax, Editable Terrain Manager, etc.?
I wouldn't post it here if it was just a compilation of other people's work. So to answer your question, yes, I've written all the water code. The terrain is the standard Ogre 1.7 terrain.
0 x

User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
Contact:

Re: OgreWater

Post by Beauty » Thu Feb 10, 2011 8:57 pm

The video is nice, but more we don't know.
Unfortunately you didn't tell any detail of your application.
So there was the possible case that your application has an unknown aim and the water is just for scene beautification.
I don't know anything, so I just asked.
I'm always interested to read more about Ogre applications. :wink:
0 x
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
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4293
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 2
Contact:

Re: OgreWater

Post by spacegaier » Thu Feb 10, 2011 9:00 pm

lingfors wrote:
Beauty wrote:Is this your own water simulation or did you use an add-on like Hydrax, Editable Terrain Manager, etc.?
I wouldn't post it here if it was just a compilation of other people's work. So to answer your question, yes, I've written all the water code. The terrain is the standard Ogre 1.7 terrain.
That sounds interesting. Looking forward to hear more, once you held your presentation :) .
0 x
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
lingfors
Hobgoblin
Posts: 505
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden

Re: OgreWater

Post by lingfors » Thu Feb 10, 2011 9:08 pm

Beauty wrote:The video is nice, but more we don't know.
Unfortunately you didn't tell any detail of your application.
So there was the possible case that your application has an unknown aim and the water is just for scene beautification.
I don't know anything, so I just asked.
I'm always interested to read more about Ogre applications. :wink:
I understand, but I find it hard to figure out what to write... Ask, and I will answer. :)

I can say as much as currently it's just above surface reflection/refraction with Fresnel and some specular on top... But I plan to implement caustics and below surface rendering as well. Oh, and hopefully to make it a package that is fairly easy to integrate into existing projects... Right now, it's fairly poorly organized, everything is in my standard "Application" class, but it shouldn't be that hard to restructure.
0 x

User avatar
Zonder
Ogre Magi
Posts: 1133
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 22

Re: OgreWater

Post by Zonder » Fri Feb 11, 2011 10:05 pm

Looks great took a few days to see it youtube blocked at work:(

What type of water are you going to simulate? for instance hydrax is aimed at large open bodies of water. Will you be filling the gap a bit with doing lakes and ponds?

Keep up the good work :)
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...

User avatar
rafa.gdev
Halfling
Posts: 56
Joined: Mon Apr 14, 2008 10:10 pm
Location: Belo Horizonte, Brazil

Re: OgreWater

Post by rafa.gdev » Sun Feb 13, 2011 8:11 am

That's really cool, looking forward for a release! =D
0 x

User avatar
Slappy
Bronze Sponsor
Bronze Sponsor
Posts: 139
Joined: Fri Sep 28, 2007 8:30 pm
Location: Slovakia

Re: OgreWater

Post by Slappy » Sun Feb 13, 2011 8:45 am

This look really promising, but I hope it will be more easy to use.....
GL with it!
0 x
Cool looking Graphical Installers in NSIS and Inno Setup: http://www.graphical-installer.com - FREE for Ogre projects
I offer NSIS/Inno Setup scripting, C/C++/C#/Delphi programming: http://www.unsigned.sk
Develop NSIS/Inno Setup projects directly in Visual Studio 2005-2015: http://www.visual-installer.com/
or RAD Studio 2009-XE8: http://www.rad-installer.com/

User avatar
Pyritie
Gnome
Posts: 363
Joined: Wed Feb 25, 2009 6:15 pm
Location: UK
Contact:

Re: OgreWater

Post by Pyritie » Mon Feb 14, 2011 9:36 pm

looks damn pretty

how intensive is it?
0 x
I use Mogre, BulletSharp, LuaNetInterface, irrKlang, and Miyagi! | Ponykart (Showcase)
Image

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

Re: OgreWater

Post by lingfors » Mon Feb 14, 2011 10:06 pm

Wow, just noticed this project made the front news. That's as good as any motivation to keep me working on this. :)
Pyritie wrote:looks damn pretty

how intensive is it?
FPS is around 300-350 on my computer (Core 2 Quad, 4GB memory, GTX 460).
0 x

cyrfer
Orc
Posts: 424
Joined: Wed Aug 01, 2007 8:13 pm
Location: Venice, CA, USA
x 2

Re: OgreWater

Post by cyrfer » Mon Feb 14, 2011 10:50 pm

It looks very nice.

Is the wave simulation done on CPU, GPU, or both?

How do you get reflection with the full scene? I assume you bake to some kind of texture. Will you explain this?
0 x

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

Re: OgreWater

Post by lingfors » Mon Feb 14, 2011 11:38 pm

cyrfer wrote:It looks very nice.

Is the wave simulation done on CPU, GPU, or both?

How do you get reflection with the full scene? I assume you bake to some kind of texture. Will you explain this?
Sure, I'll explain it. It's pretty simple.

At the moment, the water is just a simple plane. No real geometry yet, in other words, although I plan to try to implement that too.

For each frame, I render 4 textures: A refraction texture (everything underneath the water plane), a refraction depth texture (distance from camera for everything underneath the water plane), a reflection texture (everything above the water plane rendered from a camera that is placed at the "reflected" camera position) and a reflection depth texture.

Then it's simply a matter of doing texture lookups using the screen coordinates as texture coordinates. Combine this with some normal map magic, and you get specular highlights and "distorted" reflections/refractions.

Well, that's what I have so far. On the Todo-list is real geometry, "proper" refraction i.e. terrain (and other geometry) underneath the water looks more shallow than it really is, caustics and underwater rendering.
0 x

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

Re: OgreWater

Post by lingfors » Tue Feb 15, 2011 5:57 am

Bleh.

Tried to implement nice below surface rendering... Rendering the surface wasn't too hard, just some quick modifications to the shaders and some c++ code to check if the camera is above or below the water surface and then modify some stuff based on that.

Rendering everything that is below the surface (such as terrain) when the camera is below the surface, however... What a mess. Basically, what I tried was writing a custom material that just adds some fog in the correct color, then add this material as a new pass (so that it works with little or no modification to existing materials and shaders) to every object that is being rendered if we are below the surface. After ironing out some bugs (such as make sure that we only add this pass once, or making sure this pass is only used when we render to the screen), it worked pretty good.

Except for one thing - geometry far away from the camera had some serious z-fighting issues. And some geometry (I'm looking at you, new Ogre terrain) didn't seem to render this new pass at all in some cases.

I tried fiddling with the depth_bias variable, but to no avail.

It looks like I'm going to have to use some kind of post-processing effect if I want to be able to render nice below surface scenes. Which I really don't want to do... I already have 4 render passes before the scene is rendered to the screen. If I do this as a post-processing effect, I will probably need 2 new render passes. It feels like overkill, tbh... Although doing it as a post-processing effect will probably enable some other nice effects as well, like DOF and god rays.
0 x

User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland

Re: OgreWater

Post by so0os » Tue Feb 15, 2011 9:02 am

I suppose you need to set up Render Queue Groups so that water renders last.
0 x
Sos Sosowski :)
http://www.sos.gd

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

Re: OgreWater

Post by lingfors » Tue Feb 15, 2011 9:20 am

so0os wrote:I suppose you need to set up Render Queue Groups so that water renders last.
Uhm... What?
0 x

User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland

Re: OgreWater

Post by so0os » Tue Feb 15, 2011 10:39 am

Code: Select all

mTerrainEntity->setRenderQueueGroup(RNEDER_QUEUE_5);
mWaterEntity->setRenderQueueGroup(RNEDER_QUEUE_9);
This way water will be rendered after terrain, and will not 'accidentally' cover it, not displaying stuff beneath.
0 x
Sos Sosowski :)
http://www.sos.gd

SamJ
Halfling
Posts: 40
Joined: Tue Jan 25, 2011 9:12 pm

Re: OgreWater

Post by SamJ » Sat Feb 26, 2011 11:18 pm

Sorry to pester, but any update on the plans to release the source code of this? It looks amazing btw.
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: OgreWater

Post by jacmoe » Sat Feb 26, 2011 11:28 pm

Read the first post, Sam. :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

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

Re: OgreWater

Post by lingfors » Sat Feb 26, 2011 11:31 pm

I plan to release it, yes. But not yet.

I'm working on below surface rendering now. Expect a video some time next week...
0 x

litterbug23
Gnoblar
Posts: 24
Joined: Mon Sep 21, 2009 9:27 am

Re: OgreWater

Post by litterbug23 » Fri Mar 11, 2011 2:39 pm

very nice,good work!
wait for release detial method
0 x

litterbug23
Gnoblar
Posts: 24
Joined: Mon Sep 21, 2009 9:27 am

Re: OgreWater

Post by litterbug23 » Wed Mar 23, 2011 11:01 am

wait source code,or doc
0 x

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

Re: OgreWater

Post by lingfors » Wed Apr 20, 2011 2:16 pm

New video:

[youtube]FxF6HtfU4po[/youtube]

(You might have to wait a little bit, YouTube is processing it...

As you can see, I know have real, animated geometry done. The lighting is a little wonky though... Also, reflection/refraction amount as well as the water clarity and color is fully configurable during run-time. At last, below-surface rendering.

Also, as you can see there are quite a number of artifacts in the water when rendered from above the surface. These are caused by the skirts of the terrain. (For those of you that don't know, these skirts are used to cover up the cracks in the terrain, and are usually not noticeable when the terrain is watched from above.) Since the reflection is rendered from a camera below the surface and the custom near clipping plane must be quite a bit offset from the base water level due to the water geometry, these skirts are now quite noticeable. They could be seen before also, but to a much smaller extent since the custom near clipping plane was only offset by a unit or two.

I believe the problem could be fixed by using a "near Z-buffer", i.e. by rendering only the water mesh to a depth texture, and then use this texture to discard pixels that are too close. However, this would have to be done in a shader, and for every material that is rendered. Since I want this water to be as easy to plug into existing projects, this is something I really want to avoid. I wish it was possible to the rendering in two passes, the first pass simply does the "near-Z-buffer" check, and the second pass only renders if the first pass passed... But afaik, this is not possible... But if I'm wrong, I would be very grateful if someone could correct me!

Otherwise, I guess I have to leave in an option to let the user choose if they want real geometry, or a flat mesh with distorted normals only...
0 x

Post Reply