# Meshing QuestionRendering Shadows on Basic Mesh Objects

#### Thunder Chicken

Donator
So far, so good. I managed to get my Python Obj2Msh converter to work properly and I can import various *.obj geometries produced in FreeCAD into Orbiter.

Now I am trying to sort out the rendering. If I don't apply vertex normals in the file I get the proper shape and it casts a proper shadow under ambient light, but there is no variation of light on the object itself (model is a sphere that is partially clipped through the ground surface):

If I include the vertex normals to the vertices I get this:

Clearly something is borked in the normals, but I'm unsure what the issue is. The normals were generated in the *.obj file, and I flipped the coordinates of the normal vector to match the coordinate swap for the vertices and faces.

If push comes to shove I can probably recalculate the normals in my converter, but I'd like to see if I am missing something mundane (again).

Thanks all for your patience and help. I made add-ons with Blender years ago but tend to be more proficient with parametric CAD, so I wanted to go down this particular route to making add-ons.

Last edited:

#### GLS

##### Well-known member
Orbiter Contributor
What material is being used?

#### Thunder Chicken

Donator
What material is being used?
I just applied a basic material copied from another mesh:

At the start of the mesh file:
MSHX1
GROUPS 1
MATERIAL 1
TEXTURE 0
GEOM 490 1952
.
.
.
at the bottom of the mesh file:
MATERIALS 1
MATERIAL 1
0.900000 0.900000 0.900000 1
0.900000 0.900000 0.900000 1
0.900000 0.900000 0.900000 1
0 0 0 1

EDIT: There is only a single group in the file, and the visual settings in Orbiter 2016 are set to their defaults.

#### GLS

##### Well-known member
Orbiter Contributor
The material seems healthy, but this caught my eye:
Code:
GEOM 490 1952
In my head, these are too many triangles for the vertexes... could there by triangles inside the ball?
That would "connect" opposite sides of the ball, thus blending the light across and making it all have the same light.

#### Thunder Chicken

Donator
The material seems healthy, but this caught my eye:
Code:
GEOM 490 1952
In my head, these are too many triangles for the vertexes... could there by triangles inside the ball?
That would "connect" opposite sides of the ball, thus blending the light across and making it all have the same light.
Each triangle does have a second one with an opposing normal, using the same vertices.

I understand it's not necessary in this case, but I would need to do this if I wanted to render both sides of a flat plate. Would the lighting effects be screwed up if I did that? I didn't think about it before, but the vertex normals are only to one side of the plate, so I suppose that would really screw things up for one side of the plate.

To do a two-sided plate, would you need to have three vertex pairs, so you could make two opposing normal faces AND have distinct normals on the inside and outside?

EDIT: Here it is with the inside faces removed. That did the trick.

Last edited:

#### GLS

##### Well-known member
Orbiter Contributor
To do a two-sided plate, would you need to have three vertex pairs, so you could make two opposing normal faces AND have distinct normals on the inside and outside?
Yep. A vertex shared between triangles will have its normal as an average of the normals of the triangles it defines. This is great in curved surfaces to give them a smooth look by having triangles blending their light with the neighbors, but in places with shape edges this is not a wanted effect: a cube with only 8 vertexes will have a light on one face "bleed" to the sides, so the cube needs 24 vertexes to look good.

For the ball with inside and outside surfaces, you need 2 independent balls: the inside ball with the normals pointing inside, and outside ball the other with the normals pointing outside. For smoothness, each ball should have no "duplicate vertexes".

Replies
5
Views
325
Replies
2
Views
599
Replies
1
Views
234
Replies
11
Views
646