secondlife / viewer

🖥️ Second Life's official client
GNU Lesser General Public License v2.1
198 stars 46 forks source link

Mesh Uploader does not match mesh upload requirements #1529

Open canny[bot] opened 1 month ago

canny[bot] commented 1 month ago

Create a highest LOD mesh with two materials.

Create a lower LOD mesh using one of the materials that is included in the highest LOD mesh.

Attempt to upload.

What happens: Error. "Levels of detail have a different number of textureable faces"

The mesh verification steps have a bug, and an error message to go with it, and it prevents upload of mesh that the server would have accepted as valid.

While this error message states a true fact, it is also irrelevant to how SL works; It's a clearly worded explanation of a non-existant problem. Second Life's server does accept lower LOD mesh files with a smaller number of texturable faces, as long as all materials are a subset of the highest LOD. This has ALWAYS been the case, and it's a highly desirable feature (good of LL to have made it possible). I have read varied accounts of histories about how this faulty mesh check made its way into the main viewer, but the point is, it's a breaking error that shouldn't be in there. It prevents a designed and fully-working feature.

Firestorm Viewer, a few years back now, realized this had happened and has corrected the issue, with approriate checks and errors:

FS prevents upload if materials are not a subset of the material list in highest LOD, as expected.

FS also prevents uploading mesh with materials that are not assigned to faces. It can happen accidentally when we use materials correctly but decimate/optimize too much and wind up with a material slot assigned to zero faces.

In Firestorm, the above-listed conditions correctly prevent uploading in cases where SL servers would not accept the file. Firestorm does not throw an error if the lower LOD model uses a "subset" of the highest LOD materials and has at least one face assigned to each material. Because of this, mesh like I described in my 2-steps at the top upload just fine and display correctly on all viewers.

This is a very significant issue, but is not well-known about, and so we've been accepting SL "as-is" but this bug in the mesh model checking is actually causing models to have significantly more LI weight than they should. It's also causing viewers to try to display more textures than they need significantly more often than they should.

Consider an object with just one "link" and 8 material slots in use. The bugged mesh validation check requires our lowest LOD model to have all 8 materials included--and they all must be assigned to a polygon--so we must have at least 8 triangles, 3 verts each, texture islands all, so 24 vertex count.

Since Firestorm has removed the erroneous condition, it is possible to upload a single 3-vertex triangle using a single material from the highest LOD model. This is a significant LI calculation factor.

Consider a specific use-case: a detailed bit of signage, made 3D, but at a distance, indistiguishable from a simple 2D image.

In Firestorm, I can include a material slot at the highest LOD with a flat picture of the sign and assign it to a small triangle hidden among the mesh. At lowest LOD, I can use a simple 2-triangle rectangle with that material assigned to make a sign that is perfectly readable from 2 regions away, using almost nothing.

In all other viewers, I'm required to include every texture on a separate polygon, so I wind up with a blob of triangles and smeared textures (and all the LI that goes with the higher vert count) for no reason, and everyone's viewers have to grab and draw all those textures even from a great distance. Again, no reason--the ability to use only a subset of materials at lower LOD already exists.

Please fix this erroneous rejection; uploading mesh with a subset of faces works just fine and has for years, but only in one viewer that has corrected this bug.

Environment: Second Life Release 7.1.7.8974243247 (64bit)

https://secondlife.canny.io/admin/board/bug-reports/p/mesh-uploader-does-not-match-mesh-upload-requirements

canny[bot] commented 1 month ago

This issue has been linked to a Canny post: Mesh Uploader does not match mesh upload requirements :tada:

akleshchev commented 1 month ago

Is there an example model I can use to test changes with?

I can just change 'total_submeshes[lod] && total_submeshes[lod] != total_submeshes[lod_high]' from '!=' to '<', but I need a way to check if there are other issues.

JourneyBunny commented 1 month ago

Is there an example model I can use to test changes with?

I can just change 'total_submeshes[lod] && total_submeshes[lod] != total_submeshes[lod_high]' from '!=' to '<', but I need a way to check if there are other issues.

Here's a file for a wall light! There's 2 LODs, highest and LOD1. The model includes material slots for a baked brass texture, an emissive lamp shade, and a "render" image of an orthographic view of the light. At the 2 highest LODs, I would use the full-detail model, and then at LOD1 and LOD0 (lowest two), I'd use a simple "card" stand-in with the rendered texture: aIyEeL8

Here's a zip with the 2 DAE files and the textures: Sample Light.zip

akleshchev commented 1 month ago

Thank you, appears to work fine with the change, merged.

dmytrohproductengine commented 2 weeks ago

Passed QA.

Verified on the Second Life Release 7.1.9.9469671545 (64bit) on Win10/OSX in the scope of https://github.com/secondlife/iqa/issues/258.