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

Implement Optimizations #34

Open
c4b4d4 opened this issue Nov 21, 2022 · 1 comment
Open

Implement Optimizations #34

c4b4d4 opened this issue Nov 21, 2022 · 1 comment

Comments

@c4b4d4
Copy link

c4b4d4 commented Nov 21, 2022

I’m interested in implementing optimizations, I see you’ve started naming them, and I have interest in using GEOCLIPMAP, and even try to combine it to also use POLYGONREDUCTION.

Are you planning to release optimizations?

I could try implementing it myself too, where could I add it? Any recommendations?

@IceCreamYou
Copy link
Owner

I haven't actively worked on this project, other than occasional maintenance to keep it compatible with Three.js updates, in many years. So unfortunately I do not have any optimizations stored away waiting to be released 🙂 The references you see to things like GEOCLIPMAP are a sign of the unfulfilled ambitions I had for this library.

Thanks for your interest in contributing. I would certainly accept contributions, though I might not be able to review them super quickly.

where could I add it? Any recommendations?

  • POLYGONREDUCTION is a relatively simple pass over the geometry. The main issue is that once it happens, the vertices are no longer in a grid, so some of the math of the various filters/generators/etc. no longer work. So, it would need to be applied inside THREE.Terrain.Normalize in src/core.js, before the after callback. (Note that some things that use the after callback would need to be aware of this, like scattering meshes on the surface of the terrain randomly per face.)
  • The easiest way to do GEOMIPMAP is to generate the high detail mesh as usual, but then after the Normalize step, generate a bunch of new meshes at varying levels of detail for different sections of the terrain. Add those all to the scene returned by THREE.Terrain(), then the caller would be responsible for showing/hiding the relevant meshes based on the camera position (for example using THREE.LOD()) or you could add a helpful wrapper. Note that there are some tricky details with seams between different LODs. You also need to be careful about meshes placed on the surface of the terrain suddenly not being on the surface once the meshes are switched out for a different LOD.
  • GEOCLIPMAP is relatively hard because you have to morph the geometry as the camera moves. You can do this by generating different LODs like with mipmapping (though you don't need to split the terrain into sections) and then writing a shader to interpolate the terrain heights based on the camera position. The TriggerRally example linked in the code is still there, and that's how it works. There is some literature on more advanced methods, where for example you can compress the high detail terrain (along the lines of POLYGONREDUCTION) and then interpolate higher detail on demand.

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

No branches or pull requests

2 participants