Convert Figma logo to code with AI

google logofilament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

17,590
1,856
17,590
153

Top Related Projects

One stop solution for all Vulkan samples

14,858

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

6,830

minimal cross-platform standalone C headers

Vulkan & C++17 based Scene Graph Project

59,344

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Quick Overview

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, and macOS. Developed by Google, it is designed to be as small as possible and optimized for mobile platforms while still maintaining high performance and visual quality.

Pros

  • Cross-platform support for multiple operating systems
  • Physically based rendering for realistic lighting and materials
  • Optimized for mobile devices, ensuring good performance on resource-constrained hardware
  • Extensive documentation and examples provided by Google

Cons

  • Steep learning curve for developers new to graphics programming
  • Limited built-in support for advanced rendering techniques (e.g., ray tracing)
  • Requires C++ knowledge, which may be challenging for some developers
  • Smaller community compared to some other popular rendering engines

Code Examples

  1. Creating a simple scene:
#include <filament/Engine.h>
#include <filament/Scene.h>
#include <filament/View.h>

filament::Engine* engine = filament::Engine::create();
filament::Scene* scene = engine->createScene();
filament::View* view = engine->createView();
view->setScene(scene);
  1. Loading and rendering a model:
#include <filament/Material.h>
#include <filament/RenderableManager.h>

filament::Material* material = Material::Builder()
    .package(MATERIAL_PACKAGE)
    .build(*engine);

filament::RenderableManager::Builder(1)
    .geometry(0, RenderableManager::PrimitiveType::TRIANGLES, vertexBuffer, indexBuffer)
    .material(0, material->getDefaultInstance())
    .build(*engine, entity);

scene->addEntity(entity);
  1. Setting up a camera:
#include <filament/Camera.h>
#include <utils/EntityManager.h>

utils::Entity cameraEntity = utils::EntityManager::get().create();
filament::Camera* camera = engine->createCamera(cameraEntity);
view->setCamera(camera);

camera->setProjection(60.0f, (float) width / height, 0.1f, 100.0f);
camera->lookAt({0, 0, 4}, {0, 0, 0});

Getting Started

To get started with Filament:

  1. Clone the repository:

    git clone https://github.com/google/filament.git
    
  2. Install dependencies (varies by platform, see documentation)

  3. Build Filament:

    cd filament
    ./build.sh release
    
  4. Include Filament in your project and start using it:

    #include <filament/Engine.h>
    
    filament::Engine* engine = filament::Engine::create();
    // Your Filament code here
    

For more detailed instructions and examples, refer to the official Filament documentation.

Competitor Comparisons

One stop solution for all Vulkan samples

Pros of Vulkan-Samples

  • Focuses specifically on Vulkan, providing in-depth examples and best practices
  • Offers a wide range of samples covering various Vulkan features and techniques
  • Maintained by Khronos Group, ensuring up-to-date and standard-compliant examples

Cons of Vulkan-Samples

  • Limited to Vulkan API, not suitable for cross-platform or multi-API projects
  • Primarily educational, may require additional work to integrate into production projects
  • Lacks a complete rendering engine framework, focusing more on individual techniques

Code Comparison

Vulkan-Samples (Vulkan initialization):

VkInstanceCreateInfo instance_info{};
instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
vkCreateInstance(&instance_info, nullptr, &instance);

Filament (Engine initialization):

Engine* engine = Engine::create();
Renderer* renderer = engine->createRenderer();
Scene* scene = engine->createScene();

Summary

Vulkan-Samples is ideal for learning Vulkan and exploring specific techniques, while Filament provides a more comprehensive rendering engine suitable for production use across multiple platforms and APIs. Vulkan-Samples offers deeper Vulkan-specific insights, whereas Filament abstracts low-level details for easier development.

14,858

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Pros of bgfx

  • More flexible and customizable, allowing for lower-level control
  • Supports a wider range of platforms and rendering APIs
  • Lighter weight and potentially better performance for specific use cases

Cons of bgfx

  • Steeper learning curve and requires more manual setup
  • Less comprehensive built-in features compared to Filament
  • Documentation may be less extensive and user-friendly

Code Comparison

bgfx:

bgfx::init();
bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0);
bgfx::setViewRect(0, 0, 0, uint16_t(width), uint16_t(height));
bgfx::touch(0);
bgfx::frame();

Filament:

Engine* engine = Engine::create();
Renderer* renderer = engine->createRenderer();
Scene* scene = engine->createScene();
View* view = engine->createView();
view->setScene(scene);
renderer->render(view);

Both libraries provide low-level graphics rendering capabilities, but bgfx offers more granular control at the cost of increased complexity, while Filament provides a more structured and feature-rich environment out of the box. The choice between them depends on project requirements, target platforms, and developer preferences.

