What would be the best way to hijack the LOD transition so I can animate the alpha of the meshes as the LOD changes?
Maybe mesh.onLODLevelSelection
(it’s an observer).
mesh.onLODLevelSelection.add((distanceToCamera, mesh, levelMesh) => {
// distanceToCamera: distance between camera and mesh bounding sphere center
// mesh: the mesh
// levelMesh: the mesh used for the LOD level selected
});
It misses the index of the LOD, which might be useful…
Maybe @Deltakosh would accept to pass the index as a 4th parameter (?).
But it’s easy to work around this, just store the lod index directly in the lod meshes themselves.
For eg, if you have 3 load meshes mlod1, mlod2, mlod3, you can store the index as mlod1._lodidx = 1
, mlod2._lodidx = 2
and mlod3._lodidx = 3
.
Then:
mesh.onLODLevelSelection.add((distanceToCamera, mesh, levelMesh) => {
let lodIdx = levelMesh._lodidx;
});
Set mesh._lodidx = 0
if you don’t want an undefined
value in lodIdx when levelMesh === mesh
;
Hi guys. Hey P8 , do you really need the alpha to follow/be-dictated-by… the LOD switch-points?
Can you simply adjust alpha based upon distance to camera? Are you looking for a linear transition of alpha… between full-mesh and most-decimated LOD mesh? if so, camera-distance-determined alpha value… should work fine.
Speaking of decimation (ie. simplification - reduction of verts in a mesh, I think)… I went looking for proper term… for the opposite of that action… and kind-of failed. So, for now, let’s say that the opposite of decimation, is tessellation.
From what I have seen of decimators here in JS land, they can be slooooow, depending upon the complexity of the resource mesh.
Still, the ultimate “LOD blending”… would be real-time “live” decimation and tessellation… perhaps done by GPU. The percentage of decimation would be tied directly to distance-to-camera.
Actually, live tessellation is probably impossible, because program won’t know how to add “detail”, because it can’t remember what the original model looked-like. Probably ONLY various levels of decimation, but not “live” tessellation.
I think we will need some help… from hardware/firmware in the next gen of computers. But real-time decimating… that would be pretty nice, huh? Linearly variable LOD levels… phew. (drool)
No problem…but that will be for 4.2 I’m about to write a post about the code freeze
that is possible for sure, I just wanted to leverage the built in system.
I forgot you added customLODSelector at some point @Deltakosh I bet that will do what I need.