Direct3D & diffuse color material

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
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Direct3D & diffuse color material

Post by wizardofoz »

Hi all,

I can't really understand why my non-textured meshes are always rendered with a white diffuse colour.

I turned off ambient, emissive etc.. and if I use OpenGL or Software, all meshes are rendered with their right diffuse color.

This happens only with Direct3D 8 and 9.

I'm using an ATI 1400 with the last drivers...

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

Post by rogerborg »

What version of Irrlicht are you using? And can you provide us with some sample source that would allow us to replicate the problem?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

I'm using Irrlicht 1.5 Win32 compiled version and I'm now downloading the latest SVN sources.

An example code:

Code: Select all

// start up the engine
	IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,
		core::dimension2d<s32>(640,480));

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* scenemgr = device->getSceneManager();

	// add a first person shooter style user controlled camera
	scene::ICameraSceneNode * cam =  scenemgr->addCameraSceneNodeFPS();

	cam->setPosition(core::vector3df(0,0,-30));

	scene::ISceneNode * sphere = scenemgr->addSphereSceneNode();

	//----------------- 
	sphere->getMaterial(0).AmbientColor = 0;
	sphere->getMaterial(0).DiffuseColor = video::SColor(255,255,0,0);

	//-----------------

	scene::ILightSceneNode *il = scenemgr->addLightSceneNode(0,core::vector3df(0,10,-80));
	il->setRadius(100);
	
	// draw everything
	while(device->run() && driver)
	{
		driver->beginScene(true, true, video::SColor(255,0,0,255));
		scenemgr->drawAll();
		driver->endScene();
	}

	// delete device
	device->drop();
If I use OpenGL or Software the sphere is rendered correctly with a red colour while with DirectX 8 or 9 the sphere is always white despite of diffuse colour material.

Thanks again for your help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, we need to make untextured materials work as expected. You'll face the same problems with vertex colors, but in the opposite order, i.e. OpenGL fails there. Irrlicht has been developed with only textured meshes in mind. The rest was usually neglected.
wizardofoz
Posts: 8
Joined: Tue Jan 27, 2009 9:30 am

Post by wizardofoz »

Thank you for your prompt reply.

We needed to use diffuse colour on some untextured submeshes without using shaders.

I think that the material diffuse colour value could be useful also in textured meshes in order to add some simple colour effect on the texture.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, the thing is that one driver supports one part, the other one the other part. We need to figure out some flags to toggle between those states, and also check that all drivers properly implement both. Might be in 1.6, though, because we're currently adding all those fancy flags 8)
Post Reply