Realistic water scene node

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
catafest
Posts: 2
Joined: Fri Jan 15, 2010 3:18 pm
Contact:

Re: Realistic water scene node (updated)

Post by catafest »

I try to use your class ...
I got this :

Code: Select all

High level shader materials not available ( yet) in this driver, sorry 
Can you tell me what is wrong ?
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: Realistic water scene node (updated)

Post by shadowslair »

Maybe your machine is ancient or your drivers are obsolete as it`s not supporting shaders.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: Realistic water scene node (updated)

Post by polylux »

As the msg suggests you use a driver that doesn't support shaders. I assume you use the software renderer. Change to OpenGL, D3D and the like.
Furthermore (and generally) provide more information than "It's not working, what's wrong?", makes it all easier to help.

p.
beer->setMotivationCallback(this);
atul
Posts: 1
Joined: Mon Aug 15, 2011 9:16 pm

Re: Realistic water scene node (updated)

Post by atul »

Great scene node, I've just noticed one minor issue: in the OnAnimate method of the RealisticWaterSceneNode class the position of _camera (the camera from which the reflection will be rendered) is calculated in terms of the relative position of the current active camera, but shouldn't this be the absolute position of the current active camera, especially considering that the targets of the cameras are always given in absolute coordinates? This was giving me trouble because I had a camera set up as a child of a mesh and the reflections were looking very strange.

So in short the following line of code

Code: Select all

core::vector3df position = currentCamera->getPosition();
should be changed to

Code: Select all

core::vector3df position = currentCamera->getAbsolutePosition();
nman
Posts: 1
Joined: Wed Aug 24, 2011 5:32 pm

Re: Realistic water scene node (updated)

Post by nman »

i am newbie in irrlicht, today i have been successfully create transparent water effect for lake or river with opengl but nothing object reflection effect. This my screenshoot below. Can anyone help me to add the reflection effect?
Image
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

Re: Realistic water scene node (updated)

Post by Donner »

All the links seem to be dead... can someone post the latest version?
Thanks ;)
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Re: Realistic water scene node (updated)

Post by elvman »

Sorry, server is down for maintenance. It will be up in 2 days.
Ouzel – 2D game engine
Realistic water node
SGH
Posts: 13
Joined: Wed Aug 24, 2011 2:53 pm

Re: Realistic water scene node (updated)

Post by SGH »

Maybe a bit more than 2 days... o.O
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Re: Realistic water scene node

Post by elvman »

Finally changed the URL of the scene node. Sorry!
Ouzel – 2D game engine
Realistic water node
TerryRussell
Posts: 12
Joined: Wed Mar 30, 2011 7:14 pm

Re: Realistic water scene node

Post by TerryRussell »

Thank you!

I'll download it and give it a try.
Regards,

Terry
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Realistic water scene node

Post by Cube_ »

image links broken, please fix...

you know, no pix no clix
"this is not the bottleneck you are looking for"
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: Realistic water scene node

Post by Virion »

does this included in irrExt svn directories?
Sinsemilla
Posts: 38
Joined: Mon Jan 09, 2012 5:07 pm

Re: Realistic water scene node

Post by Sinsemilla »

Hi elvman,

Thirst of all you did a very nice work :D, i've tried out different water shaders and your's is fitting best to my project. Unfortunately i got a problem with it. When i am using Opengl in linux and windows, respectively GLSL, everything is running fine. When i am using direct3d, respectively HLSL in windows, i am getting a effect of blackened water. Only a circle around the camera has the correct colour. This circle is getting bigger when i am zooming back with the camera and smaller when i zoom to the water. Sorry for the noobish description without technical terms, i don't know anything about shaders... :oops:

Image

Besides of this i was running a valgrind check over my game in linux with the result of getting memory leaks from the water scene node. The valgrind output i am getting looks like this:
Invalid write of size 8
==26429==    at 0x42E565: irr::scene::ISceneNode::removeAll() (ISceneNode.h:323)
==26429==    by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429==    by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==  Address 0xde44ca8 is 136 bytes inside a block of size 504 free'd
==26429==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429==    by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429==    by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 8
==26429==    at 0x42E57F: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429==    by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429==    by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==  Address 0xde44c20 is 0 bytes inside a block of size 504 free'd
==26429==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429==    by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429==    by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 4
==26429==    at 0x424BE6: irr::IReferenceCounted::drop() const (IReferenceCounted.h:121)
==26429==    by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429==    by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429==    by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==  Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429==    by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429==    by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid write of size 4
==26429==    at 0x424BF0: irr::IReferenceCounted::drop() const (IReferenceCounted.h:121)
==26429==    by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429==    by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429==    by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==  Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429==    by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429==    by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 4
==26429==    at 0x424BF7: irr::IReferenceCounted::drop() const (IReferenceCounted.h:122)
==26429==    by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429==    by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429==    by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)
==26429==  Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429==    by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429==    by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429==    by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429==    by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429==    by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429==    by 0x43C9EE: main (main.cpp:38)

These lines (126 - 138) are located at my RunGame.cpp destructor, 126 shows where i am deleting the object:

Code: Select all

 
if (m_pWater != NULL) {
        delete m_pWater;
        m_pWater = NULL;
}
 
I used a member pointer for RealicWaterSceneNode since it has to be allocated on the heap as as showed in the example:

Code: Select all

 
m_pWater = new RealisticWaterSceneNode(m_pSceneMgr, (MAP_SCALE * MAP_CHUNK_SIZE) * 3, (MAP_SCALE * MAP_CHUNK_SIZE) * 3, m_pDriver->getTexture("./graphics/data/waterbump.png"),
                                               dimension2du(m_pGameData->WaterQuality, m_pGameData->WaterQuality), m_pSceneMgr->getRootSceneNode(), -1);
 
If i take a look at the decumentation of the functions in RealisticWater.cpp i see following:
This pointer should not be dropped. See IReferenceCounted::drop() for more information.

When i empty the destructor of RealisticWater.cpp i am getting no erros from valgrind anymore.

Sorry for my potentially bad english and nice work anyways :D
Greets Sinsemilla
mss
Posts: 24
Joined: Mon Oct 29, 2012 6:41 pm

Re: Realistic water scene node

Post by mss »

For me, the OPENGL rendering doesn't reflect anything and it doesn't do any transparency effect. For DX9, it works seemingly well, it pulls colors from the edges a little odd, but it's much better than the OPENGL shaders.

My sympathies for having the balls to dig into shaders. They're not the easiest things to work with.
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Re: Realistic water scene node

Post by ikam »

Hi

nice water node, works fine, thanks.

to fix opengl shader with 1.8 replace this code in RealisticWater.cpp :

Code: Select all

services->setPixelShaderConstant("WaterBump", (float*)(&var0), 1); //the colormap 
services->setPixelShaderConstant("RefractionMap", (float*)(&var1), 1); //the colormap 
services->setPixelShaderConstant("ReflectionMap", (float*)(&var2), 1); //the colormap
with

Code: Select all

services->setPixelShaderConstant("WaterBump", &var0, 1); //the colormap 
services->setPixelShaderConstant("RefractionMap", &var1, 1); //the colormap 
services->setPixelShaderConstant("ReflectionMap", &var2, 1); //the colormap
Post Reply