6,830

minimal cross-platform standalone C headers

Pros of sokol

  • Lightweight and minimalistic, focusing on simplicity and ease of use
  • Cross-platform support with a single-file header-only design
  • Faster compilation times due to its compact nature

Cons of sokol

  • Less feature-rich compared to Filament's comprehensive rendering capabilities
  • Limited documentation and examples compared to Filament's extensive resources
  • Smaller community and ecosystem support

Code Comparison

Sokol (simple window creation):

#include "sokol_app.h"
#include "sokol_gfx.h"

sapp_desc sokol_main(int argc, char* argv[]) {
    return (sapp_desc){ .width = 800, .height = 600, .init_cb = init, .frame_cb = frame };
}

Filament (basic rendering setup):

#include <filament/Engine.h>
#include <filament/Renderer.h>

auto engine = Engine::create();
auto renderer = engine->createRenderer();
renderer->setClearOptions({.clearColor = {0.1, 0.2, 0.3, 1.0}, .clear = true});

Both repositories offer different approaches to graphics programming, with sokol focusing on simplicity and Filament providing a more comprehensive rendering solution. The choice between them depends on project requirements and developer preferences.

Vulkan & C++17 based Scene Graph Project

Pros of VulkanSceneGraph

  • Focused specifically on Vulkan, providing a more specialized and optimized solution for Vulkan-based applications
  • Offers a higher-level scene graph abstraction, simplifying complex scene management
  • Actively developed with frequent updates and community contributions

Cons of VulkanSceneGraph

  • Limited to Vulkan, whereas Filament supports multiple backends (OpenGL, Vulkan, Metal)
  • Smaller community and ecosystem compared to Filament's Google-backed development
  • Steeper learning curve for developers not familiar with scene graph concepts

Code Comparison

VulkanSceneGraph:

auto root = vsg::Group::create();
auto transform = vsg::MatrixTransform::create();
auto geometry = vsg::GeometryNode::create();
transform->addChild(geometry);
root->addChild(transform);

Filament:

auto& engine = Engine::create();
auto entity = EntityManager::get().create();
auto& tcm = engine->getTransformManager();
auto instance = tcm.create(entity);
tcm.setParent(instance, rootTransform);

Both libraries provide abstractions for scene management, but VulkanSceneGraph offers a more explicit scene graph structure, while Filament uses an entity-component system approach.

59,344

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Pros of ImGui

  • Lightweight and easy to integrate into existing projects
  • Immediate mode GUI, allowing for rapid prototyping and dynamic interfaces
  • Cross-platform compatibility with minimal dependencies

Cons of ImGui

  • Limited built-in styling options compared to Filament's advanced rendering capabilities
  • Lacks a comprehensive scene graph or 3D rendering features
  • May require more manual management for complex UI layouts

Code Comparison

ImGui (basic window creation):

ImGui::Begin("Hello, world!");
ImGui::Text("This is some useful text.");
ImGui::End();

Filament (basic rendering setup):

Engine* engine = Engine::create();
Renderer* renderer = engine->createRenderer();
Scene* scene = engine->createScene();
View* view = engine->createView();

Summary

ImGui is a lightweight, immediate mode GUI library ideal for quick prototyping and simple interfaces. Filament, on the other hand, is a full-featured physically-based rendering engine with more advanced capabilities for 3D graphics and complex scenes. While ImGui excels in ease of use and rapid development, Filament offers more powerful rendering features and better performance for complex 3D applications. The choice between the two depends on the specific requirements of your project, with ImGui being more suitable for simple GUI needs and Filament for advanced 3D rendering tasks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Filament

Android Build Status iOS Build Status Linux Build Status macOS Build Status Windows Build Status Web Build Status

Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small as possible and as efficient as possible on Android.

Download

Download Filament releases to access stable builds. Filament release archives contains host-side tools that are required to generate assets.

Make sure you always use tools from the same release as the runtime library. This is particularly important for matc (material compiler).

If you'd rather build Filament yourself, please refer to our build manual.

Android

Android projects can simply declare Filament libraries as Maven dependencies:

repositories {
    // ...
    mavenCentral()
}

dependencies {
    implementation 'com.google.android.filament:filament-android:1.54.3'
}

Here are all the libraries available in the group com.google.android.filament:

ArtifactDescription
filament-androidThe Filament rendering engine itself.
filament-android-debugDebug version of filament-android.
gltfio-androidA glTF 2.0 loader for Filament, depends on filament-android.
filament-utils-androidKTX loading, Kotlin math, and camera utilities, depends on gltfio-android.
filamat-androidA runtime material builder/compiler. This library is large but contains a full shader compiler/validator/optimizer and supports both OpenGL and Vulkan.
filamat-android-liteA much smaller alternative to filamat-android that can only generate OpenGL shaders. It does not provide validation or optimizations.

