Google Filament

From David's Wiki
Revision as of 04:33, 12 March 2025 by David (talk | contribs) (→‎Fragment shader)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Notes on using Filament, the rendering engine for many Google applications.

Note that Filament is not a replacement for Unity or Godot.

Types

Materials

In filament, shaders are written as materials. The documentation for materials is available at https://google.github.io/filament/Materials.html

Vertex shader

Unlike standard OpenGL shaders, you cannot output arbitrary positions in the vertex shader.

You can: 1. Modify the world position of the vertices. 2. Send interpolants, aka varyings, to the pixel shader. 3. Use a custom 4x4 matrix to transform coordinates from local to clip space.

Fragment shader

The fragment shader expects the output to be in premultiplied alpha.