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

Custom shader & runtime material switching support #64

Open
kerberjg opened this issue Jul 17, 2024 · 2 comments
Open

Custom shader & runtime material switching support #64

kerberjg opened this issue Jul 17, 2024 · 2 comments

Comments

@kerberjg
Copy link

AFAIK Filament supports custom shader compilation/rendering, but I haven't found any references to it in Thermion's docs.

Is it something that has been experimented with? Can they be loaded as part of the GLTF/GLB format? (assuming that's supported)

I'm happy to help out on this if needed 🤗✨

@nmfisher
Copy link
Owner

Thanks for bringing this up, it's something I've wanted to look at more closely. Currently, you can only load custom materials:

  • by passing a materialPath when creating custom geometry (which probably isn't relevant to your question).
  • if you pass uberarchivePath to createViewer (then all gltf assets will be loaded with the specified ubershader archive, which is produced via the uberz tool)

The latter isn't a very flexible option, because then you're basically stuck with one set of materials for the lifetime of the viewer (though in some cases, maybe that's all you need).

Ideally, I think you should probably be able to 1) expose a function like createMaterialProvider(String path) to load materials from filamat files, and 2) accept a materialProvider parameter to loadGlb/loadGltf to specify a custom material for the asset (or fall-back to the ubershader if none is provided). This would probably also need to expose the whole MaterialInstance interface to the Dart bindings.

Can you give me more details about how you'd like to use custom materials?

@kerberjg
Copy link
Author

Sure!
I'd like to be able to load material definition files (as per Filament docs) on a per-entity basis at runtime.
AFAIK right now the only way to set a material on an entity is when creating the GLB/GLTF file, as the materials are embedded.
Another thing would be allowing the developers to change the material's properties at runtime as well.

I understand these need to be compiled with matc, so ideally Thermion would define a Flutter asset transformer to run on those material files at build-time.

I made sure to link relevant documentation above, I hope it's helpful 😊

@kerberjg kerberjg changed the title Custom shader support? Custom shader & runtime material switching support Jul 22, 2024
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