Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial LOD functionality. #185

Merged
merged 34 commits into from
Oct 17, 2023
Merged

Add initial LOD functionality. #185

merged 34 commits into from
Oct 17, 2023

Conversation

digisomni
Copy link
Member

@digisomni digisomni commented Sep 26, 2023

Follows the following conventions. See docs too: https://doc.babylonjs.com/features/featuresDeepDive/mesh/LOD

[name]_LOD{ level }_{ mode }_{ override }

Levels are:

  • 0
  • 1
  • 2
  • 3
  • HIDE

e.g. LODHIDE

Modes are (optional):

  • AUTO (not enabled right now)
  • SIZE (based on the amount of the screen the object covers)
  • DISTANCE

Overrides are (optional):

  • if using distance mode: 0 - infinity (any number)
  • if using size mode: Must be a number between 0.0 and 1.0, represents a percentage of 100%.

P.S. Need to fix up linting, it gets hecka annoying but it was inactive before.

@Aitolda
Copy link
Contributor

Aitolda commented Sep 26, 2023

Got our first BUG.

It doesn't currently respect the position of the LOD objects within the GLB, instead moving them to the 0,0,0 point.
100m offset
Note in the image above, the models are 100 meters from 0,0,0

GLB.x.y.z.not.respected.mp4

Now if you note the position of the objects in this video, I've added the little X to note the 0,0,0 of the GLB (raised slightly so it wasn't in the floor, hence no Y value, just X and Z shown). In fact the models should be 100 meters away on the X from this point.

Also: a very minor note, but it seems like it's holding LOD2 considerably longer than LOD1 and LOD0. This might just be a default from babylon.js but worth double checking.

@Aitolda
Copy link
Contributor

Aitolda commented Sep 26, 2023

New Bugs.

  1. having a second copy of these objects in the GLB doesn't seem to work. Note this is the default naming scheme for copies in blender, The second set will still have the position bug, but as far as I can tell they (the second set) are all visible at all times. This is likely due the the .xxx suffix not yet being accounted for. Example below.
91e48400c448931a009e166241a22298
  1. Also, rotation and scale (set in blender) from within the GLB seems to be ignored on both sets of objects just like the position, both the semi-working set and the non-working set. In blender I have both sets placed far away from the zero point and rotated and scaled randomly, but here is how they look in engine.
0837ee5799ababa357a798e6103a665b

So basically, my take away is that in the process of enabling LOD we are somehow no longer pulling rotation, position of scale of objects within said GLB. Now if I rotate the GLB itself from that native that rotation is being respected, but all the internal object transforms are being ignored.

To shake things up I added a regular (non-LOD) cube to the glb file and confirmed that it's rotation and position are indeed being honored still. You can see it floating in the sky instead of being pulled to 0,0,0 like the LOD objects.

9655258145e3ebe0e64ac32d72169e00

GLB with two sets of LOD objects and a random non-LOD cube for testing.
Here

@Aitolda
Copy link
Contributor

Aitolda commented Sep 26, 2023

Follows the following convention:

[name]_LOD{ level }_{ mode }_{ override }

Levels are:

  • 0
  • 1
  • 2
  • 3
  • HIDE

Can you explainhow to use HIDE? Is this supposed to be the cull distance? First I tried
9401cf9da201b9fe6407e64d9248a1eb

Although that doesn't really make sense since this requires an extra object/mesh, but also LOD3 just kept visible to infinity, so I imagine that wasn't the intended use.

Then I tried
463effbf27256f626c26e9f9d4eeebdb
but this (not surprisingly) didn't work.

Also tried
b7cb6f4a58a9d91a6264ac2e110ed953

Which seems to line up with the directions above, but that doesn't seem to work either. I'm not sure why you would need a hide object anyway as each "distance" unit above seems to say when that partcular LOD cuts out, so you'd think the Example_LOD3_DISTANCE_20 would be where it would be culled.

@Aitolda
Copy link
Contributor

Aitolda commented Sep 26, 2023

Not sure what exactly size is supposed to do, but this as written below had no visible impact
b71ddbaa9f466b469d01d39a6645ac23

@digisomni digisomni merged commit 0349998 into master Oct 17, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants