Problem Inverted material lighting effects

Countdown84

XR5 Payload Wrangler
Addon Developer
Tutorial Publisher
Joined
Jul 30, 2008
Messages
72
Reaction score
0
Points
6
Website
www.ryankingsbury.com
Hello everyone,

I'm in the (long, slow) process of learning 3D modeling using Blender, and I've been playing around with an updated Carina satellite mesh. I'm pretty happy with it, but when I export it to Orbiter, a couple of the materials display an inverted lighting effect. Namely, the side that should be in shadow is bright and reflective, while the side facing the sun is completely dark. This only happens on a couple of the mesh groups, and all are using pretty basic, opaque materials.

I'm exporting to Orbiter using Blorbiter's blender export script.

I haven't found anything by searching the forum, but I don't even know what to call this problem. I'm sure I'm missing something simple, but I'd be most grateful for any help. Thanks!

carina2.jpg
 
Looks like the normals are backwards. Try reversing the normals before exporting the mesh.
 
Got that same phenomenon a few times myself, can get really annoying. It is solved easiest by recalculating the normals in MeshWizard. It can happen at rare occasions that this messes up your mesh, then you're in trouble. But it's the first thing to try, since in most cases it is the easiest way to solve the problem.
 
Thanks, guys!

I tried flipping the normals in Blender, but then the entire object is backwards (you look "through" it, you know what I mean?)

I also tried recalculating the normals in MeshWizard, and that didn't seem to help either. I may try that one again though, because I'm not sure it saved properly the first time.
 
Meshwizard allways worked in that situation if it didn't do to the model what a black hole couldn't have done better, but as I said, that's very rare. If it doesn't work, I don't really know how to go about it...
 
I think you have the wrong concepts.
Normals in MSH refer to vertex normals, which are used to make edges to look sharp or rounded. A mesh with no normals would look like a black shape in Orbiter.

What you need is to flip visible side.
Visible side could be imagined as a normal vector perpendicular to the triangle, coming out of the center of triangle, but it is not a vertex normal, but a surface normal. Visible side vectors can be displayed in Mesh Wizard.

Since MSH uses vertex normals, we better call it "visible side" to avoid confusions.
 
Meshwizard also has the ability to 'flip' the normal of selected mesh groups, which can be useful in situations like this.
 
OK, I used Mesh Wizard to "recalculate normals" and the material lighting issue is fixed!
yay! Thank you all!

BUT there's a new problem....
All of the smoothing on the mesh is gone (in blender, going to the mesh menu and clicking "set smooth"). So now the mesh looks much more blocky.

Any more ideas?
 
Reassign the smoothing groops... But of course you'll have to convert it back again for that, and chances are good that your normals will be messed up after exporting again. I don't think meshwizard can assign smoothing groups. You could try assigning them in Animator, as I understand it the conversion from animator files works very stable.
Other than that, reassign smoothing groups manualy in the .msh file. But I wouldn't wish you that kind of pain!

One question, though: from what file format do you convert?

@ar81: Switching the visible side will not yield the right results in this case. Then you'll just see the mesh inside out. However, "recalculate normals" usually fixes the lighting problem described above. No Idea how it does that, but if anyone knows it should be you. ;)
 
OK, I used Mesh Wizard to "recalculate normals" and the material lighting issue is fixed!
yay! Thank you all!

BUT there's a new problem....
All of the smoothing on the mesh is gone (in blender, going to the mesh menu and clicking "set smooth"). So now the mesh looks much more blocky.

Any more ideas?

Sharp edges take place when 2 triangles do not share vertices. For example: Triangle 1 uses vertices 0, 1 and 2, and Triangle 2 uses vertices 3, 4 and 5. Let's say vertex pairs 1 and 3, and 2 and 4, have the same XYZ coordinates (mesh position) and same UV coordinates (coordinates on the texture). So even if both are in the same place, they are different vertices and vertex normals will point in different directions.
If you generate normals, common edges will be sharp.

But if you merge points, 1 and 3 would be merged and 2 and 4 would be merged. Then you generate normals and you may get a smooth surface.

Mesh Wizard can "optimize mesh" and I seem to remember it offers the option to merge points. Merged vertices will have the same vertex coordinates, and same UV coordinates, if I remember correctly.

Anyway, you may try and tell me.
If optimization and regeneration of normals do not work that way, you may need to reset normals to 0 in notepad, before processing (merge points, then generate normals) in Mesh Wizard, for the groups that you want to smooth.

---------- Post added at 18:44 ---------- Previous post was at 18:43 ----------

@ar81: Switching the visible side will not yield the right results in this case. Then you'll just see the mesh inside out. However, "recalculate normals" usually fixes the lighting problem described above. No Idea how it does that, but if anyone knows it should be you. ;)

Probably it had inverted normals.
 
I think you have the wrong concepts.
Normals in MSH refer to vertex normals, which are used to make edges to look sharp or rounded. A mesh with no normals would look like a black shape in Orbiter.
Orbiter will automatically calculate the vertex normals if you don't specify them, I believe, by averaging the surface normals of the triangles that use that vertex.
 
Sharp edges take place when 2 triangles do not share vertices. For example: Triangle 1 uses vertices 0, 1 and 2, and Triangle 2 uses vertices 3, 4 and 5. Let's say vertex pairs 1 and 3, and 2 and 4, have the same XYZ coordinates (mesh position) and same UV coordinates (coordinates on the texture). So even if both are in the same place, they are different vertices and vertex normals will point in different directions.
If you generate normals, common edges will be sharp.

