transparent water surface

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
neil
Posts: 12
Joined: Fri Sep 28, 2007 1:04 am

transparent water surface

Post by neil »

hi i'm new, how would i go about making the water surface node transparent so the water look better?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Change the material's flags to transparent. I forget what the methods and parameters are but if you check the API for ISceneNode you should be able to notice which functions and parameters it is.
Image Image Image
neil
Posts: 12
Joined: Fri Sep 28, 2007 1:04 am

Post by neil »

thanks for your help. I checked the help files but am still having trouble, could someone send me a source example of what the alpha code would look like. I appreciate it.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Have you looked at example 8 Special FX? Does it do what you want? If not, what do you want to do differently?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
neil
Posts: 12
Joined: Fri Sep 28, 2007 1:04 am

Post by neil »

The special fx example shows how to create the water node (which I have already done). What I want to do is make the water node semi transparent so i can see whats under the water, sorta like real water. So all i need help with is the code which would make something transparent or have an alpha value.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Off the top of my head, replace this:

Code: Select all

	node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
	node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));
	node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
with this:

Code: Select all

	node->setMaterialTexture(0, driver->getTexture("../../media/water.jpg"));
	node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
That'll give you a basic translucent layer, but then you'll lose the really pretty water FX. I'm not sure there's an out-of-the-box material type that'll give you both.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Try EMT_TRANSPARENT_REFLECTION_2_LAYER, but note that it doesn't work 100% in OpenGL (irrlicht version 1.3.1)

http://irrlicht.sourceforge.net/docu/na ... .html#a158
neil
Posts: 12
Joined: Fri Sep 28, 2007 1:04 am

Post by neil »

thanks for all the help. I managed to do what i wanted. But i have one last quick question. How would you make the transparent node (in this case water surface) less transparent? I would like my water a little less transparent that when using EMT_TRANSPARENT_ADD_COLOR.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Replace this:

Code: Select all

	mesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<u32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));

	node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(0,7,0));

	node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
	node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));

	node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
with this

Code: Select all

	mesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<u32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));

	smgr->getMeshManipulator()->setVertexColorAlpha(mesh->getMesh(0), OPACITY);
	node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(0,7,0));

	node->setMaterialTexture(0, driver->getTexture("../../media/water.jpg"));
	node->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA); 
Where OPACITY is the degree of opacity, with 0 being transparent and 255 being solid.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply