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

Plugins: Consider plugin that uses / enables use of BatchedMesh #417

Closed
gkjohnson opened this issue Nov 15, 2023 · 4 comments · Fixed by #800
Closed

Plugins: Consider plugin that uses / enables use of BatchedMesh #417

gkjohnson opened this issue Nov 15, 2023 · 4 comments · Fixed by #800
Milestone

Comments

@gkjohnson
Copy link
Contributor

gkjohnson commented Nov 15, 2023

Provide a variant of 3d tiles renderer that uses three.js' BatchedMesh to reduce draw calls. Related to gkjohnson/batched-3d-tiles-demo.

Useful for things like google earth and mars tiles.

For an initial set of requirements:

  • Requires all geometry to be of a similar size or maximum-size.
  • Requires that all geometry use a similar size of texture and at most one texture.
  • Requires that all tiles must use a common tile material / shader.

Process:

  • On geometry load copy the texture into a texture array and geometry into the BatchedMesh in a pre-determined buffer size along with the transform.
  • Discard the original geometry on load and store the BatchedMesh and texture index.
  • If we find a mesh that is too large to fit in the pre-allocated buffer length then create a new BatchedMesh.
    • instead we can just ask for a larger buffer allocation than is typical and optimize / expand later if we reach capacity
  • Implement a custom traversal algorithm for raycasting against batched mesh.
    • Specifically we'll want to support individually intersecting each tile from within the batched mesh to take advantage of the 3d tiles hierarchy

Open Questions:

  • Interoperability with other plugins (custom fade shader, etc)?
    • Unsupported for now
  • What happens if something like bvh is used under the hood?
    • Separate plugin required
@gkjohnson gkjohnson added this to the v0.x.x milestone Nov 15, 2023
@gkjohnson gkjohnson modified the milestones: v0.x.x, v0.3.32 Mar 28, 2024
@gkjohnson gkjohnson modified the milestones: v0.3.32, v0.3.33 Apr 24, 2024
@gkjohnson gkjohnson modified the milestones: v0.3.33, v0.3.34 May 14, 2024
@gkjohnson gkjohnson changed the title Consider derivative class that uses / enables use of BatchedMesh Plugins: Consider plugin that uses / enables use of BatchedMesh Jul 23, 2024
@gkjohnson
Copy link
Contributor Author

gkjohnson commented Jul 23, 2024

From #628

Related to #604

Add a plugin that fills in a BatchedMesh with the loaded tiles geometry, uses a custom material with support for reading from a texture array, and uploading textures to an array.

See proof of concept here.

Approach

  • Create a preallocated BatchedMesh with enough space and large enough slots for the number of tiles to be rendered.
  • Preallocate a texture array with enough space for each texture needed.
  • Auto expand allocations if needed.
  • Custom materials for rendering with albedo from texture array.
  • We can lose original references to loaded geometry.

Changes Needed

  • Ray casting must change
  • Approach for storing internally references to geometry must change
  • Lots of internal callbacks and functions that rely on "scene" would have to change

Limitations

  • Will not work with Fading tiles.
  • Will only work with tile albedo.

@gkjohnson
Copy link
Contributor Author

gkjohnson commented Sep 11, 2024

To start this could be developed to only work in simple cases (eg earth globe tiles)

@gkjohnson
Copy link
Contributor Author

gkjohnson commented Oct 7, 2024

BatchedMesh optimizing and resizing will help here when we want to resize the gometry to support more / larger tiles than originally anticipated:

@gkjohnson
Copy link
Contributor Author

gkjohnson commented Oct 10, 2024

Options

{
  instanceCount,
  vertexCount,
  indexCount,

  expansionPercent,
  maxExpansionCount,
  
  // possibly just inherit?
  textureSize, generateMipmaps, wrapping, etc,
  material,
}

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 a pull request may close this issue.

1 participant