DEV Community

Cover image for How an AR Face Filter Works: Banuba Effect Folders Explained With Code
Banuba Official
Banuba Official

Posted on

How an AR Face Filter Works: Banuba Effect Folders Explained With Code

An AR face filter is a set of instructions that runs on every camera frame: find the face, fit a 3D mesh to it, then draw on that mesh. In the Banuba Face AR SDK the tracking is built in, and everything you author lives in one effect folder that you can read, diff and ship like code.

This is the smallest working filter in that folder. It is one file, and it draws black eyeliner:

{
    "scene": "Retouch example",
    "version": "2.0.0",
    "camera": {},
    "faces": [
        {
            "makeup_eyeliner": {
                "color": "0.0 0.0 0.0",
                "finish": "matte_liquid",
                "coverage": "hi"
            }
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

We build the Face AR SDK, so the examples use our effect format. Where another tool is the better fit, we say so.

What happens on each frame when an AR face filter runs?

Three jobs run in a fixed order. Face detection finds the face in the frame. Face tracking follows the face from frame to frame and builds a model of it. A rendering engine then draws the effect on that model, so the effect moves with the head and the expression.

In our SDK the tracking step works from 68 facial anchor points and reconstructs a face mesh of up to 3,308 vertices, holding tracking across a head-angle range of -80° to +80° and under up to 70% facial occlusion, per Banuba's 3D face animation write-up. The face filters product page states the same head-angle range and 30 FPS on mid-range mobile hardware. All tracking and rendering run on-device.

Your effect does not call the tracker. It names prefabs, and each prefab is a high-level object that bundles the rendering and SDK features it needs. So the SDK owns detection and tracking, and the effect folder owns what gets drawn and when.

What is inside a Banuba effect folder?

Every effect is a folder with files that have a fixed meaning:

effect_folder/
 |-- config.json
 |-- config.js
 |-- images/
 |-- shaders/
 |-- videos/
Enter fullscreen mode Exit fullscreen mode

Our effect structure documentation says that "Only config.json is mandatory". config.js is optional and holds JavaScript logic. The subfolders have no special meaning; they group the files that config.json or config.js refer to.

Because the effect is plain files, it goes into version control next to your app code. On the web, the SDK loads an effect only as a .zip archive of this folder, so Player.applyEffect expects that archive rather than a loose folder.

How does config.json describe an AR face filter?

config.json names the scene, the format version and the prefabs. On the version field the docs are direct: "Always set it to "2.0.0". The previous version is designed for the complex legacy effects." And "camera" "tells that you will render camera feed on the screen".

A prefab is a high-level object for a set of rendering and SDK features. The prefab reference is organised into six groups:

  1. On Face: prefabs attached to a face, for example a GLTF 3D model.
  2. Makeup: makeup features, also attached to a face.
  3. Top Level: prefabs that affect the whole screen, such as background, foreground and lut.
  4. On Hands: effects applied to hands.
  5. Sprites: simple 2D sprites.
  6. Sounds: audio.

Face prefabs sit inside the faces array, one object per tracked face. The eyeliner example above uses one makeup prefab on the first face. A dog-ears mask would be a GLTF prefab in the same place, and a replaced background would be a top-level background prefab outside the array.

How do you make a filter react to the user?

Reactions go in config.js, and hand gestures are the example the docs document end to end. The SDK recognizes 5 gestures: Like, Ok, Palm, Rock and Victory, read through hand.getGesture(). Value 0 is NO_GESTURE, meaning no hand in frame.

This listener fires an effect event once, when the user starts the rock gesture:

bnb.scene.enableRecognizerFeature(bnb.FeatureID.HAND_GESTURES)

const hand = bnb.scene.getAssetManager().findHand("hand_skelet")
let previousGesture = bnb.GestureType.NO_GESTURE

bnb.eventListener.on("onUpdate", () => {
    const gesture = hand.getGesture()
    if (gesture === bnb.GestureType.ROCK && gesture !== previousGesture) {
        bnb.scene.addEffectEvent("gesture", { type: "Rock" })
        // Add your animation, sound, or other custom action here.
    }
    previousGesture = gesture
})
Enter fullscreen mode Exit fullscreen mode

hand_skelet is the hand asset that the test_gestures sample effect defines in its config.json. The onUpdate listener runs on every frame, so the comparison with previousGesture stops the action from repeating while the gesture is held.

Two limits come with this feature. Our hand gesture guide states that "Hand gesture tracking requires the Hand gesture tracking neural network", so check that your license plan includes one. The same guide reports 30 FPS on every device tier Banuba tests, with a maximum recognition distance of 2.5 m, and adds that "The figures were measured under fixed lab conditions, so treat them as a reference". On Unity, enabling hand gestures also enables hand skeleton tracking.

How does your app change a running filter?

Your app talks to a loaded effect with evalJs(), which runs JavaScript inside that effect. This is how a slider in your UI changes a filter without loading a new one.

The prefab must already be in the loaded config.json. To find its instance name, take bnb_, add the prefab name, then add the zero-based face index:

Prefab name in JSON JavaScript class Instance for face index 0
eyes_whitening EyesWhitening bnb_eyes_whitening0
makeup_lipstick MakeupLipstick bnb_makeup_lipstick0
makeup_lipsgloss MakeupLipsgloss bnb_makeup_lipsgloss0

Top-level prefabs take no index, so background is bnb_background.

The same call on 3 platforms sets the eye whitening strength to 0.5. On iOS:

// currentEffect is the BNBEffect your app loaded
currentEffect?.evalJs("bnb_eyes_whitening0.strength(0.5)", resultCallback: nil)
Enter fullscreen mode Exit fullscreen mode

On Android:

// mCurrentEffect is the Effect your app loaded
mCurrentEffect.evalJs("bnb_eyes_whitening0.strength(0.5)", null);
Enter fullscreen mode Exit fullscreen mode

On the web:

import { Webcam, Player, Effect, Module, Dom } from "https://cdn.jsdelivr.net/npm/@banuba/webar@1.18.7/dist/BanubaSDK.browser.esm.js"

// clientToken is your Banuba client token
const player = await Player.create({ clientToken: "xxx-xxx-xxx" })
await player.addModule(new Module("https://cdn.jsdelivr.net/npm/@banuba/webar@1.18.7/dist/modules/face_tracker.zip"))

const webcam = new Webcam()
await player.use(webcam)

// my_filter.zip is your effect folder, compressed
const effect = new Effect("my_filter.zip")
await player.applyEffect(effect)
Dom.render(player, "#webar-app")

await effect.evalJs("bnb_eyes_whitening0.strength(0.5)")

// When the user leaves the camera screen
webcam.stop()
Dom.unmount("#webar-app")
player.destroy()
Enter fullscreen mode Exit fullscreen mode

Version 1.18.7 of @banuba/webar is the current release on npm as of 26 November 2026, so pin it rather than tracking latest.

The last three lines matter on the web. A page that starts and stops the camera without player.destroy() leaves the player object in browser memory.

To change several settings at once, call setPrefabSettings() with the same object you would write in JSON. Pass every required parameter, because the method reapplies the settings and does not merge a partial object. To swap a whole prefab, reloadConfig() replaces the effect's configuration.

How much does an AR face filter cost the device?

The answer depends on whether the filter needs only face tracking or also a neural network. Our technical specification publishes real-time figures for "Face AR effects which only require face tracking, i.e. face filters, avatars with action units, beautification, and makeup filter (without lipstick)":

Device tier (Banuba lab figures) Real-time FPS
Android Low 25
Android High 29
iOS Mid 30
iOS High 30

Put as a sentence, a face-tracking-only effect runs at 25 FPS on Android Low, 29 FPS on Android High, and 30 FPS on iOS Mid and iOS High. These are Banuba's own measurements for the native SDKs, taken under fixed lab conditions, read from the specification in December 2026. That table carries no browser figures, so do not carry these numbers to the web.

A neural network adds cost. Lipstick needs the lips segmentation network, and the demo effects list marks every segmentation effect with a warning that performance can be lower on mid-end and low-end devices. Decide early which prefabs a filter needs, then run the filter on the weakest Android and iOS phones in your user base before the art is final.

Where do the effect files come from?

There are 3 routes, and most teams use more than one:

  1. Write the folder by hand, as in this article. The docs offer downloadable demo effects, such as test_gestures, to start from.
  2. Build the 3D asset in any 3D editor, then convert it to the SDK format in Banuba Studio, which also previews the effect on a live camera. Our walkthrough creates a face filter in Banuba Studio step by step.
  3. License ready-made filters from the Banuba Asset Store.

The effect folder is the part that platform tools do not give you. Snap's Lens Studio and TikTok's Effect House win if your audience lives inside Snapchat or TikTok. An effect made there runs inside those apps, not inside yours, and it waits for platform moderation. The third option of that kind is gone: Meta announced in August 2024 that Meta Spark would close to third-party creators on 14 January 2025.

A face filter SDK is the other shape of product: a licensed SDK that renders filters inside your own iOS, Android, web or desktop app. It does not publish to social platforms, and it is not free to ship to production.

An AR face filter is a folder your team owns

The SDK handles detection, tracking and rendering on the device. Your team owns a folder: config.json says what to draw, config.js says when, and evalJs() lets the app change it while it runs. Plan the prefabs against the FPS table early, because a segmentation network costs frames on low-end phones. When the folder works, connect it to your app with our 6-step Face AR SDK integration guide.

FAQ

Which platforms run a Banuba Face AR SDK face filter?

Per Banuba's Face AR SDK pricing guide, the SDK ships to Android, iOS, Web, macOS, Windows, Unity, React Native and Flutter. Banuba builds and maintains every one of them.

How much does the Banuba Face AR SDK cost?

Banuba prices the Face AR SDK as a custom quote, MAU-based. The pricing guide states that there is "no public price list, no 'starting at' anchor, and no per-developer seat fee", and that a quote is built from the platforms you ship on, the feature categories you activate, and your monthly active users. A 14-day free trial covers every feature on every supported platform.

Top comments (0)