[no bug]DirectX model has empty first mesh buffer

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
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

[no bug]DirectX model has empty first mesh buffer

Post by lulzfish »

I'm having this weird problem where all my materials have a ridiculously high specular.

Here's an example of how my scene should look:
Image
To get this, I had to set my light's SpecularColor to 0.

Here's how it actually looks.
Image
The front left tire's specular has been set to 0, but it has no effect. Everything in the scene is still washed out with specular highlighting.

This is in Irrlicht 1.5 with the OpenGL driver. Irrlicht 1.5.1 has the same problem, and 1.5.1 also ignores my "setLightType (ELT_DIRECTIONAL)" for some reason.

The models were exported from Blender 2.48a as DirectX meshes. In Blender, the specular value is 0 and the specular color is black. :/

When I export as OBJ, the lighting seems to work fine, and I can set the specular from within Irrlicht.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Re: Scene is washed out with specular lighting (DirectX mode

Post by bitplane »

lulzfish wrote:When I export as OBJ, the lighting seems to work fine, and I can set the specular from within Irrlicht.
I suggest comparing the other material colours, like ambient and diffuse
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

Post by lulzfish »

When using OBJ, I can set all of the colors fine.
When using X, I cannot set any of them.

:?

Also, why do SColor and SColorf use different constructors? One is ARGB and one is RGBA.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

lulzfish wrote:When using OBJ, I can set all of the colors fine.
When using X, I cannot set any of them.
You're doing something wrong, post some code and some models.
Also, why do SColor and SColorf use different constructors? One is ARGB and one is RGBA.
I guess one of them was an oversight, and now it can't be changed because it will break everyone's code!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

Post by lulzfish »

Yeah, that's what I was afraid of.

I'm using this to change the ambient / specular / diffuse on my nodes:

Code: Select all

leftBackTire->getMaterial (0).SpecularColor = SColor (255, 255, 0, 0);
leftBackTire->getMaterial (0).AmbientColor = SColor (255, 0, 255, 0);
leftBackTire->getMaterial (0).DiffuseColor = SColor (255, 0, 0, 255);
Like I said, it only works on obj for some reason.

Here's the full main.cpp just for the hell of it:
http://pastebin.com/m50e7b50b

Here's the .blend for the tires, and the .x and .obj/.mtl I exported from Blender:
http://cid-1f464824e5c9e65e.skydrive.li ... =4&lc=1033[/code]

edit: I also added the 'truck' body just for completeness, and the textures. The program expects them to be in the "models" folder.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Perhaps when exported as .X it has more than one material?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Yep BlindSide is right, the X file has two materials.

edit: This is a bug in the X loader, the X file itself only contains one mesh buffer!

edit2: Retitled, moved to bug reports and bug added

ps) Excellent test case by the way, everything I needed to reproduce the bug. Only complaint is I had to download the models one by one, but I guess you can't have everything!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

Post by lulzfish »

The truck.x loads with 8 different materials, and it looks like 0 - 6 are completely empty, as with the tire.

And each model only has one material in Blender.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The .x loader is correct. The tire has two materials defined, which requires the creation of two meshbuffers. You should simply not export the second material if you don't want it to be created. Since the assignment of meshbuffers and joints/weights is heavily related to the meshbuffer organisation it's not easy to check whether a meshbuffer can be skipped. Moreover, CSkinnedMesh does not allow to remove a meshbuffer, so there's also no way later on to fix this.
The truck has several parts, probably for joints. Each of these parts requires a material, which makes 7 all together. The 8th is once again a duplicated material, which is exported as is into the material list of the .x file. Blame the exporter or yourself (don't know really, as I'm not too much into Blender).
The shininess of the second material of the tire is set to 1, which enabled the effect as described. The only question is whether this value is correctly interpreted (does anyone know the range of shininess in .x files?). But it's definitely enabled.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Oh.. sorry! You're completely right, I can't believe I missed blatant two entries in the material list :oops:

Closing the bug :roll:
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

Post by lulzfish »

I'm going to blame Blender then, since I'm quite sure that both models have a single material and texture.

The truck has 7 different meshes, though there are no joints going on.
The truck .X has 8 materials, the first 7 are named Material (and all located near one of the meshes) and the last one is named Mat1 and has a high specular / shininess for whatever reason.

WTF.

edit: This was all of a hell of a lot of trouble, so I just found a B3D exporter for Blender, which seems to bridge Blender to Irrlicht MUCH more nicer than .X, and with smaller models.
Post Reply