readmes
This commit is contained in:
+206
-207
@@ -1,341 +1,340 @@
|
||||
# Exemples WSG
|
||||
# WSG Examples
|
||||
|
||||
Chaque exemple est autonome et illustre **un effet ou une fonctionnalité** spécifique
|
||||
de la bibliothèque. Tous utilisent l'API déclarative (`AppBuilder` + `AppHandler`).
|
||||
Each example is self-contained and demonstrates **one effect or feature** of the library. All use the declarative API (`AppBuilder` + `AppHandler`).
|
||||
|
||||
## Lancer un exemple
|
||||
## Running an example
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example <nom>
|
||||
cargo run -p wsg-lib --example <name>
|
||||
```
|
||||
|
||||
| Exemple | Effet démontré |
|
||||
|---------|---------------|
|
||||
| `demo` | Showcase complet (tous les effets combinés) |
|
||||
| `bloom` | Post-process bloom (glow autour des zones brillantes) |
|
||||
| `hdr` | HDR + Tone Mapping (ACES) + contrôle d'exposition |
|
||||
| `emissive` | Matériaux émissifs (intensités croissantes 0 → 4.0) |
|
||||
| `shadow` | Shadow mapping (ombre portée directionnelle) |
|
||||
| `culling` | Culling GPU-driven (grille 15×15, objets hors frustum ignorés) |
|
||||
| `msaa` | MSAA 4× (anti-aliasing multi-échantillons, arêtes lisses) |
|
||||
| `fog` | Brouillard de distance (3 modes : linéaire, exp, exp²) |
|
||||
| `manual` | Workflow bas niveau (Context + Renderer + PipelineCache) |
|
||||
| `import` | Import de fichier OBJ (non graphique, stdout) |
|
||||
| Example | Effect demonstrated |
|
||||
|---------|-------------------|
|
||||
| `demo` | Full showcase (all effects combined) |
|
||||
| `bloom` | Post-process bloom (glow around bright areas) |
|
||||
| `hdr` | HDR + Tone Mapping (ACES) + exposure control |
|
||||
| `emissive` | Emissive materials (increasing intensities 0 → 4.0) |
|
||||
| `shadow` | Shadow mapping (directional shadow) |
|
||||
| `culling` | GPU-driven culling (15×15 grid, off-frustum objects skipped) |
|
||||
| `msaa` | MSAA 4× (multisample anti-aliasing, smooth edges) |
|
||||
| `fog` | Distance fog (3 modes: linear, exp, exp²) |
|
||||
| `dof` | Depth of Field (cinematic bokeh, focus presets) |
|
||||
| `pbr` | PBR metallic/roughness + normal mapping |
|
||||
| `manual` | Low-level workflow (Context + Renderer + PipelineCache) |
|
||||
| `import` | OBJ file import (non-graphical, stdout) |
|
||||
|
||||
---
|
||||
|
||||
## `demo` — Showcase complet
|
||||
## `demo` — Full Showcase
|
||||
|
||||
Combine **tous** les effets : primitives LOD, textures procédurales, lumières
|
||||
(directional + point + spot), ombres, HDR/ACES, exposition, émissif, bloom, culling.
|
||||
Combines **all** effects: LOD primitives, procedural textures, lights
|
||||
(directional + point + spot), shadows, HDR/ACES, exposure, emissive, bloom, culling.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example demo
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| `1` / `2` / `3` | Presets : face / côté / dessus |
|
||||
| `+` / `-` | Exposition ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposition |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `1` / `2` / `3` | Presets: front / side / top |
|
||||
| `+` / `-` | Exposure ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposure |
|
||||
|
||||
---
|
||||
|
||||
## `bloom` — Post-process Bloom
|
||||
|
||||
Deux sphères émissives (orange intensité 2.0, bleue intensité 3.0) produisent un
|
||||
halo visible. Le cube et le sol servent de référence (non-émissifs).
|
||||
Two emissive spheres (orange intensity 2.0, blue intensity 3.0) produce a visible
|
||||
halo. The cube and floor serve as reference (non-emissive).
|
||||
|
||||
Le bloom est un pipeline 4 passes GPU : threshold → blur H → blur V → composite.
|
||||
Bloom is a 4-pass GPU pipeline: threshold → blur H → blur V → composite.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example bloom
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `+` / `-` | **Bloom threshold** +0.1 / −0.1 |
|
||||
| `[` / `]` | **Bloom intensity** +0.1 / −0.1 |
|
||||
| `I` / `O` | **Bloom radius** +0.5 / −0.5 |
|
||||
| `E` / `Q` | Exposition ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposition |
|
||||
| `E` / `Q` | Exposure ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposure |
|
||||
|
||||
### Ce qu'on voit
|
||||
### What to observe
|
||||
|
||||
- **threshold bas** (0.0) : tout l'image "bloom" (effet très diffus).
|
||||
- **threshold élevé** (2.0+) : seules les sphères émissives brillantes produisent du glow.
|
||||
- **intensity 0.0** : pas de glow visible (même si le threshold extrait des pixels).
|
||||
- **radius grand** (10+) : le glow s'étend sur une grande zone.
|
||||
- **Low threshold** (0.0): the entire image "blooms" (very diffuse effect).
|
||||
- **High threshold** (2.0+): only the bright emissive spheres produce glow.
|
||||
- **Intensity 0.0**: no visible glow (even though the threshold extracts pixels).
|
||||
- **Large radius** (10+): the glow spreads over a large area.
|
||||
|
||||
---
|
||||
|
||||
## `hdr` — HDR + Tone Mapping
|
||||
|
||||
Démontre le rendu HDR avec la courbe ACES Filmic. Trois objets :
|
||||
Demonstrates HDR rendering with the ACES Filmic curve. Three objects:
|
||||
|
||||
- **Cube** : éclairage normal (aucun émissif) — référence LDR.
|
||||
- **Sphère brillante** (émissif 3.0) : sans HDR, elle serait clampée à blanc.
|
||||
Avec ACES, les highlights "roulent" doucement vers le blanc (rolloff).
|
||||
- **Sphère sombre** (émissif 0.3) : reste sombre même à haute exposition.
|
||||
- **Cube**: normal lighting (no emissive) — LDR reference.
|
||||
- **Bright sphere** (emissive 3.0): without HDR, it would be clamped to white.
|
||||
With ACES, highlights "roll off" smoothly toward white.
|
||||
- **Dark sphere** (emissive 0.3): stays dark even at high exposure.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example hdr
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| `E` | **Exposition ×1.3** (plus clair) |
|
||||
| `Q` | **Exposition ÷1.3** (plus sombre) |
|
||||
| `0` | Reset exposition à 1.0 |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `E` | **Exposure ×1.3** (brighter) |
|
||||
| `Q` | **Exposure ÷1.3** (darker) |
|
||||
| `0` | Reset exposure to 1.0 |
|
||||
|
||||
### Ce qu'on voit
|
||||
### What to observe
|
||||
|
||||
- À exposition 1.0 : la sphère brillante est blanche mais avec des détails (rolloff ACES).
|
||||
- À exposition haute (E×E×E) : la scène s'éclaircit, la sphère brillante reste blanche
|
||||
(saturée), mais le cube gagne en détail.
|
||||
- À exposition basse (Q×Q) : tout s'assombrit, la sphère brillante devient orangée
|
||||
(les valeurs HDR > 1.0 sont compressées).
|
||||
- At exposure 1.0: the bright sphere is white but with detail (ACES rolloff).
|
||||
- At high exposure (E×E×E): the scene brightens, the bright sphere stays white
|
||||
(saturated), but the cube gains detail.
|
||||
- At low exposure (Q×Q): everything darkens, the bright sphere becomes orange
|
||||
(HDR values > 1.0 are compressed).
|
||||
|
||||
> **Note** : le tone mapper est compilé dans le pipeline au build. Pour comparer
|
||||
> ACES vs Reinhard, modifier `ToneMapper::Aces` → `ToneMapper::Reinhard` dans le source.
|
||||
> **Note**: the tone mapper is compiled into the pipeline at build time. To compare
|
||||
> ACES vs Reinhard, change `ToneMapper::Aces` → `ToneMapper::Reinhard` in the source.
|
||||
|
||||
---
|
||||
|
||||
## `emissive` — Matériaux Émissifs
|
||||
## `emissive` — Emissive Materials
|
||||
|
||||
Cinq sphères alignées avec des intensités émissives croissantes :
|
||||
Five spheres in a row with increasing emissive intensities:
|
||||
|
||||
| Sphere | Couleur | Intensité | Effet |
|
||||
|--------|---------|-----------|-------|
|
||||
| 1 | Gris | 0.0 | Aucune glow (référence) |
|
||||
| 2 | Orange | 0.5 | Légère lueur |
|
||||
| 3 | Jaune | 1.0 | Lueur visible |
|
||||
| 4 | Vert | 2.0 | Glow HDR (au-delà de 1.0) |
|
||||
| 5 | Bleu | 4.0 | Glow intense (saturation) |
|
||||
| Sphere | Color | Intensity | Effect |
|
||||
|--------|-------|-----------|--------|
|
||||
| 1 | Gray | 0.0 | No glow (reference) |
|
||||
| 2 | Orange | 0.5 | Slight glow |
|
||||
| 3 | Yellow | 1.0 | Visible glow |
|
||||
| 4 | Green | 2.0 | HDR glow (beyond 1.0) |
|
||||
| 5 | Blue | 4.0 | Intense glow (saturation) |
|
||||
|
||||
Avec HDR, les intensités > 1.0 produisent un vrai "glow" (les valeurs dépassent
|
||||
[0,1] en espace linéaire). Sans HDR, elles seraient clampées à blanc.
|
||||
With HDR, intensities > 1.0 produce a true "glow" (values exceed
|
||||
[0,1] in linear space). Without HDR, they would be clamped to white.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example emissive
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| `E` / `Q` | Exposition ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposition |
|
||||
| `C` | **Cycler le multiplicateur d'émissif** (1× → 2× → 0.5× → ...) |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `E` / `Q` | Exposure ×1.3 / ÷1.3 |
|
||||
| `0` | Reset exposure |
|
||||
| `C` | **Cycle emissive multiplier** (1× → 2× → 0.5× → ...) |
|
||||
|
||||
### Ce qu'on voit
|
||||
### What to observe
|
||||
|
||||
- La sphère 1 (intensité 0) est simplement éclairée par la lumière directionnelle.
|
||||
- Les sphères 2-5 brillent de leur propre lumière, indépendamment de l'éclairage.
|
||||
- `C` double ou réduit toutes les intensités en même temps (pour voir l'effet HDR).
|
||||
- Sphere 1 (intensity 0) is simply lit by the directional light.
|
||||
- Spheres 2-5 glow with their own light, independent of scene lighting.
|
||||
- `C` doubles or halves all intensities simultaneously (to see the HDR effect).
|
||||
|
||||
---
|
||||
|
||||
## `shadow` — Shadow Mapping
|
||||
|
||||
Quatre objets (cube, sphère, cône, cylindre) sur un sol, éclairés par une lumière
|
||||
directionnelle qui projette des ombres. La qualité des ombres est contrôlée par
|
||||
`ShadowConfig` (taille de la shadow map, biais anti-acne).
|
||||
Four objects (cube, sphere, cone, cylinder) on a floor, lit by a directional light
|
||||
that casts shadows. Shadow quality is controlled by `ShadowConfig` (map size, anti-acne bias).
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example shadow
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| `1` | Vue de face |
|
||||
| `2` | Vue de côté |
|
||||
| `3` | **Vue de dessus** (voir la forme des ombres clairement) |
|
||||
| `L` | Changer la direction de la lumière (3 presets) |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `1` | Front view |
|
||||
| `2` | Side view |
|
||||
| `3` | **Top view** (see shadow shapes clearly) |
|
||||
| `L` | Change light direction (3 presets) |
|
||||
|
||||
### Ce qu'on voit
|
||||
### What to observe
|
||||
|
||||
- Le cube tourne lentement → son ombre bouge sur le sol.
|
||||
- La sphère a une transition ombre/lumière douce (terminateur lisse).
|
||||
- Le cône produit une ombre triangulaire distincte.
|
||||
- En vue de dessus (`3`), on voit la forme exacte des ombres projetées.
|
||||
- La taille de la shadow map (1024 par défaut) détermine la résolution :
|
||||
modifier `SHADOW_MAP_SIZE` en haut du fichier pour tester 256 (pixelisé) ou 2048 (net).
|
||||
- The cube rotates slowly → its shadow moves on the floor.
|
||||
- The sphere has a smooth shadow/light transition (soft terminator).
|
||||
- The cone produces a distinct triangular shadow.
|
||||
- In top view (`3`), you see the exact shape of projected shadows.
|
||||
- Shadow map size (1024 default) determines resolution:
|
||||
modify `SHADOW_MAP_SIZE` at the top of the file to test 256 (pixelated) or 2048 (sharp).
|
||||
|
||||
---
|
||||
|
||||
## `culling` — GPU Frustum Culling
|
||||
|
||||
Une grille de **15×15 = 225 cubes** est placée sur un grand sol. Le culling
|
||||
GPU-driven (compute shader) détermine quels cubes sont visibles dans le frustum
|
||||
de la caméra et zéro leurs draw args indirects — **zéro coût CPU**.
|
||||
A grid of **15×15 = 225 cubes** is placed on a large floor. The GPU-driven culling
|
||||
(compute shader) determines which cubes are visible in the camera frustum and zeros
|
||||
their indirect draw args — **zero CPU cost**.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example culling
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra (regarder autour) |
|
||||
| Molette | Zoom in/out |
|
||||
| `R` | Reset (vue de dessus) |
|
||||
| `1` | Vue de face (les cubes derrière sont culled) |
|
||||
| `2` | Vue de côté |
|
||||
| `3` | **Vue de dessus** (voir toute la grille) |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera (look around) |
|
||||
| Wheel | Zoom in/out |
|
||||
| `R` | Reset (top view) |
|
||||
| `1` | Front view (cubes behind are culled) |
|
||||
| `2` | Side view |
|
||||
| `3` | **Top view** (see the full grid) |
|
||||
|
||||
### Ce qu'on voit
|
||||
### What to observe
|
||||
|
||||
- En vue de dessus (`3`) : toute la grille 20×20 est visible.
|
||||
- Orbiter à 90° : les cubes derrière la caméra **ne sont pas dessinés** (culled).
|
||||
- Zoomer très près : seuls les cubes proches du plan de near sont rendus.
|
||||
- Les cubes tournent lentement (phases décalées) → le culling est dynamique
|
||||
(un cube peut entrer/sortir du frustum au cours d'une frame).
|
||||
- In top view (`3`): the entire grid is visible.
|
||||
- Orbit to 90°: cubes behind the camera **are not drawn** (culled).
|
||||
- Zoom very close: only cubes near the near plane are rendered.
|
||||
- Cubes rotate slowly (staggered phases) → culling is dynamic
|
||||
(a cube can enter/leave the frustum during a frame).
|
||||
|
||||
> **Note** : le culling est activé via `AppBuilder::with_culling(true)`. Le modifier
|
||||
> à `false` dans le source désactive le culling (tous les 400 cubes sont toujours
|
||||
> dessinés, même hors écran).
|
||||
> **Note**: culling is enabled via `AppBuilder::with_culling(true)`. Changing
|
||||
> it to `false` in the source disables culling (all cubes are always drawn, even off-screen).
|
||||
|
||||
---
|
||||
|
||||
## `msaa` — MSAA 4× (Anti-aliasing)
|
||||
|
||||
Démontre l'anti-aliasing multi-échantillons : les arêtes des objets (cube, sphère)
|
||||
sont lisses au lieu d'être "en escalier". La scène contient un cube (arêtes nettes),
|
||||
une sphère (silhouette courbe) et un petit cube près de la caméra (aliasing maximal).
|
||||
Demonstrates multisample anti-aliasing: object edges (cube, sphere)
|
||||
are smooth instead of "stair-stepped". The scene contains a cube (sharp edges),
|
||||
a sphere (curved silhouette), and a small cube near the camera (maximum aliasing).
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example msaa
|
||||
```
|
||||
|
||||
### Touches
|
||||
### Keys
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Glisser (LMB) | Orbiter la caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| `M` | Afficher le nombre d'échantillons |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
| `M` | Show sample count |
|
||||
|
||||
### Pour comparer avec/sans MSAA
|
||||
### To compare with/without MSAA
|
||||
|
||||
Supprimer la ligne `.with_msaa(4)` dans le source et recompiler : la scène est
|
||||
identique, seules les arêtes diffèrent (escaler vs lisse).
|
||||
Remove the `.with_msaa(4)` line in the source and recompile: the scene is
|
||||
identical, only the edges differ (stair-stepped vs smooth).
|
||||
|
||||
> **Note** : MSAA est un réglage de build-time (allocation de textures multi-échantillons).
|
||||
> Il fonctionne indépendamment de HDR : avec HDR, la texture MSAA est `Rgba16Float`
|
||||
> et résout dans la texture HDR avant bloom/TM.
|
||||
> **Note**: MSAA is a build-time setting (multisample texture allocation).
|
||||
> It works independently of HDR: with HDR, the MSAA texture is `Rgba16Float`
|
||||
> and resolves into the HDR texture before bloom/TM.
|
||||
|
||||
---
|
||||
|
||||
## `fog` — Brouillard de distance
|
||||
## `fog` — Distance Fog
|
||||
|
||||
Démontre les 3 modes de brouillard : **linéaire**, **exponentiel**, **exponentiel²**.
|
||||
La scène contient une rangée de cubes qui s'éloignent et des sphères dispersées sur
|
||||
un grand plan au sol. Le brouillard fond les objets vers une couleur de fond,
|
||||
créant l'illusion d'un monde infini.
|
||||
Demonstrates the 3 fog modes: **linear**, **exponential**, **exponential²**.
|
||||
The scene contains a row of cubes receding into the distance and scattered spheres
|
||||
on a large floor plane. Fog blends objects toward a background color,
|
||||
creating the illusion of an infinite world.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example fog --features "all-prims"
|
||||
```
|
||||
|
||||
**Touches** : `1` = linéaire, `2` = exp, `3` = exp², `4` = désactivé, `R` = reset.
|
||||
**Keys**: `1` = linear, `2` = exp, `3` = exp², `4` = off, `R` = reset.
|
||||
|
||||
> Le brouillard est appliqué dans le shader fragment principal (après l'éclairage,
|
||||
> avant le tone mapping). Il utilise la distance euclidienne du fragment à la caméra.
|
||||
> Fog is applied in the main fragment shader (after lighting, before tone mapping).
|
||||
> It uses the Euclidean distance from the fragment to the camera.
|
||||
|
||||
---
|
||||
|
||||
## `dof` — Depth of Field (bokeh cinématique)
|
||||
## `dof` — Depth of Field (cinematic bokeh)
|
||||
|
||||
Démontre le flou de profondeur de champ : un objet au centre reste net tandis que
|
||||
le premier et arrière-plan se flouent selon leur distance au plan de mise au point.
|
||||
Crée un effet d'attention naturelle (type cinématique).
|
||||
Demonstrates depth of field blur: an object at the focus plane stays sharp while
|
||||
foreground and background blur according to their distance from the focus plane.
|
||||
Creates a natural attention effect (cinematic style).
|
||||
|
||||
La scène contient un cube de focus au centre, des sphères en premier plan (proches)
|
||||
et des cubes en arrière-plan (loin), sur un plan au sol.
|
||||
The scene contains 20 cubes in a row along Z (z=3 to z=-25.5) and 5 spheres to the
|
||||
sides, on a floor plane. Focus presets at 3m / 8m / 15m.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example dof --features "all-prims"
|
||||
```
|
||||
|
||||
**Touches** : `1` = cinématique, `2` = subtil, `3` = focus 2m, `4` = focus 10m, `5` = off, `R` = reset.
|
||||
**Keys**: `1` = cinematic, `2` = subtle, `3` = focus 3m, `4` = focus 15m, `5` = off, `R` = reset.
|
||||
|
||||
> DoF opère en HDR linéaire (après bloom, avant tone mapping). Deux passes :
|
||||
> CoC (depth → rayon de flou par pixel) puis blur disque 12-taps à rayon variable.
|
||||
> DoF operates in linear HDR (after bloom, before tone mapping). Two passes:
|
||||
> CoC (depth → per-pixel blur radius) then 12-tap disc blur with variable radius.
|
||||
|
||||
---
|
||||
|
||||
## `manual` — Workflow bas niveau
|
||||
## `pbr` — PBR Metallic/Roughness + Normal Mapping
|
||||
|
||||
Démontre l'API **sans** la façade `App` : utilisation directe de `Context`,
|
||||
`Renderer`, `PipelineCache`, `Mesh`, `Material`. Rend un quad coloré (unlit).
|
||||
|
||||
Utile pour comprendre ce que la façade `App` encapsule.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example manual
|
||||
```
|
||||
|
||||
Pas de touches — rendu statique (quad unlit, 4 couleurs).
|
||||
|
||||
---
|
||||
|
||||
## `import` — Import de fichier OBJ
|
||||
|
||||
Exemple **non graphique** : parse un fichier `.obj` et affiche les statistiques
|
||||
(nombre de sommets, normales, UVs, indices, bounding box) sur stdout.
|
||||
|
||||
```sh
|
||||
# Avec un fichier :
|
||||
cargo run -p wsg-lib --example import --features import-obj -- /path/to/model.obj
|
||||
|
||||
# Sans argument (triangle de démonstration) :
|
||||
cargo run -p wsg-lib --example import --features import-obj
|
||||
```
|
||||
|
||||
Pas de touches — s'exécute et quitte.
|
||||
|
||||
---
|
||||
|
||||
## `pbr` — PBR Metallic/Roughness + Normal Mapping (Étape 27)
|
||||
|
||||
Démonstration du workflow PBR Cook-Torrance : GGX distribution + Smith visibility +
|
||||
Schlick Fresnel + IBL hémisphérique + normal mapping.
|
||||
Demonstrates the Cook-Torrance PBR workflow: GGX distribution + Smith geometry +
|
||||
Schlick Fresnel + hemispheric IBL + normal mapping.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example pbr
|
||||
```
|
||||
|
||||
| Touche | Action |
|
||||
|--------|--------|
|
||||
| Drag (LMB) | Orbite caméra |
|
||||
| Molette | Zoom |
|
||||
| `R` | Reset caméra |
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| Drag (LMB) | Orbit camera |
|
||||
| Wheel | Zoom |
|
||||
| `R` | Reset camera |
|
||||
|
||||
Scène : 6 matériaux PBR (métal miroir, plastique, rouillé, céramique, bump map, sol matte).
|
||||
Le cube avec normal map montre des bumps procéduraux (sin wave).
|
||||
Scene: 6 PBR materials (mirror metal, smooth plastic, rusty metal, ceramic, bump map, matte floor).
|
||||
The bump-map cube shows procedural sin-wave surface detail.
|
||||
|
||||
---
|
||||
|
||||
## `manual` — Low-level Workflow
|
||||
|
||||
Demonstrates the API **without** the `App` facade: direct use of `Context`,
|
||||
`Renderer`, `PipelineCache`, `Mesh`, `Material`. Renders a colored quad (unlit).
|
||||
|
||||
Useful for understanding what the `App` facade encapsulates.
|
||||
|
||||
```sh
|
||||
cargo run -p wsg-lib --example manual
|
||||
```
|
||||
|
||||
No keys — static render (unlit quad, 4 colors).
|
||||
|
||||
---
|
||||
|
||||
## `import` — OBJ File Import
|
||||
|
||||
**Non-graphical** example: parses a `.obj` file and prints statistics
|
||||
(vertex count, normals, UVs, indices, bounding box) to stdout.
|
||||
|
||||
```sh
|
||||
# With a file:
|
||||
cargo run -p wsg-lib --example import --features import-obj -- /path/to/model.obj
|
||||
|
||||
# Without argument (demo triangle):
|
||||
cargo run -p wsg-lib --example import --features import-obj
|
||||
```
|
||||
|
||||
No keys — runs and exits.
|
||||
|
||||
Reference in New Issue
Block a user