But if you merge points, 1 and 3 would be merged and 2 and 4 would be merged. Then you generate normals and you may get a smooth surface.

Mesh Wizard can "optimize mesh" and I seem to remember it offers the option to merge points. Merged vertices will have the same vertex coordinates, and same UV coordinates, if I remember correctly.

Anyway, you may try and tell me.
If optimization and regeneration of normals do not work that way, you may need to reset normals to 0 in notepad, before processing (merge points, then generate normals) in Mesh Wizard, for the groups that you want to smooth.

Very informative. Thank you, ar81!

I brought the mesh into Mesh Wizard and did the Optimize Mesh, which resulted in merging about a thousand vertices. Then I repeated "Generate Normals." Unfortunately it still looks the same. I did not try manually resetting the normals; I'm not completely sure how to do that to be honest.

carina3.jpg



Jedidia - in answer to your question, this was converted from Blender's .blend format using Blorbiter's export script.
 
I did not try manually resetting the normals; I'm not completely sure how to do that to be honest.

Hmmm. It looks like I coded it to check for identical vertices with normals too. So it checks for vertex with save position, normal and UV coordinates to merge vertices.

Vertex data looks like

<x> <y> <z> <NormalX> <NormalY> <NormalZ> <U> <V>

so if it looks like

3 3 3 0.4 0.4 0.4 0.75 0.25

resetting normals means changing values to 0

3 3 3 0 0 0 0.75 0.25

I am not sure if it works, but I suspect it will.

So steps would be
1.Resetting normals to 0
2.Optimize (merge vertices)
3.Generate normals

I coded Mesh Wizard long ago, so I do not remember exactly how it worked, but I suspect this is how I coded it. I would advise to test with a small mesh with a few triangles to see if it works.

Optimizing is good, because the more triangles and vertices, the heavier it will be for rendering purposes.

Mesh Wizard was never intended to be a "mesh tweaker", it just resulted that way. Originally I planned it as a viewer, to locate points only. And back then I did not know many things about coding, so it is a real mess if you look at the code.

Also, I did not design it, so I was coding along the way. It is a miracle that it worked. It still has lots of bugs. But the most cost effective strategy to debug would be to remake it from scratch.

It was my second real coding practice for windows environment, and I was self teaching myself.

Mesh Wizard was intended to be an aid so people do not have to edit a mesh with notepad for massive data tasks like rotating or scaling, for example. But there are still some things people need to do manually with notepad.
 
Well, I can understand that MeshWizard has its limitations, but I think I speak for a lot of the Orbiter community in saying that it is an AMAZINGLY useful tool, and one that has made addon development much easier for a lot of people. thank you!

I'm going on vacation tomorrow, so it will probably be a while before I can try your solution, but thank you everyone for your very enlightening posts. I have a much better grasp of the problem now.
 
Jedidia - in answer to your question, this was converted from Blender's .blend format using Blorbiter's export script.

If everything fails, you could try exporting it as another format and convert it from there. As far as my experience goes, practically every converter and exporter for the .msh format has it's (minor) flaws that can mess up things under certain (allthough not very clear) conditions. But yes, your Mesh looks like Meshwizard threw all the smoothing groups out of the window. Which is interesting, I never saw it doing that before...
 
If everything fails, you could try exporting it as another format and convert it from there. As far as my experience goes, practically every converter and exporter for the .msh format has it's (minor) flaws that can mess up things under certain (allthough not very clear) conditions. But yes, your Mesh looks like Meshwizard threw all the smoothing groups out of the window. Which is interesting, I never saw it doing that before...

Sharp borders happen because different vertices are at the same location but normals are different. The trick of resetting all normals to (0,0,0) is to make Mesh Wizard to see vertices with same UV and position to be equal, since it looks for identical position-normal-UV combo when merging.

Orbiter does not have automatic smoothing. Mesh Wizard does not either.
 
Orbiter does not have automatic smoothing

Now, that's news... still, the information of smoothing groops has to be passed along to the .msh format in some way, otherwise the models wouldn't look the same in orbiter as they look in 3dsMax.
 
Now, that's news... still, the information of smoothing groops has to be passed along to the .msh format in some way, otherwise the models wouldn't look the same in orbiter as they look in 3dsMax.

2 vertices at the same position will look smooth if their normals point in the same direction. Else, it will look sharp.

If 3DS looks smooth and export also looks that way, it must be because smoothed vertices are merged before normals are calculated. But neither Orbiter or Mesh Wizard have a smooth feature.

Mesh Wizard sees the mesh just like orbiter does.
 
Good news! I got it working simply by repeating the steps above.

I exported from blender, used Mesh Wizard to merge identical verts and generate normals, and voila! It worked this time.

After that, I was able to re-import the mesh to Blender and mess with the smoothing groups without screwing up the vertex normals.

THANK YOU to all who helped me solve this problem.

My next questions is this: why does the shadow gradient look so bad? Is this related to the mesh itself or the material?

carina4.jpg
 
I do not particularly like the vertex and edge smoothing that DirectX7 does.
You might like to load your mesh with mesh wizard and check where normals are pointing. If you have normals in a non uniform pattern, the lighting might not be uniform.

You may need to select groups, and the press the button or select the option that displays the list of triangles and vertices, check the display of normals checkbox, and go one by one selecting vertices in the list, so you can see vertex normals.
 
Back
Top