Question ASCII-3 (Lua Script J-3 with mesh made with Notepad) Adventures and Questions

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
As a bit of a learning exercise for creating and rendering meshes and textures, I wanted to make a small add-on with a low-poly mesh that I could make from scratch, picking points off a drawing and making the mesh in a text editor. I picked a J-3 Cub as a suitable aircraft.

Piper_L-4B_Grasshopper_3-view_line_drawing.png

So I pulled out a ruler and started triangulating the geometry and put it into a mesh file (attached). The geometry seems to be going well (I still have to do the fiddly round bits like the tires, struts, etc. but it's mostly there). Here's how it looks in Orbiter:

Screenshot at 2024-05-28 22-20-49.png
The geometry seems pretty solid so I must have the left-hand-rule under control. The wings and surfaces are essentially all 2D. To ensure they are opaque from all angles, I made two triangles for every three vertices, with the left hand convention setting opposite normals for both triangles.

But I am obviously having some rendering issues.

1. I can't seem to get reflections off any of the surfaces. I know this is set in the specular color setting of the surface materials in the mesh file, but no matter how I set them I seem to get just the same color with no illumination.
2. The transparent windscreens behave strangely. They seem to negate the transparency of whatever is behind them. If an opaque surface is behind it, that surface renders transparent, and vice versa. These surfaces are set just like the opaque surfaces, with two triangles with opposing normals, which I don't know if it is a part of the problem or the correct procedure.

Can anyone see what I might be doing wrong with respect to the rendering of these surfaces? If I can fix these things I think I can make a fun little add-on with a real propeller engine.
 

Attachments

  • J-3.zip
    1.1 KB · Views: 4

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,844
Reaction score
2,580
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Your transparent meshgroups are not the last in the mesh file, that is a problem. Also you set every meshgroup to NONORMAL, which inhibits shading resulting in a flat colour AFAIR.

Finally: You don't need to repeat the material and texture entries for following meshgroups with the same material properties. This shouldn't have an effect on your visual, but improves performance (as if that matters here).
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
Your transparent meshgroups are not the last in the mesh file, that is a problem.
I see. I put them last and now the transparency renders correctly.
Also you set every meshgroup to NONORMAL, which inhibits shading resulting in a flat colour AFAIR.
I thought that was required if the face normals were not prescribed. I removed those NONORMAL flags, but it did not change the lack of surface reflection.
Finally: You don't need to repeat the material and texture entries for following meshgroups with the same material properties. This shouldn't have an effect on your visual, but improves performance (as if that matters here).
Well, if I can start a healthy habit...
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,844
Reaction score
2,580
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Maybe reduce the ambient light factor for your shading a bit from 1.0 to ]0.1 ... 0.3[
 

Gondos

Well-known member
Joined
Apr 18, 2022
Messages
267
Reaction score
317
Points
78
Location
On my chair
I think you need the NONORMAL flag for orbiter to compute the normals for you :

Code:
} else if (!_strnicmp (cbuf, "NONORMAL", 8)) {
                bnormal = false; calcnml = true;
}
...
if (calcnml) mesh.CalcNormals (g, true);
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
Maybe reduce the ambient light factor for your shading a bit from 1.0 to ]0.1 ... 0.3[
Doesn't seem to do anything. This is what I have for my materials:
Code:
MATERIAL Cub_Yellow
0.50 0.35 0.00 1.00
1.00 0.70 0.00 1.00
0.1 0.1 0.1 1.0
0 0 0 1
MATERIAL Clear_Glass
0.10 0.10 0.10 0.50
0.20 0.20 0.20 0.50
0 0 0 1
0 0 0 1
MATERIAL Tire_Black
0.10 0.10 0.10 1.00
0.20 0.20 0.20 1.00
0 0 0 1
0 0 0 1

And this is what it looks like - still flat:

Screenshot at 2024-05-29 11-47-03.png
I think you need the NONORMAL flag for orbiter to compute the normals for you
That's what I read in the docs, but it doesn't seem to do anything one way or another.
 

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,512
Reaction score
760
Points
203
It seems like your materials aren't set up properly for specular highlights. For example, the material named "Cub_Yellow" has a specular highlight color of 0.1, 0.1 and 0.1 which corresponds to a very, near pitch black color. Try upping it to full on white (1 1 1 1).
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
It seems like your materials aren't set up properly for specular highlights. For example, the material named "Cub_Yellow" has a specular highlight color of 0.1, 0.1 and 0.1 which corresponds to a very, near pitch black color. Try upping it to full on white (1 1 1 1).
I tried that:

Code:
MATERIAL Cub_Yellow
0.50 0.35 0.00 1.00
1.00 0.70 0.00 1.00
1 1 1 1
0 0 0 1

Still got this:

Screenshot at 2024-05-29 14-47-16.png
I don't have any textures applied, but I don't think that matters? I should be able to get reflections off different surfaces?
 

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,512
Reaction score
760
Points
203
Try a scenario where it is closer to local noon for best lighting (that is what I always do as it guarantees that the sun will provide the most light on everything). Also, I see that you're using OpenOrbiter, is all of the visual effects checked on the Options tab?
 

Buck Rogers

Major Spacecadet
Joined
Feb 26, 2013
Messages
500
Reaction score
447
Points
63
I couldn't get it work in notepad so I imported into Blender, changed the colour, and exported.
This is the (unfortunate) result, at least the colour is better:)
0503.jpg
.msh attached
 

