Jump to content

Auto LOD - Quadratic Error Decimation


RaananW
 Share

Recommended Posts

If anyone wants to know the page for LOD is found here:

http://doc.babylonjs.com/page.php?p=24822

 

And I just wanna say that you, Raanan, has done a HUGE favor to all of us here at babylon. You've created something that will make our games faster for the years to come, and I for one am super grateful for it! Your awesome!

Link to comment
Share on other sites

I will be really glad to see that working in a game. :-) Always a pleasure contributing back to such a great project!

 

Skull is decimated wonderfully - http://www.babylonjs-playground.com/#2JBSNA  (it will alert when it finished all 5 levels of simplification, just zoom in and out and look at the number of vertices).

Still a small problem with disappearing triangles, but it is actually unnoticeable when you are so far away from the object. I will anyhow look into that, this shouldn't have happened. Maybe due to the async porting, I gotta check.

I will continue on improving and fixing this code, if anyone has a question or something is not working correctly, please let me know! Would be happy to answer.

Link to comment
Share on other sites

yes, this is what I meant with "Still a small problem with disappearing triangles". I am working on it, I believe it has something to do with concurrency.  On large models, or if set at a relative large distance, it will be unnoticed (look at the skull from very far away, it is 90% reduction, but shape is preserved).

I hope to fix it in the next few days. Will update here.

Link to comment
Share on other sites

Hi,

I tried avoiding object cloning, as this sets the geometry as well. But by not using clone, I didn't set the other parameters... I know how to fix this, will upload a fix today.
The triangles problem should also be much better, I pushed a fix yesterday. I just don't know if it's in the playground yet.

Link to comment
Share on other sites

My question is - what do you define as the parent of the LOD Mesh? the original mesh from which the LOD was made, or the parent node (if exists) of the original mesh?

The parent attribute of LOD levels is already being set, this why i assumed you mean the original mesh.

What's currently missing is changing the scale, position, rotation etc' attributes of the LOD mesh to be equal to the original mesh's attributes. Will do that later on today.

If I am wrong here, please show me an example so I can understand what you mean.

Link to comment
Share on other sites

Currently what I reported on was the parent of the LOD mesh (which in some cases is an instance mesh in my scene).

 

My other question is if it would be possible to use the LOD mesh of the instance parent, but the scale, rotation and location of the instance so I'm not recreating the same LOD mesh for every instance. This would free up a lot of redundancy if it doesn't already work this way.

Link to comment
Share on other sites

If i understand your question correctly, you ask if you can take one mesh's LOD level and add it as another mesh's LOD level.

The answer is yes, of course. It is just a mesh. If those LOD-parent meshes have different scaling (for example) you will have to clone the LOD mesh, change its scale (or any attribute you want) and add it to the other mesh as LOD level.

It is technically possible, no need to recalculate 100 meshes, if they are the same.

Link to comment
Share on other sites

Judging by what DK said in a previous LOD discussion, all LODs should or will eventually follow instanced meshes back to their parents. So maybe my questions are moot points since based on that, if I instance a model, it will automatically have the LOD information.

 

Correct me if I'm wrong in that assumption... :)

Link to comment
Share on other sites

Just checked it as well - 

http://www.babylonjs-playground.com/#2JBSNA

I load a mesh, give it scale and rotation, create an instance with a new position and only then run the simplification. This seems to work with no fix needed.

Maybe show a playground example of what is wrong before I fix something that's not a bug :-)

 

@Deltakosh, any chance of deploying the new babylon.js file? the triangles fix is not yet in the playground.

Link to comment
Share on other sites

  • 4 weeks later...
Why create copy objects when uses 'simplify'.
When I look in DebugLayer this every time I create a duplicate of the object by adding 'Decimated' before the model name.
So that augment the number of Draw calls and the number of models on the scene. This has no impact on performance in the end?
I question only.
 
I also find a bug. Certain object does not seem to be simplified.
In made if he create the two simplification of a base object, but the object disappears in the first distance.
 
Example:
mesh.simplify([{distance:150, quality:0.9}, {distance:200, quality:0.8}, {distance:300, quality:0.5}]);

The objects disappears to the distance 150. Subject simplify and three on the same number of poly.

I can you send the model if you want. for testing.
Link to comment
Share on other sites

Hi dad72, as only one mesh is being rendered at the time, there is only 1 draw call per simplified object. The number of meshes however changes.

There shouldn't be any impact on performance (well, there should - it should be better  :) ).

 

Please send me the models, would be great to check them! Make sure you are simplifying after the object was loaded, this is the problem I had with ground from height map.

Link to comment
Share on other sites

Hi Dad72,

 

as we already discussed the problem is that the mesh has submeshes. the algorithm was not created with that thought in mind.

 

Wanted to give an update - I am working on improving the implementation to allow simplification of meshes with submeshes. I hope that I will finish in a day or two. It requires a bot more than simplifying the submeshes, as parallel processing of so many meshes will lower the FPS quite a lot. With that thought in mind, I am creating a "simplification queue" that will automatically process one mesh after the other.

 

When I finish I will push it to babylon's github and hopefully babylon 2.1 will have submeshes support for the simplification functionality.

Link to comment
Share on other sites

Hi Raanan,

 

I saw the new work to support submesh, but it does seem to work. Total model disappears. The model I have you send through MP is always available if you want to test. 

 

And I notice that the first models on simplification (No submesh here) lacks full polygon. when I go to the 2500 => 2100 the half of the model disappears.

 

Here in picture:

 

No simplify (2500 verts)


 

Simlifie (2100 verts) => mesh.simplify([{quality:0.9, distance:100}]);


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...