# The same picture natively and on the web

The native SDK draws an avatar as the web renderer does: the same build, the same pose, the same shaders. A game
that shows an avatar natively and a site that shows it in a page show the same figure, within the noise two
rasterisers make between themselves. This page says what is held equal, how to get the reference setup, and where
the pictures may differ.

## The reference setup

A native picture matches the web renderer's when both draw with the same options. `sona_snapshot` in the web's
setup: one sample, no mips, bloom on, no shadow, no credit.

```c
sona_quality q;
sona_draw_options o;
sona_quality_defaults(&q);
q.msaa = 1;                      /* one sample */
q.flags = 0;                     /* no mips */
sona_renderer_set_quality(renderer, &q);
memset(&o, 0, sizeof o);
o.flags = SONA_DRAW_NO_CREDIT;   /* no shadow, no badge; bloom stays on */
sona_camera_preset(avatar, SONA_PRESET_FULL, &view);
sona_snapshot(renderer, &view, 512, 512, &o, rgba);
```

```cpp
sona_quality q = sona::quality_defaults();
q.msaa = 1;                                // one sample
q.flags = 0;                               // no mips
r.set_quality(&q);
sona_draw_options o;
std::memset(&o, 0, sizeof o);
o.flags = SONA_DRAW_NO_CREDIT;             // no shadow, no badge; bloom stays on
avatar.camera_preset(SONA_PRESET_FULL, view);
std::vector<uint8_t> rgba;
r.snapshot(view, 512, 512, rgba, &o);
```

```csharp
var q = SonaRenderer.QualityDefaults();
q.msaa = 1;                                      // one sample
q.flags = 0;                                     // no mips
r.SetQuality(q);
var shot = avatar.CameraPreset(SonaPreset.Full, view);
var rgba = r.Snapshot(shot, 512, 512, SonaDrawFlags.NoCredit);   // no shadow, no badge; bloom stays on
```

```rust
let mut q = quality_defaults();
q.msaa = 1;                                      // one sample
q.flags = 0;                                     // no mips
r.set_quality(Some(&q))?;
let mut shot = *view;
avatar.camera_preset(Preset::Full, &mut shot)?;
let opts = DrawOptions { flags: sona_sys::SONA_DRAW_NO_CREDIT, ..Default::default() };   // no shadow, no badge; bloom stays on
let rgba = r.snapshot(&shot, 512, 512, Some(&opts))?;
```

```python
# The Python package has no renderer on a device of your own: it reads avatars as data (avatar.pose()) for an engine
# to draw, and draws pictures with sona.Headless.
q = sona.quality_defaults()
```

`sona_view` is the web camera: the same eye, target, field of view and projection give the same matrices.

## What is held equal

| What | How closely |
|---|---|
| Every stock clip, on a body it was made for, at a fixed point of its length | The mean and the 99.5th-percentile difference from the web's picture stay within twice what two web rasterisers differ by on that frame |
| Every sample avatar, standing | The same |
| The camera | The native view and projection equal the web camera's |
| Backends | Vulkan, OpenGL 3.3, OpenGL ES 3.0, Direct3D 11 and Direct3D 12 are each held to it; so are the web SDK's WebGL2 and WebGPU renderers ([WebGPU](web-webgpu.md)) |

## Where pictures differ

- **Software rasterisers.** Mesa's llvmpipe and lavapipe convert sRGB with approximations of their own, so any
  program on them is off from a GPU's picture by a fraction of a level, in one direction or the other by
  brightness. The web renderer on llvmpipe is off the same way, and native matches it there.
- **Quality settings.** Multisampling and mips are on by default natively ([quality](quality.md)) and change edge
  and texture pixels by design. Turn them off, as above, for a pixel comparison.
- **Styles and lighting.** A style or a lighting replaces the original look on purpose
  ([styles](styles.md), [lighting](lighting.md)).
