[fixed] 1.5 - EMT_TRANSPARENT_ALPHA_CHANNEL_REF DirectX prob

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
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

[fixed] 1.5 - EMT_TRANSPARENT_ALPHA_CHANNEL_REF DirectX prob

Post by mike76 »

Hi!

I think there is something wrong in
EMT_TRANSPARENT_ALPHA_CHANNEL_REF
under DirectX

It produces no transparency at all ( PNG with Alpha channel was used, TGA too ) and the node stay solid, under video::EDT_OPENGL is everything ok, transparency works.

I thought, its my driver-or-png file related problem, and compiled the same source under older version of Irrlicht (1.3.1) and both, DirectX and OpenGL draw my node correct (with alpha channel - transparency).

BTW,
EMT_TRANSPARENT_ALPHA_CHANNEL works ok in DX and OGL modes.


-mike
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

OK, thanks for letting us know. I'm assuming that you're using the 1.5 SDK.

Any chance that you can provide a test app and sample resources, so that we can be sure that we're testing exactly the same problem? We can use it as the basis of a regression test.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

Yes, v 1.5

I just wanted to see the difference between these two transparent methods
(EMT_TRANSPARENT_ALPHA_CHANNEL_REF should be a lot faster than EMT_TRANSPARENT_ALPHA_CHANNEL)

To do it, i placed random about 900 simple nodes with "_REF" transparency and a camera to count FPS,
but to my astonishment the "_REF" method won't work properly.

It very simple scene, like this:

Code: Select all

//...
//usual stuff...
//...

//init. Irrlicht...
video::E_DRIVER_TYPE driverType; 
driverType = video::EDT_DIRECT3D9;  //<-- no "_REF" transparency 
//driverType = video::EDT_OPENGL;     //<-- here is everyting ok

// create device
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(driverType,		core::dimension2d<s32>(800, 600), 32, false, false, false, &receiver);
	if (device == 0) return 1; // could not create selected driver.
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();



//force 32 bit textures...
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

//put FPS camera...
smgr->addCameraSceneNodeFPS(0, 100.0f, .1f);
	

//init some nodes for test
scene::IAnimatedMeshSceneNode*  node[999];

//build a simple scene,  put some random nodes with transparency..
irr::scene::IAnimatedMesh* mesh;
for (int t=0; t<900; t++)
{
	mesh = smgr->getMesh("media/pine03.3ds"); //or anything...
	node[t]=smgr->addAnimatedMeshSceneNode(mesh);
	float x=rand()%9999;
	float y=rand()%99;
	float z=rand()%9999;
	node[t]->setPosition(core::vector3df(x,y,z));

	node[t]->setMaterialTexture(0, driver->getTexture("media/grass.png"));   //png with an alpha-channel


//             node[t]->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);    //transparency works

	            node[t]->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF );  //solid.....?


//             node[t]->setHardwareMappingHint(scene::EHM_STATIC);   //speeds it up..

//------- and this manual applying 'mask' doesn't help at all......
//         ITexture* grassTex = driver->getTexture("media/grass.png");
//         driver->makeColorKeyTexture(grassTex, (SColor)(255,0,0,0)); 
//         grassTex->regenerateMipMapLevels(); 
//         node[t]->setMaterialTexture(0,grassTex);       

	
} //end of for t=  ...  

And for sure that there is no problem with my PNG file I used even the file "grass.png" from bitplane's "grass node" routines
( this one: http://irrlicht.sourceforge.net/phpBB2 ... p?t=10762 ).


-mike
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

OK, investigating now, using this test code.

Code: Select all

#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;

#pragma comment(lib, "irrlicht.lib")

int main()
{
	IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, core::dimension2d<s32>(160, 120), 32);
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	ISceneNode * backCube = smgr->addCubeSceneNode();
	backCube->setPosition(vector3df(0, 0, 10));
	backCube->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
	backCube->setMaterialType(video::EMT_SOLID );  //solid.....?
	backCube->setMaterialFlag(video::EMF_LIGHTING, false);

	ISceneNode * frontCube = smgr->addCubeSceneNode();
	// http://irrlicht-plugins.googlecode.com/svn/trunk/scene/nodes/GrassPatchSceneNode/media/grass.png
	frontCube->setMaterialTexture(0, driver->getTexture("../../media/grass.png"));
	frontCube->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF );  //solid.....?
	frontCube->setMaterialFlag(video::EMF_LIGHTING, false);

	(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));

	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(255,113,113,133));
		smgr->drawAll();
		driver->endScene();
	}

	device->drop();
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

OK, this is caused (or revealed) by a change in CD3D9MaterialRenderer.h in SVN 1512

I suspect (but can't be sure) that this is a copy-and-paste issue. We've changed CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF so that it uses the actual value in material.MaterialTypeParam. We used to default to using 127 if that value was 0 (which it apparently always is).

Instead, I suggest that (from the contract for TRANSPARENT_ALPHA_CHANNEL_REF) that we should ignore the material.MaterialTypeParam and always use 127.

I'll see if I can get hybrid to have a look at this, as I don't know the reason for us making that change.

Thanks for reporting this; it's a rather important bit of functionality!
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Fix confirmed and committed on the 1.5 branch in SVN 2055. Thanks again for reporting this.
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