Page 1 of 1

Diffuse Color set to White if OBJ meshbuffer has a texture

Posted: Wed Apr 29, 2015 10:58 am
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?

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

Posted: Wed Apr 29, 2015 11:04 am
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!

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

Posted: Thu Apr 30, 2015 1:42 pm
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.

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

Posted: Thu Apr 30, 2015 2:25 pm
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).