[fixed]water transparency not working

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

[fixed]water transparency not working

Post by xDan »

Hello,

How can I get Irrlicht's built in water to be partially transparent?

This question has been asked before, but the suggested solution doesn't seem to work for me.

Here's my code

Code: Select all

			const f32 waveHeight = 0.1;
			const f32 waveSpeed = 1000.0;
			const f32 waveLength = 2.5;
			
			scene::ISceneManager *smgr = device->getSceneManager();
			
			const f32 seaWidth = 50.f;
			const f32 seaHeight = 200.f;
			const f32 tileSize = 2.0;
			const f32 textureScale = 3.0;
			
			scene::IAnimatedMesh *meshWater = smgr->addHillPlaneMesh("waterHill",
					core::dimension2df(tileSize,tileSize), // tile size
					core::dimension2du( (u32)(seaWidth/tileSize), (u32)(seaHeight/tileSize) ), // tile count
					0,0.01,// material and hill height, not used for water (want a flat plane)
					core::dimension2df(seaWidth*0.1,seaHeight*0.1), // hill count. None for water.
					core::dimension2df(seaWidth/textureScale,seaHeight/textureScale)); // x,y texture repeat
			
			scene::IMesh *staticMeshWater = meshWater->getMesh(0);
			
			smgr->getMeshManipulator()->setVertexColorAlpha(staticMeshWater, 100);
			
			scene::ISceneNode *nodeWater = smgr->addWaterSurfaceSceneNode(staticMeshWater,
					waveHeight, waveSpeed, waveLength);
			
			nodeWater->setMaterialTexture(0, device->getVideoDriver()->getTexture("watersand.png"));
			nodeWater->setMaterialTexture(1, device->getVideoDriver()->getTexture("water.jpg"));
			nodeWater->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
			
			const f32 waterHeight = -0.4;
			nodeWater->setPosition(core::vector3df(-seaWidth/2.0,waterHeight,0));
Whatever value I put for alpha, the transparency doesn't change. It just remains a slightly transparent white colour. In fact it looks very similar to using TRANSPARENT_ADD_COLOR:

Image
(ignore the character thing in the middle)

I notice in the docs it says "Please note that this material type is currently not 100% implemented in OpenGL". So perhaps that is the issue, it simply isn't implemented!? :S

I'm using OpenGL, Irrlicht 1.6

Using shader based water is out of the question for this project.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, if it looks better in D3D it could be a problem with the OpenGL implementation, otherwise it's maybe the whole material that is somewhat odd. Most two layer materials are pretty much unknown how there look should be. I guess some test cases would be good :wink:
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Ok, I just found the "MaterialViewer" app in the latest Irrlicht 1.7.1.

Here it does seem to work with Direct3d (I tried Direct3D9) but does not work with OpenGL.

Instructions:
- run the app...
- set material type to trans_reflection..
- file->open stones and water textures from the media folder
- set first material to stones
- set second material to water
- now adjust the Vertex Colors alpha value.

For me with the direct3d it seems to work perfectly, I can choose any alpha value and the object appears lighter or darker as expected. However with OpenGL changing the alpha has no effect.

(I can make an actual test case if you want, but the above seems enough to demonstrate. Also I can't compile to Direct3D easily since I'm using Mingw).

Edit: Also, adjusting the vertex *colour* in OpenGL has an effect of making the object lighter or darker. With black being invisible and pure white being visible. *EXACTLY* as if ADD_COLOR was used.
(this isn't a fix though, as ADD_COLOR isn't useful for water, I need proper transparency). With direct3d, changing the colour of the vertex correctly has no effect (as you would expect)
Last edited by xDan on Sat Sep 04, 2010 9:49 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, I'll check and try to create a regression test from that. Once I know which parameters are going into the rendering, I should find the correct OpenGL settings, too.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Great :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, this is fixed now in SVN.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Thanks!
Post Reply