Diffuse Color set to White if OBJ meshbuffer has a texture

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
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Diffuse Color set to White if OBJ meshbuffer has a texture

Post by devsh »

COBJMeshFileLoader.cpp

Code: Select all

 
        // Set diffuse material color to white so as not to affect texture color
        // Because Maya set diffuse color Kd to black when you use a diffuse color map
        // But is this the right thing to do?
        currMaterial->Meshbuffer->Material.DiffuseColor.set(
            currMaterial->Meshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 );

Seriously guys?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Diffuse Color set to White if OBJ meshbuffer has a textu

Post by CuteAlien »

Well, I suppose it was added to make it look the same before and after export. Formats like obj have the trouble that many tools use them in slightly different ways so we try to make it work in Irrlicht based on the examples we are getting. If you have an example where this is wrong and can give us the corresponding model and tell about the toolchain involved we can look at it.

If all you have to say is "Seriously guys?" without _any_ explanation where and why this might be wrong and without _any_ testcase ... then please just get lost. I'm kinda pissed off by now by your constant off-hand remarks dissing the engine without _ever_ giving any useful examples. You're using Irrlicht long enough by now to know we can do nothing with stupid comments like that without giving us any useable data at all!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Diffuse Color set to White if OBJ meshbuffer has a textu

Post by devsh »

okay...

what happens is that the .mtl property called Kd which is the diffuse color, gets loaded correctly into the mesh buffer's SMaterial when there is no texture specified for that material in the mtl file

as soon as we specify a texture, the DiffuseColor gets set to white...

which is obviously a bug

I found those 4 lines in the function that handles loading a texture specified in the MTL file, so I fixed it in my build of irrlicht.
What is immensely frustrating is that you guys, the irrlicht devs, don't keep any sort of record of the workarounds that are floating around in the source code.


I dont care that maya violates the OBJ format standard and sets Kd to black when texture is enabled, we should stick to the standard, especially that its easy to correct maya's mistakes by just editing the MTL.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Diffuse Color set to White if OBJ meshbuffer has a textu

Post by CuteAlien »

Saying Maya violates the obj or mtl format is a little tricky. All descriptions about obj or mtl are documentations of what the Alias guys do in their format. They are the standard.

The code-comment you posted clearly shows that whoever wrote this also wasn't comfortable with that solution. But hasn't seen a better solution that works with original obj files, so he decided to make them work and then to comment it. If someone has a better solution that's always nice. Breaking original obj files is probably not better.

And yeah - it's not nice. I might have run into this once as well. I suspect the solution is to have a better way to pass parameters to the loaders (maybe attributes which are evaluated at start of loading and somehow documented).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply