# How many pixels does a triangle use

I know JME has a method to determine this – but I’m having trouble finding it. Should have bookmarked it when I saw it last time… been searching forum & javadocs and it must be right in front of me but I can’t find it… someone else remember off hand?

thx for the extra pair of searching eyes…

Depends how zoomed in you are on the triangle.
rasterization

I’m having trouble figuring out when this information would be useful. Can you explain what you are really trying to do?

Programmatically creating some outdoor meshes – and would like to avoid creating detailed meshes on things that are far away… how far away? well… far enough away that a typical triangle from their mesh would only bit a few pixels…

-Eric

@ehubbard said: Programmatically creating some outdoor meshes -- and would like to avoid creating detailed meshes on things that are far away.... how far away? well.. far enough away that a typical triangle from their mesh would only bit a few pixels.....

-Eric

How do you determine the “typical triangle”? Which one stands in for the typical one?

Take that one, run its three coordinates through the projection matrix, take the area of the triangle.

A triangle side on to the camera would show much fewer pixels than one facing straight towards it though.
I think the OP needs to think a bit smarter about this. Read up on various LOD schemes and you will see any number of solutions that people have already spent a lot of time working on. You will find that most of them just use a rule based on distance from camera…

@zarch said: A triangle side on to the camera would show much fewer pixels than one facing straight towards it though.

…and would have a tiny area once projected onto the screen. (ie: run through the projection matrix as said). Or maybe you are speaking to “picking a good representative triangle”. That’s why I asked that question because picking a good triangle cannot just be random. It’s actually the way more complicated part of the problem. Once you have a triangle, it’s easy.

@zarch said: I think the OP needs to think a bit smarter about this. Read up on various LOD schemes and you will see any number of solutions that people have already spent a lot of time working on. You will find that most of them just use a rule based on distance from camera...

Agreed. Use distance and a per-model bias… potentially set by the artist… and you will get pretty far.

If in the off chance that you do not know your models up front (like users can add their own or something) then you can still assign a bias, you just have to calculated by averaging the areas of the triangles… or min/maxing… or some other function to calculate a reasonable bias.

Yes, representative triangle involves both a triangle with the right absolute area and one with the right orientation.

Personally if doing this algorithmically rather than manually I’d just use a simple rule based on absolute size of object compared to size on screen and then merge all vertices closer together than a certain threshold based on that. Picking the right vertices to merge towards would be the tricky bit

Although that also raises problems with uv mapping depending on whether your texture is continuous over the mesh or some form of atlas.

I might indeed end up with a “simple rule based” solution… but I must explore solutions first. I can pick a good “face on” triangle easy enough in my situation. So I can run it through the projection matrix or … as I just found this morning… (sleeping on it helps?) AreaUtils! uses a Bounding Volume and not a Triangle… and admits that it is an approx… but I really only need an approx at this stage…