Suggestions for seamless water (w/ pic) (new problems)...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Suggestions for seamless water (w/ pic) (new problems)...

Post by Rytz »

Basically, I have 6 different meshes that, together, create 1 large body of water.

The problem is that there is a hole (purposely put there) in the middle of this body of water, that goes beneath water-level. It's kinda like a "reverse well", where in a normal well, the water is in the well and not around the outside of it.

I've created and positioned the water nodes correctly, but the problem is that you can see the seams (bounds) for each mesh. What's the best approach for overcoming this?

See the image below. Any input is appreciated.

Image
Last edited by Rytz on Fri Sep 26, 2008 12:20 am, edited 1 time in total.
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You need to play around with the E_TEXTURE_CLAMP parameter of the mesh's SMaterialLayer that uses that texture. It can be one of the following:

ETC_REPEAT Texture repeats.
ETC_CLAMP Texture is clamped to the last pixel.
ETC_CLAMP_TO_EDGE Texture is clamped to the edge pixel.
ETC_CLAMP_TO_BORDER Texture is clamped to the border pixel (if exists).
ETC_MIRROR Texture is alternatingly mirrored (0..1..0..1..0..).

It seems like you can do node->getMaterial(0).setFlag(EMF_TEXTURE_WRAP, ETC_REPEAT);

Try some different parameters to see which looks best, my bet would be either ETC_CLAMP or ETC_CLAMP_TO_EDGE
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Could also be two overlapping transparent materials. Moreover, the problem is not the hole, but the surrounding, which is not just one mesh. Question is why you use several meshes instead of just one?
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

Thanks for the replies.
hybrid wrote:Could also be two overlapping transparent materials. Moreover, the problem is not the hole, but the surrounding, which is not just one mesh. Question is why you use several meshes instead of just one?
Is it possible to create one mesh for the entire "square" of the map and not have water show up where the hole is? That was my reasoning for creating 6 meshes instead of one big one, so that I could go "around" the hole.

Will the IWaterSurfaceSceneNode follow the shape of the mesh that is bound to it or will the node always show up as a flat rectangle? If it follows any shape I guess I could create a mesh for the water that wraps all the way around the hole.
Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

The water surface node follows any shape its given. You should make your mesh an evenly spaced grid of vertices for best effect.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

bitplane wrote:The water surface node follows any shape its given. You should make your mesh an evenly spaced grid of vertices for best effect.
Awesome. Thanks all for the replies.
Image
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

Ok, so I created a single mesh to enclose the "well" instead of 6, but now I've run into 2 other problems. The first one seems expected, the other does not.

[Problem #1]:
I'm not getting the "hill" effect that I was with the previous "6 mesh" method (I was using "addHillPlaneMesh" to create meshes for the water nodes). It's one flat surface that bounces up and down which you can't see in the image. It looks more like an icy surface.

Image




[Problem #2]:
At certain angles, the water mesh is disappearing altogether. I don't have any other clues as to why, but here is the pic and the code I use to create it below:

Image

Code: Select all

                // create animated water mesh...
                scene::IAnimatedMesh *meshNewWater = ptrClient->ptrVideo->dvWindow->getSceneManager()->getMeshManipulator()->createAnimatedMesh(
                    ptrClient->avatar->room->meshWater);

                // create "top-down" / "over-water" water node...
                scene::ISceneNode *nodeWaterOver = ptrClient->ptrVideo->dvWindow->getSceneManager()->addWaterSurfaceSceneNode(
                    meshNewWater, 2.0f, 200.0f, 20.0f, ptrClient->avatar->room->nodeRoom, -1,
                    ptrClient->avatar->room->meshWater->getBoundingBox().getCenter(),
                    core::vector3df(0, 0, 0),
                    core::vector3df(1.0f, 1.0f, 1.0f));
                nodeWaterOver->setMaterialTexture(0, ptrClient->ptrVideo->irrVDriver->getTexture("./media/textures/water/water01.jpg"));
                nodeWaterOver->setMaterialTexture(1, ptrClient->ptrVideo->irrVDriver->getTexture("./media/textures/water/water01.jpg"));
                nodeWaterOver->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
                nodeWaterOver->setMaterialFlag(video::EMF_LIGHTING, false);
                //nodeWaterOver->setMaterialFlag(video::EMF_TEXTURE_WRAP, true);

                // create "bottom-up" / "under-water" water node...
                scene::ISceneNode *nodeWaterUnder = ptrClient->ptrVideo->dvWindow->getSceneManager()->addWaterSurfaceSceneNode(
                    meshNewWater, 2.0f, 200.0f, 20.0f, ptrClient->avatar->room->nodeRoom, -1,
                    ptrClient->avatar->room->meshWater->getBoundingBox().getCenter(),
                    core::vector3df(180, 0, 0),
                    core::vector3df(1.0f, 1.0f, 1.0f));
                nodeWaterUnder->setMaterialTexture(0, ptrClient->ptrVideo->irrVDriver->getTexture("./media/textures/water/water01.jpg"));
                nodeWaterUnder->setMaterialTexture(1, ptrClient->ptrVideo->irrVDriver->getTexture("./media/textures/water/water01.jpg"));
                nodeWaterUnder->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
                nodeWaterUnder->setMaterialFlag(video::EMF_LIGHTING, false);
                //nodeWaterUnder->setMaterialFlag(video::EMF_TEXTURE_WRAP, true);

                // drop the reference...
                meshNewWater->drop();
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Looks like either your mesh has some problems, or the water scene node is not working as good as expected :? Can you upload your mesh somewhere such we have a fully working version for tests?
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

hybrid wrote:Looks like either your mesh has some problems, or the water scene node is not working as good as expected :? Can you upload your mesh somewhere such we have a fully working version for tests?
I'll throw the mesh up for download when I get to work tomorrow but I'm guessing you're right that it's my mesh because the water node works fine when I use a mesh created from addHillPlaneMesh. It "waves" the way it should and I don't get the visibility problem.

Are there any special requirements for a mesh that is to be used for a water scene node?
Image
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

Well I got the "waves" working in my own mesh. I figured out that I'm an idiot and that I needed more vertices :O.

The visibility problem is still there though. I'm gonna try eliminating some other parts of the map and see if it's something with the map that's causing it.
Image
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

It's probably a culling issue. Try changing the node->setAutomaticCulling( ); to EAC_FRUSTUM_BOX or EAC_OFF to see if it works then.
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

Eigen wrote:It's probably a culling issue. Try changing the node->setAutomaticCulling( ); to EAC_FRUSTUM_BOX or EAC_OFF to see if it works then.
Thanks Eigen - setting the culling to off fixed my visibility issue.

Just one more issue to overcome... I'm getting a weird texture / tiling issue. I'm using the Ascii DirectX mesh format exported by DeleD Lite and the water mesh is a grid object that is 32x32. It only seems to happen when I use EMT_REFLECTION_2_LAYER or EMT_TRANSPARENT_REFLECTION_2_LAYER so it probably has something to do with reflection.


*WITHOUT* EMT_REFLECTION_2_LAYER
Image


*WITH* EMT_REFLECTION_2_LAYER
Image


In the bottom pic you can see that the "reflection" visuals aren't lining up. I found THIS thread on some problems with this format but not sure if it's the exact same problem. Any thoughts?
Image
Post Reply