blitz-research/monkey2

Models with alpha sort their own meshes backwards

Closed this issue · 12 comments

Hi,

While sorting between different models seems to work fine, if a single model has multiple separate pieces they're sorting backwards, like this (A should be in front of B, B in front of C, etc.):
screen shot 2019-01-29 at 12 35 27 pm

Here's the example file, with assets.
AlphaTest.zip

There's also a tree model, you can see how the leaf cards are rendered behind the leaf "bag" that should be the innermost mesh. Walk around with WASD keys and Mouse look.

(By the way, the only way I know to enable alpha textures without making a whole object transparent is by making its alpha 0.999... not sure there's a better way).

Microsoft 3D viewer also has issues with tree.gltf but renders slices.gltf in correct order. Playing with alphaMode did not seem to help when testing.

None of those files have the correct blend mode because Houdini's GLTF implementation is still basic (no transparency, no animation, etc.). But even if the GLTF file has the correct blend mode (or if you override it by code, like I'm doing), the sorting is still wrong in the mojo3d side if the mesh contains more than one piece.

Thanks!

Thanks Mark! The individual slices use offset texture coordinates, and a single texture containing 4 tiles.

I understand the problem, and seems like sorting by surface bounds center would be good enough!

I can also switch to generating individual slices, the problem in that case is not with Mojo3D but with Houdini, whose GLTF exporter doesn't do a good job with instances yet (everything is exported as unique objects, and that kills my frame rate when I have a lot of instances). It's an early exporter version, so I expect it to improve soon.

I will try to export to uniquely named pivots instead, and replace them at runtime with properly cloned meshes on the Mojo3D side.

Here's a zip containing two gltf files, ones where the slices are combined, and one where they are separated.

slices.zip

Thanks!

I don't see any change in the dev branch, did you push it?

Anyway, I tried an option called "packed copies" in Houdini, its equivalent of instances.
It seems to load as a single model in mojo3d, but I can't tell for sure if each instance is indeed a gltf surface, instead of part of a polygon soup.

packed_copies.zip

Here's how it looks in Ted2Go, currently. The same sorting issue, but in a different order than before:
screen shot 2019-02-03 at 12 46 25 pm

Maybe this is what you're looking for? My only other options are one entity per mesh, or all meshes combined into a single one (Polygon soup).

Houdini can definitely do multiple materials per mesh, but I was avoiding that since the goal was to render a large number of instanced meshes as fast as possible, so I was trying to use the same exact material on each one (i.e. the branches on a tree, then the tree model itself is copied hundreds of times).

Got the latest dev branch, will test it tomorrow.
Thanks!

Thanks Mark, I think I have enough information to now to work around the issue on the asset creation side. I'll close it, but feel free to reopen the issue in case you want to keep track of it.

Cheers!