Missing faces .obj to .mdl

I’m importing an .obj file via assimp and then displaying it. For some reason some faces of the model arent showing up when rendered. Ive tested the obj file in several different external viewers and they all show these faces no problem.
Urho:


Other viewer:

What could be the problem here? Is there a way i can upload my .obj file?

My guess is that some of the faces might be oriented backwards, potentially. In terms of uploading, you could try a gist on GitHub or maybe PasteBin - .obj is a text file after all.

You are absolutely right! This did the trick:

material->SetCullMode(CullMode::CULL_NONE);

What disadvantage will i have setting this on all materials by default?

In general models are constructed with a consistent winding on the triangles. This allows the GPU to quickly discard half of the triangles based solely on the view and the triangle winding without any per-pixel work. Basically, it halves (ish) the amount of work to render a model.

So you’ll lose that performance gain, but if you’re not pushing the limits with your scenes, it may be worth doing that rather than correcting all of the models.

Flip your normals in your editor before export and all should be fine.

Im building a kind of 3d viewer for CAD related applications where users will be able to load their own models, so editing is not an option. Ill just have to switch off culling

In AssetImporter use the -nf option. Some times Assetimporter thinks some faces are wrong and flips their normals. This way you don’t have to disable culling completely.

If you don’t plan to use lights in your viewer then that should work. Hovewer disabling the culling will cause wrong lighting since normals are important in light calculations. (Lights will still use your flipped normals to shade faces)

1 Like

Sadly the -nf option didnt help.

What do you mean with not use light? Without lights i wont see anything

You can see your model without lights because there’s always ambient light in the scene defined in your zone… Try adding a spotlight or a directional light and you will see that disabling culling is not a good idea.
EDIT : I just tested it and if normals are flipped in a model the lighting is wrong.

You’re right. Is it possible to use front and back faces?

AFAIK you can’t… each vertex has only one normal which can point in one direction only. Lighting uses normals when calcualte light and shadows and it doesn’t care about culling. It could be done if you really really need this but it doesn’t worth the hassle since it is a very specific situation and it is easier to flip your normals at export or do it dynamically in your viewer. (vertex.normal = -vertex.normal)
Or you can modify the LitSolid shader to fit your needs.

I cannot influence the model origin, so I’d have to do something when I import the model, however i assumed assetImporter takes care of this.

Im confused, as any program I test the model in, (in .obj form) displays it perfectly, so i don’t see why the assetImporter would flip the normals, and also not why when using -nf option in assetImporter the model still doesnt appear correct.

What do you mean with the LitSolidShader?

My guess is you exported your model with a negative scale on one of the axes (maybe the model was mirrored in the editing software ?) and asset importer doesn’t take the scale into account at import time. This is just an idea though…

Can you check your model’s scale first ? Or even better : can you upload your model so i can check it if it’s not problem ?

https://filebin.net/glxb28x4y9fwsl3h

Here are the original .obj and the .mdl generated with assetImporter.

Thanks!

Ok i just tried to import your .obj file in 3ds max and the model shows up totally wrong (exactly as the converted mdl in Urho3d)
kép

Some faces are randomly flipped… Did you tried exporting your model in another format ?

I looked at your obj file in Maya and it looks the same as the result pic in Urho3D – so many faces are flipped. You might consider importing it to Blender and tweak the faces and re-exporting it.

And, it looks like Dave is seeing the same thing.

1 Like

Thanks for taking your time to help me. Sadly manual editing is simply not an option, as the program should display “any” model in a good way, and seeing as the viewers i’ve tested it in can do that successfully and without manual help that’s the benchmark for me.

Ive tried using the unlit shader , and this seems to work, rendering all the faces i require, but now of course all faces are equally lit bright and thus unusable. Can this be refined somehow? Do you see any solution how i could get this to work without manual editing? Performance isnt my highest concern, and besides showing the model, lighting neednt be fancy either.

Can your 3D modeling tool export the file in .fbx format or something else that’s common?

yes it can

https://gofile.io/?c=bpANTr

but afaik assimp doesnt not support this, correct?