Page 1 of 1

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

Posted: Wed Sep 24, 2008 10:31 pm
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

Posted: Thu Sep 25, 2008 7:23 am
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

Posted: Thu Sep 25, 2008 7:28 am
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?

Posted: Thu Sep 25, 2008 2:23 pm
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.

Posted: Thu Sep 25, 2008 2:51 pm
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.

Posted: Thu Sep 25, 2008 4:14 pm
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.

Posted: Fri Sep 26, 2008 12:19 am
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();

Posted: Fri Sep 26, 2008 7:49 am
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?

Posted: Fri Sep 26, 2008 8:02 am
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?

Posted: Fri Sep 26, 2008 8:16 am
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.

Posted: Fri Sep 26, 2008 10:43 am
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.

Posted: Fri Sep 26, 2008 6:15 pm
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?