iOS

iOS projects can use CocoaPods to install the latest release:

pod 'Filament', '~> 1.54.3'

Documentation

  • Filament, an in-depth explanation of real-time physically based rendering, the graphics capabilities and implementation of Filament. This document explains the math and reasoning behind most of our decisions. This document is a good introduction to PBR for graphics programmers.
  • Materials, the full reference documentation for our material system. This document explains our different material models, how to use the material compiler matc and how to write custom materials.
  • Material Properties, a reference sheet for the standard material model.

Examples

Night scene Night scene Materials Materials Helmet Screen-space refraction

Features

APIs

  • Native C++ API for Android, iOS, Linux, macOS and Windows
  • Java/JNI API for Android
  • JavaScript API

Backends

  • OpenGL 4.1+ for Linux, macOS and Windows
  • OpenGL ES 3.0+ for Android and iOS
  • Metal for macOS and iOS
  • Vulkan 1.0 for Android, Linux, macOS, and Windows
  • WebGL 2.0 for all platforms

Rendering

  • Clustered forward renderer
  • Cook-Torrance microfacet specular BRDF
  • Lambertian diffuse BRDF
  • Custom lighting/surface shading
  • HDR/linear lighting
  • Metallic workflow
  • Clear coat
  • Anisotropic lighting
  • Approximated translucent (subsurface) materials
  • Cloth/fabric/sheen shading
  • Normal mapping & ambient occlusion mapping
  • Image-based lighting
  • Physically-based camera (shutter speed, sensitivity and aperture)
  • Physical light units
  • Point lights, spot lights, and directional light
  • Specular anti-aliasing
  • Point, spot, and directional light shadows
  • Cascaded shadows
  • EVSM, PCSS, DPCF, or PCF shadows
  • Transparent shadows
  • Contact shadows
  • Screen-space ambient occlusion
  • Screen-space reflections
  • Screen-space refraction
  • Global fog
  • Dynamic resolution (with support for AMD FidelityFX FSR)

Post processing

  • HDR bloom
  • Depth of field bokeh
  • Multiple tone mappers: generic (customizable), ACES, filmic, etc.
  • Color and tone management: luminance scaling, gamut mapping
  • Color grading: exposure, night adaptation, white balance, channel mixer, shadows/mid-tones/highlights, ASC CDL, contrast, saturation, etc.
  • TAA, FXAA, MSAA
  • Screen-space lens flares

glTF 2.0

  • Encodings

    • Embeded
    • Binary
  • Primitive Types

    • Points
    • Lines
    • Line Loop
    • Line Strip
    • Triangles
    • Triangle Strip
    • Triangle Fan
  • Animation

    • Transform animation
    • Linear interpolation
    • Morph animation
      • Sparse accessor
    • Skin animation
    • Joint animation
  • Extensions

    • KHR_draco_mesh_compression
    • KHR_lights_punctual
    • KHR_materials_clearcoat
    • KHR_materials_emissive_strength
    • KHR_materials_ior
    • KHR_materials_pbrSpecularGlossiness
    • KHR_materials_sheen
    • KHR_materials_transmission
    • KHR_materials_unlit
    • KHR_materials_variants
    • KHR_materials_volume
    • KHR_materials_specular
    • KHR_mesh_quantization
    • KHR_texture_basisu
    • KHR_texture_transform
    • EXT_meshopt_compression

Rendering with Filament

Native Linux, macOS and Windows

You must create an Engine, a Renderer and a SwapChain. The SwapChain is created from a native window pointer (an NSView on macOS or a HWND on Windows for instance):

Engine* engine = Engine::create();
SwapChain* swapChain = engine->createSwapChain(nativeWindow);
Renderer* renderer = engine->createRenderer();

To render a frame you must then create a View, a Scene and a Camera:

Camera* camera = engine->createCamera(EntityManager::get().create());
View* view = engine->createView();
Scene* scene = engine->createScene();

view->setCamera(camera);
view->setScene(scene);

Renderables are added to the scene:

Entity renderable = EntityManager::get().create();
// build a quad
RenderableManager::Builder(1)
        .boundingBox({{ -1, -1, -1 }, { 1, 1, 1 }})
        .material(0, materialInstance)
        .geometry(0, RenderableManager::PrimitiveType::TRIANGLES, vertexBuffer, indexBuffer, 0, 6)
        .culling(false)
        .build(*engine, renderable);
scene->addEntity(renderable);

The material instance is obtained from a material, itself loaded from a binary blob generated by matc:

Material* material = Material::Builder()
        .package((void*) BAKED_MATERIAL_PACKAGE, sizeof(BAKED_MATERIAL_PACKAGE))
        .build(*engine);