Attachments

  • test.txt
    7.9 KB · Views: 3

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
Try a scenario where it is closer to local noon for best lighting (that is what I always do as it guarantees that the sun will provide the most light on everything). Also, I see that you're using OpenOrbiter, is all of the visual effects checked on the Options tab?
All of the visual effects are enabled. Other add-ons show shading:

Screenshot at 2024-05-29 16-44-53.png

Changing to local time (about 4:30 PM) doesn't change the rendering at all:

Screenshot at 2024-05-29 16-30-55.png
Screenshot at 2024-05-29 16-32-22.png
I get the same behavior in Orbiter.exe and Orbiter_ng.exe. Really unsure what is going on.
 

Buck Rogers

Major Spacecadet
Joined
Feb 26, 2013
Messages
500
Reaction score
447
Points
63
I created the mesh in Notepad (it's just a text file)
I do a lot of editing in notepad- materials, paths etc. Very adventerous of you, good luck, hope your matrix eye is well focused:cool:
Can you load my mesh as-is and see what you get?
I get what you get
Screenshot at 2024-05-29 16-44-53.png

Where can I get that jet?
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
I get what you get
I copied the material properties from your mesh file and it doesn't change anything except for the color in my mesh. Still no reflectivity.
Where can I get that jet?
It's a Mirage2000, one of Kev33s old add-ons that I resurrected for Orbiter with my air-breathing jet engine add-on.


I have a Lua script version of this same add-on that I'll probably release at some point, flies just as well as the compiled version.
 

Buck Rogers

Major Spacecadet
Joined
Feb 26, 2013
Messages
500
Reaction score
447
Points
63
I copied the material properties from your mesh file and it doesn't change anything except for the color in my mesh. Still no reflectivity.
I couldn't fix it by changing the materials in notepad, so it's the mesh triangles, maybe you can compare the blender output with your input, the normals aren't working, but in the export some are.
 

jacquesmomo

Addon Developer
Addon Developer
Joined
Jun 14, 2008
Messages
617
Reaction score
461
Points
78
Location
FRANCE
Website
francophone.dansteph.com
I don't have any textures applied, but I don't think that matters?

I think that yes...

Just try this :
  • apply a plain texture (yellow for example) to all your groups in your mesh (exept for the windows of course !)
  • and for the materials set a white color for example this :

MATERIALS 1
Blanc-brillant
MATERIAL Blanc-brillant
1 1 1 1
1 1 1 1
1 1 1 1 80
.2 .2 .2 1

(exept for the windows.... )

and look at the result which should be much better...
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
I think that yes...

Just try this :
  • apply a plain texture (yellow for example) to all your groups in your mesh (exept for the windows of course !)
  • and for the materials set a white color for example this :

MATERIALS 1
Blanc-brillant
MATERIAL Blanc-brillant
1 1 1 1
1 1 1 1
1 1 1 1 80
.2 .2 .2 1

(exept for the windows.... )

and look at the result which should be much better...
If this works that means that something is very broken in Orbiter. It should be using the specular and emissive properties for the materials, and there should not be a need for a texture to show the color.

It should be making some attempt to approximate normals with the NONORMALS flags, but it doesn't seem to be doing that. I might try to see if I can calculate the normals for the wing and see if that makes any difference (they should all be in the +Y or -Y direction, so not so miserable to calculate).

I am wondering if this is something broken between Orbiter 2016 and OpenOrbiter. I will try to set it up in Orbiter 2016 and see if that changes anything.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
Apparently Orbiter (OpenOrbiter at least) can't do anything with the NONORMALS flag and the normals must be specified. I quickly threw them in for the vertices on surfaces in the X/Y/Z directions:

Screenshot at 2024-05-29 18-15-19.png
Not fatal, but I'll have to do a bit of math for the vertices on surfaces that aren't aligned with the principle axes.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,661
Reaction score
3,617
Points
138
Location
Massachusetts
I also need to make separate groups for the top and bottom parts of the 2D surfaces so I can set their normals right.

I am baffled why the normals are associated with the vertices vs. the triangles formed by the vertices. That doesn't make any sense to me. A normal to a surface has a mathematical definition - a normal to a vertex doesn't.
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
249
Reaction score
143
Points
58
Location
Lehi, Utah
Associating the normals with the vertices allows the renderer to 'shade' the triangle based on the different normals at its 'edges' (the vertices). Its how our low poly meshes look smooth.
 
Top