Filament sample Android apps

This directory contains several sample Android applications that demonstrate how to use the Filament APIs. Click the name of a sample to browse its source code.

hello-trianglelit-cubetextured-objectimage-based-lighting
Hello TriangleLit CubeTextured ObjectImage-based Lighting
Demonstrates how to set up a rendering surface for Filament and draw a simple animated triangle. This is the best starting point for learning the basic structure of a Filament app.Demonstrates how to create a light and a mesh with the attributes required for lighting.Demonstrates how to load and use textures for complex materials.Demonstrates how to create image-based lights and load complex meshes.
material-buildergltf-viewertransparent-viewtexture-view
Material BuilderglTF ViewerTransparent ViewTexture View
Demonstrates how to programmatically generate Filament materials on the device with MaterialBuilder, as opposed to compiling them on the host machine with matc. This approach increases the size of the app because it requires the filamat library.Demonstrates how to load glTF models with ModelViewer and how to use the camera manipulator. The app can also receive models, zipped glTF files, and HDR environments from a desktop browser through the remote page.Demonstrates how to render into a transparent SurfaceView so that Android views placed beneath it remain visible.Demonstrates how to render into a TextureView instead of a SurfaceView.
multi-viewtexture-targetprocedural-effectprocedural-texture-quad
Multi ViewTexture TargetProcedural EffectProcedural Texture Quad
Demonstrates how to render a single scene with multiple Filament Views, each with its own viewport. One of the views is drawn on top of the others with translucent blending.Demonstrates how to render a scene off-screen into a texture with a RenderTarget, and then use that texture on a quad drawn on screen. By default, the texture is backed by an Android HardwareBuffer and sampled as an external texture.Demonstrates attribute-less rendering, where the vertex shader generates a full-screen quad from the vertex index without any vertex attributes. The fragment shader then draws an animated procedural pattern driven by a time parameter.Demonstrates how to draw a textured quad whose geometry is generated entirely in the vertex shader from the vertex index. This shows that attribute-less geometry can still be combined with regular texture sampling.
hello-camerastream-testtime-projectionmaterial-instance-stress
Hello CameraStream TestTime ProjectionMaterial Instance Stress
Demonstrates how to use Stream with Android's Camera2 API.Tests the various ways to interact with Stream by drawing into an external texture using Canvas. If the two sets of stripes in the screenshot are perfectly aligned, then the Filament frame and the external texture are perfectly synchronized.Demonstrates frame pacing with FramePacer and how to drive material animation from the expected presentation time instead of the vsync time. The clock hand advances by exactly one step per frame, so dropped or late frames are easy to spot. Switches let you inject pauses, change the target frame rate, and compare the two timing modes.Stress-tests the engine by rendering a grid of 1,000 cubes, each with its own MaterialInstance. The color, roughness, and scale of every cube are updated on each frame.
page-curllive-wallpaperrender-validationcpp-viewer
Page CurlLive WallpaperRender ValidationC++ Viewer
Pure Java app that demonstrates custom vertex shader animation and two-sided texturing. Applies the deformation described in "Deforming Pages of Electronic Books" by Hong et al. Users can drag horizontally to turn the page.Demonstrates how to use Filament as the renderer for an Android Live Wallpaper.A tool that renders glTF test scenes with ModelViewer on each configured backend, such as OpenGL and Vulkan, and compares the results against golden images. Tests are packaged as zip bundles that contain a JSON configuration, models, and goldens, and the app can generate the goldens on the device. Failing tests are shown with their difference images.Runs the cross-platform C++ samples from the top-level samples/ directory on Android through JNI. A drop-down menu switches between samples such as hellotriangle, suzanne, and shadowtest, and a specific sample can be launched with adb shell am start and the sample extra.

Building Samples

Before you start, make sure to read Filament's README. You need to be able to compile Filament's native library and Filament's AAR for this project. The easiest way to proceed is to install all the required dependencies and to run the following commands at the root of the source tree.

To build the samples, please follow the steps described in BUILDING.md