Content filters¶
A content filter says which items a game allows, by section, franchise or tag ("no logos, no weapons", "only this game's items"). The SDK applies it everywhere it picks or shows items: catalogue searches, random avatars, pickers, and every avatar a ctx loads, the player's own and everyone else's. The calls are in the C reference: content filters.
A short example¶
sona_catalogue *cat = NULL;
sona_filter *f = NULL;
sona_catalogue_load(ctx, "data/sona-catalogue.bin", &cat);
sona_filter_create(ctx, cat, &f);
/* no weapons, nothing horror, no alcohol */
sona_filter_preset(f, SONA_CONTENT_FAMILY);
/* no brand, team or game logos */
sona_filter_preset(f, SONA_CONTENT_NO_LOGOS);
/* every avatar the ctx reads from now on */
sona_ctx_set_filter(ctx, f);
/* a picker lists allowed items only */
sona_catalogue_query q = { 0 };
q.section = SONA_SECTION_SHIRT;
q.require = SONA_ITEM_OFFERED;
sona_filter_search(f, cat, &q, hits, 50, &total);
/* another player's avatar: denied items come off, with a report */
sona_avatar_add(ctx, their_manifest, NULL, &a);
/* ... once it has loaded ... */
sona_filter_report rep = { sizeof rep };
if (sona_avatar_filter_report(a, &rep) == SONA_OK && rep.count)
printf("%u items were taken out of this avatar\n", rep.count);
sona::Catalogue cat("data/sona-catalogue.bin", &ctx);
sona_filter *f = nullptr;
sona_filter_create(ctx.raw(), cat.raw(), &f);
// no weapons, nothing horror, no alcohol
sona_filter_preset(f, SONA_CONTENT_FAMILY);
// no brand, team or game logos
sona_filter_preset(f, SONA_CONTENT_NO_LOGOS);
// every avatar the ctx reads from now on
sona_ctx_set_filter(ctx.raw(), f);
// a picker lists allowed items only
sona_catalogue_query q = sona::query_defaults();
q.section = SONA_SECTION_SHIRT;
q.require = SONA_ITEM_OFFERED;
uint32_t hits[50], total = 0;
sona_filter_search(f, cat.raw(), &q, hits, 50, &total);
// another player's avatar: denied items come off, with a report
sona::Avatar a = ctx.add(their_manifest);
// ... once it has loaded ...
sona_filter_report rep = { (uint32_t)sizeof rep };
if (sona_avatar_filter_report(a.raw(), &rep) == SONA_OK && rep.count)
std::printf("%u items were taken out of this avatar\n", rep.count);
using var cat = SonaCatalogue.Load("data/sona-catalogue.bin", ctx);
using var f = SonaFilter.Create(cat, ctx);
// no weapons, nothing horror, no alcohol
f.Preset(SonaContentPreset.Family);
// no brand, team or game logos
f.Preset(SonaContentPreset.NoLogos);
// every avatar the ctx reads from now on
SonaFilter.SetOn(ctx, f);
// a picker lists allowed items only
var hits = f.Search(cat, SonaSection.Shirt, 50, out int total);
// another player's avatar: denied items come off, with a report
var a = ctx.Add(theirManifest);
// ... once it has loaded ...
var changes = SonaFilter.ReportOf(a);
if (changes.Count > 0) Console.WriteLine($"{changes.Count} items were taken out of this avatar");
// the crate has no filter wrapper: the C calls through sona_sys
let cat = Catalogue::load_with(ctx, "data/sona-catalogue.bin")?;
let mut f: *mut sona_sys::sona_filter = std::ptr::null_mut();
let mut hits = [0u32; 50];
let mut total = 0u32;
unsafe {
sona_sys::sona_filter_create(ctx.raw(), cat.raw(), &mut f);
// no weapons, nothing horror, no alcohol
sona_sys::sona_filter_preset(f, sona_sys::SONA_CONTENT_FAMILY);
// no brand, team or game logos
sona_sys::sona_filter_preset(f, sona_sys::SONA_CONTENT_NO_LOGOS);
// every avatar the ctx reads from now on
sona_sys::sona_ctx_set_filter(ctx.raw(), f);
// a picker lists allowed items only
let mut q: sona_sys::sona_catalogue_query = std::mem::zeroed();
q.section = sona_sys::SONA_SECTION_SHIRT as u32;
q.require = sona_sys::SONA_ITEM_OFFERED;
sona_sys::sona_filter_search(f, cat.raw(), &q, hits.as_mut_ptr(), 50,
&mut total);
}
// another player's avatar: denied items come off, with a report
let a = ctx.add(manifest, &AddOptions::default())?;
// ... once it has loaded ...
let mut rep: sona_sys::sona_filter_report = unsafe { std::mem::zeroed() };
rep.size = std::mem::size_of::<sona_sys::sona_filter_report>() as u32;
if unsafe { sona_sys::sona_avatar_filter_report(a.raw(),
&mut rep) } == sona_sys::SONA_OK && rep.count > 0 {
println!("{} items were taken out of this avatar", rep.count);
}
cat = sona.Catalogue("data/sona-catalogue.bin", ctx)
f = sona.Filter(cat, ctx)
# no weapons, horror or alcohol; no brand, team or game logos
f.preset("family", "no-logos")
# every avatar the ctx reads from now on
f.apply_to(ctx)
# a picker lists allowed items only
hits, total = f.search(cat, section="shirt", limit=50)
# another player's avatar: denied items come off, with a report
a = ctx.add(their_manifest)
# ... once it has loaded ...
changes = sona.filter_report(a)
if changes:
print(len(changes), "items were taken out of this avatar")
The sample samples/c/content_filter.c dresses a cast avatar in a shirt, a hat and a prop that the filter
denies, draws it before and after, then draws it once more through the ctx's copy of the filter, which gives the
same picture as the filtered manifest:
content_filter --catalogue sona-catalogue.bin --cast devs-cast.json --pick
53 \
--filter family,no-logos --out family --check
Rules¶
A filter starts from a catalogue (sona_filter_create) and copies what it needs of it, so the catalogue may be freed
first. Rules come in two kinds:
- Allow rules: with none, every item is allowed. With some, an item must match at least one of them.
- Deny rules: an item that matches one is denied.
An id rule (sona_filter_item) beats both, and a deny by id beats an allow by id. Each rule call adds to the rules;
sona_filter_reset drops them all.
| Rule | Call | Matches |
|---|---|---|
| Section | sona_filter_sections(f, mode, bits) |
1u << sona_section: shirt, headwear, carryable, ... |
| Slot | sona_filter_slots(f, mode, mask) |
items covering any of these AssetMask bits (0x1000 is every prop) |
| Game | sona_filter_game(f, mode, "name") |
the game, brand or collection an item comes from, as sona_catalogue_game names it |
| Tag | sona_filter_tag(f, mode, "weapon") |
a built-in tag, or one the host defined |
| Source | sona_filter_sources(f, mode, bits) |
SONA_CONTENT_STOCK, _AWARD, _MARKETPLACE, _CUSTOM (custom items), _UNLISTED (ids the catalogue lacks) |
| Item | sona_filter_item(f, mode, &id) |
one id, in the catalogue or not |
"Only this game" is two allow rules, so the avatar keeps its stock hair, eyes and clothes:
sona_filter_game(f, SONA_CONTENT_ALLOW, "Racer X");
sona_filter_sources(f, SONA_CONTENT_ALLOW, SONA_CONTENT_STOCK);
sona_filter *f = nullptr; // the filter above
sona_filter_game(f, SONA_CONTENT_ALLOW, "Racer X");
sona_filter_sources(f, SONA_CONTENT_ALLOW, SONA_CONTENT_STOCK);
using var cat = SonaCatalogue.Load("data/sona-catalogue.bin", ctx);
using var f = SonaFilter.Create(cat, ctx);
f.Game(true, "Racer X");
f.Sources(true, Native.SONA_CONTENT_STOCK);
// the filter above
let f: *mut sona_sys::sona_filter = std::ptr::null_mut();
unsafe {
sona_sys::sona_filter_game(f, sona_sys::SONA_CONTENT_ALLOW,
c"Racer X".as_ptr());
sona_sys::sona_filter_sources(f, sona_sys::SONA_CONTENT_ALLOW,
sona_sys::SONA_CONTENT_STOCK);
}
from sona._native import SONA_CONTENT_STOCK
f = sona.Filter(sona.Catalogue("data/sona-catalogue.bin", ctx), ctx)
f.game("Racer X", allow=True)
f.sources(SONA_CONTENT_STOCK, allow=True)
The slot defaults (the stock shirt, trousers, shoes and hair each body falls back to) pass every rule but a deny by
id: they are what a denied item is replaced with. The man's stock default tee prints the console's power symbol, so
SONA_CONTENT_NO_LOGOS denies it by id, and a plain stock tee (the long sleeved tee) stands in for it. When a
filter denies both a slot's default and its stand-in, a denied item in that slot leaves it empty (the bare torso).
Ids the catalogue lacks (custom items, items newer than the catalogue) get their section from their own id, so section, slot, source and id rules work on them; game and tag rules never match them unless a tag was put on the id.
sona_filter_allows(f, &id) and sona_filter_check(f, &id, &verdict) answer for one item: allowed or not, the
reason (SONA_CONTENT_BY_ID, _BY_SOURCE, _BY_SECTION, _BY_SLOT, _BY_GAME, _BY_TAG, _NOT_ALLOWED), the
tag behind a tag denial, the item's section, source and tags. Verdicts are worked out for every catalogue item when a
rule changes, so a check is a binary search. Once set up a filter is read-only and every
read call is safe from any thread at once.
Where it applies¶
- Pickers and catalogue queries:
sona_filter_searchissona_catalogue_searchover allowed items only (offset and total count allowed items).sona_catalogue_searchitself never filters: a catalogue has no ctx, so a picker passes the filter, usually the ctx's (sona_ctx_filter). The pointersona_ctx_filterreturns belongs to the ctx and is gone at the nextsona_ctx_set_filterorsona_close: read it again rather than keep it. - Previews:
sona_item_preview_addof an item the ctx's filter denies fails withSONA_E_NOT_FOUNDand says why insona_last_error, so a picker shows an error, not an empty stand-in body. - Avatars:
sona_ctx_set_filter(ctx, f)gives the ctx a copy (later changes tofdo not reach it; set it again). Every avatar whose manifest the ctx reads from then on goes through it:sona_avatar_add,sona_avatar_add_base64, headless renders, batches. The manifest is read in the firstsona_updateafter the add, so an avatar added beforesona_ctx_set_filterand not updated since is filtered too; one already read is not (remove it and add it again).sona_avatar_filter_reportsays what changed:SONA_E_NOT_FOUNDwhen no filter was set when it was read. - Manifests in your own code:
sona_filter_manifest(the parsed struct) andsona_filter_manifest_bytes(the 1000 bytes, in place; the same bytes back when nothing is denied). - Random avatars and dress like (
sona_make_random,sona_make_dress_like, Making avatars in code): passsona_filter_allowsas the options'availablecallback, then runsona_filter_manifest_byteson the result. - The CLI:
--filter family,no-logosor--filter rules.jsononcatalogue search,avatar random,avatar dress-likeandrender, and the commandsavatar filter,filter tagsandfilter check(The sona command-line tool). - The MCP server:
sona-mcp --filter family,no-logos(or a rules file) sets the filter on its ctx.search_itemsand the sections resource count allowed items only,avatar_wearrefuses a denied item,dress_from_textpicks allowed items only, an avatar made or edited is stored filtered (the reply'scontent_filtersays how many items changed),render_itemof a denied item fails, andsdk_infonames the filter (sona-mcp). - The Studio:
sona-studio --filter <list>sets it on both of its ctxs; the Wardrobe and the Scene's random outfits list allowed items only, and the Wardrobe's status line names the filter. - Godot and Unreal:
SonaFilterwithSonaServer.set_filter, andUSonaFilterwithUSonaSubsystem::; the catalogue's search then lists allowed items only and each avatar reports what changed (engine reference).SetContentFilter (Filter, Catalogue)
What happens to a denied item on an avatar¶
| Where | Becomes |
|---|---|
| Shirt, trousers, shoes, hair | the slot's default: the last-worn item when allowed, else the body's stock one, else the slot's plain stand-in (the man's shirt has one); empty when none is allowed |
| A costume covering shirt, trousers and shoes | taken off; each slot it covered gets its default |
| Eyes, eyebrows, mouth | the first allowed stock part for that body |
| Chin, nose, ears | the head's own shape |
| Facial hair, eye shadow, facial features, hats, glasses, gloves, jewellery, props | taken off |
| The body and head | never filtered |
The last-worn cache (the clothes a costume gives back when it comes off) is cleaned too, so no later edit brings a
denied item back. Each change is reported (sona_filter_change: the denied item, what replaced it, replaced or
hidden, the reason, the tag, the section); cache entries are only counted (report.cache).
Tags¶
Eight tags are built in, derived from the catalogue's own words when the filter is made: whole words of the item's name (ASCII case folded), some only on carryables, phrases that cancel a hit ("bow tie", "baseball bat", a team called "Devils"), words of the game string, and the item's family. The word tables hold only generic words, no franchise, brand or team names.
| Tag | How it is derived | Items (of 23,943) |
|---|---|---|
licensed |
an award, or an item whose game string is not one of the store's own house collections (a house collection's name is made only of generic words: "Holiday Collection", "Toy Armory") | 16,702 |
logo |
"logo", "emblem", "crest", "insignia", "badge" in the name, or a licensed shirt, hat, shoes or trousers | 10,609 |
weapon |
sword, rifle, blaster, axe, dagger, grenade, gun, ... anywhere; bow, staff, blade, hammer, bat, club, ... on carryables only | 300 |
horror |
zombie, skull, skeleton, demon, vampire, werewolf, reaper, gore, ...; "horror" or "evil" in the game | 640 |
military |
army, marine, soldier, camo, combat, tactical, ...; "military" in the game | 656 |
seasonal |
christmas, santa, halloween, pumpkin, valentine, easter, ...; holiday words in the game | 528 |
hides-face |
mask, balaclava, helmet, mascot on a costume, hat, glasses or full outfit | 1,199 |
alcohol |
beer, wine, champagne, cocktail, ... | 1 |
Hosts add their own tags (sona_filter_tag_define, up to 64 in all) and put tags on items or take them off
(sona_filter_tag_set), for ids in the catalogue or not.
Presets¶
| Preset | Denies | Allowed (of 23,943) |
|---|---|---|
SONA_CONTENT_FAMILY |
tags weapon, horror, alcohol |
23,007 |
SONA_CONTENT_NO_LOGOS |
tag logo, and the man's default tee by id |
13,333 |
SONA_CONTENT_NO_LICENSED |
tag licensed |
7,241 |
The counts here and in the tag table are on the full offline catalogue (23,943 items from 895 games). A catalogue of fewer items gives smaller counts.
Presets add deny rules, so they combine with each other and with your own rules.
How complete they are¶
The presets are built from the catalogue's data alone: names, game strings, families and sections. No one has looked at the pictures. What that means for each:
- weapon is precise and incomplete. In a sample of about 75 tagged items read by name, all were weapons (toy ones included) or shirts named after one ("Lancer T-shirt"). It misses what a name does not say: animated attack props named for the move ("Assassin Assault", "Divine Flame Strike"), costumes that carry a sword or a gun, armour sets. A human pass over the 2,946 carryables and the 6,609 costumes is what makes it complete.
- horror has the same shape: skull shirts and zombie masks are caught, a creepy costume with a plain name is not. Team names are cancelled by phrase; any other team or brand with a scary word is a false hit.
- logo errs the other way, on purpose: every printed garment from a licence counts, whether its print is a logo or not (a game's jacket with no mark is denied too). It misses house items whose print is a brand or a logo but whose name does not say so. The man's stock default tee (the power symbol) is denied by id, and the long sleeved tee stands in, so a no-logos avatar shows no logo the SDK put there itself. Other stock garments with a printed mark (the stock "Tee with badges", "Dollar tee", the country sport tops) are stock, not licensed, and stay allowed: they need the human pass.
- licensed depends on telling the store's own collections from licences by their names: 75 of the 895 game strings are house collections by the word list. A licence whose collection name is made only of generic words would count as house, and a vendor line ("Team DZN") counts as house. Awards always count as licensed.
- alcohol finds one item: the catalogue has almost none by name.
The human tag pass¶
On top of the word rules the catalogue carries a reviewed set: tags the word rules missed and ones they put on by
mistake, over every carryable and costume, each looked at in a picture. It adds weapon (toy blasters, katanas,
claws, lightsabers, turrets), military (tanks, jets, attack helicopters, drones, helmets, night vision goggles)
and horror (monster pets, horror masks, skull helmets, zombie masks), and takes tags off where a word misled (a
body wash called Axe, a plush sabre-tooth tiger, a hockey team called Devils). It is baked into the catalogue
(format 1.1, record bytes 57 and 58), so every preset uses it with no rules file.
--tag-sheets --items <items.json> --thumbs <dirs> --sheets-out <dir> [--derived <tags.json>] [--all] writes the pages
for a person's review, plain HTML with an index (*-index.json) beside each: tags-on-<tag> and tags-off-<tag> show
every id the review changes, each picture with its number, name and id; all-carryable-NN and all-costume-NN show
every item with the review's tags and the word rules' tags, so a missed or wrong tag can be found anywhere.
Rules files¶
sona_filter_load reads rules as JSON, all or nothing: on an error the filter is unchanged and why says what was
wrong ("no item comes from the game \"Racer Y\"", "unknown tag \"wepon\""). Keys are applied in order, so define a
tag ("tags") before a rule uses it.
{
"comment": "a kids' racing game",
"preset": ["family", "no-logos"],
"tags": { "tie-in": ["00000008-1111-0001-c000-000000000003"] },
"untag": { "weapon": ["00001000-2222-0001-c000-000000000006"] },
"allow": { "games": ["Racer X"], "sources": ["stock"] },
"deny": { "sections": ["glasses"], "slots": ["ring", 1024],
"tags": ["tie-in"],
"items": ["00000040-3333-0001-c000-000000000007"] }
}
sections take the names of sona_catalogue_section_name; slots take slot names (head, body, hair, shirt,
trousers, shoes, headwear, gloves, glasses, wristwear, earrings, ring, carryable, eyes, eyebrows, mouth, facialHair,
facialFeature, eyeShadow, nose, chin, ears, animation, costume, shape) or AssetMask numbers; sources take stock,
award, marketplace, custom and unlisted; games match case folded.
Bindings¶
C#: SonaFilter (Create, Preset, the rule calls, Load, Allows, Check, Search, FilterManifest,
SetOn(ctx), ReportOf(avatar)). Python: sona.Filter (preset, the rule calls, load, allows, check,
search, filter_manifest, apply_to(ctx)), sona.filter_report(avatar). Rust: the sona_filter_* functions
and structs in sona360-sys (sona_sys in code).
This page as Markdown · All the docs as one file (llms-full.txt)