Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(cursor): rebuild the Pixel Candy models and the Prism Glow arrow after the sheet
Claude51c217cc72ce
diff --git a/crates/compositor/src/sculpt.rs b/crates/compositor/src/sculpt.rsindex 653347323..a5eb0e793 100644--- a/crates/compositor/src/sculpt.rs+++ b/crates/compositor/src/sculpt.rs@@ -9,10 +9,10 @@//! curseur 1, x à droite, y VERS LE HAUT, z vers la caméra, l'écran en z = 0. Les constantes//! ci-dessous sont le miroir des `SCULPT_*` des trois shaders.//!-//! Les voxels de la flèche de Pixel Candy (`SCULPT_ARROWPIX`, `SCULPT_ARROWBACK`) sont son polygone-//! échantillonné : une cellule de 1/16 porte un voxel quand son centre est à plus de 0,01 dedans, un-//! bloc de la couche violette quand il est à moins de 0,9 cellule. Changer le polygone, c'est-//! régénérer ces deux tables.+//! Deux thèmes sont des tables que des scripts écrivent dans les trois shaders : les grilles de+//! voxels de Pixel Candy (`scripts/generate-pixel-candy-voxels.mjs`) et les plans taillés de Prism+//! Glow (`scripts/generate-prism-glow-gem.mjs`). On change le modèle dans le script, on le relance,+//! et on ajuste ici la boîte si la forme a bougé.use crate::frame_geometry::SpriteShape;@@ -25,17 +25,20 @@ const ZREF_ARROW: f32 = 0.2;const ZREF_HAND: f32 = 0.185;/// Le dessous de tous les modèles, dans le prototype.const Z_LOW: f32 = 0.05;+/// Le côté d'un voxel de Pixel Candy.+const VOX: f32 = 0.07;/// Le plus haut : les yeux de l'étoile de Star Sprout, sur la flèche comme sur la manchette.const Z_HIGH_ARROW: f32 = 0.31;const Z_HIGH_HAND: f32 = 0.4;/// Boîtes des modèles dans le prototype (x0, x1, haut). Leur hauteur est celle du sprite,/// 1 / SCULPT_SCALE : le mode 15 tient le plus grand côté de la boîte pour 1 (`sprite_size`).-/// Celles de la flèche taillée et des voxels, puis de la main taillée, dont le pouce déborde ;-/// puis les thèmes cerclés, que leur trait élargit et que débordent l'étoile et les feuilles (Star-/// Sprout), les tirets du clic et le calque jaune (Pop Coral), le pouce.-const BOX_ARROW: [f32; 3] = [-0.1, 0.75, 0.09];-const BOX_HAND: [f32; 3] = [-0.27, 0.73, 0.07];+/// Celles du cristal, dont le pouce déborde ; des voxels, que leur anneau violet élargit d'une+/// cellule ; puis des thèmes cerclés, que leur trait élargit et que débordent l'étoile et les+/// feuilles (Star Sprout), les tirets du clic et le calque jaune (Pop Coral), le pouce.+const BOX_GEM_ARROW: [f32; 3] = [-0.1, 0.75, 0.09];const BOX_GEM_HAND: [f32; 3] = [-0.39, 0.61, 0.03];+const BOX_PIXEL_ARROW: [f32; 3] = [-0.1, 0.6, 0.09];+const BOX_PIXEL_HAND: [f32; 3] = [-0.38, 0.73, 0.09];const BOX_INK_ARROW: [f32; 3] = [-0.08, 0.6, 0.03];const BOX_INK_HAND: [f32; 3] = [-0.36, 0.6, 0.03];const BOX_CORAL_ARROW: [f32; 3] = [-0.35, 0.6, 0.06];@@ -46,13 +49,13 @@ const BOX_SPROUT_HAND: [f32; 3] = [-0.33, 0.56, 0.03];/// Dans l'ordre des identifiants du shader.const THEMES: [&str; 5] = ["studio-ink", "prism-glow", "pop-coral", "pixel-candy", "star-sprout"];-/// Le haut de la silhouette (y du prototype) : la couche violette des voxels dépasse la pointe-/// d'une cellule, la pointe arrondie de la flèche et le sommet de sa table taillée dépassent le-/// hotspot de 0,03, le bout de l'index y est ; les thèmes cerclés tiennent leur hotspot au bord-/// de leur trait, comme leur PNG.+/// Le haut de la silhouette (y du prototype) : l'anneau violet des voxels dépasse la pointe+/// d'une cellule, le sommet de la table taillée de la flèche dépasse le hotspot de 0,03, le bout+/// de l'index y est ; les thèmes cerclés tiennent leur hotspot au bord de leur trait, comme leur+/// PNG.fn silhouette_top(theme: usize, arrow: bool) -> f32 {match (THEMES[theme], arrow) {- ("pixel-candy", _) => 0.0625,+ ("pixel-candy", _) => VOX,("studio-ink" | "pop-coral" | "star-sprout", _) => 0.0,(_, true) => 0.03,(_, false) => 0.0,@@ -62,15 +65,17 @@ fn silhouette_top(theme: usize, arrow: bool) -> f32 {/// La boîte du modèle (x0, x1, haut) dans le prototype.fn model_box(theme: usize, arrow: bool) -> [f32; 3] {match (THEMES[theme], arrow) {- ("prism-glow", false) => BOX_GEM_HAND,("studio-ink", true) => BOX_INK_ARROW,("studio-ink", false) => BOX_INK_HAND,+ ("prism-glow", true) => BOX_GEM_ARROW,+ ("prism-glow", false) => BOX_GEM_HAND,("pop-coral", true) => BOX_CORAL_ARROW,("pop-coral", false) => BOX_CORAL_HAND,+ ("pixel-candy", true) => BOX_PIXEL_ARROW,+ ("pixel-candy", false) => BOX_PIXEL_HAND,("star-sprout", true) => BOX_SPROUT_ARROW,("star-sprout", false) => BOX_SPROUT_HAND,- (_, true) => BOX_ARROW,- (_, false) => BOX_HAND,+ (other, _) => unreachable!("thème sculpté inconnu : {other}"),}}@@ -158,6 +163,7 @@ mod tests {("SCULPT_ZREF_ARROW", ZREF_ARROW),("SCULPT_ZREF_HAND", ZREF_HAND),("SCULPT_HOVER", Z_LOW),+ ("SCULPT_VOX", VOX),] {let line = src.lines()@@ -211,4 +217,52 @@ mod tests {assert!((len - 1.0).abs() < 1e-3, "normale non unitaire : {p:?}");}}++ /// Les nombres de la table `name` d'un shader, du `=` à la fin de la liste, constructeurs de+ /// vecteurs retirés : la même table s'écrit alors pareil dans les trois langages.+ fn table(src: &str, name: &str) -> Vec<f32> {+ // La déclaration : `NAME =` en WGSL, `NAME[taille]` en HLSL et en Metal (pas un `NAME[i]` du code).+ let decl = format!("{name}[");+ let sized = |&i: &usize| src[i + decl.len()..].starts_with(|c: char| c.is_ascii_digit());+ let at = src.find(&format!("{name} =")).or_else(|| src.match_indices(&decl).map(|(i, _)| i).find(sized));+ let rest = &src[at.expect(name)..];+ let rest = &rest[rest.find('=').unwrap()..];+ let open = rest.find(['(', '{']).unwrap() + 1;+ let close = [rest.find(");"), rest.find("};")].into_iter().flatten().min().unwrap();+ let mut list = rest[open..close].to_string();+ for ty in ["vec2<f32>", "vec4<f32>", "vec4<i32>", "float2", "float4", "int4"] {+ list = list.replace(ty, "");+ }+ list.split(|c: char| !(c.is_ascii_digit() || c == '.' || c == '-'))+ .filter(|t| !t.is_empty())+ .map(|t| t.parse().unwrap_or_else(|_| panic!("{name} : nombre illisible {t}")))+ .collect()+ }++ /// Les grilles de Pixel Candy, que `scripts/generate-pixel-candy-voxels.mjs` écrit dans les+ /// trois shaders, y sont les mêmes ; le menthe est sur la face, l'anneau autour d'elle.+ #[test]+ fn the_voxel_tables_match_in_the_three_shaders() {+ let hlsl = include_str!("shaders.hlsl");+ let metal = include_str!("shaders.metal");+ let wgsl = include_str!("vk_shaders/layer.wgsl");+ let names = ["PIX_BODY", "PIX_MINT", "PIX_RING", "PIX_RECT_N", "PIX_GRID", "PIX_ORIGIN", "PIX_BOX", "PIX_RECT"];+ for name in names {+ let reference = table(wgsl, name);+ assert!(!reference.is_empty(), "{name} vide");+ assert_eq!(table(hlsl, name), reference, "{name} : HLSL et WGSL diffèrent");+ assert_eq!(table(metal, name), reference, "{name} : Metal et WGSL diffèrent");+ }+ let body = table(wgsl, "PIX_BODY");+ let mint = table(wgsl, "PIX_MINT");+ let ring = table(wgsl, "PIX_RING");+ for g in table(wgsl, "PIX_GRID").chunks(4) {+ let [_, rows, b, w] = [g[0], g[1], g[2], g[3]].map(|v| v as usize);+ for r in 0..rows {+ let (face, green) = (body[b + r] as u32, mint[b + r] as u32);+ assert_eq!(green & !face, 0, "menthe hors de la face, ligne {r}");+ assert_eq!((ring[w + r + 1] as u32 >> 1) & face, 0, "anneau sur la face, ligne {r}");+ }+ }+ }}diff --git a/crates/compositor/src/shaders.hlsl b/crates/compositor/src/shaders.hlslindex ff5e13fc9..730e62f78 100644--- a/crates/compositor/src/shaders.hlsl+++ b/crates/compositor/src/shaders.hlsl@@ -592,7 +592,7 @@ static const float MODEL_CONTACT_ALPHA = 0.5;// voxels, 7 couche violette, 8 cristal.static const float SCULPT_SCALE = 0.85;static const float SCULPT_HOVER = 0.05;-static const float SCULPT_VOX = 0.0625;+static const float SCULPT_VOX = 0.07;// Hauteur, dans le prototype, du z = 0 du modèle : le dessus de la pointe de la flèche, l'axe du// bout de l'index.static const float SCULPT_ZREF_ARROW = 0.2;@@ -644,35 +644,6 @@ float2 s_rot(float2 v, float a)return float2(c * v.x - s * v.y, s * v.x + c * v.y);}-// La flèche : polygone à sept sommets, pointe à l'origine.-static const float2 SCULPT_ARROW[7] = {- float2(0.0, 0.0), float2(0.0, -0.86), float2(0.215, -0.665), float2(0.37, -1.0),- float2(0.53, -0.93), float2(0.38, -0.60), float2(0.64, -0.60)-};--float s_arrow2(float2 p)-{- float d = dot(p - SCULPT_ARROW[0], p - SCULPT_ARROW[0]);- float s = 1.0;- int j = 6;- [loop] for (int i = 0; i < 7; i++)- {- float2 e = SCULPT_ARROW[j] - SCULPT_ARROW[i];- float2 w = p - SCULPT_ARROW[i];- float2 b = w - e * saturate(dot(w, e) / dot(e, e));- d = min(d, dot(b, b));- bool c0 = p.y >= SCULPT_ARROW[i].y;- bool c1 = p.y < SCULPT_ARROW[j].y;- bool c2 = e.x * w.y > e.y * w.x;- if ((c0 && c1 && c2) || (!c0 && !c1 && !c2))- {- s = -s;- }- j = i;- }- return s * sqrt(d);-}-float s_star5(float2 p, float r, float rf){const float2 k1 = float2(0.809016994375, -0.587785252292);@@ -743,7 +714,8 @@ static const float4 RIM_GLOVE_R[9] = {float4(0.066, 0.0553, 0.0553, 0.0507), float4(0.063, 0.024, 0.022, 0.02), float4(0.0647, -0.555, 0.056, 0.0)};-// Distance signée au polygone de RIM_POLY qui commence en `base` (cf. `s_arrow2`).+// Distance signée au polygone de RIM_POLY qui commence en `base` : distance aux arêtes, signe par+// la parité des traversées d'une demi-droite.float s_rim_poly(float2 p, int base){float d = dot(p - RIM_POLY[base], p - RIM_POLY[base]);@@ -915,107 +887,135 @@ float2 s_rimmed(float3 p, int theme, int shape)return s_opu(r, float2(s_ellipsoid(e, float3(0.075, 0.13, 0.1)) * rs, 5.0));}-// Pixel Candy : une ligne par entier, bit c = colonne c, ligne 0 juste sous la pointe. La flèche-// est le polygone échantillonné à 16 cellules par unité (`sculpt.rs` dit comment la régénérer) ;-// la main est dessinée à la main, un gant échantillonné fondant ses doigts. Les tables *BACK-// portent la couche violette, la face dilatée d'une cellule, décalée d'une ligne et d'une colonne.-static const int SCULPT_ARROWPIX[16] = { 0, 1, 3, 7, 31, 63, 127, 255, 511, 63, 55, 115, 113, 224, 224, 64 };-static const int SCULPT_ARROWBACK[18] = {- 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 255, 511, 511, 999, 995, 960, 192+// Pixel Candy : deux grilles de voxels dessinées d'après la planche (design/cursors/3d-concept.png),+// une ligne par entier, bit c = colonne c, ligne 0 en haut. `PIX_BODY` porte la face rose,+// `PIX_MINT` ses voxels menthe ; `PIX_RING`, l'anneau violet, toute cellule vide qui touche la face+// (côtés et coins), décalé d'une ligne et d'une colonne pour tenir la ligne et la colonne -1.+// `PIX_GRID` : colonnes, lignes et début de chaque forme dans les tables ; `PIX_ORIGIN` : le coin+// haut-gauche de la cellule (0, 0) ; `PIX_BOX` (centre, demi-côtés) : la boîte de la face et de+// l'anneau ; `PIX_RECT`, bornés par `PIX_RECT_N` : les mêmes en rectangles, pour l'ombre. Tables+// générées par scripts/generate-pixel-candy-voxels.mjs, qui réécrit les trois shaders : c'est là+// qu'on redessine une grille.+// <pixel-candy-voxels>+static const int PIX_BODY[25] = { 1, 3, 7, 15, 31, 63, 127, 31, 27, 59, 113, 96, 24, 24, 24, 24, 216, 1752, 7899, 8191, 8190, 8188, 4088, 2032, 992 };+static const int PIX_MINT[25] = { 0, 0, 0, 0, 0, 1, 1, 1, 9, 11, 17, 32, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32 };+static const int PIX_RING[29] = { 7, 13, 25, 49, 97, 193, 385, 257, 449, 201, 393, 285, 311, 480, 120, 72, 72, 72, 968, 7752, 29263, 16969, 16385, 16387, 16390, 24588, 12312, 6192, 4064 };+static const int PIX_RECT_N[3] = { 0, 12, 21 };+static const int4 PIX_GRID[2] = {+ int4(7, 12, 0, 0),+ int4(13, 13, 12, 14)+};+static const float2 PIX_ORIGIN[2] = {+ float2(0.0, 0.0),+ float2(-0.28, 0.0)};-static const int SCULPT_HANDPIX[15] = { 4, 14, 14, 14, 110, 878, 7022, 7022, 8190, 8191, 8191, 8191, 8190, 4092, 4092 };-static const int SCULPT_HANDBACK[17] = {- 28, 62, 62, 62, 510, 4094, 32766, 32766, 32766, 32767, 32767, 32767, 32767, 32767, 32766, 16380, 16380+static const float4 PIX_BOX[2] = {+ float4(0.245, -0.42, 0.315, 0.49),+ float4(0.175, -0.455, 0.525, 0.525)};-// La couche violette de la main, une plage de colonnes par ligne (toutes pleines) : la distance-// exacte à son contour, pour l'ombre portée.-static const float2 SCULPT_HANDSPAN[17] = {- float2(2.0, 4.0), float2(1.0, 5.0), float2(1.0, 5.0), float2(1.0, 5.0), float2(1.0, 8.0),- float2(1.0, 11.0), float2(1.0, 14.0), float2(1.0, 14.0), float2(1.0, 14.0), float2(0.0, 14.0),- float2(0.0, 14.0), float2(0.0, 14.0), float2(0.0, 14.0), float2(0.0, 14.0), float2(1.0, 14.0),- float2(2.0, 13.0), float2(2.0, 13.0)+static const float4 PIX_RECT[21] = {+ float4(0.035, 0.035, 0.105, 0.035),+ float4(0.07, -0.035, 0.14, 0.035),+ float4(0.105, -0.105, 0.175, 0.035),+ float4(0.14, -0.175, 0.21, 0.035),+ float4(0.175, -0.245, 0.245, 0.035),+ float4(0.21, -0.315, 0.28, 0.035),+ float4(0.245, -0.455, 0.315, 0.105),+ float4(0.21, -0.595, 0.28, 0.035),+ float4(0.245, -0.7, 0.315, 0.07),+ float4(0.035, -0.805, 0.105, 0.035),+ float4(0.385, -0.805, 0.175, 0.035),+ float4(0.42, -0.875, 0.14, 0.035),+ float4(0.0, -0.07, 0.14, 0.14),+ float4(0.105, -0.245, 0.245, 0.035),+ float4(0.21, -0.315, 0.35, 0.035),+ float4(0.175, -0.49, 0.525, 0.14),+ float4(0.21, -0.665, 0.49, 0.035),+ float4(0.245, -0.735, 0.455, 0.035),+ float4(0.245, -0.805, 0.385, 0.035),+ float4(0.245, -0.875, 0.315, 0.035),+ float4(0.245, -0.945, 0.245, 0.035)};+// </pixel-candy-voxels>-// Origine de la grille : la flèche part de sa pointe, la main de 2,5 cellules à sa gauche.-float2 s_grid_origin(int shape)+// Le bit `c` d'une ligne. FXC évalue les deux côtés d'un `&&` : chaque index est ramené dans sa+// table avant la lecture, les tests de bornes font le reste.+bool s_pix_bit(int m, int c){- return shape == 0 ? float2(0.0, 0.0) : float2(-2.5 * SCULPT_VOX, 0.0);+ return ((m >> clamp(c, 0, 31)) & 1) == 1;}-// Le bit `c` de la ligne `r` d'une table de `rows` lignes et `cols` colonnes. FXC évalue les deux-// côtés d'un `&&` : l'index est ramené dans la table avant la lecture, le test fait le reste.-bool s_bit(int row, int r, int c, int rows, int cols)+// La cellule (c, r) de la forme `shape`, r compté vers le bas depuis la ligne 0 : un voxel de la+// face, un voxel menthe, un bloc de l'anneau.+bool s_pix_body(int shape, int c, int r){- return r >= 0 && r < rows && c >= 0 && c < cols && ((row >> clamp(c, 0, 31)) & 1) == 1;+ int4 g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_BODY[g.z + clamp(r, 0, g.y - 1)], c);}-// La cellule `id` (colonne, ligne, y vers le haut) porte-t-elle un voxel de la face ?-bool s_occ(float2 id, int shape)+bool s_pix_mint(int shape, int c, int r){- int c = (int)id.x;- int r = -(int)id.y - 1;- if (shape == 0)- {- return s_bit(SCULPT_ARROWPIX[clamp(r, 0, 15)], r, c, 16, 16);- }- return s_bit(SCULPT_HANDPIX[clamp(r, 0, 14)], r, c, 15, 13);+ int4 g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_MINT[g.z + clamp(r, 0, g.y - 1)], c);}-// … et un bloc de la couche violette.-bool s_occ_back(float2 id, int shape)+bool s_pix_ring(int shape, int c, int r){- int c = (int)id.x + 1;- int r = -(int)id.y;- if (shape == 0)- {- return s_bit(SCULPT_ARROWBACK[clamp(r, 0, 17)], r, c, 18, 17);- }- return s_bit(SCULPT_HANDBACK[clamp(r, 0, 16)], r, c, 17, 15);+ int4 g = PIX_GRID[shape];+ return c >= -1 && c <= g.x && r >= -1 && r <= g.y+ && s_pix_bit(PIX_RING[g.w + clamp(r + 1, 0, g.y + 1)], c + 1);+}++// La cellule qui contient `p` (prototype, y vers le haut).+int2 s_pix_cell(float2 p, int shape)+{+ float2 o = PIX_ORIGIN[shape];+ return int2((int)floor((p.x - o.x) / SCULPT_VOX), (int)floor((o.y - p.y) / SCULPT_VOX));}-// Chaque cellule pleine est un cube biseauté ; la couche violette est un étage plus bas. Hors du-// voisinage 3×3, une borne : une cellule au moins, et jamais plus près que la boîte de la forme.+// Chaque voxel de la face est un cube au bord à peine cassé, pour que la face lise d'un bloc ;+// l'anneau violet est en retrait de 0,03 derrière elle. Hors du voisinage 3×3, une borne : une+// cellule au moins, et jamais plus près que la boîte de la forme.float2 s_voxels(float3 p, int shape){- float2 o = s_grid_origin(shape);- float2 cell = floor((p.xy - o) / SCULPT_VOX);- float2 bc = shape == 0 ? float2(0.33, -0.5) : float2(0.25, -0.47);- float2 bh = shape == 0 ? float2(0.44, 0.61) : float2(0.48, 0.55);- float2 bq = max(abs(p.xy - bc) - bh, 0.0);+ float4 b = PIX_BOX[shape];+ float2 bq = max(abs(p.xy - b.xy) - b.zw, 0.0);float bz = max(abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07, 0.0);float far = max(SCULPT_VOX, sqrt(dot(bq, bq) + bz * bz));float dF = far;float dB = far;- const float3 half_cell = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.04);+ float2 o = PIX_ORIGIN[shape];+ int2 cell = s_pix_cell(p.xy, shape);+ const float3 face = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.07);+ const float3 ring = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.055);[loop] for (int j = -1; j <= 1; j++){[loop] for (int i = -1; i <= 1; i++){- float2 id = cell + float2(i, j);- float3 q = float3(p.xy - (o + (id + 0.5) * SCULPT_VOX), p.z);- if (s_occ(id, shape))+ int c = cell.x + i;+ int r = cell.y + j;+ float3 q = float3(p.x - o.x - (c + 0.5) * SCULPT_VOX, p.y - o.y + (r + 0.5) * SCULPT_VOX, p.z);+ if (s_pix_body(shape, c, r)){- dF = min(dF, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.1), half_cell, 0.009));+ dF = min(dF, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.07), face, 0.004));}- if (s_occ_back(id, shape))+ if (s_pix_ring(shape, c, r)){- dB = min(dB, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.04), half_cell, 0.009));+ dB = min(dB, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.055), ring, 0.01));}}}return dF < dB ? float2(dF, 6.0) : float2(dB, 7.0);}-// Distance, dans le plan de l'écran, au contour de la couche violette de la main.-float s_pixel_hand_dist(float2 p)+// Distance, dans le plan de l'écran, au contour de la face et de l'anneau.+float s_pixel_outline(float2 p, int shape){float d = 1e9;- [loop] for (int r = 0; r < 17; r++)+ [loop] for (int i = PIX_RECT_N[shape]; i < PIX_RECT_N[shape + 1]; i++){- float2 x = (SCULPT_HANDSPAN[r] + float2(-3.5, -2.5)) * SCULPT_VOX;- float2 y = float2(-r, 1.0 - r) * SCULPT_VOX;- float2 q = max(max(float2(x.x, y.x) - p, p - float2(x.y, y.y)), 0.0);- d = min(d, length(q));+ float2 q = abs(p - PIX_RECT[i].xy) - PIX_RECT[i].zw;+ d = min(d, length(max(q, 0.0)) + min(max(q.x, q.y), 0.0));}return d;}@@ -1029,23 +1029,28 @@ float s_pixel_hand_dist(float2 p)// scripts/generate-prism-glow-gem.mjs, qui réécrit les trois shaders : c'est là qu'on change une// pièce.// <prism-glow-gem>-static const float4 GEM_PLANES[182] = {- float4(0.0000, 0.0000, 1.0000, 0.2800), float4(0.0000, 0.0000, -1.0000, -0.0500),- float4(-1.0000, 0.0000, 0.0000, 0.0200), float4(-0.9104, 0.0000, 0.4138, 0.0658),- float4(-0.5085, -0.1525, 0.8475, 0.2021), float4(-0.5085, 0.1525, 0.8475, 0.0725),- float4(0.3690, -0.9294, 0.0000, 0.8105), float4(0.3360, -0.8461, 0.4138, 0.7854),- float4(0.3294, -0.4163, 0.8475, 0.5427), float4(0.0459, -0.5289, 0.8475, 0.5358),- float4(0.6854, 0.7282, 0.0000, 0.0081), float4(0.6239, 0.6629, 0.4138, 0.0550),- float4(0.2374, 0.4748, 0.8475, 0.0654), float4(0.4596, 0.2657, 0.8475, 0.1971),- float4(0.0000, 0.0000, 1.0000, 0.2800), float4(0.0000, 0.0000, -1.0000, -0.0500),- float4(-0.9076, -0.4199, 0.0000, 0.0841), float4(-0.8262, -0.3823, 0.4138, 0.1242),- float4(-0.3974, -0.3520, 0.8475, 0.3039), float4(-0.5255, -0.0751, 0.8475, 0.0359),- float4(0.4008, -0.9162, 0.0000, 1.0645), float4(0.3649, -0.8340, 0.4138, 1.0166),- float4(0.3436, -0.4047, 0.8475, 0.6723), float4(0.0641, -0.5270, 0.8475, 0.6645),- float4(0.9104, 0.4138, 0.0000, 0.0977), float4(0.8288, 0.3767, 0.4138, 0.1365),- float4(0.3998, 0.3493, 0.8475, 0.0418), float4(0.5260, 0.0715, 0.8475, 0.3117),- float4(-0.3665, 0.9304, 0.0000, -0.6975), float4(-0.3337, 0.8470, 0.4138, -0.5874),- float4(-0.3283, 0.4172, 0.8475, -0.2344), float4(-0.0444, 0.5290, 0.8475, -0.2207),+static const float4 GEM_PLANES[192] = {+ float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-1.0000, 0.0000, 0.0000, 0.0200),+ float4(0.6701, 0.7423, 0.0000, 0.0089), float4(0.3396, -0.9406, 0.0000, 0.8209),+ float4(-0.7071, 0.0000, 0.7071, 0.0990), float4(0.4738, 0.5249, 0.7071, 0.0911),+ float4(-0.5321, 0.0453, 0.8455, 0.1135), float4(0.3282, 0.4268, 0.8427, 0.1074),+ float4(0.2402, -0.6651, 0.7071, 0.6653), float4(-0.5305, -0.0518, 0.8461, 0.1578),+ float4(0.1183, -0.5102, 0.8519, 0.5489), float4(0.2317, -0.4575, 0.8585, 0.5489),+ float4(0.3883, 0.3573, 0.8495, 0.1523), float4(-0.5134, -0.0525, 0.8565, 0.1609),+ float4(0.0252, -0.2758, 0.9609, 0.3798), float4(0.1526, -0.2157, 0.9645, 0.3784),+ float4(0.3772, 0.3440, 0.8599, 0.1556), float4(0.0000, 0.0000, -1.0000, -0.0500),+ float4(-0.9247, -0.3807, 0.0000, 0.0756), float4(-0.2425, 0.9701, 0.0000, -0.6864),+ float4(0.3162, -0.9487, 0.0000, 1.0530), float4(0.9162, 0.4008, 0.0000, 0.1535),+ float4(-0.6951, -0.2862, 0.6594, 0.1360), float4(-0.1823, 0.7293, 0.6594, -0.4369),+ float4(-0.6008, -0.1704, 0.7810, 0.0920), float4(-0.2671, 0.5255, 0.8078, -0.3007),+ float4(0.2377, -0.7132, 0.6594, 0.8708), float4(-0.5558, -0.3051, 0.7733, 0.2145),+ float4(0.0695, -0.6055, 0.7928, 0.7235), float4(0.6887, 0.3013, 0.6594, 0.1945),+ float4(0.3049, -0.5129, 0.8024, 0.7420), float4(0.5987, 0.1809, 0.7803, 0.2685),+ float4(0.5498, 0.3206, 0.7713, 0.1366), float4(-0.0211, 0.6144, 0.7887, -0.2831),+ float4(-0.5531, -0.1469, 0.8200, 0.0945), float4(-0.2350, 0.3241, 0.9164, -0.1346),+ float4(-0.5001, -0.2865, 0.8172, 0.2243), float4(-0.0196, -0.4001, 0.9163, 0.5194),+ float4(0.2515, -0.2926, 0.9226, 0.5389), float4(0.5634, 0.1624, 0.8101, 0.2721),+ float4(0.5203, 0.3103, 0.7956, 0.1356), float4(0.0413, 0.4381, 0.8980, -0.1238),float4(0.0000, 0.0000, -1.0000, -0.0500), float4(0.0000, -1.0000, 0.0000, 0.7200),float4(-1.0000, 0.0000, 0.0000, 0.1400), float4(1.0000, 0.0000, 0.0000, 0.1400),float4(0.7682, 0.6402, 0.0000, 0.0499), float4(0.0000, 1.0000, 0.0000, 0.0000),@@ -1122,10 +1127,10 @@ static const float4 GEM_PLANES[182] = {float4(-0.0779, -0.2355, 0.9688, 0.4421), float4(-0.1668, -0.2549, 0.9525, 0.4530),float4(0.1324, -0.1566, 0.9787, 0.4232), float4(0.1566, -0.1906, 0.9691, 0.4552)};-static const int GEM_PIECE[9] = { 0, 14, 32, 53, 77, 101, 124, 149, 182 };+static const int GEM_PIECE[9] = { 0, 17, 42, 63, 87, 111, 134, 159, 192 };static const float3 GEM_BOX[4] = {- float3(0.320, -0.485, 0.165),- float3(0.350, 0.525, 0.125),+ float3(0.340, -0.485, 0.160),+ float3(0.370, 0.525, 0.120),float3(0.107, -0.500, 0.175),float3(0.487, 0.510, 0.135)};@@ -1234,7 +1239,7 @@ float2 sculpt_eval(float3 q, bool occ)float2 r;if (occ && theme == 3){- float d2 = shape == 0 ? s_arrow2(p.xy) - 1.2 * SCULPT_VOX : s_pixel_hand_dist(p.xy);+ float d2 = s_pixel_outline(p.xy, shape);float dz = abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07;r = float2(length(max(float2(d2, dz), 0.0)) + min(max(d2, dz), 0.0), 7.0);}@@ -1357,20 +1362,20 @@ SculptMat s_mat(float3 alb, float rough, float spec, float sss, float refl)return m;}-// Couleur de face du voxel qui porte `p` (prototype) : menthe où le bord regarde en bas à gauche,-// rose pâle où il regarde en haut à droite, rose dedans.+// Couleur de face du voxel qui porte `p` (prototype) : menthe où la grille le dit, rose pâle sur+// le dessus des marches (rien au-dessus), rose dedans.float3 s_pixel_colour(float3 p, int shape){- float2 id = floor((p.xy - s_grid_origin(shape)) / SCULPT_VOX);- if (!s_occ(id + float2(-1.0, 0.0), shape) || !s_occ(id + float2(0.0, -1.0), shape))+ int2 cell = s_pix_cell(p.xy, shape);+ if (s_pix_mint(shape, cell.x, cell.y)){- return s_lin(0.52, 0.91, 0.77);+ return s_lin(0.30, 0.82, 0.58);}- if (!s_occ(id + float2(1.0, 0.0), shape) || !s_occ(id + float2(0.0, 1.0), shape))+ if (!s_pix_body(shape, cell.x, cell.y - 1)){- return s_lin(1.0, 0.78, 0.87);+ return s_lin(1.0, 0.76, 0.76);}- return s_lin(1.0, 0.50, 0.71);+ return s_lin(1.0, 0.40, 0.62);}// La matière `mat` (id de `sculpt_proto`) au point `p` du prototype.@@ -1402,8 +1407,9 @@ SculptMat sculpt_material(float mat, float3 p, int theme, int shape)if (mat < 4.5) return s_mat(s_lin(0.62, 0.92, 0.72), 0.3, 0.6, 0.3, 0.35);return s_mat(s_lin(0.07, 0.15, 0.33), 0.7, 0.15, 0.05, 0.08);}- if (mat < 6.5) return s_mat(s_pixel_colour(p, shape), 0.45, 0.35, 0.15, 0.2);- return s_mat(s_lin(0.36, 0.18, 0.54), 0.45, 0.35, 0.1, 0.2);+ if (mat < 6.5) return s_mat(s_pixel_colour(p, shape), 0.45, 0.3, 0.15, 0.12);+ // L'anneau violet, mat : sous la lampe, un reflet le blanchirait.+ return s_mat(s_lin(0.22, 0.13, 0.33), 0.65, 0.15, 0.05, 0.06);}// L'environnement du studio vu du modèle : l'écran dessous, la pièce au-dessus (z du modèle), unediff --git a/crates/compositor/src/shaders.metal b/crates/compositor/src/shaders.metalindex 0157c79ca..671fedfb5 100644--- a/crates/compositor/src/shaders.metal+++ b/crates/compositor/src/shaders.metal@@ -589,7 +589,7 @@ inline int sculpt_id(constant Layer &layer)// ---- Curseurs sculptés ---- (repère du PROTOTYPE : hauteur 1, y vers le haut, écran en z = 0)constant float SCULPT_SCALE = 0.85;constant float SCULPT_HOVER = 0.05;-constant float SCULPT_VOX = 0.0625;+constant float SCULPT_VOX = 0.07;constant float SCULPT_ZREF_ARROW = 0.2;constant float SCULPT_ZREF_HAND = 0.185;constant float SCULPT_LAMP_DIST = 1.9;@@ -637,34 +637,6 @@ inline float2 s_rot(float2 v, float a)return float2(c * v.x - s * v.y, s * v.x + c * v.y);}-constant float2 SCULPT_ARROW[7] = {- float2(0.0, 0.0), float2(0.0, -0.86), float2(0.215, -0.665), float2(0.37, -1.0),- float2(0.53, -0.93), float2(0.38, -0.60), float2(0.64, -0.60)-};--static float s_arrow2(float2 p)-{- float d = dot(p - SCULPT_ARROW[0], p - SCULPT_ARROW[0]);- float s = 1.0;- int j = 6;- for (int i = 0; i < 7; i++)- {- float2 e = SCULPT_ARROW[j] - SCULPT_ARROW[i];- float2 w = p - SCULPT_ARROW[i];- float2 b = w - e * saturate(dot(w, e) / dot(e, e));- d = min(d, dot(b, b));- bool c0 = p.y >= SCULPT_ARROW[i].y;- bool c1 = p.y < SCULPT_ARROW[j].y;- bool c2 = e.x * w.y > e.y * w.x;- if ((c0 && c1 && c2) || (!c0 && !c1 && !c2))- {- s = -s;- }- j = i;- }- return s * sqrt(d);-}-static float s_star5(float2 p, float r, float rf){const float2 k1 = float2(0.809016994375, -0.587785252292);@@ -869,117 +841,146 @@ static float2 s_rimmed(float3 p, int theme, int shape)return s_opu(r, float2(s_ellipsoid(e, float3(0.075, 0.13, 0.1)) * rs, 5.0));}-// Pixel Candy : une ligne par entier, bit c = colonne c (cf. HLSL et `sculpt.rs`).-constant int SCULPT_ARROWPIX[16] = { 0, 1, 3, 7, 31, 63, 127, 255, 511, 63, 55, 115, 113, 224, 224, 64 };-constant int SCULPT_ARROWBACK[18] = {- 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 255, 511, 511, 999, 995, 960, 192+// Pixel Candy : tables générées par scripts/generate-pixel-candy-voxels.mjs (cf. HLSL).+// <pixel-candy-voxels>+constant int PIX_BODY[25] = { 1, 3, 7, 15, 31, 63, 127, 31, 27, 59, 113, 96, 24, 24, 24, 24, 216, 1752, 7899, 8191, 8190, 8188, 4088, 2032, 992 };+constant int PIX_MINT[25] = { 0, 0, 0, 0, 0, 1, 1, 1, 9, 11, 17, 32, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32 };+constant int PIX_RING[29] = { 7, 13, 25, 49, 97, 193, 385, 257, 449, 201, 393, 285, 311, 480, 120, 72, 72, 72, 968, 7752, 29263, 16969, 16385, 16387, 16390, 24588, 12312, 6192, 4064 };+constant int PIX_RECT_N[3] = { 0, 12, 21 };+constant int4 PIX_GRID[2] = {+ int4(7, 12, 0, 0),+ int4(13, 13, 12, 14)+};+constant float2 PIX_ORIGIN[2] = {+ float2(0.0, 0.0),+ float2(-0.28, 0.0)};-constant int SCULPT_HANDPIX[15] = { 4, 14, 14, 14, 110, 878, 7022, 7022, 8190, 8191, 8191, 8191, 8190, 4092, 4092 };-constant int SCULPT_HANDBACK[17] = {- 28, 62, 62, 62, 510, 4094, 32766, 32766, 32766, 32767, 32767, 32767, 32767, 32767, 32766, 16380, 16380+constant float4 PIX_BOX[2] = {+ float4(0.245, -0.42, 0.315, 0.49),+ float4(0.175, -0.455, 0.525, 0.525)};-constant float2 SCULPT_HANDSPAN[17] = {- float2(2.0, 4.0), float2(1.0, 5.0), float2(1.0, 5.0), float2(1.0, 5.0), float2(1.0, 8.0),- float2(1.0, 11.0), float2(1.0, 14.0), float2(1.0, 14.0), float2(1.0, 14.0), float2(0.0, 14.0),- float2(0.0, 14.0), float2(0.0, 14.0), float2(0.0, 14.0), float2(0.0, 14.0), float2(1.0, 14.0),- float2(2.0, 13.0), float2(2.0, 13.0)+constant float4 PIX_RECT[21] = {+ float4(0.035, 0.035, 0.105, 0.035),+ float4(0.07, -0.035, 0.14, 0.035),+ float4(0.105, -0.105, 0.175, 0.035),+ float4(0.14, -0.175, 0.21, 0.035),+ float4(0.175, -0.245, 0.245, 0.035),+ float4(0.21, -0.315, 0.28, 0.035),+ float4(0.245, -0.455, 0.315, 0.105),+ float4(0.21, -0.595, 0.28, 0.035),+ float4(0.245, -0.7, 0.315, 0.07),+ float4(0.035, -0.805, 0.105, 0.035),+ float4(0.385, -0.805, 0.175, 0.035),+ float4(0.42, -0.875, 0.14, 0.035),+ float4(0.0, -0.07, 0.14, 0.14),+ float4(0.105, -0.245, 0.245, 0.035),+ float4(0.21, -0.315, 0.35, 0.035),+ float4(0.175, -0.49, 0.525, 0.14),+ float4(0.21, -0.665, 0.49, 0.035),+ float4(0.245, -0.735, 0.455, 0.035),+ float4(0.245, -0.805, 0.385, 0.035),+ float4(0.245, -0.875, 0.315, 0.035),+ float4(0.245, -0.945, 0.245, 0.035)};+// </pixel-candy-voxels>-inline float2 s_grid_origin(int shape)+inline bool s_pix_bit(int m, int c){- return shape == 0 ? float2(0.0, 0.0) : float2(-2.5 * SCULPT_VOX, 0.0);+ return ((m >> clamp(c, 0, 31)) & 1) == 1;}-inline bool s_bit(int row, int r, int c, int rows, int cols)+static bool s_pix_body(int shape, int c, int r){- return r >= 0 && r < rows && c >= 0 && c < cols && ((row >> clamp(c, 0, 31)) & 1) == 1;+ int4 g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_BODY[g.z + clamp(r, 0, g.y - 1)], c);}-static bool s_occ(float2 id, int shape)+static bool s_pix_mint(int shape, int c, int r){- int c = int(id.x);- int r = -int(id.y) - 1;- if (shape == 0)- {- return s_bit(SCULPT_ARROWPIX[clamp(r, 0, 15)], r, c, 16, 16);- }- return s_bit(SCULPT_HANDPIX[clamp(r, 0, 14)], r, c, 15, 13);+ int4 g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_MINT[g.z + clamp(r, 0, g.y - 1)], c);}-static bool s_occ_back(float2 id, int shape)+static bool s_pix_ring(int shape, int c, int r){- int c = int(id.x) + 1;- int r = -int(id.y);- if (shape == 0)- {- return s_bit(SCULPT_ARROWBACK[clamp(r, 0, 17)], r, c, 18, 17);- }- return s_bit(SCULPT_HANDBACK[clamp(r, 0, 16)], r, c, 17, 15);+ int4 g = PIX_GRID[shape];+ return c >= -1 && c <= g.x && r >= -1 && r <= g.y+ && s_pix_bit(PIX_RING[g.w + clamp(r + 1, 0, g.y + 1)], c + 1);+}++inline int2 s_pix_cell(float2 p, int shape)+{+ float2 o = PIX_ORIGIN[shape];+ return int2(int(floor((p.x - o.x) / SCULPT_VOX)), int(floor((o.y - p.y) / SCULPT_VOX)));}static float2 s_voxels(float3 p, int shape){- float2 o = s_grid_origin(shape);- float2 cell = floor((p.xy - o) / SCULPT_VOX);- float2 bc = shape == 0 ? float2(0.33, -0.5) : float2(0.25, -0.47);- float2 bh = shape == 0 ? float2(0.44, 0.61) : float2(0.48, 0.55);- float2 bq = max(abs(p.xy - bc) - bh, 0.0);+ float4 b = PIX_BOX[shape];+ float2 bq = max(abs(p.xy - b.xy) - b.zw, 0.0);float bz = max(abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07, 0.0);float far = max(SCULPT_VOX, sqrt(dot(bq, bq) + bz * bz));float dF = far;float dB = far;- const float3 half_cell = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.04);+ float2 o = PIX_ORIGIN[shape];+ int2 cell = s_pix_cell(p.xy, shape);+ const float3 face = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.07);+ const float3 ring = float3(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.055);for (int j = -1; j <= 1; j++){for (int i = -1; i <= 1; i++){- float2 id = cell + float2(float(i), float(j));- float3 q = float3(p.xy - (o + (id + 0.5) * SCULPT_VOX), p.z);- if (s_occ(id, shape))+ int c = cell.x + i;+ int r = cell.y + j;+ float3 q = float3(p.x - o.x - (float(c) + 0.5) * SCULPT_VOX, p.y - o.y + (float(r) + 0.5) * SCULPT_VOX, p.z);+ if (s_pix_body(shape, c, r)){- dF = min(dF, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.1), half_cell, 0.009));+ dF = min(dF, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.07), face, 0.004));}- if (s_occ_back(id, shape))+ if (s_pix_ring(shape, c, r)){- dB = min(dB, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.04), half_cell, 0.009));+ dB = min(dB, s_round_box(q - float3(0.0, 0.0, SCULPT_HOVER + 0.055), ring, 0.01));}}}return dF < dB ? float2(dF, 6.0) : float2(dB, 7.0);}-static float s_pixel_hand_dist(float2 p)+static float s_pixel_outline(float2 p, int shape){float d = 1e9;- for (int r = 0; r < 17; r++)+ for (int i = PIX_RECT_N[shape]; i < PIX_RECT_N[shape + 1]; i++){- float2 x = (SCULPT_HANDSPAN[r] + float2(-3.5, -2.5)) * SCULPT_VOX;- float2 y = float2(-float(r), 1.0 - float(r)) * SCULPT_VOX;- float2 q = max(max(float2(x.x, y.x) - p, p - float2(x.y, y.y)), 0.0);- d = min(d, length(q));+ float2 q = abs(p - PIX_RECT[i].xy) - PIX_RECT[i].zw;+ d = min(d, length(max(q, 0.0)) + min(max(q.x, q.y), 0.0));}return d;}// Prism Glow : table générée par scripts/generate-prism-glow-gem.mjs (cf. HLSL).// <prism-glow-gem>-constant float4 GEM_PLANES[182] = {- float4(0.0000, 0.0000, 1.0000, 0.2800), float4(0.0000, 0.0000, -1.0000, -0.0500),- float4(-1.0000, 0.0000, 0.0000, 0.0200), float4(-0.9104, 0.0000, 0.4138, 0.0658),- float4(-0.5085, -0.1525, 0.8475, 0.2021), float4(-0.5085, 0.1525, 0.8475, 0.0725),- float4(0.3690, -0.9294, 0.0000, 0.8105), float4(0.3360, -0.8461, 0.4138, 0.7854),- float4(0.3294, -0.4163, 0.8475, 0.5427), float4(0.0459, -0.5289, 0.8475, 0.5358),- float4(0.6854, 0.7282, 0.0000, 0.0081), float4(0.6239, 0.6629, 0.4138, 0.0550),- float4(0.2374, 0.4748, 0.8475, 0.0654), float4(0.4596, 0.2657, 0.8475, 0.1971),- float4(0.0000, 0.0000, 1.0000, 0.2800), float4(0.0000, 0.0000, -1.0000, -0.0500),- float4(-0.9076, -0.4199, 0.0000, 0.0841), float4(-0.8262, -0.3823, 0.4138, 0.1242),- float4(-0.3974, -0.3520, 0.8475, 0.3039), float4(-0.5255, -0.0751, 0.8475, 0.0359),- float4(0.4008, -0.9162, 0.0000, 1.0645), float4(0.3649, -0.8340, 0.4138, 1.0166),- float4(0.3436, -0.4047, 0.8475, 0.6723), float4(0.0641, -0.5270, 0.8475, 0.6645),- float4(0.9104, 0.4138, 0.0000, 0.0977), float4(0.8288, 0.3767, 0.4138, 0.1365),- float4(0.3998, 0.3493, 0.8475, 0.0418), float4(0.5260, 0.0715, 0.8475, 0.3117),- float4(-0.3665, 0.9304, 0.0000, -0.6975), float4(-0.3337, 0.8470, 0.4138, -0.5874),- float4(-0.3283, 0.4172, 0.8475, -0.2344), float4(-0.0444, 0.5290, 0.8475, -0.2207),+constant float4 GEM_PLANES[192] = {+ float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-1.0000, 0.0000, 0.0000, 0.0200),+ float4(0.6701, 0.7423, 0.0000, 0.0089), float4(0.3396, -0.9406, 0.0000, 0.8209),+ float4(-0.7071, 0.0000, 0.7071, 0.0990), float4(0.4738, 0.5249, 0.7071, 0.0911),+ float4(-0.5321, 0.0453, 0.8455, 0.1135), float4(0.3282, 0.4268, 0.8427, 0.1074),+ float4(0.2402, -0.6651, 0.7071, 0.6653), float4(-0.5305, -0.0518, 0.8461, 0.1578),+ float4(0.1183, -0.5102, 0.8519, 0.5489), float4(0.2317, -0.4575, 0.8585, 0.5489),+ float4(0.3883, 0.3573, 0.8495, 0.1523), float4(-0.5134, -0.0525, 0.8565, 0.1609),+ float4(0.0252, -0.2758, 0.9609, 0.3798), float4(0.1526, -0.2157, 0.9645, 0.3784),+ float4(0.3772, 0.3440, 0.8599, 0.1556), float4(0.0000, 0.0000, -1.0000, -0.0500),+ float4(-0.9247, -0.3807, 0.0000, 0.0756), float4(-0.2425, 0.9701, 0.0000, -0.6864),+ float4(0.3162, -0.9487, 0.0000, 1.0530), float4(0.9162, 0.4008, 0.0000, 0.1535),+ float4(-0.6951, -0.2862, 0.6594, 0.1360), float4(-0.1823, 0.7293, 0.6594, -0.4369),+ float4(-0.6008, -0.1704, 0.7810, 0.0920), float4(-0.2671, 0.5255, 0.8078, -0.3007),+ float4(0.2377, -0.7132, 0.6594, 0.8708), float4(-0.5558, -0.3051, 0.7733, 0.2145),+ float4(0.0695, -0.6055, 0.7928, 0.7235), float4(0.6887, 0.3013, 0.6594, 0.1945),+ float4(0.3049, -0.5129, 0.8024, 0.7420), float4(0.5987, 0.1809, 0.7803, 0.2685),+ float4(0.5498, 0.3206, 0.7713, 0.1366), float4(-0.0211, 0.6144, 0.7887, -0.2831),+ float4(-0.5531, -0.1469, 0.8200, 0.0945), float4(-0.2350, 0.3241, 0.9164, -0.1346),+ float4(-0.5001, -0.2865, 0.8172, 0.2243), float4(-0.0196, -0.4001, 0.9163, 0.5194),+ float4(0.2515, -0.2926, 0.9226, 0.5389), float4(0.5634, 0.1624, 0.8101, 0.2721),+ float4(0.5203, 0.3103, 0.7956, 0.1356), float4(0.0413, 0.4381, 0.8980, -0.1238),float4(0.0000, 0.0000, -1.0000, -0.0500), float4(0.0000, -1.0000, 0.0000, 0.7200),float4(-1.0000, 0.0000, 0.0000, 0.1400), float4(1.0000, 0.0000, 0.0000, 0.1400),float4(0.7682, 0.6402, 0.0000, 0.0499), float4(0.0000, 1.0000, 0.0000, 0.0000),@@ -1056,10 +1057,10 @@ constant float4 GEM_PLANES[182] = {float4(-0.0779, -0.2355, 0.9688, 0.4421), float4(-0.1668, -0.2549, 0.9525, 0.4530),float4(0.1324, -0.1566, 0.9787, 0.4232), float4(0.1566, -0.1906, 0.9691, 0.4552)};-constant int GEM_PIECE[9] = { 0, 14, 32, 53, 77, 101, 124, 149, 182 };+constant int GEM_PIECE[9] = { 0, 17, 42, 63, 87, 111, 134, 159, 192 };constant float3 GEM_BOX[4] = {- float3(0.320, -0.485, 0.165),- float3(0.350, 0.525, 0.125),+ float3(0.340, -0.485, 0.160),+ float3(0.370, 0.525, 0.120),float3(0.107, -0.500, 0.175),float3(0.487, 0.510, 0.135)};@@ -1153,7 +1154,7 @@ static float2 sculpt_eval(float3 q, bool occ, constant Layer &layer)float2 r;if (occ && theme == 3){- float d2 = shape == 0 ? s_arrow2(p.xy) - 1.2 * SCULPT_VOX : s_pixel_hand_dist(p.xy);+ float d2 = s_pixel_outline(p.xy, shape);float dz = abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07;r = float2(length(max(float2(d2, dz), 0.0)) + min(max(d2, dz), 0.0), 7.0);}@@ -1264,16 +1265,16 @@ inline SculptMat s_mat(float3 alb, float rough, float spec, float sss, float refstatic float3 s_pixel_colour(float3 p, int shape){- float2 id = floor((p.xy - s_grid_origin(shape)) / SCULPT_VOX);- if (!s_occ(id + float2(-1.0, 0.0), shape) || !s_occ(id + float2(0.0, -1.0), shape))+ int2 cell = s_pix_cell(p.xy, shape);+ if (s_pix_mint(shape, cell.x, cell.y)){- return s_lin(0.52, 0.91, 0.77);+ return s_lin(0.30, 0.82, 0.58);}- if (!s_occ(id + float2(1.0, 0.0), shape) || !s_occ(id + float2(0.0, 1.0), shape))+ if (!s_pix_body(shape, cell.x, cell.y - 1)){- return s_lin(1.0, 0.78, 0.87);+ return s_lin(1.0, 0.76, 0.76);}- return s_lin(1.0, 0.50, 0.71);+ return s_lin(1.0, 0.40, 0.62);}static SculptMat sculpt_material(float mat, float3 p, int theme, int shape)@@ -1299,8 +1300,8 @@ static SculptMat sculpt_material(float mat, float3 p, int theme, int shape)if (mat < 4.5) return s_mat(s_lin(0.62, 0.92, 0.72), 0.3, 0.6, 0.3, 0.35);return s_mat(s_lin(0.07, 0.15, 0.33), 0.7, 0.15, 0.05, 0.08);}- if (mat < 6.5) return s_mat(s_pixel_colour(p, shape), 0.45, 0.35, 0.15, 0.2);- return s_mat(s_lin(0.36, 0.18, 0.54), 0.45, 0.35, 0.1, 0.2);+ if (mat < 6.5) return s_mat(s_pixel_colour(p, shape), 0.45, 0.3, 0.15, 0.12);+ return s_mat(s_lin(0.22, 0.13, 0.33), 0.65, 0.15, 0.05, 0.06);}static float3 model_env(float3 d, float rough, float3 l, float3 fill)diff --git a/crates/compositor/src/vk_shaders/layer.wgsl b/crates/compositor/src/vk_shaders/layer.wgslindex 3a97bf932..9b3ea7bd5 100644--- a/crates/compositor/src/vk_shaders/layer.wgsl+++ b/crates/compositor/src/vk_shaders/layer.wgsl@@ -609,7 +609,7 @@ fn sculpt_id() -> i32 {// ---- Curseurs sculptes ---- (repere du PROTOTYPE : hauteur 1, y vers le haut, ecran en z = 0)const SCULPT_SCALE: f32 = 0.85;const SCULPT_HOVER: f32 = 0.05;-const SCULPT_VOX: f32 = 0.0625;+const SCULPT_VOX: f32 = 0.07;const SCULPT_ZREF_ARROW: f32 = 0.2;const SCULPT_ZREF_HAND: f32 = 0.185;const SCULPT_LAMP_DIST: f32 = 1.9;@@ -651,31 +651,6 @@ fn s_rot(v: vec2<f32>, a: f32) -> vec2<f32> {return vec2<f32>(c * v.x - s * v.y, s * v.x + c * v.y);}-const SCULPT_ARROW = array<vec2<f32>, 7>(- vec2<f32>(0.0, 0.0), vec2<f32>(0.0, -0.86), vec2<f32>(0.215, -0.665), vec2<f32>(0.37, -1.0),- vec2<f32>(0.53, -0.93), vec2<f32>(0.38, -0.60), vec2<f32>(0.64, -0.60)-);--fn s_arrow2(p: vec2<f32>) -> f32 {- var d = dot(p - SCULPT_ARROW[0], p - SCULPT_ARROW[0]);- var s = 1.0;- var j = 6;- for (var i = 0; i < 7; i++) {- let e = SCULPT_ARROW[j] - SCULPT_ARROW[i];- let w = p - SCULPT_ARROW[i];- let b = w - e * saturate(dot(w, e) / dot(e, e));- d = min(d, dot(b, b));- let c0 = p.y >= SCULPT_ARROW[i].y;- let c1 = p.y < SCULPT_ARROW[j].y;- let c2 = e.x * w.y > e.y * w.x;- if (c0 && c1 && c2) || (!c0 && !c1 && !c2) {- s = -s;- }- j = i;- }- return s * sqrt(d);-}-fn s_star5(p0: vec2<f32>, r: f32, rf: f32) -> f32 {let k1 = vec2<f32>(0.809016994375, -0.587785252292);let k2 = vec2<f32>(-0.809016994375, -0.587785252292);@@ -862,104 +837,133 @@ fn s_rimmed(p: vec3<f32>, theme: i32, shape: i32) -> vec2<f32> {return s_opu(r, vec2<f32>(s_ellipsoid(e, vec3<f32>(0.075, 0.13, 0.1)) * rs, 5.0));}-// Pixel Candy : une ligne par entier, bit c = colonne c (cf. HLSL et `sculpt.rs`).-const SCULPT_ARROWPIX = array<i32, 16>(0, 1, 3, 7, 31, 63, 127, 255, 511, 63, 55, 115, 113, 224, 224, 64);-const SCULPT_ARROWBACK = array<i32, 18>(- 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 255, 511, 511, 999, 995, 960, 192+// Pixel Candy : tables générées par scripts/generate-pixel-candy-voxels.mjs (cf. HLSL).+// <pixel-candy-voxels>+const PIX_BODY = array<i32, 25>(1, 3, 7, 15, 31, 63, 127, 31, 27, 59, 113, 96, 24, 24, 24, 24, 216, 1752, 7899, 8191, 8190, 8188, 4088, 2032, 992);+const PIX_MINT = array<i32, 25>(0, 0, 0, 0, 0, 1, 1, 1, 9, 11, 17, 32, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32);+const PIX_RING = array<i32, 29>(7, 13, 25, 49, 97, 193, 385, 257, 449, 201, 393, 285, 311, 480, 120, 72, 72, 72, 968, 7752, 29263, 16969, 16385, 16387, 16390, 24588, 12312, 6192, 4064);+const PIX_RECT_N = array<i32, 3>(0, 12, 21);+const PIX_GRID = array<vec4<i32>, 2>(+ vec4<i32>(7, 12, 0, 0),+ vec4<i32>(13, 13, 12, 14)+);+const PIX_ORIGIN = array<vec2<f32>, 2>(+ vec2<f32>(0.0, 0.0),+ vec2<f32>(-0.28, 0.0));-const SCULPT_HANDPIX = array<i32, 15>(4, 14, 14, 14, 110, 878, 7022, 7022, 8190, 8191, 8191, 8191, 8190, 4092, 4092);-const SCULPT_HANDBACK = array<i32, 17>(- 28, 62, 62, 62, 510, 4094, 32766, 32766, 32766, 32767, 32767, 32767, 32767, 32767, 32766, 16380, 16380+const PIX_BOX = array<vec4<f32>, 2>(+ vec4<f32>(0.245, -0.42, 0.315, 0.49),+ vec4<f32>(0.175, -0.455, 0.525, 0.525));-const SCULPT_HANDSPAN = array<vec2<f32>, 17>(- vec2<f32>(2.0, 4.0), vec2<f32>(1.0, 5.0), vec2<f32>(1.0, 5.0), vec2<f32>(1.0, 5.0), vec2<f32>(1.0, 8.0),- vec2<f32>(1.0, 11.0), vec2<f32>(1.0, 14.0), vec2<f32>(1.0, 14.0), vec2<f32>(1.0, 14.0), vec2<f32>(0.0, 14.0),- vec2<f32>(0.0, 14.0), vec2<f32>(0.0, 14.0), vec2<f32>(0.0, 14.0), vec2<f32>(0.0, 14.0), vec2<f32>(1.0, 14.0),- vec2<f32>(2.0, 13.0), vec2<f32>(2.0, 13.0)+const PIX_RECT = array<vec4<f32>, 21>(+ vec4<f32>(0.035, 0.035, 0.105, 0.035),+ vec4<f32>(0.07, -0.035, 0.14, 0.035),+ vec4<f32>(0.105, -0.105, 0.175, 0.035),+ vec4<f32>(0.14, -0.175, 0.21, 0.035),+ vec4<f32>(0.175, -0.245, 0.245, 0.035),+ vec4<f32>(0.21, -0.315, 0.28, 0.035),+ vec4<f32>(0.245, -0.455, 0.315, 0.105),+ vec4<f32>(0.21, -0.595, 0.28, 0.035),+ vec4<f32>(0.245, -0.7, 0.315, 0.07),+ vec4<f32>(0.035, -0.805, 0.105, 0.035),+ vec4<f32>(0.385, -0.805, 0.175, 0.035),+ vec4<f32>(0.42, -0.875, 0.14, 0.035),+ vec4<f32>(0.0, -0.07, 0.14, 0.14),+ vec4<f32>(0.105, -0.245, 0.245, 0.035),+ vec4<f32>(0.21, -0.315, 0.35, 0.035),+ vec4<f32>(0.175, -0.49, 0.525, 0.14),+ vec4<f32>(0.21, -0.665, 0.49, 0.035),+ vec4<f32>(0.245, -0.735, 0.455, 0.035),+ vec4<f32>(0.245, -0.805, 0.385, 0.035),+ vec4<f32>(0.245, -0.875, 0.315, 0.035),+ vec4<f32>(0.245, -0.945, 0.245, 0.035));+// </pixel-candy-voxels>-fn s_grid_origin(shape: i32) -> vec2<f32> {- return select(vec2<f32>(-2.5 * SCULPT_VOX, 0.0), vec2<f32>(0.0), shape == 0);+fn s_pix_bit(m: i32, c: i32) -> bool {+ return ((m >> u32(clamp(c, 0, 31))) & 1) == 1;}-fn s_bit(row: i32, r: i32, c: i32, rows: i32, cols: i32) -> bool {- return r >= 0 && r < rows && c >= 0 && c < cols && ((row >> u32(clamp(c, 0, 31))) & 1) == 1;+fn s_pix_body(shape: i32, c: i32, r: i32) -> bool {+ let g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_BODY[g.z + clamp(r, 0, g.y - 1)], c);}-fn s_occ(id: vec2<f32>, shape: i32) -> bool {- let c = i32(id.x);- let r = -i32(id.y) - 1;- if shape == 0 {- return s_bit(SCULPT_ARROWPIX[clamp(r, 0, 15)], r, c, 16, 16);- }- return s_bit(SCULPT_HANDPIX[clamp(r, 0, 14)], r, c, 15, 13);+fn s_pix_mint(shape: i32, c: i32, r: i32) -> bool {+ let g = PIX_GRID[shape];+ return c >= 0 && c < g.x && r >= 0 && r < g.y && s_pix_bit(PIX_MINT[g.z + clamp(r, 0, g.y - 1)], c);}-fn s_occ_back(id: vec2<f32>, shape: i32) -> bool {- let c = i32(id.x) + 1;- let r = -i32(id.y);- if shape == 0 {- return s_bit(SCULPT_ARROWBACK[clamp(r, 0, 17)], r, c, 18, 17);- }- return s_bit(SCULPT_HANDBACK[clamp(r, 0, 16)], r, c, 17, 15);+fn s_pix_ring(shape: i32, c: i32, r: i32) -> bool {+ let g = PIX_GRID[shape];+ return c >= -1 && c <= g.x && r >= -1 && r <= g.y && s_pix_bit(PIX_RING[g.w + clamp(r + 1, 0, g.y + 1)], c + 1);+}++fn s_pix_cell(p: vec2<f32>, shape: i32) -> vec2<i32> {+ let o = PIX_ORIGIN[shape];+ return vec2<i32>(i32(floor((p.x - o.x) / SCULPT_VOX)), i32(floor((o.y - p.y) / SCULPT_VOX)));}fn s_voxels(p: vec3<f32>, shape: i32) -> vec2<f32> {- let o = s_grid_origin(shape);- let cell = floor((p.xy - o) / SCULPT_VOX);- let bc = select(vec2<f32>(0.25, -0.47), vec2<f32>(0.33, -0.5), shape == 0);- let bh = select(vec2<f32>(0.48, 0.55), vec2<f32>(0.44, 0.61), shape == 0);- let bq = max(abs(p.xy - bc) - bh, vec2<f32>(0.0));+ let b = PIX_BOX[shape];+ let bq = max(abs(p.xy - b.xy) - b.zw, vec2<f32>(0.0));let bz = max(abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07, 0.0);let far = max(SCULPT_VOX, sqrt(dot(bq, bq) + bz * bz));var dF = far;var dB = far;- let half_cell = vec3<f32>(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.04);+ let o = PIX_ORIGIN[shape];+ let cell = s_pix_cell(p.xy, shape);+ let face = vec3<f32>(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.07);+ let ring = vec3<f32>(0.5 * SCULPT_VOX, 0.5 * SCULPT_VOX, 0.055);for (var j = -1; j <= 1; j++) {for (var i = -1; i <= 1; i++) {- let id = cell + vec2<f32>(f32(i), f32(j));- let q = vec3<f32>(p.xy - (o + (id + vec2<f32>(0.5)) * SCULPT_VOX), p.z);- if s_occ(id, shape) {- dF = min(dF, s_round_box(q - vec3<f32>(0.0, 0.0, SCULPT_HOVER + 0.1), half_cell, 0.009));+ let c = cell.x + i;+ let r = cell.y + j;+ let q = vec3<f32>(p.x - o.x - (f32(c) + 0.5) * SCULPT_VOX, p.y - o.y + (f32(r) + 0.5) * SCULPT_VOX, p.z);+ if s_pix_body(shape, c, r) {+ dF = min(dF, s_round_box(q - vec3<f32>(0.0, 0.0, SCULPT_HOVER + 0.07), face, 0.004));}- if s_occ_back(id, shape) {- dB = min(dB, s_round_box(q - vec3<f32>(0.0, 0.0, SCULPT_HOVER + 0.04), half_cell, 0.009));+ if s_pix_ring(shape, c, r) {+ dB = min(dB, s_round_box(q - vec3<f32>(0.0, 0.0, SCULPT_HOVER + 0.055), ring, 0.01));}}}return select(vec2<f32>(dB, 7.0), vec2<f32>(dF, 6.0), dF < dB);}-fn s_pixel_hand_dist(p: vec2<f32>) -> f32 {+fn s_pixel_outline(p: vec2<f32>, shape: i32) -> f32 {var d = 1e9;- for (var r = 0; r < 17; r++) {- let x = (SCULPT_HANDSPAN[r] + vec2<f32>(-3.5, -2.5)) * SCULPT_VOX;- let y = vec2<f32>(-f32(r), 1.0 - f32(r)) * SCULPT_VOX;- let q = max(max(vec2<f32>(x.x, y.x) - p, p - vec2<f32>(x.y, y.y)), vec2<f32>(0.0));- d = min(d, length(q));+ for (var i = PIX_RECT_N[shape]; i < PIX_RECT_N[shape + 1]; i++) {+ let q = abs(p - PIX_RECT[i].xy) - PIX_RECT[i].zw;+ d = min(d, length(max(q, vec2<f32>(0.0))) + min(max(q.x, q.y), 0.0));}return d;}// Prism Glow : table générée par scripts/generate-prism-glow-gem.mjs (cf. HLSL).// <prism-glow-gem>-const GEM_PLANES = array<vec4<f32>, 182>(- vec4<f32>(0.0000, 0.0000, 1.0000, 0.2800), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),- vec4<f32>(-1.0000, 0.0000, 0.0000, 0.0200), vec4<f32>(-0.9104, 0.0000, 0.4138, 0.0658),- vec4<f32>(-0.5085, -0.1525, 0.8475, 0.2021), vec4<f32>(-0.5085, 0.1525, 0.8475, 0.0725),- vec4<f32>(0.3690, -0.9294, 0.0000, 0.8105), vec4<f32>(0.3360, -0.8461, 0.4138, 0.7854),- vec4<f32>(0.3294, -0.4163, 0.8475, 0.5427), vec4<f32>(0.0459, -0.5289, 0.8475, 0.5358),- vec4<f32>(0.6854, 0.7282, 0.0000, 0.0081), vec4<f32>(0.6239, 0.6629, 0.4138, 0.0550),- vec4<f32>(0.2374, 0.4748, 0.8475, 0.0654), vec4<f32>(0.4596, 0.2657, 0.8475, 0.1971),- vec4<f32>(0.0000, 0.0000, 1.0000, 0.2800), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),- vec4<f32>(-0.9076, -0.4199, 0.0000, 0.0841), vec4<f32>(-0.8262, -0.3823, 0.4138, 0.1242),- vec4<f32>(-0.3974, -0.3520, 0.8475, 0.3039), vec4<f32>(-0.5255, -0.0751, 0.8475, 0.0359),- vec4<f32>(0.4008, -0.9162, 0.0000, 1.0645), vec4<f32>(0.3649, -0.8340, 0.4138, 1.0166),- vec4<f32>(0.3436, -0.4047, 0.8475, 0.6723), vec4<f32>(0.0641, -0.5270, 0.8475, 0.6645),- vec4<f32>(0.9104, 0.4138, 0.0000, 0.0977), vec4<f32>(0.8288, 0.3767, 0.4138, 0.1365),- vec4<f32>(0.3998, 0.3493, 0.8475, 0.0418), vec4<f32>(0.5260, 0.0715, 0.8475, 0.3117),- vec4<f32>(-0.3665, 0.9304, 0.0000, -0.6975), vec4<f32>(-0.3337, 0.8470, 0.4138, -0.5874),- vec4<f32>(-0.3283, 0.4172, 0.8475, -0.2344), vec4<f32>(-0.0444, 0.5290, 0.8475, -0.2207),+const GEM_PLANES = array<vec4<f32>, 192>(+ vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500), vec4<f32>(-1.0000, 0.0000, 0.0000, 0.0200),+ vec4<f32>(0.6701, 0.7423, 0.0000, 0.0089), vec4<f32>(0.3396, -0.9406, 0.0000, 0.8209),+ vec4<f32>(-0.7071, 0.0000, 0.7071, 0.0990), vec4<f32>(0.4738, 0.5249, 0.7071, 0.0911),+ vec4<f32>(-0.5321, 0.0453, 0.8455, 0.1135), vec4<f32>(0.3282, 0.4268, 0.8427, 0.1074),+ vec4<f32>(0.2402, -0.6651, 0.7071, 0.6653), vec4<f32>(-0.5305, -0.0518, 0.8461, 0.1578),+ vec4<f32>(0.1183, -0.5102, 0.8519, 0.5489), vec4<f32>(0.2317, -0.4575, 0.8585, 0.5489),+ vec4<f32>(0.3883, 0.3573, 0.8495, 0.1523), vec4<f32>(-0.5134, -0.0525, 0.8565, 0.1609),+ vec4<f32>(0.0252, -0.2758, 0.9609, 0.3798), vec4<f32>(0.1526, -0.2157, 0.9645, 0.3784),+ vec4<f32>(0.3772, 0.3440, 0.8599, 0.1556), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),+ vec4<f32>(-0.9247, -0.3807, 0.0000, 0.0756), vec4<f32>(-0.2425, 0.9701, 0.0000, -0.6864),+ vec4<f32>(0.3162, -0.9487, 0.0000, 1.0530), vec4<f32>(0.9162, 0.4008, 0.0000, 0.1535),+ vec4<f32>(-0.6951, -0.2862, 0.6594, 0.1360), vec4<f32>(-0.1823, 0.7293, 0.6594, -0.4369),+ vec4<f32>(-0.6008, -0.1704, 0.7810, 0.0920), vec4<f32>(-0.2671, 0.5255, 0.8078, -0.3007),+ vec4<f32>(0.2377, -0.7132, 0.6594, 0.8708), vec4<f32>(-0.5558, -0.3051, 0.7733, 0.2145),+ vec4<f32>(0.0695, -0.6055, 0.7928, 0.7235), vec4<f32>(0.6887, 0.3013, 0.6594, 0.1945),+ vec4<f32>(0.3049, -0.5129, 0.8024, 0.7420), vec4<f32>(0.5987, 0.1809, 0.7803, 0.2685),+ vec4<f32>(0.5498, 0.3206, 0.7713, 0.1366), vec4<f32>(-0.0211, 0.6144, 0.7887, -0.2831),+ vec4<f32>(-0.5531, -0.1469, 0.8200, 0.0945), vec4<f32>(-0.2350, 0.3241, 0.9164, -0.1346),+ vec4<f32>(-0.5001, -0.2865, 0.8172, 0.2243), vec4<f32>(-0.0196, -0.4001, 0.9163, 0.5194),+ vec4<f32>(0.2515, -0.2926, 0.9226, 0.5389), vec4<f32>(0.5634, 0.1624, 0.8101, 0.2721),+ vec4<f32>(0.5203, 0.3103, 0.7956, 0.1356), vec4<f32>(0.0413, 0.4381, 0.8980, -0.1238),vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500), vec4<f32>(0.0000, -1.0000, 0.0000, 0.7200),vec4<f32>(-1.0000, 0.0000, 0.0000, 0.1400), vec4<f32>(1.0000, 0.0000, 0.0000, 0.1400),vec4<f32>(0.7682, 0.6402, 0.0000, 0.0499), vec4<f32>(0.0000, 1.0000, 0.0000, 0.0000),@@ -1036,10 +1040,10 @@ const GEM_PLANES = array<vec4<f32>, 182>(vec4<f32>(-0.0779, -0.2355, 0.9688, 0.4421), vec4<f32>(-0.1668, -0.2549, 0.9525, 0.4530),vec4<f32>(0.1324, -0.1566, 0.9787, 0.4232), vec4<f32>(0.1566, -0.1906, 0.9691, 0.4552));-const GEM_PIECE = array<i32, 9>(0, 14, 32, 53, 77, 101, 124, 149, 182);+const GEM_PIECE = array<i32, 9>(0, 17, 42, 63, 87, 111, 134, 159, 192);const GEM_BOX = array<vec3<f32>, 4>(- vec3<f32>(0.320, -0.485, 0.165),- vec3<f32>(0.350, 0.525, 0.125),+ vec3<f32>(0.340, -0.485, 0.160),+ vec3<f32>(0.370, 0.525, 0.120),vec3<f32>(0.107, -0.500, 0.175),vec3<f32>(0.487, 0.510, 0.135));@@ -1116,7 +1120,7 @@ fn sculpt_eval(q: vec3<f32>, occ: bool) -> vec2<f32> {let p = sculpt_point(q);var r: vec2<f32>;if occ && theme == 3 {- let d2 = select(s_pixel_hand_dist(p.xy), s_arrow2(p.xy) - 1.2 * SCULPT_VOX, shape == 0);+ let d2 = s_pixel_outline(p.xy, shape);let dz = abs(p.z - (SCULPT_HOVER + 0.07)) - 0.07;r = vec2<f32>(length(max(vec2<f32>(d2, dz), vec2<f32>(0.0))) + min(max(d2, dz), 0.0), 7.0);} else {@@ -1201,14 +1205,14 @@ struct SculptMat {}fn s_pixel_colour(p: vec3<f32>, shape: i32) -> vec3<f32> {- let id = floor((p.xy - s_grid_origin(shape)) / SCULPT_VOX);- if !s_occ(id + vec2<f32>(-1.0, 0.0), shape) || !s_occ(id + vec2<f32>(0.0, -1.0), shape) {- return s_lin(0.52, 0.91, 0.77);+ let cell = s_pix_cell(p.xy, shape);+ if s_pix_mint(shape, cell.x, cell.y) {+ return s_lin(0.30, 0.82, 0.58);}- if !s_occ(id + vec2<f32>(1.0, 0.0), shape) || !s_occ(id + vec2<f32>(0.0, 1.0), shape) {- return s_lin(1.0, 0.78, 0.87);+ if !s_pix_body(shape, cell.x, cell.y - 1) {+ return s_lin(1.0, 0.76, 0.76);}- return s_lin(1.0, 0.50, 0.71);+ return s_lin(1.0, 0.40, 0.62);}fn sculpt_material(mat: f32, p: vec3<f32>, theme: i32, shape: i32) -> SculptMat {@@ -1247,9 +1251,9 @@ fn sculpt_material(mat: f32, p: vec3<f32>, theme: i32, shape: i32) -> SculptMatreturn SculptMat(s_lin(0.07, 0.15, 0.33), 0.7, 0.15, 0.05, 0.08);}if mat < 6.5 {- return SculptMat(s_pixel_colour(p, shape), 0.45, 0.35, 0.15, 0.2);+ return SculptMat(s_pixel_colour(p, shape), 0.45, 0.3, 0.15, 0.12);}- return SculptMat(s_lin(0.36, 0.18, 0.54), 0.45, 0.35, 0.1, 0.2);+ return SculptMat(s_lin(0.22, 0.13, 0.33), 0.65, 0.15, 0.05, 0.06);}fn model_env(d: vec3<f32>, rough: f32, l: vec3<f32>, fill: vec3<f32>) -> vec3<f32> {diff --git a/design/cursors/3d-direction.md b/design/cursors/3d-direction.mdindex ed7c55d99..aaf78af7e 100644--- a/design/cursors/3d-direction.md+++ b/design/cursors/3d-direction.md@@ -13,9 +13,9 @@ compositor's beveled extrusion.| Theme | Arrow model | Hand model || --- | --- | --- || Studio Ink | Black rim, a raised ivory band, a recessed satin black field. | Ivory glove cushion in a black rim, black ridges between the fingers. |-| Prism Glow | Cut crystal: flat facets, a polygonal silhouette, cyan, deep blue and violet facets with bright edges. | A cut gem after `3d-concept.png`: an index column, three fingers side by side, the thumb and a faceted palm on one slab. |+| Prism Glow | A cut gem after `3d-concept.png`: a wide girdle, a crown fanning out from one point, a chunky tail; cyan, deep blue and violet facets with bright edges. | The same cut: an index column, three fingers side by side, the thumb and a faceted palm on one slab. || Pop Coral | Coral cushion in a navy rim, a yellow layer behind it offset down-left, two yellow click dashes. | Yellow glove cushion in a navy rim, two coral click dashes. |-| Pixel Candy | Beveled voxels: a pink face with mint and pale pink edges, purple blocks one step behind. | Voxel glove with the same colours and purple back layer. |+| Pixel Candy | Voxels drawn after `3d-concept.png`: a pink face, mint voxels down the left edge and the tail, pale pink step tops, a purple ring one voxel wide set a little behind. | A voxel hand in the same colours: the index, the other fingers apart, the thumb, mint down the lower-left edge. || Star Sprout | Glossy mint cushion framed by the navy outline of its drawing, carrying a star with a face and two leaves. | Ivory glove cushion in the same navy frame, navy ridges between the fingers, a mint cuff and the same star. |Studio Ink, Pop Coral and Star Sprout keep their drawn outline, as in@@ -36,9 +36,9 @@ click and size changes.To change a model, edit it in all three shaders (`sculpt_proto`,`sculpt_material`) and keep `sculpt.rs` in step: its boxes must contain the-shapes, and a test checks that the shaders mirror its constants. Pixel Candy's-arrow voxels are sampled from the arrow polygon; `sculpt.rs` says how. Prism-Glow's pieces are convex polyhedra described in-`scripts/generate-prism-glow-gem.mjs`, which writes their planes into the three-shaders; change a piece there and run it, and a test checks the three tables+shapes, and a test checks that the shaders mirror its constants. Two themes are+tables written by scripts: Pixel Candy's voxel grids+(`scripts/generate-pixel-candy-voxels.mjs`) and Prism Glow's convex pieces+(`scripts/generate-prism-glow-gem.mjs`). Change the grid or the piece there and+run the script; it rewrites all three shaders, and tests check the tablesagree.diff --git a/design/cursors/requirements.md b/design/cursors/requirements.mdindex 44f189fc7..f9d9f864f 100644--- a/design/cursors/requirements.md+++ b/design/cursors/requirements.md@@ -43,7 +43,7 @@ their 3D models.| Studio Ink | Black rim, raised ivory band, recessed satin black field. | Ivory glove cushion; the black outline stays as a physical rim, with black ridges between the fingers. || Prism Glow | Translucent faceted crystal; no navy ink contour. | Crystal palm and distinct faceted fingers; no navy ink contour. || Pop Coral | Coral cushion in a navy rim; the yellow offset becomes a layer behind it; the click dashes become physical pieces. | Yellow glove cushion in a navy rim; the coral click dashes become physical pieces. |-| Pixel Candy | Keep the stepped voxel form; purple is side/back blocks, not a flat outline. | Stepped voxel fingers and palm; preserve purple as physical side/back blocks. |+| Pixel Candy | Keep the stepped voxel form; purple is a ring of physical blocks set behind the face, not a flat outline. | Stepped voxel fingers and palm; preserve purple as a physical ring of blocks behind the face. || Star Sprout | Puffy mint cushion; the navy outline stays as a physical rim (a navy tray and a rounded bead) around it, the star and its leaves in front, each in its own navy rim. | Puffy ivory glove in the same navy rim, with navy ridges between the fingers; separate mint cuff framed in navy; the star and leaves in front, as in `star-sprout/3d-reference.png`. |The 2D PNG may keep a drawn contour where it helps readability. Its contourdiff --git a/docs/3d-effects-v2.md b/docs/3d-effects-v2.mdindex e1103e551..d84f2a7f5 100644--- a/docs/3d-effects-v2.md+++ b/docs/3d-effects-v2.md@@ -300,6 +300,10 @@ main) sont des polyèdres convexes, le max des plans de leurs faces : une table`scripts/generate-prism-glow-gem.mjs` calcule (enveloppe convexe de points posés à la main) etécrit dans les trois shaders. Le verre luit de lui-même, chaque facette prend sa teinte de sonorientation, et les arêtes vives s'allument (`s_gem_glint`).+Les voxels de Pixel Candy suivent deux grilles dessinées d'après la planche+(`scripts/generate-pixel-candy-voxels.mjs`, qui les écrit de même) : la face rose et ses voxels+menthe, le dessus des marches en rose pâle, et un anneau violet d'un voxel, en retrait derrière la+face.- **Éclairage**, sprites extrudés compris : une lampe proche en haut à gauche, qui met un dégradéet un reflet même sur une face plane ; une lumière d'appoint faible ; le côté ombré teinté pardiff --git a/scripts/generate-pixel-candy-voxels.mjs b/scripts/generate-pixel-candy-voxels.mjsnew file mode 100644index 000000000..d713e91fd--- /dev/null+++ b/scripts/generate-pixel-candy-voxels.mjs@@ -0,0 +1,209 @@+// Voxel grids of the Pixel Candy 3D cursors (mode 15, theme 3).+// Run with `node scripts/generate-pixel-candy-voxels.mjs` after changing a grid below: it rewrites+// the PIX_* tables of the three compositor shaders, between their `<pixel-candy-voxels>` markers.+//+// A grid is drawn after the reference sheet (design/cursors/3d-concept.png), row 0 at the top:+// `P` a pink voxel, `M` a mint one, `.` nothing. The purple ring is not drawn: it is every empty+// cell that touches a voxel, sides and corners, and stands a little behind the face. The hotspot+// (prototype origin, see crates/compositor/src/sculpt.rs) is the top-left corner of the arrow's+// first voxel and the top middle of the index.++import { readFile, writeFile } from "node:fs/promises";+import path from "node:path";+import { fileURLToPath } from "node:url";++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");+const SHADERS = path.join(ROOT, "crates", "compositor", "src");+// Mirrors SCULPT_VOX in the shaders and VOX in sculpt.rs.+const VOX = 0.07;++const ARROW = {+ origin: [0, 0],+ grid: [+ "P......",+ "PP.....",+ "PPP....",+ "PPPP...",+ "PPPPP..",+ "MPPPPP.",+ "MPPPPPP",+ "MPPPP..",+ "MP.MP..",+ "MM.MPP.",+ "M...MPP",+ ".....MP",+ ],+};++const HAND = {+ origin: [-4 * VOX, 0],+ grid: [+ "...PP........",+ "...PP........",+ "...PP........",+ "...PP........",+ "...PP.PP.....",+ "...PP.PP.PP..",+ "PP.PP.PP.PPPP",+ "MPPPPPPPPPPPP",+ ".MPPPPPPPPPPP",+ "..MPPPPPPPPPP",+ "...MPPPPPPPP.",+ "....MPPPPPP..",+ ".....MPPPP...",+ ],+};++const SHAPES = [ARROW, HAND];++function masks({ grid }) {+ const cols = grid[0].length;+ const rows = grid.length;+ const at = (c, r) => r >= 0 && r < rows && c >= 0 && c < cols && grid[r][c] !== ".";+ const body = grid.map((line) =>+ [...line].reduce((m, ch, c) => (ch === "." ? m : m | (1 << c)), 0),+ );+ const mint = grid.map((line) =>+ [...line].reduce((m, ch, c) => (ch === "M" ? m | (1 << c) : m), 0),+ );+ const ring = [];+ for (let r = -1; r <= rows; r++) {+ let m = 0;+ for (let c = -1; c <= cols; c++) {+ if (at(c, r)) continue;+ let touches = false;+ for (let j = -1; j <= 1; j++) for (let i = -1; i <= 1; i++) touches ||= at(c + i, r + j);+ if (touches) m |= 1 << (c + 1);+ }+ ring.push(m);+ }+ return { cols, rows, body, mint, ring };+}++// Face and ring as rectangles (centre, half size, prototype units): each row's runs, merged with+// the rows below while the run stays the same. The shadow uses their exact outline.+function rects({ origin }, { cols, rows, body, ring }) {+ const full = ring.map((m, i) => m | ((i >= 1 && i <= rows ? body[i - 1] : 0) << 1));+ const runs = full.map((m) => {+ const out = [];+ for (let c = 0; c < cols + 2; c++) {+ if (!(m & (1 << c))) continue;+ const start = c;+ while (c + 1 < cols + 2 && m & (1 << (c + 1))) c++;+ out.push([start, c]);+ }+ return out;+ });+ const open = [];+ const done = [];+ runs.forEach((row, r) => {+ for (const box of open.splice(0)) {+ const k = row.findIndex(([a, b]) => a === box.a && b === box.b);+ if (k >= 0) {+ box.r1 = r;+ row.splice(k, 1);+ open.push(box);+ } else done.push(box);+ }+ for (const [a, b] of row) open.push({ a, b, r0: r, r1: r });+ });+ done.push(...open);+ return done.map(({ a, b, r0, r1 }) => {+ const x0 = origin[0] + (a - 1) * VOX;+ const x1 = origin[0] + b * VOX;+ const y0 = origin[1] - (r1 - 1 + 1) * VOX;+ const y1 = origin[1] - (r0 - 1) * VOX;+ return [(x0 + x1) / 2, (y0 + y1) / 2, (x1 - x0) / 2, (y1 - y0) / 2];+ });+}++const data = SHAPES.map((s) => ({ shape: s, ...masks(s) }));+const boxes = data.map((d) => rects(d.shape, d));+const grid = [];+let bodyAt = 0;+let ringAt = 0;+for (const d of data) {+ grid.push([d.cols, d.rows, bodyAt, ringAt]);+ bodyAt += d.rows;+ ringAt += d.rows + 2;+}+const rectStarts = boxes.reduce((s, b) => [...s, s[s.length - 1] + b.length], [0]);+// Bounding box of face and ring (centre, half size), for the bound away from the grid.+const bounds = boxes.map((list) => {+ const x0 = Math.min(...list.map((b) => b[0] - b[2]));+ const x1 = Math.max(...list.map((b) => b[0] + b[2]));+ const y0 = Math.min(...list.map((b) => b[1] - b[3]));+ const y1 = Math.max(...list.map((b) => b[1] + b[3]));+ return [(x0 + x1) / 2, (y0 + y1) / 2, (x1 - x0) / 2, (y1 - y0) / 2];+});++const num = (v) => {+ const s = v.toFixed(4);+ return Number(s) === 0 ? "0.0" : s.replace(/0+$/, "").replace(/\.$/, ".0");+};++function block(lang) {+ const t = {+ wgsl: { i4: "vec4<i32>", f2: "vec2<f32>", f4: "vec4<f32>" },+ hlsl: { i4: "int4", f2: "float2", f4: "float4" },+ metal: { i4: "int4", f2: "float2", f4: "float4" },+ }[lang];+ const vec = (type, v) =>+ `${type}(${v.map((x) => (type === t.i4 ? String(x) : num(x))).join(", ")})`;+ const ints = (list) => list.join(", ");+ const tables = [+ ["PIX_BODY", "i32", data.flatMap((d) => d.body)],+ ["PIX_MINT", "i32", data.flatMap((d) => d.mint)],+ ["PIX_RING", "i32", data.flatMap((d) => d.ring)],+ ["PIX_RECT_N", "i32", rectStarts],+ ];+ const vectors = [+ ["PIX_GRID", t.i4, grid],+ ["PIX_ORIGIN", t.f2, SHAPES.map((s) => s.origin)],+ ["PIX_BOX", t.f4, bounds],+ ["PIX_RECT", t.f4, boxes.flat()],+ ];+ if (lang === "wgsl") {+ return [+ ...tables.map(([n, ty, v]) => `const ${n} = array<${ty}, ${v.length}>(${ints(v)});`),+ ...vectors.map(+ ([n, ty, v]) =>+ `const ${n} = array<${ty}, ${v.length}>(\n ${v.map((x) => vec(ty, x)).join(",\n ")}\n);`,+ ),+ ].join("\n");+ }+ const decl = lang === "hlsl" ? "static const" : "constant";+ const scalar = { i32: "int" };+ return [+ ...tables.map(([n, ty, v]) => `${decl} ${scalar[ty]} ${n}[${v.length}] = { ${ints(v)} };`),+ ...vectors.map(+ ([n, ty, v]) =>+ `${decl} ${ty} ${n}[${v.length}] = {\n ${v.map((x) => vec(ty, x)).join(",\n ")}\n};`,+ ),+ ].join("\n");+}++const targets = [+ ["vk_shaders/layer.wgsl", "wgsl"],+ ["shaders.hlsl", "hlsl"],+ ["shaders.metal", "metal"],+];+const marked = /(\/\/ <pixel-candy-voxels>\n)[\s\S]*?(\/\/ <\/pixel-candy-voxels>)/;+const sources = await Promise.all(+ targets.map(([file]) => readFile(path.join(SHADERS, file), "utf8")),+);+targets.forEach(([file], i) => {+ if (!marked.test(sources[i])) throw new Error(`${file}: no <pixel-candy-voxels> markers`);+});+for (const [i, [file, lang]] of targets.entries()) {+ const src = sources[i].replace(marked, (_, open, close) => `${open}${block(lang)}\n${close}`);+ await writeFile(path.join(SHADERS, file), src);+}+console.log(+ data+ .map(+ (d, i) =>+ `${["arrow", "hand"][i]}: ${d.cols}×${d.rows} voxels, ${boxes[i].length} shadow rects`,+ )+ .join("; "),+);diff --git a/scripts/generate-prism-glow-gem.mjs b/scripts/generate-prism-glow-gem.mjsindex 3f0a90ce0..591eab180 100644--- a/scripts/generate-prism-glow-gem.mjs+++ b/scripts/generate-prism-glow-gem.mjs@@ -17,28 +17,45 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");const SHADERS = path.join(ROOT, "crates", "compositor", "src");const HOVER = 0.05;-// The arrow: a head and a tail, each a slab whose every edge carries a wall, a steep girdle-// facet and two crown facets that meet over the middle of the edge.-const ARROW_Z0 = HOVER + 0.03;+// Both models follow the reference sheet (design/cursors/3d-concept.png) and are built the same+// way. A piece is its outline (convex, counter-clockwise), the top of its wall `zg`, a crown ring+// inset by `c` at `zc` (its edge midpoints raised by `lift`, which splits every crown facet in+// two), and the points its facets rise to; the piece is the convex hull of all of them.++// The arrow: a head with a wide girdle and a crown that fans out from one point, and the tail.const ARROW = [- [- [-0.02, 0.03],- [-0.02, -0.88],- [0.66, -0.61],- ],- [- [0.215, -0.665],- [0.37, -1.0],- [0.53, -0.93],- [0.38, -0.6],- ],+ {+ name: "head",+ outline: [+ [-0.02, 0.03],+ [-0.02, -0.88],+ [0.7, -0.62],+ ],+ zg: 0.12,+ c: 0.07,+ zc: 0.17,+ lift: 0.02,+ tops: [[0.18, -0.42, 0.27]],+ },+ {+ name: "tail",+ outline: [+ [0.19, -0.66],+ [0.33, -1.0],+ [0.57, -0.92],+ [0.43, -0.6],+ ],+ zg: 0.12,+ c: 0.05,+ zc: 0.165,+ lift: 0.012,+ tops: [[0.38, -0.79, 0.23]],+ },];-// The hand, after the reference sheet (design/cursors/3d-concept.png): an index column, three-// fingers side by side, the thumb and the palm, all on the same slab. A piece is its outline-// (convex, counter-clockwise), the top of its wall `zg`, a crown ring inset by `c` at `zc`, and-// the points its facets rise to. The fingers stand higher than the palm where they overlap it,-// so their crease with the palm is the knuckle line.+// The hand: an index column, three fingers side by side, the thumb and the palm, all on the same+// slab. The fingers stand higher than the palm where they overlap it, so their crease with the+// palm is the knuckle line.const HAND = [{name: "index",@@ -176,23 +193,6 @@ function edgeFrame(a, b) {return { len, d, inward: [-d[1], d[0]] };}-function arrowPiece(outline) {- const z0 = ARROW_Z0;- const planes = [plane([0, 0, 1], z0 + 0.2), plane([0, 0, -1], -(z0 - 0.03))];- outline.forEach((a, i) => {- const { len, d, inward: m } = edgeFrame(a, outline[(i + 1) % outline.length]);- const am = a[0] * m[0] + a[1] * m[1];- const ad = a[0] * d[0] + a[1] * d[1];- planes.push(plane([-m[0], -m[1], 0], -am));- planes.push(plane([-2.2 * m[0], -2.2 * m[1], 1], z0 + 0.035 - 2.2 * am));- for (const s of [1, -1]) {- const n = [-0.6 * m[0] + 0.18 * s * d[0], -0.6 * m[1] + 0.18 * s * d[1], 1];- planes.push(plane(n, z0 + 0.07 - 0.6 * am + 0.18 * s * (ad + 0.5 * len)));- }- });- return planes;-}-// The outline moved inward by `c`: the offset edges, each crossed with the previous one.function inset(outline, c) {const lines = outline.map((a, i) => {@@ -207,11 +207,19 @@ function inset(outline, c) {});}-function handPoints({ outline, zg, c, zc, tops }) {+function gemPoints({ outline, zg, c, zc, lift = 0, tops }) {+ const ring = inset(outline, c);+ const mids = lift+ ? ring.map(([x, y], i) => {+ const [u, v] = ring[(i + 1) % ring.length];+ return [(x + u) / 2, (y + v) / 2, zc + lift];+ })+ : [];return [...outline.map(([x, y]) => [x, y, HOVER]),...outline.map(([x, y]) => [x, y, zg]),- ...inset(outline, c).map(([x, y]) => [x, y, zc]),+ ...ring.map(([x, y]) => [x, y, zc]),+ ...mids,...tops,];}@@ -242,14 +250,10 @@ function box(points) {return [lo.map((v, i) => (v + hi[i]) / 2), lo.map((v, i) => (hi[i] - v) / 2 + 0.01)];}-const pieces = [...ARROW.map(arrowPiece), ...HAND.map((h) => hullPlanes(handPoints(h)))];+const pieces = [...ARROW, ...HAND].map((piece) => hullPlanes(gemPoints(piece)));const planes = pieces.flat();const starts = pieces.reduce((s, p) => [...s, s[s.length - 1] + p.length], [0]);-const arrowPoints = ARROW.flat().flatMap(([x, y]) => [- [x, y, HOVER],- [x, y, ARROW_Z0 + 0.2],-]);-const boxes = [...box(arrowPoints), ...box(HAND.flatMap(handPoints))];+const boxes = [...box(ARROW.flatMap(gemPoints)), ...box(HAND.flatMap(gemPoints))];const num = (v, digits) => {const s = v.toFixed(digits);@@ -305,5 +309,5 @@ for (const [i, [file, lang]] of targets.entries()) {await writeFile(path.join(SHADERS, file), src);}console.log(- `${planes.length} planes: ${HAND.map((h, i) => `${h.name} ${pieces[i + 2].length}`).join(", ")}`,+ `${planes.length} planes: ${[...ARROW, ...HAND].map((g, i) => `${g.name} ${pieces[i].length}`).join(", ")}`,);