Transparent Cube Disappear

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
marian.ek
Posts: 6
Joined: Mon Oct 13, 2008 3:28 pm
Location: Poland

Transparent Cube Disappear

Post by marian.ek »

Hello.
The Problem is : Cube inside odther cube become invisible when the camera moving.
I set the material shader transparent.
I want to nest transparent cubes inside others. When the camera moving some cube disappear.
How solve this problem ?? z-buffer, backFaceCulling,ISceneNode::setAutomaticCulling() with EAC_OFF ??

Code: Select all

	case video::EDT_DIRECT3D9:
		if (UseHighLevelShaders)
		{
			psFileName = "media/d3d9.hlsl";
			vsFileName = psFileName; // both shaders are in the same file
		}
		
	newMaterialType1 = gpu->addHighLevelShaderMaterialFromFiles(
		vsFileName, "vertexMain", video::EVST_VS_1_1,
		psFileName, "pixelMain", video::EPST_PS_1_1,
		mc, video::EMT_SOLID);

	newMaterialType2 = gpu->addHighLevelShaderMaterialFromFiles(
		vsFileName, "vertexMain", video::EVST_VS_1_1,
		psFileName, "pixelMain", video::EPST_PS_1_1,
		mc, video::EMT_TRANSPARENT_ADD_COLOR);

	// EXTERNAL
	scene::ISceneNode* node1;
	node1 = smgr->addCubeSceneNode(50);
	node1->setPosition(core::vector3df(0,-10,50));
	node1->setMaterialTexture(0, driver->getTexture("media/wall.bmp"));
	node1->setMaterialFlag(video::EMF_LIGHTING, false);
	node1->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);

	smgr->addTextSceneNode(gui->getBuiltInFont(),
			L"PS & VS & EMT_TRANSPARENT",
			video::SColor(255,255,255,255),	node1);

	////////////// DISAPPEAR !!!!!! ////////////////////////
	// INTERNAL 1
	scene::ISceneNode* node2;
	node2 = smgr->addCubeSceneNode(15);
	node2->setPosition(core::vector3df(10,-10,50));
	node2->setMaterialTexture(0, driver->getTexture("media/wall.bmp"));
	node2->setMaterialFlag(video::EMF_LIGHTING, false);
	node2->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);

	smgr->addTextSceneNode(gui->getBuiltInFont(),
		L"PS & VS & EMT_TRANSPARENT",
		video::SColor(255,255,255,255),	node2);

	////////////// DISAPPEAR !!!!!! ////////////////////////
	// INTERNAL 2
	scene::ISceneNode* node3;
	node3 = smgr->addCubeSceneNode(15);
	node3->setPosition(core::vector3df(-10,-10,50));
	node3->setMaterialTexture(0, driver->getTexture("media/wall.bmp"));
	node3->setMaterialFlag(video::EMF_LIGHTING, false);
	node3->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);

	smgr->addTextSceneNode(gui->getBuiltInFont(),
		L"PS & VS & EMT_TRANSPARENT",
		video::SColor(255,255,255,255),	node3);
Image
Last edited by marian.ek on Fri Jul 24, 2009 7:09 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Looks like alpha testing.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yeah you need to make sure the cube on the inside is always drawn before the cube on the outside. You may be able to do this with an animator that positions the cube at an offset further from the camera than the big cube.

Also make sure Z WRITE ENABLE is off.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
marian.ek
Posts: 6
Joined: Mon Oct 13, 2008 3:28 pm
Location: Poland

Post by marian.ek »

Thanks !
I turn off flag EMF_ZWRITE_ENABLE.
It's O.K.
Post Reply