diff --git a/android/samples/material-builder/app/build.gradle b/android/samples/material-builder/app/build.gradle index 1d634c0ec0..70c0e69eb4 100644 --- a/android/samples/material-builder/app/build.gradle +++ b/android/samples/material-builder/app/build.gradle @@ -73,6 +73,13 @@ android { } } + // The filamat library has two variants: full and lite. Here we default to the "full" variant. + // Replace "full" with "lite" to use the filamat-lite variant, which has a smaller binary size + // but comes with certain restrictions. See "Filamat Lite" in libs/filamat/README.md. + defaultConfig { + missingDimensionStrategy 'functionality', 'full' + } + // We use the .filamat extension for materials compiled with matc // Telling aapt to not compress them allows to load them efficiently aaptOptions { diff --git a/android/samples/material-builder/app/src/main/assets/models/shader_ball.filamesh b/android/samples/material-builder/app/src/main/assets/models/shader_ball.filamesh index f33c4a08b5..0079be3f4c 100644 Binary files a/android/samples/material-builder/app/src/main/assets/models/shader_ball.filamesh and b/android/samples/material-builder/app/src/main/assets/models/shader_ball.filamesh differ diff --git a/android/samples/material-builder/app/src/main/java/com/google/android/filament/material_builder/MainActivity.kt b/android/samples/material-builder/app/src/main/java/com/google/android/filament/material_builder/MainActivity.kt index f015f2aa9c..c5e1dfd1fa 100644 --- a/android/samples/material-builder/app/src/main/java/com/google/android/filament/material_builder/MainActivity.kt +++ b/android/samples/material-builder/app/src/main/java/com/google/android/filament/material_builder/MainActivity.kt @@ -212,6 +212,10 @@ class MainActivity : Activity() { " material.clearCoat = 1.0;\n" + "}\n") + // Turn off shader code optimization so this sample is compatible with the "lite" + // variant of the filamat library. + .optimization(MaterialBuilder.Optimization.NONE) + .build() if (matPackage.isValid) { diff --git a/libs/filamat/src/sca/GLSLToolsLite.cpp b/libs/filamat/src/sca/GLSLToolsLite.cpp index 5f3927f774..6a995905c4 100644 --- a/libs/filamat/src/sca/GLSLToolsLite.cpp +++ b/libs/filamat/src/sca/GLSLToolsLite.cpp @@ -79,6 +79,10 @@ bool GLSLToolsLite::findProperties( filament::backend::ShaderType type, const utils::CString& material, MaterialBuilder::PropertyList& properties) const noexcept { + if (material.empty()) { + return true; + } + const std::string shaderCode = stripComments(material.c_str()); size_t start = 0, end = 0;