help! obj model display not correct in irrlicht

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

help! obj model display not correct in irrlicht

Post 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]
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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
Last edited by ym1218 on Wed Jul 01, 2009 1:55 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
ym1218
Posts: 19
Joined: Mon Jun 15, 2009 3:47 am

Post 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
Post Reply