Prefabs Overview
A prefab is a high-level object that represents a set of rendering and SDK features.
Prefabs are divided into several types:
- On Face - prefabs that depend on a face.
- Makeup - prefabs that represent makeup features and also depend on a face.
- Top Level - prefabs that affect the entire screen and are not attached to a face.
- On Hands - prefabs that apply effects to hands.
- Sprites - prefabs that represent simple 2D sprites.
- Sounds - prefabs that represent audio.
Example prefab configuration:
{
"scene": "effect name",
"version": "2.0.0",
"camera": {},
// Top level prefabs
"background": {
// ...
},
"foreground": {
// ...
},
"lut": {
// ...
},
"lights": {
// ...
},
"msaa": {
// ...
},
// On Face
"faces": [
{
// first face
"face_prefab1": {
//...
},
"makeup_prefab1": {
//...
}
// ...
},
{
// second face
}
// ..
],
// Sounds
"sounds": [
{
"sound_prefab1": {
//...
},
"sound_prefab2": {
//...
}
// ...
}
],
// Sprites
"sprites": [
{
"sprite_prefab1": {
//...
},
"sprite_prefab2": {
//...
}
// ...
}
// ...
]
}
Where:
scene- the name of your effect.version- the version of this configuration file. Always set it to2.0.0. Earlier versions are intended for complex legacy effects.camera- indicates that the camera feed will be rendered on the screen.faces- an array of JSON objects describing the features to place on each face. For each face, define a JSON object whose keys are prefab names and whose values are the parameters for those prefabs.top_level_prefab- one of the top-level prefabs.sprites- an array of JSON objects describing sprite features.sounds- an array of JSON objects describing sound features.
tip
You can create an effect with any set of prefabs.
tip
You can change an effect at runtime by calling the reload_config() or reloadConfig() method:
- C++
- Java
- Swift
- JavaScript
constexpr auto new_config = R"(
{
"camera" : {},
"background" : {
// ...
}
}
)";
effect_player->effect_manager()->reload_config(new_config);
import com.banuba.sdk.player.Player
// ...
val newConfig =
"" "
{
"camera" : {},
"background" : {
// ...
}
}
"" ";
player.effectPlayer.effectManager()
.reloadConfig(newConfig)
import BanubaEffectPlayer
// ...
let newConfig = """
{
"camera": {},
"background": {
// ...
}
}
""";
player.effectPlayer?.effectManager().reloadConfig(newConfig)
const new_config =
`{
"camera": {},
"background": {
// ...
}
}`
player._effectManager.reloadConfig(new_config)
note
Colors are represented as three- or four-component strings. Each component is a value in
the range [0, 1] or [0, 255], and components are separated by spaces. For example,
1 0 0 1 represents red. HTML-style hex strings are also accepted. For example,
#00FF00 represents green; an alpha value of FF is assumed when omitted.