MaterialInstance* materialInstance = material->createInstance();

To learn more about materials and matc, please refer to the materials documentation.

To render, simply pass the View to the Renderer:

// beginFrame() returns false if we need to skip a frame
if (renderer->beginFrame(swapChain)) {
    // for each View
    renderer->render(view);
    renderer->endFrame();
}

For complete examples of Linux, macOS and Windows Filament applications, look at the source files in the samples/ directory. These samples are all based on libs/filamentapp/ which contains the code that creates a native window with SDL2 and initializes the Filament engine, renderer and views.

For more information on how to prepare environment maps for image-based lighting please refer to BUILDING.md.

Android

See android/samples for examples of how to use Filament on Android.

You must always first initialize Filament by calling Filament.init().

Rendering with Filament on Android is similar to rendering from native code (the APIs are largely the same across languages). You can render into a Surface by passing a Surface to the createSwapChain method. This allows you to render to a SurfaceTexture, a TextureView or a SurfaceView. To make things easier we provide an Android specific API called UiHelper in the package com.google.android.filament.android. All you need to do is set a render callback on the helper and attach your SurfaceView or TextureView to it. You are still responsible for creating the swap chain in the onNativeWindowChanged() callback.

iOS

Filament is supported on iOS 11.0 and above. See ios/samples for examples of using Filament on iOS.

Filament on iOS is largely the same as native rendering with C++. A CAEAGLLayer or CAMetalLayer is passed to the createSwapChain method. Filament for iOS supports both Metal (preferred) and OpenGL ES.

Assets

To get started you can use the textures and environment maps found respectively in third_party/textures and third_party/environments. These assets are under CC0 license. Please refer to their respective URL.txt files to know more about the original authors.

Environments must be pre-processed using cmgen or using the libiblprefilter library.

How to make contributions

Please read and follow the steps in CONTRIBUTING.md. Make sure you are familiar with the code style.

Directory structure

This repository not only contains the core Filament engine, but also its supporting libraries and tools.

  • android: Android libraries and projects
    • filamat-android: Filament material generation library (AAR) for Android
    • filament-android: Filament library (AAR) for Android
    • filament-utils-android: Extra utilities (KTX loader, math types, etc.)
    • gltfio-android: Filament glTF loading library (AAR) for Android
    • samples: Android-specific Filament samples
  • art: Source for various artworks (logos, PDF manuals, etc.)
  • assets: 3D assets to use with sample applications
  • build: CMake build scripts
  • docs: Documentation
    • math: Mathematica notebooks used to explore BRDFs, equations, etc.
  • filament: Filament rendering engine (minimal dependencies)
    • backend: Rendering backends/drivers (Vulkan, Metal, OpenGL/ES)
  • ide: Configuration files for IDEs (CLion, etc.)
  • ios: Sample projects for iOS
  • libs: Libraries
    • bluegl: OpenGL bindings for macOS, Linux and Windows
    • bluevk: Vulkan bindings for macOS, Linux, Windows and Android
    • camutils: Camera manipulation utilities
    • filabridge: Library shared by the Filament engine and host tools
    • filaflat: Serialization/deserialization library used for materials
    • filagui: Helper library for Dear ImGui
    • filamat: Material generation library
    • filamentapp: SDL2 skeleton to build sample apps
    • filameshio: Tiny filamesh parsing library (see also tools/filamesh)
    • geometry: Mesh-related utilities
    • gltfio: Loader for glTF 2.0
    • ibl: IBL generation tools
    • image: Image filtering and simple transforms
    • imageio: Image file reading / writing, only intended for internal use
    • matdbg: DebugServer for inspecting shaders at run-time (debug builds only)
    • math: Math library
    • mathio: Math types support for output streams
    • utils: Utility library (threads, memory, data structures, etc.)
    • viewer: glTF viewer library (requires gltfio)
  • samples: Sample desktop applications
  • shaders: Shaders used by filamat and matc
  • third_party: External libraries and assets
    • environments: Environment maps under CC0 license that can be used with cmgen
    • models: Models under permissive licenses
    • textures: Textures under CC0 license
  • tools: Host tools
    • cmgen: Image-based lighting asset generator
    • filamesh: Mesh converter
    • glslminifier: Minifies GLSL source code
    • matc: Material compiler
    • matinfo Displays information about materials compiled with matc
    • mipgen Generates a series of miplevels from a source image
    • normal-blending: Tool to blend normal maps
    • resgen Aggregates binary blobs into embeddable resources
    • roughness-prefilter: Pre-filters a roughness map from a normal map to reduce aliasing
    • specular-color: Computes the specular color of conductors based on spectral data
  • web: JavaScript bindings, documentation, and samples

License

Please see LICENSE.

Disclaimer

This is not an officially supported Google product.