Page 15 of 18

Re: Realistic water scene node (updated)

Posted: Sun Aug 14, 2011 7:45 pm
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 ?

Re: Realistic water scene node (updated)

Posted: Sun Aug 14, 2011 8:54 pm
by shadowslair
Maybe your machine is ancient or your drivers are obsolete as it`s not supporting shaders.

Re: Realistic water scene node (updated)

Posted: Sun Aug 14, 2011 9:06 pm
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.

Re: Realistic water scene node (updated)

Posted: Mon Aug 15, 2011 9:27 pm
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();

Re: Realistic water scene node (updated)

Posted: Wed Aug 24, 2011 5:48 pm
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

Re: Realistic water scene node (updated)

Posted: Sun Oct 09, 2011 6:03 pm
by Donner
All the links seem to be dead... can someone post the latest version?
Thanks ;)

Re: Realistic water scene node (updated)

Posted: Mon Oct 10, 2011 7:32 pm
by elvman
Sorry, server is down for maintenance. It will be up in 2 days.

Re: Realistic water scene node (updated)

Posted: Sun Oct 16, 2011 9:53 pm
by SGH
Maybe a bit more than 2 days... o.O

Re: Realistic water scene node

Posted: Tue Oct 25, 2011 4:51 pm
by elvman
Finally changed the URL of the scene node. Sorry!

Re: Realistic water scene node

Posted: Tue Oct 25, 2011 7:17 pm
by TerryRussell
Thank you!

I'll download it and give it a try.

Re: Realistic water scene node

Posted: Fri Nov 18, 2011 10:50 am
by Cube_
image links broken, please fix...

you know, no pix no clix

Re: Realistic water scene node

Posted: Sat Nov 19, 2011 4:35 pm
by Virion
does this included in irrExt svn directories?

Re: Realistic water scene node

Posted: Sun Feb 12, 2012 4:08 pm
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

Re: Realistic water scene node

Posted: Fri Nov 30, 2012 9:56 pm
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.

Re: Realistic water scene node

Posted: Thu Dec 27, 2012 9:47 pm
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