Page 1 of 2

help! obj model display not correct in irrlicht

Posted: Wed Jul 01, 2009 1:19 am
by ym1218
The same obj file, it display perfect in Deep Exploration, but not correct in Irrlicht, I don't know what's the reason, someone can give me some advice? thanks.

In Deep Exploration
Image


In Irrlicht
Image

In Irrlicht by set material to EMT_TRANSPARENT_ALPHA_CHANNEL
Image[/img]

Posted: Wed Jul 01, 2009 1:36 am
by sudi
yeah thats bc the meshbuffer of the books is drawn before the shelve...
u should not set material emt_transparent on the whole object.

Posted: Wed Jul 01, 2009 1:54 am
by ym1218
The whole transparent version used only to comparison, the transparent effect is perfect but not correct.

I uploaded the model, download here
http://www.soft5a.com/ym/files/Archive.zip

Here is a normal rendering, I marked the errors by red.
Image

Posted: Wed Jul 01, 2009 11:58 am
by hybrid
The chariot seems to lack back faces. Sinc .obj does not handle backface culling, you'll have holes instead of faces on the inside. You can disable backface culling on your mesh, which should help already. However, there seems to be some transparent materil on the chariot as well, which does not look correct. Don't know what would be intended and why it uses transparency at all, maybe some wrong material assignment?
I couldn't reproduce the problem with the drink glasses.

Posted: Wed Jul 01, 2009 1:28 pm
by BlindSide
I personally find that forcing ZWriteEnable does help in these cases.

You'll have to get the scene parameters using ISceneManager::getParameters(), and then set the Allow Z Write Enable on Transparent setting to true.

The issue with this is that you have to manually set this on all transparent materials that need to disable ZWrite to false.

What sudi was trying to say is that you should split the mesh into seperate meshbuffers, the transparent parts and solid parts, and this should save you a lot of trouble. You may still need to enable ZWrite in certain situations though.

Posted: Wed Jul 01, 2009 2:12 pm
by ym1218
Thanks for all replies.

I've disabled backculling, the chariot looks correct now, but the transparent effect is not good as I expect.

I need to get a similar render effect like Deep Exploration, but I donnot konw how to adjust irrlicht, I hope someone can give me some advices about this.

Here is the new snapshot.

Image

Posted: Wed Jul 01, 2009 2:39 pm
by ym1218
Thanks for your reply, but disable ZWite doesnot work.

It's a obj file, I want to iterate all the children nodes but found it has no children nodes, do you have another method to split the mesh except using getChildren() method?
BlindSide wrote:I personally find that forcing ZWriteEnable does help in these cases.

You'll have to get the scene parameters using ISceneManager::getParameters(), and then set the Allow Z Write Enable on Transparent setting to true.

The issue with this is that you have to manually set this on all transparent materials that need to disable ZWrite to false.

What sudi was trying to say is that you should split the mesh into seperate meshbuffers, the transparent parts and solid parts, and this should save you a lot of trouble. You may still need to enable ZWrite in certain situations though.

Posted: Wed Jul 01, 2009 4:00 pm
by sudi
na i meant that when the mesh is loaded their is a meshbuffer for every material. But when u use setMaterialType with the scenenode all meshbuffers use the same material. that is not good when the material is not transparent.

Posted: Wed Jul 01, 2009 4:20 pm
by hybrid
The material difference is due to your bump mapping. Try to remove the bump settings in the material file. This should come in a later step, as there's currently no way to get a proper bumpmap import with the values you set in oyur modelling tool. Some values are simply fixed to a value which might be improper for the current mesh.
The glass seems to have a high specular value with very low shininess, such that the brightness is far too high. Try to set shininess to 0 (to disable it for now). Also make sure that you set normalize_normals when scaling your mesh, because all lighting equations depend on proper normals.

Posted: Thu Jul 02, 2009 5:47 am
by BlindSide
Thanks for your reply, but disable ZWite doesnot work.
I just tried it and it helps (Btw I said to enable ZWrite, not disable...), see the difference (With all materials set to EMT_TRANSPARENT_ALPHA_CHANNEL):

Image

The important thing to notice is that the books are not incorrectly behind the cabinet wood, and the cabinet glass is correctly behind the cabinet wood.

You have to do this:

Code: Select all

smgr->getParameters()->setAttribute(ALLOW_ZWRITE_ON_TRANSPARENT, true);
You did not provide the texture though so I'm not sure how it will look with that applied.

Posted: Thu Jul 02, 2009 8:01 am
by ym1218
BlindSide, you are right, I mistaken to set the materials to ZWriteAble, thank you very much.

The glass effect is really what I want, only a bit transparent error, I marked in snapshot here(I'm sorry for my poor knowledge about 3D render).
Image

Posted: Thu Jul 02, 2009 8:08 am
by hybrid
Try to use a SOLID material for the bull, this will render this one first, and hence get the correct impression. Using a transparent material on things which are not using any transparent effect will only slow down the rendering.

Posted: Thu Jul 02, 2009 10:06 am
by ym1218
Hybrid, thanks you for your help, but the render quality is more important than speed for me in this project.

All the objects displayed in screen is one whole model, I donnot know how to change the bull's material separately. My project is a 3D Viewer, this means I cannot modify the model.

I wanted using ISceneNode's getChildren method to get the childs nodes, but I found this model has no child.
hybrid wrote:Try to use a SOLID material for the bull, this will render this one first, and hence get the correct impression. Using a transparent material on things which are not using any transparent effect will only slow down the rendering.

Posted: Thu Jul 02, 2009 1:23 pm
by hybrid
Well, then just avoid the setMaterial(EMT_TRANSPARENT_VERTEX_ALPHA) at all. It's not really necessary, the actual problems are somewhere else.

Posted: Fri Jul 03, 2009 9:45 am
by ym1218
Thanks for all.

Here is the core code:

Code: Select all

m_smgr->getParameters()->setAttribute(ALLOW_ZWRITE_ON_TRANSPARENT, true);
m_scenenode->setMaterialFlag(EMF_BACK_FACE_CULLING,false); 

for(u32 i = 0;i<m_scenenode->getMaterialCount(); i++)
{			
	switch(m_scenenode->getMaterial(i).MaterialType)
	{
	case EMT_TRANSPARENT_VERTEX_ALPHA:
		m_scenenode->getMaterial(i).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
		break;
	default:
		break;
	}
}


Here is the newest snapshot, it seems better.

Image